@wonderwhy-er/desktop-commander 0.2.42 → 0.2.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/handlers/filesystem-handlers.js +2 -1
- package/dist/remote-device/remote-channel.d.ts +14 -0
- package/dist/remote-device/remote-channel.js +107 -28
- package/dist/server.d.ts +5 -1
- package/dist/server.js +65 -14
- package/dist/terminal-manager.d.ts +18 -0
- package/dist/terminal-manager.js +84 -18
- package/dist/tools/edit.js +4 -3
- package/dist/tools/fuzzySearch.d.ts +10 -20
- package/dist/tools/fuzzySearch.js +66 -105
- package/dist/tools/fuzzySearchCore.d.ts +52 -0
- package/dist/tools/fuzzySearchCore.js +125 -0
- package/dist/tools/improved-process-tools.js +8 -1
- package/dist/tools/schemas.d.ts +20 -0
- package/dist/tools/schemas.js +45 -2
- package/dist/types.d.ts +3 -1
- package/dist/ui/file-preview/preview-runtime.js +5 -5
- package/dist/ui/file-preview/src/directory-controller.js +3 -3
- package/dist/ui/file-preview/src/file-type-handlers.js +2 -2
- package/dist/ui/file-preview/src/markdown/controller.js +3 -1
- package/dist/ui/file-preview/src/panel-actions.js +2 -2
- package/dist/utils/capture.js +13 -7
- package/dist/utils/unsupportedParams.d.ts +24 -0
- package/dist/utils/unsupportedParams.js +66 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -1
|
@@ -88,7 +88,7 @@ for compatibility with Zod schema generation. Both are functionally equivalent f
|
|
|
88
88
|
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:y.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:y.string().optional().describe("User's timezone in IANA format."),userAgent:y.string().optional().describe("Host application identifier."),platform:y.union([y.literal("web"),y.literal("desktop"),y.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:y.object({touch:y.boolean().optional().describe("Whether the device supports touch input."),hover:y.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:y.object({top:y.number().describe("Top safe area inset in pixels."),right:y.number().describe("Right safe area inset in pixels."),bottom:y.number().describe("Bottom safe area inset in pixels."),left:y.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),n8=y.object({method:y.literal("ui/notifications/host-context-changed"),params:x$.describe("Partial context update containing only changed fields.")}),tQ=y.object({method:y.literal("ui/update-model-context"),params:y.object({content:y.array(Yi).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:y.record(y.string(),y.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),nQ=y.object({method:y.literal("ui/initialize"),params:y.object({appInfo:fs.describe("App identification (name and version)."),appCapabilities:YL.describe("Features and capabilities this app provides."),protocolVersion:y.string().describe("Protocol version this app supports.")})}),r8=y.object({protocolVersion:y.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:fs.describe("Host application identification and version."),hostCapabilities:XL.describe("Features and capabilities provided by the host."),hostContext:x$.describe("Rich context about the host environment.")}).passthrough();function k$(e){let t=document.documentElement;t.setAttribute("data-theme",e),t.style.colorScheme=e}function _$(e,t=document.documentElement){for(let[n,i]of Object.entries(e))i!==void 0&&t.style.setProperty(n,i)}function w$(e){if(document.getElementById("__mcp-host-fonts"))return;let t=document.createElement("style");t.id="__mcp-host-fonts",t.textContent=e,document.head.appendChild(t)}var Yl=class extends Rl{constructor(n,i={},r={autoResize:!0}){super(r);It(this,"_appInfo");It(this,"_capabilities");It(this,"options");It(this,"_hostCapabilities");It(this,"_hostInfo");It(this,"_hostContext");It(this,"sendOpenLink",this.openLink);this._appInfo=n,this._capabilities=i,this.options=r,this.setRequestHandler(Gi,o=>(console.log("Received ping:",o.params),{})),this.onhostcontextchanged=()=>{}}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}set ontoolinput(n){this.setNotificationHandler(qL,i=>n(i.params))}set ontoolinputpartial(n){this.setNotificationHandler(WL,i=>n(i.params))}set ontoolresult(n){this.setNotificationHandler(t8,i=>n(i.params))}set ontoolcancelled(n){this.setNotificationHandler(VL,i=>n(i.params))}set onhostcontextchanged(n){this.setNotificationHandler(n8,i=>{this._hostContext={...this._hostContext,...i.params},n(i.params)})}set onteardown(n){this.setRequestHandler(GL,(i,r)=>n(i.params,r))}set oncalltool(n){this.setRequestHandler(xp,(i,r)=>n(i.params,r))}set onlisttools(n){this.setRequestHandler(yp,(i,r)=>n(i.params,r))}assertCapabilityForMethod(n){}assertRequestHandlerCapability(n){switch(n){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${n})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${n} registered`)}}assertNotificationCapability(n){}assertTaskCapability(n){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(n){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(n,i){return await this.request({method:"tools/call",params:n},Qi,i)}sendMessage(n,i){return this.request({method:"ui/message",params:n},HL,i)}sendLog(n){return this.notification({method:"notifications/message",params:n})}updateModelContext(n,i){return this.request({method:"ui/update-model-context",params:n},El,i)}openLink(n,i){return this.request({method:"ui/open-link",params:n},ZL,i)}requestDisplayMode(n,i){return this.request({method:"ui/request-display-mode",params:n},QL,i)}sendSizeChanged(n){return this.notification({method:"ui/notifications/size-changed",params:n})}setupSizeChangedNotifications(){let n=!1,i=0,r=0,o=()=>{n||(n=!0,requestAnimationFrame(()=>{n=!1;let a=document.documentElement,l=a.style.width,u=a.style.height;a.style.width="fit-content",a.style.height="fit-content";let c=a.getBoundingClientRect();a.style.width=l,a.style.height=u;let d=window.innerWidth-a.clientWidth,f=Math.ceil(c.width+d),p=Math.ceil(c.height);(f!==i||p!==r)&&(i=f,r=p,this.sendSizeChanged({width:f,height:p}))}))};o();let s=new ResizeObserver(o);return s.observe(document.documentElement),s.observe(document.body),()=>s.disconnect()}async connect(n=new wp(window.parent,window.parent),i){await super.connect(n);try{let r=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:cO}},r8,i);if(r===void 0)throw Error(`Server sent invalid initialize result: ${r}`);this._hostCapabilities=r.hostCapabilities,this._hostInfo=r.hostInfo,this._hostContext=r.hostContext,await this.notification({method:"ui/notifications/initialized"}),this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(r){throw this.close(),r}}};var i8='<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M7 10l5 5 5-5z"></path></svg>',o8='<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M7 14l5-5 5 5z"></path></svg>';function s8(e,t){if(!e)return;let n=t?"Collapse":"Expand";e.title=n,e.setAttribute("aria-label",n),e.innerHTML=t?o8:i8}function a8(e,t){e&&(e.classList.toggle("expanded",t),e.classList.toggle("collapsed",!t))}function l8(e){let{shell:t,toggleButton:n,initialExpanded:i,onToggle:r,onScrollAfterExpand:o,onRender:s}=e,a=i,l=!1,u=typeof o=="function",c=p=>{let h=a;a=p,a8(t,a),s8(n,a),!h&&a&&(l=!1)},d=()=>{c(!a),r?.(a),s?.()},f=p=>{if(!a||l)return;let h=p?.target instanceof Node?p.target:null;h&&t&&!t.contains(h)||(l=!0,o?.())};return c(a),n?.addEventListener("click",d),u&&(t?.addEventListener("scroll",f,{passive:!0}),document.addEventListener("scroll",f,{passive:!0,capture:!0})),{getExpanded:()=>a,setExpanded:c,toggle:d,dispose:()=>{n?.removeEventListener("click",d),u&&(t?.removeEventListener("scroll",f),document.removeEventListener("scroll",f,!0))}}}function S$(e){let{shell:t,compactRow:n,initialExpanded:i,onToggle:r,onScrollAfterExpand:o,onRender:s}=e,a=l8({shell:t,toggleButton:null,initialExpanded:i,onToggle:c=>{n?.setAttribute("aria-expanded",String(c)),r?.(c)},onScrollAfterExpand:o,onRender:s});n?.setAttribute("aria-expanded",String(i));let l=()=>{a.toggle()},u=c=>{c.key!=="Enter"&&c.key!==" "||(c.preventDefault(),a.toggle())};return n?.addEventListener("click",l),n?.addEventListener("keydown",u),{getExpanded:a.getExpanded,setExpanded:a.setExpanded,toggle:a.toggle,dispose:()=>{n?.removeEventListener("click",l),n?.removeEventListener("keydown",u),a.dispose()}}}var E$="desktop-commander:widget-state",Im="__dc_widget_id__:";function u8(){let e=typeof globalThis.crypto=="object"?globalThis.crypto:void 0;return typeof e?.randomUUID=="function"?e.randomUUID():`widget-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function c8(e){let t=e.indexOf(Im);if(t===-1)return;let n=e.slice(t+Im.length).split("|",1)[0];if(n)try{return decodeURIComponent(n)}catch{return n}}function d8(){if(typeof window>"u")return"unknown-instance";let e=typeof window.name=="string"?window.name:"",t=c8(e);if(t)return t;let n=u8(),i=`${Im}${encodeURIComponent(n)}`;try{window.name=e?`${e}|${i}`:i}catch{}return n}function f8(){if(typeof window>"u")return`${E$}:unknown`;let e=window.location.pathname||"unknown",t=d8();return`${E$}:${e}:${encodeURIComponent(t)}`}function p8(){if(!(typeof window>"u"))try{return window.sessionStorage}catch{return}}function h8(){return typeof window<"u"&&typeof window.openai?.setWidgetState=="function"}function $$(e){if(!h8()){let t=p8(),n=f8();return{read(){if(t)try{let i=t.getItem(n);if(!i)return;let o=JSON.parse(i)?.payload;return o===void 0||e&&!e(o)?void 0:o}catch{return}},write(i){if(t)try{t.setItem(n,JSON.stringify({payload:i}))}catch{}}}}return{read(){try{let t=window.openai?.widgetState;if(t==null)return;let n=t.payload;return n===void 0||e&&!e(n)?void 0:n}catch{return}},write(t){try{window.openai?.setWidgetState?.({payload:t})}catch{}}}}function pn(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Gs(e){let t=e.variant??"ready",n=`compact-row compact-row--${t}`,i=e.id?` id="${pn(e.id)}"`:"",o=e.interactive??t==="ready"?' role="button" tabindex="0"':"",s=typeof e.expanded=="boolean"?` aria-expanded="${String(e.expanded)}"`:"",a=e.expandable?'<svg class="compact-chevron" viewBox="0 0 24 24" aria-hidden="true"><path d="M10 6l6 6-6 6z"/></svg>':"",l=e.filename?`<span class="compact-filename">${pn(e.filename)}</span>`:"";return`<div class="${n}"${i}${o}${s}>${a}<span class="compact-label">${pn(e.label)}</span>${l}</div>`}function Zu(e){return typeof e=="object"&&e!==null}function C$(e,t){if(!Zu(e))return;(e.theme==="light"||e.theme==="dark")&&k$(e.theme);let n=Zu(e.styles)?e.styles:null,i=Zu(n?.variables)?n.variables:null,r=Zu(n?.css)?n.css:null,o=typeof r?.fonts=="string"?r.fonts:null;i&&_$(i),o&&w$(o),typeof e.initiallyExpanded=="boolean"&&(t.expanded=e.initiallyExpanded),typeof e.compact=="boolean"&&typeof t.compact=="boolean"&&(t.compact=e.compact),typeof e.hideSummaryRow=="boolean"&&(t.hideSummaryRow=e.hideSummaryRow,e.hideSummaryRow&&(t.expanded=!0,typeof t.compact=="boolean"&&(t.compact=!0)))}async function T$(e){let{app:t,chrome:n,onContextApplied:i,onConnected:r}=e;t.onhostcontextchanged=s=>{C$(s,n),i?.()},await t.connect();let o=t.getHostContext();o&&(C$(o,n),i?.()),await r?.()}function m8(e){let t={};if(!e)return t;for(let[n,i]of Object.entries(e))(typeof i=="string"||typeof i=="number"||typeof i=="boolean"||i===null)&&(t[n]=i);return t}function I$(e,t){let n=t.baseParams??{};return(i,r={})=>{e("track_ui_event",{event:i,component:t.component,params:{...n,...m8(r)}}).catch(()=>{})}}var G$=Xv(K$(),1);var ot=G$.default;function X$(e){let t=e.regex,n={},i={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},i]});let r={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},o=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),s={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},a={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,r]};r.contains.push(a);let l={match:/\\"/},u={className:"string",begin:/'/,end:/'/},c={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},f=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],p=e.SHEBANG({binary:`(${f.join("|")})`,relevance:10}),h={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},m=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],g=["true","false"],b={match:/(\/[a-z._-]+)+/},v=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],x=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],_=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],E=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:m,literal:g,built_in:[...v,...x,"set","shopt",..._,...E]},contains:[p,e.SHEBANG(),h,d,o,s,b,a,l,u,c,n]}}var o9=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),s9=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],a9=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],l9=[...s9,...a9],u9=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),c9=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),d9=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),f9=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function Y$(e){let t=e.regex,n=o9(e),i={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},r="and or not only",o=/@-?\w[\w]*(-\w+)*/,s="[a-zA-Z-][a-zA-Z0-9_-]*",a=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,i,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+s,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+c9.join("|")+")"},{begin:":(:)?("+d9.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+f9.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...a,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:o},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:r,attribute:u9.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...a,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+l9.join("|")+")\\b"}]}}function Q$(e){let o={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:o,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:o,illegal:/["']/}]}]}}var ho="[0-9](_*[0-9])*",Ju=`\\.(${ho})`,Ku="[0-9a-fA-F](_*[0-9a-fA-F])*",eC={className:"number",variants:[{begin:`(\\b(${ho})((${Ju})|\\.)?|(${Ju}))[eE][+-]?(${ho})[fFdD]?\\b`},{begin:`\\b(${ho})((${Ju})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Ju})[fFdD]?\\b`},{begin:`\\b(${ho})[fFdD]\\b`},{begin:`\\b0[xX]((${Ku})\\.?|(${Ku})?\\.(${Ku}))[pP][+-]?(${ho})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Ku})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function tC(e,t,n){return n===-1?"":e.replace(t,i=>tC(e,t,n-1))}function nC(e){let t=e.regex,n="[\xC0-\u02B8a-zA-Z_$][\xC0-\u02B8a-zA-Z_$0-9]*",i=n+tC("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),l={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},u={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},c={className:"params",begin:/\(/,end:/\)/,keywords:l,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:l,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[t.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[c,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+i+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:l,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:l,relevance:0,contains:[u,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,eC,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},eC,u]}}var rC="[A-Za-z$_][0-9A-Za-z$_]*",p9=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],h9=["true","false","null","undefined","NaN","Infinity"],iC=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],oC=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],sC=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],m9=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],g9=[].concat(sC,iC,oC);function aC(e){let t=e.regex,n=(q,{after:re})=>{let pe="</"+q[0].slice(1);return q.input.indexOf(pe,re)!==-1},i=rC,r={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,s={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(q,re)=>{let pe=q[0].length+q.index,k=q.input[pe];if(k==="<"||k===","){re.ignoreMatch();return}k===">"&&(n(q,{after:pe})||re.ignoreMatch());let S,O=q.input.substring(pe);if(S=O.match(/^\s*=/)){re.ignoreMatch();return}if((S=O.match(/^\s+extends\s+/))&&S.index===0){re.ignoreMatch();return}}},a={$pattern:rC,keyword:p9,literal:h9,built_in:g9,"variable.language":m9},l="[0-9](_?[0-9])*",u=`\\.(${l})`,c="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${c})((${u})|\\.)?|(${u}))[eE][+-]?(${l})\\b`},{begin:`\\b(${c})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},f={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:"xml"}},h={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:"css"}},m={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:"graphql"}},g={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},v={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:i+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},x=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,h,m,g,{match:/\$\d+/},d];f.contains=x.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(x)});let _=[].concat(v,f.contains),E=_.concat([{begin:/(\s*)\(/,end:/\)/,keywords:a,contains:["self"].concat(_)}]),T={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:E},N={variants:[{match:[/class/,/\s+/,i,/\s+/,/extends/,/\s+/,t.concat(i,"(",t.concat(/\./,i),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,i],scope:{1:"keyword",3:"title.class"}}]},M={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...iC,...oC]}},H={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},ce={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[T],illegal:/%/},Ze={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Fe(q){return t.concat("(?!",q.join("|"),")")}let Ie={match:t.concat(/\b/,Fe([...sC,"super","import"].map(q=>`${q}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},ve={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Y={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},T]},A="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",Z={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(A)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[T]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:E,CLASS_REFERENCE:M},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),H,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,h,m,g,v,{match:/\$\d+/},d,M,{scope:"attr",match:i+t.lookahead(":"),relevance:0},Z,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[v,e.REGEXP_MODE,{className:"function",begin:A,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:E}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.end},{match:o},{begin:s.begin,"on:begin":s.isTrulyOpeningTag,end:s.end}],subLanguage:"xml",contains:[{begin:s.begin,end:s.end,skip:!0,contains:["self"]}]}]},ce,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[T,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},ve,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[T]},Ie,Ze,N,Y,{match:/\$[(.]/}]}}function lC(e){let t={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},i=["true","false","null"],r={scope:"literal",beginKeywords:i.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:i},contains:[t,n,e.QUOTE_STRING_MODE,r,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function uC(e){let t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},i={begin:"^[-\\*]{3,}",end:"$"},r={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},o={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},s={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},a=/[A-Za-z][A-Za-z0-9+.-]*/,l={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,a,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},u={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},c={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},d=e.inherit(u,{contains:[]}),f=e.inherit(c,{contains:[]});u.contains.push(f),c.contains.push(d);let p=[n,l];return[u,c,d,f].forEach(b=>{b.contains=b.contains.concat(p)}),p=p.concat(u,c),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:p},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:p}]}]},n,o,u,c,{className:"quote",begin:"^>\\s+",contains:p,end:"$"},r,i,l,s,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function cC(e){let t=e.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,i=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],a={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:i,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},l={className:"meta",begin:/^(>>>|\.\.\.) /},u={className:"subst",begin:/\{/,end:/\}/,keywords:a,illegal:/#/},c={begin:/\{\{/,relevance:0},d={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,l],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,l],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,l,c,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,l,c,u]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,c,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,c,u]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},f="[0-9](_?[0-9])*",p=`(\\b(${f}))?\\.(${f})|\\b(${f})\\.`,h=`\\b|${i.join("|")}`,m={className:"number",relevance:0,variants:[{begin:`(\\b(${f})|(${p}))[eE][+-]?(${f})[jJ]?(?=${h})`},{begin:`(${p})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${h})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${h})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${h})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${h})`},{begin:`\\b(${f})[jJ](?=${h})`}]},g={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:a,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},b={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:["self",l,m,d,e.HASH_COMMENT_MODE]}]};return u.contains=[d,m,l],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:a,illegal:/(<\/|\?)|=>/,contains:[l,m,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},d,g,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[b]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[m,b,d]}]}}function dC(e){let t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",i=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),r=t.concat(i,/(::\w+)*/),s={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},a={className:"doctag",begin:"@[A-Za-z]+"},l={begin:"#<",end:">"},u=[e.COMMENT("#","$",{contains:[a]}),e.COMMENT("^=begin","^=end",{contains:[a],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],c={className:"subst",begin:/#\{/,end:/\}/,keywords:s},d={className:"string",contains:[e.BACKSLASH_ESCAPE,c],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,c]})]}]},f="[1-9](_?[0-9])*|0",p="[0-9](_?[0-9])*",h={className:"number",relevance:0,variants:[{begin:`\\b(${f})(\\.(${p}))?([eE][+-]?(${p})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},m={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:s}]},T=[d,{variants:[{match:[/class\s+/,r,/\s+<\s+/,r]},{match:[/\b(class|module)\s+/,r]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:s},{match:[/(include|extend)\s+/,r],scope:{2:"title.class"},keywords:s},{relevance:0,match:[r,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:i,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[m]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[d,{begin:n}],relevance:0},h,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:s},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,c],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(l,u),relevance:0}].concat(l,u);c.contains=T,m.contains=T;let ce=[{begin:/^\s*=>/,starts:{end:"$",contains:T}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:s,contains:T}}];return u.unshift(l),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:s,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(ce).concat(u).concat(T)}}function fC(e){let t=e.regex,n=/(r#)?/,i=t.concat(n,e.UNDERSCORE_IDENT_RE),r=t.concat(n,e.IDENT_RE),o={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,r,t.lookahead(/\s*\(/))},s="([ui](8|16|32|64|128|size)|f(32|64))?",a=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],l=["true","false","Some","None","Ok","Err"],u=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],c=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:c,keyword:a,literal:l,built_in:u},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+s},{begin:"\\b0o([0-7_]+)"+s},{begin:"\\b0x([A-Fa-f0-9_]+)"+s},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+s}],relevance:0},{begin:[/fn/,/\s+/,i],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,i],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,i,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,i],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,i],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:u,type:c}},{className:"punctuation",begin:"->"},o]}}function pC(e){let t=e.regex,n=e.COMMENT("--","$"),i={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},r={begin:/"/,end:/"/,contains:[{match:/""/}]},o=["true","false","unknown"],s=["double precision","large object","with timezone","without timezone"],a=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],l=["add","asc","collation","desc","final","first","last","view"],u=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],c=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],d=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],f=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],p=c,h=[...u,...l].filter(E=>!c.includes(E)),m={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},g={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},b={match:t.concat(/\b/,t.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function v(E){return t.concat(/\b/,t.either(...E.map(T=>T.replace(/\s+/,"\\s+"))),/\b/)}let x={scope:"keyword",match:v(f),relevance:0};function _(E,{exceptions:T,when:N}={}){let M=N;return T=T||[],E.map(H=>H.match(/\|\d+$/)||T.includes(H)?H:M(H)?`${H}|0`:H)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:_(h,{when:E=>E.length<3}),literal:o,type:a,built_in:d},contains:[{scope:"type",match:v(s)},x,b,m,i,r,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,g]}}var Gu="[A-Za-z$_][0-9A-Za-z$_]*",hC=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],mC=["true","false","null","undefined","NaN","Infinity"],gC=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],bC=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],vC=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],yC=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],xC=[].concat(vC,gC,bC);function b9(e){let t=e.regex,n=(q,{after:re})=>{let pe="</"+q[0].slice(1);return q.input.indexOf(pe,re)!==-1},i=Gu,r={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,s={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(q,re)=>{let pe=q[0].length+q.index,k=q.input[pe];if(k==="<"||k===","){re.ignoreMatch();return}k===">"&&(n(q,{after:pe})||re.ignoreMatch());let S,O=q.input.substring(pe);if(S=O.match(/^\s*=/)){re.ignoreMatch();return}if((S=O.match(/^\s+extends\s+/))&&S.index===0){re.ignoreMatch();return}}},a={$pattern:Gu,keyword:hC,literal:mC,built_in:xC,"variable.language":yC},l="[0-9](_?[0-9])*",u=`\\.(${l})`,c="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${c})((${u})|\\.)?|(${u}))[eE][+-]?(${l})\\b`},{begin:`\\b(${c})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},f={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:"xml"}},h={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:"css"}},m={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:"graphql"}},g={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},v={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:i+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},x=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,h,m,g,{match:/\$\d+/},d];f.contains=x.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(x)});let _=[].concat(v,f.contains),E=_.concat([{begin:/(\s*)\(/,end:/\)/,keywords:a,contains:["self"].concat(_)}]),T={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:E},N={variants:[{match:[/class/,/\s+/,i,/\s+/,/extends/,/\s+/,t.concat(i,"(",t.concat(/\./,i),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,i],scope:{1:"keyword",3:"title.class"}}]},M={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...gC,...bC]}},H={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},ce={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[T],illegal:/%/},Ze={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Fe(q){return t.concat("(?!",q.join("|"),")")}let Ie={match:t.concat(/\b/,Fe([...vC,"super","import"].map(q=>`${q}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},ve={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Y={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},T]},A="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",Z={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(A)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[T]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:E,CLASS_REFERENCE:M},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),H,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,h,m,g,v,{match:/\$\d+/},d,M,{scope:"attr",match:i+t.lookahead(":"),relevance:0},Z,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[v,e.REGEXP_MODE,{className:"function",begin:A,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:E}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.end},{match:o},{begin:s.begin,"on:begin":s.isTrulyOpeningTag,end:s.end}],subLanguage:"xml",contains:[{begin:s.begin,end:s.end,skip:!0,contains:["self"]}]}]},ce,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[T,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},ve,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[T]},Ie,Ze,N,Y,{match:/\$[(.]/}]}}function kC(e){let t=e.regex,n=b9(e),i=Gu,r=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],o={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},s={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:r},contains:[n.exports.CLASS_REFERENCE]},a={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},l=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],u={$pattern:Gu,keyword:hC.concat(l),literal:mC,built_in:xC.concat(r),"variable.language":yC},c={className:"meta",begin:"@"+i},d=(m,g,b)=>{let v=m.contains.findIndex(x=>x.label===g);if(v===-1)throw new Error("can not find mode to replace");m.contains.splice(v,1,b)};Object.assign(n.keywords,u),n.exports.PARAMS_CONTAINS.push(c);let f=n.contains.find(m=>m.scope==="attr"),p=Object.assign({},f,{match:t.concat(i,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,f,p]),n.contains=n.contains.concat([c,o,s,p]),d(n,"shebang",e.SHEBANG()),d(n,"use_strict",a);let h=n.contains.find(m=>m.label==="func.def");return h.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function Lm(e){let t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),i=/[\p{L}0-9._:-]+/u,r={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},o={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},s=e.inherit(o,{begin:/\(/,end:/\)/}),a=e.inherit(e.APOS_STRING_MODE,{className:"string"}),l=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),u={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:i,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[r]},{begin:/'/,end:/'/,contains:[r]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[o,l,a,s,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[o,s,l,a]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},r,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[l]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[u],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[u],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:u}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function Xu(e){let t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",i={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},r={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},o={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},s={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,r]},a=e.inherit(s,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),f={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},p={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},h={begin:/\{/,end:/\}/,contains:[p],illegal:"\\n",relevance:0},m={begin:"\\[",end:"\\]",contains:[p],illegal:"\\n",relevance:0},g=[i,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},f,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},h,m,o,s],b=[...g];return b.pop(),b.push(a),p.contains=b,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:g}}ot.registerLanguage("bash",X$);ot.registerLanguage("css",Y$);ot.registerLanguage("go",Q$);ot.registerLanguage("java",nC);ot.registerLanguage("javascript",aC);ot.registerLanguage("json",lC);ot.registerLanguage("markdown",uC);ot.registerLanguage("python",cC);ot.registerLanguage("ruby",dC);ot.registerLanguage("rust",fC);ot.registerLanguage("sql",pC);ot.registerLanguage("typescript",kC);ot.registerLanguage("xml",Lm);ot.registerLanguage("html",Lm);ot.registerLanguage("yaml",Xu);ot.registerLanguage("toml",Xu);ot.registerLanguage("ini",Xu);function _t(e){return pn(e)}function Yu(e,t){let n=(t||"").toLowerCase();if(!n||n==="text")return _t(e);try{return ot.getLanguage(n)?ot.highlight(e,{language:n,ignoreIllegals:!0}).value:ot.highlightAuto(e).value}catch{return _t(e)}}function tt(e){return e.replace(/^\[Reading [^\]]+\]\r?\n(?:\r?\n)?/,"")}function jt(e){let t=e.match(/^\[Reading (\d+) lines from (?:line )?(\d+|start) \(total: (\d+) lines/);if(!t)return;let n=Number.parseInt(t[1],10),i=t[2]==="start",r=i?0:Number.parseInt(t[2],10),o=i?1:r,s=Number.parseInt(t[3],10);return{fromLine:o,toLine:o+n-1,totalLines:s,isPartial:n<s,readOffset:r}}function Qu(e){return e.availableDisplayModes?.includes("fullscreen")?{canFullscreen:!0}:{canFullscreen:!1,reason:"Fullscreen editing is unavailable in this host."}}function _C(e){return jt(e)?.isPartial===!0}function ui(e){return typeof e=="object"&&e!==null}function Zt(e){let t=e.trim().replace(/\\/g,"/"),n=t.split("/").pop()??t,i=n.lastIndexOf(".");return i<=0||i===n.length-1?"none":n.slice(i+1).toLowerCase()}function ec(e){return ui(e)?typeof e.fileName=="string"&&typeof e.filePath=="string"&&typeof e.fileType=="string":!1}function Fm(e,t){return{...e,content:t}}function Nt(e){if(!ui(e))return;let t=e.content;if(Array.isArray(t)){for(let n of t)if(ui(n)&&n.type==="text"&&typeof n.text=="string"&&n.text.trim().length>0)return n.text}}function v9(e){if(ui(e))return typeof e.content=="string"?e.content:void 0}function tc(e){if(!ui(e))return;let t=ec(e.structuredContent)?e.structuredContent:ec(e)?e:null;if(!t)return;let n=v9(e.structuredContent)??Nt(e)??Nt(e.structuredContent)??"";return Fm(t,n)}function wC(e){if(!ui(e))throw new Error("edit_block did not return a valid result.");if(e.isError===!0){let t=Nt(e)??"";throw new Error(t||"edit_block failed.")}if(!ui(e.structuredContent)){let t=Nt(e)??"";throw new Error(t||"edit_block did not confirm success.")}}function Ir(e){return/^https?:\/\//i.test(e)}function SC(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).map(i=>_t(i)).join(' <span class="breadcrumb-sep">\u203A</span> ')}function Bm(e){let t=tt(e);if(t==="")return 0;let n=t.split(`
|
|
89
89
|
`);return n[n.length-1]===""?n.length-1:n.length}function Um(e){let t=e.split(`
|
|
90
90
|
`),n=[],i=[];for(let a of t)/^\[(DIR|FILE|DENIED|NOT_FOUND|WARNING)\]/.test(a.trim())?i.push(a.trim()):i.length===0&&n.push(a);let r=[];for(let a of i){if(a.startsWith("[WARNING]")){let p=a.replace(/^\[WARNING\]\s*/,""),h=p.indexOf(":"),m=h>=0?p.slice(0,h).trim():"",g=h>=0?p.slice(h+1).trim():p,b=m.replace(/\\/g,"/").split("/").filter(Boolean);r.push({name:m,fullPath:m,isDir:!1,isDenied:!1,isNotFound:!1,isWarning:!0,warningText:g,depth:b.length});continue}let l=a.startsWith("[DIR]"),u=a.startsWith("[DENIED]"),c=a.startsWith("[NOT_FOUND]"),d=a.replace(/^\[(DIR|FILE|DENIED|NOT_FOUND)\]\s*/,""),f=d.replace(/\\/g,"/").split("/");r.push({name:d,fullPath:d,isDir:l,isDenied:u,isNotFound:c,isWarning:!1,warningText:"",depth:f.length-1})}let o=[],s=[o];for(let a of r){let u={name:a.fullPath.replace(/\\/g,"/").split("/").pop()??a.fullPath,isDir:a.isDir,isDenied:a.isDenied,isNotFound:a.isNotFound,isWarning:a.isWarning,warningText:a.warningText,children:[],relativePath:a.fullPath};for(;s.length>a.depth+1;)s.pop();s[s.length-1].push(u),a.isDir&&s.push(u.children)}return{hint:n.join(`
|
|
91
|
-
`).trim(),entries:o}}var EC=0;function jm(e,t){if(e.length===0)return'<div class="dir-tree"><span class="dir-empty">Empty directory</span></div>';function n(i){return i.map(r=>{let o=`de-${EC++}`,s=`${t}/${r.relativePath.replace(/\\/g,"/")}`,a=_t(s);if(r.isWarning)return`<div class="dir-entry"><button class="dir-row dir-row-warning dir-load-more" data-loadpath="${a}"><span class="dir-warning-icon">\u26A0\uFE0F</span> <span class="dir-warning-text">${_t(r.warningText)} \u2014 click to load all</span></button></div>`;if(r.isDenied)return`<div class="dir-entry"><span class="dir-icon">\u{1F6AB}</span> <span class="dir-name-denied">${_t(r.name)}</span></div>`;if(r.isNotFound)return`<div class="dir-entry"><span class="dir-icon">\u2753</span> <span class="dir-name-denied">${_t(r.name)}</span></div>`;if(r.isDir){let l=r.children.length>0,u=`<span class="dir-chevron${l?" expanded":""}">${l?"\u25BC":"\u25B6"}</span>`,c=`<button class="dir-open-btn" data-openpath="${a}" title="Open in Finder">\u{1F4C2}</button>`,d=l?`<div class="dir-children" id="${o}-ch">${n(r.children)}</div>`:"";return`<div class="dir-entry-group" id="${o}"><div class="dir-row dir-row-folder" data-path="${a}" data-eid="${o}" data-loaded="${l}">${u} <span class="dir-icon">\u{1F4C1}</span> <span class="dir-name">${_t(r.name)}</span>${c}</div>${d}</div>`}return`<div class="dir-entry"><div class="dir-row dir-row-file" data-path="${a}"><span class="file-icon">\u{1F4C4}</span> <span class="file-name">${_t(r.name)}</span></div></div>`}).join("")}return`<div class="dir-tree">${n(e)}</div>`}function $C(e,t){EC=0;let{hint:n,entries:i}=Um(e);return{notice:n||void 0,html:`<div class="panel-content directory-content">${jm(i,t)}</div>`}}function CC(e){let t=e.container.querySelector(".dir-tree");t&&t.addEventListener("click",async n=>{let i=n.target.closest(".dir-open-btn");if(i){n.stopPropagation();let a=i.dataset.openpath;if(!a)return;let l=e.buildOpenInFolderCommand(a);if(l)try{await e.callTool?.("start_process",{command:l,timeout_ms:12e3})}catch{}return}let r=n.target.closest(".dir-load-more");if(r){n.stopPropagation();let a=r.dataset.loadpath;if(!a)return;r.querySelector(".dir-warning-text").textContent="Loading\u2026",r.disabled=!0;try{let l=await e.callTool?.("list_directory",{path:a,depth:1}),u=Nt(l)??"";if(u){let c=Um(u),d=jm(c.entries,a),f=r.closest(".dir-children");if(f){let p=document.createElement("div");p.innerHTML=d;let h=p.querySelector(".dir-tree");f.innerHTML=h?h.innerHTML:""}}}catch{r.querySelector(".dir-warning-text").textContent="Failed to load",r.disabled=!1}return}let o=n.target.closest(".dir-row");if(!o)return;let s=o.dataset.path;if(s){if(o.classList.contains("dir-row-folder")){let a=o.dataset.eid;if(!a)return;let l=document.getElementById(`${a}-ch`),u=o.querySelector(".dir-chevron");if(l){let c=l.classList.toggle("dir-collapsed");u?.classList.toggle("expanded",!c),u&&(u.textContent=c?"\u25B6":"\u25BC");return}if(o.dataset.loaded==="true")return;u&&(u.textContent="\u23F3");try{let c=await e.callTool?.("list_directory",{path:s,depth:2}),d=Nt(c)??"";if(d){o.dataset.loaded="true";let f=Um(d),p=jm(f.entries,s),h=document.createElement("div");h.className="dir-children",h.id=`${a}-ch`;let m=document.createElement("div");m.innerHTML=p;let g=m.querySelector(".dir-tree");h.innerHTML=g?g.innerHTML:'<span class="dir-empty">Empty</span>',o.parentElement?.appendChild(h),u?.classList.add("expanded"),u&&(u.textContent="\u25BC")}}catch{u&&(u.textContent="\u26A0")}return}if(o.classList.contains("dir-row-file")){o.classList.add("dir-loading");try{let a=await e.callTool?.("read_file",{path:s});if(!a||typeof a!="object"||a===null)return;let l=a.structuredContent;if(l&&typeof l=="object"){let u=Nt(a)??"";e.onOpenPayload(Fm(l,u))}}catch{o.classList.remove("dir-loading")}}}})}function Dt(e){this.content=e}Dt.prototype={constructor:Dt,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var i=n&&n!=e?this.remove(n):this,r=i.find(e),o=i.content.slice();return r==-1?o.push(n||e,t):(o[r+1]=t,n&&(o[r]=n)),new Dt(o)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new Dt(n)},addToStart:function(e,t){return new Dt([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Dt(n)},addBefore:function(e,t,n){var i=this.remove(t),r=i.content.slice(),o=i.find(e);return r.splice(o==-1?r.length:o,0,t,n),new Dt(r)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=Dt.from(e),e.size?new Dt(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=Dt.from(e),e.size?new Dt(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Dt.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}};Dt.from=function(e){if(e instanceof Dt)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Dt(t)};var Zm=Dt;function PC(e,t,n){for(let i=0;;i++){if(i==e.childCount||i==t.childCount)return e.childCount==t.childCount?null:n;let r=e.child(i),o=t.child(i);if(r==o){n+=r.nodeSize;continue}if(!r.sameMarkup(o))return n;if(r.isText&&r.text!=o.text){for(let s=0;r.text[s]==o.text[s];s++)n++;return n}if(r.content.size||o.content.size){let s=PC(r.content,o.content,n+1);if(s!=null)return s}n+=r.nodeSize}}function LC(e,t,n,i){for(let r=e.childCount,o=t.childCount;;){if(r==0||o==0)return r==o?null:{a:n,b:i};let s=e.child(--r),a=t.child(--o),l=s.nodeSize;if(s==a){n-=l,i-=l;continue}if(!s.sameMarkup(a))return{a:n,b:i};if(s.isText&&s.text!=a.text){let u=0,c=Math.min(s.text.length,a.text.length);for(;u<c&&s.text[s.text.length-u-1]==a.text[a.text.length-u-1];)u++,n--,i--;return{a:n,b:i}}if(s.content.size||a.content.size){let u=LC(s.content,a.content,n-1,i-1);if(u)return u}n-=l,i-=l}}var z=class e{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let i=0;i<t.length;i++)this.size+=t[i].nodeSize}nodesBetween(t,n,i,r=0,o){for(let s=0,a=0;a<n;s++){let l=this.content[s],u=a+l.nodeSize;if(u>t&&i(l,r+a,o||null,s)!==!1&&l.content.size){let c=a+1;l.nodesBetween(Math.max(0,t-c),Math.min(l.content.size,n-c),i,r+c)}a=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,i,r){let o="",s=!0;return this.nodesBetween(t,n,(a,l)=>{let u=a.isText?a.text.slice(Math.max(t,l)-l,n-l):a.isLeaf?r?typeof r=="function"?r(a):r:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&u||a.isTextblock)&&i&&(s?s=!1:o+=i),o+=u},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,i=t.firstChild,r=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(i)&&(r[r.length-1]=n.withText(n.text+i.text),o=1);o<t.content.length;o++)r.push(t.content[o]);return new e(r,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let i=[],r=0;if(n>t)for(let o=0,s=0;s<n;o++){let a=this.content[o],l=s+a.nodeSize;l>t&&((s<t||l>n)&&(a.isText?a=a.cut(Math.max(0,t-s),Math.min(a.text.length,n-s)):a=a.cut(Math.max(0,t-s-1),Math.min(a.content.size,n-s-1))),i.push(a),r+=a.nodeSize),s=l}return new e(i,r)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let i=this.content[t];if(i==n)return this;let r=this.content.slice(),o=this.size+n.nodeSize-i.nodeSize;return r[t]=n,new e(r,o)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,i=0;n<this.content.length;n++){let r=this.content[n];t(r,i,n),i+=r.nodeSize}}findDiffStart(t,n=0){return PC(this,t,n)}findDiffEnd(t,n=this.size,i=t.size){return LC(this,t,n,i)}findIndex(t){if(t==0)return nc(0,t);if(t==this.size)return nc(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,i=0;;n++){let r=this.child(n),o=i+r.nodeSize;if(o>=t)return o==t?nc(n+1,o):nc(n,i);i=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,i=0;for(let r=0;r<t.length;r++){let o=t[r];i+=o.nodeSize,r&&o.isText&&t[r-1].sameMarkup(o)?(n||(n=t.slice(0,r)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new e(n||t,i)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};z.empty=new z([],0);var Hm={index:0,offset:0};function nc(e,t){return Hm.index=e,Hm.offset=t,Hm}function ic(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!ic(e[i],t[i]))return!1}else{for(let i in e)if(!(i in t)||!ic(e[i],t[i]))return!1;for(let i in t)if(!(i in e))return!1}return!0}var _e=class e{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,i=!1;for(let r=0;r<t.length;r++){let o=t[r];if(this.eq(o))return t;if(this.type.excludes(o.type))n||(n=t.slice(0,r));else{if(o.type.excludes(this.type))return t;!i&&o.type.rank>this.type.rank&&(n||(n=t.slice(0,r)),n.push(this),i=!0),n&&n.push(o)}}return n||(n=t.slice()),i||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&ic(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let i=t.marks[n.type];if(!i)throw new RangeError(`There is no mark type ${n.type} in this schema`);let r=i.create(n.attrs);return i.checkAttrs(r.attrs),r}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].eq(n[i]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((i,r)=>i.type.rank-r.type.rank),n}};_e.none=[];var fi=class extends Error{},B=class e{constructor(t,n,i){this.content=t,this.openStart=n,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let i=BC(this.content,t+this.openStart,n);return i&&new e(i,this.openStart,this.openEnd)}removeBetween(t,n){return new e(FC(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return e.empty;let i=n.openStart||0,r=n.openEnd||0;if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new e(z.fromJSON(t,n.content),i,r)}static maxOpen(t,n=!0){let i=0,r=0;for(let o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)i++;for(let o=t.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)r++;return new e(t,i,r)}};B.empty=new B(z.empty,0,0);function FC(e,t,n){let{index:i,offset:r}=e.findIndex(t),o=e.maybeChild(i),{index:s,offset:a}=e.findIndex(n);if(r==t||o.isText){if(a!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(i!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(i,o.copy(FC(o.content,t-r-1,n-r-1)))}function BC(e,t,n,i){let{index:r,offset:o}=e.findIndex(t),s=e.maybeChild(r);if(o==t||s.isText)return i&&!i.canReplace(r,r,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=BC(s.content,t-o-1,n,s);return a&&e.replaceChild(r,s.copy(a))}function y9(e,t,n){if(n.openStart>e.depth)throw new fi("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new fi("Inconsistent open depths");return UC(e,t,n,0)}function UC(e,t,n,i){let r=e.index(i),o=e.node(i);if(r==t.index(i)&&i<e.depth-n.openStart){let s=UC(e,t,n,i+1);return o.copy(o.content.replaceChild(r,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&e.depth==i&&t.depth==i){let s=e.parent,a=s.content;return di(s,a.cut(0,e.parentOffset).append(n.content).append(a.cut(t.parentOffset)))}else{let{start:s,end:a}=x9(n,e);return di(o,ZC(e,s,a,t,i))}else return di(o,oc(e,t,i))}function jC(e,t){if(!t.type.compatibleContent(e.type))throw new fi("Cannot join "+t.type.name+" onto "+e.type.name)}function Wm(e,t,n){let i=e.node(n);return jC(i,t.node(n)),i}function ci(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Qs(e,t,n,i){let r=(t||e).node(n),o=0,s=t?t.index(n):r.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(ci(e.nodeAfter,i),o++));for(let a=o;a<s;a++)ci(r.child(a),i);t&&t.depth==n&&t.textOffset&&ci(t.nodeBefore,i)}function di(e,t){return e.type.checkContent(t),e.copy(t)}function ZC(e,t,n,i,r){let o=e.depth>r&&Wm(e,t,r+1),s=i.depth>r&&Wm(n,i,r+1),a=[];return Qs(null,e,r,a),o&&s&&t.index(r)==n.index(r)?(jC(o,s),ci(di(o,ZC(e,t,n,i,r+1)),a)):(o&&ci(di(o,oc(e,t,r+1)),a),Qs(t,n,r,a),s&&ci(di(s,oc(n,i,r+1)),a)),Qs(i,null,r,a),new z(a)}function oc(e,t,n){let i=[];if(Qs(null,e,n,i),e.depth>n){let r=Wm(e,t,n+1);ci(di(r,oc(e,t,n+1)),i)}return Qs(t,null,n,i),new z(i)}function x9(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let o=n-1;o>=0;o--)r=t.node(o).copy(z.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var sc=class e{constructor(t,n,i){this.pos=t,this.path=n,this.parentOffset=i,this.depth=n.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,n=this.index(this.depth);if(n==t.childCount)return null;let i=this.pos-this.path[this.path.length-1],r=t.child(n);return i?t.child(n).cut(i):r}get nodeBefore(){let t=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(t).cut(0,n):t==0?null:this.parent.child(t-1)}posAtIndex(t,n){n=this.resolveDepth(n);let i=this.path[n*3],r=n==0?0:this.path[n*3-1]+1;for(let o=0;o<t;o++)r+=i.child(o).nodeSize;return r}marks(){let t=this.parent,n=this.index();if(t.content.size==0)return _e.none;if(this.textOffset)return t.child(n).marks;let i=t.maybeChild(n-1),r=t.maybeChild(n);if(!i){let a=i;i=r,r=a}let o=i.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!r||!o[s].isInSet(r.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(t){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let i=n.marks,r=t.parent.maybeChild(t.index());for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!r||!i[o].isInSet(r.marks))&&(i=i[o--].removeFromSet(i));return i}sharedDepth(t){for(let n=this.depth;n>0;n--)if(this.start(n)<=t&&this.end(n)>=t)return n;return 0}blockRange(t=this,n){if(t.pos<this.pos)return t.blockRange(this);for(let i=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);i>=0;i--)if(t.pos<=this.end(i)&&(!n||n(this.node(i))))return new pi(this,t,i);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let n=1;n<=this.depth;n++)t+=(t?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return t+":"+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");let i=[],r=0,o=n;for(let s=t;;){let{index:a,offset:l}=s.content.findIndex(o),u=o-l;if(i.push(s,a,r+l),!u||(s=s.child(a),s.isText))break;o=u-1,r+=l+1}return new e(n,i,o)}static resolveCached(t,n){let i=TC.get(t);if(i)for(let o=0;o<i.elts.length;o++){let s=i.elts[o];if(s.pos==n)return s}else TC.set(t,i=new Vm);let r=i.elts[i.i]=e.resolve(t,n);return i.i=(i.i+1)%k9,r}},Vm=class{constructor(){this.elts=[],this.i=0}},k9=12,TC=new WeakMap,pi=class{constructor(t,n,i){this.$from=t,this.$to=n,this.depth=i}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},_9=Object.create(null),Gt=class e{constructor(t,n,i,r=_e.none){this.type=t,this.attrs=n,this.marks=r,this.content=i||z.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,n,i,r=0){this.content.nodesBetween(t,n,i,r,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,n,i,r){return this.content.textBetween(t,n,i,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,n,i){return this.type==t&&ic(this.attrs,n||t.defaultAttrs||_9)&&_e.sameSet(this.marks,i||_e.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(t,n=this.content.size){return t==0&&n==this.content.size?this:this.copy(this.content.cut(t,n))}slice(t,n=this.content.size,i=!1){if(t==n)return B.empty;let r=this.resolve(t),o=this.resolve(n),s=i?0:r.sharedDepth(n),a=r.start(s),u=r.node(s).content.cut(r.pos-a,o.pos-a);return new B(u,r.depth-s,o.depth-s)}replace(t,n,i){return y9(this.resolve(t),this.resolve(n),i)}nodeAt(t){for(let n=this;;){let{index:i,offset:r}=n.content.findIndex(t);if(n=n.maybeChild(i),!n)return null;if(r==t||n.isText)return n;t-=r+1}}childAfter(t){let{index:n,offset:i}=this.content.findIndex(t);return{node:this.content.maybeChild(n),index:n,offset:i}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:n,offset:i}=this.content.findIndex(t);if(i<t)return{node:this.content.child(n),index:n,offset:i};let r=this.content.child(n-1);return{node:r,index:n-1,offset:i-r.nodeSize}}resolve(t){return sc.resolveCached(this,t)}resolveNoCache(t){return sc.resolve(this,t)}rangeHasMark(t,n,i){let r=!1;return n>t&&this.nodesBetween(t,n,o=>(i.isInSet(o.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),HC(this.marks,t)}contentMatchAt(t){let n=this.type.contentMatch.matchFragment(this.content,0,t);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(t,n,i=z.empty,r=0,o=i.childCount){let s=this.contentMatchAt(t).matchFragment(i,r,o),a=s&&s.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=r;l<o;l++)if(!this.type.allowsMarks(i.child(l).marks))return!1;return!0}canReplaceWith(t,n,i,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(t).matchType(i),s=o&&o.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=_e.none;for(let n=0;n<this.marks.length;n++){let i=this.marks[n];i.type.checkAttrs(i.attrs),t=i.addToSet(t)}if(!_e.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(n=>n.toJSON())),t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let i;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=n.marks.map(t.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(n.text,i)}let r=z.fromJSON(t,n.content),o=t.nodeType(n.type).create(n.attrs,r,i);return o.type.checkAttrs(o.attrs),o}};Gt.prototype.text=void 0;var Jm=class e extends Gt{constructor(t,n,i,r){if(super(t,n,null,r),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):HC(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,n){return this.text.slice(t,n)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(t=0,n=this.text.length){return t==0&&n==this.text.length?this:this.withText(this.text.slice(t,n))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}};function HC(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}var hi=class e{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,n){let i=new Km(t,n);if(i.next==null)return e.empty;let r=qC(i);i.next&&i.err("Unexpected trailing text");let o=I9(T9(r));return A9(o,i),o}matchType(t){for(let n=0;n<this.next.length;n++)if(this.next[n].type==t)return this.next[n].next;return null}matchFragment(t,n=0,i=t.childCount){let r=this;for(let o=n;r&&o<i;o++)r=r.matchType(t.child(o).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:n}=this.next[t];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(t){for(let n=0;n<this.next.length;n++)for(let i=0;i<t.next.length;i++)if(this.next[n].type==t.next[i].type)return!0;return!1}fillBefore(t,n=!1,i=0){let r=[this];function o(s,a){let l=s.matchFragment(t,i);if(l&&(!n||l.validEnd))return z.from(a.map(u=>u.createAndFill()));for(let u=0;u<s.next.length;u++){let{type:c,next:d}=s.next[u];if(!(c.isText||c.hasRequiredAttrs())&&r.indexOf(d)==-1){r.push(d);let f=o(d,a.concat(c));if(f)return f}}return null}return o(this,[])}findWrapping(t){for(let i=0;i<this.wrapCache.length;i+=2)if(this.wrapCache[i]==t)return this.wrapCache[i+1];let n=this.computeWrapping(t);return this.wrapCache.push(t,n),n}computeWrapping(t){let n=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let r=i.shift(),o=r.match;if(o.matchType(t)){let s=[];for(let a=r;a.type;a=a.via)s.push(a.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:a,next:l}=o.next[s];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!r.type||l.validEnd)&&(i.push({match:a.contentMatch,type:a,via:r}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function n(i){t.push(i);for(let r=0;r<i.next.length;r++)t.indexOf(i.next[r].next)==-1&&n(i.next[r].next)}return n(this),t.map((i,r)=>{let o=r+(i.validEnd?"*":" ")+" ";for(let s=0;s<i.next.length;s++)o+=(s?", ":"")+i.next[s].type.name+"->"+t.indexOf(i.next[s].next);return o}).join(`
|
|
91
|
+
`).trim(),entries:o}}var EC=0;function jm(e,t){if(e.length===0)return'<div class="dir-tree"><span class="dir-empty">Empty directory</span></div>';function n(i){return i.map(r=>{let o=`de-${EC++}`,s=`${t}/${r.relativePath.replace(/\\/g,"/")}`,a=_t(s);if(r.isWarning)return`<div class="dir-entry"><button class="dir-row dir-row-warning dir-load-more" data-loadpath="${a}"><span class="dir-warning-icon">\u26A0\uFE0F</span> <span class="dir-warning-text">${_t(r.warningText)} \u2014 click to load all</span></button></div>`;if(r.isDenied)return`<div class="dir-entry"><span class="dir-icon">\u{1F6AB}</span> <span class="dir-name-denied">${_t(r.name)}</span></div>`;if(r.isNotFound)return`<div class="dir-entry"><span class="dir-icon">\u2753</span> <span class="dir-name-denied">${_t(r.name)}</span></div>`;if(r.isDir){let l=r.children.length>0,u=`<span class="dir-chevron${l?" expanded":""}">${l?"\u25BC":"\u25B6"}</span>`,c=`<button class="dir-open-btn" data-openpath="${a}" title="Open in Finder">\u{1F4C2}</button>`,d=l?`<div class="dir-children" id="${o}-ch">${n(r.children)}</div>`:"";return`<div class="dir-entry-group" id="${o}"><div class="dir-row dir-row-folder" data-path="${a}" data-eid="${o}" data-loaded="${l}">${u} <span class="dir-icon">\u{1F4C1}</span> <span class="dir-name">${_t(r.name)}</span>${c}</div>${d}</div>`}return`<div class="dir-entry"><div class="dir-row dir-row-file" data-path="${a}"><span class="file-icon">\u{1F4C4}</span> <span class="file-name">${_t(r.name)}</span></div></div>`}).join("")}return`<div class="dir-tree">${n(e)}</div>`}function $C(e,t){EC=0;let{hint:n,entries:i}=Um(e);return{notice:n||void 0,html:`<div class="panel-content directory-content">${jm(i,t)}</div>`}}function CC(e){let t=e.container.querySelector(".dir-tree");t&&t.addEventListener("click",async n=>{let i=n.target.closest(".dir-open-btn");if(i){n.stopPropagation();let a=i.dataset.openpath;if(!a)return;let l=e.buildOpenInFolderCommand(a);if(l)try{await e.callTool?.("start_process",{command:l,timeout_ms:12e3})}catch{}return}let r=n.target.closest(".dir-load-more");if(r){n.stopPropagation();let a=r.dataset.loadpath;if(!a)return;r.querySelector(".dir-warning-text").textContent="Loading\u2026",r.disabled=!0;try{let l=await e.callTool?.("list_directory",{path:a,depth:1,origin:"ui"}),u=Nt(l)??"";if(u){let c=Um(u),d=jm(c.entries,a),f=r.closest(".dir-children");if(f){let p=document.createElement("div");p.innerHTML=d;let h=p.querySelector(".dir-tree");f.innerHTML=h?h.innerHTML:""}}}catch{r.querySelector(".dir-warning-text").textContent="Failed to load",r.disabled=!1}return}let o=n.target.closest(".dir-row");if(!o)return;let s=o.dataset.path;if(s){if(o.classList.contains("dir-row-folder")){let a=o.dataset.eid;if(!a)return;let l=document.getElementById(`${a}-ch`),u=o.querySelector(".dir-chevron");if(l){let c=l.classList.toggle("dir-collapsed");u?.classList.toggle("expanded",!c),u&&(u.textContent=c?"\u25B6":"\u25BC");return}if(o.dataset.loaded==="true")return;u&&(u.textContent="\u23F3");try{let c=await e.callTool?.("list_directory",{path:s,depth:2,origin:"ui"}),d=Nt(c)??"";if(d){o.dataset.loaded="true";let f=Um(d),p=jm(f.entries,s),h=document.createElement("div");h.className="dir-children",h.id=`${a}-ch`;let m=document.createElement("div");m.innerHTML=p;let g=m.querySelector(".dir-tree");h.innerHTML=g?g.innerHTML:'<span class="dir-empty">Empty</span>',o.parentElement?.appendChild(h),u?.classList.add("expanded"),u&&(u.textContent="\u25BC")}}catch{u&&(u.textContent="\u26A0")}return}if(o.classList.contains("dir-row-file")){o.classList.add("dir-loading");try{let a=await e.callTool?.("read_file",{path:s,origin:"ui"});if(!a||typeof a!="object"||a===null)return;let l=a.structuredContent;if(l&&typeof l=="object"){let u=Nt(a)??"";e.onOpenPayload(Fm(l,u))}}catch{o.classList.remove("dir-loading")}}}})}function Dt(e){this.content=e}Dt.prototype={constructor:Dt,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var i=n&&n!=e?this.remove(n):this,r=i.find(e),o=i.content.slice();return r==-1?o.push(n||e,t):(o[r+1]=t,n&&(o[r]=n)),new Dt(o)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new Dt(n)},addToStart:function(e,t){return new Dt([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Dt(n)},addBefore:function(e,t,n){var i=this.remove(t),r=i.content.slice(),o=i.find(e);return r.splice(o==-1?r.length:o,0,t,n),new Dt(r)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=Dt.from(e),e.size?new Dt(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=Dt.from(e),e.size?new Dt(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Dt.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}};Dt.from=function(e){if(e instanceof Dt)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Dt(t)};var Zm=Dt;function PC(e,t,n){for(let i=0;;i++){if(i==e.childCount||i==t.childCount)return e.childCount==t.childCount?null:n;let r=e.child(i),o=t.child(i);if(r==o){n+=r.nodeSize;continue}if(!r.sameMarkup(o))return n;if(r.isText&&r.text!=o.text){for(let s=0;r.text[s]==o.text[s];s++)n++;return n}if(r.content.size||o.content.size){let s=PC(r.content,o.content,n+1);if(s!=null)return s}n+=r.nodeSize}}function LC(e,t,n,i){for(let r=e.childCount,o=t.childCount;;){if(r==0||o==0)return r==o?null:{a:n,b:i};let s=e.child(--r),a=t.child(--o),l=s.nodeSize;if(s==a){n-=l,i-=l;continue}if(!s.sameMarkup(a))return{a:n,b:i};if(s.isText&&s.text!=a.text){let u=0,c=Math.min(s.text.length,a.text.length);for(;u<c&&s.text[s.text.length-u-1]==a.text[a.text.length-u-1];)u++,n--,i--;return{a:n,b:i}}if(s.content.size||a.content.size){let u=LC(s.content,a.content,n-1,i-1);if(u)return u}n-=l,i-=l}}var z=class e{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let i=0;i<t.length;i++)this.size+=t[i].nodeSize}nodesBetween(t,n,i,r=0,o){for(let s=0,a=0;a<n;s++){let l=this.content[s],u=a+l.nodeSize;if(u>t&&i(l,r+a,o||null,s)!==!1&&l.content.size){let c=a+1;l.nodesBetween(Math.max(0,t-c),Math.min(l.content.size,n-c),i,r+c)}a=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,i,r){let o="",s=!0;return this.nodesBetween(t,n,(a,l)=>{let u=a.isText?a.text.slice(Math.max(t,l)-l,n-l):a.isLeaf?r?typeof r=="function"?r(a):r:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&u||a.isTextblock)&&i&&(s?s=!1:o+=i),o+=u},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,i=t.firstChild,r=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(i)&&(r[r.length-1]=n.withText(n.text+i.text),o=1);o<t.content.length;o++)r.push(t.content[o]);return new e(r,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let i=[],r=0;if(n>t)for(let o=0,s=0;s<n;o++){let a=this.content[o],l=s+a.nodeSize;l>t&&((s<t||l>n)&&(a.isText?a=a.cut(Math.max(0,t-s),Math.min(a.text.length,n-s)):a=a.cut(Math.max(0,t-s-1),Math.min(a.content.size,n-s-1))),i.push(a),r+=a.nodeSize),s=l}return new e(i,r)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let i=this.content[t];if(i==n)return this;let r=this.content.slice(),o=this.size+n.nodeSize-i.nodeSize;return r[t]=n,new e(r,o)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,i=0;n<this.content.length;n++){let r=this.content[n];t(r,i,n),i+=r.nodeSize}}findDiffStart(t,n=0){return PC(this,t,n)}findDiffEnd(t,n=this.size,i=t.size){return LC(this,t,n,i)}findIndex(t){if(t==0)return nc(0,t);if(t==this.size)return nc(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,i=0;;n++){let r=this.child(n),o=i+r.nodeSize;if(o>=t)return o==t?nc(n+1,o):nc(n,i);i=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,i=0;for(let r=0;r<t.length;r++){let o=t[r];i+=o.nodeSize,r&&o.isText&&t[r-1].sameMarkup(o)?(n||(n=t.slice(0,r)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new e(n||t,i)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};z.empty=new z([],0);var Hm={index:0,offset:0};function nc(e,t){return Hm.index=e,Hm.offset=t,Hm}function ic(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!ic(e[i],t[i]))return!1}else{for(let i in e)if(!(i in t)||!ic(e[i],t[i]))return!1;for(let i in t)if(!(i in e))return!1}return!0}var _e=class e{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,i=!1;for(let r=0;r<t.length;r++){let o=t[r];if(this.eq(o))return t;if(this.type.excludes(o.type))n||(n=t.slice(0,r));else{if(o.type.excludes(this.type))return t;!i&&o.type.rank>this.type.rank&&(n||(n=t.slice(0,r)),n.push(this),i=!0),n&&n.push(o)}}return n||(n=t.slice()),i||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&ic(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let i=t.marks[n.type];if(!i)throw new RangeError(`There is no mark type ${n.type} in this schema`);let r=i.create(n.attrs);return i.checkAttrs(r.attrs),r}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].eq(n[i]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((i,r)=>i.type.rank-r.type.rank),n}};_e.none=[];var fi=class extends Error{},B=class e{constructor(t,n,i){this.content=t,this.openStart=n,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let i=BC(this.content,t+this.openStart,n);return i&&new e(i,this.openStart,this.openEnd)}removeBetween(t,n){return new e(FC(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return e.empty;let i=n.openStart||0,r=n.openEnd||0;if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new e(z.fromJSON(t,n.content),i,r)}static maxOpen(t,n=!0){let i=0,r=0;for(let o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)i++;for(let o=t.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)r++;return new e(t,i,r)}};B.empty=new B(z.empty,0,0);function FC(e,t,n){let{index:i,offset:r}=e.findIndex(t),o=e.maybeChild(i),{index:s,offset:a}=e.findIndex(n);if(r==t||o.isText){if(a!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(i!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(i,o.copy(FC(o.content,t-r-1,n-r-1)))}function BC(e,t,n,i){let{index:r,offset:o}=e.findIndex(t),s=e.maybeChild(r);if(o==t||s.isText)return i&&!i.canReplace(r,r,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=BC(s.content,t-o-1,n,s);return a&&e.replaceChild(r,s.copy(a))}function y9(e,t,n){if(n.openStart>e.depth)throw new fi("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new fi("Inconsistent open depths");return UC(e,t,n,0)}function UC(e,t,n,i){let r=e.index(i),o=e.node(i);if(r==t.index(i)&&i<e.depth-n.openStart){let s=UC(e,t,n,i+1);return o.copy(o.content.replaceChild(r,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&e.depth==i&&t.depth==i){let s=e.parent,a=s.content;return di(s,a.cut(0,e.parentOffset).append(n.content).append(a.cut(t.parentOffset)))}else{let{start:s,end:a}=x9(n,e);return di(o,ZC(e,s,a,t,i))}else return di(o,oc(e,t,i))}function jC(e,t){if(!t.type.compatibleContent(e.type))throw new fi("Cannot join "+t.type.name+" onto "+e.type.name)}function Wm(e,t,n){let i=e.node(n);return jC(i,t.node(n)),i}function ci(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Qs(e,t,n,i){let r=(t||e).node(n),o=0,s=t?t.index(n):r.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(ci(e.nodeAfter,i),o++));for(let a=o;a<s;a++)ci(r.child(a),i);t&&t.depth==n&&t.textOffset&&ci(t.nodeBefore,i)}function di(e,t){return e.type.checkContent(t),e.copy(t)}function ZC(e,t,n,i,r){let o=e.depth>r&&Wm(e,t,r+1),s=i.depth>r&&Wm(n,i,r+1),a=[];return Qs(null,e,r,a),o&&s&&t.index(r)==n.index(r)?(jC(o,s),ci(di(o,ZC(e,t,n,i,r+1)),a)):(o&&ci(di(o,oc(e,t,r+1)),a),Qs(t,n,r,a),s&&ci(di(s,oc(n,i,r+1)),a)),Qs(i,null,r,a),new z(a)}function oc(e,t,n){let i=[];if(Qs(null,e,n,i),e.depth>n){let r=Wm(e,t,n+1);ci(di(r,oc(e,t,n+1)),i)}return Qs(t,null,n,i),new z(i)}function x9(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let o=n-1;o>=0;o--)r=t.node(o).copy(z.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var sc=class e{constructor(t,n,i){this.pos=t,this.path=n,this.parentOffset=i,this.depth=n.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,n=this.index(this.depth);if(n==t.childCount)return null;let i=this.pos-this.path[this.path.length-1],r=t.child(n);return i?t.child(n).cut(i):r}get nodeBefore(){let t=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(t).cut(0,n):t==0?null:this.parent.child(t-1)}posAtIndex(t,n){n=this.resolveDepth(n);let i=this.path[n*3],r=n==0?0:this.path[n*3-1]+1;for(let o=0;o<t;o++)r+=i.child(o).nodeSize;return r}marks(){let t=this.parent,n=this.index();if(t.content.size==0)return _e.none;if(this.textOffset)return t.child(n).marks;let i=t.maybeChild(n-1),r=t.maybeChild(n);if(!i){let a=i;i=r,r=a}let o=i.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!r||!o[s].isInSet(r.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(t){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let i=n.marks,r=t.parent.maybeChild(t.index());for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!r||!i[o].isInSet(r.marks))&&(i=i[o--].removeFromSet(i));return i}sharedDepth(t){for(let n=this.depth;n>0;n--)if(this.start(n)<=t&&this.end(n)>=t)return n;return 0}blockRange(t=this,n){if(t.pos<this.pos)return t.blockRange(this);for(let i=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);i>=0;i--)if(t.pos<=this.end(i)&&(!n||n(this.node(i))))return new pi(this,t,i);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let n=1;n<=this.depth;n++)t+=(t?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return t+":"+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");let i=[],r=0,o=n;for(let s=t;;){let{index:a,offset:l}=s.content.findIndex(o),u=o-l;if(i.push(s,a,r+l),!u||(s=s.child(a),s.isText))break;o=u-1,r+=l+1}return new e(n,i,o)}static resolveCached(t,n){let i=TC.get(t);if(i)for(let o=0;o<i.elts.length;o++){let s=i.elts[o];if(s.pos==n)return s}else TC.set(t,i=new Vm);let r=i.elts[i.i]=e.resolve(t,n);return i.i=(i.i+1)%k9,r}},Vm=class{constructor(){this.elts=[],this.i=0}},k9=12,TC=new WeakMap,pi=class{constructor(t,n,i){this.$from=t,this.$to=n,this.depth=i}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},_9=Object.create(null),Gt=class e{constructor(t,n,i,r=_e.none){this.type=t,this.attrs=n,this.marks=r,this.content=i||z.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,n,i,r=0){this.content.nodesBetween(t,n,i,r,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,n,i,r){return this.content.textBetween(t,n,i,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,n,i){return this.type==t&&ic(this.attrs,n||t.defaultAttrs||_9)&&_e.sameSet(this.marks,i||_e.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(t,n=this.content.size){return t==0&&n==this.content.size?this:this.copy(this.content.cut(t,n))}slice(t,n=this.content.size,i=!1){if(t==n)return B.empty;let r=this.resolve(t),o=this.resolve(n),s=i?0:r.sharedDepth(n),a=r.start(s),u=r.node(s).content.cut(r.pos-a,o.pos-a);return new B(u,r.depth-s,o.depth-s)}replace(t,n,i){return y9(this.resolve(t),this.resolve(n),i)}nodeAt(t){for(let n=this;;){let{index:i,offset:r}=n.content.findIndex(t);if(n=n.maybeChild(i),!n)return null;if(r==t||n.isText)return n;t-=r+1}}childAfter(t){let{index:n,offset:i}=this.content.findIndex(t);return{node:this.content.maybeChild(n),index:n,offset:i}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:n,offset:i}=this.content.findIndex(t);if(i<t)return{node:this.content.child(n),index:n,offset:i};let r=this.content.child(n-1);return{node:r,index:n-1,offset:i-r.nodeSize}}resolve(t){return sc.resolveCached(this,t)}resolveNoCache(t){return sc.resolve(this,t)}rangeHasMark(t,n,i){let r=!1;return n>t&&this.nodesBetween(t,n,o=>(i.isInSet(o.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),HC(this.marks,t)}contentMatchAt(t){let n=this.type.contentMatch.matchFragment(this.content,0,t);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(t,n,i=z.empty,r=0,o=i.childCount){let s=this.contentMatchAt(t).matchFragment(i,r,o),a=s&&s.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=r;l<o;l++)if(!this.type.allowsMarks(i.child(l).marks))return!1;return!0}canReplaceWith(t,n,i,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(t).matchType(i),s=o&&o.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=_e.none;for(let n=0;n<this.marks.length;n++){let i=this.marks[n];i.type.checkAttrs(i.attrs),t=i.addToSet(t)}if(!_e.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(n=>n.toJSON())),t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let i;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=n.marks.map(t.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(n.text,i)}let r=z.fromJSON(t,n.content),o=t.nodeType(n.type).create(n.attrs,r,i);return o.type.checkAttrs(o.attrs),o}};Gt.prototype.text=void 0;var Jm=class e extends Gt{constructor(t,n,i,r){if(super(t,n,null,r),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):HC(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,n){return this.text.slice(t,n)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(t=0,n=this.text.length){return t==0&&n==this.text.length?this:this.withText(this.text.slice(t,n))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}};function HC(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}var hi=class e{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,n){let i=new Km(t,n);if(i.next==null)return e.empty;let r=qC(i);i.next&&i.err("Unexpected trailing text");let o=I9(T9(r));return A9(o,i),o}matchType(t){for(let n=0;n<this.next.length;n++)if(this.next[n].type==t)return this.next[n].next;return null}matchFragment(t,n=0,i=t.childCount){let r=this;for(let o=n;r&&o<i;o++)r=r.matchType(t.child(o).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:n}=this.next[t];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(t){for(let n=0;n<this.next.length;n++)for(let i=0;i<t.next.length;i++)if(this.next[n].type==t.next[i].type)return!0;return!1}fillBefore(t,n=!1,i=0){let r=[this];function o(s,a){let l=s.matchFragment(t,i);if(l&&(!n||l.validEnd))return z.from(a.map(u=>u.createAndFill()));for(let u=0;u<s.next.length;u++){let{type:c,next:d}=s.next[u];if(!(c.isText||c.hasRequiredAttrs())&&r.indexOf(d)==-1){r.push(d);let f=o(d,a.concat(c));if(f)return f}}return null}return o(this,[])}findWrapping(t){for(let i=0;i<this.wrapCache.length;i+=2)if(this.wrapCache[i]==t)return this.wrapCache[i+1];let n=this.computeWrapping(t);return this.wrapCache.push(t,n),n}computeWrapping(t){let n=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let r=i.shift(),o=r.match;if(o.matchType(t)){let s=[];for(let a=r;a.type;a=a.via)s.push(a.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:a,next:l}=o.next[s];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!r.type||l.validEnd)&&(i.push({match:a.contentMatch,type:a,via:r}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function n(i){t.push(i);for(let r=0;r<i.next.length;r++)t.indexOf(i.next[r].next)==-1&&n(i.next[r].next)}return n(this),t.map((i,r)=>{let o=r+(i.validEnd?"*":" ")+" ";for(let s=0;s<i.next.length;s++)o+=(s?", ":"")+i.next[s].type.name+"->"+t.indexOf(i.next[s].next);return o}).join(`
|
|
92
92
|
`)}};hi.empty=new hi(!0);var Km=class{constructor(t,n){this.string=t,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}};function qC(e){let t=[];do t.push(w9(e));while(e.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function w9(e){let t=[];do t.push(S9(e));while(e.next&&e.next!=")"&&e.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function S9(e){let t=C9(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=E9(e,t);else break;return t}function IC(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function E9(e,t){let n=IC(e),i=n;return e.eat(",")&&(e.next!="}"?i=IC(e):i=-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:i,expr:t}}function $9(e,t){let n=e.nodeTypes,i=n[t];if(i)return[i];let r=[];for(let o in n){let s=n[o];s.isInGroup(t)&&r.push(s)}return r.length==0&&e.err("No node type or group '"+t+"' found"),r}function C9(e){if(e.eat("(")){let t=qC(e);return e.eat(")")||e.err("Missing closing paren"),t}else if(/\W/.test(e.next))e.err("Unexpected token '"+e.next+"'");else{let t=$9(e,e.next).map(n=>(e.inline==null?e.inline=n.isInline:e.inline!=n.isInline&&e.err("Mixing inline and block content"),{type:"name",value:n}));return e.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function T9(e){let t=[[]];return r(o(e,0),n()),t;function n(){return t.push([])-1}function i(s,a,l){let u={term:l,to:a};return t[s].push(u),u}function r(s,a){s.forEach(l=>l.to=a)}function o(s,a){if(s.type=="choice")return s.exprs.reduce((l,u)=>l.concat(o(u,a)),[]);if(s.type=="seq")for(let l=0;;l++){let u=o(s.exprs[l],a);if(l==s.exprs.length-1)return u;r(u,a=n())}else if(s.type=="star"){let l=n();return i(a,l),r(o(s.expr,l),l),[i(l)]}else if(s.type=="plus"){let l=n();return r(o(s.expr,a),l),r(o(s.expr,l),l),[i(l)]}else{if(s.type=="opt")return[i(a)].concat(o(s.expr,a));if(s.type=="range"){let l=a;for(let u=0;u<s.min;u++){let c=n();r(o(s.expr,l),c),l=c}if(s.max==-1)r(o(s.expr,l),l);else for(let u=s.min;u<s.max;u++){let c=n();i(l,c),r(o(s.expr,l),c),l=c}return[i(l)]}else{if(s.type=="name")return[i(a,void 0,s.value)];throw new Error("Unknown expr type")}}}}function WC(e,t){return t-e}function AC(e,t){let n=[];return i(t),n.sort(WC);function i(r){let o=e[r];if(o.length==1&&!o[0].term)return i(o[0].to);n.push(r);for(let s=0;s<o.length;s++){let{term:a,to:l}=o[s];!a&&n.indexOf(l)==-1&&i(l)}}}function I9(e){let t=Object.create(null);return n(AC(e,0));function n(i){let r=[];i.forEach(s=>{e[s].forEach(({term:a,to:l})=>{if(!a)return;let u;for(let c=0;c<r.length;c++)r[c][0]==a&&(u=r[c][1]);AC(e,l).forEach(c=>{u||r.push([a,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let o=t[i.join(",")]=new hi(i.indexOf(e.length-1)>-1);for(let s=0;s<r.length;s++){let a=r[s][1].sort(WC);o.next.push({type:r[s][0],next:t[a.join(",")]||n(a)})}return o}}function A9(e,t){for(let n=0,i=[e];n<i.length;n++){let r=i[n],o=!r.validEnd,s=[];for(let a=0;a<r.next.length;a++){let{type:l,next:u}=r.next[a];s.push(l.name),o&&!(l.isText||l.hasRequiredAttrs())&&(o=!1),i.indexOf(u)==-1&&i.push(u)}o&&t.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function VC(e){let t=Object.create(null);for(let n in e){let i=e[n];if(!i.hasDefault)return null;t[n]=i.default}return t}function JC(e,t){let n=Object.create(null);for(let i in e){let r=t&&t[i];if(r===void 0){let o=e[i];if(o.hasDefault)r=o.default;else throw new RangeError("No value supplied for attribute "+i)}n[i]=r}return n}function KC(e,t,n,i){for(let r in t)if(!(r in e))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let r in e){let o=e[r];o.validate&&o.validate(t[r])}}function GC(e,t){let n=Object.create(null);if(t)for(let i in t)n[i]=new Gm(e,i,t[i]);return n}var ac=class e{constructor(t,n,i){this.name=t,this.schema=n,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=GC(t,i.attrs),this.defaultAttrs=VC(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||t=="text"),this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==hi.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:JC(this.attrs,t)}create(t=null,n,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Gt(this,this.computeAttrs(t),z.from(n),_e.setFrom(i))}createChecked(t=null,n,i){return n=z.from(n),this.checkContent(n),new Gt(this,this.computeAttrs(t),n,_e.setFrom(i))}createAndFill(t=null,n,i){if(t=this.computeAttrs(t),n=z.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let r=this.contentMatch.matchFragment(n),o=r&&r.fillBefore(z.empty,!0);return o?new Gt(this,t,n.append(o),_e.setFrom(i)):null}validContent(t){let n=this.contentMatch.matchFragment(t);if(!n||!n.validEnd)return!1;for(let i=0;i<t.childCount;i++)if(!this.allowsMarks(t.child(i).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){KC(this.attrs,t,"node",this.name)}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return!0;for(let n=0;n<t.length;n++)if(!this.allowsMarkType(t[n].type))return!1;return!0}allowedMarks(t){if(this.markSet==null)return t;let n;for(let i=0;i<t.length;i++)this.allowsMarkType(t[i].type)?n&&n.push(t[i]):n||(n=t.slice(0,i));return n?n.length?n:_e.none:t}static compile(t,n){let i=Object.create(null);t.forEach((o,s)=>i[o]=new e(o,n,s));let r=n.spec.topNode||"doc";if(!i[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let o in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};function z9(e,t,n){let i=n.split("|");return r=>{let o=r===null?"null":typeof r;if(i.indexOf(o)<0)throw new RangeError(`Expected value of type ${i} for attribute ${t} on type ${e}, got ${o}`)}}var Gm=class{constructor(t,n,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate=typeof i.validate=="string"?z9(t,n,i.validate):i.validate}get isRequired(){return!this.hasDefault}},ta=class e{constructor(t,n,i,r){this.name=t,this.rank=n,this.schema=i,this.spec=r,this.attrs=GC(t,r.attrs),this.excluded=null;let o=VC(this.attrs);this.instance=o?new _e(this,o):null}create(t=null){return!t&&this.instance?this.instance:new _e(this,JC(this.attrs,t))}static compile(t,n){let i=Object.create(null),r=0;return t.forEach((o,s)=>i[o]=new e(o,r++,n,s)),i}removeFromSet(t){for(var n=0;n<t.length;n++)t[n].type==this&&(t=t.slice(0,n).concat(t.slice(n+1)),n--);return t}isInSet(t){for(let n=0;n<t.length;n++)if(t[n].type==this)return t[n]}checkAttrs(t){KC(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}},Ar=class{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let r in t)n[r]=t[r];n.nodes=Zm.from(t.nodes),n.marks=Zm.from(t.marks||{}),this.nodes=ac.compile(this.spec.nodes,this),this.marks=ta.compile(this.spec.marks,this);let i=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let o=this.nodes[r],s=o.spec.content||"",a=o.spec.marks;if(o.contentMatch=i[s]||(i[s]=hi.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=a=="_"?null:a?zC(this,a.split(" ")):a==""||!o.inlineContent?[]:null}for(let r in this.marks){let o=this.marks[r],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:zC(this,s.split(" "))}this.nodeFromJSON=r=>Gt.fromJSON(this,r),this.markFromJSON=r=>_e.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,n=null,i,r){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof ac){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(n,i,r)}text(t,n){let i=this.nodes.text;return new Jm(i,i.defaultAttrs,t,_e.setFrom(n))}mark(t,n){return typeof t=="string"&&(t=this.marks[t]),t.create(n)}nodeType(t){let n=this.nodes[t];if(!n)throw new RangeError("Unknown node type: "+t);return n}};function zC(e,t){let n=[];for(let i=0;i<t.length;i++){let r=t[i],o=e.marks[r],s=o;if(o)n.push(o);else for(let a in e.marks){let l=e.marks[a];(r=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[i]+"'")}return n}function M9(e){return e.tag!=null}function N9(e){return e.style!=null}var hn=class e{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let i=this.matchedStyles=[];n.forEach(r=>{if(M9(r))this.tags.push(r);else if(N9(r)){let o=/[^=]*/.exec(r.style)[0];i.indexOf(o)<0&&i.push(o),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let o=t.nodes[r.node];return o.contentMatch.matchType(o)})}parse(t,n={}){let i=new lc(this,n,!1);return i.addAll(t,_e.none,n.from,n.to),i.finish()}parseSlice(t,n={}){let i=new lc(this,n,!0);return i.addAll(t,_e.none,n.from,n.to),B.maxOpen(i.finish())}matchTag(t,n,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let o=this.tags[r];if(R9(t,o.tag)&&(o.namespace===void 0||t.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(t);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(t,n,i,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let s=this.styles[o],a=s.style;if(!(a.indexOf(t)!=0||s.context&&!i.matchesContext(s.context)||a.length>t.length&&(a.charCodeAt(t.length)!=61||a.slice(t.length+1)!=n))){if(s.getAttrs){let l=s.getAttrs(n);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(t){let n=[];function i(r){let o=r.priority==null?50:r.priority,s=0;for(;s<n.length;s++){let a=n[s];if((a.priority==null?50:a.priority)<o)break}n.splice(s,0,r)}for(let r in t.marks){let o=t.marks[r].spec.parseDOM;o&&o.forEach(s=>{i(s=NC(s)),s.mark||s.ignore||s.clearMark||(s.mark=r)})}for(let r in t.nodes){let o=t.nodes[r].spec.parseDOM;o&&o.forEach(s=>{i(s=NC(s)),s.node||s.ignore||s.mark||(s.node=r)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},XC={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},D9={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},YC={ol:!0,ul:!0},na=1,Xm=2,ea=4;function MC(e,t,n){return t!=null?(t?na:0)|(t==="full"?Xm:0):e&&e.whitespace=="pre"?na|Xm:n&~ea}var mo=class{constructor(t,n,i,r,o,s){this.type=t,this.attrs=n,this.marks=i,this.solid=r,this.options=s,this.content=[],this.activeMarks=_e.none,this.match=o||(s&ea?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(z.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let i=this.type.contentMatch,r;return(r=i.findWrapping(t.type))?(this.match=i,r):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&na)){let i=this.content[this.content.length-1],r;if(i&&i.isText&&(r=/[ \t\r\n\u000c]+$/.exec(i.text))){let o=i;i.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-r[0].length))}}let n=z.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(z.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!XC.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}},lc=class{constructor(t,n,i){this.parser=t,this.options=n,this.isOpen=i,this.open=0,this.localPreserveWS=!1;let r=n.topNode,o,s=MC(null,n.preserveWhitespace,0)|(i?ea:0);r?o=new mo(r.type,r.attrs,_e.none,!0,n.topMatch||r.type.contentMatch,s):i?o=new mo(null,null,_e.none,!0,null,s):o=new mo(t.schema.topNodeType,null,_e.none,!0,null,s),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,n){t.nodeType==3?this.addTextNode(t,n):t.nodeType==1&&this.addElement(t,n)}addTextNode(t,n){let i=t.nodeValue,r=this.top,o=r.options&Xm?"full":this.localPreserveWS||(r.options&na)>0,{schema:s}=this.parser;if(o==="full"||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(i)){if(o)if(o==="full")i=i.replace(/\r\n?/g,`
|
|
93
93
|
`);else if(s.linebreakReplacement&&/[\r\n]/.test(i)&&this.top.findWrapping(s.linebreakReplacement.create())){let a=i.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(s.text(a[l]),n,!/\S/.test(a[l]));i=""}else i=i.replace(/\r?\n|\r/g," ");else if(i=i.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let a=r.content[r.content.length-1],l=t.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(i=i.slice(1))}i&&this.insertNode(s.text(i),n,!/\S/.test(i)),this.findInText(t)}else this.findInside(t)}addElement(t,n,i){let r=this.localPreserveWS,o=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let s=t.nodeName.toLowerCase(),a;YC.hasOwnProperty(s)&&this.parser.normalizeLists&&O9(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(a=this.parser.matchTag(t,this,i));e:if(l?l.ignore:D9.hasOwnProperty(s))this.findInside(t),this.ignoreFallback(t,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(t=l.skip);let u,c=this.needsBlock;if(XC.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),u=!0,o.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,n);break e}let d=l&&l.skip?n:this.readStyles(t,n);d&&this.addAll(t,d),u&&this.sync(o),this.needsBlock=c}else{let u=this.readStyles(t,n);u&&this.addElementByRule(t,l,u,l.consuming===!1?a:void 0)}this.localPreserveWS=r}leafFallback(t,n){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
|
|
94
94
|
`),n)}ignoreFallback(t,n){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(t,n){let i=t.style;if(i&&i.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let o=this.parser.matchedStyles[r],s=i.getPropertyValue(o);if(s)for(let a=void 0;;){let l=this.parser.matchStyle(o,s,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(u=>!l.clearMark(u)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(t,n,i,r){let o,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),i,t.nodeName=="BR")||this.leafFallback(t,i);else{let l=this.enter(s,n.attrs||null,i,n.preserveWhitespace);l&&(o=!0,i=l)}else{let l=this.parser.schema.marks[n.mark];i=i.concat(l.create(n.attrs))}let a=this.top;if(s&&s.isLeaf)this.findInside(t);else if(r)this.addElement(t,i,r);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(l=>this.insertNode(l,i,!1));else{let l=t;typeof n.contentElement=="string"?l=t.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(t):n.contentElement&&(l=n.contentElement),this.findAround(t,l,!0),this.addAll(l,i),this.findAround(t,l,!1)}o&&this.sync(a)&&this.open--}addAll(t,n,i,r){let o=i||0;for(let s=i?t.childNodes[i]:t.firstChild,a=r==null?null:t.childNodes[r];s!=a;s=s.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(s,n);this.findAtPoint(t,o)}findPlace(t,n,i){let r,o;for(let s=this.open,a=0;s>=0;s--){let l=this.nodes[s],u=l.findWrapping(t);if(u&&(!r||r.length>u.length+a)&&(r=u,o=l,!u.length))break;if(l.solid){if(i)break;a+=2}}if(!r)return null;this.sync(o);for(let s=0;s<r.length;s++)n=this.enterInner(r[s],null,n,!1);return n}insertNode(t,n,i){if(t.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let r=this.findPlace(t,n,i);if(r){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(t.type));let s=_e.none;for(let a of r.concat(t.marks))(o.type?o.type.allowsMarkType(a.type):DC(a.type,t.type))&&(s=a.addToSet(s));return o.content.push(t.mark(s)),!0}return!1}enter(t,n,i,r){let o=this.findPlace(t.create(n),i,!1);return o&&(o=this.enterInner(t,n,i,!0,r)),o}enterInner(t,n,i,r=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let a=MC(t,o,s.options);s.options&ea&&s.content.length==0&&(a|=ea);let l=_e.none;return i=i.filter(u=>(s.type?s.type.allowsMarkType(u.type):DC(u.type,t))?(l=u.addToSet(l),!1):!0),this.nodes.push(new mo(t,n,l,r,null,a)),this.open++,i}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let n=this.open;n>=0;n--){if(this.nodes[n]==t)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=na)}return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let i=this.nodes[n].content;for(let r=i.length-1;r>=0;r--)t+=i[r].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==t&&this.find[i].offset==n&&(this.find[i].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,i){if(t!=n&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&t.nodeType==1&&t.contains(this.find[r].node)&&n.compareDocumentPosition(this.find[r].node)&(i?2:4)&&(this.find[r].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),i=this.options.context,r=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type),o=-(i?i.depth+1:0)+(r?0:1),s=(a,l)=>{for(;a>=0;a--){let u=n[a];if(u==""){if(a==n.length-1||a==0)continue;for(;l>=o;l--)if(s(a-1,l))return!0;return!1}else{let c=l>0||l==0&&r?this.nodes[l].type:i&&l>=o?i.node(l-o).type:null;if(!c||c.name!=u&&!c.isInGroup(u))return!1;l--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let i=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let n in this.parser.schema.nodes){let i=this.parser.schema.nodes[n];if(i.isTextblock&&i.defaultAttrs)return i}}};function O9(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let i=t.nodeType==1?t.nodeName.toLowerCase():null;i&&YC.hasOwnProperty(i)&&n?(n.appendChild(t),t=n):i=="li"?n=t:i&&(n=null)}}function R9(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function NC(e){let t={};for(let n in e)t[n]=e[n];return t}function DC(e,t){let n=t.schema.nodes;for(let i in n){let r=n[i];if(!r.allowsMarkType(e))continue;let o=[],s=a=>{o.push(a);for(let l=0;l<a.edgeCount;l++){let{type:u,next:c}=a.edge(l);if(u==t||o.indexOf(c)<0&&s(c))return!0}};if(s(r.contentMatch))return!0}}var ir=class e{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},i){i||(i=qm(n).createDocumentFragment());let r=i,o=[];return t.forEach(s=>{if(o.length||s.marks.length){let a=0,l=0;for(;a<o.length&&l<s.marks.length;){let u=s.marks[l];if(!this.marks[u.type.name]){l++;continue}if(!u.eq(o[a][0])||u.type.spec.spanning===!1)break;a++,l++}for(;a<o.length;)r=o.pop()[1];for(;l<s.marks.length;){let u=s.marks[l++],c=this.serializeMark(u,s.isInline,n);c&&(o.push([u,r]),r.appendChild(c.dom),r=c.contentDOM||c.dom)}}r.appendChild(this.serializeNodeInner(s,n))}),i}serializeNodeInner(t,n){let{dom:i,contentDOM:r}=rc(qm(n),this.nodes[t.type.name](t),null,t.attrs);if(r){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,r)}return i}serializeNode(t,n={}){let i=this.serializeNodeInner(t,n);for(let r=t.marks.length-1;r>=0;r--){let o=this.serializeMark(t.marks[r],t.isInline,n);o&&((o.contentDOM||o.dom).appendChild(i),i=o.dom)}return i}serializeMark(t,n,i={}){let r=this.marks[t.type.name];return r&&rc(qm(i),r(t,n),null,t.attrs)}static renderSpec(t,n,i=null,r){return rc(t,n,i,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=OC(t.nodes);return n.text||(n.text=i=>i.text),n}static marksFromSchema(t){return OC(t.marks)}};function OC(e){let t={};for(let n in e){let i=e[n].spec.toDOM;i&&(t[n]=i)}return t}function qm(e){return e.document||window.document}var RC=new WeakMap;function P9(e){let t=RC.get(e);return t===void 0&&RC.set(e,t=L9(e)),t}function L9(e){let t=null;function n(i){if(i&&typeof i=="object")if(Array.isArray(i))if(typeof i[0]=="string")t||(t=[]),t.push(i);else for(let r=0;r<i.length;r++)n(i[r]);else for(let r in i)n(i[r])}return n(e),t}function rc(e,t,n,i){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let r=t[0],o;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(o=P9(i))&&o.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=r.indexOf(" ");s>0&&(n=r.slice(0,s),r=r.slice(s+1));let a,l=n?e.createElementNS(n,r):e.createElement(r),u=t[1],c=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){c=2;for(let d in u)if(u[d]!=null){let f=d.indexOf(" ");f>0?l.setAttributeNS(d.slice(0,f),d.slice(f+1),u[d]):d=="style"&&l.style?l.style.cssText=u[d]:l.setAttribute(d,u[d])}}for(let d=c;d<t.length;d++){let f=t[d];if(f===0){if(d<t.length-1||d>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:p,contentDOM:h}=rc(e,f,n,i);if(l.appendChild(p),h){if(a)throw new RangeError("Multiple content holes");a=h}}}return{dom:l,contentDOM:a}}var tT=65535,nT=Math.pow(2,16);function F9(e,t){return e+t*nT}function QC(e){return e&tT}function B9(e){return(e-(e&tT))/nT}var rT=1,iT=2,uc=4,oT=8,oa=class{constructor(t,n,i){this.pos=t,this.delInfo=n,this.recover=i}get deleted(){return(this.delInfo&oT)>0}get deletedBefore(){return(this.delInfo&(rT|uc))>0}get deletedAfter(){return(this.delInfo&(iT|uc))>0}get deletedAcross(){return(this.delInfo&uc)>0}},or=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(t){let n=0,i=QC(t);if(!this.inverted)for(let r=0;r<i;r++)n+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[i*3]+n+B9(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,i){let r=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>t)break;let u=this.ranges[a+o],c=this.ranges[a+s],d=l+u;if(t<=d){let f=u?t==l?-1:t==d?1:n:n,p=l+r+(f<0?0:c);if(i)return p;let h=t==(n<0?l:d)?null:F9(a/3,t-l),m=t==l?iT:t==d?rT:uc;return(n<0?t!=l:t!=d)&&(m|=oT),new oa(p,m,h)}r+=c-u}return i?t+r:new oa(t+r,0,null)}touches(t,n){let i=0,r=QC(n),o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>t)break;let u=this.ranges[a+o],c=l+u;if(t<=c&&a==r*3)return!0;i+=this.ranges[a+s]-u}return!1}forEach(t){let n=this.inverted?2:1,i=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let s=this.ranges[r],a=s-(this.inverted?o:0),l=s+(this.inverted?0:o),u=this.ranges[r+n],c=this.ranges[r+i];t(a,a+u,l,l+c),o+=c-u}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};or.empty=new or([]);var sa=class e{constructor(t,n,i=0,r=t?t.length:0){this.mirror=n,this.from=i,this.to=r,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,i=this._maps.length;n<t._maps.length;n++){let r=t.getMirror(n);this.appendMap(t._maps[n],r!=null&&r<n?i+r:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,i=this._maps.length+t._maps.length;n>=0;n--){let r=t.getMirror(n);this.appendMap(t._maps[n].invert(),r!=null&&r>n?i-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let i=this.from;i<this.to;i++)t=this._maps[i].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,i){let r=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],a=s.mapResult(t,n);if(a.recover!=null){let l=this.getMirror(o);if(l!=null&&l>o&&l<this.to){o=l,t=this._maps[l].recover(a.recover);continue}}r|=a.delInfo,t=a.pos}return i?t:new oa(t,r,null)}},Ym=Object.create(null),ht=class{getMap(){return or.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=Ym[n.stepType];if(!i)throw new RangeError(`No step type ${n.stepType} defined`);return i.fromJSON(t,n)}static jsonID(t,n){if(t in Ym)throw new RangeError("Duplicate use of step JSON ID "+t);return Ym[t]=n,n.prototype.jsonID=t,n}},wt=class e{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,i,r){try{return e.ok(t.replace(n,i,r))}catch(o){if(o instanceof fi)return e.fail(o.message);throw o}}};function rg(e,t,n){let i=[];for(let r=0;r<e.childCount;r++){let o=e.child(r);o.content.size&&(o=o.copy(rg(o.content,t,o))),o.isInline&&(o=t(o,n,r)),i.push(o)}return z.fromArray(i)}var aa=class e extends ht{constructor(t,n,i){super(),this.from=t,this.to=n,this.mark=i}apply(t){let n=t.slice(this.from,this.to),i=t.resolve(this.from),r=i.node(i.sharedDepth(this.to)),o=new B(rg(n.content,(s,a)=>!s.isAtom||!a.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),r),n.openStart,n.openEnd);return wt.fromReplace(t,this.from,this.to,o)}invert(){return new sr(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new e(n.pos,i.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))}};ht.jsonID("addMark",aa);var sr=class e extends ht{constructor(t,n,i){super(),this.from=t,this.to=n,this.mark=i}apply(t){let n=t.slice(this.from,this.to),i=new B(rg(n.content,r=>r.mark(this.mark.removeFromSet(r.marks)),t),n.openStart,n.openEnd);return wt.fromReplace(t,this.from,this.to,i)}invert(){return new aa(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new e(n.pos,i.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))}};ht.jsonID("removeMark",sr);var la=class e extends ht{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return wt.fail("No node at mark step's position");let i=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return wt.fromReplace(t,this.pos,this.pos+1,new B(z.from(i),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let i=this.mark.addToSet(n.marks);if(i.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(i))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new go(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new e(n.pos,t.markFromJSON(n.mark))}};ht.jsonID("addNodeMark",la);var go=class e extends ht{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return wt.fail("No node at mark step's position");let i=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return wt.fromReplace(t,this.pos,this.pos+1,new B(z.from(i),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new la(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new e(n.pos,t.markFromJSON(n.mark))}};ht.jsonID("removeNodeMark",go);var St=class e extends ht{constructor(t,n,i,r=!1){super(),this.from=t,this.to=n,this.slice=i,this.structure=r}apply(t){return this.structure&&tg(t,this.from,this.to)?wt.fail("Structure replace would overwrite content"):wt.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new or([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),i=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return i.deletedAcross&&n.deletedAcross?null:new e(i.pos,Math.max(i.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?B.empty:new B(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?B.empty:new B(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new e(n.from,n.to,B.fromJSON(t,n.slice),!!n.structure)}};St.MAP_BIAS=1;ht.jsonID("replace",St);var lt=class e extends ht{constructor(t,n,i,r,o,s,a=!1){super(),this.from=t,this.to=n,this.gapFrom=i,this.gapTo=r,this.slice=o,this.insert=s,this.structure=a}apply(t){if(this.structure&&(tg(t,this.from,this.gapFrom)||tg(t,this.gapTo,this.to)))return wt.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return wt.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,n.content);return i?wt.fromReplace(t,this.from,this.to,i):wt.fail("Content does not fit in gap")}getMap(){return new or([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),i=t.mapResult(this.to,-1),r=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),o=this.to==this.gapTo?i.pos:t.map(this.gapTo,1);return n.deletedAcross&&i.deletedAcross||r<n.pos||o>i.pos?null:new e(n.pos,i.pos,r,o,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new e(n.from,n.to,n.gapFrom,n.gapTo,B.fromJSON(t,n.slice),n.insert,!!n.structure)}};ht.jsonID("replaceAround",lt);function tg(e,t,n){let i=e.resolve(t),r=n-t,o=i.depth;for(;r>0&&o>0&&i.indexAfter(o)==i.node(o).childCount;)o--,r--;if(r>0){let s=i.node(o).maybeChild(i.indexAfter(o));for(;r>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,r--}}return!1}function U9(e,t,n,i){let r=[],o=[],s,a;e.doc.nodesBetween(t,n,(l,u,c)=>{if(!l.isInline)return;let d=l.marks;if(!i.isInSet(d)&&c.type.allowsMarkType(i.type)){let f=Math.max(u,t),p=Math.min(u+l.nodeSize,n),h=i.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(h)||(s&&s.to==f&&s.mark.eq(d[m])?s.to=p:r.push(s=new sr(f,p,d[m])));a&&a.to==f?a.to=p:o.push(a=new aa(f,p,i))}}),r.forEach(l=>e.step(l)),o.forEach(l=>e.step(l))}function j9(e,t,n,i){let r=[],o=0;e.doc.nodesBetween(t,n,(s,a)=>{if(!s.isInline)return;o++;let l=null;if(i instanceof ta){let u=s.marks,c;for(;c=i.isInSet(u);)(l||(l=[])).push(c),u=c.removeFromSet(u)}else i?i.isInSet(s.marks)&&(l=[i]):l=s.marks;if(l&&l.length){let u=Math.min(a+s.nodeSize,n);for(let c=0;c<l.length;c++){let d=l[c],f;for(let p=0;p<r.length;p++){let h=r[p];h.step==o-1&&d.eq(r[p].style)&&(f=h)}f?(f.to=u,f.step=o):r.push({style:d,from:Math.max(a,t),to:u,step:o})}}}),r.forEach(s=>e.step(new sr(s.from,s.to,s.style)))}function ig(e,t,n,i=n.contentMatch,r=!0){let o=e.doc.nodeAt(t),s=[],a=t+1;for(let l=0;l<o.childCount;l++){let u=o.child(l),c=a+u.nodeSize,d=i.matchType(u.type);if(!d)s.push(new St(a,c,B.empty));else{i=d;for(let f=0;f<u.marks.length;f++)n.allowsMarkType(u.marks[f].type)||e.step(new sr(a,c,u.marks[f]));if(r&&u.isText&&n.whitespace!="pre"){let f,p=/\r?\n|\r/g,h;for(;f=p.exec(u.text);)h||(h=new B(z.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),s.push(new St(a+f.index,a+f.index+f[0].length,h))}}a=c}if(!i.validEnd){let l=i.fillBefore(z.empty,!0);e.replace(a,a,new B(l,0,0))}for(let l=s.length-1;l>=0;l--)e.step(s[l])}function Z9(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function ar(e){let n=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let i=e.depth,r=0,o=0;;--i){let s=e.$from.node(i),a=e.$from.index(i)+r,l=e.$to.indexAfter(i)-o;if(i<e.depth&&s.canReplace(a,l,n))return i;if(i==0||s.type.spec.isolating||!Z9(s,a,l))break;a&&(r=1),l<s.childCount&&(o=1)}return null}function H9(e,t,n){let{$from:i,$to:r,depth:o}=t,s=i.before(o+1),a=r.after(o+1),l=s,u=a,c=z.empty,d=0;for(let h=o,m=!1;h>n;h--)m||i.index(h)>0?(m=!0,c=z.from(i.node(h).copy(c)),d++):l--;let f=z.empty,p=0;for(let h=o,m=!1;h>n;h--)m||r.after(h+1)<r.end(h)?(m=!0,f=z.from(r.node(h).copy(f)),p++):u++;e.step(new lt(l,u,s,a,new B(c.append(f),d,p),c.size-d,!0))}function vo(e,t,n=null,i=e){let r=q9(e,t),o=r&&W9(i,t);return o?r.map(eT).concat({type:t,attrs:n}).concat(o.map(eT)):null}function eT(e){return{type:e,attrs:null}}function q9(e,t){let{parent:n,startIndex:i,endIndex:r}=e,o=n.contentMatchAt(i).findWrapping(t);if(!o)return null;let s=o.length?o[0]:t;return n.canReplaceWith(i,r,s)?o:null}function W9(e,t){let{parent:n,startIndex:i,endIndex:r}=e,o=n.child(i),s=t.contentMatch.findWrapping(o.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let u=i;l&&u<r;u++)l=l.matchType(n.child(u).type);return!l||!l.validEnd?null:s}function V9(e,t,n){let i=z.empty;for(let s=n.length-1;s>=0;s--){if(i.size){let a=n[s].type.contentMatch.matchFragment(i);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=z.from(n[s].type.create(n[s].attrs,i))}let r=t.start,o=t.end;e.step(new lt(r,o,r,o,new B(i,0,0),n.length,!0))}function J9(e,t,n,i,r){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,n,(s,a)=>{let l=typeof r=="function"?r(s):r;if(s.isTextblock&&!s.hasMarkup(i,l)&&K9(e.doc,e.mapping.slice(o).map(a),i)){let u=null;if(i.schema.linebreakReplacement){let p=i.whitespace=="pre",h=!!i.contentMatch.matchType(i.schema.linebreakReplacement);p&&!h?u=!1:!p&&h&&(u=!0)}u===!1&&aT(e,s,a,o),ig(e,e.mapping.slice(o).map(a,1),i,void 0,u===null);let c=e.mapping.slice(o),d=c.map(a,1),f=c.map(a+s.nodeSize,1);return e.step(new lt(d,f,d+1,f-1,new B(z.from(i.create(l,null,s.marks)),0,0),1,!0)),u===!0&&sT(e,s,a,o),!1}})}function sT(e,t,n,i){t.forEach((r,o)=>{if(r.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(r.text);){let l=e.mapping.slice(i).map(n+1+o+s.index);e.replaceWith(l,l+1,t.type.schema.linebreakReplacement.create())}}})}function aT(e,t,n,i){t.forEach((r,o)=>{if(r.type==r.type.schema.linebreakReplacement){let s=e.mapping.slice(i).map(n+1+o);e.replaceWith(s,s+1,t.type.schema.text(`
|
|
@@ -372,7 +372,7 @@ ${s}`;if(i.indexOf(c)!==-1)continue;let d=[{joiner:" ",b:s},{joiner:"",b:s}];if(
|
|
|
372
372
|
`}}var jW={js:"javascript",cjs:"javascript",mjs:"javascript",ts:"typescript",jsx:"javascript",tsx:"typescript",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",ini:"ini",xml:"xml",html:"html",htm:"html",css:"css",scss:"css",less:"css",sh:"bash",bash:"bash",zsh:"bash",py:"python",rb:"ruby",java:"java",go:"go",rs:"rust",sql:"sql",md:"markdown",markdown:"markdown"};function ZW(e){let t=e.toLowerCase().match(/\.([a-z0-9]+)$/);return t?t[1]:""}function Dv(e){let t=ZW(e);return jW[t]??"text"}function oM(e,t){if(Dv(t)!=="json")return{content:e};try{return{content:`${JSON.stringify(JSON.parse(e),null,2)}
|
|
373
373
|
`}}catch{return{content:e,notice:"Invalid JSON. Showing raw source."}}}function Ya(e,t="text",n=1){let o=Yu(e,t||"text").split(`
|
|
374
374
|
`);return o.length>0&&o[o.length-1]===""&&o.pop(),`<pre class="code-viewer"><table class="code-table"><tbody>${o.map((a,l)=>{let u=n+l;return`<tr class="code-line" data-line="${u}"><td class="line-num" data-line="${u}">${u}</td><td class="line-content">${a||" "}</td></tr>`}).join(`
|
|
375
|
-
`)}</tbody></table></pre>`}function HW(){if(typeof window>"u"||typeof document>"u")return{background:"Canvas",text:"CanvasText",fontFamily:"system-ui, sans-serif"};let e=window.getComputedStyle(document.documentElement),t=e.getPropertyValue("--panel").trim()||"Canvas",n=e.getPropertyValue("--text").trim()||"CanvasText",i=e.getPropertyValue("--font-sans").trim()||"system-ui, sans-serif";return{background:t,text:n,fontFamily:i}}function qW(e){let t=HW(),n=`<!doctype html><html><head><meta charset="utf-8" /><style>html,body{margin:0;padding:0;background:${t.background};color:${t.text};}body{font-family:${t.fontFamily};padding:16px;line-height:1.5;}img{max-width:100%;height:auto;}</style></head><body>${e}</body></html>`;return`<iframe class="html-rendered-frame" title="Rendered HTML preview" sandbox="allow-scripts allow-forms allow-popups" referrerpolicy="no-referrer" srcdoc="${_t(n)}"></iframe>`}function sM(e,t){if(t==="source")return{html:`<div class="panel-content source-content">${Ya(e,"html")}</div>`};try{return{html:`<div class="panel-content html-content">${qW(e)}</div>`}}catch{return{html:`<div class="panel-content source-content">${Ya(e,"html")}</div>`,notice:"HTML renderer failed. Showing source instead."}}}var WW=new Set(["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/svg","image/svg+xml"]);function Ov(e){return e?e.toLowerCase().split(";",1)[0].trim():""}function aM(e){let t=Ov(e);return t.length>0&&WW.has(t)}function lM(e){return`<pre class="code-viewer"><code class="hljs language-text">${_t(e)}</code></pre>`}function VW(e){let t=Ov(e.mimeType);if(!aM(t))return{notice:"Preview is unavailable for this image format.",html:'<div class="panel-content source-content"></div>'};if(!e.
|
|
375
|
+
`)}</tbody></table></pre>`}function HW(){if(typeof window>"u"||typeof document>"u")return{background:"Canvas",text:"CanvasText",fontFamily:"system-ui, sans-serif"};let e=window.getComputedStyle(document.documentElement),t=e.getPropertyValue("--panel").trim()||"Canvas",n=e.getPropertyValue("--text").trim()||"CanvasText",i=e.getPropertyValue("--font-sans").trim()||"system-ui, sans-serif";return{background:t,text:n,fontFamily:i}}function qW(e){let t=HW(),n=`<!doctype html><html><head><meta charset="utf-8" /><style>html,body{margin:0;padding:0;background:${t.background};color:${t.text};}body{font-family:${t.fontFamily};padding:16px;line-height:1.5;}img{max-width:100%;height:auto;}</style></head><body>${e}</body></html>`;return`<iframe class="html-rendered-frame" title="Rendered HTML preview" sandbox="allow-scripts allow-forms allow-popups" referrerpolicy="no-referrer" srcdoc="${_t(n)}"></iframe>`}function sM(e,t){if(t==="source")return{html:`<div class="panel-content source-content">${Ya(e,"html")}</div>`};try{return{html:`<div class="panel-content html-content">${qW(e)}</div>`}}catch{return{html:`<div class="panel-content source-content">${Ya(e,"html")}</div>`,notice:"HTML renderer failed. Showing source instead."}}}var WW=new Set(["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/svg","image/svg+xml"]);function Ov(e){return e?e.toLowerCase().split(";",1)[0].trim():""}function aM(e){let t=Ov(e);return t.length>0&&WW.has(t)}function lM(e){return`<pre class="code-viewer"><code class="hljs language-text">${_t(e)}</code></pre>`}function VW(e){let t=Ov(e.mimeType);if(!aM(t))return{notice:"Preview is unavailable for this image format.",html:'<div class="panel-content source-content"></div>'};if(!e.content||e.content.trim().length===0)return{notice:"Preview is unavailable because image data is missing.",html:'<div class="panel-content source-content"></div>'};let n=`data:${t};base64,${e.content}`;return{html:`<div class="panel-content image-content"><div class="image-preview"><img src="${_t(n)}" alt="${_t(e.fileName)}" loading="eager" decoding="async"></div></div>`}}function Qa(e,t){return{supportsPreview:!0,canCopy:t,canOpenInFolder:!Ir(e.filePath)}}var Rv={directory:{getCapabilities:e=>Qa(e,!1),renderBody:({payload:e})=>$C(tt(e.content),e.filePath)},html:{getCapabilities:e=>Qa(e,!0),renderBody:({payload:e,htmlMode:t})=>sM(tt(e.content),t)},image:{getCapabilities:e=>Qa(e,!1),renderBody:({payload:e})=>VW(e)},markdown:{getCapabilities:e=>Qa(e,!1),renderBody:({payload:e,markdownController:t})=>{try{return t.buildBody(e)}catch{return{notice:"Markdown renderer failed. Showing raw source instead.",html:`<div class="panel-content source-content">${lM(tt(e.content))}</div>`}}}},text:{getCapabilities:e=>Qa(e,!0),renderBody:({payload:e,startLine:t})=>{let n=tt(e.content),i=Dv(e.filePath),r=oM(n,e.filePath);return{notice:r.notice,html:`<div class="panel-content source-content">${Ya(r.content,i,t)}</div>`}}},unsupported:{getCapabilities:e=>{let t=tt(e.content).trim().length>0;return{supportsPreview:t,canCopy:t,canOpenInFolder:!Ir(e.filePath)}},renderBody:({payload:e})=>{let t=tt(e.content);return t.trim().length===0?{notice:"Preview is not available for this file type.",html:'<div class="panel-content source-content"></div>'}:{html:`<div class="panel-content source-content">${lM(t)}</div>`}}}};function uM(e){return Rv[e.fileType]?.getCapabilities(e)??{supportsPreview:!1,canCopy:!1,canOpenInFolder:!Ir(e.filePath)}}function cM(e){return(Rv[e.payload.fileType]??Rv.text).renderBody(e)}function jo(e){return`'${e.replace(/'/g,"'\\''")}'`}function dM(e){let t=[];for(let i=0;i<e.length;i+=1){let r=e.charCodeAt(i);t.push(r&255,r>>8)}let n="";for(let i of t)n+=String.fromCharCode(i);return btoa(n)}function Pv(e,t){let n=e.trim();if(!n||t(n))return;let i=navigator.userAgent.toLowerCase();if(i.includes("win")){let o=`Start-Process -FilePath explorer.exe -ArgumentList @('/select,','${n.replace(/'/g,"''")}')`;return`powershell.exe -NoProfile -NonInteractive -EncodedCommand ${dM(o)}`}return i.includes("mac")?`open -R ${jo(n)}`:`xdg-open ${jo(Fi(n))}`}function fM(e,t,n){let i=e.trim();if(!i||t(i))return;let r=n.get(i);if(r?.appPath&&navigator.userAgent.toLowerCase().includes("mac"))return`open -a ${jo(r.appPath)} ${jo(i)}`;let o=navigator.userAgent.toLowerCase();if(o.includes("win")){let a=`Start-Process -FilePath '${i.replace(/'/g,"''")}'`;return`powershell.exe -NoProfile -NonInteractive -EncodedCommand ${dM(a)}`}return o.includes("mac")?`open ${jo(i)}`:`xdg-open ${jo(i)}`}function pM(){return'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 1 1 3 3L7 19l-4 1 1-4Z"/></svg>'}function hM(e){if(e.isMarkdownEditing)return e.previousAbortController&&e.previousAbortController.abort(),null;let t=document.querySelector(".panel-content-wrapper");if(!t)return e.previousAbortController;let n=t;e.previousAbortController?.abort();let i=new AbortController,r=null,o="",s=null;function a(d){if(!r)return;let p=d.getRangeAt(0).getBoundingClientRect(),h=n.getBoundingClientRect(),m=p.left+p.width/2-h.left,g=p.top-h.top+n.scrollTop-32,b=r.offsetWidth||200;m=Math.max(8,Math.min(m-b/2,n.clientWidth-b-8)),g=Math.max(4,g),r.style.left=`${m}px`,r.style.top=`${g}px`}function l(d){s&&(clearTimeout(s),s=null),r||(r=document.createElement("div"),r.className="selection-hint",r.textContent="AI can see your selection",n.appendChild(r)),r.classList.add("visible"),a(d)}function u(){r&&(r.classList.remove("visible"),s=setTimeout(()=>{r?.remove(),r=null},200))}function c(d){let f=d.anchorNode?.parentElement?.closest(".code-line"),p=d.focusNode?.parentElement?.closest(".code-line");if(f&&p){let h=parseInt(f.dataset.line??"",10),m=parseInt(p.dataset.line??"",10);if(!isNaN(h)&&!isNaN(m)){let g=Math.min(h,m),b=Math.max(h,m);return g===b?`line ${g}`:`lines ${g}\u2013${b}`}}return""}return document.addEventListener("selectionchange",()=>{let d=document.getSelection();if(!d||d.isCollapsed){o&&(o="",e.updateContext?.(""),u());return}let f=d.toString().trim();if(!f||f===o)return;let p=n.contains(d.anchorNode),h=n.contains(d.focusNode);if(!p&&!h){o&&(o="",e.updateContext?.(""),u());return}o=f;let m=c(d),g=m?` (${m})`:"",b=`User selected text from file ${e.payload.filePath}${g}:
|
|
376
376
|
\`\`\`
|
|
377
377
|
${f}
|
|
378
378
|
\`\`\``;e.updateContext?.(b),l(d),e.trackUiEvent?.("text_selected",{file_type:e.payload.fileType,file_extension:e.getFileExtensionForAnalytics(e.payload.filePath),char_count:f.length})},{signal:i.signal}),i}function Lv(e,t){Array.from(e.querySelectorAll("[data-toc-id]")).forEach(i=>{let r=i.dataset.tocId===t;i.classList.toggle("is-active",r),i.setAttribute("aria-current",r?"location":"false")})}function mM(e,t){return e.map(n=>`<button class="document-outline-link markdown-toc-link${n.id===t?" is-active":""}" type="button" data-toc-id="${pn(n.id)}" data-level="${n.level}" aria-current="${n.id===t?"location":"false"}">${pn(n.text)}</button>`).join("")}function gM(){return'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>'}function JW(){return'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>'}function bM(e,t){return e.length===0?"":`
|
|
@@ -403,7 +403,7 @@ ${f}
|
|
|
403
403
|
`),r=t.split(`
|
|
404
404
|
`),o=i.length*r.length>1e6?rV(i,r):eV(i,r);if(o.length===0)return[];let s=3,a=$M(n),u=tV(o,s*2+1).filter(c=>nV(c,a)).map(c=>{let d=Math.max(0,c.oldStart-s),f=Math.min(i.length,c.oldEnd+s),p=i.slice(d,f).join(`
|
|
405
405
|
`),h=[...i.slice(d,c.oldStart),...r.slice(c.newStart,c.newEnd),...i.slice(c.oldEnd,f)].join(`
|
|
406
|
-
`);return{old_string:p,new_string:h}}).filter(c=>c.old_string!==c.new_string);return u.length===1&&u[0].old_string===e&&u[0].new_string===t?CM(e,t):iV(u)}function sV(e,t){return t.reduce((n,i)=>n.replace(i.old_string,i.new_string),e)}function aV(e){return typeof e=="object"&&e!==null}function lV(e){if(!aV(e)||e.isError!==!0)return!1;let t=Nt(e)?.toLowerCase()??"";return t.includes("not found")||t.includes("no such file")||t.includes("enoent")}function TM(e){let t,n,i,r=null,o=1e3;function s(){r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,A()},o)}function a(){r!==null&&(clearTimeout(r),r=null)}function l(){a(),n?.destroy(),n=void 0,i?.dispose(),i=void 0}function u(){t=void 0,l()}function c(k){return tt(k.content)}function d(k,S,O={}){let L=O.keepDraft?k.draftContent:S;k.sourceContent=S,k.fullDocumentContent=S,k.draftContent=L,k.outline=Zo(S),k.dirty=L!==S,k.dirtyLineRanges=[],k.fileDeleted=!1,k.outline.some(oe=>oe.id===k.activeHeadingId)||(k.activeHeadingId=k.outline[0]?.id??null)}async function f(k,S,O){let L=await e.callTool?.("read_file",{path:k,...typeof S=="number"?{offset:O??0,length:S}:{}});return{rawResult:L,payload:tc(L)??null}}async function p(k,S,O){return(await f(k,S,O)).payload}async function h(k){let S=jt(k.content);return S?.isPartial?await p(k.filePath,S.totalLines)??k:k}async function m(k){let S=await p(k);return S?h(S):null}function g(k){let S=tt(k.content);if(!t||t.filePath!==k.filePath||t.sourceContent!==S){let O=Zo(S);t={filePath:k.filePath,sourceContent:S,fullDocumentContent:S,draftContent:S,outline:O,mode:"edit",dirty:!1,dirtyLineRanges:[],activeHeadingId:O[0]?.id??null,pendingAnchor:null,notice:null,error:null,saving:!1,loadingDocument:!1,editorView:"markdown",editorScrollTop:0,saveIndicator:"idle",fileDeleted:!1}}return t}function b(k){return k.draftContent!==k.fullDocumentContent}function v(k){let S=g(k),O=S.outline,oe=e.getCurrentDisplayMode()==="fullscreen"?bM(O,S.activeHeadingId):"";return!S.activeHeadingId&&O.length>0&&(S.activeHeadingId=O[0].id),{notice:[S.error,S.notice].find($e=>typeof $e=="string"&&$e.trim().length>0),html:`
|
|
406
|
+
`);return{old_string:p,new_string:h}}).filter(c=>c.old_string!==c.new_string);return u.length===1&&u[0].old_string===e&&u[0].new_string===t?CM(e,t):iV(u)}function sV(e,t){return t.reduce((n,i)=>n.replace(i.old_string,i.new_string),e)}function aV(e){return typeof e=="object"&&e!==null}function lV(e){if(!aV(e)||e.isError!==!0)return!1;let t=Nt(e)?.toLowerCase()??"";return t.includes("not found")||t.includes("no such file")||t.includes("enoent")}function TM(e){let t,n,i,r=null,o=1e3;function s(){r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,A()},o)}function a(){r!==null&&(clearTimeout(r),r=null)}function l(){a(),n?.destroy(),n=void 0,i?.dispose(),i=void 0}function u(){t=void 0,l()}function c(k){return tt(k.content)}function d(k,S,O={}){let L=O.keepDraft?k.draftContent:S;k.sourceContent=S,k.fullDocumentContent=S,k.draftContent=L,k.outline=Zo(S),k.dirty=L!==S,k.dirtyLineRanges=[],k.fileDeleted=!1,k.outline.some(oe=>oe.id===k.activeHeadingId)||(k.activeHeadingId=k.outline[0]?.id??null)}async function f(k,S,O){let L=await e.callTool?.("read_file",{path:k,...typeof S=="number"?{offset:O??0,length:S}:{},origin:"ui"});return{rawResult:L,payload:tc(L)??null}}async function p(k,S,O){return(await f(k,S,O)).payload}async function h(k){let S=jt(k.content);return S?.isPartial?await p(k.filePath,S.totalLines)??k:k}async function m(k){let S=await p(k);return S?h(S):null}function g(k){let S=tt(k.content);if(!t||t.filePath!==k.filePath||t.sourceContent!==S){let O=Zo(S);t={filePath:k.filePath,sourceContent:S,fullDocumentContent:S,draftContent:S,outline:O,mode:"edit",dirty:!1,dirtyLineRanges:[],activeHeadingId:O[0]?.id??null,pendingAnchor:null,notice:null,error:null,saving:!1,loadingDocument:!1,editorView:"markdown",editorScrollTop:0,saveIndicator:"idle",fileDeleted:!1}}return t}function b(k){return k.draftContent!==k.fullDocumentContent}function v(k){let S=g(k),O=S.outline,oe=e.getCurrentDisplayMode()==="fullscreen"?bM(O,S.activeHeadingId):"";return!S.activeHeadingId&&O.length>0&&(S.activeHeadingId=O[0].id),{notice:[S.error,S.notice].find($e=>typeof $e=="string"&&$e.trim().length>0),html:`
|
|
407
407
|
<div class="panel-content markdown-content markdown-content--workspace">
|
|
408
408
|
<div class="markdown-workspace markdown-workspace--edit${oe?" markdown-workspace--with-toc":""}">
|
|
409
409
|
${oe}
|
|
@@ -412,7 +412,7 @@ ${f}
|
|
|
412
412
|
</section>
|
|
413
413
|
</div>
|
|
414
414
|
</div>
|
|
415
|
-
`}}async function x(k){let S=Lz(k),O=new Set(["[DIR] .git","[DIR] .obsidian","[FILE] package.json","[FILE] pnpm-workspace.yaml","[FILE] turbo.json"]);for(let L of S)try{let oe=await e.callTool?.("list_directory",{path:L,depth:1}),ee=Nt(oe)??"";if(YW(ee).some(ft=>O.has(ft)))return L}catch{}return Fi(k)}async function _(k,S){let O=S.trim();if(O.length===0)return[];let L=await x(k),oe=await e.callTool?.("start_search",{path:L,pattern:O,searchType:"files",filePattern:"*.md",maxResults:20,earlyTermination:!1,literalSearch:!0}),ee=Nt(oe)??"",$e=QW(ee),ft=Fi(k);return $e.map(ke=>{let Re=ke.replace(/\\/g,"/"),bt=Re.split("/").pop()??Re,Tt=SM(bt),Xe=Fz(ft,Re),Ne=SM(Xe.startsWith("./")?Xe.slice(2):Xe);return{path:Re,title:Tt,wikiPath:Ne,relativePath:Xe}})}async function E(k,S){if(S===k&&t)return t.outline.map(L=>({id:L.id,text:L.text}));let O=await m(S);return O?Zo(c(O)).map(L=>({id:L.id,text:L.text})):[]}function T(k){let S=k.trim();return S?document.getElementById(S)??document.getElementById(Pi(S)):null}function N(k){let S=T(k);if(!S)return!1;let O=[],L=S.parentElement;for(;L;){let $e=window.getComputedStyle(L).overflowY;($e==="auto"||$e==="scroll"||$e==="overlay")&&L.scrollHeight>L.clientHeight&&O.push(L),L=L.parentElement}S.scrollIntoView({block:"start",inline:"nearest"});for(let ee of O){let $e=ee.getBoundingClientRect(),ft=S.getBoundingClientRect(),ke=Math.max(ee.scrollTop+(ft.top-$e.top)-24,0);ee.scrollTop=ke}let oe=document.scrollingElement;if(oe){let ee=S.getBoundingClientRect().top,$e=Math.max(oe.scrollTop+ee-24,0);oe.scrollTop=$e}return S.setAttribute("tabindex","-1"),S.focus({preventScroll:!0}),t&&(t.activeHeadingId=S.id||Pi(k)),!0}function M(){let k=t?.pendingAnchor;!t||!k||(t.pendingAnchor=null,N(k)||(t.error=`Heading not found: ${k}`,e.rerender()))}function H(k,S,O,L){e.updateSaveStatus(k,S),window.setTimeout(()=>{L&&!L()||e.updateSaveStatus("","")},O)}async function ce(k){try{let S=jt(k.content),{rawResult:O,payload:L}=S?.isPartial?await f(k.filePath,S.toLine-S.fromLine+1,S.readOffset):await f(k.filePath);if(!L){lV(O)&&(t&&(t.fileDeleted=!0),e.updateSaveStatus("File deleted","saved"));return}let oe=c(L),ee=c(k);if(oe===ee)return;e.storePayloadOverride(L),t=void 0,e.rerender()}catch{}}async function Ze(k,S={}){let O=g(k),L=jt(k.content);if(!L?.isPartial){S.keepEditMode&&(O.mode="edit",O.editorView="markdown",O.notice=null,O.error=null,O.draftContent=O.sourceContent,O.dirty=!1,e.rerender());return}O.loadingDocument=!0,O.notice="Loading full document\u2026",O.error=null,e.rerender();try{let oe=await p(k.filePath,L.totalLines);if(!oe){O.error="Failed to load the full document.",O.notice=null,O.loadingDocument=!1,e.rerender();return}e.syncPayload?.(oe);let ee=g(oe);ee.loadingDocument=!1,ee.notice=null,ee.error=null,d(ee,ee.sourceContent),S.keepEditMode&&(ee.mode="edit",ee.editorView="markdown",e.rerender())}catch{O.loadingDocument=!1,O.notice=null,O.error="Failed to load the full document.",e.rerender()}}async function Fe(k,S){let O=g(k);if(O.dirty&&!window.confirm("Discard unsaved changes and follow this link?"))return;let L=qz(k.filePath,S);if(O.notice=null,O.error=null,L.kind==="external"&&L.url){if(!await e.openExternalLink?.(L.url))try{window.open(L.url,"_blank","noopener")}catch{}return}if(L.kind==="anchor"&&L.anchor){!N(L.anchor)&&t&&(t.error=`Heading not found: ${L.anchor}`,e.rerender());return}if(L.kind==="file"&&L.targetPath){if(await e.openExternalLink?.(L.targetPath))return;let ee=await p(L.targetPath);if(!ee){t&&(t.error=`Unable to open ${L.targetPath}.`,e.rerender());return}e.syncPayload?.(ee);let $e=g(ee);$e.pendingAnchor=L.anchor??null,$e.error=null,$e.notice=null,e.rerender()}}async function Ie(k){let S=g(k);if(S.error=null,S.notice=null,_C(k.content)){await Ze(k,{keepEditMode:!0});return}S.mode="edit",S.draftContent=S.fullDocumentContent,S.dirty=!1,S.editorView="markdown",e.setExpanded(!0),e.rerender()}async function ve(){return Qu({availableDisplayModes:e.getAvailableDisplayModes()}).canFullscreen?await e.requestDisplayMode?.("fullscreen")==="fullscreen":!1}function Y(){if(!t)return;let k=t.filePath;t.draftContent=t.fullDocumentContent,t.dirty=!1,t.dirtyLineRanges=[],t.error=null,t.notice=null,e.rerender(),H("Reverted","saved",1500),e.trackUiEvent?.("markdown_reverted",{file_extension:Zt(k)})}async function A(){if(!t||t.saving||!t.dirty||t.fileDeleted)return;a();let k=t;k.saving=!0,k.saveIndicator="saving",k.error=null,k.notice=null;try{let S=oV(k.fullDocumentContent,k.draftContent,k.dirtyLineRanges);if(S.length===0){k.saving=!1,k.saveIndicator="idle",k.dirty=!1,k.dirtyLineRanges=[];return}let O=0,L=[],oe=null;for(let ke of S)try{let Re=await e.callTool?.("edit_block",{file_path:k.filePath,old_string:ke.old_string,new_string:ke.new_string,expected_replacements:1});wC(Re),O++}catch(Re){L.push(ke),oe=Re}if(L.length>0){let ke=new Error(`${O} of ${S.length} edit${S.length===1?"":"s"} applied; ${L.length} could not land because the text changed on disk.`);throw ke.appliedCount=O,ke.skippedCount=L.length,ke.totalCount=S.length,ke.underlyingError=oe,ke}let ee=sV(k.fullDocumentContent,S);k.fullDocumentContent=ee,k.sourceContent=ee,k.draftContent=ee,k.outline=Zo(k.sourceContent),k.dirty=!1,k.dirtyLineRanges=[],k.saving=!1,k.saveIndicator="saved",k.outline.some(ke=>ke.id===k.activeHeadingId)||(k.activeHeadingId=k.outline[0]?.id??null);let $e=e.getCurrentPayload();if($e){let Re=$e.content.match(/^(\[Reading [^\]]+\]\r?\n(?:\r?\n)?)/)?.[1]??"";e.storePayloadOverride({...$e,content:Re+ee})}let ft=document.getElementById("revert-markdown");ft&&(ft.disabled=!b(k)),H("Saved","saved",1800,()=>!k.dirty&&!k.saving?(k.saveIndicator="idle",!0):!1),e.trackUiEvent?.("markdown_saved",{file_extension:Zt(k.filePath),blocks:S.length})}catch(S){k.saving=!1,k.saveIndicator="idle";let O=S,L=typeof O.appliedCount=="number"?O.appliedCount:0,oe=typeof O.skippedCount=="number"?O.skippedCount:0,ee=typeof O.totalCount=="number"?O.totalCount:0,$e=L>0&&oe>0,ft=L===0&&oe>0,ke=await m(k.filePath).catch(()=>null),Re=!1,bt=null;if(ke){let Tt=c(ke);Tt!==k.fullDocumentContent&&(d(k,Tt,{keepDraft:!0}),e.storePayloadOverride(ke),Re=!0,bt=Tt)}if(k.notice=null,$e)k.error=`${L} of ${ee} edit${ee===1?"":"s"} saved. ${oe} ${oe===1?"edit":"edits"} did not apply because that text changed on disk \u2014 your draft still has them; save again to merge.`,e.rerender(),H("Saved (partial)","saved",3e3),e.trackUiEvent?.("markdown_save_partial",{file_extension:Zt(k.filePath),applied:L,skipped:oe,total:ee});else if(ft&&Re&&e.showConflictDialog&&bt!==null){let Tt=bt,Ne=k.filePath.replace(/\\/g,"/").split("/").pop()||k.filePath;k.error=null,e.rerender(),e.trackUiEvent?.("markdown_save_conflict_shown",{file_extension:Zt(k.filePath)}),e.showConflictDialog({fileName:Ne,onUseDiskVersion:()=>{t===k&&(d(k,Tt),e.rerender()),e.trackUiEvent?.("markdown_save_conflict_resolved",{file_extension:Zt(k.filePath),action:"use_disk"})},onSaveMyChanges:()=>{e.trackUiEvent?.("markdown_save_conflict_resolved",{file_extension:Zt(k.filePath),action:"save_mine"}),A()},onCancel:()=>{t===k&&(k.error="File changed on disk. Save again to merge your edits, or reopen to discard them.",e.rerender()),e.trackUiEvent?.("markdown_save_conflict_resolved",{file_extension:Zt(k.filePath),action:"dismissed"})}})}else k.error=Re?"File changed on disk. Save again to merge your edits, or reopen the file to discard them.":S instanceof Error?S.message:"Save failed.",e.rerender(),H("Save failed","saving",3e3);e.trackUiEvent?.("markdown_save_failed",{file_extension:Zt(k.filePath),reloaded_from_disk:Re,applied:L,skipped:oe,total:ee})}}function Z(k,S){let O=g(k),L=document.querySelector(".panel-content-wrapper");O.editorScrollTop=L?.scrollTop??0;let oe=O.editorView;O.editorView=S,O.notice=null,O.error=null,e.rerender(),oe!==S&&e.trackUiEvent?.("markdown_view_toggled",{file_extension:Zt(k.filePath),view:S}),typeof O.editorScrollTop=="number"&&window.requestAnimationFrame(()=>{let ee=document.querySelector(".panel-content-wrapper");ee&&(ee.scrollTop=O.editorScrollTop)})}function q(k){let S=g(k),O=document.querySelector(".panel-content-wrapper"),L=S.outline,oe=Zt(k.filePath),ee=!1;{let ke=document.getElementById("markdown-editor-root");ke&&(n=nM({target:ke,value:S.draftContent,view:S.editorView,initialScrollTop:S.editorScrollTop,currentFilePath:k.filePath,searchLinks:Xe=>_(k.filePath,Xe),loadHeadings:Xe=>E(k.filePath,Xe),onChange:(Xe,Ne)=>{if(Xe===S.draftContent)return;if(S.draftContent=Xe,S.dirty=Xe!==S.fullDocumentContent,S.dirty){let An=Ne&&Ne.length>0?Ne:[{fromLine:1,toLine:Xe.split(`
|
|
415
|
+
`}}async function x(k){let S=Lz(k),O=new Set(["[DIR] .git","[DIR] .obsidian","[FILE] package.json","[FILE] pnpm-workspace.yaml","[FILE] turbo.json"]);for(let L of S)try{let oe=await e.callTool?.("list_directory",{path:L,depth:1,origin:"ui"}),ee=Nt(oe)??"";if(YW(ee).some(ft=>O.has(ft)))return L}catch{}return Fi(k)}async function _(k,S){let O=S.trim();if(O.length===0)return[];let L=await x(k),oe=await e.callTool?.("start_search",{path:L,pattern:O,searchType:"files",filePattern:"*.md",maxResults:20,earlyTermination:!1,literalSearch:!0}),ee=Nt(oe)??"",$e=QW(ee),ft=Fi(k);return $e.map(ke=>{let Re=ke.replace(/\\/g,"/"),bt=Re.split("/").pop()??Re,Tt=SM(bt),Xe=Fz(ft,Re),Ne=SM(Xe.startsWith("./")?Xe.slice(2):Xe);return{path:Re,title:Tt,wikiPath:Ne,relativePath:Xe}})}async function E(k,S){if(S===k&&t)return t.outline.map(L=>({id:L.id,text:L.text}));let O=await m(S);return O?Zo(c(O)).map(L=>({id:L.id,text:L.text})):[]}function T(k){let S=k.trim();return S?document.getElementById(S)??document.getElementById(Pi(S)):null}function N(k){let S=T(k);if(!S)return!1;let O=[],L=S.parentElement;for(;L;){let $e=window.getComputedStyle(L).overflowY;($e==="auto"||$e==="scroll"||$e==="overlay")&&L.scrollHeight>L.clientHeight&&O.push(L),L=L.parentElement}S.scrollIntoView({block:"start",inline:"nearest"});for(let ee of O){let $e=ee.getBoundingClientRect(),ft=S.getBoundingClientRect(),ke=Math.max(ee.scrollTop+(ft.top-$e.top)-24,0);ee.scrollTop=ke}let oe=document.scrollingElement;if(oe){let ee=S.getBoundingClientRect().top,$e=Math.max(oe.scrollTop+ee-24,0);oe.scrollTop=$e}return S.setAttribute("tabindex","-1"),S.focus({preventScroll:!0}),t&&(t.activeHeadingId=S.id||Pi(k)),!0}function M(){let k=t?.pendingAnchor;!t||!k||(t.pendingAnchor=null,N(k)||(t.error=`Heading not found: ${k}`,e.rerender()))}function H(k,S,O,L){e.updateSaveStatus(k,S),window.setTimeout(()=>{L&&!L()||e.updateSaveStatus("","")},O)}async function ce(k){try{let S=jt(k.content),{rawResult:O,payload:L}=S?.isPartial?await f(k.filePath,S.toLine-S.fromLine+1,S.readOffset):await f(k.filePath);if(!L){lV(O)&&(t&&(t.fileDeleted=!0),e.updateSaveStatus("File deleted","saved"));return}let oe=c(L),ee=c(k);if(oe===ee)return;e.storePayloadOverride(L),t=void 0,e.rerender()}catch{}}async function Ze(k,S={}){let O=g(k),L=jt(k.content);if(!L?.isPartial){S.keepEditMode&&(O.mode="edit",O.editorView="markdown",O.notice=null,O.error=null,O.draftContent=O.sourceContent,O.dirty=!1,e.rerender());return}O.loadingDocument=!0,O.notice="Loading full document\u2026",O.error=null,e.rerender();try{let oe=await p(k.filePath,L.totalLines);if(!oe){O.error="Failed to load the full document.",O.notice=null,O.loadingDocument=!1,e.rerender();return}e.syncPayload?.(oe);let ee=g(oe);ee.loadingDocument=!1,ee.notice=null,ee.error=null,d(ee,ee.sourceContent),S.keepEditMode&&(ee.mode="edit",ee.editorView="markdown",e.rerender())}catch{O.loadingDocument=!1,O.notice=null,O.error="Failed to load the full document.",e.rerender()}}async function Fe(k,S){let O=g(k);if(O.dirty&&!window.confirm("Discard unsaved changes and follow this link?"))return;let L=qz(k.filePath,S);if(O.notice=null,O.error=null,L.kind==="external"&&L.url){if(!await e.openExternalLink?.(L.url))try{window.open(L.url,"_blank","noopener")}catch{}return}if(L.kind==="anchor"&&L.anchor){!N(L.anchor)&&t&&(t.error=`Heading not found: ${L.anchor}`,e.rerender());return}if(L.kind==="file"&&L.targetPath){if(await e.openExternalLink?.(L.targetPath))return;let ee=await p(L.targetPath);if(!ee){t&&(t.error=`Unable to open ${L.targetPath}.`,e.rerender());return}e.syncPayload?.(ee);let $e=g(ee);$e.pendingAnchor=L.anchor??null,$e.error=null,$e.notice=null,e.rerender()}}async function Ie(k){let S=g(k);if(S.error=null,S.notice=null,_C(k.content)){await Ze(k,{keepEditMode:!0});return}S.mode="edit",S.draftContent=S.fullDocumentContent,S.dirty=!1,S.editorView="markdown",e.setExpanded(!0),e.rerender()}async function ve(){return Qu({availableDisplayModes:e.getAvailableDisplayModes()}).canFullscreen?await e.requestDisplayMode?.("fullscreen")==="fullscreen":!1}function Y(){if(!t)return;let k=t.filePath;t.draftContent=t.fullDocumentContent,t.dirty=!1,t.dirtyLineRanges=[],t.error=null,t.notice=null,e.rerender(),H("Reverted","saved",1500),e.trackUiEvent?.("markdown_reverted",{file_extension:Zt(k)})}async function A(){if(!t||t.saving||!t.dirty||t.fileDeleted)return;a();let k=t;k.saving=!0,k.saveIndicator="saving",k.error=null,k.notice=null;try{let S=oV(k.fullDocumentContent,k.draftContent,k.dirtyLineRanges);if(S.length===0){k.saving=!1,k.saveIndicator="idle",k.dirty=!1,k.dirtyLineRanges=[];return}let O=0,L=[],oe=null;for(let ke of S)try{let Re=await e.callTool?.("edit_block",{file_path:k.filePath,old_string:ke.old_string,new_string:ke.new_string,expected_replacements:1,origin:"ui"});wC(Re),O++}catch(Re){L.push(ke),oe=Re}if(L.length>0){let ke=new Error(`${O} of ${S.length} edit${S.length===1?"":"s"} applied; ${L.length} could not land because the text changed on disk.`);throw ke.appliedCount=O,ke.skippedCount=L.length,ke.totalCount=S.length,ke.underlyingError=oe,ke}let ee=sV(k.fullDocumentContent,S);k.fullDocumentContent=ee,k.sourceContent=ee,k.draftContent=ee,k.outline=Zo(k.sourceContent),k.dirty=!1,k.dirtyLineRanges=[],k.saving=!1,k.saveIndicator="saved",k.outline.some(ke=>ke.id===k.activeHeadingId)||(k.activeHeadingId=k.outline[0]?.id??null);let $e=e.getCurrentPayload();if($e){let Re=$e.content.match(/^(\[Reading [^\]]+\]\r?\n(?:\r?\n)?)/)?.[1]??"";e.storePayloadOverride({...$e,content:Re+ee})}let ft=document.getElementById("revert-markdown");ft&&(ft.disabled=!b(k)),H("Saved","saved",1800,()=>!k.dirty&&!k.saving?(k.saveIndicator="idle",!0):!1),e.trackUiEvent?.("markdown_saved",{file_extension:Zt(k.filePath),blocks:S.length})}catch(S){k.saving=!1,k.saveIndicator="idle";let O=S,L=typeof O.appliedCount=="number"?O.appliedCount:0,oe=typeof O.skippedCount=="number"?O.skippedCount:0,ee=typeof O.totalCount=="number"?O.totalCount:0,$e=L>0&&oe>0,ft=L===0&&oe>0,ke=await m(k.filePath).catch(()=>null),Re=!1,bt=null;if(ke){let Tt=c(ke);Tt!==k.fullDocumentContent&&(d(k,Tt,{keepDraft:!0}),e.storePayloadOverride(ke),Re=!0,bt=Tt)}if(k.notice=null,$e)k.error=`${L} of ${ee} edit${ee===1?"":"s"} saved. ${oe} ${oe===1?"edit":"edits"} did not apply because that text changed on disk \u2014 your draft still has them; save again to merge.`,e.rerender(),H("Saved (partial)","saved",3e3),e.trackUiEvent?.("markdown_save_partial",{file_extension:Zt(k.filePath),applied:L,skipped:oe,total:ee});else if(ft&&Re&&e.showConflictDialog&&bt!==null){let Tt=bt,Ne=k.filePath.replace(/\\/g,"/").split("/").pop()||k.filePath;k.error=null,e.rerender(),e.trackUiEvent?.("markdown_save_conflict_shown",{file_extension:Zt(k.filePath)}),e.showConflictDialog({fileName:Ne,onUseDiskVersion:()=>{t===k&&(d(k,Tt),e.rerender()),e.trackUiEvent?.("markdown_save_conflict_resolved",{file_extension:Zt(k.filePath),action:"use_disk"})},onSaveMyChanges:()=>{e.trackUiEvent?.("markdown_save_conflict_resolved",{file_extension:Zt(k.filePath),action:"save_mine"}),A()},onCancel:()=>{t===k&&(k.error="File changed on disk. Save again to merge your edits, or reopen to discard them.",e.rerender()),e.trackUiEvent?.("markdown_save_conflict_resolved",{file_extension:Zt(k.filePath),action:"dismissed"})}})}else k.error=Re?"File changed on disk. Save again to merge your edits, or reopen the file to discard them.":S instanceof Error?S.message:"Save failed.",e.rerender(),H("Save failed","saving",3e3);e.trackUiEvent?.("markdown_save_failed",{file_extension:Zt(k.filePath),reloaded_from_disk:Re,applied:L,skipped:oe,total:ee})}}function Z(k,S){let O=g(k),L=document.querySelector(".panel-content-wrapper");O.editorScrollTop=L?.scrollTop??0;let oe=O.editorView;O.editorView=S,O.notice=null,O.error=null,e.rerender(),oe!==S&&e.trackUiEvent?.("markdown_view_toggled",{file_extension:Zt(k.filePath),view:S}),typeof O.editorScrollTop=="number"&&window.requestAnimationFrame(()=>{let ee=document.querySelector(".panel-content-wrapper");ee&&(ee.scrollTop=O.editorScrollTop)})}function q(k){let S=g(k),O=document.querySelector(".panel-content-wrapper"),L=S.outline,oe=Zt(k.filePath),ee=!1;{let ke=document.getElementById("markdown-editor-root");ke&&(n=nM({target:ke,value:S.draftContent,view:S.editorView,initialScrollTop:S.editorScrollTop,currentFilePath:k.filePath,searchLinks:Xe=>_(k.filePath,Xe),loadHeadings:Xe=>E(k.filePath,Xe),onChange:(Xe,Ne)=>{if(Xe===S.draftContent)return;if(S.draftContent=Xe,S.dirty=Xe!==S.fullDocumentContent,S.dirty){let An=Ne&&Ne.length>0?Ne:[{fromLine:1,toLine:Xe.split(`
|
|
416
416
|
`).length}];S.dirtyLineRanges=$M([...S.dirtyLineRanges,...An])}else S.dirtyLineRanges=[];S.dirty&&!ee&&(ee=!0,e.trackUiEvent?.("markdown_edit_started",{file_extension:oe,view:S.editorView})),S.dirty&&s();let Ye=Zo(Xe);XW(S.outline,Ye)||(S.outline=Ye,S.outline.some(An=>An.id===S.activeHeadingId)||(S.activeHeadingId=S.outline[0]?.id??null),i?.refresh(S.outline,S.activeHeadingId)),S.dirty&&S.saveIndicator==="saved"&&(S.saveIndicator="idle");let Ui=document.getElementById("revert-markdown");Ui&&(Ui.disabled=!b(S))},onBlur:()=>{S.dirty&&(a(),A())}}),n.focus()),document.getElementById("revert-markdown")?.addEventListener("click",()=>{Y()}),document.getElementById("markdown-mode-raw")?.addEventListener("click",()=>{Z(k,"raw")}),document.getElementById("markdown-mode-markdown")?.addEventListener("click",()=>{Z(k,"markdown")})}document.getElementById("expand-fullscreen")?.addEventListener("click",()=>{ve()}),O&&O.addEventListener("click",ke=>{let bt=ke.target?.closest("a[href]");if(!bt||!bt.closest(".markdown-doc"))return;let Tt=bt.getAttribute("href");Tt&&(ke.preventDefault(),Fe(k,Tt))});let ft=document.querySelector(".document-outline-shell");ft&&O&&(i=vM({shell:ft,outline:L,scrollContainer:O,onSelect:ke=>{let Re=S.outline.find(bt=>bt.id===ke);Re&&typeof Re.line=="number"&&(n?.revealLine(Re.line,Re.id),S.activeHeadingId=Re.id)}})??void 0),window.setTimeout(()=>{M()},0)}function re(k){let S=g(k),O=S.draftContent;return S.editorView==="raw"?O:wM(O)||O}async function pe(k){let S=t?.saveIndicator==="saved"||t?.dirty;if(t&&(t.notice=null,t.editorView="markdown"),S&&k){let O=jt(k.content);if(O?.isPartial){let L=await p(k.filePath,O.toLine-O.fromLine+1,O.readOffset);if(L)return L}}}return{attachHandlers:q,buildBody:v,clear:u,disposeHandles:l,ensureCompletePayload:h,getCopyText:re,getState:g,handleInlineExitFromFullscreen:pe,isUndoAvailable:b,readCompletePayload:m,readPayload:p,readPayloadContent:c,refreshFromDisk:ce,requestEditMode:Ie,requestFullscreen:ve,saveDocument:A,setEditorView:Z}}function IM(){return`
|
|
417
417
|
<div class="md-conflict-modal" id="md-conflict-modal" role="dialog" aria-modal="true" aria-labelledby="md-conflict-title" aria-describedby="md-conflict-body" hidden>
|
|
418
418
|
<div class="md-conflict-card">
|
|
@@ -446,7 +446,7 @@ ${f}
|
|
|
446
446
|
</footer>
|
|
447
447
|
</div>
|
|
448
448
|
</div>
|
|
449
|
-
`}function AM(e){let{container:t}=e,n=t.querySelector("#md-conflict-modal"),i=t.querySelector("#md-conflict-filename"),r=t.querySelector("#md-conflict-use-disk"),o=t.querySelector("#md-conflict-save-mine"),s=t.querySelector("#md-conflict-close"),a=null,l=null,u=()=>{if(!n||n.hidden)return;n.hidden=!0,document.removeEventListener("keydown",c,!0),n.removeEventListener("click",d);let h=a?.onCancel;if(a=null,l&&document.contains(l))try{l.focus()}catch{}l=null,h?.()},c=h=>{if(!(!n||n.hidden)){if(h.key==="Escape"){h.stopPropagation(),h.preventDefault(),u();return}if(h.key==="Tab"){let m=[r,o,s].filter(_=>!!_);if(m.length===0)return;let g=document.activeElement,b=g?m.indexOf(g):-1,v=h.shiftKey?-1:1,x=b===-1?v===1?0:m.length-1:(b+v+m.length)%m.length;h.preventDefault(),m[x].focus()}}},d=h=>{h.target===n&&h.stopPropagation()},f=()=>{let h=a?.onUseDiskVersion;a=null,u(),h?.()},p=()=>{let h=a?.onSaveMyChanges;a=null,u(),h?.()};return r?.addEventListener("click",f),o?.addEventListener("click",p),s?.addEventListener("click",u),{open:h=>{if(!n){h.onCancel?.();return}a=h,i&&(i.textContent=h.fileName),l=document.activeElement??null,n.hidden=!1,document.addEventListener("keydown",c,!0),n.addEventListener("click",d),window.requestAnimationFrame(()=>{o?.focus()})},close:u,isOpen:()=>!!n&&!n.hidden}}function zM(e){let t=b=>e.container.querySelector(`#${b}`),n=b=>{let v=document.createElement("textarea");v.value=b,v.setAttribute("readonly",""),v.style.position="fixed",v.style.top="-9999px",document.body.appendChild(v),v.select();let x=document.execCommand("copy");return document.body.removeChild(v),x},i=(b,v,x,_)=>{b.setAttribute("title",v),b.setAttribute("aria-label",v),b.textContent=v,_&&setTimeout(()=>{b.textContent=x,b.setAttribute("title",x),b.setAttribute("aria-label",x)},_)},r=(b,v,x,_)=>{b.setAttribute("title",v),b.setAttribute("aria-label",v),b.dataset.status=v,_&&setTimeout(()=>{b.setAttribute("title",x),b.setAttribute("aria-label",x),delete b.dataset.status},_)},o=async b=>{try{return navigator.clipboard?.writeText?(await navigator.clipboard.writeText(b),!0):n(b)}catch{return n(b)}},s=e.getFileExtensionForAnalytics(e.payload.filePath),a=t("copy-source");a?.addEventListener("click",async()=>{e.trackUiEvent?.("copy_clicked",{file_type:e.payload.fileType,file_extension:s});let b=await o(tt(e.payload.content));i(a,b?"Copied!":"Copy failed","Copy",1500)});let l=t("copy-active-markdown");l?.addEventListener("click",async()=>{let b=e.markdownController.getCopyText(e.payload);if(!b)return;let v=await o(b);v&&(e.updateSaveStatus("Copied","saved"),window.setTimeout(()=>e.updateSaveStatus("",""),1500)),r(l,v?"Copied!":"Copy failed","Copy",1500)}),t("toggle-html-mode")?.addEventListener("click",()=>{let b=e.htmlMode==="rendered"?"source":"rendered";e.trackUiEvent?.("html_view_toggled",{file_type:e.payload.fileType,file_extension:s}),e.render(e.payload,b,e.getIsExpanded())});let c=t("open-in-folder");if(c){let b=e.buildOpenInFolderCommand(e.payload.filePath);b?c.addEventListener("click",async()=>{e.trackUiEvent?.("open_in_folder",{file_type:e.payload.fileType,file_extension:s});try{await e.callTool?.("start_process",{command:b,timeout_ms:12e3})}catch{}}):c.disabled=!0}let d=t("open-in-editor");if(d){let b=e.buildOpenInEditorCommand(e.payload.filePath);b?d.addEventListener("click",async()=>{e.trackUiEvent?.("open_in_editor",{file_type:e.payload.fileType,file_extension:s});try{await e.callTool?.("start_process",{command:b,timeout_ms:12e3})}catch{}}):d.disabled=!0}let f=t("load-before"),p=t("load-after");if(!f&&!p)return;let h=jt(e.payload.content);if(!h?.isPartial)return;let m=tt(e.payload.content),g=async(b,v)=>{let x=b.textContent;b.textContent="Loading\u2026",b.disabled=!0,e.trackUiEvent?.(v==="before"?"load_lines_before":"load_lines_after",{file_type:e.payload.fileType,file_extension:s});try{let _=v==="before"?{path:e.payload.filePath,offset:0,length:h.fromLine-1}:{path:e.payload.filePath,offset:h.toLine},E=await e.callTool?.("read_file",_),T=Nt(E);if(T&&typeof T=="string"){let N=tt(T),M=v==="before"?`${N}${N.endsWith(`
|
|
449
|
+
`}function AM(e){let{container:t}=e,n=t.querySelector("#md-conflict-modal"),i=t.querySelector("#md-conflict-filename"),r=t.querySelector("#md-conflict-use-disk"),o=t.querySelector("#md-conflict-save-mine"),s=t.querySelector("#md-conflict-close"),a=null,l=null,u=()=>{if(!n||n.hidden)return;n.hidden=!0,document.removeEventListener("keydown",c,!0),n.removeEventListener("click",d);let h=a?.onCancel;if(a=null,l&&document.contains(l))try{l.focus()}catch{}l=null,h?.()},c=h=>{if(!(!n||n.hidden)){if(h.key==="Escape"){h.stopPropagation(),h.preventDefault(),u();return}if(h.key==="Tab"){let m=[r,o,s].filter(_=>!!_);if(m.length===0)return;let g=document.activeElement,b=g?m.indexOf(g):-1,v=h.shiftKey?-1:1,x=b===-1?v===1?0:m.length-1:(b+v+m.length)%m.length;h.preventDefault(),m[x].focus()}}},d=h=>{h.target===n&&h.stopPropagation()},f=()=>{let h=a?.onUseDiskVersion;a=null,u(),h?.()},p=()=>{let h=a?.onSaveMyChanges;a=null,u(),h?.()};return r?.addEventListener("click",f),o?.addEventListener("click",p),s?.addEventListener("click",u),{open:h=>{if(!n){h.onCancel?.();return}a=h,i&&(i.textContent=h.fileName),l=document.activeElement??null,n.hidden=!1,document.addEventListener("keydown",c,!0),n.addEventListener("click",d),window.requestAnimationFrame(()=>{o?.focus()})},close:u,isOpen:()=>!!n&&!n.hidden}}function zM(e){let t=b=>e.container.querySelector(`#${b}`),n=b=>{let v=document.createElement("textarea");v.value=b,v.setAttribute("readonly",""),v.style.position="fixed",v.style.top="-9999px",document.body.appendChild(v),v.select();let x=document.execCommand("copy");return document.body.removeChild(v),x},i=(b,v,x,_)=>{b.setAttribute("title",v),b.setAttribute("aria-label",v),b.textContent=v,_&&setTimeout(()=>{b.textContent=x,b.setAttribute("title",x),b.setAttribute("aria-label",x)},_)},r=(b,v,x,_)=>{b.setAttribute("title",v),b.setAttribute("aria-label",v),b.dataset.status=v,_&&setTimeout(()=>{b.setAttribute("title",x),b.setAttribute("aria-label",x),delete b.dataset.status},_)},o=async b=>{try{return navigator.clipboard?.writeText?(await navigator.clipboard.writeText(b),!0):n(b)}catch{return n(b)}},s=e.getFileExtensionForAnalytics(e.payload.filePath),a=t("copy-source");a?.addEventListener("click",async()=>{e.trackUiEvent?.("copy_clicked",{file_type:e.payload.fileType,file_extension:s});let b=await o(tt(e.payload.content));i(a,b?"Copied!":"Copy failed","Copy",1500)});let l=t("copy-active-markdown");l?.addEventListener("click",async()=>{let b=e.markdownController.getCopyText(e.payload);if(!b)return;let v=await o(b);v&&(e.updateSaveStatus("Copied","saved"),window.setTimeout(()=>e.updateSaveStatus("",""),1500)),r(l,v?"Copied!":"Copy failed","Copy",1500)}),t("toggle-html-mode")?.addEventListener("click",()=>{let b=e.htmlMode==="rendered"?"source":"rendered";e.trackUiEvent?.("html_view_toggled",{file_type:e.payload.fileType,file_extension:s}),e.render(e.payload,b,e.getIsExpanded())});let c=t("open-in-folder");if(c){let b=e.buildOpenInFolderCommand(e.payload.filePath);b?c.addEventListener("click",async()=>{e.trackUiEvent?.("open_in_folder",{file_type:e.payload.fileType,file_extension:s});try{await e.callTool?.("start_process",{command:b,timeout_ms:12e3})}catch{}}):c.disabled=!0}let d=t("open-in-editor");if(d){let b=e.buildOpenInEditorCommand(e.payload.filePath);b?d.addEventListener("click",async()=>{e.trackUiEvent?.("open_in_editor",{file_type:e.payload.fileType,file_extension:s});try{await e.callTool?.("start_process",{command:b,timeout_ms:12e3})}catch{}}):d.disabled=!0}let f=t("load-before"),p=t("load-after");if(!f&&!p)return;let h=jt(e.payload.content);if(!h?.isPartial)return;let m=tt(e.payload.content),g=async(b,v)=>{let x=b.textContent;b.textContent="Loading\u2026",b.disabled=!0,e.trackUiEvent?.(v==="before"?"load_lines_before":"load_lines_after",{file_type:e.payload.fileType,file_extension:s});try{let _=v==="before"?{path:e.payload.filePath,offset:0,length:h.fromLine-1,origin:"ui"}:{path:e.payload.filePath,offset:h.toLine,origin:"ui"},E=await e.callTool?.("read_file",_),T=Nt(E);if(T&&typeof T=="string"){let N=tt(T),M=v==="before"?`${N}${N.endsWith(`
|
|
450
450
|
`)?"":`
|
|
451
451
|
`}${m}`:`${m}${m.endsWith(`
|
|
452
452
|
`)?"":`
|