dsh-codinput 0.3.8 → 0.3.9

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/lib/client.js CHANGED
@@ -2,7 +2,7 @@ window.__ModuleLoader__.load({ id: "dsh-codinput", factory: (require) => {
2
2
  var module = { exports: {} };
3
3
  var exports = module.exports;
4
4
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
5
- "use strict";var Hs=Object.defineProperty;var I0=Object.getOwnPropertyDescriptor;var N0=Object.getOwnPropertyNames;var B0=Object.prototype.hasOwnProperty;var _0=(n,e,t)=>e in n?Hs(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var du=(n,e)=>{for(var t in e)Hs(n,t,{get:e[t],enumerable:!0})},H0=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of N0(e))!B0.call(n,r)&&r!==t&&Hs(n,r,{get:()=>e[r],enumerable:!(i=I0(e,r))||i.enumerable});return n};var F0=n=>H0(Hs({},"__esModule",{value:!0}),n);var de=(n,e,t)=>_0(n,typeof e!="symbol"?e+"":e,t);var Mk={};du(Mk,{CodinputBar:()=>Id,apply:()=>Ak,inject:()=>Tk,name:()=>Ck});module.exports=F0(Mk);function Oe(){let n=window;return n.__dshCodinputDebug??=[],n.__dshCodinputErrs??=[],n.__dshCodinputTriggers??={},n.__dshCodinputKeyboard??={},n.__dshCodinputShell??={},n}function Zt(...n){let e=Oe();e.__dshCodinputDebug.push(n.length===1?n[0]:n),e.__dshCodinputDebug.length>400&&e.__dshCodinputDebug.splice(0,e.__dshCodinputDebug.length-400)}function me(n,e){let t=Oe();t.__dshCodinputErrs.push({scope:n,error:e instanceof Error?e.stack??e.message:String(e)}),t.__dshCodinputErrs.length>200&&t.__dshCodinputErrs.splice(0,t.__dshCodinputErrs.length-200)}function Dl(n){Oe().__dshCodinputSessionId=n}function Fe(n,e){try{e()}catch(t){me(n,t)}}var Ws=require("react"),Fs="dsh-codinput",Ol={"head.edit":"\u7F16\u8F91","head.preview":"\u9884\u89C8","head.editOnly":"\u4EC5\u7F16\u8F91","head.previewOnly":"\u4EC5\u9884\u89C8","head.split":"\u7F16\u8F91 + \u9884\u89C8","editor.placeholder":"\u63CF\u8FF0\u4F60\u60F3\u8981\u6784\u5EFA\u7684\u5185\u5BB9\uFF0C/ \u8C03\u7528\u6307\u4EE4\uFF0C@ \u6587\u4EF6\u6216\u5BF9\u8BDD","preview.empty":"\u6682\u65E0\u53EF\u9884\u89C8\u5185\u5BB9","tool.command":"\u6307\u4EE4\uFF08/\uFF09","tool.send":"\u53D1\u9001","tool.model":"\u9009\u62E9\u6A21\u578B\uFF0C\u5F53\u524D {name}","tool.modelPlain":"\u9009\u62E9\u6A21\u578B","tool.context":"\u4E0A\u4E0B\u6587\u5DF2\u7528 {percent}%","tool.contextTitle":"\u4E0A\u4E0B\u6587\u5DF2\u7528","attach.group":"\u8349\u7A3F\u9644\u4EF6","attach.uploading":"\u4E0A\u4F20\u4E2D\u2026","attach.failed":"\u4E0A\u4F20\u5931\u8D25","attach.retry":"\u91CD\u8BD5\u4E0A\u4F20","attach.remove":"\u79FB\u9664\u9644\u4EF6 {name}","attach.scrollLeft":"\u5411\u5DE6\u6EDA\u52A8\u9644\u4EF6","attach.scrollRight":"\u5411\u53F3\u6EDA\u52A8\u9644\u4EF6","attach.channelUnavailable":"\u9644\u4EF6\u901A\u9053\u4E0D\u53EF\u7528","attach.pending":"\u5F85\u4E0A\u4F20\u6587\u4EF6 {name}","stats.session":"\u4F1A\u8BDD\u7EDF\u8BA1","stats.usage":"Token \u7528\u91CF","stats.turns":"{turns} \u8F6E {steps} \u6B65","stats.tps":"{tps} tok/s","stats.modelTime":"\u6A21\u578B\u7528\u65F6","stats.toolTime":"\u5DE5\u5177\u8C03\u7528\u7528\u65F6","stats.ttft":"\u9996 token \u5E73\u5747\uFF08TTFT\uFF09","stats.tpsLabel":"\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09","stats.totalTokens":"{tokens} tok","stats.cacheHit":"\u7F13\u5B58\u547D\u4E2D {percent}%","stats.cacheHitLabel":"\u7F13\u5B58\u547D\u4E2D","stats.cacheRead":"\u7F13\u5B58\u8BFB\u53D6","stats.cacheWrite":"\u7F13\u5B58\u5199\u5165","stats.output":"\u8F93\u51FA","stats.uncached":"\u672A\u7F13\u5B58\u8F93\u5165","stats.breakdown":"\u4E0A\u4E0B\u6587\u5206\u6BB5","stats.prompt":"\u7CFB\u7EDF\u63D0\u793A\u8BCD","stats.tools":"\u5DE5\u5177\u5B9A\u4E49","stats.messages":"\u5BF9\u8BDD\u6D88\u606F","menu.model":"\u6A21\u578B","menu.reasoning":"\u63A8\u7406\u7B49\u7EA7","menu.reasoningNone":"\u5F53\u524D\u6A21\u578B\u672A\u63D0\u4F9B\u63A8\u7406\u7B49\u7EA7\u3002","menu.source.command":"\u6307\u4EE4","menu.source.skill":"\u6280\u80FD","menu.source.subagent":"\u5B50\u667A\u80FD\u4F53","menu.drill":"\u8FDB\u5165\u76EE\u5F55","menu.nav":"\u76EE\u5F55\u5BFC\u822A","menu.triggerCandidates":"\u89E6\u53D1\u5019\u9009\u5EFA\u8BAE","menu.empty":"\u6CA1\u6709\u5339\u914D\u9879","menu.loading":"\u52A0\u8F7D\u4E2D\u2026","menu.loadFailed":"\u52A0\u8F7D\u5931\u8D25","menu.refreshingModels":"\u6B63\u5728\u5237\u65B0\u6A21\u578B\u5217\u8868\u2026","menu.noModels":"\u6CA1\u6709\u53EF\u7528\u7684\u6A21\u578B\u3002","menu.filter":"\u7B5B\u9009\u9009\u9879\u2026","popup.ack":"\u6211\u5DF2\u4E86\u89E3\u8BE5\u64CD\u4F5C\u7684\u5F71\u54CD","perm.trigger":"\u8BBF\u95EE\u6A21\u5F0F\uFF0C\u5F53\u524D\uFF1A{name}","perm.confirmTitle":"\u786E\u8BA4\u542F\u7528\u5B8C\u5168\u6743\u9650\uFF1F","perm.confirmEnable":"\u542F\u7528\u5B8C\u5168\u6743\u9650","perm.warning":"\u542F\u7528\u5B8C\u5168\u6743\u9650\u540E\uFF0C\u667A\u80FD\u4F53\u5C06\u51CF\u5C11\u786E\u8BA4\u6B65\u9AA4\uFF0C\u5E76\u4E14\u53EF\u4EE5\u76F4\u63A5\u6267\u884C\u66F4\u591A\u64CD\u4F5C\uFF0C\u5305\u62EC\u654F\u611F\u64CD\u4F5C\u3001\u6587\u4EF6\u4FEE\u6539\u6216\u5916\u90E8\u547D\u4EE4\u3002\u4EC5\u5EFA\u8BAE\u5728\u4F60\u4FE1\u4EFB\u5F53\u524D\u4EFB\u52A1\u65F6\u4F7F\u7528\u3002","perm.ack":"\u6211\u5DF2\u4E86\u89E3\u98CE\u9669\uFF0C\u5E76\u613F\u610F\u7EE7\u7EED","perm.cancel":"\u53D6\u6D88","perm.close":"\u5173\u95ED","perm.switchFailed":"\u6743\u9650\u5207\u6362\u5931\u8D25","perm.channelRejected":"\u547D\u4EE4\u901A\u9053\u62D2\u7EDD","perm.noInputSurface":"\u65E0\u53EF\u7528\u8F93\u5165\u9762","perm.preset.read-only":"\u4EC5\u53EF\u67E5\u770B","perm.preset.workspace-write":"\u5DE5\u4F5C\u533A\u5185\u4FEE\u6539","perm.preset.danger-full-access":"\u5B8C\u5168\u6743\u9650","set.enabled":"\u542F\u7528\u63A5\u7BA1","set.enabledDesc":"\u5173\u95ED\u5373\u6062\u590D\u5B98\u65B9\u8F93\u5165\u6846\uFF0C\u8349\u7A3F\u4E0D\u4E22\uFF1B/codinput \u540C\u6837\u53EF\u5207\u6362","set.userMarkdown":"\u7528\u6237\u6D88\u606F Markdown \u6E32\u67D3","set.userMarkdownDesc":"\u53F3\u4FA7\u81EA\u5DF1\u53D1\u51FA\u7684\u6D88\u606F\u6309 Markdown \u6392\u7248\uFF08\u6807\u9898/\u5217\u8868/\u4EE3\u7801\u5757\u7B49\uFF09\uFF1B\u5173\u95ED\u6062\u590D\u5B98\u65B9\u7EAF\u6587\u672C","umsg.copy":"\u590D\u5236","umsg.copied":"\u5DF2\u590D\u5236","umsg.referenceSummary":"\u5F15\u7528\uFF1A{labels}","umsg.clock.md":"{m}\u6708{d}\u65E5","umsg.clock.ymd":"{y}\u5E74{m}\u6708{d}\u65E5","umsg.extraBlock":"\u989D\u5916\u5185\u5BB9\u5757","umsg.image":"\u56FE\u7247","set.lineNumbers":"\u663E\u793A\u884C\u53F7","set.lineNumbersDesc":"\u5F53\u524D\u884C\u4E0E\u884C\u53F7\u9AD8\u4EAE\u5E38\u5F00","set.font":"\u7F16\u8F91\u5668\u5B57\u4F53","set.fontDesc":"CSS font-family\uFF0C\u7559\u7A7A\u6062\u590D\u9ED8\u8BA4","set.sendKey":"\u53D1\u9001\u5FEB\u6377\u952E","set.sendKeyDesc":"\u70B9\u51FB\u540E\u6309\u4E0B\u4EFB\u610F\u7EC4\u5408\u5B8C\u6210\u5F55\u5236\uFF1B\u4E0E\u6362\u884C\u5FEB\u6377\u952E\u4E0D\u5F97\u76F8\u540C","set.lineBreakKey":"\u6362\u884C\u5FEB\u6377\u952E","set.lineBreakKeyDesc":"\u70B9\u51FB\u540E\u6309\u4E0B\u4EFB\u610F\u7EC4\u5408\u5B8C\u6210\u5F55\u5236\uFF1B\u4E0E\u53D1\u9001\u5FEB\u6377\u952E\u4E0D\u5F97\u76F8\u540C","set.defaultView":"\u9ED8\u8BA4\u89C6\u56FE","set.defaultViewDesc":"\u63A5\u7BA1\u9762\u677F\u521D\u59CB\u663E\u793A\u7684\u5F62\u6001","set.recording":"\u6309\u952E\u2026","set.reset":"\u6062\u590D\u9ED8\u8BA4","set.resetAction":"\u91CD\u7F6E","set.resetAll":"\u6E05\u7A7A\u5168\u90E8 Codinput \u504F\u597D","ball.label":"\u5C55\u5F00 Codinput \u8F93\u5165\u9762\u677F","ball.title":"\u5C55\u5F00 Codinput","side.notice":"\u672C\u4F1A\u8BDD\u7684\u8F93\u5165\u9762\u5DF2\u5728\u53E6\u4E00\u4E2A\u5206\u680F\u4E2D\u6253\u5F00\uFF08\u8F93\u5165\u5165\u53E3\u552F\u4E00\uFF09\u3002","side.guideDesc":"\u4EE3\u7801\u7F16\u8F91\u5668\u98CE\u683C\u7684\u8F93\u5165\u9762\u677F\uFF1B\u5F00\u542F\u671F\u95F4\u4E3B\u8F93\u5165\u6846\u7531\u672C\u9762\u677F\u63A5\u7BA1\uFF08\u5171\u7528\u540C\u4E00\u53F0\u8F93\u5165\u673A\uFF09","side.disabled":"Codinput \u63A5\u7BA1\u5DF2\u5173\u95ED\uFF1A\u4E3B\u8F93\u5165\u5728\u539F\u8F93\u5165\u4F4D\uFF08\u5B98\u65B9\u8F93\u5165\u6846\uFF09\u3002\u8F93\u5165 /codinput \u6216\u5230 \u8BBE\u7F6E \u2192 Codinput \u91CD\u65B0\u5F00\u542F\u3002","tool.attach":"\u6587\u4EF6","tool.stop":"\u505C\u6B62","image.preview":"\u539F\u56FE\u9884\u89C8","image.closePreview":"\u5173\u95ED\u539F\u56FE\u9884\u89C8","image.openOriginal":"\u67E5\u770B\u539F\u56FE","image.openOriginalLabel":"{name}\uFF0C\u70B9\u51FB\u67E5\u770B\u539F\u56FE","cmd.enter":"\u8FDB\u5165 Codinput \u8F93\u5165\u63A5\u7BA1","cmd.exit":"\u9000\u51FA Codinput\uFF0C\u6062\u590D\u5B98\u65B9\u8F93\u5165\u6846"},hu={"head.edit":"Edit","head.preview":"Preview","head.editOnly":"Edit only","head.previewOnly":"Preview only","head.split":"Edit + Preview","editor.placeholder":"Describe what you want to build \u2014 / for commands, @ for files or chats","preview.empty":"Nothing to preview","tool.command":"Commands (/)","tool.send":"Send","tool.model":"Select model, current {name}","tool.modelPlain":"Select model","tool.context":"Context used {percent}%","tool.contextTitle":"Context used","attach.group":"Draft attachments","attach.uploading":"Uploading\u2026","attach.failed":"Upload failed","attach.retry":"Retry upload","attach.remove":"Remove attachment {name}","attach.scrollLeft":"Scroll attachments left","attach.scrollRight":"Scroll attachments right","attach.channelUnavailable":"Attachment channel unavailable","attach.pending":"Pending file {name}","stats.session":"Session stats","stats.usage":"Token usage","stats.turns":"{turns} turns \xB7 {steps} steps","stats.tps":"{tps} tok/s","stats.modelTime":"Model time","stats.toolTime":"Tool call time","stats.ttft":"Avg first token (TTFT)","stats.tpsLabel":"Output speed (TPS)","stats.totalTokens":"{tokens} tok","stats.cacheHit":"Cache hit {percent}%","stats.cacheHitLabel":"Cache hit","stats.cacheRead":"Cache read","stats.cacheWrite":"Cache write","stats.output":"Output","stats.uncached":"Uncached input","stats.breakdown":"Context breakdown","stats.prompt":"System prompt","stats.tools":"Tool definitions","stats.messages":"Conversation","menu.model":"Model","menu.reasoning":"Reasoning effort","menu.reasoningNone":"The current model exposes no reasoning effort.","menu.source.command":"Commands","menu.source.skill":"Skills","menu.source.subagent":"Subagents","menu.drill":"Open folder","menu.nav":"Folder navigation","menu.triggerCandidates":"Trigger suggestions","menu.empty":"No matches","menu.loading":"Loading\u2026","menu.loadFailed":"Failed to load","menu.refreshingModels":"Refreshing model list\u2026","menu.noModels":"No models available.","menu.filter":"Filter options\u2026","popup.ack":"I understand the impact of this action","perm.trigger":"Access mode, current: {name}","perm.confirmTitle":"Enable full access?","perm.confirmEnable":"Enable full access","perm.warning":"With full access the agent skips most confirmations and can perform more actions directly, including sensitive operations, file writes, or external commands. Only use it when you trust the current task.","perm.ack":"I understand the risk and want to continue","perm.cancel":"Cancel","perm.close":"Close","perm.switchFailed":"Failed to switch permission","perm.channelRejected":"Command channel rejected","perm.noInputSurface":"No input surface available","perm.preset.read-only":"Read only","perm.preset.workspace-write":"Write in workspace","perm.preset.danger-full-access":"Full access","set.enabled":"Take over composer","set.enabledDesc":"Turning it off restores the official composer; the draft is kept. /codinput toggles it too.","set.userMarkdown":"Markdown for user messages","set.userMarkdownDesc":"Render your own (right-side) messages as Markdown \u2014 headings, lists, code blocks; off restores the official plain text","umsg.copy":"Copy","umsg.copied":"Copied","umsg.referenceSummary":"Referenced: {labels}","umsg.clock.md":"{m}/{d}","umsg.clock.ymd":"{y}/{m}/{d}","umsg.extraBlock":"Extra content block","umsg.image":"Image","set.lineNumbers":"Show line numbers","set.lineNumbersDesc":"The current line and its gutter number stay highlighted","set.font":"Editor font","set.fontDesc":"CSS font-family; leave empty for the default","set.sendKey":"Send shortcut","set.sendKeyDesc":"Click, then press any combination to record it; must differ from the line-break shortcut","set.lineBreakKey":"Line-break shortcut","set.lineBreakKeyDesc":"Click, then press any combination to record it; must differ from the send shortcut","set.defaultView":"Default view","set.defaultViewDesc":"Initial layout of the takeover panel","set.recording":"Press keys\u2026","set.reset":"Reset","set.resetAction":"Reset","set.resetAll":"Clear all Codinput preferences","ball.label":"Open the Codinput input panel","ball.title":"Open Codinput","side.notice":"This session's input panel is already open in another split pane (only one input surface exists).","side.guideDesc":"Code-editor style input panel. While enabled it takes over the composer (sharing the same input machine).","side.disabled":"Codinput takeover is off: the composer is back at its original place (official input). Type /codinput or open Settings \u2192 Codinput to re-enable.","tool.attach":"File","tool.stop":"Stop","image.preview":"Original image preview","image.closePreview":"Close original image preview","image.openOriginal":"View original","image.openOriginalLabel":"{name}, click to view the original","cmd.enter":"Enable the Codinput composer takeover","cmd.exit":"Disable Codinput and restore the official composer"},fu=null,fr=null,zs="zh",Ll=new Set,uu=new Map;function z0(){for(let n of Ll)n()}function W0(n,e){return e?n.replace(/\{(\w+)\}/g,(t,i)=>{let r=e[i];return r===void 0?t:String(r)}):n}function V0(){return zs.startsWith("zh")?Ol:hu}function pu(n){let e=n;if(e){fu=e;try{e.register?.(Fs,"zh",Ol),e.register?.(Fs,"en",hu),fr=e.bind?.(Fs)??null}catch{try{fr=e.bind?.(Fs)??null}catch{fr=null}}try{let t=e.getSnapshot?.();t?.active&&(zs=t.active),e.subscribe?.(()=>{let i=e.getSnapshot?.();i?.active&&i.active!==zs&&(zs=i.active),z0()})}catch{}}}function pr(n){let e=uu.get(n);if(e)return e;let t=null;try{t=fu?.bind?.(n)??null}catch{t=null}return t&&uu.set(n,t),t}function $0(n){return Ll.add(n),()=>{Ll.delete(n)}}function mu(n,e){if(fr)try{let i=fr(n,e);if(i&&i!==n)return i}catch{}let t=V0()[n]??Ol[n];return t===void 0?void 0:W0(t,e)}function x(n,e){return mu(n,e)??n}function Ii(n,e){return mu(n,e)}function St(){let[,n]=(0,Ws.useState)(0);return(0,Ws.useEffect)(()=>$0(()=>n(e=>e+1)),[]),x}var Y={};function gu(n){Fe("stash.conversation",()=>{n.inject(["conversation"],e=>{Y.conversation=e.conversation})}),Fe("stash.services",()=>{n.inject(["slots","sessions","commandUi"],e=>{Y.slots=e.slots,Y.sessions=e.sessions,Y.commandUi=e.commandUi})}),Fe("stash.sidebarRight",()=>{n.inject(["slots","sidebarRightTabs","sidebarRight"],e=>{Y.sidebarRight=e.sidebarRight})}),Fe("stash.modelDirectories",()=>{n.inject(["modelDirectories","sessions","remote","remote.session"],e=>{Y.modelDirectories=e.modelDirectories})}),Fe("i18n.install",()=>{n.inject(["locale"],e=>{pu(e.locale)})})}var bu="dsh-codinput-styles",Pl=`
5
+ "use strict";var Hs=Object.defineProperty;var B0=Object.getOwnPropertyDescriptor;var _0=Object.getOwnPropertyNames;var H0=Object.prototype.hasOwnProperty;var F0=(n,e,t)=>e in n?Hs(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var du=(n,e)=>{for(var t in e)Hs(n,t,{get:e[t],enumerable:!0})},z0=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of _0(e))!H0.call(n,r)&&r!==t&&Hs(n,r,{get:()=>e[r],enumerable:!(i=B0(e,r))||i.enumerable});return n};var W0=n=>z0(Hs({},"__esModule",{value:!0}),n);var de=(n,e,t)=>F0(n,typeof e!="symbol"?e+"":e,t);var Rk={};du(Rk,{CodinputBar:()=>Id,apply:()=>Ek,inject:()=>Mk,name:()=>Ak});module.exports=W0(Rk);function Oe(){let n=window;return n.__dshCodinputDebug??=[],n.__dshCodinputErrs??=[],n.__dshCodinputTriggers??={},n.__dshCodinputKeyboard??={},n.__dshCodinputShell??={},n}function Zt(...n){let e=Oe();e.__dshCodinputDebug.push(n.length===1?n[0]:n),e.__dshCodinputDebug.length>400&&e.__dshCodinputDebug.splice(0,e.__dshCodinputDebug.length-400)}function me(n,e){let t=Oe();t.__dshCodinputErrs.push({scope:n,error:e instanceof Error?e.stack??e.message:String(e)}),t.__dshCodinputErrs.length>200&&t.__dshCodinputErrs.splice(0,t.__dshCodinputErrs.length-200)}function Ll(n){Oe().__dshCodinputSessionId=n}function Fe(n,e){try{e()}catch(t){me(n,t)}}var Ws=require("react"),Fs="dsh-codinput",Ol={"head.edit":"\u7F16\u8F91","head.preview":"\u9884\u89C8","head.editOnly":"\u4EC5\u7F16\u8F91","head.previewOnly":"\u4EC5\u9884\u89C8","head.split":"\u7F16\u8F91 + \u9884\u89C8","editor.placeholder":"\u63CF\u8FF0\u4F60\u60F3\u8981\u6784\u5EFA\u7684\u5185\u5BB9\uFF0C/ \u8C03\u7528\u6307\u4EE4\uFF0C@ \u6587\u4EF6\u6216\u5BF9\u8BDD","preview.empty":"\u6682\u65E0\u53EF\u9884\u89C8\u5185\u5BB9","tool.command":"\u6307\u4EE4\uFF08/\uFF09","tool.send":"\u53D1\u9001","tool.model":"\u9009\u62E9\u6A21\u578B\uFF0C\u5F53\u524D {name}","tool.modelPlain":"\u9009\u62E9\u6A21\u578B","tool.context":"\u4E0A\u4E0B\u6587\u5DF2\u7528 {percent}%","tool.contextTitle":"\u4E0A\u4E0B\u6587\u5DF2\u7528","attach.group":"\u8349\u7A3F\u9644\u4EF6","attach.uploading":"\u4E0A\u4F20\u4E2D\u2026","attach.failed":"\u4E0A\u4F20\u5931\u8D25","attach.retry":"\u91CD\u8BD5\u4E0A\u4F20","attach.remove":"\u79FB\u9664\u9644\u4EF6 {name}","attach.scrollLeft":"\u5411\u5DE6\u6EDA\u52A8\u9644\u4EF6","attach.scrollRight":"\u5411\u53F3\u6EDA\u52A8\u9644\u4EF6","attach.channelUnavailable":"\u9644\u4EF6\u901A\u9053\u4E0D\u53EF\u7528","attach.pending":"\u5F85\u4E0A\u4F20\u6587\u4EF6 {name}","stats.session":"\u4F1A\u8BDD\u7EDF\u8BA1","stats.usage":"Token \u7528\u91CF","stats.turns":"{turns} \u8F6E {steps} \u6B65","stats.tps":"{tps} tok/s","stats.modelTime":"\u6A21\u578B\u7528\u65F6","stats.toolTime":"\u5DE5\u5177\u8C03\u7528\u7528\u65F6","stats.ttft":"\u9996 token \u5E73\u5747\uFF08TTFT\uFF09","stats.tpsLabel":"\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09","stats.totalTokens":"{tokens} tok","stats.cacheHit":"\u7F13\u5B58\u547D\u4E2D {percent}%","stats.cacheHitLabel":"\u7F13\u5B58\u547D\u4E2D","stats.cacheRead":"\u7F13\u5B58\u8BFB\u53D6","stats.cacheWrite":"\u7F13\u5B58\u5199\u5165","stats.output":"\u8F93\u51FA","stats.uncached":"\u672A\u7F13\u5B58\u8F93\u5165","stats.breakdown":"\u4E0A\u4E0B\u6587\u5206\u6BB5","stats.prompt":"\u7CFB\u7EDF\u63D0\u793A\u8BCD","stats.tools":"\u5DE5\u5177\u5B9A\u4E49","stats.messages":"\u5BF9\u8BDD\u6D88\u606F","menu.model":"\u6A21\u578B","menu.reasoning":"\u63A8\u7406\u7B49\u7EA7","menu.reasoningNone":"\u5F53\u524D\u6A21\u578B\u672A\u63D0\u4F9B\u63A8\u7406\u7B49\u7EA7\u3002","menu.source.command":"\u6307\u4EE4","menu.source.skill":"\u6280\u80FD","menu.source.subagent":"\u5B50\u667A\u80FD\u4F53","menu.drill":"\u8FDB\u5165\u76EE\u5F55","menu.nav":"\u76EE\u5F55\u5BFC\u822A","menu.triggerCandidates":"\u89E6\u53D1\u5019\u9009\u5EFA\u8BAE","menu.empty":"\u6CA1\u6709\u5339\u914D\u9879","menu.loading":"\u52A0\u8F7D\u4E2D\u2026","menu.loadFailed":"\u52A0\u8F7D\u5931\u8D25","menu.refreshingModels":"\u6B63\u5728\u5237\u65B0\u6A21\u578B\u5217\u8868\u2026","menu.noModels":"\u6CA1\u6709\u53EF\u7528\u7684\u6A21\u578B\u3002","menu.filter":"\u7B5B\u9009\u9009\u9879\u2026","popup.ack":"\u6211\u5DF2\u4E86\u89E3\u8BE5\u64CD\u4F5C\u7684\u5F71\u54CD","perm.trigger":"\u8BBF\u95EE\u6A21\u5F0F\uFF0C\u5F53\u524D\uFF1A{name}","perm.confirmTitle":"\u786E\u8BA4\u542F\u7528\u5B8C\u5168\u6743\u9650\uFF1F","perm.confirmEnable":"\u542F\u7528\u5B8C\u5168\u6743\u9650","perm.warning":"\u542F\u7528\u5B8C\u5168\u6743\u9650\u540E\uFF0C\u667A\u80FD\u4F53\u5C06\u51CF\u5C11\u786E\u8BA4\u6B65\u9AA4\uFF0C\u5E76\u4E14\u53EF\u4EE5\u76F4\u63A5\u6267\u884C\u66F4\u591A\u64CD\u4F5C\uFF0C\u5305\u62EC\u654F\u611F\u64CD\u4F5C\u3001\u6587\u4EF6\u4FEE\u6539\u6216\u5916\u90E8\u547D\u4EE4\u3002\u4EC5\u5EFA\u8BAE\u5728\u4F60\u4FE1\u4EFB\u5F53\u524D\u4EFB\u52A1\u65F6\u4F7F\u7528\u3002","perm.ack":"\u6211\u5DF2\u4E86\u89E3\u98CE\u9669\uFF0C\u5E76\u613F\u610F\u7EE7\u7EED","perm.cancel":"\u53D6\u6D88","perm.close":"\u5173\u95ED","perm.switchFailed":"\u6743\u9650\u5207\u6362\u5931\u8D25","perm.channelRejected":"\u547D\u4EE4\u901A\u9053\u62D2\u7EDD","perm.noInputSurface":"\u65E0\u53EF\u7528\u8F93\u5165\u9762","perm.preset.read-only":"\u4EC5\u53EF\u67E5\u770B","perm.preset.workspace-write":"\u5DE5\u4F5C\u533A\u5185\u4FEE\u6539","perm.preset.danger-full-access":"\u5B8C\u5168\u6743\u9650","set.enabled":"\u542F\u7528\u63A5\u7BA1","set.enabledDesc":"\u5173\u95ED\u5373\u6062\u590D\u5B98\u65B9\u8F93\u5165\u6846\uFF0C\u8349\u7A3F\u4E0D\u4E22\uFF1B/codinput \u540C\u6837\u53EF\u5207\u6362","set.userMarkdown":"\u7528\u6237\u6D88\u606F Markdown \u6E32\u67D3","set.userMarkdownDesc":"\u53F3\u4FA7\u81EA\u5DF1\u53D1\u51FA\u7684\u6D88\u606F\u6309 Markdown \u6392\u7248\uFF08\u6807\u9898/\u5217\u8868/\u4EE3\u7801\u5757\u7B49\uFF09\uFF1B\u5173\u95ED\u6062\u590D\u5B98\u65B9\u7EAF\u6587\u672C","umsg.copy":"\u590D\u5236","umsg.copied":"\u5DF2\u590D\u5236","umsg.referenceSummary":"\u5F15\u7528\uFF1A{labels}","umsg.clock.md":"{m}\u6708{d}\u65E5","umsg.clock.ymd":"{y}\u5E74{m}\u6708{d}\u65E5","umsg.extraBlock":"\u989D\u5916\u5185\u5BB9\u5757","umsg.image":"\u56FE\u7247","set.lineNumbers":"\u663E\u793A\u884C\u53F7","set.lineNumbersDesc":"\u5F53\u524D\u884C\u4E0E\u884C\u53F7\u9AD8\u4EAE\u5E38\u5F00","set.font":"\u7F16\u8F91\u5668\u5B57\u4F53","set.fontDesc":"CSS font-family\uFF0C\u7559\u7A7A\u6062\u590D\u9ED8\u8BA4","set.sendKey":"\u53D1\u9001\u5FEB\u6377\u952E","set.sendKeyDesc":"\u70B9\u51FB\u540E\u6309\u4E0B\u4EFB\u610F\u7EC4\u5408\u5B8C\u6210\u5F55\u5236\uFF1B\u4E0E\u6362\u884C\u5FEB\u6377\u952E\u4E0D\u5F97\u76F8\u540C","set.lineBreakKey":"\u6362\u884C\u5FEB\u6377\u952E","set.lineBreakKeyDesc":"\u70B9\u51FB\u540E\u6309\u4E0B\u4EFB\u610F\u7EC4\u5408\u5B8C\u6210\u5F55\u5236\uFF1B\u4E0E\u53D1\u9001\u5FEB\u6377\u952E\u4E0D\u5F97\u76F8\u540C","set.defaultView":"\u9ED8\u8BA4\u89C6\u56FE","set.defaultViewDesc":"\u63A5\u7BA1\u9762\u677F\u521D\u59CB\u663E\u793A\u7684\u5F62\u6001","set.recording":"\u6309\u952E\u2026","set.reset":"\u6062\u590D\u9ED8\u8BA4","set.resetAction":"\u91CD\u7F6E","set.resetAll":"\u6E05\u7A7A\u5168\u90E8 Codinput \u504F\u597D","ball.label":"\u5C55\u5F00 Codinput \u8F93\u5165\u9762\u677F","ball.title":"\u5C55\u5F00 Codinput","side.notice":"\u672C\u4F1A\u8BDD\u7684\u8F93\u5165\u9762\u5DF2\u5728\u53E6\u4E00\u4E2A\u5206\u680F\u4E2D\u6253\u5F00\uFF08\u8F93\u5165\u5165\u53E3\u552F\u4E00\uFF09\u3002","side.guideDesc":"\u4EE3\u7801\u7F16\u8F91\u5668\u98CE\u683C\u7684\u8F93\u5165\u9762\u677F\uFF1B\u5F00\u542F\u671F\u95F4\u4E3B\u8F93\u5165\u6846\u7531\u672C\u9762\u677F\u63A5\u7BA1\uFF08\u5171\u7528\u540C\u4E00\u53F0\u8F93\u5165\u673A\uFF09","side.disabled":"Codinput \u63A5\u7BA1\u5DF2\u5173\u95ED\uFF1A\u4E3B\u8F93\u5165\u5728\u539F\u8F93\u5165\u4F4D\uFF08\u5B98\u65B9\u8F93\u5165\u6846\uFF09\u3002\u8F93\u5165 /codinput \u6216\u5230 \u8BBE\u7F6E \u2192 Codinput \u91CD\u65B0\u5F00\u542F\u3002","tool.attach":"\u6587\u4EF6","tool.stop":"\u505C\u6B62","image.preview":"\u539F\u56FE\u9884\u89C8","image.closePreview":"\u5173\u95ED\u539F\u56FE\u9884\u89C8","image.openOriginal":"\u67E5\u770B\u539F\u56FE","image.openOriginalLabel":"{name}\uFF0C\u70B9\u51FB\u67E5\u770B\u539F\u56FE","cmd.enter":"\u8FDB\u5165 Codinput \u8F93\u5165\u63A5\u7BA1","cmd.exit":"\u9000\u51FA Codinput\uFF0C\u6062\u590D\u5B98\u65B9\u8F93\u5165\u6846"},hu={"head.edit":"Edit","head.preview":"Preview","head.editOnly":"Edit only","head.previewOnly":"Preview only","head.split":"Edit + Preview","editor.placeholder":"Describe what you want to build \u2014 / for commands, @ for files or chats","preview.empty":"Nothing to preview","tool.command":"Commands (/)","tool.send":"Send","tool.model":"Select model, current {name}","tool.modelPlain":"Select model","tool.context":"Context used {percent}%","tool.contextTitle":"Context used","attach.group":"Draft attachments","attach.uploading":"Uploading\u2026","attach.failed":"Upload failed","attach.retry":"Retry upload","attach.remove":"Remove attachment {name}","attach.scrollLeft":"Scroll attachments left","attach.scrollRight":"Scroll attachments right","attach.channelUnavailable":"Attachment channel unavailable","attach.pending":"Pending file {name}","stats.session":"Session stats","stats.usage":"Token usage","stats.turns":"{turns} turns \xB7 {steps} steps","stats.tps":"{tps} tok/s","stats.modelTime":"Model time","stats.toolTime":"Tool call time","stats.ttft":"Avg first token (TTFT)","stats.tpsLabel":"Output speed (TPS)","stats.totalTokens":"{tokens} tok","stats.cacheHit":"Cache hit {percent}%","stats.cacheHitLabel":"Cache hit","stats.cacheRead":"Cache read","stats.cacheWrite":"Cache write","stats.output":"Output","stats.uncached":"Uncached input","stats.breakdown":"Context breakdown","stats.prompt":"System prompt","stats.tools":"Tool definitions","stats.messages":"Conversation","menu.model":"Model","menu.reasoning":"Reasoning effort","menu.reasoningNone":"The current model exposes no reasoning effort.","menu.source.command":"Commands","menu.source.skill":"Skills","menu.source.subagent":"Subagents","menu.drill":"Open folder","menu.nav":"Folder navigation","menu.triggerCandidates":"Trigger suggestions","menu.empty":"No matches","menu.loading":"Loading\u2026","menu.loadFailed":"Failed to load","menu.refreshingModels":"Refreshing model list\u2026","menu.noModels":"No models available.","menu.filter":"Filter options\u2026","popup.ack":"I understand the impact of this action","perm.trigger":"Access mode, current: {name}","perm.confirmTitle":"Enable full access?","perm.confirmEnable":"Enable full access","perm.warning":"With full access the agent skips most confirmations and can perform more actions directly, including sensitive operations, file writes, or external commands. Only use it when you trust the current task.","perm.ack":"I understand the risk and want to continue","perm.cancel":"Cancel","perm.close":"Close","perm.switchFailed":"Failed to switch permission","perm.channelRejected":"Command channel rejected","perm.noInputSurface":"No input surface available","perm.preset.read-only":"Read only","perm.preset.workspace-write":"Write in workspace","perm.preset.danger-full-access":"Full access","set.enabled":"Take over composer","set.enabledDesc":"Turning it off restores the official composer; the draft is kept. /codinput toggles it too.","set.userMarkdown":"Markdown for user messages","set.userMarkdownDesc":"Render your own (right-side) messages as Markdown \u2014 headings, lists, code blocks; off restores the official plain text","umsg.copy":"Copy","umsg.copied":"Copied","umsg.referenceSummary":"Referenced: {labels}","umsg.clock.md":"{m}/{d}","umsg.clock.ymd":"{y}/{m}/{d}","umsg.extraBlock":"Extra content block","umsg.image":"Image","set.lineNumbers":"Show line numbers","set.lineNumbersDesc":"The current line and its gutter number stay highlighted","set.font":"Editor font","set.fontDesc":"CSS font-family; leave empty for the default","set.sendKey":"Send shortcut","set.sendKeyDesc":"Click, then press any combination to record it; must differ from the line-break shortcut","set.lineBreakKey":"Line-break shortcut","set.lineBreakKeyDesc":"Click, then press any combination to record it; must differ from the send shortcut","set.defaultView":"Default view","set.defaultViewDesc":"Initial layout of the takeover panel","set.recording":"Press keys\u2026","set.reset":"Reset","set.resetAction":"Reset","set.resetAll":"Clear all Codinput preferences","ball.label":"Open the Codinput input panel","ball.title":"Open Codinput","side.notice":"This session's input panel is already open in another split pane (only one input surface exists).","side.guideDesc":"Code-editor style input panel. While enabled it takes over the composer (sharing the same input machine).","side.disabled":"Codinput takeover is off: the composer is back at its original place (official input). Type /codinput or open Settings \u2192 Codinput to re-enable.","tool.attach":"File","tool.stop":"Stop","image.preview":"Original image preview","image.closePreview":"Close original image preview","image.openOriginal":"View original","image.openOriginalLabel":"{name}, click to view the original","cmd.enter":"Enable the Codinput composer takeover","cmd.exit":"Disable Codinput and restore the official composer"},fu=null,fr=null,zs="zh",Dl=new Set,uu=new Map;function V0(){for(let n of Dl)n()}function $0(n,e){return e?n.replace(/\{(\w+)\}/g,(t,i)=>{let r=e[i];return r===void 0?t:String(r)}):n}function U0(){return zs.startsWith("zh")?Ol:hu}function pu(n){let e=n;if(e){fu=e;try{e.register?.(Fs,"zh",Ol),e.register?.(Fs,"en",hu),fr=e.bind?.(Fs)??null}catch{try{fr=e.bind?.(Fs)??null}catch{fr=null}}try{let t=e.getSnapshot?.();t?.active&&(zs=t.active),e.subscribe?.(()=>{let i=e.getSnapshot?.();i?.active&&i.active!==zs&&(zs=i.active),V0()})}catch{}}}function pr(n){let e=uu.get(n);if(e)return e;let t=null;try{t=fu?.bind?.(n)??null}catch{t=null}return t&&uu.set(n,t),t}function j0(n){return Dl.add(n),()=>{Dl.delete(n)}}function mu(n,e){if(fr)try{let i=fr(n,e);if(i&&i!==n)return i}catch{}let t=U0()[n]??Ol[n];return t===void 0?void 0:$0(t,e)}function v(n,e){return mu(n,e)??n}function Ii(n,e){return mu(n,e)}function St(){let[,n]=(0,Ws.useState)(0);return(0,Ws.useEffect)(()=>j0(()=>n(e=>e+1)),[]),v}var Y={};function gu(n){Fe("stash.conversation",()=>{n.inject(["conversation"],e=>{Y.conversation=e.conversation})}),Fe("stash.services",()=>{n.inject(["slots","sessions","commandUi"],e=>{Y.slots=e.slots,Y.sessions=e.sessions,Y.commandUi=e.commandUi})}),Fe("stash.sidebarRight",()=>{n.inject(["slots","sidebarRightTabs","sidebarRight"],e=>{Y.sidebarRight=e.sidebarRight})}),Fe("stash.modelDirectories",()=>{n.inject(["modelDirectories","sessions","remote","remote.session"],e=>{Y.modelDirectories=e.modelDirectories})}),Fe("i18n.install",()=>{n.inject(["locale"],e=>{pu(e.locale)})})}var bu="dsh-codinput-styles",Pl=`
6
6
  /* ===== \u62D6\u6587\u4EF6\u5165\u5361\u7247\uFF1A\u843D\u533A\u63D0\u793A\uFF08\u7C98\u8D34/\u62D6\u5165\u9644\u4EF6\u5165\u53E3\uFF09===== */
7
7
  .dci-card[data-drop] { outline: 2px solid var(--dsw-alias-state-business-primary, currentColor); outline-offset: -2px; }
8
8
 
@@ -657,11 +657,11 @@ button.dci-umsg-chip:hover, button.dci-umsg-chip:focus { outline: none; text-dec
657
657
  button.dci-umsg-chip:focus-visible { box-shadow: 0 0 0 2px var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); }
658
658
  .dci-umsg-chip[data-chip="slash"] { font-family: var(--dsw-font-markdown-code-font-family); }
659
659
  .dci-umsg-chipicon { width: 1em; height: 1em; margin-right: 4px; vertical-align: -0.125em; }
660
- `;function wu(){let n=document.getElementById(bu);if(n){n.textContent!==Pl&&(n.textContent=Pl);return}let e=document.createElement("style");e.id=bu,e.textContent=Pl,document.head.appendChild(e)}var mr={enabled:!0,userMarkdown:!0,lineNumbers:!0,fontFamily:"'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",sendHotkey:"mod+enter",lineBreakHotkey:"enter",defaultEdit:!0,defaultPreview:!1,composerBodyHeight:null,mode:"normal",floatX:null,floatY:null,floatW:null,floatH:null},yu="dsh-codinput.prefs.v2",U0="dsh-codinput.permission-applied",Il=new Set;function ue(){try{let n=window.localStorage.getItem(yu);if(!n)return{...mr};let e=JSON.parse(n),t={...mr,...e&&typeof e=="object"?e:null},i=e;return i.sendKey==="enter"&&(t.sendHotkey="enter",t.lineBreakHotkey="shift-enter"),t.mode=i.mode==="float"||i.mode==="normal"?i.mode:i.floating===!0?"float":"normal",t}catch{return{...mr}}}function ct(n){let e={...ue(),...n};try{window.localStorage.setItem(yu,JSON.stringify(e))}catch{}for(let t of Il)t();return e}function pn(n){return Il.add(n),()=>Il.delete(n)}function Nl(n){try{window.localStorage.setItem(U0,n)}catch{}}var Ln=require("react"),gr=new Map,_l=new Set,j0=1,Dn=new Map;function ku(n,e){return n.visible===e.visible&&n.expanded===e.expanded}function K0(n){if(n.size!==Dn.size)return!1;for(let[e,t]of n){let i=Dn.get(e);if(!i||!ku(i,t)||i.owner!==t.owner)return!1}return!0}function Bl(){let n=new Map;for(let[e,t]of gr){let i=n.get(t.sessionId);i?!i.visible&&t.visible&&n.set(t.sessionId,{visible:!0,expanded:t.expanded,owner:e}):n.set(t.sessionId,{visible:t.visible,expanded:t.expanded,owner:e})}if(!K0(n)){Dn=n;for(let e of _l)e()}}function Su(n,e){let t=j0++;gr.set(t,{sessionId:n,...e}),Bl();let i=!1;return{token:t,set(r){let s=gr.get(t);s&&!ku(s,r)&&(gr.set(t,{sessionId:s.sessionId,...r}),Bl())},release(){i||(i=!0,gr.delete(t)&&Bl())}}}function xu(n){return n!==void 0&&Dn.has(n)}function Cu(){return[...Dn.keys()]}function Tu(){return Dn.size>0}function G0(n){return n===void 0?void 0:Dn.get(n)}function vu(n,e){return e===0||n===void 0?!0:Dn.get(n)?.owner===e}var Hl=new Set;function Au(n){for(let e of Hl)e(n)}function Mu(n){return Hl.add(n),()=>{Hl.delete(n)}}function Eu(n,e){let[t,i]=(0,Ln.useState)(()=>vu(n,e));return(0,Ln.useEffect)(()=>{let r=()=>{let s=vu(n,e);i(o=>o===s?o:s)};return r(),br(r)},[n,e]),t}function br(n){return _l.add(n),()=>{_l.delete(n)}}function Ru(n){let[e,t]=(0,Ln.useState)(()=>xu(n));return(0,Ln.useEffect)(()=>{let i=()=>{let r=xu(n);t(s=>s===r?s:r)};return i(),br(i)},[n]),e}function Du(n){let e=()=>{let r=G0(n);return{carried:r!==void 0,collapsed:r!==void 0&&r.expanded===!1&&r.visible===!1}},[t,i]=(0,Ln.useState)(e);return(0,Ln.useEffect)(()=>{let r=()=>{let s=e();i(o=>o.carried===s.carried&&o.collapsed===s.collapsed?o:s)};return r(),br(r)},[n]),t}var fn=require("react"),s0=require("react-dom");var hl=require("react"),e0=require("react-dom");var mt=require("react");var Pe=require("react");function $l(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ei=$l();function Bu(n){ei=n}var xr={exec:()=>null};function ce(n,e=""){let t=typeof n=="string"?n:n.source,i={replace:(r,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(nt.caret,"$1"),t=t.replace(r,o),i},getRegex:()=>new RegExp(t,e)};return i}var nt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i")},q0=/^(?:[ \t]*(?:\n|$))+/,X0=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,J0=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,vr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Y0=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ul=/(?:[*+-]|\d{1,9}[.)])/,_u=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Hu=ce(_u).replace(/bull/g,Ul).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Z0=ce(_u).replace(/bull/g,Ul).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),jl=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Q0=/^[^\n]+/,Kl=/(?!\s*\])(?:\\.|[^\[\]\\])+/,eb=ce(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Kl).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),tb=ce(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ul).getRegex(),Gs="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Gl=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,nb=ce("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Gl).replace("tag",Gs).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Fu=ce(jl).replace("hr",vr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Gs).getRegex(),ib=ce(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Fu).getRegex(),ql={blockquote:ib,code:X0,def:eb,fences:J0,heading:Y0,hr:vr,html:nb,lheading:Hu,list:tb,newline:q0,paragraph:Fu,table:xr,text:Q0},Lu=ce("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",vr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Gs).getRegex(),rb={...ql,lheading:Z0,table:Lu,paragraph:ce(jl).replace("hr",vr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Lu).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Gs).getRegex()},sb={...ql,html:ce(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Gl).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:xr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ce(jl).replace("hr",vr).replace("heading",` *#{1,6} *[^
661
- ]`).replace("lheading",Hu).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ob=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,lb=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,zu=/^( {2,}|\\)\n(?!\s*$)/,ab=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,qs=/[\p{P}\p{S}]/u,Xl=/[\s\p{P}\p{S}]/u,Wu=/[^\s\p{P}\p{S}]/u,cb=ce(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Xl).getRegex(),Vu=/(?!~)[\p{P}\p{S}]/u,db=/(?!~)[\s\p{P}\p{S}]/u,ub=/(?:[^\s\p{P}\p{S}]|~)/u,hb=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,$u=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,fb=ce($u,"u").replace(/punct/g,qs).getRegex(),pb=ce($u,"u").replace(/punct/g,Vu).getRegex(),Uu="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",mb=ce(Uu,"gu").replace(/notPunctSpace/g,Wu).replace(/punctSpace/g,Xl).replace(/punct/g,qs).getRegex(),gb=ce(Uu,"gu").replace(/notPunctSpace/g,ub).replace(/punctSpace/g,db).replace(/punct/g,Vu).getRegex(),bb=ce("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Wu).replace(/punctSpace/g,Xl).replace(/punct/g,qs).getRegex(),wb=ce(/\\(punct)/,"gu").replace(/punct/g,qs).getRegex(),yb=ce(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),xb=ce(Gl).replace("(?:-->|$)","-->").getRegex(),vb=ce("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",xb).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Us=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,kb=ce(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Us).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ju=ce(/^!?\[(label)\]\[(ref)\]/).replace("label",Us).replace("ref",Kl).getRegex(),Ku=ce(/^!?\[(ref)\](?:\[\])?/).replace("ref",Kl).getRegex(),Sb=ce("reflink|nolink(?!\\()","g").replace("reflink",ju).replace("nolink",Ku).getRegex(),Jl={_backpedal:xr,anyPunctuation:wb,autolink:yb,blockSkip:hb,br:zu,code:lb,del:xr,emStrongLDelim:fb,emStrongRDelimAst:mb,emStrongRDelimUnd:bb,escape:ob,link:kb,nolink:Ku,punctuation:cb,reflink:ju,reflinkSearch:Sb,tag:vb,text:ab,url:xr},Cb={...Jl,link:ce(/^!?\[(label)\]\((.*?)\)/).replace("label",Us).getRegex(),reflink:ce(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Us).getRegex()},zl={...Jl,emStrongRDelimAst:gb,emStrongLDelim:pb,url:ce(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Tb={...zl,br:ce(zu).replace("{2,}","*").getRegex(),text:ce(zl.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Vs={normal:ql,gfm:rb,pedantic:sb},wr={normal:Jl,gfm:zl,breaks:Tb,pedantic:Cb},Ab={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ou=n=>Ab[n];function Qt(n,e){if(e){if(nt.escapeTest.test(n))return n.replace(nt.escapeReplace,Ou)}else if(nt.escapeTestNoEncode.test(n))return n.replace(nt.escapeReplaceNoEncode,Ou);return n}function Pu(n){try{n=encodeURI(n).replace(nt.percentDecode,"%")}catch{return null}return n}function Iu(n,e){let t=n.replace(nt.findPipe,(s,o,l)=>{let a=!1,c=o;for(;--c>=0&&l[c]==="\\";)a=!a;return a?"|":" |"}),i=t.split(nt.splitPipe),r=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),e)if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(nt.slashPipe,"|");return i}function yr(n,e,t){let i=n.length;if(i===0)return"";let r=0;for(;r<i;){let s=n.charAt(i-r-1);if(s===e&&!t)r++;else if(s!==e&&t)r++;else break}return n.slice(0,i-r)}function Mb(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let i=0;i<n.length;i++)if(n[i]==="\\")i++;else if(n[i]===e[0])t++;else if(n[i]===e[1]&&(t--,t<0))return i;return t>0?-2:-1}function Nu(n,e,t,i,r){let s=e.href,o=e.title||null,l=n[1].replace(r.other.outputLinkReplace,"$1");i.state.inLink=!0;let a={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:o,text:l,tokens:i.inlineTokens(l)};return i.state.inLink=!1,a}function Eb(n,e,t){let i=n.match(t.other.indentCodeCompensation);if(i===null)return e;let r=i[1];return e.split(`
660
+ `;function wu(){let n=document.getElementById(bu);if(n){n.textContent!==Pl&&(n.textContent=Pl);return}let e=document.createElement("style");e.id=bu,e.textContent=Pl,document.head.appendChild(e)}var mr={enabled:!0,userMarkdown:!0,lineNumbers:!0,fontFamily:"'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",sendHotkey:"mod+enter",lineBreakHotkey:"enter",defaultEdit:!0,defaultPreview:!1,composerBodyHeight:null,mode:"normal",floatX:null,floatY:null,floatW:null,floatH:null},yu="dsh-codinput.prefs.v2",K0="dsh-codinput.permission-applied",Il=new Set;function ue(){try{let n=window.localStorage.getItem(yu);if(!n)return{...mr};let e=JSON.parse(n),t={...mr,...e&&typeof e=="object"?e:null},i=e;return i.sendKey==="enter"&&(t.sendHotkey="enter",t.lineBreakHotkey="shift-enter"),t.mode=i.mode==="float"||i.mode==="normal"?i.mode:i.floating===!0?"float":"normal",t}catch{return{...mr}}}function ct(n){let e={...ue(),...n};try{window.localStorage.setItem(yu,JSON.stringify(e))}catch{}for(let t of Il)t();return e}function pn(n){return Il.add(n),()=>Il.delete(n)}function Nl(n){try{window.localStorage.setItem(K0,n)}catch{}}var On=require("react"),gr=new Map,_l=new Set,G0=1,Dn=new Map;function ku(n,e){return n.visible===e.visible&&n.expanded===e.expanded}function q0(n){if(n.size!==Dn.size)return!1;for(let[e,t]of n){let i=Dn.get(e);if(!i||!ku(i,t)||i.owner!==t.owner)return!1}return!0}function Bl(){let n=new Map;for(let[e,t]of gr){let i=n.get(t.sessionId);i?!i.visible&&t.visible&&n.set(t.sessionId,{visible:!0,expanded:t.expanded,owner:e}):n.set(t.sessionId,{visible:t.visible,expanded:t.expanded,owner:e})}if(!q0(n)){Dn=n;for(let e of _l)e()}}function Su(n,e){let t=G0++;gr.set(t,{sessionId:n,...e}),Bl();let i=!1;return{token:t,set(r){let s=gr.get(t);s&&!ku(s,r)&&(gr.set(t,{sessionId:s.sessionId,...r}),Bl())},release(){i||(i=!0,gr.delete(t)&&Bl())}}}function xu(n){return n!==void 0&&Dn.has(n)}function Cu(){return[...Dn.keys()]}function Tu(){return Dn.size>0}function X0(n){return n===void 0?void 0:Dn.get(n)}function vu(n,e){return e===0||n===void 0?!0:Dn.get(n)?.owner===e}var Hl=new Set;function Au(n){for(let e of Hl)e(n)}function Mu(n){return Hl.add(n),()=>{Hl.delete(n)}}function Eu(n,e){let[t,i]=(0,On.useState)(()=>vu(n,e));return(0,On.useEffect)(()=>{let r=()=>{let s=vu(n,e);i(o=>o===s?o:s)};return r(),br(r)},[n,e]),t}function br(n){return _l.add(n),()=>{_l.delete(n)}}function Ru(n){let[e,t]=(0,On.useState)(()=>xu(n));return(0,On.useEffect)(()=>{let i=()=>{let r=xu(n);t(s=>s===r?s:r)};return i(),br(i)},[n]),e}function Lu(n){let e=()=>{let r=X0(n);return{carried:r!==void 0,collapsed:r!==void 0&&r.expanded===!1&&r.visible===!1}},[t,i]=(0,On.useState)(e);return(0,On.useEffect)(()=>{let r=()=>{let s=e();i(o=>o.carried===s.carried&&o.collapsed===s.collapsed?o:s)};return r(),br(r)},[n]),t}var fn=require("react"),l0=require("react-dom");var hl=require("react"),n0=require("react-dom");var mt=require("react");var Pe=require("react");function $l(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ei=$l();function Bu(n){ei=n}var xr={exec:()=>null};function ce(n,e=""){let t=typeof n=="string"?n:n.source,i={replace:(r,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(nt.caret,"$1"),t=t.replace(r,o),i},getRegex:()=>new RegExp(t,e)};return i}var nt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i")},J0=/^(?:[ \t]*(?:\n|$))+/,Y0=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Z0=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,vr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Q0=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ul=/(?:[*+-]|\d{1,9}[.)])/,_u=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Hu=ce(_u).replace(/bull/g,Ul).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),eb=ce(_u).replace(/bull/g,Ul).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),jl=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,tb=/^[^\n]+/,Kl=/(?!\s*\])(?:\\.|[^\[\]\\])+/,nb=ce(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Kl).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ib=ce(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ul).getRegex(),Gs="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Gl=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,rb=ce("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Gl).replace("tag",Gs).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Fu=ce(jl).replace("hr",vr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Gs).getRegex(),sb=ce(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Fu).getRegex(),ql={blockquote:sb,code:Y0,def:nb,fences:Z0,heading:Q0,hr:vr,html:rb,lheading:Hu,list:ib,newline:J0,paragraph:Fu,table:xr,text:tb},Du=ce("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",vr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Gs).getRegex(),ob={...ql,lheading:eb,table:Du,paragraph:ce(jl).replace("hr",vr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Du).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Gs).getRegex()},lb={...ql,html:ce(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Gl).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:xr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ce(jl).replace("hr",vr).replace("heading",` *#{1,6} *[^
661
+ ]`).replace("lheading",Hu).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ab=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,cb=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,zu=/^( {2,}|\\)\n(?!\s*$)/,db=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,qs=/[\p{P}\p{S}]/u,Xl=/[\s\p{P}\p{S}]/u,Wu=/[^\s\p{P}\p{S}]/u,ub=ce(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Xl).getRegex(),Vu=/(?!~)[\p{P}\p{S}]/u,hb=/(?!~)[\s\p{P}\p{S}]/u,fb=/(?:[^\s\p{P}\p{S}]|~)/u,pb=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,$u=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,mb=ce($u,"u").replace(/punct/g,qs).getRegex(),gb=ce($u,"u").replace(/punct/g,Vu).getRegex(),Uu="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",bb=ce(Uu,"gu").replace(/notPunctSpace/g,Wu).replace(/punctSpace/g,Xl).replace(/punct/g,qs).getRegex(),wb=ce(Uu,"gu").replace(/notPunctSpace/g,fb).replace(/punctSpace/g,hb).replace(/punct/g,Vu).getRegex(),yb=ce("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Wu).replace(/punctSpace/g,Xl).replace(/punct/g,qs).getRegex(),xb=ce(/\\(punct)/,"gu").replace(/punct/g,qs).getRegex(),vb=ce(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),kb=ce(Gl).replace("(?:-->|$)","-->").getRegex(),Sb=ce("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",kb).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Us=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Cb=ce(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Us).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ju=ce(/^!?\[(label)\]\[(ref)\]/).replace("label",Us).replace("ref",Kl).getRegex(),Ku=ce(/^!?\[(ref)\](?:\[\])?/).replace("ref",Kl).getRegex(),Tb=ce("reflink|nolink(?!\\()","g").replace("reflink",ju).replace("nolink",Ku).getRegex(),Jl={_backpedal:xr,anyPunctuation:xb,autolink:vb,blockSkip:pb,br:zu,code:cb,del:xr,emStrongLDelim:mb,emStrongRDelimAst:bb,emStrongRDelimUnd:yb,escape:ab,link:Cb,nolink:Ku,punctuation:ub,reflink:ju,reflinkSearch:Tb,tag:Sb,text:db,url:xr},Ab={...Jl,link:ce(/^!?\[(label)\]\((.*?)\)/).replace("label",Us).getRegex(),reflink:ce(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Us).getRegex()},zl={...Jl,emStrongRDelimAst:wb,emStrongLDelim:gb,url:ce(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Mb={...zl,br:ce(zu).replace("{2,}","*").getRegex(),text:ce(zl.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Vs={normal:ql,gfm:ob,pedantic:lb},wr={normal:Jl,gfm:zl,breaks:Mb,pedantic:Ab},Eb={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ou=n=>Eb[n];function Qt(n,e){if(e){if(nt.escapeTest.test(n))return n.replace(nt.escapeReplace,Ou)}else if(nt.escapeTestNoEncode.test(n))return n.replace(nt.escapeReplaceNoEncode,Ou);return n}function Pu(n){try{n=encodeURI(n).replace(nt.percentDecode,"%")}catch{return null}return n}function Iu(n,e){let t=n.replace(nt.findPipe,(s,o,l)=>{let a=!1,c=o;for(;--c>=0&&l[c]==="\\";)a=!a;return a?"|":" |"}),i=t.split(nt.splitPipe),r=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),e)if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(nt.slashPipe,"|");return i}function yr(n,e,t){let i=n.length;if(i===0)return"";let r=0;for(;r<i;){let s=n.charAt(i-r-1);if(s===e&&!t)r++;else if(s!==e&&t)r++;else break}return n.slice(0,i-r)}function Rb(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let i=0;i<n.length;i++)if(n[i]==="\\")i++;else if(n[i]===e[0])t++;else if(n[i]===e[1]&&(t--,t<0))return i;return t>0?-2:-1}function Nu(n,e,t,i,r){let s=e.href,o=e.title||null,l=n[1].replace(r.other.outputLinkReplace,"$1");i.state.inLink=!0;let a={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:o,text:l,tokens:i.inlineTokens(l)};return i.state.inLink=!1,a}function Lb(n,e,t){let i=n.match(t.other.indentCodeCompensation);if(i===null)return e;let r=i[1];return e.split(`
662
662
  `).map(s=>{let o=s.match(t.other.beginningSpace);if(o===null)return s;let[l]=o;return l.length>=r.length?s.slice(r.length):s}).join(`
663
663
  `)}var js=class{constructor(n){de(this,"options");de(this,"rules");de(this,"lexer");this.options=n||ei}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:yr(t,`
664
- `)}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],i=Eb(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:i}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let i=yr(t,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(t=i.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:yr(e[0],`
664
+ `)}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],i=Lb(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:i}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let i=yr(t,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(t=i.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:yr(e[0],`
665
665
  `)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=yr(e[0],`
666
666
  `).split(`
667
667
  `),i="",r="",s=[];for(;t.length>0;){let o=!1,l=[],a;for(a=0;a<t.length;a++)if(this.rules.other.blockquoteStart.test(t[a]))l.push(t[a]),o=!0;else if(!o)l.push(t[a]);else break;t=t.slice(a);let c=l.join(`
@@ -676,13 +676,13 @@ ${d}`:d;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
676
676
  `);continue}}return{type:"blockquote",raw:i,tokens:s,text:r}}}list(n){let e=this.rules.block.list.exec(n);if(e){let t=e[1].trim(),i=t.length>1,r={type:"list",raw:"",ordered:i,start:i?+t.slice(0,-1):"",loose:!1,items:[]};t=i?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=i?t:"[*+-]");let s=this.rules.other.listItemRegex(t),o=!1;for(;n;){let a=!1,c="",d="";if(!(e=s.exec(n))||this.rules.block.hr.test(n))break;c=e[0],n=n.substring(c.length);let u=e[2].split(`
677
677
  `,1)[0].replace(this.rules.other.listReplaceTabs,b=>" ".repeat(3*b.length)),h=n.split(`
678
678
  `,1)[0],f=!u.trim(),p=0;if(this.options.pedantic?(p=2,d=u.trimStart()):f?p=e[1].length+1:(p=e[2].search(this.rules.other.nonSpaceChar),p=p>4?1:p,d=u.slice(p),p+=e[1].length),f&&this.rules.other.blankLine.test(h)&&(c+=h+`
679
- `,n=n.substring(h.length+1),a=!0),!a){let b=this.rules.other.nextBulletRegex(p),v=this.rules.other.hrRegex(p),k=this.rules.other.fencesBeginRegex(p),N=this.rules.other.headingBeginRegex(p),S=this.rules.other.htmlBeginRegex(p);for(;n;){let C=n.split(`
680
- `,1)[0],A;if(h=C,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),A=h):A=h.replace(this.rules.other.tabCharGlobal," "),k.test(h)||N.test(h)||S.test(h)||b.test(h)||v.test(h))break;if(A.search(this.rules.other.nonSpaceChar)>=p||!h.trim())d+=`
681
- `+A.slice(p);else{if(f||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||k.test(u)||N.test(u)||v.test(u))break;d+=`
682
- `+h}!f&&!h.trim()&&(f=!0),c+=C+`
683
- `,n=n.substring(C.length+1),u=A.slice(p)}}r.loose||(o?r.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0));let m=null,w;this.options.gfm&&(m=this.rules.other.listIsTask.exec(d),m&&(w=m[0]!=="[ ] ",d=d.replace(this.rules.other.listReplaceTask,""))),r.items.push({type:"list_item",raw:c,task:!!m,checked:w,loose:!1,text:d,tokens:[]}),r.raw+=c}let l=r.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let a=0;a<r.items.length;a++)if(this.lexer.state.top=!1,r.items[a].tokens=this.lexer.blockTokens(r.items[a].text,[]),!r.loose){let c=r.items[a].tokens.filter(u=>u.type==="space"),d=c.length>0&&c.some(u=>this.rules.other.anyLine.test(u.raw));r.loose=d}if(r.loose)for(let a=0;a<r.items.length;a++)r.items[a].loose=!0;return r}}html(n){let e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){let e=this.rules.block.def.exec(n);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:i,title:r}}}table(n){let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=Iu(e[1]),i=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
679
+ `,n=n.substring(h.length+1),a=!0),!a){let b=this.rules.other.nextBulletRegex(p),k=this.rules.other.hrRegex(p),C=this.rules.other.fencesBeginRegex(p),P=this.rules.other.headingBeginRegex(p),S=this.rules.other.htmlBeginRegex(p);for(;n;){let x=n.split(`
680
+ `,1)[0],T;if(h=x,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),T=h):T=h.replace(this.rules.other.tabCharGlobal," "),C.test(h)||P.test(h)||S.test(h)||b.test(h)||k.test(h))break;if(T.search(this.rules.other.nonSpaceChar)>=p||!h.trim())d+=`
681
+ `+T.slice(p);else{if(f||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||C.test(u)||P.test(u)||k.test(u))break;d+=`
682
+ `+h}!f&&!h.trim()&&(f=!0),c+=x+`
683
+ `,n=n.substring(x.length+1),u=T.slice(p)}}r.loose||(o?r.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0));let m=null,w;this.options.gfm&&(m=this.rules.other.listIsTask.exec(d),m&&(w=m[0]!=="[ ] ",d=d.replace(this.rules.other.listReplaceTask,""))),r.items.push({type:"list_item",raw:c,task:!!m,checked:w,loose:!1,text:d,tokens:[]}),r.raw+=c}let l=r.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let a=0;a<r.items.length;a++)if(this.lexer.state.top=!1,r.items[a].tokens=this.lexer.blockTokens(r.items[a].text,[]),!r.loose){let c=r.items[a].tokens.filter(u=>u.type==="space"),d=c.length>0&&c.some(u=>this.rules.other.anyLine.test(u.raw));r.loose=d}if(r.loose)for(let a=0;a<r.items.length;a++)r.items[a].loose=!0;return r}}html(n){let e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){let e=this.rules.block.def.exec(n);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:i,title:r}}}table(n){let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=Iu(e[1]),i=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
684
684
  `):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===i.length){for(let o of i)this.rules.other.tableAlignRight.test(o)?s.align.push("right"):this.rules.other.tableAlignCenter.test(o)?s.align.push("center"):this.rules.other.tableAlignLeft.test(o)?s.align.push("left"):s.align.push(null);for(let o=0;o<t.length;o++)s.header.push({text:t[o],tokens:this.lexer.inline(t[o]),header:!0,align:s.align[o]});for(let o of r)s.rows.push(Iu(o,s.header.length).map((l,a)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:s.align[a]})));return s}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
685
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let s=yr(t.slice(0,-1),"\\");if((t.length-s.length)%2===0)return}else{let s=Mb(e[2],"()");if(s===-2)return;if(s>-1){let l=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,l).trim(),e[3]=""}}let i=e[2],r="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(i);s&&(i=s[1],r=s[3])}else r=e[3]?e[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?i=i.slice(1):i=i.slice(1,-1)),Nu(e,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let i=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[i.toLowerCase()];if(!r){let s=t[0].charAt(0);return{type:"text",raw:s,text:s}}return Nu(t,r,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let i=this.rules.inline.emStrongLDelim.exec(n);if(!i||i[3]&&t.match(this.rules.other.unicodeAlphaNumeric))return;if(!(i[1]||i[2]||"")||!t||this.rules.inline.punctuation.exec(t)){let s=[...i[0]].length-1,o,l,a=s,c=0,d=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,e=e.slice(-1*n.length+s);(i=d.exec(e))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(l=[...o].length,i[3]||i[4]){a+=l;continue}else if((i[5]||i[6])&&s%3&&!((s+l)%3)){c+=l;continue}if(a-=l,a>0)continue;l=Math.min(l,l+a+c);let u=[...i[0]][0].length,h=n.slice(0,s+i.index+u+l);if(Math.min(s,l)%2){let p=h.slice(1,-1);return{type:"em",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}let f=h.slice(2,-2);return{type:"strong",raw:h,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(t),r=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return i&&r&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n){let e=this.rules.inline.del.exec(n);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,i;return e[2]==="@"?(t=e[1],i="mailto:"+t):(t=e[1],i=t),{type:"link",raw:e[0],text:t,href:i,tokens:[{type:"text",raw:t,text:t}]}}}url(n){let e;if(e=this.rules.inline.url.exec(n)){let t,i;if(e[2]==="@")t=e[0],i="mailto:"+t;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);t=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:t,href:i,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},mn=class Wl{constructor(e){de(this,"tokens");de(this,"options");de(this,"state");de(this,"tokenizer");de(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ei,this.options.tokenizer=this.options.tokenizer||new js,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:nt,block:Vs.normal,inline:wr.normal};this.options.pedantic?(t.block=Vs.pedantic,t.inline=wr.pedantic):this.options.gfm&&(t.block=Vs.gfm,this.options.breaks?t.inline=wr.breaks:t.inline=wr.gfm),this.tokenizer.rules=t}static get rules(){return{block:Vs,inline:wr}}static lex(e,t){return new Wl(t).lex(e)}static lexInline(e,t){return new Wl(t).inlineTokens(e)}lex(e){e=e.replace(nt.carriageReturn,`
685
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let s=yr(t.slice(0,-1),"\\");if((t.length-s.length)%2===0)return}else{let s=Rb(e[2],"()");if(s===-2)return;if(s>-1){let l=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,l).trim(),e[3]=""}}let i=e[2],r="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(i);s&&(i=s[1],r=s[3])}else r=e[3]?e[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?i=i.slice(1):i=i.slice(1,-1)),Nu(e,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let i=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[i.toLowerCase()];if(!r){let s=t[0].charAt(0);return{type:"text",raw:s,text:s}}return Nu(t,r,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let i=this.rules.inline.emStrongLDelim.exec(n);if(!i||i[3]&&t.match(this.rules.other.unicodeAlphaNumeric))return;if(!(i[1]||i[2]||"")||!t||this.rules.inline.punctuation.exec(t)){let s=[...i[0]].length-1,o,l,a=s,c=0,d=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,e=e.slice(-1*n.length+s);(i=d.exec(e))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(l=[...o].length,i[3]||i[4]){a+=l;continue}else if((i[5]||i[6])&&s%3&&!((s+l)%3)){c+=l;continue}if(a-=l,a>0)continue;l=Math.min(l,l+a+c);let u=[...i[0]][0].length,h=n.slice(0,s+i.index+u+l);if(Math.min(s,l)%2){let p=h.slice(1,-1);return{type:"em",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}let f=h.slice(2,-2);return{type:"strong",raw:h,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(t),r=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return i&&r&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n){let e=this.rules.inline.del.exec(n);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,i;return e[2]==="@"?(t=e[1],i="mailto:"+t):(t=e[1],i=t),{type:"link",raw:e[0],text:t,href:i,tokens:[{type:"text",raw:t,text:t}]}}}url(n){let e;if(e=this.rules.inline.url.exec(n)){let t,i;if(e[2]==="@")t=e[0],i="mailto:"+t;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);t=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:t,href:i,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},mn=class Wl{constructor(e){de(this,"tokens");de(this,"options");de(this,"state");de(this,"tokenizer");de(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ei,this.options.tokenizer=this.options.tokenizer||new js,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:nt,block:Vs.normal,inline:wr.normal};this.options.pedantic?(t.block=Vs.pedantic,t.inline=wr.pedantic):this.options.gfm&&(t.block=Vs.gfm,this.options.breaks?t.inline=wr.breaks:t.inline=wr.gfm),this.tokenizer.rules=t}static get rules(){return{block:Vs,inline:wr}}static lex(e,t){return new Wl(t).lex(e)}static lexInline(e,t){return new Wl(t).inlineTokens(e)}lex(e){e=e.replace(nt.carriageReturn,`
686
686
  `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let i=this.inlineQueue[t];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],i=!1){for(this.options.pedantic&&(e=e.replace(nt.tabCharGlobal," ").replace(nt.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(o=>(r=o.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let o=t.at(-1);r.raw.length===1&&o!==void 0?o.raw+=`
687
687
  `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let o=t.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=`
688
688
  `+r.raw,o.text+=`
@@ -712,18 +712,18 @@ ${n}</tr>
712
712
  `}tablecell(n){let e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
713
713
  `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${Qt(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let i=this.parser.parseInline(t),r=Pu(n);if(r===null)return i;n=r;let s='<a href="'+n+'"';return e&&(s+=' title="'+Qt(e)+'"'),s+=">"+i+"</a>",s}image({href:n,title:e,text:t,tokens:i}){i&&(t=this.parser.parseInline(i,this.parser.textRenderer));let r=Pu(n);if(r===null)return Qt(t);n=r;let s=`<img src="${n}" alt="${t}"`;return e&&(s+=` title="${Qt(e)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:Qt(n.text)}},Yl=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}},gn=class Vl{constructor(e){de(this,"options");de(this,"renderer");de(this,"textRenderer");this.options=e||ei,this.options.renderer=this.options.renderer||new Ks,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Yl}static parse(e,t){return new Vl(t).parse(e)}static parseInline(e,t){return new Vl(t).parseInline(e)}parse(e,t=!0){let i="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let l=s,a=this.options.extensions.renderers[l.type].call({parser:this},l);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(l.type)){i+=a||"";continue}}let o=s;switch(o.type){case"space":{i+=this.renderer.space(o);continue}case"hr":{i+=this.renderer.hr(o);continue}case"heading":{i+=this.renderer.heading(o);continue}case"code":{i+=this.renderer.code(o);continue}case"table":{i+=this.renderer.table(o);continue}case"blockquote":{i+=this.renderer.blockquote(o);continue}case"list":{i+=this.renderer.list(o);continue}case"html":{i+=this.renderer.html(o);continue}case"paragraph":{i+=this.renderer.paragraph(o);continue}case"text":{let l=o,a=this.renderer.text(l);for(;r+1<e.length&&e[r+1].type==="text";)l=e[++r],a+=`
714
714
  `+this.renderer.text(l);t?i+=this.renderer.paragraph({type:"paragraph",raw:a,text:a,tokens:[{type:"text",raw:a,text:a,escaped:!0}]}):i+=a;continue}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return i}parseInline(e,t=this.renderer){let i="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let l=this.options.extensions.renderers[s.type].call({parser:this},s);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){i+=l||"";continue}}let o=s;switch(o.type){case"escape":{i+=t.text(o);break}case"html":{i+=t.html(o);break}case"link":{i+=t.link(o);break}case"image":{i+=t.image(o);break}case"strong":{i+=t.strong(o);break}case"em":{i+=t.em(o);break}case"codespan":{i+=t.codespan(o);break}case"br":{i+=t.br(o);break}case"del":{i+=t.del(o);break}case"text":{i+=t.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return i}},Fl,$s=(Fl=class{constructor(n){de(this,"options");de(this,"block");this.options=n||ei}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?mn.lex:mn.lexInline}provideParser(){return this.block?gn.parse:gn.parseInline}},de(Fl,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"])),Fl),Zl=class{constructor(...n){de(this,"defaults",$l());de(this,"options",this.setOptions);de(this,"parse",this.parseMarkdown(!0));de(this,"parseInline",this.parseMarkdown(!1));de(this,"Parser",gn);de(this,"Renderer",Ks);de(this,"TextRenderer",Yl);de(this,"Lexer",mn);de(this,"Tokenizer",js);de(this,"Hooks",$s);this.use(...n)}walkTokens(n,e){let t=[];for(let i of n)switch(t=t.concat(e.call(this,i)),i.type){case"table":{let r=i;for(let s of r.header)t=t.concat(this.walkTokens(s.tokens,e));for(let s of r.rows)for(let o of s)t=t.concat(this.walkTokens(o.tokens,e));break}case"list":{let r=i;t=t.concat(this.walkTokens(r.items,e));break}default:{let r=i;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(s=>{let o=r[s].flat(1/0);t=t.concat(this.walkTokens(o,e))}):r.tokens&&(t=t.concat(this.walkTokens(r.tokens,e)))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let i={...t};if(i.async=this.defaults.async||i.async||!1,t.extensions&&(t.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let s=e.renderers[r.name];s?e.renderers[r.name]=function(...o){let l=r.renderer.apply(this,o);return l===!1&&(l=s.apply(this,o)),l}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[r.level];s?s.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),i.extensions=e),t.renderer){let r=this.defaults.renderer||new Ks(this.defaults);for(let s in t.renderer){if(!(s in r))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,l=t.renderer[o],a=r[o];r[o]=(...c)=>{let d=l.apply(r,c);return d===!1&&(d=a.apply(r,c)),d||""}}i.renderer=r}if(t.tokenizer){let r=this.defaults.tokenizer||new js(this.defaults);for(let s in t.tokenizer){if(!(s in r))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,l=t.tokenizer[o],a=r[o];r[o]=(...c)=>{let d=l.apply(r,c);return d===!1&&(d=a.apply(r,c)),d}}i.tokenizer=r}if(t.hooks){let r=this.defaults.hooks||new $s;for(let s in t.hooks){if(!(s in r))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,l=t.hooks[o],a=r[o];$s.passThroughHooks.has(s)?r[o]=c=>{if(this.defaults.async)return Promise.resolve(l.call(r,c)).then(u=>a.call(r,u));let d=l.call(r,c);return a.call(r,d)}:r[o]=(...c)=>{let d=l.apply(r,c);return d===!1&&(d=a.apply(r,c)),d}}i.hooks=r}if(t.walkTokens){let r=this.defaults.walkTokens,s=t.walkTokens;i.walkTokens=function(o){let l=[];return l.push(s.call(this,o)),r&&(l=l.concat(r.call(this,o))),l}}this.defaults={...this.defaults,...i}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return mn.lex(n,e??this.defaults)}parser(n,e){return gn.parse(n,e??this.defaults)}parseMarkdown(n){return(t,i)=>{let r={...i},s={...this.defaults,...r},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));s.hooks&&(s.hooks.options=s,s.hooks.block=n);let l=s.hooks?s.hooks.provideLexer():n?mn.lex:mn.lexInline,a=s.hooks?s.hooks.provideParser():n?gn.parse:gn.parseInline;if(s.async)return Promise.resolve(s.hooks?s.hooks.preprocess(t):t).then(c=>l(c,s)).then(c=>s.hooks?s.hooks.processAllTokens(c):c).then(c=>s.walkTokens?Promise.all(this.walkTokens(c,s.walkTokens)).then(()=>c):c).then(c=>a(c,s)).then(c=>s.hooks?s.hooks.postprocess(c):c).catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let c=l(t,s);s.hooks&&(c=s.hooks.processAllTokens(c)),s.walkTokens&&this.walkTokens(c,s.walkTokens);let d=a(c,s);return s.hooks&&(d=s.hooks.postprocess(d)),d}catch(c){return o(c)}}}onError(n,e){return t=>{if(t.message+=`
715
- Please report this to https://github.com/markedjs/marked.`,n){let i="<p>An error occurred:</p><pre>"+Qt(t.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(t);throw t}}},Qn=new Zl;function ae(n,e){return Qn.parse(n,e)}ae.options=ae.setOptions=function(n){return Qn.setOptions(n),ae.defaults=Qn.defaults,Bu(ae.defaults),ae};ae.getDefaults=$l;ae.defaults=ei;ae.use=function(...n){return Qn.use(...n),ae.defaults=Qn.defaults,Bu(ae.defaults),ae};ae.walkTokens=function(n,e){return Qn.walkTokens(n,e)};ae.parseInline=Qn.parseInline;ae.Parser=gn;ae.parser=gn.parse;ae.Renderer=Ks;ae.TextRenderer=Yl;ae.Lexer=mn;ae.lexer=mn.lex;ae.Tokenizer=js;ae.Hooks=$s;ae.parse=ae;var Hk=ae.options,Fk=ae.setOptions,zk=ae.use,Wk=ae.walkTokens,Vk=ae.parseInline;var $k=gn.parse,Uk=mn.lex;var Mr={};du(Mr,{default:()=>Ar});function Gu(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=Array(e);t<e;t++)i[t]=n[t];return i}function Rb(n){if(Array.isArray(n))return n}function Db(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var i,r,s,o,l=[],a=!0,c=!1;try{if(s=(t=t.call(n)).next,e!==0)for(;!(a=(i=s.call(t)).done)&&(l.push(i.value),l.length!==e);a=!0);}catch(d){c=!0,r=d}finally{try{if(!a&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(c)throw r}}return l}}function Lb(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
716
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ob(n,e){return Rb(n)||Db(n,e)||Pb(n,e)||Lb()}function Pb(n,e){if(n){if(typeof n=="string")return Gu(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Gu(n,e):void 0}}var ah=Object.entries,qu=Object.setPrototypeOf,Ib=Object.isFrozen,Nb=Object.getPrototypeOf,Bb=Object.getOwnPropertyDescriptor,ze=Object.freeze,Ve=Object.seal,Ni=Object.create,ch=typeof Reflect<"u"&&Reflect,sa=ch.apply,oa=ch.construct;ze||(ze=function(e){return e});Ve||(Ve=function(e){return e});sa||(sa=function(e,t){for(var i=arguments.length,r=new Array(i>2?i-2:0),s=2;s<i;s++)r[s-2]=arguments[s];return e.apply(t,r)});oa||(oa=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return new e(...i)});var ni=Ne(Array.prototype.forEach),_b=Ne(Array.prototype.lastIndexOf),Xu=Ne(Array.prototype.pop),kr=Ne(Array.prototype.push),Hb=Ne(Array.prototype.splice),Bi=Array.isArray,Tr=Ne(String.prototype.toLowerCase),Ql=Ne(String.prototype.toString),Ju=Ne(String.prototype.match),Sr=Ne(String.prototype.replace),Yu=Ne(String.prototype.indexOf),Fb=Ne(String.prototype.trim),zb=Ne(Number.prototype.toString),Wb=Ne(Boolean.prototype.toString),Zu=typeof BigInt>"u"?null:Ne(BigInt.prototype.toString),Qu=typeof Symbol>"u"?null:Ne(Symbol.prototype.toString),dt=Ne(Object.prototype.hasOwnProperty),Cr=Ne(Object.prototype.toString),Je=Ne(RegExp.prototype.test),ti=Vb(TypeError);function Ne(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return sa(n,e,i)}}function Vb(n){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return oa(n,t)}}function le(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tr;if(qu&&qu(n,null),!Bi(e))return n;let i=e.length;for(;i--;){let r=e[i];if(typeof r=="string"){let s=t(r);s!==r&&(Ib(e)||(e[i]=s),r=s)}n[r]=!0}return n}function $b(n){for(let e=0;e<n.length;e++)dt(n,e)||(n[e]=null);return n}function bt(n){let e=Ni(null);for(let i of ah(n)){var t=Ob(i,2);let r=t[0],s=t[1];dt(n,r)&&(Bi(s)?e[r]=$b(s):s&&typeof s=="object"&&s.constructor===Object?e[r]=bt(s):e[r]=s)}return e}function Ub(n){switch(typeof n){case"string":return n;case"number":return zb(n);case"boolean":return Wb(n);case"bigint":return Zu?Zu(n):"0";case"symbol":return Qu?Qu(n):"Symbol()";case"undefined":return Cr(n);case"function":case"object":{if(n===null)return Cr(n);let e=n,t=Ct(e,"toString");if(typeof t=="function"){let i=t(e);return typeof i=="string"?i:Cr(i)}return Cr(n)}default:return Cr(n)}}function Ct(n,e){for(;n!==null;){let i=Bb(n,e);if(i){if(i.get)return Ne(i.get);if(typeof i.value=="function")return Ne(i.value)}n=Nb(n)}function t(){return null}return t}function jb(n){try{return Je(n,""),!0}catch{return!1}}var eh=ze(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ea=ze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ta=ze(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Kb=ze(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),na=ze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Gb=ze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),th=ze(["#text"]),nh=ze(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ia=ze(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ih=ze(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Xs=ze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),qb=Ve(/{{[\w\W]*|^[\w\W]*}}/g),Xb=Ve(/<%[\w\W]*|^[\w\W]*%>/g),Jb=Ve(/\${[\w\W]*/g),Yb=Ve(/^data-[\-\w.\u00B7-\uFFFF]+$/),Zb=Ve(/^aria-[\-\w]+$/),rh=Ve(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Qb=Ve(/^(?:\w+script|data):/i),ew=Ve(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),tw=Ve(/^html$/i),nw=Ve(/^[a-z][.\w]*(-[.\w]+)+$/i),sh=Ve(/<[/\w!]/g),oh=Ve(/<[/\w]/g),iw=Ve(/<\/no(script|embed|frames)/i),rw=Ve(/\/>/i),gt={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},dh=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],sw=ze(le({},dh)),ow=(function(){let n={};return ni(dh,e=>{n[e]=Ve(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),ze(n)})(),lw=function(){return typeof window>"u"?null:window},aw=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null,r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(i=t.getAttribute(r));let s="dompurify"+(i?"#"+i:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},lh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},On=function(e,t,i,r){return dt(e,t)&&Bi(e[t])?le(r.base?bt(r.base):{},e[t],r.transform):i},ra=function(e,t,i){let r=dt(e,t)?e[t]:void 0;return r&&typeof r=="object"?bt(r):i()};function uh(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:lw(),e=E=>uh(E);if(e.version="3.4.15",e.removed=[],!n||!n.document||n.document.nodeType!==gt.document||!n.Element)return e.isSupported=!1,e;let t=n.document,i=t,r=i.currentScript;n.DocumentFragment;let s=n.HTMLTemplateElement,o=n.Node,l=n.Element,a=n.NodeFilter,c=n.NamedNodeMap;c===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;let d=n.DOMParser,u=n.trustedTypes,h=l.prototype,f=Ct(h,"cloneNode"),p=Ct(h,"remove"),m=Ct(h,"removeAttributeNode"),w=Ct(h,"nextSibling"),b=Ct(h,"childNodes"),v=Ct(h,"parentNode"),k=Ct(h,"shadowRoot"),N=Ct(h,"attributes"),S=o&&o.prototype?Ct(o.prototype,"nodeType"):null,C=o&&o.prototype?Ct(o.prototype,"nodeName"):null,A=o&&o.prototype?Ct(o.prototype,"ownerDocument"):null,$=function(g){return S?S(g):g.nodeType},F=function(g){return C?C(g):g.nodeName};if(typeof s=="function"){let E=t.createElement("template");E.content&&E.content.ownerDocument&&(t=E.content.ownerDocument)}let R,O="",M,P=!1,z=0,J=function(){if(z>0)throw ti('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},q=function(g){J(),z++;try{return R.createHTML(g)}finally{z--}},Me=function(g){J(),z++;try{return R.createScriptURL(g)}finally{z--}},et=function(){return P||(M=aw(u,r),P=!0),M},Se=t,je=Se.implementation,ot=Se.createNodeIterator,Ke=Se.createDocumentFragment,Xe=Se.getElementsByTagName,kt=i.importNode,ie=lh();e.isSupported=typeof ah=="function"&&typeof v=="function"&&je&&je.createHTMLDocument!==void 0;let Tn=qb,Mi=Xb,dr=Jb,pl=Yb,ml=Zb,gl=Qb,ks=ew,Ss=nw,bl=rh,ye=null,Cs=le({},[...eh,...ea,...ta,...na,...th]),xe=null,K=le({},[...nh,...ia,...ih,...Xs]),Z=Object.seal(Ni(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ie=null,An=null,We=Object.seal(Ni(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Mn=!0,It=!0,Ts=!1,Fd=!0,En=!1,Jn=!0,Yn=!1,wl=!1,As=null,Ms=null,yl=!1,Ei=!1,Es=!1,Rs=!1,zd=!0,Wd=!1,Vd="user-content-",xl=!0,vl=!1,Ri={},Di=null,$d=le({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),Ud=null,jd=le({},["audio","video","img","source","image","track"]),Kd=null,Gd=le({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ds="http://www.w3.org/1998/Math/MathML",Ls="http://www.w3.org/2000/svg",Jt="http://www.w3.org/1999/xhtml",Li=Jt,kl=!1,Sl=null,w0=le({},[Ds,Ls,Jt],Ql),qd=ze(["mi","mo","mn","ms","mtext"]),Cl=le({},qd),Xd=ze(["annotation-xml"]),Tl=le({},Xd),y0=le({},["title","style","font","a","script"]),ur=null,x0=["application/xhtml+xml","text/html"],v0="text/html",Le=null,Oi=null,k0=t.createElement("form"),Jd=function(g){return g instanceof RegExp||g instanceof Function},Al=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Oi&&Oi===g)return;(!g||typeof g!="object")&&(g={}),g=bt(g),ur=x0.indexOf(g.PARSER_MEDIA_TYPE)===-1?v0:g.PARSER_MEDIA_TYPE,Le=ur==="application/xhtml+xml"?Ql:Tr,ye=On(g,"ALLOWED_TAGS",Cs,{transform:Le}),xe=On(g,"ALLOWED_ATTR",K,{transform:Le}),Sl=On(g,"ALLOWED_NAMESPACES",w0,{transform:Ql}),Kd=On(g,"ADD_URI_SAFE_ATTR",Gd,{transform:Le,base:Gd}),Ud=On(g,"ADD_DATA_URI_TAGS",jd,{transform:Le,base:jd}),Di=On(g,"FORBID_CONTENTS",$d,{transform:Le}),Ie=On(g,"FORBID_TAGS",bt({}),{transform:Le}),An=On(g,"FORBID_ATTR",bt({}),{transform:Le}),Ri=dt(g,"USE_PROFILES")?g.USE_PROFILES&&typeof g.USE_PROFILES=="object"?bt(g.USE_PROFILES):g.USE_PROFILES:!1,Mn=g.ALLOW_ARIA_ATTR!==!1,It=g.ALLOW_DATA_ATTR!==!1,Ts=g.ALLOW_UNKNOWN_PROTOCOLS||!1,Fd=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,En=g.SAFE_FOR_TEMPLATES||!1,Jn=g.SAFE_FOR_XML!==!1,Yn=g.WHOLE_DOCUMENT||!1,Ei=g.RETURN_DOM||!1,Es=g.RETURN_DOM_FRAGMENT||!1,Rs=g.RETURN_TRUSTED_TYPE||!1,yl=g.FORCE_BODY||!1,zd=g.SANITIZE_DOM!==!1,Wd=g.SANITIZE_NAMED_PROPS||!1,xl=g.KEEP_CONTENT!==!1,vl=g.IN_PLACE||!1,bl=jb(g.ALLOWED_URI_REGEXP)?g.ALLOWED_URI_REGEXP:rh,Li=typeof g.NAMESPACE=="string"?g.NAMESPACE:Jt,Cl=ra(g,"MATHML_TEXT_INTEGRATION_POINTS",()=>le({},qd)),Tl=ra(g,"HTML_INTEGRATION_POINTS",()=>le({},Xd));let y=ra(g,"CUSTOM_ELEMENT_HANDLING",()=>Ni(null));if(Z=Ni(null),dt(y,"tagNameCheck")&&Jd(y.tagNameCheck)&&(Z.tagNameCheck=y.tagNameCheck),dt(y,"attributeNameCheck")&&Jd(y.attributeNameCheck)&&(Z.attributeNameCheck=y.attributeNameCheck),dt(y,"allowCustomizedBuiltInElements")&&typeof y.allowCustomizedBuiltInElements=="boolean"&&(Z.allowCustomizedBuiltInElements=y.allowCustomizedBuiltInElements),Ve(Z),En&&(It=!1),Es&&(Ei=!0),Ri&&(ye=le({},th),xe=Ni(null),Ri.html===!0&&(le(ye,eh),le(xe,nh)),Ri.svg===!0&&(le(ye,ea),le(xe,ia),le(xe,Xs)),Ri.svgFilters===!0&&(le(ye,ta),le(xe,ia),le(xe,Xs)),Ri.mathMl===!0&&(le(ye,na),le(xe,ih),le(xe,Xs))),We.tagCheck=null,We.attributeCheck=null,dt(g,"ADD_TAGS")&&(typeof g.ADD_TAGS=="function"?We.tagCheck=g.ADD_TAGS:Bi(g.ADD_TAGS)&&(ye===Cs&&(ye=bt(ye)),le(ye,g.ADD_TAGS,Le))),dt(g,"ADD_ATTR")&&(typeof g.ADD_ATTR=="function"?We.attributeCheck=g.ADD_ATTR:Bi(g.ADD_ATTR)&&(xe===K&&(xe=bt(xe)),le(xe,g.ADD_ATTR,Le))),dt(g,"ADD_FORBID_CONTENTS")&&Bi(g.ADD_FORBID_CONTENTS)&&(Di===$d&&(Di=bt(Di)),le(Di,g.ADD_FORBID_CONTENTS,Le)),xl&&(ye["#text"]=!0),Yn&&le(ye,["html","head","body"]),ye.table&&(le(ye,["tbody"]),delete Ie.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw ti('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ti('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let T=R;R=g.TRUSTED_TYPES_POLICY;try{O=q("")}catch(H){throw R=T,H}}else g.TRUSTED_TYPES_POLICY===null?(R=void 0,O=""):(R===void 0&&(R=et()),R&&typeof O=="string"&&(O=q("")));ze&&ze(g),Oi=g},Yd=le({},[...ea,...ta,...Kb]),Zd=le({},[...na,...Gb]),S0=function(g,y,T){return y.namespaceURI===Jt?g==="svg":y.namespaceURI===Ds?g==="svg"&&(T==="annotation-xml"||Cl[T]):!!Yd[g]},C0=function(g,y,T){return y.namespaceURI===Jt?g==="math":y.namespaceURI===Ls?g==="math"&&Tl[T]:!!Zd[g]},T0=function(g,y,T){return y.namespaceURI===Ls&&!Tl[T]||y.namespaceURI===Ds&&!Cl[T]?!1:!Zd[g]&&(y0[g]||!Yd[g])},A0=function(g){let y=v(g);(!y||!y.tagName)&&(y={namespaceURI:Li,tagName:"template"});let T=Tr(g.tagName),H=Tr(y.tagName);return Sl[g.namespaceURI]?g.namespaceURI===Ls?S0(T,y,H):g.namespaceURI===Ds?C0(T,y,H):g.namespaceURI===Jt?T0(T,y,H):!!(ur==="application/xhtml+xml"&&Sl[g.namespaceURI]):!1},Rn=function(g){kr(e.removed,{element:g});try{v(g).removeChild(g)}catch{if(p(g),!v(g))throw ti("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Qd=function(g,y,T){try{m(g,y)}catch{try{g.removeAttribute(T)}catch{}}},Os=function(g){Ps(g);let y=b(g);if(y){let H=[];ni(y,W=>{kr(H,W)}),ni(H,W=>{try{p(W)}catch{}})}let T=N(g);if(T)for(let H=T.length-1;H>=0;--H){let W=T[H],G=W&&W.name;typeof G=="string"&&Qd(g,W,G)}},Zn=function(g,y,T){if(!T)try{T=y.getAttributeNode(g)}catch{T=null}kr(e.removed,{attribute:T||null,from:y});try{T?m(y,T):y.removeAttribute(g)}catch{try{y.removeAttribute(g)}catch{}}if(g==="is")if(Ei||Es)try{Rn(y)}catch{}else try{y.setAttribute(g,"")}catch{}},M0=function(g){let y=N(g);if(y)for(let T=y.length-1;T>=0;--T){let H=y[T],W=H&&H.name;typeof W!="string"||xe[Le(W)]||Qd(g,H,W)}},Ps=function(g){let y=[g];for(;y.length>0;){let T=y.pop();$(T)===gt.element&&M0(T);let W=b(T);if(W)for(let G=W.length-1;G>=0;--G)y.push(W[G])}},eu=function(g,y){return Jn?g==="patchsrc"?!0:g==="for"&&y!=="label"&&y!=="output":!1},E0=function(g){if(!Jn)return;let y=[g];for(;y.length>0;){let T=y.pop(),H=$(T);if(H===gt.processingInstruction||H===gt.comment&&Je(oh,T.data)){try{p(T)}catch{}continue}if(H===gt.element){let G=T,pe=Le(F(T));try{G.hasAttribute&&G.hasAttribute("patchsrc")&&G.removeAttribute("patchsrc"),G.hasAttribute&&G.hasAttribute("for")&&eu("for",pe)&&G.removeAttribute("for")}catch{}}let W=b(T);if(W)for(let G=W.length-1;G>=0;--G)y.push(W[G])}},tu=function(g){let y=null,T=null;if(yl)g="<remove></remove>"+g;else{let G=Ju(g,/^[\r\n\t ]+/);T=G&&G[0]}ur==="application/xhtml+xml"&&Li===Jt&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");let H=R?q(g):g;if(Li===Jt)try{y=new d().parseFromString(H,ur)}catch{}if(!y||!y.documentElement){y=je.createDocument(Li,"template",null);try{y.documentElement.innerHTML=kl?O:H}catch{}}let W=y.body||y.documentElement;return g&&T&&W.insertBefore(t.createTextNode(T),W.childNodes[0]||null),Li===Jt?Xe.call(y,Yn?"html":"body")[0]:Yn?y.documentElement:W},nu=function(g){let y=A?A(g):g.ownerDocument;return ot.call(y||g,g,a.SHOW_ELEMENT|a.SHOW_COMMENT|a.SHOW_TEXT|a.SHOW_PROCESSING_INSTRUCTION|a.SHOW_CDATA_SECTION,null)},Is=function(g){return g=Sr(g,Tn," "),g=Sr(g,Mi," "),g=Sr(g,dr," "),g},Ml=function(g){var y;g.normalize();let T=A?A(g):g.ownerDocument,H=ot.call(T||g,g,a.SHOW_TEXT|a.SHOW_COMMENT|a.SHOW_CDATA_SECTION|a.SHOW_PROCESSING_INSTRUCTION,null),W=H.nextNode();for(;W;)W.data=Is(W.data),W=H.nextNode();let G=(y=g.querySelectorAll)===null||y===void 0?void 0:y.call(g,"template");G&&ni(G,pe=>{Pi(pe.content)&&Ml(pe.content)})},Ns=function(g){let y=C?C(g):null;return typeof y!="string"||Le(y)!=="form"?!1:typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||g.attributes!==N(g)||typeof g.removeAttribute!="function"||typeof g.removeAttributeNode!="function"||typeof g.getAttributeNode!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function"||g.nodeType!==S(g)||g.childNodes!==b(g)},Pi=function(g){if(!S||typeof g!="object"||g===null)return!1;try{return S(g)===gt.documentFragment}catch{return!1}},hr=function(g){if(!S||typeof g!="object"||g===null)return!1;try{return typeof S(g)=="number"}catch{return!1}};function Yt(E,g,y){E.length!==0&&ni(E,T=>{T.call(e,g,y,Oi)})}let R0=function(g,y){return!!(Jn&&g.hasChildNodes()&&!hr(g.firstElementChild)&&Je(sh,g.textContent)&&Je(sh,g.innerHTML)||Jn&&g.namespaceURI===Jt&&sw[y]&&(hr(g.firstElementChild)||typeof g.textContent=="string"&&Je(ow[y],g.textContent))||g.nodeType===gt.processingInstruction||Jn&&g.nodeType===gt.comment&&Je(oh,g.data))},Bs=function(g,y){if(g instanceof RegExp)return Je(g,y);if(g instanceof Function){for(var T=arguments.length,H=new Array(T>2?T-2:0),W=2;W<T;W++)H[W-2]=arguments[W];return!!g(y,...H)}return!1},D0=function(g,y,T){if(!Ie[y]&&lu(y)&&Bs(Z.tagNameCheck,y))return!1;if(xl&&!Di[y]){let H=v(g),W=b(g);if(W&&H){let G=W.length;for(let pe=G-1;pe>=0;--pe){let Ee=g===T?f(W[pe],!0):W[pe];H.insertBefore(Ee,w(g))}}}return Rn(g),!0},iu=function(g,y,T,H){return g.length===0?y:y===T||y===H?bt(y):y},ru=function(g,y){return g===y||v(g)!==null?!1:(vl&&Ps(g),!0)},su=function(g,y){if(Yt(ie.beforeSanitizeElements,g,null),ru(g,y))return!0;if(Ns(g))return Rn(g),!0;let T=Le(F(g));if(ye=iu(ie.uponSanitizeElement,ye,Cs,As),Yt(ie.uponSanitizeElement,g,{tagName:T,allowedTags:ye}),ru(g,y))return!0;if(R0(g,T))return Rn(g),!0;if(Ie[T]||!(We.tagCheck instanceof Function&&We.tagCheck(T))&&!ye[T]){let W=D0(g,T,y);return W===!1&&Yt(ie.afterSanitizeElements,g,null),W}if($(g)===gt.element&&!A0(g)||(T==="noscript"||T==="noembed"||T==="noframes")&&Je(iw,g.innerHTML))return Rn(g),!0;if(En&&g.nodeType===gt.text){let W=Is(g.textContent);g.textContent!==W&&(kr(e.removed,{element:g.cloneNode()}),g.textContent=W)}return Yt(ie.afterSanitizeElements,g,null),!1},ou=function(g,y,T){if(An[y]||eu(y,g)||zd&&(y==="id"||y==="name")&&(T in t||T in k0))return!1;let H=xe[y]||We.attributeCheck instanceof Function&&We.attributeCheck(y,g);return It&&Je(pl,y)||Mn&&Je(ml,y)?!0:H?Kd[y]||Je(bl,Sr(T,ks,""))||(y==="src"||y==="xlink:href"||y==="href")&&g!=="script"&&Yu(T,"data:")===0&&Ud[g]||Ts&&!Je(gl,Sr(T,ks,""))?!0:!T:lu(g)&&Bs(Z.tagNameCheck,g)&&Bs(Z.attributeNameCheck,y,g)||y==="is"&&Z.allowCustomizedBuiltInElements&&Bs(Z.tagNameCheck,T)},L0=le({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),lu=function(g){return!L0[Tr(g)]&&Je(Ss,g)},O0=function(g,y,T,H){if(R&&typeof u=="object"&&typeof u.getAttributeType=="function"&&!T)switch(u.getAttributeType(g,y)){case"TrustedHTML":return q(H);case"TrustedScriptURL":return Me(H)}return H},P0=function(g,y,T,H){try{return T?g.setAttributeNS(T,y,H):g.setAttribute(y,H),Ns(g)?(Rn(g),!1):!0}catch{return Zn(y,g),!1}},au=function(g){Yt(ie.beforeSanitizeAttributes,g,null);let y=g.attributes;if(!y||Ns(g))return;xe=iu(ie.uponSanitizeAttribute,xe,K,Ms);let T={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe,forceKeepAttr:void 0},H=y.length,W=Le(g.nodeName);for(;H--;){let G=y[H],pe=G.name,Ee=G.namespaceURI,lt=G.value,at=Le(pe),Rl=lt,tt=pe==="value"?Rl:Fb(Rl),cu=!1;if(T.attrName=at,T.attrValue=tt,T.keepAttr=!0,T.forceKeepAttr=void 0,Yt(ie.uponSanitizeAttribute,g,T),tt=T.attrValue,Wd&&(at==="id"||at==="name")&&Yu(tt,Vd)!==0&&(Zn(pe,g,G),tt=Vd+tt,cu=!0),Jn&&Je(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,tt)){Zn(pe,g,G);continue}if(at==="attributename"&&Ju(tt,"href")){Zn(pe,g,G);continue}if(!T.forceKeepAttr){if(!T.keepAttr){Zn(pe,g,G);continue}if(!Fd&&Je(rw,tt)){Zn(pe,g,G);continue}if(En&&(tt=Is(tt)),!ou(W,at,tt)){Zn(pe,g,G);continue}tt=O0(W,at,Ee,tt),tt!==Rl&&P0(g,pe,Ee,tt)&&cu&&Xu(e.removed)}}Yt(ie.afterSanitizeAttributes,g,null)},_s=function(g){let y=null,T=nu(g);for(Yt(ie.beforeSanitizeShadowDOM,g,null);y=T.nextNode();)if(Yt(ie.uponSanitizeShadowNode,y,null),su(y,g),au(y),Pi(y.content)&&_s(y.content),$(y)===gt.element){let H=k(y);Pi(H)&&(El(H),_s(H))}Yt(ie.afterSanitizeShadowDOM,g,null)},El=function(g){let y=[{node:g,shadow:null}];for(;y.length>0;){let T=y.pop();if(T.shadow){_s(T.shadow);continue}let H=T.node,G=$(H)===gt.element,pe=b(H);if(pe)for(let Ee=pe.length-1;Ee>=0;--Ee)y.push({node:pe[Ee],shadow:null});if(G){let Ee=C?C(H):null;if(typeof Ee=="string"&&Le(Ee)==="template"){let lt=H.content;Pi(lt)&&y.push({node:lt,shadow:null})}}if(G){let Ee=k(H);Pi(Ee)&&y.push({node:null,shadow:Ee},{node:Ee,shadow:null})}}};return e.sanitize=function(E){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=null,T=null,H=null,W=null;if(kl=!E,kl&&(E="<!-->"),typeof E!="string"&&!hr(E)&&(E=Ub(E),typeof E!="string"))throw ti("dirty is not a string, aborting");if(!e.isSupported)return E;wl?(ye=As,xe=Ms):Al(g),(ie.uponSanitizeElement.length>0||ie.uponSanitizeAttribute.length>0)&&(ye=bt(ye)),ie.uponSanitizeAttribute.length>0&&(xe=bt(xe)),e.removed=[];let G=vl&&typeof E!="string"&&hr(E);if(G){E0(E);let lt=F(E);if(typeof lt=="string"){let at=Le(lt);if(!ye[at]||Ie[at])throw Os(E),ti("root node is forbidden and cannot be sanitized in-place")}if(Ns(E))throw Os(E),ti("root node is clobbered and cannot be sanitized in-place");try{El(E)}catch(at){throw Os(E),at}}else if(hr(E))y=tu("<!---->"),T=y.ownerDocument.importNode(E,!0),T.nodeType===gt.element&&T.nodeName==="BODY"||T.nodeName==="HTML"?y=T:y.appendChild(T),El(y);else{if(!Ei&&!En&&!Yn&&E.indexOf("<")===-1)return R&&Rs?q(E):E;if(y=tu(E),!y)return Ei?null:Rs?O:""}y&&yl&&Rn(y.firstChild);let pe=G?E:y;try{let lt=nu(pe);for(;H=lt.nextNode();)su(H,pe),au(H),Pi(H.content)&&_s(H.content)}catch(lt){throw G&&(Os(E),ni(e.removed,at=>{at.element&&Ps(at.element)})),lt}if(G)return ni(e.removed,lt=>{lt.element&&Ps(lt.element)}),En&&Ml(E),E;if(Ei){if(En&&Ml(y),Es)for(W=Ke.call(y.ownerDocument);y.firstChild;)W.appendChild(y.firstChild);else W=y;return(xe.shadowroot||xe.shadowrootmode)&&(W=kt.call(i,W,!0)),W}let Ee=Yn?y.outerHTML:y.innerHTML;return Yn&&ye["!doctype"]&&y.ownerDocument&&y.ownerDocument.doctype&&y.ownerDocument.doctype.name&&Je(tw,y.ownerDocument.doctype.name)&&(Ee="<!DOCTYPE "+y.ownerDocument.doctype.name+`>
717
- `+Ee),En&&(Ee=Is(Ee)),R&&Rs?q(Ee):Ee},e.setConfig=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Al(E),wl=!0,As=ye,Ms=xe},e.clearConfig=function(){Oi=null,wl=!1,As=null,Ms=null,R=M,O=""},e.isValidAttribute=function(E,g,y){Oi||Al({});let T=Le(E),H=Le(g);return ou(T,H,y)},e.addHook=function(E,g){typeof g=="function"&&dt(ie,E)&&kr(ie[E],g)},e.removeHook=function(E,g){if(dt(ie,E)){if(g!==void 0){let y=_b(ie[E],g);return y===-1?void 0:Hb(ie[E],y,1)[0]}return Xu(ie[E])}},e.removeHooks=function(E){dt(ie,E)&&(ie[E]=[])},e.removeAllHooks=function(){ie=lh()},e}var Ar=uh();function Js(n,e,t,i){let r=t?Array.from(t):[];if(!n||!e||r.length===0)return!1;let s=Y.conversation;if(!s)return i?.("error",x("attach.channelUnavailable")),!1;try{let o=s.createDrafts(n,r);if(o.length===0)return!1;let l=e.addAttachments(o.map(a=>a.id));return l||s.releaseDraftAttachments(o),l}catch(o){return i?.("error",o instanceof Error?o.message:String(o)),!1}}function hh(n){let e=null,t=Y.conversation?.input.shell(n);if(typeof t?.bindFilePicker=="function")return t.bindFilePicker({available:()=>!0,open:()=>{e?.remove();let i=document.createElement("input");e=i,i.type="file",i.multiple=!0,i.style.display="none",i.addEventListener("change",()=>{i.remove(),e===i&&(e=null),Js(n,Y.conversation?.input.shell(n)??void 0,i.files)}),document.body.appendChild(i),i.click()}})}function fh(n){return n!==null&&Array.from(n.types).includes("Files")}var U=require("react/jsx-runtime");function Pn(n,e,t,i="currentColor"){return(0,U.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e??16,height:e??16,viewBox:"0 0 24 24",fill:"none",stroke:i,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,"aria-hidden":"true",children:n})}var la=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("path",{d:"M6.8 5.8 2.9 11l4 4.4"}),(0,U.jsx)("path",{d:"M17.2 5.8 21.1 11l-3.9 4.4"}),(0,U.jsx)("path",{d:"M10.7 9.5 12.5 3.9"}),(0,U.jsx)("path",{d:"M16.6 9.4 6.9 14l2.9 1.3.1 2.5q.1.8.7.3l1-2.3 2.2 1.4Z"}),(0,U.jsx)("path",{d:"M9.8 15.3 16.6 9.4"})]});function ph({size:n,className:e}){return Pn(la,n,e)}function aa({size:n,className:e}){return Pn(la,n,e,"#3964FE")}function mh({size:n,className:e}){return Pn((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}),(0,U.jsx)("path",{d:"m15 5 4 4"})]}),n,e)}function gh({size:n,className:e}){return Pn((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),(0,U.jsx)("circle",{cx:"12",cy:"12",r:"3"})]}),n,e)}function bh({size:n,className:e}){return Pn((0,U.jsx)("path",{d:"M18 6 6 18M6 6l12 12"}),n,e)}function wh({size:n,className:e}){return Pn((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),(0,U.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"})]}),n,e)}function yh({size:n,className:e}){return Pn((0,U.jsx)("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"}),n,e)}function xh({size:n,className:e}){return Pn((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,U.jsx)("path",{d:"m21 21-4.3-4.3"})]}),n,e)}function vh({size:n}){return(0,U.jsx)("svg",{width:n??14,height:n??14,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:(0,U.jsx)("path",{d:"M8.64453 1.5V7.34961H14.5V8.65039H8.64453V14.5H7.34473V8.65039H1.5V7.34961H7.34473V1.5H8.64453Z",fill:"currentColor"})})}var kh="M8.20554 0.899994L14.7901 3.36857V7.01026C14.7901 12 11.0466 14.2103 8.20554 15.3C5.36446 14.2103 1.62012 12 1.62012 7.01026V3.36857L8.20554 0.899994Z",cw="M12.1654 5.7552L8.9447 9.41475C8.73044 9.65816 8.53628 9.8804 8.35774 10.0423C8.1713 10.2114 7.94235 10.3717 7.64016 10.4254C7.48207 10.4535 7.32 10.4552 7.16151 10.4294C6.85843 10.3801 6.62728 10.2223 6.43836 10.0559C6.25752 9.89653 6.06037 9.67732 5.84264 9.43705L4.72925 8.20897L5.63557 7.38707L6.74897 8.61594C6.98603 8.87755 7.12974 9.03533 7.24673 9.13839C7.31033 9.19443 7.34485 9.21476 7.35823 9.22122C7.38068 9.22484 7.40352 9.22515 7.42593 9.22122C7.40522 9.22502 7.42893 9.23294 7.53583 9.136C7.65132 9.03126 7.79316 8.87139 8.02643 8.60638L11.2479 4.94763L12.1654 5.7552Z";function Sh({size:n}){return(0,U.jsxs)("svg",{width:n??16,height:n??16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,U.jsx)("path",{d:kh,stroke:"currentColor",strokeWidth:"1.31831",strokeLinejoin:"round"}),(0,U.jsx)("path",{d:cw,fill:"currentColor"})]})}function Ch({size:n}){return(0,U.jsxs)("svg",{width:n??16,height:n??16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,U.jsx)("path",{d:"M8.08887 0.251709C8.20479 0.23085 8.32486 0.241168 8.43652 0.282959L15.0215 2.75171C15.2787 2.84819 15.4492 3.09414 15.4492 3.3689V7.0105C15.4492 7.10986 15.4441 7.2081 15.4414 7.30542C15.0285 7.07175 14.5905 6.87695 14.1309 6.73022V3.82495L8.20508 1.60327L2.2793 3.82495V7.0105C2.27936 9.7171 3.4745 11.5379 5.02734 12.7947C5.01025 12.9942 5 13.1962 5 13.4001C5.00001 13.7617 5.02722 14.1169 5.08008 14.4636C2.91555 13.0393 0.961014 10.752 0.960938 7.0105V3.3689C0.960938 3.09417 1.13146 2.84821 1.38867 2.75171L7.97461 0.282959L8.08887 0.251709Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M11.3525 5.64688V6.85688H5V5.64688H11.3525Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M9.5824 8.29376V9.50376H5V8.29376H9.5824Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M14.6647 15.6852H10.0338C10.3878 15.3751 10.7567 15.0517 11.0772 14.7706C11.2531 14.6164 11.4144 14.4746 11.5511 14.3547H14.6647V15.6852Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M8.14852 14.1308L7.33925 15.4976C7.22458 15.6912 7.42245 15.9194 7.63037 15.8333L9.09785 15.2254L15.0399 10.0719L14.0905 8.97733L8.14852 14.1308Z",fill:"currentColor"})]})}function Th({size:n}){return(0,U.jsxs)("svg",{width:n??16,height:n??16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,U.jsx)("path",{d:kh,stroke:"currentColor",strokeWidth:"1.31831",strokeLinejoin:"round"}),(0,U.jsx)("path",{d:"M9.10094 4.5V8.75939H7.59888V4.5H9.10094Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M9.10094 9.8114V11.5H7.59888V9.8114H9.10094Z",fill:"currentColor"})]})}function Ah({size:n}){return(0,U.jsxs)("svg",{width:n??18,height:n??18,viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:[(0,U.jsx)("path",{d:"M6.3002 3.32843L7.69986 3.32843L7.69986 7.79657H6.3002L6.3002 3.32843Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M6.3002 9.01935H7.69986V10.6711H6.3002V9.01935Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M12.6328 6.99976C12.6328 3.88874 10.111 1.36694 7 1.36694C3.88899 1.36695 1.3672 3.88875 1.36719 6.99976C1.36719 10.1108 3.88899 12.6326 7 12.6326C10.111 12.6326 12.6328 10.1108 12.6328 6.99976ZM13.8582 6.99976C13.8582 10.7873 10.7876 13.8579 7 13.8579C3.21244 13.8579 0.141846 10.7873 0.141846 6.99976C0.141857 3.2122 3.21245 0.141612 7 0.141602C10.7876 0.141602 13.8581 3.21219 13.8582 6.99976Z",fill:"currentColor"})]})}function Mh({size:n}){return(0,U.jsx)("svg",{width:n??16,height:n??16,viewBox:"0 0 16 16","aria-hidden":"true",children:(0,U.jsx)("path",{d:"M8.3125 0.980183C8.66767 1.0531 8.97902 1.20418 9.2627 1.43233C9.48724 1.61297 9.73029 1.85793 9.97949 2.10714L14.707 6.83468L13.293 8.24874L9 3.95577V15.0417H7V3.95577L2.70703 8.24874L1.29297 6.83468L6.02051 2.10714C6.26971 1.85793 6.51277 1.61297 6.7373 1.43233C6.97662 1.23986 7.28445 1.04402 7.6875 0.980183C7.8973 0.947006 8.1031 0.95516 8.3125 0.980183Z",fill:"currentColor"})})}function Eh({size:n}){return(0,U.jsx)("svg",{width:n??16,height:n??16,viewBox:"0 0 16 16","aria-hidden":"true",children:(0,U.jsx)("rect",{x:"3",y:"3",width:"10",height:"10",rx:"3",fill:"currentColor"})})}function en({size:n}){return(0,U.jsx)("svg",{width:n??14,height:n??14,viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:(0,U.jsx)("path",{d:"M3.5 5.75L7 9.25L10.5 5.75",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}function Rh({size:n=16,className:e}){return(0,U.jsx)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:e,"aria-hidden":"true",children:la})}var Pt=require("react");var da=[],Ph=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<n.length;e++)(e%2?Ph:da).push(t=t+n[e])})();function dw(n){if(n<768)return!1;for(let e=0,t=da.length;;){let i=e+t>>1;if(n<da[i])t=i;else if(n>=Ph[i])e=i+1;else return!0;if(e==t)return!1}}function Dh(n){return n>=127462&&n<=127487}var Lh=8205;function Ih(n,e,t=!0,i=!0){return(t?Nh:uw)(n,e,i)}function Nh(n,e,t){if(e==n.length)return e;e&&Bh(n.charCodeAt(e))&&_h(n.charCodeAt(e-1))&&e--;let i=ca(n,e);for(e+=Oh(i);e<n.length;){let r=ca(n,e);if(i==Lh||r==Lh||t&&dw(r))e+=Oh(r),i=r;else if(Dh(r)){let s=0,o=e-2;for(;o>=0&&Dh(ca(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function uw(n,e,t){for(;e>1;){let i=Nh(n,e-2,t);if(i<e)return i;e--}return 0}function ca(n,e){let t=n.charCodeAt(e);if(!_h(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Bh(i)?(t-55296<<10)+(i-56320)+65536:t}function Bh(n){return n>=56320&&n<57344}function _h(n){return n>=55296&&n<56320}function Oh(n){return n<65536?1:2}var ne=class n{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Wi(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),Hi.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Wi(this,e,t);let i=[];return this.decompose(e,t,i,0),Hi.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new oi(this),s=new oi(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new oi(this,e)}iterRange(e,t=this.length){return new to(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new no(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?n.empty:e.length<=32?new wt(e):Hi.from(wt.split(e,[]))}},wt=class n extends ne{constructor(e,t=hw(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new ha(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new n(Hh(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=eo(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new n(l,o.length+s.length));else{let a=l.length>>1;i.push(new n(l.slice(0,a)),new n(l.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof n))return super.replace(e,t,i);[e,t]=Wi(this,e,t);let r=eo(this.text,eo(i.text,Hh(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new n(r,s):Hi.from(n.split(r,[]),s)}sliceString(e,t=this.length,i=`
715
+ Please report this to https://github.com/markedjs/marked.`,n){let i="<p>An error occurred:</p><pre>"+Qt(t.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(t);throw t}}},Qn=new Zl;function ae(n,e){return Qn.parse(n,e)}ae.options=ae.setOptions=function(n){return Qn.setOptions(n),ae.defaults=Qn.defaults,Bu(ae.defaults),ae};ae.getDefaults=$l;ae.defaults=ei;ae.use=function(...n){return Qn.use(...n),ae.defaults=Qn.defaults,Bu(ae.defaults),ae};ae.walkTokens=function(n,e){return Qn.walkTokens(n,e)};ae.parseInline=Qn.parseInline;ae.Parser=gn;ae.parser=gn.parse;ae.Renderer=Ks;ae.TextRenderer=Yl;ae.Lexer=mn;ae.lexer=mn.lex;ae.Tokenizer=js;ae.Hooks=$s;ae.parse=ae;var zk=ae.options,Wk=ae.setOptions,Vk=ae.use,$k=ae.walkTokens,Uk=ae.parseInline;var jk=gn.parse,Kk=mn.lex;var Mr={};du(Mr,{default:()=>Ar});function Gu(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=Array(e);t<e;t++)i[t]=n[t];return i}function Db(n){if(Array.isArray(n))return n}function Ob(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var i,r,s,o,l=[],a=!0,c=!1;try{if(s=(t=t.call(n)).next,e!==0)for(;!(a=(i=s.call(t)).done)&&(l.push(i.value),l.length!==e);a=!0);}catch(d){c=!0,r=d}finally{try{if(!a&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(c)throw r}}return l}}function Pb(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
716
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ib(n,e){return Db(n)||Ob(n,e)||Nb(n,e)||Pb()}function Nb(n,e){if(n){if(typeof n=="string")return Gu(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Gu(n,e):void 0}}var ah=Object.entries,qu=Object.setPrototypeOf,Bb=Object.isFrozen,_b=Object.getPrototypeOf,Hb=Object.getOwnPropertyDescriptor,ze=Object.freeze,Ve=Object.seal,Ni=Object.create,ch=typeof Reflect<"u"&&Reflect,sa=ch.apply,oa=ch.construct;ze||(ze=function(e){return e});Ve||(Ve=function(e){return e});sa||(sa=function(e,t){for(var i=arguments.length,r=new Array(i>2?i-2:0),s=2;s<i;s++)r[s-2]=arguments[s];return e.apply(t,r)});oa||(oa=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return new e(...i)});var ni=Ne(Array.prototype.forEach),Fb=Ne(Array.prototype.lastIndexOf),Xu=Ne(Array.prototype.pop),kr=Ne(Array.prototype.push),zb=Ne(Array.prototype.splice),Bi=Array.isArray,Tr=Ne(String.prototype.toLowerCase),Ql=Ne(String.prototype.toString),Ju=Ne(String.prototype.match),Sr=Ne(String.prototype.replace),Yu=Ne(String.prototype.indexOf),Wb=Ne(String.prototype.trim),Vb=Ne(Number.prototype.toString),$b=Ne(Boolean.prototype.toString),Zu=typeof BigInt>"u"?null:Ne(BigInt.prototype.toString),Qu=typeof Symbol>"u"?null:Ne(Symbol.prototype.toString),dt=Ne(Object.prototype.hasOwnProperty),Cr=Ne(Object.prototype.toString),Je=Ne(RegExp.prototype.test),ti=Ub(TypeError);function Ne(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return sa(n,e,i)}}function Ub(n){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return oa(n,t)}}function le(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tr;if(qu&&qu(n,null),!Bi(e))return n;let i=e.length;for(;i--;){let r=e[i];if(typeof r=="string"){let s=t(r);s!==r&&(Bb(e)||(e[i]=s),r=s)}n[r]=!0}return n}function jb(n){for(let e=0;e<n.length;e++)dt(n,e)||(n[e]=null);return n}function bt(n){let e=Ni(null);for(let i of ah(n)){var t=Ib(i,2);let r=t[0],s=t[1];dt(n,r)&&(Bi(s)?e[r]=jb(s):s&&typeof s=="object"&&s.constructor===Object?e[r]=bt(s):e[r]=s)}return e}function Kb(n){switch(typeof n){case"string":return n;case"number":return Vb(n);case"boolean":return $b(n);case"bigint":return Zu?Zu(n):"0";case"symbol":return Qu?Qu(n):"Symbol()";case"undefined":return Cr(n);case"function":case"object":{if(n===null)return Cr(n);let e=n,t=Ct(e,"toString");if(typeof t=="function"){let i=t(e);return typeof i=="string"?i:Cr(i)}return Cr(n)}default:return Cr(n)}}function Ct(n,e){for(;n!==null;){let i=Hb(n,e);if(i){if(i.get)return Ne(i.get);if(typeof i.value=="function")return Ne(i.value)}n=_b(n)}function t(){return null}return t}function Gb(n){try{return Je(n,""),!0}catch{return!1}}var eh=ze(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ea=ze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ta=ze(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),qb=ze(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),na=ze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Xb=ze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),th=ze(["#text"]),nh=ze(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ia=ze(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ih=ze(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Xs=ze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Jb=Ve(/{{[\w\W]*|^[\w\W]*}}/g),Yb=Ve(/<%[\w\W]*|^[\w\W]*%>/g),Zb=Ve(/\${[\w\W]*/g),Qb=Ve(/^data-[\-\w.\u00B7-\uFFFF]+$/),ew=Ve(/^aria-[\-\w]+$/),rh=Ve(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),tw=Ve(/^(?:\w+script|data):/i),nw=Ve(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),iw=Ve(/^html$/i),rw=Ve(/^[a-z][.\w]*(-[.\w]+)+$/i),sh=Ve(/<[/\w!]/g),oh=Ve(/<[/\w]/g),sw=Ve(/<\/no(script|embed|frames)/i),ow=Ve(/\/>/i),gt={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},dh=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],lw=ze(le({},dh)),aw=(function(){let n={};return ni(dh,e=>{n[e]=Ve(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),ze(n)})(),cw=function(){return typeof window>"u"?null:window},dw=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null,r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(i=t.getAttribute(r));let s="dompurify"+(i?"#"+i:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},lh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Pn=function(e,t,i,r){return dt(e,t)&&Bi(e[t])?le(r.base?bt(r.base):{},e[t],r.transform):i},ra=function(e,t,i){let r=dt(e,t)?e[t]:void 0;return r&&typeof r=="object"?bt(r):i()};function uh(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:cw(),e=E=>uh(E);if(e.version="3.4.15",e.removed=[],!n||!n.document||n.document.nodeType!==gt.document||!n.Element)return e.isSupported=!1,e;let t=n.document,i=t,r=i.currentScript;n.DocumentFragment;let s=n.HTMLTemplateElement,o=n.Node,l=n.Element,a=n.NodeFilter,c=n.NamedNodeMap;c===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;let d=n.DOMParser,u=n.trustedTypes,h=l.prototype,f=Ct(h,"cloneNode"),p=Ct(h,"remove"),m=Ct(h,"removeAttributeNode"),w=Ct(h,"nextSibling"),b=Ct(h,"childNodes"),k=Ct(h,"parentNode"),C=Ct(h,"shadowRoot"),P=Ct(h,"attributes"),S=o&&o.prototype?Ct(o.prototype,"nodeType"):null,x=o&&o.prototype?Ct(o.prototype,"nodeName"):null,T=o&&o.prototype?Ct(o.prototype,"ownerDocument"):null,W=function(g){return S?S(g):g.nodeType},H=function(g){return x?x(g):g.nodeName};if(typeof s=="function"){let E=t.createElement("template");E.content&&E.content.ownerDocument&&(t=E.content.ownerDocument)}let z,D="",R,F=!1,M=0,K=function(){if(M>0)throw ti('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},X=function(g){K(),M++;try{return z.createHTML(g)}finally{M--}},ye=function(g){K(),M++;try{return z.createScriptURL(g)}finally{M--}},et=function(){return F||(R=dw(u,r),F=!0),R},Ce=t,je=Ce.implementation,ot=Ce.createNodeIterator,Ke=Ce.createDocumentFragment,Xe=Ce.getElementsByTagName,kt=i.importNode,ie=lh();e.isSupported=typeof ah=="function"&&typeof k=="function"&&je&&je.createHTMLDocument!==void 0;let An=Jb,Mi=Yb,dr=Zb,pl=Qb,ml=ew,gl=tw,ks=nw,Ss=rw,bl=rh,xe=null,Cs=le({},[...eh,...ea,...ta,...na,...th]),ve=null,G=le({},[...nh,...ia,...ih,...Xs]),Z=Object.seal(Ni(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ie=null,Mn=null,We=Object.seal(Ni(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),En=!0,Bt=!0,Ts=!1,Fd=!0,Rn=!1,Jn=!0,Yn=!1,wl=!1,As=null,Ms=null,yl=!1,Ei=!1,Es=!1,Rs=!1,zd=!0,Wd=!1,Vd="user-content-",xl=!0,vl=!1,Ri={},Li=null,$d=le({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),Ud=null,jd=le({},["audio","video","img","source","image","track"]),Kd=null,Gd=le({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ls="http://www.w3.org/1998/Math/MathML",Ds="http://www.w3.org/2000/svg",Jt="http://www.w3.org/1999/xhtml",Di=Jt,kl=!1,Sl=null,x0=le({},[Ls,Ds,Jt],Ql),qd=ze(["mi","mo","mn","ms","mtext"]),Cl=le({},qd),Xd=ze(["annotation-xml"]),Tl=le({},Xd),v0=le({},["title","style","font","a","script"]),ur=null,k0=["application/xhtml+xml","text/html"],S0="text/html",De=null,Oi=null,C0=t.createElement("form"),Jd=function(g){return g instanceof RegExp||g instanceof Function},Al=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Oi&&Oi===g)return;(!g||typeof g!="object")&&(g={}),g=bt(g),ur=k0.indexOf(g.PARSER_MEDIA_TYPE)===-1?S0:g.PARSER_MEDIA_TYPE,De=ur==="application/xhtml+xml"?Ql:Tr,xe=Pn(g,"ALLOWED_TAGS",Cs,{transform:De}),ve=Pn(g,"ALLOWED_ATTR",G,{transform:De}),Sl=Pn(g,"ALLOWED_NAMESPACES",x0,{transform:Ql}),Kd=Pn(g,"ADD_URI_SAFE_ATTR",Gd,{transform:De,base:Gd}),Ud=Pn(g,"ADD_DATA_URI_TAGS",jd,{transform:De,base:jd}),Li=Pn(g,"FORBID_CONTENTS",$d,{transform:De}),Ie=Pn(g,"FORBID_TAGS",bt({}),{transform:De}),Mn=Pn(g,"FORBID_ATTR",bt({}),{transform:De}),Ri=dt(g,"USE_PROFILES")?g.USE_PROFILES&&typeof g.USE_PROFILES=="object"?bt(g.USE_PROFILES):g.USE_PROFILES:!1,En=g.ALLOW_ARIA_ATTR!==!1,Bt=g.ALLOW_DATA_ATTR!==!1,Ts=g.ALLOW_UNKNOWN_PROTOCOLS||!1,Fd=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Rn=g.SAFE_FOR_TEMPLATES||!1,Jn=g.SAFE_FOR_XML!==!1,Yn=g.WHOLE_DOCUMENT||!1,Ei=g.RETURN_DOM||!1,Es=g.RETURN_DOM_FRAGMENT||!1,Rs=g.RETURN_TRUSTED_TYPE||!1,yl=g.FORCE_BODY||!1,zd=g.SANITIZE_DOM!==!1,Wd=g.SANITIZE_NAMED_PROPS||!1,xl=g.KEEP_CONTENT!==!1,vl=g.IN_PLACE||!1,bl=Gb(g.ALLOWED_URI_REGEXP)?g.ALLOWED_URI_REGEXP:rh,Di=typeof g.NAMESPACE=="string"?g.NAMESPACE:Jt,Cl=ra(g,"MATHML_TEXT_INTEGRATION_POINTS",()=>le({},qd)),Tl=ra(g,"HTML_INTEGRATION_POINTS",()=>le({},Xd));let y=ra(g,"CUSTOM_ELEMENT_HANDLING",()=>Ni(null));if(Z=Ni(null),dt(y,"tagNameCheck")&&Jd(y.tagNameCheck)&&(Z.tagNameCheck=y.tagNameCheck),dt(y,"attributeNameCheck")&&Jd(y.attributeNameCheck)&&(Z.attributeNameCheck=y.attributeNameCheck),dt(y,"allowCustomizedBuiltInElements")&&typeof y.allowCustomizedBuiltInElements=="boolean"&&(Z.allowCustomizedBuiltInElements=y.allowCustomizedBuiltInElements),Ve(Z),Rn&&(Bt=!1),Es&&(Ei=!0),Ri&&(xe=le({},th),ve=Ni(null),Ri.html===!0&&(le(xe,eh),le(ve,nh)),Ri.svg===!0&&(le(xe,ea),le(ve,ia),le(ve,Xs)),Ri.svgFilters===!0&&(le(xe,ta),le(ve,ia),le(ve,Xs)),Ri.mathMl===!0&&(le(xe,na),le(ve,ih),le(ve,Xs))),We.tagCheck=null,We.attributeCheck=null,dt(g,"ADD_TAGS")&&(typeof g.ADD_TAGS=="function"?We.tagCheck=g.ADD_TAGS:Bi(g.ADD_TAGS)&&(xe===Cs&&(xe=bt(xe)),le(xe,g.ADD_TAGS,De))),dt(g,"ADD_ATTR")&&(typeof g.ADD_ATTR=="function"?We.attributeCheck=g.ADD_ATTR:Bi(g.ADD_ATTR)&&(ve===G&&(ve=bt(ve)),le(ve,g.ADD_ATTR,De))),dt(g,"ADD_FORBID_CONTENTS")&&Bi(g.ADD_FORBID_CONTENTS)&&(Li===$d&&(Li=bt(Li)),le(Li,g.ADD_FORBID_CONTENTS,De)),xl&&(xe["#text"]=!0),Yn&&le(xe,["html","head","body"]),xe.table&&(le(xe,["tbody"]),delete Ie.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw ti('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ti('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let A=z;z=g.TRUSTED_TYPES_POLICY;try{D=X("")}catch(_){throw z=A,_}}else g.TRUSTED_TYPES_POLICY===null?(z=void 0,D=""):(z===void 0&&(z=et()),z&&typeof D=="string"&&(D=X("")));ze&&ze(g),Oi=g},Yd=le({},[...ea,...ta,...qb]),Zd=le({},[...na,...Xb]),T0=function(g,y,A){return y.namespaceURI===Jt?g==="svg":y.namespaceURI===Ls?g==="svg"&&(A==="annotation-xml"||Cl[A]):!!Yd[g]},A0=function(g,y,A){return y.namespaceURI===Jt?g==="math":y.namespaceURI===Ds?g==="math"&&Tl[A]:!!Zd[g]},M0=function(g,y,A){return y.namespaceURI===Ds&&!Tl[A]||y.namespaceURI===Ls&&!Cl[A]?!1:!Zd[g]&&(v0[g]||!Yd[g])},E0=function(g){let y=k(g);(!y||!y.tagName)&&(y={namespaceURI:Di,tagName:"template"});let A=Tr(g.tagName),_=Tr(y.tagName);return Sl[g.namespaceURI]?g.namespaceURI===Ds?T0(A,y,_):g.namespaceURI===Ls?A0(A,y,_):g.namespaceURI===Jt?M0(A,y,_):!!(ur==="application/xhtml+xml"&&Sl[g.namespaceURI]):!1},Ln=function(g){kr(e.removed,{element:g});try{k(g).removeChild(g)}catch{if(p(g),!k(g))throw ti("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Qd=function(g,y,A){try{m(g,y)}catch{try{g.removeAttribute(A)}catch{}}},Os=function(g){Ps(g);let y=b(g);if(y){let _=[];ni(y,V=>{kr(_,V)}),ni(_,V=>{try{p(V)}catch{}})}let A=P(g);if(A)for(let _=A.length-1;_>=0;--_){let V=A[_],q=V&&V.name;typeof q=="string"&&Qd(g,V,q)}},Zn=function(g,y,A){if(!A)try{A=y.getAttributeNode(g)}catch{A=null}kr(e.removed,{attribute:A||null,from:y});try{A?m(y,A):y.removeAttribute(g)}catch{try{y.removeAttribute(g)}catch{}}if(g==="is")if(Ei||Es)try{Ln(y)}catch{}else try{y.setAttribute(g,"")}catch{}},R0=function(g){let y=P(g);if(y)for(let A=y.length-1;A>=0;--A){let _=y[A],V=_&&_.name;typeof V!="string"||ve[De(V)]||Qd(g,_,V)}},Ps=function(g){let y=[g];for(;y.length>0;){let A=y.pop();W(A)===gt.element&&R0(A);let V=b(A);if(V)for(let q=V.length-1;q>=0;--q)y.push(V[q])}},eu=function(g,y){return Jn?g==="patchsrc"?!0:g==="for"&&y!=="label"&&y!=="output":!1},L0=function(g){if(!Jn)return;let y=[g];for(;y.length>0;){let A=y.pop(),_=W(A);if(_===gt.processingInstruction||_===gt.comment&&Je(oh,A.data)){try{p(A)}catch{}continue}if(_===gt.element){let q=A,pe=De(H(A));try{q.hasAttribute&&q.hasAttribute("patchsrc")&&q.removeAttribute("patchsrc"),q.hasAttribute&&q.hasAttribute("for")&&eu("for",pe)&&q.removeAttribute("for")}catch{}}let V=b(A);if(V)for(let q=V.length-1;q>=0;--q)y.push(V[q])}},tu=function(g){let y=null,A=null;if(yl)g="<remove></remove>"+g;else{let q=Ju(g,/^[\r\n\t ]+/);A=q&&q[0]}ur==="application/xhtml+xml"&&Di===Jt&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");let _=z?X(g):g;if(Di===Jt)try{y=new d().parseFromString(_,ur)}catch{}if(!y||!y.documentElement){y=je.createDocument(Di,"template",null);try{y.documentElement.innerHTML=kl?D:_}catch{}}let V=y.body||y.documentElement;return g&&A&&V.insertBefore(t.createTextNode(A),V.childNodes[0]||null),Di===Jt?Xe.call(y,Yn?"html":"body")[0]:Yn?y.documentElement:V},nu=function(g){let y=T?T(g):g.ownerDocument;return ot.call(y||g,g,a.SHOW_ELEMENT|a.SHOW_COMMENT|a.SHOW_TEXT|a.SHOW_PROCESSING_INSTRUCTION|a.SHOW_CDATA_SECTION,null)},Is=function(g){return g=Sr(g,An," "),g=Sr(g,Mi," "),g=Sr(g,dr," "),g},Ml=function(g){var y;g.normalize();let A=T?T(g):g.ownerDocument,_=ot.call(A||g,g,a.SHOW_TEXT|a.SHOW_COMMENT|a.SHOW_CDATA_SECTION|a.SHOW_PROCESSING_INSTRUCTION,null),V=_.nextNode();for(;V;)V.data=Is(V.data),V=_.nextNode();let q=(y=g.querySelectorAll)===null||y===void 0?void 0:y.call(g,"template");q&&ni(q,pe=>{Pi(pe.content)&&Ml(pe.content)})},Ns=function(g){let y=x?x(g):null;return typeof y!="string"||De(y)!=="form"?!1:typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||g.attributes!==P(g)||typeof g.removeAttribute!="function"||typeof g.removeAttributeNode!="function"||typeof g.getAttributeNode!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function"||g.nodeType!==S(g)||g.childNodes!==b(g)},Pi=function(g){if(!S||typeof g!="object"||g===null)return!1;try{return S(g)===gt.documentFragment}catch{return!1}},hr=function(g){if(!S||typeof g!="object"||g===null)return!1;try{return typeof S(g)=="number"}catch{return!1}};function Yt(E,g,y){E.length!==0&&ni(E,A=>{A.call(e,g,y,Oi)})}let D0=function(g,y){return!!(Jn&&g.hasChildNodes()&&!hr(g.firstElementChild)&&Je(sh,g.textContent)&&Je(sh,g.innerHTML)||Jn&&g.namespaceURI===Jt&&lw[y]&&(hr(g.firstElementChild)||typeof g.textContent=="string"&&Je(aw[y],g.textContent))||g.nodeType===gt.processingInstruction||Jn&&g.nodeType===gt.comment&&Je(oh,g.data))},Bs=function(g,y){if(g instanceof RegExp)return Je(g,y);if(g instanceof Function){for(var A=arguments.length,_=new Array(A>2?A-2:0),V=2;V<A;V++)_[V-2]=arguments[V];return!!g(y,..._)}return!1},O0=function(g,y,A){if(!Ie[y]&&lu(y)&&Bs(Z.tagNameCheck,y))return!1;if(xl&&!Li[y]){let _=k(g),V=b(g);if(V&&_){let q=V.length;for(let pe=q-1;pe>=0;--pe){let Ee=g===A?f(V[pe],!0):V[pe];_.insertBefore(Ee,w(g))}}}return Ln(g),!0},iu=function(g,y,A,_){return g.length===0?y:y===A||y===_?bt(y):y},ru=function(g,y){return g===y||k(g)!==null?!1:(vl&&Ps(g),!0)},su=function(g,y){if(Yt(ie.beforeSanitizeElements,g,null),ru(g,y))return!0;if(Ns(g))return Ln(g),!0;let A=De(H(g));if(xe=iu(ie.uponSanitizeElement,xe,Cs,As),Yt(ie.uponSanitizeElement,g,{tagName:A,allowedTags:xe}),ru(g,y))return!0;if(D0(g,A))return Ln(g),!0;if(Ie[A]||!(We.tagCheck instanceof Function&&We.tagCheck(A))&&!xe[A]){let V=O0(g,A,y);return V===!1&&Yt(ie.afterSanitizeElements,g,null),V}if(W(g)===gt.element&&!E0(g)||(A==="noscript"||A==="noembed"||A==="noframes")&&Je(sw,g.innerHTML))return Ln(g),!0;if(Rn&&g.nodeType===gt.text){let V=Is(g.textContent);g.textContent!==V&&(kr(e.removed,{element:g.cloneNode()}),g.textContent=V)}return Yt(ie.afterSanitizeElements,g,null),!1},ou=function(g,y,A){if(Mn[y]||eu(y,g)||zd&&(y==="id"||y==="name")&&(A in t||A in C0))return!1;let _=ve[y]||We.attributeCheck instanceof Function&&We.attributeCheck(y,g);return Bt&&Je(pl,y)||En&&Je(ml,y)?!0:_?Kd[y]||Je(bl,Sr(A,ks,""))||(y==="src"||y==="xlink:href"||y==="href")&&g!=="script"&&Yu(A,"data:")===0&&Ud[g]||Ts&&!Je(gl,Sr(A,ks,""))?!0:!A:lu(g)&&Bs(Z.tagNameCheck,g)&&Bs(Z.attributeNameCheck,y,g)||y==="is"&&Z.allowCustomizedBuiltInElements&&Bs(Z.tagNameCheck,A)},P0=le({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),lu=function(g){return!P0[Tr(g)]&&Je(Ss,g)},I0=function(g,y,A,_){if(z&&typeof u=="object"&&typeof u.getAttributeType=="function"&&!A)switch(u.getAttributeType(g,y)){case"TrustedHTML":return X(_);case"TrustedScriptURL":return ye(_)}return _},N0=function(g,y,A,_){try{return A?g.setAttributeNS(A,y,_):g.setAttribute(y,_),Ns(g)?(Ln(g),!1):!0}catch{return Zn(y,g),!1}},au=function(g){Yt(ie.beforeSanitizeAttributes,g,null);let y=g.attributes;if(!y||Ns(g))return;ve=iu(ie.uponSanitizeAttribute,ve,G,Ms);let A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ve,forceKeepAttr:void 0},_=y.length,V=De(g.nodeName);for(;_--;){let q=y[_],pe=q.name,Ee=q.namespaceURI,lt=q.value,at=De(pe),Rl=lt,tt=pe==="value"?Rl:Wb(Rl),cu=!1;if(A.attrName=at,A.attrValue=tt,A.keepAttr=!0,A.forceKeepAttr=void 0,Yt(ie.uponSanitizeAttribute,g,A),tt=A.attrValue,Wd&&(at==="id"||at==="name")&&Yu(tt,Vd)!==0&&(Zn(pe,g,q),tt=Vd+tt,cu=!0),Jn&&Je(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,tt)){Zn(pe,g,q);continue}if(at==="attributename"&&Ju(tt,"href")){Zn(pe,g,q);continue}if(!A.forceKeepAttr){if(!A.keepAttr){Zn(pe,g,q);continue}if(!Fd&&Je(ow,tt)){Zn(pe,g,q);continue}if(Rn&&(tt=Is(tt)),!ou(V,at,tt)){Zn(pe,g,q);continue}tt=I0(V,at,Ee,tt),tt!==Rl&&N0(g,pe,Ee,tt)&&cu&&Xu(e.removed)}}Yt(ie.afterSanitizeAttributes,g,null)},_s=function(g){let y=null,A=nu(g);for(Yt(ie.beforeSanitizeShadowDOM,g,null);y=A.nextNode();)if(Yt(ie.uponSanitizeShadowNode,y,null),su(y,g),au(y),Pi(y.content)&&_s(y.content),W(y)===gt.element){let _=C(y);Pi(_)&&(El(_),_s(_))}Yt(ie.afterSanitizeShadowDOM,g,null)},El=function(g){let y=[{node:g,shadow:null}];for(;y.length>0;){let A=y.pop();if(A.shadow){_s(A.shadow);continue}let _=A.node,q=W(_)===gt.element,pe=b(_);if(pe)for(let Ee=pe.length-1;Ee>=0;--Ee)y.push({node:pe[Ee],shadow:null});if(q){let Ee=x?x(_):null;if(typeof Ee=="string"&&De(Ee)==="template"){let lt=_.content;Pi(lt)&&y.push({node:lt,shadow:null})}}if(q){let Ee=C(_);Pi(Ee)&&y.push({node:null,shadow:Ee},{node:Ee,shadow:null})}}};return e.sanitize=function(E){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=null,A=null,_=null,V=null;if(kl=!E,kl&&(E="<!-->"),typeof E!="string"&&!hr(E)&&(E=Kb(E),typeof E!="string"))throw ti("dirty is not a string, aborting");if(!e.isSupported)return E;wl?(xe=As,ve=Ms):Al(g),(ie.uponSanitizeElement.length>0||ie.uponSanitizeAttribute.length>0)&&(xe=bt(xe)),ie.uponSanitizeAttribute.length>0&&(ve=bt(ve)),e.removed=[];let q=vl&&typeof E!="string"&&hr(E);if(q){L0(E);let lt=H(E);if(typeof lt=="string"){let at=De(lt);if(!xe[at]||Ie[at])throw Os(E),ti("root node is forbidden and cannot be sanitized in-place")}if(Ns(E))throw Os(E),ti("root node is clobbered and cannot be sanitized in-place");try{El(E)}catch(at){throw Os(E),at}}else if(hr(E))y=tu("<!---->"),A=y.ownerDocument.importNode(E,!0),A.nodeType===gt.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?y=A:y.appendChild(A),El(y);else{if(!Ei&&!Rn&&!Yn&&E.indexOf("<")===-1)return z&&Rs?X(E):E;if(y=tu(E),!y)return Ei?null:Rs?D:""}y&&yl&&Ln(y.firstChild);let pe=q?E:y;try{let lt=nu(pe);for(;_=lt.nextNode();)su(_,pe),au(_),Pi(_.content)&&_s(_.content)}catch(lt){throw q&&(Os(E),ni(e.removed,at=>{at.element&&Ps(at.element)})),lt}if(q)return ni(e.removed,lt=>{lt.element&&Ps(lt.element)}),Rn&&Ml(E),E;if(Ei){if(Rn&&Ml(y),Es)for(V=Ke.call(y.ownerDocument);y.firstChild;)V.appendChild(y.firstChild);else V=y;return(ve.shadowroot||ve.shadowrootmode)&&(V=kt.call(i,V,!0)),V}let Ee=Yn?y.outerHTML:y.innerHTML;return Yn&&xe["!doctype"]&&y.ownerDocument&&y.ownerDocument.doctype&&y.ownerDocument.doctype.name&&Je(iw,y.ownerDocument.doctype.name)&&(Ee="<!DOCTYPE "+y.ownerDocument.doctype.name+`>
717
+ `+Ee),Rn&&(Ee=Is(Ee)),z&&Rs?X(Ee):Ee},e.setConfig=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Al(E),wl=!0,As=xe,Ms=ve},e.clearConfig=function(){Oi=null,wl=!1,As=null,Ms=null,z=R,D=""},e.isValidAttribute=function(E,g,y){Oi||Al({});let A=De(E),_=De(g);return ou(A,_,y)},e.addHook=function(E,g){typeof g=="function"&&dt(ie,E)&&kr(ie[E],g)},e.removeHook=function(E,g){if(dt(ie,E)){if(g!==void 0){let y=Fb(ie[E],g);return y===-1?void 0:zb(ie[E],y,1)[0]}return Xu(ie[E])}},e.removeHooks=function(E){dt(ie,E)&&(ie[E]=[])},e.removeAllHooks=function(){ie=lh()},e}var Ar=uh();function Js(n,e,t,i){let r=t?Array.from(t):[];if(!n||!e||r.length===0)return!1;let s=Y.conversation;if(!s)return i?.("error",v("attach.channelUnavailable")),!1;try{let o=s.createDrafts(n,r);if(o.length===0)return!1;let l=e.addAttachments(o.map(a=>a.id));return l||s.releaseDraftAttachments(o),l}catch(o){return i?.("error",o instanceof Error?o.message:String(o)),!1}}function hh(n){let e=null,t=Y.conversation?.input.shell(n);if(typeof t?.bindFilePicker=="function")return t.bindFilePicker({available:()=>!0,open:()=>{e?.remove();let i=document.createElement("input");e=i,i.type="file",i.multiple=!0,i.style.display="none",i.addEventListener("change",()=>{i.remove(),e===i&&(e=null),Js(n,Y.conversation?.input.shell(n)??void 0,i.files)}),document.body.appendChild(i),i.click()}})}function fh(n){return n!==null&&Array.from(n.types).includes("Files")}var U=require("react/jsx-runtime");function In(n,e,t,i="currentColor"){return(0,U.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e??16,height:e??16,viewBox:"0 0 24 24",fill:"none",stroke:i,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,"aria-hidden":"true",children:n})}var la=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("path",{d:"M6.8 5.8 2.9 11l4 4.4"}),(0,U.jsx)("path",{d:"M17.2 5.8 21.1 11l-3.9 4.4"}),(0,U.jsx)("path",{d:"M10.7 9.5 12.5 3.9"}),(0,U.jsx)("path",{d:"M16.6 9.4 6.9 14l2.9 1.3.1 2.5q.1.8.7.3l1-2.3 2.2 1.4Z"}),(0,U.jsx)("path",{d:"M9.8 15.3 16.6 9.4"})]});function ph({size:n,className:e}){return In(la,n,e)}function aa({size:n,className:e}){return In(la,n,e,"#3964FE")}function mh({size:n,className:e}){return In((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}),(0,U.jsx)("path",{d:"m15 5 4 4"})]}),n,e)}function gh({size:n,className:e}){return In((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),(0,U.jsx)("circle",{cx:"12",cy:"12",r:"3"})]}),n,e)}function bh({size:n,className:e}){return In((0,U.jsx)("path",{d:"M18 6 6 18M6 6l12 12"}),n,e)}function wh({size:n,className:e}){return In((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),(0,U.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"})]}),n,e)}function yh({size:n,className:e}){return In((0,U.jsx)("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"}),n,e)}function xh({size:n,className:e}){return In((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,U.jsx)("path",{d:"m21 21-4.3-4.3"})]}),n,e)}function vh({size:n}){return(0,U.jsx)("svg",{width:n??14,height:n??14,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:(0,U.jsx)("path",{d:"M8.64453 1.5V7.34961H14.5V8.65039H8.64453V14.5H7.34473V8.65039H1.5V7.34961H7.34473V1.5H8.64453Z",fill:"currentColor"})})}var kh="M8.20554 0.899994L14.7901 3.36857V7.01026C14.7901 12 11.0466 14.2103 8.20554 15.3C5.36446 14.2103 1.62012 12 1.62012 7.01026V3.36857L8.20554 0.899994Z",uw="M12.1654 5.7552L8.9447 9.41475C8.73044 9.65816 8.53628 9.8804 8.35774 10.0423C8.1713 10.2114 7.94235 10.3717 7.64016 10.4254C7.48207 10.4535 7.32 10.4552 7.16151 10.4294C6.85843 10.3801 6.62728 10.2223 6.43836 10.0559C6.25752 9.89653 6.06037 9.67732 5.84264 9.43705L4.72925 8.20897L5.63557 7.38707L6.74897 8.61594C6.98603 8.87755 7.12974 9.03533 7.24673 9.13839C7.31033 9.19443 7.34485 9.21476 7.35823 9.22122C7.38068 9.22484 7.40352 9.22515 7.42593 9.22122C7.40522 9.22502 7.42893 9.23294 7.53583 9.136C7.65132 9.03126 7.79316 8.87139 8.02643 8.60638L11.2479 4.94763L12.1654 5.7552Z";function Sh({size:n}){return(0,U.jsxs)("svg",{width:n??16,height:n??16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,U.jsx)("path",{d:kh,stroke:"currentColor",strokeWidth:"1.31831",strokeLinejoin:"round"}),(0,U.jsx)("path",{d:uw,fill:"currentColor"})]})}function Ch({size:n}){return(0,U.jsxs)("svg",{width:n??16,height:n??16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,U.jsx)("path",{d:"M8.08887 0.251709C8.20479 0.23085 8.32486 0.241168 8.43652 0.282959L15.0215 2.75171C15.2787 2.84819 15.4492 3.09414 15.4492 3.3689V7.0105C15.4492 7.10986 15.4441 7.2081 15.4414 7.30542C15.0285 7.07175 14.5905 6.87695 14.1309 6.73022V3.82495L8.20508 1.60327L2.2793 3.82495V7.0105C2.27936 9.7171 3.4745 11.5379 5.02734 12.7947C5.01025 12.9942 5 13.1962 5 13.4001C5.00001 13.7617 5.02722 14.1169 5.08008 14.4636C2.91555 13.0393 0.961014 10.752 0.960938 7.0105V3.3689C0.960938 3.09417 1.13146 2.84821 1.38867 2.75171L7.97461 0.282959L8.08887 0.251709Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M11.3525 5.64688V6.85688H5V5.64688H11.3525Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M9.5824 8.29376V9.50376H5V8.29376H9.5824Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M14.6647 15.6852H10.0338C10.3878 15.3751 10.7567 15.0517 11.0772 14.7706C11.2531 14.6164 11.4144 14.4746 11.5511 14.3547H14.6647V15.6852Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M8.14852 14.1308L7.33925 15.4976C7.22458 15.6912 7.42245 15.9194 7.63037 15.8333L9.09785 15.2254L15.0399 10.0719L14.0905 8.97733L8.14852 14.1308Z",fill:"currentColor"})]})}function Th({size:n}){return(0,U.jsxs)("svg",{width:n??16,height:n??16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,U.jsx)("path",{d:kh,stroke:"currentColor",strokeWidth:"1.31831",strokeLinejoin:"round"}),(0,U.jsx)("path",{d:"M9.10094 4.5V8.75939H7.59888V4.5H9.10094Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M9.10094 9.8114V11.5H7.59888V9.8114H9.10094Z",fill:"currentColor"})]})}function Ah({size:n}){return(0,U.jsxs)("svg",{width:n??18,height:n??18,viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:[(0,U.jsx)("path",{d:"M6.3002 3.32843L7.69986 3.32843L7.69986 7.79657H6.3002L6.3002 3.32843Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M6.3002 9.01935H7.69986V10.6711H6.3002V9.01935Z",fill:"currentColor"}),(0,U.jsx)("path",{d:"M12.6328 6.99976C12.6328 3.88874 10.111 1.36694 7 1.36694C3.88899 1.36695 1.3672 3.88875 1.36719 6.99976C1.36719 10.1108 3.88899 12.6326 7 12.6326C10.111 12.6326 12.6328 10.1108 12.6328 6.99976ZM13.8582 6.99976C13.8582 10.7873 10.7876 13.8579 7 13.8579C3.21244 13.8579 0.141846 10.7873 0.141846 6.99976C0.141857 3.2122 3.21245 0.141612 7 0.141602C10.7876 0.141602 13.8581 3.21219 13.8582 6.99976Z",fill:"currentColor"})]})}function Mh({size:n}){return(0,U.jsx)("svg",{width:n??16,height:n??16,viewBox:"0 0 16 16","aria-hidden":"true",children:(0,U.jsx)("path",{d:"M8.3125 0.980183C8.66767 1.0531 8.97902 1.20418 9.2627 1.43233C9.48724 1.61297 9.73029 1.85793 9.97949 2.10714L14.707 6.83468L13.293 8.24874L9 3.95577V15.0417H7V3.95577L2.70703 8.24874L1.29297 6.83468L6.02051 2.10714C6.26971 1.85793 6.51277 1.61297 6.7373 1.43233C6.97662 1.23986 7.28445 1.04402 7.6875 0.980183C7.8973 0.947006 8.1031 0.95516 8.3125 0.980183Z",fill:"currentColor"})})}function Eh({size:n}){return(0,U.jsx)("svg",{width:n??16,height:n??16,viewBox:"0 0 16 16","aria-hidden":"true",children:(0,U.jsx)("rect",{x:"3",y:"3",width:"10",height:"10",rx:"3",fill:"currentColor"})})}function en({size:n}){return(0,U.jsx)("svg",{width:n??14,height:n??14,viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:(0,U.jsx)("path",{d:"M3.5 5.75L7 9.25L10.5 5.75",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}function Rh({size:n=16,className:e}){return(0,U.jsx)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:e,"aria-hidden":"true",children:la})}var Pt=require("react");var da=[],Ph=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<n.length;e++)(e%2?Ph:da).push(t=t+n[e])})();function hw(n){if(n<768)return!1;for(let e=0,t=da.length;;){let i=e+t>>1;if(n<da[i])t=i;else if(n>=Ph[i])e=i+1;else return!0;if(e==t)return!1}}function Lh(n){return n>=127462&&n<=127487}var Dh=8205;function Ih(n,e,t=!0,i=!0){return(t?Nh:fw)(n,e,i)}function Nh(n,e,t){if(e==n.length)return e;e&&Bh(n.charCodeAt(e))&&_h(n.charCodeAt(e-1))&&e--;let i=ca(n,e);for(e+=Oh(i);e<n.length;){let r=ca(n,e);if(i==Dh||r==Dh||t&&hw(r))e+=Oh(r),i=r;else if(Lh(r)){let s=0,o=e-2;for(;o>=0&&Lh(ca(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function fw(n,e,t){for(;e>1;){let i=Nh(n,e-2,t);if(i<e)return i;e--}return 0}function ca(n,e){let t=n.charCodeAt(e);if(!_h(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Bh(i)?(t-55296<<10)+(i-56320)+65536:t}function Bh(n){return n>=56320&&n<57344}function _h(n){return n>=55296&&n<56320}function Oh(n){return n<65536?1:2}var ne=class n{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Wi(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),Hi.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Wi(this,e,t);let i=[];return this.decompose(e,t,i,0),Hi.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new oi(this),s=new oi(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new oi(this,e)}iterRange(e,t=this.length){return new to(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new no(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?n.empty:e.length<=32?new wt(e):Hi.from(wt.split(e,[]))}},wt=class n extends ne{constructor(e,t=pw(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new ha(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new n(Hh(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=eo(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new n(l,o.length+s.length));else{let a=l.length>>1;i.push(new n(l.slice(0,a)),new n(l.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof n))return super.replace(e,t,i);[e,t]=Wi(this,e,t);let r=eo(this.text,eo(i.text,Hh(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new n(r,s):Hi.from(n.split(r,[]),s)}sliceString(e,t=this.length,i=`
718
718
  `){[e,t]=Wi(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=i),e<a&&t>s&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new n(i,r)),i=[],r=-1);return r>-1&&t.push(new n(i,r)),t}},Hi=class n extends ne{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,r);r=l+1,i=a+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&t>=o){let c=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!c?i.push(l):l.decompose(e-o,t-o,i,c)}o=a+1}}replace(e,t,i){if([e,t]=Wi(this,e,t),i.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&t<=l){let a=o.replace(e-s,t-s,i),c=this.lines-o.lines+a.lines;if(a.lines<c>>4&&a.lines>c>>6){let d=this.children.slice();return d[r]=a,new n(d,this.length-(t-e)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
719
- `){[e,t]=Wi(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=i),e<a&&t>o&&(r+=l.sliceString(e-o,t-o,i)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof n))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let a=this.children[r],c=e.children[s];if(a!=c)return i+a.scanIdentical(c,t);i+=a.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let f of e)i+=f.lines;if(i<32){let f=[];for(let p of e)p.flatten(f);return new wt(f,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,c=-1,d=[];function u(f){let p;if(f.lines>s&&f instanceof n)for(let m of f.children)u(m);else f.lines>o&&(a>o||!a)?(h(),l.push(f)):f instanceof wt&&a&&(p=d[d.length-1])instanceof wt&&f.lines+p.lines<=32?(a+=f.lines,c+=f.length+1,d[d.length-1]=new wt(p.text.concat(f.text),p.length+1+f.length)):(a+f.lines>r&&h(),a+=f.lines,c+=f.length+1,d.push(f))}function h(){a!=0&&(l.push(d.length==1?d[0]:n.from(d,c)),c=-1,a=d.length=0)}for(let f of e)u(f);return h(),l.length==1?l[0]:new n(l,t)}};ne.empty=new wt([""],0);function hw(n){let e=-1;for(let t of n)e+=t.length+1;return e}function eo(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s<n.length&&r<=i;s++){let l=n[s],a=r+l.length;a>=t&&(a>i&&(l=l.slice(0,i-r)),r<t&&(l=l.slice(t-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function Hh(n,e,t){return eo(n,[""],e,t)}var oi=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof wt?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof wt?r.text.length:r.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
720
- `,this;e--}else if(r instanceof wt){let a=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof wt?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},to=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new oi(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},no=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(ne.prototype[Symbol.iterator]=function(){return this.iter()},oi.prototype[Symbol.iterator]=to.prototype[Symbol.iterator]=no.prototype[Symbol.iterator]=function(){return this});var ha=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function Wi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function $e(n,e,t=!0,i=!0){return Ih(n,e,t,i)}function fw(n){return n>=56320&&n<57344}function pw(n){return n>=55296&&n<56320}function $h(n,e){let t=n.charCodeAt(e);if(!pw(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return fw(i)?(t-55296<<10)+(i-56320)+65536:t}function Uh(n){return n<65536?1:2}var fa=/\r\n?|\n/,ut=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(ut||(ut={})),bn=class n{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,t=!1){pa(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new n(e)}composeDesc(e){return this.empty?e:e.empty?this:jh(this,e)}mapDesc(e,t=!1){return e.empty?this:ma(this,e,t)}mapPos(e,t=-1,i=ut.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],c=r+l;if(a<0){if(c>e)return s+(e-r);s+=l}else{if(i!=ut.Simple&&c>=e&&(i==ut.TrackDel&&r<e&&c>e||i==ut.TrackBefore&&r<e||i==ut.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new n(e)}static create(e){return new n(e)}},it=class n extends bn{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return pa(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return ma(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(ne.empty);i.push(o?e.slice(s,s+o):ne.empty)}s+=o}return new n(t,i)}compose(e){return this.empty?e:e.empty?this:jh(this,e,!0)}map(e,t=!1){return e.empty?this:ma(this,e,t,!0)}iterChanges(e,t=!1){pa(this,e,t)}get desc(){return bn.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new ai(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let d=Math.min(s.len,a-l);Ye(r,d,-1);let u=s.ins==-1?-1:s.off==0?s.ins:0;Ye(t,d,u),u>0&&In(i,t,s.text),s.forward(d),l+=d}let c=e[o++];for(;l<c;){if(s.done)break e;let d=Math.min(s.len,c-l);Ye(t,d,-1),Ye(r,d,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(d),l+=d}}return{changes:new n(t,i),filtered:bn.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(d=!1){if(!d&&!r.length)return;o<t&&Ye(r,t-o,-1);let u=new n(r,s);l=l?l.compose(u.map(l)):u,r=[],s=[],o=0}function c(d){if(Array.isArray(d))for(let u of d)c(u);else if(d instanceof n){if(d.length!=t)throw new RangeError(`Mismatched change set length (got ${d.length}, expected ${t})`);a(),l=l?l.compose(d.map(l)):d}else{let{from:u,to:h=u,insert:f}=d;if(u>h||u<0||h>t)throw new RangeError(`Invalid change range ${u} to ${h} (in doc of length ${t})`);let p=f?typeof f=="string"?ne.of(f.split(i||fa)):f:ne.empty,m=p.length;if(u==h&&m==0)return;u<o&&a(),u>o&&Ye(r,u-o,-1),Ye(r,h-u,m),In(s,r,p),o=h}}return c(e),a(!l),l}static empty(e){return new n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<r;)i.push(ne.empty);i[r]=ne.of(s.slice(1)),t.push(s[0],i[r].length)}}}return new n(t,i)}static createSet(e,t){return new n(e,t)}};function Ye(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=0&&t<=0&&t==n[r+1]?n[r]+=e:r>=0&&e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function In(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(ne.empty);n.push(t)}}function pa(n,e,t){let i=n.inserted;for(let r=0,s=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)r+=l,s+=l;else{let c=r,d=s,u=ne.empty;for(;c+=l,d+=a,a&&i&&(u=u.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,c,s,d,u),r=c,s=d}}}function ma(n,e,t,i=!1){let r=[],s=i?[]:null,o=new ai(n),l=new ai(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let c=Math.min(o.len,l.len);Ye(r,c,-1),o.forward(c),l.forward(c)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let c=l.len;for(Ye(r,l.ins,-1);c;){let d=Math.min(o.len,c);o.ins>=0&&a<o.i&&o.len<=d&&(Ye(r,0,o.ins),s&&In(s,r,o.text),a=o.i),o.forward(d),c-=d}l.next()}else if(o.ins>=0){let c=0,d=o.len;for(;d;)if(l.ins==-1){let u=Math.min(d,l.len);c+=u,d-=u,l.forward(u)}else if(l.ins==0&&l.len<d)d-=l.len,l.next();else break;Ye(r,c,a<o.i?o.ins:0),s&&a<o.i&&In(s,r,o.text),a=o.i,o.forward(o.len-d)}else{if(o.done&&l.done)return s?it.createSet(r,s):bn.create(r);throw new Error("Mismatched change set lengths")}}}function jh(n,e,t=!1){let i=[],r=t?[]:null,s=new ai(n),o=new ai(e);for(let l=!1;;){if(s.done&&o.done)return r?it.createSet(i,r):bn.create(i);if(s.ins==0)Ye(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)Ye(i,0,o.ins,l),r&&In(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),c=i.length;if(s.ins==-1){let d=o.ins==-1?-1:o.off?0:o.ins;Ye(i,a,d,l),r&&d&&In(r,i,o.text)}else o.ins==-1?(Ye(i,s.off?0:s.len,a,l),r&&In(r,i,s.textBit(a))):(Ye(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&In(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>c),s.forward2(a),o.forward(a)}}}}var ai=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?ne.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?ne.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},ii=class n{constructor(e,t,i,r){this.from=e,this.to=t,this.flags=i,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new n(i,r,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return D.range(e,t,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return D.range(this.anchor,r,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return D.range(e.anchor,e.head)}static create(e,t,i,r){return new n(e,t,i,r)}},D=class n{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:n.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new n([this.main],0)}addRange(e,t=!0){return n.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,n.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new n(e.ranges.map(t=>ii.fromJSON(t)),e.main)}static single(e,t=e){return new n([n.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return n.normalized(e.slice(),t);i=s.to}return new n(e,t)}static cursor(e,t=0,i,r){return ii.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i)),r)}static range(e,t,i,r,s){let o=r==null?7:Math.min(6,r);return!s&&e!=t&&(s=t<e?1:-1),s&&(o|=s<0?8:16),t<e?ii.create(t,e,o|32,i):ii.create(e,t,o,i)}static undirectionalRange(e,t){return ii.create(e,t,64,void 0)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?n.range(a,l):n.range(l,a))}}return new n(e,t)}};function Kh(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Ta=0,V=class n{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=Ta++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new n(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Aa),!!e.static,e.enables)}of(e){return new Fi([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Fi(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Fi(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function Aa(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var Fi=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=Ta++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,c=!1,d=[];for(let u of this.dependencies)u=="doc"?a=!0:u=="selection"?c=!0:(((t=e[u.id])!==null&&t!==void 0?t:1)&1)==0&&d.push(e[u.id]);return{create(u){return u.values[o]=i(u),1},update(u,h){if(a&&h.docChanged||c&&(h.docChanged||h.selection)||ga(u,d)){let f=i(u);if(l?!Fh(f,u.values[o],r):!r(f,u.values[o]))return u.values[o]=f,1}return 0},reconfigure:(u,h)=>{let f,p=h.config.address[s];if(p!=null){let m=so(h,p);if(this.dependencies.every(w=>w instanceof V?h.facet(w)===u.facet(w):w instanceof Tt?h.field(w,!1)==u.field(w,!1):!0)||(l?Fh(f=i(u),m,r):r(f=i(u),m)))return u.values[o]=m,0}else f=i(u);return u.values[o]=f,1}}}get extension(){return this}};function Fh(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function ga(n,e){let t=!1;for(let i of e)Rr(n,i)&1&&(t=!0);return t}function mw(n,e,t){let i=t.map(a=>n[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let c=[];for(let d=0;d<i.length;d++){let u=so(a,i[d]);if(r[d]==2)for(let h of u)c.push(h);else c.push(u)}return e.combine(c)}return{create(a){for(let c of i)Rr(a,c);return a.values[o]=l(a),1},update(a,c){if(!ga(a,s))return 0;let d=l(a);return e.compare(d,a.values[o])?0:(a.values[o]=d,1)},reconfigure(a,c){let d=ga(a,i),u=c.config.facets[e.id],h=c.facet(e);if(u&&!d&&Aa(t,u))return a.values[o]=h,0;let f=l(a);return e.compare(f,h)?(a.values[o]=h,0):(a.values[o]=f,1)}}}var Ys=V.define({static:!0}),Tt=class n{constructor(e,t,i,r,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new n(Ta++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Ys).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>{let s=i.facet(Ys),o=r.facet(Ys),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Ys.of({field:this,create:e})]}get extension(){return this}},ri={lowest:4,low:3,default:2,high:1,highest:0};function Er(n){return e=>new io(e,n)}var Pr={highest:Er(ri.highest),high:Er(ri.high),default:Er(ri.default),low:Er(ri.low),lowest:Er(ri.lowest)},io=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},wn=class n{of(e){return new Dr(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Dr=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},ro=class n{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let h of gw(e,t,o))h instanceof Tt?r.push(h):(s[h.facet.id]||(s[h.facet.id]=[])).push(h);let l=Object.create(null),a=[],c=[];for(let h of r)l[h.id]=c.length<<1,c.push(f=>h.slot(f));let d=i?.config.facets;for(let h in s){let f=s[h],p=f[0].facet,m=d&&d[h]||[];if(f.every(w=>w.type==0))if(l[p.id]=a.length<<1|1,Aa(m,f))a.push(i.facet(p));else{let w=p.combine(f.map(b=>b.value));a.push(i&&p.compare(w,i.facet(p))?i.facet(p):w)}else{for(let w of f)w.type==0?(l[w.id]=a.length<<1|1,a.push(w.value)):(l[w.id]=c.length<<1,c.push(b=>w.dynamicSlot(b)));l[p.id]=c.length<<1,c.push(w=>mw(w,p,f))}}let u=c.map(h=>h(l));return new n(e,o,u,l,a,s)}};function gw(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let c=i[a].indexOf(o);c>-1&&i[a].splice(c,1),o instanceof Dr&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let c of o)s(c,l);else if(o instanceof Dr){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),s(c,l)}else if(o instanceof io)s(o.inner,o.prec);else if(o instanceof Tt)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Fi)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,ri.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(c==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(c,l)}}return s(n,ri.default),i.reduce((o,l)=>o.concat(l))}function Rr(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function so(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var Gh=V.define(),ba=V.define({combine:n=>n.some(e=>e),static:!0}),qh=V.define({combine:n=>n.length?n[0]:void 0,static:!0}),Xh=V.define(),Jh=V.define(),Yh=V.define(),Zh=V.define({combine:n=>n.length?n[0]:!1}),ht=class{constructor(e,t){this.type=e,this.value=t}static define(){return new wa}},wa=class{of(e){return new ht(this,e)}},ya=class{constructor(e){this.map=e}of(e){return new ve(this,e)}},ve=class n{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new n(this.type,t)}is(e){return this.type==e}static define(e={}){return new ya(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}};ve.reconfigure=ve.define();ve.appendConfig=ve.define();var Be=class n{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Kh(i,t.newLength),s.some(l=>l.type==n.time)||(this.annotations=s.concat(n.time.of(Date.now())))}static create(e,t,i,r,s,o){return new n(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(n.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};Be.time=ht.define();Be.userEvent=ht.define();Be.addToHistory=ht.define();Be.remote=ht.define();function bw(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i<n.length&&(r==e.length||e[r]>=n[i]))s=n[i++],o=n[i++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Qh(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=it.empty(e.changes.length),o=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:ve.mapEffects(n.effects,r).concat(ve.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function xa(n,e,t){let i=e.selection,r=zi(e.annotations);return e.userEvent&&(r=r.concat(Be.userEvent.of(e.userEvent))),{changes:e.changes instanceof it?e.changes:it.of(e.changes||[],t,n.facet(qh)),selection:i&&(i instanceof D?i:D.single(i.anchor,i.head)),effects:zi(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function ef(n,e,t){let i=xa(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=Qh(i,xa(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=Be.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return yw(t?ww(r):r)}function ww(n){let e=n.startState,t=!0;for(let r of e.facet(Xh)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:bw(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=it.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=Be.create(e,r,n.selection&&n.selection.map(s),ve.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(Jh);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof Be?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Be?n=s[0]:n=ef(e,zi(s),!1)}return n}function yw(n){let e=n.startState,t=e.facet(Yh),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=Qh(i,xa(e,s,n.changes.newLength),!0))}return i==n?n:Be.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var xw=[];function zi(n){return n==null?xw:Array.isArray(n)?n:[n]}var Nt=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(Nt||(Nt={})),vw=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,va;try{va=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function kw(n){if(va)return va.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||vw.test(t)))return!0}return!1}function Sw(n){return e=>{if(!/\S/.test(e))return Nt.Space;if(kw(e))return Nt.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return Nt.Word;return Nt.Other}}var Ce=class n{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Rr(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Rr(this,i),so(this,i)}update(...e){return ef(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(wn.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,c)=>r.set(c,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(ve.reconfigure)?(t=null,i=l.value):l.is(ve.appendConfig)&&(t=null,i=zi(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=ro.resolve(i,r,this),s=new n(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,c)=>c.reconfigure(a,this),null).values);let o=e.startState.facet(ba)?e.newSelection:e.newSelection.asSingle();new n(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:D.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=zi(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),c=this.changes(a.changes),d=c.map(r);for(let h=0;h<l;h++)s[h]=s[h].map(d);let u=r.mapDesc(c,!0);s.push(a.range.map(u)),r=r.compose(d),o=ve.mapEffects(o,d).concat(ve.mapEffects(zi(a.effects),u))}return{changes:r,selection:D.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof it?e:it.of(e,this.doc.length,this.facet(n.lineSeparator))}toText(e){return ne.of(e.split(this.facet(n.lineSeparator)||fa))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Rr(this,t),so(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof Tt&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return n.create({doc:e.doc,selection:D.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=ro.resolve(e.extensions||[],new Map),i=e.doc instanceof ne?e.doc:ne.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||fa)),r=e.selection?e.selection instanceof D?e.selection:D.single(e.selection.anchor,e.selection.head):D.single(0);return Kh(r,i.length),t.staticFacet(ba)||(r=r.asSingle()),new n(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(n.tabSize)}get lineBreak(){return this.facet(n.lineSeparator)||`
721
- `}get readOnly(){return this.facet(Zh)}phrase(e,...t){for(let i of this.facet(n.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(Gh))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return Sw(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=$e(t,o,!1);if(s(t.slice(a,o))!=Nt.Word)break;o=a}for(;l<r;){let a=$e(t,l);if(s(t.slice(l,a))!=Nt.Word)break;l=a}return o==l?null:D.range(o+i,l+i)}};Ce.allowMultipleSelections=ba;Ce.tabSize=V.define({combine:n=>n.length?n[0]:4});Ce.lineSeparator=qh;Ce.readOnly=Zh;Ce.phrases=V.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});Ce.languageData=Gh;Ce.changeFilter=Xh;Ce.transactionFilter=Jh;Ce.transactionExtender=Yh;wn.reconfigure=ve.define();function Vi(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var tn=class{eq(e){return this==e}range(e,t=e){return Lr.create(e,t,this)}};tn.prototype.startSide=tn.prototype.endSide=0;tn.prototype.point=!1;tn.prototype.mapMode=ut.TrackDel;function Ma(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}var Lr=class n{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new n(e,t,i)}};function ka(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var Sa=class n{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return _i(this.to)}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,c=s[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return c>=0?o:l;c>=0?l=a:o=a+1}}between(e,t,i,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t,i,r,s){let o=[],l=[],a=[],c=-1,d=-1;e:for(let u=0;u<this.value.length;u++){let h=this.value[u],f=this.from[u]+e,p=this.to[u]+e,m,w;if(f==p){let b=t.mapPos(f,h.startSide,h.mapMode);if(b==null||(m=w=b,h.startSide!=h.endSide&&(w=t.mapPos(f,h.endSide),w<m)))continue}else if(m=t.mapPos(f,h.startSide),w=t.mapPos(p,h.endSide),m>w||m==w&&h.startSide>0&&h.endSide<=0)continue;if(!((w-m||h.endSide-h.startSide)<0))if(c<0&&(c=m),h.point&&(d=Math.max(d,w-m)),(m-i||h.startSide-r)>=0)o.push(h),l.push(m-c),a.push(w-c),i=w,r=h.endSide;else{if(m==w)for(let b=o.length;b>0;b--){if((m-(a[b-1]+c)||h.startSide-o[b-1].endSide)>=0){o.splice(b,0,h),l.splice(b,0,m-c),a.splice(b,0,w-c);continue e}if((m-(l[b-1]+c)||h.endSide-o[b-1].startSide)>0)break}s(m,w,h)}}return{mapped:o.length?new n(l,a,o,d):null,pos:c}}},he=class n{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new n(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(ka)),this.isEmpty)return t.length?n.of(t):this;let l=new oo(this,null,-1).goto(0),a=0,c=[],d=new li;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let u=t[a++];d.addInner(u.from,u.to,u.value,!1)||c.push(u)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&d.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(d.addInner(l.from,l.to,l.value,!1)||c.push(Lr.create(l.from,l.to,l.value))),l.next());return d.finishInner(this.nextLayer.isEmpty&&!c.length?n.empty:this.nextLayer.update({add:c,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],r=-1,s,o=(a,c,d)=>{s||(s=new li),s.addRange(a,c,d,!1)};for(let a=0;a<this.chunk.length;a++){let c=this.chunkPos[a],d=this.chunk[a],u=e.touchesRange(c,c+d.length);if(u===!1)r=Math.max(r,d.maxPoint),t.push(d),i.push(e.mapPos(c));else if(u===!0){let[h,f]=t.length?[_i(i)+_i(t).length,_i(_i(t).value).endSide]:[-1,-1],{mapped:p,pos:m}=d.map(c,e,h,f,o);p&&(r=Math.max(r,p.maxPoint),t.push(p),i.push(m))}}let l=this.nextLayer.map(e);return s&&(l=s.finishInner(l)),t.length==0?l:new n(i,t,l||n.empty,r)}between(e,t,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Or.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Or.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),l=t.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),a=zh(o,l,i),c=new si(o,a,s),d=new si(l,a,s);i.iterGaps((u,h,f)=>Wh(c,u,d,h,f,r)),i.empty&&i.length==0&&Wh(c,0,d,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(d=>!d.isEmpty&&t.indexOf(d)<0),o=t.filter(d=>!d.isEmpty&&e.indexOf(d)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=zh(s,o),a=new si(s,l,0).goto(i),c=new si(o,l,0).goto(i);for(;;){if(a.to!=c.to||!Ca(a.active,c.active)||a.point&&(!c.point||!Ma(a.point,c.point)))return!1;if(a.to>r)return!0;a.next(),c.next()}}static spans(e,t,i,r,s=-1){let o=new si(e,null,s).goto(t),l=t,a=o.openStart;for(;;){let c=Math.min(o.to,i);if(o.point){let d=o.activeForPoint(o.to),u=o.pointFrom<t?d.length+1:o.point.startSide<0?d.length:Math.min(d.length,a);r.point(l,c,o.point,d,u,o.pointRank),a=Math.min(o.openEnd(c),d.length)}else c>l&&(r.span(l,c,o.active,a),a=o.openEnd(c));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new li;for(let r of e instanceof Lr?[e]:t?Cw(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return n.empty;let t=_i(e);for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=n.empty;r=r.nextLayer)t=new n(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}};he.empty=new he([],[],null,-1);function _i(n){return n[n.length-1]}function Cw(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(ka(e,i)>0)return n.slice().sort(ka);e=i}return n}he.empty.nextLayer=he.empty;var li=class n{finishChunk(e){this.chunks.push(new Sa(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addRange(e,t,i,!0)}addRange(e,t,i,r){this.addInner(e,t,i,r)||(this.nextLayer||(this.nextLayer=new n)).addRange(e,t,i,r)}addInner(e,t,i,r){let s=e-this.lastTo||i.startSide-this.last.endSide;if(r&&s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(he.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=he.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function zh(n,e,t){let i=new Map;for(let s of n)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!t?.touchesRange(l,l+s.chunk[o].length)&&r.add(s.chunk[o])}return r}var oo=class{constructor(e,t,i,r=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},Or=class n{constructor(e){this.heap=e}static from(e,t=null,i=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&r.push(new oo(o,t,i,s));return r.length==1?r[0]:new n(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)ua(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)ua(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),ua(this.heap,0)}}};function ua(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1<n.length&&r.compare(n[i+1])>=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}var si=class{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Or.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Zs(this.active,e),Zs(this.activeTo,e),Zs(this.activeRank,e),this.minActive=Vh(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||r-this.activeTo[t])>0;)t++;Qs(this.active,t,i),Qs(this.activeTo,t,r),Qs(this.activeRank,t,s),e&&Qs(e,t,this.cursor.from),this.minActive=Vh(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Zs(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}};function Wh(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,l=i,a=i-e,c=!!s.boundChange;for(let d=!1;;){let u=n.to+a-t.to,h=u||n.endSide-t.endSide,f=h<0?n.to+a:t.to,p=Math.min(f,o);if(n.point||t.point?(n.point&&t.point&&Ma(n.point,t.point)&&Ca(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,p,n.point,t.point),d=!1):(d&&(s.boundChange(l),d=!1),p>l&&!Ca(n.active,t.active)&&s.compareRange(l,p,n.active,t.active),c&&p<o&&(u||n.openEnd(f)!=t.openEnd(f))&&(d=!0)),f>o)break;l=f,h<=0&&n.next(),h>=0&&t.next()}}function Ca(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!Ma(n[t],e[t]))return!1;return!0}function Zs(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function Qs(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function Vh(n,e){let t=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||n[r].endSide-n[t].endSide)<0&&(t=r,i=e[r]);return t}function ci(n,e,t=n.length){let i=0;for(let r=0;r<t&&r<n.length;)n.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=$e(n,r));return i}function tf(n,e,t,i){for(let r=0,s=0;;){if(s>=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=$e(n,r)}return i===!0?-1:n.length}var nf=typeof Symbol>"u"?"__\u037C":Symbol.for("\u037C"),Ea=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),rf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},At=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,c){let d=[],u=/^@(\w+)\b/.exec(o[0]),h=u&&u[1]=="keyframes";if(u&&l==null)return a.push(o[0]+";");for(let f in l){let p=l[f];if(/&/.test(f))s(f.split(/,\s*/).map(m=>o.map(w=>m.replace(/&/,w))).reduce((m,w)=>m.concat(w)),p,a);else if(p&&typeof p=="object"){if(!u)throw new RangeError("The value of a property ("+f+") should be a primitive value.");s(r(f),p,d,h)}else p!=null&&d.push(f.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(d.length||h)&&a.push((i&&!u&&!c?o.map(i):o).join(", ")+" {"+d.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
719
+ `){[e,t]=Wi(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=i),e<a&&t>o&&(r+=l.sliceString(e-o,t-o,i)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof n))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let a=this.children[r],c=e.children[s];if(a!=c)return i+a.scanIdentical(c,t);i+=a.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let f of e)i+=f.lines;if(i<32){let f=[];for(let p of e)p.flatten(f);return new wt(f,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,c=-1,d=[];function u(f){let p;if(f.lines>s&&f instanceof n)for(let m of f.children)u(m);else f.lines>o&&(a>o||!a)?(h(),l.push(f)):f instanceof wt&&a&&(p=d[d.length-1])instanceof wt&&f.lines+p.lines<=32?(a+=f.lines,c+=f.length+1,d[d.length-1]=new wt(p.text.concat(f.text),p.length+1+f.length)):(a+f.lines>r&&h(),a+=f.lines,c+=f.length+1,d.push(f))}function h(){a!=0&&(l.push(d.length==1?d[0]:n.from(d,c)),c=-1,a=d.length=0)}for(let f of e)u(f);return h(),l.length==1?l[0]:new n(l,t)}};ne.empty=new wt([""],0);function pw(n){let e=-1;for(let t of n)e+=t.length+1;return e}function eo(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s<n.length&&r<=i;s++){let l=n[s],a=r+l.length;a>=t&&(a>i&&(l=l.slice(0,i-r)),r<t&&(l=l.slice(t-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function Hh(n,e,t){return eo(n,[""],e,t)}var oi=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof wt?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof wt?r.text.length:r.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
720
+ `,this;e--}else if(r instanceof wt){let a=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof wt?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},to=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new oi(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},no=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(ne.prototype[Symbol.iterator]=function(){return this.iter()},oi.prototype[Symbol.iterator]=to.prototype[Symbol.iterator]=no.prototype[Symbol.iterator]=function(){return this});var ha=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function Wi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function $e(n,e,t=!0,i=!0){return Ih(n,e,t,i)}function mw(n){return n>=56320&&n<57344}function gw(n){return n>=55296&&n<56320}function $h(n,e){let t=n.charCodeAt(e);if(!gw(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return mw(i)?(t-55296<<10)+(i-56320)+65536:t}function Uh(n){return n<65536?1:2}var fa=/\r\n?|\n/,ut=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(ut||(ut={})),bn=class n{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,t=!1){pa(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new n(e)}composeDesc(e){return this.empty?e:e.empty?this:jh(this,e)}mapDesc(e,t=!1){return e.empty?this:ma(this,e,t)}mapPos(e,t=-1,i=ut.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],c=r+l;if(a<0){if(c>e)return s+(e-r);s+=l}else{if(i!=ut.Simple&&c>=e&&(i==ut.TrackDel&&r<e&&c>e||i==ut.TrackBefore&&r<e||i==ut.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new n(e)}static create(e){return new n(e)}},it=class n extends bn{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return pa(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return ma(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(ne.empty);i.push(o?e.slice(s,s+o):ne.empty)}s+=o}return new n(t,i)}compose(e){return this.empty?e:e.empty?this:jh(this,e,!0)}map(e,t=!1){return e.empty?this:ma(this,e,t,!0)}iterChanges(e,t=!1){pa(this,e,t)}get desc(){return bn.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new ai(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let d=Math.min(s.len,a-l);Ye(r,d,-1);let u=s.ins==-1?-1:s.off==0?s.ins:0;Ye(t,d,u),u>0&&Nn(i,t,s.text),s.forward(d),l+=d}let c=e[o++];for(;l<c;){if(s.done)break e;let d=Math.min(s.len,c-l);Ye(t,d,-1),Ye(r,d,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(d),l+=d}}return{changes:new n(t,i),filtered:bn.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(d=!1){if(!d&&!r.length)return;o<t&&Ye(r,t-o,-1);let u=new n(r,s);l=l?l.compose(u.map(l)):u,r=[],s=[],o=0}function c(d){if(Array.isArray(d))for(let u of d)c(u);else if(d instanceof n){if(d.length!=t)throw new RangeError(`Mismatched change set length (got ${d.length}, expected ${t})`);a(),l=l?l.compose(d.map(l)):d}else{let{from:u,to:h=u,insert:f}=d;if(u>h||u<0||h>t)throw new RangeError(`Invalid change range ${u} to ${h} (in doc of length ${t})`);let p=f?typeof f=="string"?ne.of(f.split(i||fa)):f:ne.empty,m=p.length;if(u==h&&m==0)return;u<o&&a(),u>o&&Ye(r,u-o,-1),Ye(r,h-u,m),Nn(s,r,p),o=h}}return c(e),a(!l),l}static empty(e){return new n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<r;)i.push(ne.empty);i[r]=ne.of(s.slice(1)),t.push(s[0],i[r].length)}}}return new n(t,i)}static createSet(e,t){return new n(e,t)}};function Ye(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=0&&t<=0&&t==n[r+1]?n[r]+=e:r>=0&&e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function Nn(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(ne.empty);n.push(t)}}function pa(n,e,t){let i=n.inserted;for(let r=0,s=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)r+=l,s+=l;else{let c=r,d=s,u=ne.empty;for(;c+=l,d+=a,a&&i&&(u=u.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,c,s,d,u),r=c,s=d}}}function ma(n,e,t,i=!1){let r=[],s=i?[]:null,o=new ai(n),l=new ai(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let c=Math.min(o.len,l.len);Ye(r,c,-1),o.forward(c),l.forward(c)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let c=l.len;for(Ye(r,l.ins,-1);c;){let d=Math.min(o.len,c);o.ins>=0&&a<o.i&&o.len<=d&&(Ye(r,0,o.ins),s&&Nn(s,r,o.text),a=o.i),o.forward(d),c-=d}l.next()}else if(o.ins>=0){let c=0,d=o.len;for(;d;)if(l.ins==-1){let u=Math.min(d,l.len);c+=u,d-=u,l.forward(u)}else if(l.ins==0&&l.len<d)d-=l.len,l.next();else break;Ye(r,c,a<o.i?o.ins:0),s&&a<o.i&&Nn(s,r,o.text),a=o.i,o.forward(o.len-d)}else{if(o.done&&l.done)return s?it.createSet(r,s):bn.create(r);throw new Error("Mismatched change set lengths")}}}function jh(n,e,t=!1){let i=[],r=t?[]:null,s=new ai(n),o=new ai(e);for(let l=!1;;){if(s.done&&o.done)return r?it.createSet(i,r):bn.create(i);if(s.ins==0)Ye(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)Ye(i,0,o.ins,l),r&&Nn(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),c=i.length;if(s.ins==-1){let d=o.ins==-1?-1:o.off?0:o.ins;Ye(i,a,d,l),r&&d&&Nn(r,i,o.text)}else o.ins==-1?(Ye(i,s.off?0:s.len,a,l),r&&Nn(r,i,s.textBit(a))):(Ye(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&Nn(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>c),s.forward2(a),o.forward(a)}}}}var ai=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?ne.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?ne.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},ii=class n{constructor(e,t,i,r){this.from=e,this.to=t,this.flags=i,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new n(i,r,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return L.range(e,t,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return L.range(this.anchor,r,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return L.range(e.anchor,e.head)}static create(e,t,i,r){return new n(e,t,i,r)}},L=class n{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:n.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new n([this.main],0)}addRange(e,t=!0){return n.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,n.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new n(e.ranges.map(t=>ii.fromJSON(t)),e.main)}static single(e,t=e){return new n([n.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return n.normalized(e.slice(),t);i=s.to}return new n(e,t)}static cursor(e,t=0,i,r){return ii.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i)),r)}static range(e,t,i,r,s){let o=r==null?7:Math.min(6,r);return!s&&e!=t&&(s=t<e?1:-1),s&&(o|=s<0?8:16),t<e?ii.create(t,e,o|32,i):ii.create(e,t,o,i)}static undirectionalRange(e,t){return ii.create(e,t,64,void 0)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?n.range(a,l):n.range(l,a))}}return new n(e,t)}};function Kh(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Ta=0,$=class n{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=Ta++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new n(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Aa),!!e.static,e.enables)}of(e){return new Fi([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Fi(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Fi(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function Aa(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var Fi=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=Ta++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,c=!1,d=[];for(let u of this.dependencies)u=="doc"?a=!0:u=="selection"?c=!0:(((t=e[u.id])!==null&&t!==void 0?t:1)&1)==0&&d.push(e[u.id]);return{create(u){return u.values[o]=i(u),1},update(u,h){if(a&&h.docChanged||c&&(h.docChanged||h.selection)||ga(u,d)){let f=i(u);if(l?!Fh(f,u.values[o],r):!r(f,u.values[o]))return u.values[o]=f,1}return 0},reconfigure:(u,h)=>{let f,p=h.config.address[s];if(p!=null){let m=so(h,p);if(this.dependencies.every(w=>w instanceof $?h.facet(w)===u.facet(w):w instanceof Tt?h.field(w,!1)==u.field(w,!1):!0)||(l?Fh(f=i(u),m,r):r(f=i(u),m)))return u.values[o]=m,0}else f=i(u);return u.values[o]=f,1}}}get extension(){return this}};function Fh(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function ga(n,e){let t=!1;for(let i of e)Rr(n,i)&1&&(t=!0);return t}function bw(n,e,t){let i=t.map(a=>n[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let c=[];for(let d=0;d<i.length;d++){let u=so(a,i[d]);if(r[d]==2)for(let h of u)c.push(h);else c.push(u)}return e.combine(c)}return{create(a){for(let c of i)Rr(a,c);return a.values[o]=l(a),1},update(a,c){if(!ga(a,s))return 0;let d=l(a);return e.compare(d,a.values[o])?0:(a.values[o]=d,1)},reconfigure(a,c){let d=ga(a,i),u=c.config.facets[e.id],h=c.facet(e);if(u&&!d&&Aa(t,u))return a.values[o]=h,0;let f=l(a);return e.compare(f,h)?(a.values[o]=h,0):(a.values[o]=f,1)}}}var Ys=$.define({static:!0}),Tt=class n{constructor(e,t,i,r,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new n(Ta++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Ys).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>{let s=i.facet(Ys),o=r.facet(Ys),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Ys.of({field:this,create:e})]}get extension(){return this}},ri={lowest:4,low:3,default:2,high:1,highest:0};function Er(n){return e=>new io(e,n)}var Pr={highest:Er(ri.highest),high:Er(ri.high),default:Er(ri.default),low:Er(ri.low),lowest:Er(ri.lowest)},io=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},wn=class n{of(e){return new Lr(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Lr=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},ro=class n{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let h of ww(e,t,o))h instanceof Tt?r.push(h):(s[h.facet.id]||(s[h.facet.id]=[])).push(h);let l=Object.create(null),a=[],c=[];for(let h of r)l[h.id]=c.length<<1,c.push(f=>h.slot(f));let d=i?.config.facets;for(let h in s){let f=s[h],p=f[0].facet,m=d&&d[h]||[];if(f.every(w=>w.type==0))if(l[p.id]=a.length<<1|1,Aa(m,f))a.push(i.facet(p));else{let w=p.combine(f.map(b=>b.value));a.push(i&&p.compare(w,i.facet(p))?i.facet(p):w)}else{for(let w of f)w.type==0?(l[w.id]=a.length<<1|1,a.push(w.value)):(l[w.id]=c.length<<1,c.push(b=>w.dynamicSlot(b)));l[p.id]=c.length<<1,c.push(w=>bw(w,p,f))}}let u=c.map(h=>h(l));return new n(e,o,u,l,a,s)}};function ww(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let c=i[a].indexOf(o);c>-1&&i[a].splice(c,1),o instanceof Lr&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let c of o)s(c,l);else if(o instanceof Lr){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),s(c,l)}else if(o instanceof io)s(o.inner,o.prec);else if(o instanceof Tt)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Fi)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,ri.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(c==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(c,l)}}return s(n,ri.default),i.reduce((o,l)=>o.concat(l))}function Rr(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function so(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var Gh=$.define(),ba=$.define({combine:n=>n.some(e=>e),static:!0}),qh=$.define({combine:n=>n.length?n[0]:void 0,static:!0}),Xh=$.define(),Jh=$.define(),Yh=$.define(),Zh=$.define({combine:n=>n.length?n[0]:!1}),ht=class{constructor(e,t){this.type=e,this.value=t}static define(){return new wa}},wa=class{of(e){return new ht(this,e)}},ya=class{constructor(e){this.map=e}of(e){return new ke(this,e)}},ke=class n{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new n(this.type,t)}is(e){return this.type==e}static define(e={}){return new ya(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}};ke.reconfigure=ke.define();ke.appendConfig=ke.define();var Be=class n{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Kh(i,t.newLength),s.some(l=>l.type==n.time)||(this.annotations=s.concat(n.time.of(Date.now())))}static create(e,t,i,r,s,o){return new n(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(n.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};Be.time=ht.define();Be.userEvent=ht.define();Be.addToHistory=ht.define();Be.remote=ht.define();function yw(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i<n.length&&(r==e.length||e[r]>=n[i]))s=n[i++],o=n[i++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Qh(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=it.empty(e.changes.length),o=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:ke.mapEffects(n.effects,r).concat(ke.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function xa(n,e,t){let i=e.selection,r=zi(e.annotations);return e.userEvent&&(r=r.concat(Be.userEvent.of(e.userEvent))),{changes:e.changes instanceof it?e.changes:it.of(e.changes||[],t,n.facet(qh)),selection:i&&(i instanceof L?i:L.single(i.anchor,i.head)),effects:zi(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function ef(n,e,t){let i=xa(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=Qh(i,xa(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=Be.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return vw(t?xw(r):r)}function xw(n){let e=n.startState,t=!0;for(let r of e.facet(Xh)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:yw(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=it.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=Be.create(e,r,n.selection&&n.selection.map(s),ke.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(Jh);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof Be?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Be?n=s[0]:n=ef(e,zi(s),!1)}return n}function vw(n){let e=n.startState,t=e.facet(Yh),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=Qh(i,xa(e,s,n.changes.newLength),!0))}return i==n?n:Be.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var kw=[];function zi(n){return n==null?kw:Array.isArray(n)?n:[n]}var _t=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(_t||(_t={})),Sw=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,va;try{va=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Cw(n){if(va)return va.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||Sw.test(t)))return!0}return!1}function Tw(n){return e=>{if(!/\S/.test(e))return _t.Space;if(Cw(e))return _t.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return _t.Word;return _t.Other}}var Te=class n{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Rr(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Rr(this,i),so(this,i)}update(...e){return ef(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(wn.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,c)=>r.set(c,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(ke.reconfigure)?(t=null,i=l.value):l.is(ke.appendConfig)&&(t=null,i=zi(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=ro.resolve(i,r,this),s=new n(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,c)=>c.reconfigure(a,this),null).values);let o=e.startState.facet(ba)?e.newSelection:e.newSelection.asSingle();new n(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:L.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=zi(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),c=this.changes(a.changes),d=c.map(r);for(let h=0;h<l;h++)s[h]=s[h].map(d);let u=r.mapDesc(c,!0);s.push(a.range.map(u)),r=r.compose(d),o=ke.mapEffects(o,d).concat(ke.mapEffects(zi(a.effects),u))}return{changes:r,selection:L.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof it?e:it.of(e,this.doc.length,this.facet(n.lineSeparator))}toText(e){return ne.of(e.split(this.facet(n.lineSeparator)||fa))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Rr(this,t),so(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof Tt&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return n.create({doc:e.doc,selection:L.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=ro.resolve(e.extensions||[],new Map),i=e.doc instanceof ne?e.doc:ne.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||fa)),r=e.selection?e.selection instanceof L?e.selection:L.single(e.selection.anchor,e.selection.head):L.single(0);return Kh(r,i.length),t.staticFacet(ba)||(r=r.asSingle()),new n(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(n.tabSize)}get lineBreak(){return this.facet(n.lineSeparator)||`
721
+ `}get readOnly(){return this.facet(Zh)}phrase(e,...t){for(let i of this.facet(n.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(Gh))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return Tw(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=$e(t,o,!1);if(s(t.slice(a,o))!=_t.Word)break;o=a}for(;l<r;){let a=$e(t,l);if(s(t.slice(l,a))!=_t.Word)break;l=a}return o==l?null:L.range(o+i,l+i)}};Te.allowMultipleSelections=ba;Te.tabSize=$.define({combine:n=>n.length?n[0]:4});Te.lineSeparator=qh;Te.readOnly=Zh;Te.phrases=$.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});Te.languageData=Gh;Te.changeFilter=Xh;Te.transactionFilter=Jh;Te.transactionExtender=Yh;wn.reconfigure=ke.define();function Vi(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var tn=class{eq(e){return this==e}range(e,t=e){return Dr.create(e,t,this)}};tn.prototype.startSide=tn.prototype.endSide=0;tn.prototype.point=!1;tn.prototype.mapMode=ut.TrackDel;function Ma(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}var Dr=class n{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new n(e,t,i)}};function ka(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var Sa=class n{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return _i(this.to)}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,c=s[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return c>=0?o:l;c>=0?l=a:o=a+1}}between(e,t,i,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t,i,r,s){let o=[],l=[],a=[],c=-1,d=-1;e:for(let u=0;u<this.value.length;u++){let h=this.value[u],f=this.from[u]+e,p=this.to[u]+e,m,w;if(f==p){let b=t.mapPos(f,h.startSide,h.mapMode);if(b==null||(m=w=b,h.startSide!=h.endSide&&(w=t.mapPos(f,h.endSide),w<m)))continue}else if(m=t.mapPos(f,h.startSide),w=t.mapPos(p,h.endSide),m>w||m==w&&h.startSide>0&&h.endSide<=0)continue;if(!((w-m||h.endSide-h.startSide)<0))if(c<0&&(c=m),h.point&&(d=Math.max(d,w-m)),(m-i||h.startSide-r)>=0)o.push(h),l.push(m-c),a.push(w-c),i=w,r=h.endSide;else{if(m==w)for(let b=o.length;b>0;b--){if((m-(a[b-1]+c)||h.startSide-o[b-1].endSide)>=0){o.splice(b,0,h),l.splice(b,0,m-c),a.splice(b,0,w-c);continue e}if((m-(l[b-1]+c)||h.endSide-o[b-1].startSide)>0)break}s(m,w,h)}}return{mapped:o.length?new n(l,a,o,d):null,pos:c}}},he=class n{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new n(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(ka)),this.isEmpty)return t.length?n.of(t):this;let l=new oo(this,null,-1).goto(0),a=0,c=[],d=new li;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let u=t[a++];d.addInner(u.from,u.to,u.value,!1)||c.push(u)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&d.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(d.addInner(l.from,l.to,l.value,!1)||c.push(Dr.create(l.from,l.to,l.value))),l.next());return d.finishInner(this.nextLayer.isEmpty&&!c.length?n.empty:this.nextLayer.update({add:c,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],r=-1,s,o=(a,c,d)=>{s||(s=new li),s.addRange(a,c,d,!1)};for(let a=0;a<this.chunk.length;a++){let c=this.chunkPos[a],d=this.chunk[a],u=e.touchesRange(c,c+d.length);if(u===!1)r=Math.max(r,d.maxPoint),t.push(d),i.push(e.mapPos(c));else if(u===!0){let[h,f]=t.length?[_i(i)+_i(t).length,_i(_i(t).value).endSide]:[-1,-1],{mapped:p,pos:m}=d.map(c,e,h,f,o);p&&(r=Math.max(r,p.maxPoint),t.push(p),i.push(m))}}let l=this.nextLayer.map(e);return s&&(l=s.finishInner(l)),t.length==0?l:new n(i,t,l||n.empty,r)}between(e,t,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Or.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Or.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),l=t.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),a=zh(o,l,i),c=new si(o,a,s),d=new si(l,a,s);i.iterGaps((u,h,f)=>Wh(c,u,d,h,f,r)),i.empty&&i.length==0&&Wh(c,0,d,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(d=>!d.isEmpty&&t.indexOf(d)<0),o=t.filter(d=>!d.isEmpty&&e.indexOf(d)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=zh(s,o),a=new si(s,l,0).goto(i),c=new si(o,l,0).goto(i);for(;;){if(a.to!=c.to||!Ca(a.active,c.active)||a.point&&(!c.point||!Ma(a.point,c.point)))return!1;if(a.to>r)return!0;a.next(),c.next()}}static spans(e,t,i,r,s=-1){let o=new si(e,null,s).goto(t),l=t,a=o.openStart;for(;;){let c=Math.min(o.to,i);if(o.point){let d=o.activeForPoint(o.to),u=o.pointFrom<t?d.length+1:o.point.startSide<0?d.length:Math.min(d.length,a);r.point(l,c,o.point,d,u,o.pointRank),a=Math.min(o.openEnd(c),d.length)}else c>l&&(r.span(l,c,o.active,a),a=o.openEnd(c));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new li;for(let r of e instanceof Dr?[e]:t?Aw(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return n.empty;let t=_i(e);for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=n.empty;r=r.nextLayer)t=new n(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}};he.empty=new he([],[],null,-1);function _i(n){return n[n.length-1]}function Aw(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(ka(e,i)>0)return n.slice().sort(ka);e=i}return n}he.empty.nextLayer=he.empty;var li=class n{finishChunk(e){this.chunks.push(new Sa(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addRange(e,t,i,!0)}addRange(e,t,i,r){this.addInner(e,t,i,r)||(this.nextLayer||(this.nextLayer=new n)).addRange(e,t,i,r)}addInner(e,t,i,r){let s=e-this.lastTo||i.startSide-this.last.endSide;if(r&&s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(he.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=he.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function zh(n,e,t){let i=new Map;for(let s of n)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!t?.touchesRange(l,l+s.chunk[o].length)&&r.add(s.chunk[o])}return r}var oo=class{constructor(e,t,i,r=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},Or=class n{constructor(e){this.heap=e}static from(e,t=null,i=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&r.push(new oo(o,t,i,s));return r.length==1?r[0]:new n(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)ua(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)ua(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),ua(this.heap,0)}}};function ua(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1<n.length&&r.compare(n[i+1])>=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}var si=class{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Or.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Zs(this.active,e),Zs(this.activeTo,e),Zs(this.activeRank,e),this.minActive=Vh(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||r-this.activeTo[t])>0;)t++;Qs(this.active,t,i),Qs(this.activeTo,t,r),Qs(this.activeRank,t,s),e&&Qs(e,t,this.cursor.from),this.minActive=Vh(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Zs(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}};function Wh(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,l=i,a=i-e,c=!!s.boundChange;for(let d=!1;;){let u=n.to+a-t.to,h=u||n.endSide-t.endSide,f=h<0?n.to+a:t.to,p=Math.min(f,o);if(n.point||t.point?(n.point&&t.point&&Ma(n.point,t.point)&&Ca(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,p,n.point,t.point),d=!1):(d&&(s.boundChange(l),d=!1),p>l&&!Ca(n.active,t.active)&&s.compareRange(l,p,n.active,t.active),c&&p<o&&(u||n.openEnd(f)!=t.openEnd(f))&&(d=!0)),f>o)break;l=f,h<=0&&n.next(),h>=0&&t.next()}}function Ca(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!Ma(n[t],e[t]))return!1;return!0}function Zs(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function Qs(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function Vh(n,e){let t=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||n[r].endSide-n[t].endSide)<0&&(t=r,i=e[r]);return t}function ci(n,e,t=n.length){let i=0;for(let r=0;r<t&&r<n.length;)n.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=$e(n,r));return i}function tf(n,e,t,i){for(let r=0,s=0;;){if(s>=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=$e(n,r)}return i===!0?-1:n.length}var nf=typeof Symbol>"u"?"__\u037C":Symbol.for("\u037C"),Ea=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),rf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},At=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,c){let d=[],u=/^@(\w+)\b/.exec(o[0]),h=u&&u[1]=="keyframes";if(u&&l==null)return a.push(o[0]+";");for(let f in l){let p=l[f];if(/&/.test(f))s(f.split(/,\s*/).map(m=>o.map(w=>m.replace(/&/,w))).reduce((m,w)=>m.concat(w)),p,a);else if(p&&typeof p=="object"){if(!u)throw new RangeError("The value of a property ("+f+") should be a primitive value.");s(r(f),p,d,h)}else p!=null&&d.push(f.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(d.length||h)&&a.push((i&&!u&&!c?o.map(i):o).join(", ")+" {"+d.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
722
722
  `)}static newName(){let e=rf[nf]||1;return rf[nf]=e+1,"\u037C"+e.toString(36)}static mount(e,t,i){let r=e[Ea],s=i&&i.nonce;r?s&&r.setNonce(s):r=new Ra(e,s),r.mount(Array.isArray(t)?t:[t],e)}},sf=new Map,Ra=class{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=sf.get(i);if(s)return e[Ea]=s;this.sheet=new r.CSSStyleSheet,sf.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Ea]=this}mount(e,t){let i=this.sheet,r=0,s=0;for(let o=0;o<e.length;o++){let l=e[o],a=this.modules.indexOf(l);if(a<s&&a>-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),i)for(let c=0;c<l.rules.length;c++)i.insertRule(l.rules[c],r++)}else{for(;s<a;)r+=this.modules[s++].rules.length;r+=l.rules.length,s++}}if(i)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
723
- `;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var yn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},$i={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Tw=typeof navigator<"u"&&/Mac/.test(navigator.platform),Aw=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(_e=0;_e<10;_e++)yn[48+_e]=yn[96+_e]=String(_e);var _e;for(_e=1;_e<=24;_e++)yn[_e+111]="F"+_e;var _e;for(_e=65;_e<=90;_e++)yn[_e]=String.fromCharCode(_e+32),$i[_e]=String.fromCharCode(_e);var _e;for(lo in yn)$i.hasOwnProperty(lo)||($i[lo]=yn[lo]);var lo;function of(n){var e=Tw&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Aw&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?$i:yn)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var rt=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Ba=typeof document<"u"?document:{documentElement:{style:{}}},_a=/Edge\/(\d+)/.exec(rt.userAgent),Hf=/MSIE \d/.test(rt.userAgent),Ha=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(rt.userAgent),Io=!!(Hf||Ha||_a),lf=!Io&&/gecko\/(\d+)/i.test(rt.userAgent),Da=!Io&&/Chrome\/(\d+)/.exec(rt.userAgent),af="webkitFontSmoothing"in Ba.documentElement.style,Fa=!Io&&/Apple Computer/.test(rt.vendor),cf=Fa&&(/Mobile\/\w+/.test(rt.userAgent)||rt.maxTouchPoints>2),B={mac:cf||/Mac/.test(rt.platform),windows:/Win/.test(rt.platform),linux:/Linux|X11/.test(rt.platform),ie:Io,ie_version:Hf?Ba.documentMode||6:Ha?+Ha[1]:_a?+_a[1]:0,gecko:lf,gecko_version:lf?+(/Firefox\/(\d+)/.exec(rt.userAgent)||[0,0])[1]:0,chrome:!!Da,chrome_version:Da?+Da[1]:0,ios:cf,android:/Android\b/.test(rt.userAgent),webkit:af,webkit_version:af?+(/\bAppleWebKit\/(\d+)/.exec(rt.userAgent)||[0,0])[1]:0,safari:Fa,safari_version:Fa?+(/\bVersion\/(\d+(\.\d+)?)/.exec(rt.userAgent)||[0,0])[1]:0,tabSize:Ba.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Ac(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}var xo=Object.create(null);function Mc(n,e,t){if(n==e)return!0;n||(n=xo),e||(e=xo);let i=Object.keys(n),r=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function Mw(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function df(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function Ew(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let i=n.attributes[t];e[i.name]=i.value}return e}var _n=class{eq(e){return!1}updateDOM(e,t,i){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},Ge=(function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n})(Ge||(Ge={})),be=class extends tn{constructor(e,t,i,r){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Kr(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new fi(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=Ff(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new fi(e,i,r,t,e.widget||null,!0)}static line(e){return new Gr(e)}static set(e,t=!1){return he.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};be.none=he.empty;var Kr=class n extends be{constructor(e){let{start:t,end:i}=Ff(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Ac(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||xo}eq(e){return this==e||e instanceof n&&this.tagName==e.tagName&&Mc(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};Kr.prototype.point=!1;var Gr=class n extends be{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&Mc(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};Gr.prototype.mapMode=ut.TrackBefore;Gr.prototype.point=!0;var fi=class n extends be{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?ut.TrackBefore:ut.TrackAfter:ut.TrackDel}get type(){return this.startSide!=this.endSide?Ge.WidgetRange:this.startSide<=0?Ge.WidgetBefore:Ge.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&Rw(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};fi.prototype.point=!0;function Ff(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function Rw(n,e){return n==e||!!(n&&e&&n.compare(e))}function qi(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}var vo=class n extends tn{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof n&&this.tagName==e.tagName&&Mc(this.attributes,e.attributes)}static create(e){return new n(e.tagName,e.attributes||xo,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return he.of(e,t)}};vo.prototype.startSide=vo.prototype.endSide=-1;function qr(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function za(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function _r(n,e){if(!e.anchorNode)return!1;try{return za(n,e.anchorNode)}catch{return!1}}function Hr(n){return n.nodeType==3?Jr(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function Fr(n,e,t,i){return t?uf(n,e,t,i,-1)||uf(n,e,t,i,1):!1}function Hn(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function ko(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function uf(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:kn(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=Hn(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?kn(n):0}else return!1}}function kn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Xr(n,e){let{left:t,right:i}=n;if(t==i)return n;let r=e?t:i;return{left:r,right:r,top:n.top,bottom:n.bottom}}function Dw(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function zf(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function Lw(n,e,t,i,r,s,o,l){let a=n.ownerDocument,c=a.defaultView||window;for(let d=n,u=!1;d&&!u;)if(d.nodeType==1){let h,f=d==a.body,p=1,m=1;if(f)h=Dw(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(d).position)&&(u=!0),d.scrollHeight<=d.clientHeight&&d.scrollWidth<=d.clientWidth){d=d.assignedSlot||d.parentNode;continue}let v=d.getBoundingClientRect();({scaleX:p,scaleY:m}=zf(d,v)),h={left:v.left,right:v.left+d.clientWidth*p,top:v.top,bottom:v.top+d.clientHeight*m}}let w=0,b=0;if(r=="nearest")e.top<h.top+o?(b=e.top-(h.top+o),t>0&&e.bottom>h.bottom+b&&(b=e.bottom-h.bottom+o)):e.bottom>h.bottom-o&&(b=e.bottom-h.bottom+o,t<0&&e.top-b<h.top&&(b=e.top-(h.top+o)));else{let v=e.bottom-e.top,k=h.bottom-h.top;b=(r=="center"&&v<=k?e.top+v/2-k/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-k+o)-h.top}if(i=="nearest"?e.left<h.left+s?(w=e.left-(h.left+s),t>0&&e.right>h.right+w&&(w=e.right-h.right+s)):e.right>h.right-s&&(w=e.right-h.right+s,t<0&&e.left<h.left+w&&(w=e.left-(h.left+s))):w=(i=="center"?e.left+(e.right-e.left)/2-(h.right-h.left)/2:i=="start"==l?e.left-s:e.right-(h.right-h.left)+s)-h.left,w||b)if(f)c.scrollBy(w,b);else{let v=0,k=0;if(b){let N=d.scrollTop;d.scrollTop+=b/m,k=(d.scrollTop-N)*m}if(w){let N=d.scrollLeft;d.scrollLeft+=w/p,v=(d.scrollLeft-N)*p}e={left:e.left-v,top:e.top-k,right:e.right-v,bottom:e.bottom-k},v&&Math.abs(v-w)<1&&(i="nearest"),k&&Math.abs(k-b)<1&&(r="nearest")}if(f)break;(e.top<h.top||e.bottom>h.bottom||e.left<h.left||e.right>h.right)&&(e={left:Math.max(e.left,h.left),right:Math.min(e.right,h.right),top:Math.max(e.top,h.top),bottom:Math.min(e.bottom,h.bottom)}),d=d.assignedSlot||d.parentNode}else if(d.nodeType==11)d=d.host;else break}function Wf(n,e=!0){let t=n.ownerDocument,i=null,r=null;for(let s=n.parentNode;s&&!(s==t.body||(!e||i)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),e&&!i&&s.scrollWidth>s.clientWidth&&(i=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:i,y:r}}var Wa=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?kn(t):0),i,Math.min(e.focusOffset,i?kn(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}};function Vf(n){let e=[];for(let t=n;t;t=t.nodeType==11?t.host:t.parentNode)t.nodeType==1&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function $f(n,e=!0){for(let{node:t,left:i,top:r}of n)e&&t.scrollTop!=r&&(t.scrollTop=r),t.scrollLeft!=i&&(t.scrollLeft=i)}var di=null;B.safari&&B.safari_version>=26&&(di=!1);function Uf(n){if(n.setActive)return n.setActive();if(di)return n.focus(di);let e=Vf(n);n.focus(di==null?{get preventScroll(){return di={preventScroll:!0},!0}}:void 0),di||(di=!1,$f(e))}var hf;function Jr(n,e,t=e){let i=hf||(hf=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Xi(n,e,t,i){let r={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,n.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,n.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Ow(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Pw(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,kn(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=kn(t))}else{if(t==n)return!0;i=Hn(t),t=t.parentNode}}function jf(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function Kf(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=kn(t)}else if(t.parentNode&&!ko(t))i=Hn(t),t=t.parentNode;else return null}}function Gf(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i<t.nodeValue.length)return{node:t,offset:i};if(t.nodeType==1&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!ko(t))i=Hn(t)+1,t=t.parentNode;else return null}}var rn=class n{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new n(e.parentNode,Hn(e),t)}static after(e,t){return new n(e.parentNode,Hn(e)+1,t)}},we=(function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n})(we||(we={})),pi=we.LTR,Ec=we.RTL;function qf(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}var Iw=qf("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Nw=qf("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Va=Object.create(null),nn=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);Va[e]=t,Va[t]=-e}function Xf(n){return n<=247?Iw[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?Nw[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}var Bw=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,Rt=class{get dir(){return this.level%2?Ec:pi}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(s<0||(r!=0?r<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function Jf(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let i=n[t],r=e[t];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!Jf(i.inner,r.inner))return!1}return!0}var fe=[];function _w(n,e,t,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:t,a=s?256:r;for(let c=o,d=a,u=a;c<l;c++){let h=Xf(n.charCodeAt(c));h==512?h=d:h==8&&u==4&&(h=16),fe[c]=h==4?2:h,h&7&&(u=h),d=h}for(let c=o,d=a,u=a;c<l;c++){let h=fe[c];if(h==128)c<l-1&&d==fe[c+1]&&d&24?h=fe[c]=d:fe[c]=256;else if(h==64){let f=c+1;for(;f<l&&fe[f]==64;)f++;let p=c&&d==8||f<t&&fe[f]==8?u==1?1:8:256;for(let m=c;m<f;m++)fe[m]=p;c=f-1}else h==8&&u==1&&(fe[c]=1);d=h,h&7&&(u=h)}}}function Hw(n,e,t,i,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let c=o?i[o-1].to:e,d=o<i.length?i[o].from:t;for(let u=c,h,f,p;u<d;u++)if(f=Va[h=n.charCodeAt(u)])if(f<0){for(let m=l-3;m>=0;m-=3)if(nn[m+1]==-f){let w=nn[m+2],b=w&2?r:w&4?w&1?s:r:0;b&&(fe[u]=fe[nn[m]]=b),l=m;break}}else{if(nn.length==189)break;nn[l++]=u,nn[l++]=h,nn[l++]=a}else if((p=fe[u])==2||p==1){let m=p==r;a=m?0:1;for(let w=l-3;w>=0;w-=3){let b=nn[w+2];if(b&2)break;if(m)nn[w+2]|=2;else{if(b&4)break;nn[w+2]|=4}}}}}function Fw(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,l=r<t.length?t[r].from:e;for(let a=o;a<l;){let c=fe[a];if(c==256){let d=a+1;for(;;)if(d==l){if(r==t.length)break;d=t[r++].to,l=r<t.length?t[r].from:e}else if(fe[d]==256)d++;else break;let u=s==1,h=(d<e?fe[d]:i)==1,f=u==h?u?1:2:i;for(let p=d,m=r,w=m?t[m-1].to:n;p>a;)p==w&&(p=t[--m].from,w=m?t[m-1].to:n),fe[--p]=f;a=d}else s=c,a++}}}function $a(n,e,t,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let a=e,c=0;a<t;){let d=!0,u=!1;if(c==s.length||a<s[c].from){let m=fe[a];m!=l&&(d=!1,u=m==16)}let h=!d&&l==1?[]:null,f=d?i:i+1,p=a;e:for(;;)if(c<s.length&&p==s[c].from){if(u)break e;let m=s[c];if(!d)for(let w=m.to,b=c+1;;){if(w==t)break e;if(b<s.length&&s[b].from==w)w=s[b++].to;else{if(fe[w]==l)break e;break}}if(c++,h)h.push(m);else{m.from>a&&o.push(new Rt(a,m.from,f));let w=m.direction==pi!=!(f%2);Ua(n,w?i+1:i,r,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(d?fe[p]!=l:fe[p]==l))break;p++}h?$a(n,a,p,i+1,r,h,o):a<p&&o.push(new Rt(a,p,f)),a=p}else for(let a=t,c=s.length;a>e;){let d=!0,u=!1;if(!c||a>s[c-1].to){let m=fe[a-1];m!=l&&(d=!1,u=m==16)}let h=!d&&l==1?[]:null,f=d?i:i+1,p=a;e:for(;;)if(c&&p==s[c-1].to){if(u)break e;let m=s[--c];if(!d)for(let w=m.from,b=c;;){if(w==e)break e;if(b&&s[b-1].to==w)w=s[--b].from;else{if(fe[w-1]==l)break e;break}}if(h)h.push(m);else{m.to<a&&o.push(new Rt(m.to,a,f));let w=m.direction==pi!=!(f%2);Ua(n,w?i+1:i,r,m.inner,m.from,m.to,o),a=m.from}p=m.from}else{if(p==e||(d?fe[p-1]!=l:fe[p-1]==l))break;p--}h?$a(n,p,a,i+1,r,h,o):p<a&&o.push(new Rt(p,a,f)),a=p}}function Ua(n,e,t,i,r,s,o){let l=e%2?2:1;_w(n,r,s,i,l),Hw(n,r,s,i,l),Fw(r,s,i,l),$a(n,r,s,e,t,i,o)}function zw(n,e,t){if(!n)return[new Rt(0,0,e==Ec?1:0)];if(e==pi&&!t.length&&!Bw.test(n))return Yf(n.length);if(t.length)for(;n.length>fe.length;)fe[fe.length]=256;let i=[],r=e==pi?0:1;return Ua(n,r,r,t,0,n.length,i),i}function Yf(n){return[new Rt(0,n,0)]}var Zf="";function Ww(n,e,t,i,r){var s;let o=i.head-n.from,l=Rt.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),a=e[l],c=a.side(r,t);if(o==c){let h=l+=r?1:-1;if(h<0||h>=e.length)return null;a=e[l=h],o=a.side(!r,t),c=a.side(r,t)}let d=$e(n.text,o,a.forward(r,t));(d<a.from||d>a.to)&&(d=c),Zf=n.text.slice(Math.min(o,d),Math.max(o,d));let u=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return u&&d==c&&u.level+(r?0:1)<a.level?D.cursor(u.side(!r,t)+n.from,u.forward(r,t)?1:-1,u.level):D.cursor(d+n.from,a.forward(r,t)?-1:1,a.level)}function Vw(n,e,t){for(let i=e;i<t;i++){let r=Xf(n.charCodeAt(i));if(r==1)return pi;if(r==2||r==4)return Ec}return pi}var Qf=V.define(),ep=V.define(),tp=V.define(),np=V.define(),ja=V.define(),ip=V.define(),rp=V.define(),Rc=V.define(),Dc=V.define(),sp=V.define({combine:n=>n.some(e=>e)}),op=V.define({combine:n=>n.some(e=>e)}),lp=V.define(),zr=class n{constructor(e,t,i,r,s,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new n(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new n(D.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},ao=ve.define({map:(n,e)=>n.map(e)}),ap=ve.define();function _t(n,e,t){let i=n.facet(np);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}var xn=V.define({combine:n=>n.length?n[0]:!0}),$w=0,ji=V.define({combine(n){return n.filter((e,t)=>{for(let i=0;i<t;i++)if(n[i].plugin==e.plugin)return!1;return!0})}}),Ft=class n{constructor(e,t,i,r,s){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=r,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(ji.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(ji.of({plugin:this,arg:e}))}static define(e,t){let{eventHandlers:i,eventObservers:r,provide:s,decorations:o}=t||{};return new n($w++,e,i,r,l=>{let a=[];return o&&a.push(No.of(c=>{let d=c.plugin(l);return d?o(d):be.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return n.define((i,r)=>new e(i,r),t)}},Wr=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(_t(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){_t(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){_t(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},cp=V.define(),Lc=V.define(),No=V.define(),dp=V.define(),Oc=V.define(),Yr=V.define(),up=V.define();function ff(n,e){let t=n.state.facet(up);if(!t.length)return t;let i=t.map(s=>s instanceof Function?s(n):s),r=[];return he.spans(i,e.from,e.to,{point(){},span(s,o,l,a){let c=s-e.from,d=o-e.from,u=r;for(let h=l.length-1;h>=0;h--,a--){let f=l[h].spec.bidiIsolate,p;if(f==null&&(f=Vw(e.text,c,d)),a>0&&u.length&&(p=u[u.length-1]).to==c&&p.direction==f)p.to=d,u=p.inner;else{let m={from:c,to:d,direction:f,inner:[]};u.push(m),u=m.inner}}}}),r}var hp=V.define();function fp(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(hp)){let o=s(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}var Ir=V.define(),Ht=class n{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new n(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toA<i.fromA)break;i=i.join(r),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let r=0,s=0,o=0;;){let l=r<e.length?e[r].fromB:1e9,a=s<t.length?t[s]:1e9,c=Math.min(l,a);if(c==1e9)break;let d=c+o,u=c,h=d;for(;;)if(s<t.length&&t[s]<=u){let f=t[s+1];s+=2,u=Math.max(u,f);for(let p=r;p<e.length&&e[p].fromB<=u;p++)o=e[p].toA-e[p].toB;h=Math.max(h,f+o)}else if(r<e.length&&e[r].fromB<=u){let f=e[r++];u=Math.max(u,f.toB),h=Math.max(h,f.toA),o=f.toA-f.toB}else break;i.push(new n(d,h,c,u))}return i}},So=class n{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=it.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new Ht(s,o,l,a))),this.changedRanges=r}static create(e,t,i){return new n(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},Uw=[],Te=class{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Uw}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&Mw(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let r of this.children){if(r==e)return i;i+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=Hn(this.dom),r=this.length?e>0:t>0;return new rn(this.parent.dom,i+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Yi)return e;return null}static get(e){return e.cmTile}},Ji=class extends Te{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,r,s=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,r=i?i.nextSibling:t.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==t)for(;r&&r!=l.dom;)r=pf(r);else t.insertBefore(l.dom,r);i=l.dom}for(r=i?i.nextSibling:t.firstChild,s&&r&&(s.written=!0);r;)r=pf(r);this.length=o}};function pf(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Yi=class extends Ji{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Te.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,r=0,s=0;;)if(r==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&s++,r=t.pop()}else{let o=i.children[r++];if(o instanceof vn)t.push(r),i=o,r=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,t){let i,r=-1,s,o=-1;if(this.blockTiles((l,a)=>{let c=a+l.length;if(e>=a&&e<=c){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(a<e||e==c&&(t<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,r=e-a),(c>e||e==a&&(t>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!i&&!s)throw new Error("No tile at position "+e);return i&&t<0||!s?{tile:i,offset:r}:{tile:s,offset:o}}},vn=class n extends Ji{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new n(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}},Zi=class n extends Ji{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let r=new n(t||document.createElement("div"),e);return(!t||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,i){let r=null,s=-1,o=null,l=-1;function a(d,u){for(let h=0,f=0;h<d.children.length&&f<=u;h++){let p=d.children[h],m=f+p.length;m>=u&&(p.isComposite()?a(p,u-f):(!o||o.isHidden&&(t>0&&!(o.flags&32)||i&&Kw(o,p)))&&(m>u||p.flags&32&&t<=1)?(o=p,l=u-f):(f<u||p.flags&16&&!p.isHidden&&t>=-1)&&(r=p,s=u-f)),f=m}}a(this,e);let c=(t<0?r:o)||r||o;return c?{tile:c,offset:c==r?s:l}:null}coordsIn(e,t,i){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,i):jw(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:r,offset:s}=i;if(this.dom.contains(r.dom))return r.isText()?new rn(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:t);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new rn(a.dom,0);a==i.tile&&(l=!0)}}return new rn(this.dom,0)}};function jw(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=Hr(e);return t[t.length-1]||null}function Kw(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.top<t.bottom}var ft=class n extends Ji{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new n(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}},ui=class n extends Te{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,i){let r=this.dom.nodeValue.length;e>r&&(e=r);let s=e,o=e,l=0;e==0&&t<0||e==r&&t>=0?B.chrome||B.gecko||(e?(s--,l=1):o<r&&(o++,l=-1)):t<0?s--:o<r&&o++;let a=Jr(this.dom,s,o).getClientRects();if(!a.length)return null;let c=a[(l?l<0:t>=0)?0:a.length-1];return B.safari&&!l&&c.width==0&&(c=Array.prototype.find.call(a,d=>d.width)||c),i==null?c:Xr(c,(l?l>0:t<0)==i)}static of(e,t){let i=new n(t||document.createTextNode(e),e);return t||(i.flags|=2),i}},mi=class n extends Te{constructor(e,t,i,r){super(e,t,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(i)return Xr(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top<o.bottom);a+=l?-1:1);return Xr(o,!l)}}get overrideDOMText(){if(!this.length)return ne.empty;let{root:e}=this;if(!e)return ne.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,r,s){return s||(s=e.toDOM(t),e.editable||(s.contentEditable="false")),new n(s,i,e,r)}},Qi=class extends Te{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return ne.empty}coordsIn(e,t,i){let r=this.dom.getBoundingClientRect();return i==null?r:Xr(r,t>0==i)}},Ka=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(s==r.children.length){if(!e&&!l.length)break;i&&i.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let a=r.children[s],c=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!i||i.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!c,s++,e-=a.length):(l.push({tile:r,index:s}),r=a,s=0,i&&a.isComposite()&&i.enter(a))}else{let a=r.length;if(s<a&&e){let c=Math.min(e,a-s);i&&i.skip(r,s,s+c),e-=c,s+=c}if(s==a)o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++;else if(!e)break}return this.tile=r,this.index=s,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},Ga=class{constructor(e,t,i,r){this.from=e,this.to=t,this.wrapper=i,this.rank=r}},qa=class{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,r){var s;this.flushBuffer();let o=this.ensureMarks(t,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new ui(l.dom,l.text+e);a.parent=o}else o.append(r||ui.of(e,(s=this.cache.find(ui))===null||s===void 0?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?La(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=i;for(let l=t.marks.length-1;l>=0;l--){let a=t.marks[l],c=r.lastChild;if(c instanceof ft&&c.mark.eq(a.mark))c.dom!=a.dom&&c.setDOM(La(a.dom)),r=c;else{let{dom:d}=a;this.cache.reused.get(a)&&Te.get(a.dom)&&(d=La(a.dom));let u=ft.of(a.mark,d);r.append(u),r=u}this.cache.reused.set(a,2)}let s=Te.get(e.text);s&&this.cache.reused.set(s,2);let o=new ui(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,r.append(o)}addInlineWidget(e,t,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(t,i);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=pp);let r=Zi.start(e,t||((i=this.cache.find(Zi))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(t>0&&(l=r.lastChild)&&l instanceof ft&&l.mark.eq(o))r=l,t--;else{let a=ft.of(o,(i=this.cache.find(ft,c=>c.mark.eq(o)))===null||i===void 0?void 0:i.dom);r.append(a),r=a,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!mf(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(B.ios&&mf(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Oa,0,32)||new mi(Oa.toDOM(),0,Oa,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,i=new Ga(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-i.rank||this.wrappers[r-1].to-i.to)<0;)r--;this.wrappers.splice(r,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let r=t.lastChild;if(i.from<this.pos&&r instanceof vn&&r.wrapper.eq(i.wrapper))t=r;else{let s=vn.of(i.wrapper,(e=this.cache.find(vn,o=>o.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Qi,void 0,1);return i&&(i.flags=t),i||new Qi(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},Xa=class{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}},Co=[mi,Zi,ui,ft,Qi,vn,Yi];for(let n=0;n<Co.length;n++)Co[n].bucket=n;var Ja=class{constructor(e){this.view=e,this.buckets=Co.map(()=>[]),this.index=Co.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let r=e.bucket,s=this.buckets[r],o=this.index[r];for(let l=0;l<s.length;l++){let a=(l+o)%s.length,c=s[a];if((!t||t(c))&&!this.reused.has(c))return s.splice(a,1),a<o&&this.index[r]--,this.reused.set(c,i),c}return null}findWidget(e,t,i){let r=this.buckets[0];if(r.length)for(let s=0,o=0;;s++){if(s==r.length){if(o)return null;o=1,s=0}let l=r[s];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view,l.widget)))return r.splice(s,1),s<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new mi(l.dom,t,e,l.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},Ya=class{constructor(e,t,i,r,s){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new Ja(e),this.text=new Xa(e.state.doc),this.builder=new qa(this.cache,new Yi(e,e.contentDOM),he.iter(i)),this.cache.reused.set(t,2),this.old=new Ka(t),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let r=0,s=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>r){let c=a-r;this.preserve(c,!o,!l),r=a,s+=c}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(s,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(s,l.toB)),s=l.toB,r=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let r=Xw(this.old),s=this.openMarks;this.old.advance(e,i?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let c=a>0||l<o.length?mi.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);c.flags&256?(c.flags&=-2,this.builder.addBlockWidget(c)):(this.builder.ensureLine(null),this.builder.addInlineWidget(c,r,s),s=r.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,r,s,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),r,s)),s=r.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Qi)this.cache.add(o);else if(o instanceof ft)this.builder.ensureLine(null),this.builder.addMark(o,r,s),this.cache.reused.set(o,1),s=r.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof ft&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof ft&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,r=this.builder,s=-1,o=he.spans(this.decorations,e,t,{point:(l,a,c,d,u,h)=>{if(c instanceof fi){if(this.disallowBlockEffectsFor[h]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=d.length,u>d.length)r.continueWidget(a-l);else{let f=c.widget||(c.block?Fn.block:Fn.inline),p=Gw(c),m=this.cache.findWidget(f,a-l,p)||mi.of(f,this.view,a-l,p);c.block?(c.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(m)):(r.ensureLine(i),r.addInlineWidget(m,d,u))}i=null}else i=qw(i,c);a>l&&this.text.skip(a-l)},span:(l,a,c,d)=>{for(let u=l;u<a;){let h=this.text.next(Math.min(512,a-u));h==null?(r.addLineStartIfNotCovered(i),r.addBreak(),u++):(r.ensureLine(i),r.addText(h,c,u==l?d:c.length),u+=h.length),i=null}s=c.length}});s>-1&&(this.openWidget=o>s),this.openWidget||r.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let r=e.parentNode;;r=r.parentNode){let s=Te.get(r);if(r==this.view.contentDOM)break;s instanceof ft?t.push(s):s?.isLine()?i=s:s instanceof vn||(r.nodeName=="DIV"&&!i?i=new Zi(r,pp):i||t.push(ft.of(new Kr({tagName:r.nodeName.toLowerCase(),attributes:Ew(r)}),r)))}return i?{line:i,marks:t}:null}};function mf(n,e){let t=i=>{for(let r of i.children)if((e?r.isText():r.length)||t(r))return!0;return!1};return t(n)}function Gw(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}var pp={class:"cm-line"};function qw(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&Ac(t,n),i&&(n.class+=" "+i)),n}function Xw(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof ft&&e.push(i.mark)}return e}function La(n){let e=Te.get(n);return e&&e.setDOM(n.cloneNode()),n}var Fn=class extends _n{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};Fn.inline=new Fn("span");Fn.block=new Fn("div");var Oa=new class extends _n{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},To=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=be.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Yi(e,e.contentDOM),this.updateInner([new Ht(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:d,toA:u})=>u<this.minWidthFrom||d>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!iy(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?Yw(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:d,to:u}=this.hasComposition;i=new Ht(d,u,e.changes.mapPos(d,-1),e.changes.mapPos(u,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(B.ie||B.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=ey(o,this.decorations,e.changes);a.length&&(i=Ht.extendWithRanges(i,a));let c=ty(l,this.blockWrappers,e.changes);return c.length&&(i=Ht.extendWithRanges(i,c)),s&&!i.some(d=>d.fromA<=s.range.fromA&&d.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new Ya(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Te.get(t.text)&&l.cache.reused.set(Te.get(t.text),2),this.tile=l.run(e,t),Za(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=B.chrome||B.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof Vr&&r.push(s.dom);i.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(ap)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,r=this.view.root.activeElement,s=r==i,o=!s&&!(this.view.state.facet(xn)||i.tabIndex>-1)&&_r(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(s||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,c,d;if(a.empty?d=c=this.inlineDOMNearPos(a.anchor,a.assoc||1):(d=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),c=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),B.gecko&&a.empty&&!this.hasComposition&&Jw(c)){let h=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(h,c.node.childNodes[c.offset]||null)),c=d=new rn(h,0),l=!0}let u=this.view.observer.selectionRange;(l||!u.focusNode||(!Fr(c.node,c.offset,u.anchorNode,u.anchorOffset)||!Fr(d.node,d.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,a))&&(this.view.observer.ignore(()=>{B.android&&B.chrome&&i.contains(u.focusNode)&&ny(u.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let h=qr(this.view.root);if(h)if(a.empty){if(B.gecko){let f=Zw(c.node,c.offset);if(f&&f!=3){let p=(f==1?Kf:Gf)(c.node,c.offset);p&&(c=new rn(p.node,p.offset))}}h.collapse(c.node,c.offset),a.bidiLevel!=null&&h.caretBidiLevel!==void 0&&(h.caretBidiLevel=a.bidiLevel)}else if(h.extend){h.collapse(c.node,c.offset);try{h.extend(d.node,d.offset)}catch{}}else{let f=document.createRange();a.anchor>a.head&&([c,d]=[d,c]),f.setEnd(d.node,d.offset),f.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(f)}o&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,d)),this.impreciseAnchor=c.precise?null:new rn(u.anchorNode,u.anchorOffset),this.impreciseHead=d.precise?null:new rn(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Fr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=qr(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!a||!c||a.bottom>c.top)return;let d=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(d.node,d.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&i.collapse(r,s)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let s;if(e==i.dom)s=i.dom.childNodes[t];else{let o=kn(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==i.dom.firstChild)return r;for(;s&&!Te.get(s);)s=s.nextSibling;if(!s)return r+i.length;for(let o=0,l=r;;o++){let a=i.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?r+t:r+(t?i.length:0):r}domAtPos(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(r,t):i.domIn(r,t)}inlineDOMNearPos(e,t){let i,r=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((c,d)=>{if(c.isWidget()){if(c.flags&32&&d>=e)return!0;c.flags&16&&(s=!0)}else{let u=d+c.length;if(d<=e&&(i=c,r=e-d,s=u<e),u>=e&&!o&&(o=c,l=e-d,a=d>e),d>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(s&&o?i=null:a&&i&&(o=null),i&&t<0||!o?i.domIn(r,t):o.domIn(l,t))}coordsAt(e,t,i){let{tile:r,offset:s}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof Vr?null:r.coordsInWidget(s,t,!0):r.coordsIn(s,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=r(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&o<s.length){let l=$e(s.text,o);if(l==o)return null;let a=Jr(s.dom,o,l).getClientRects();for(let c=0;c<a.length;c++){let d=a[c];if(c==a.length-1||d.top<d.bottom&&d.left<d.right)return d}}return null}return r(t,i)}measureVisibleLineHeights(e){let t=[],{from:i,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==we.LTR,c=0,d=(u,h,f)=>{for(let p=0;p<u.children.length&&!(h>r);p++){let m=u.children[p],w=h+m.length,b=m.dom.getBoundingClientRect(),{height:v}=b;if(f&&!p&&(c+=b.top-f.top),m instanceof vn)w>i&&d(m,h,b);else if(h>=i&&(c>0&&t.push(-c),t.push(v+c),c=0,o)){let k=m.dom.lastChild,N=k?Hr(k):[];if(N.length){let S=N[N.length-1],C=a?S.right-b.left:b.right-S.left;C>l&&(l=C,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=w)}}f&&p==u.children.length-1&&(c+=f.bottom-b.bottom),h=w+m.breakAfter}};return d(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?we.RTL:we.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let c of o.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let d=Hr(c.dom);if(d.length!=1)return;l+=d[0].width,a=d[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),i,r,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=Hr(t.firstChild)[0];i=t.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(be.replace({widget:new Vr(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return be.set(e)}updateDeco(){let e=1,t=this.view.state.facet(No).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),i=!1,r=this.view.state.facet(Oc).map((s,o)=>{let l=typeof s=="function";return l&&(i=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=i,t.push(he.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(dp).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(lp))try{if(c(this.view,e.range,e))return!0}catch(d){_t(this.view.state,d,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=fp(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(Lw(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==we.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.visualViewport.offsetTop)){let c=this.view.docView.lineAt(t.head,1);if(c){let d=Vf(c.dom);c.dom.scrollIntoView({block:"nearest"}),$f(d,!1)}}}lineHasWidget(e){let t=i=>i.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Za(this.tile)}};function Za(n,e){let t=e?.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)Za(i,e)}}function Jw(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function mp(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=Kf(t.focusNode,t.focusOffset),r=Gf(t.focusNode,t.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let l=Te.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(n.docView.lastCompositionAfterCursor){let a=Te.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(s=r)}}if(n.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function Yw(n,e,t){let i=mp(n,t);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new Ht(a.mapPos(s),a.mapPos(o),s,o),text:r}}function Zw(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}var Qw=class{constructor(){this.changes=[]}compareRange(e,t){qi(e,t,this.changes)}comparePoint(e,t){qi(e,t,this.changes)}boundChange(e){qi(e,e,this.changes)}};function ey(n,e,t){let i=new Qw;return he.compare(n,e,t,i),i.changes}var Qa=class{constructor(){this.changes=[]}compareRange(e,t){qi(e,t,this.changes)}comparePoint(){}boundChange(e){qi(e,e,this.changes)}};function ty(n,e,t){let i=new Qa;return he.compare(n,e,t,i),i.changes}function ny(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function iy(n,e){let t=!1;return e&&n.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}var Vr=class extends _n{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function ry(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return D.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=$e(r.text,s,!1):l=$e(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let c=$e(r.text,o,!1);if(i(r.text.slice(c,o))!=a)break;o=c}for(;l<r.length;){let c=$e(r.text,l);if(i(r.text.slice(l,c))!=a)break;l=c}return D.undirectionalRange(o+r.from,l+r.from)}function sy(n,e,t,i,r){let s=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(n.defaultLineHeight-l)*.5)/l);s+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+tf(o,s,n.state.tabSize)}function ec(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let s of i.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!r||s.type==Ge.Text&&(r.type!=s.type||(t<0?s.from<e:s.to>e)))&&(r=s)}}return r||i}return i}function oy(n,e,t,i){let r=ec(n,e.head,e.assoc||-1),s=!i||r.type!=Ge.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let l=n.dom.getBoundingClientRect(),a=n.textDirectionAt(r.from),c=n.posAtCoords({x:t==(a==we.LTR)?l.right-1:l.left+1,y:(s.top+s.bottom)/2});if(c!=null)return D.cursor(c,t?-1:1)}let o=n.state.doc.lineAt(e.head);return(t?o.to==r.to:o.from==r.from)?n.visualLineSide(o,t):D.cursor(t?r.to:r.from,t?-1:1)}function gf(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let l=e,a=null;;){let c=Ww(r,s,o,l,t),d=Zf;if(!c){if(r.number==(t?n.state.doc.lines:1))return l;d=`
724
- `,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),c=n.visualLineSide(r,!t)}if(a){if(!a(d))return l}else{if(!i)return c;a=i(d)}l=c}}function ly(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==Nt.Space&&(r=o),r==o}}function ay(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return D.cursor(r,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),c=n.coordsAtPos(r,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),d=n.documentTop;if(c)o==null&&(o=c.left-a.left),l=s<0?c.top:c.bottom;else{let p=n.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+d}let u=a.left+o,h=n.viewState.heightOracle.textHeight>>1,f=i??h;for(let p=0;;p+=h){let m=l+(f+p)*s,w=tc(n,{x:u,y:m},!1,s);if(t?m>a.bottom:m<a.top)return D.cursor(w.pos,w.assoc);let b=n.coordsAtPos(w.pos,w.assoc),v=b?(b.top+b.bottom)/2:0;if(!b||(t?v>l:v<l))return D.cursor(w.pos,w.assoc,void 0,o)}}function $r(n,e,t){for(;;){let i=0;for(let r of n)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=i||t||(e-s<o-e?-1:1);e=a<0?s:o,i=a}});if(!i)return e}}function gp(n,e){let t=null;for(let i=0;i<e.ranges.length;i++){let r=e.ranges[i],s=null;if(r.empty){let o=$r(n,r.from,0);o!=r.from&&(s=D.cursor(o,-1))}else{let o=$r(n,r.from,-1),l=$r(n,r.to,1);(o!=r.from||l!=r.to)&&(r.undirectional?s=D.undirectionalRange(r.from,r.to):s=D.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(t||(t=e.ranges.slice()),t[i]=s)}return t?D.create(t,e.mainIndex):e}function Pa(n,e,t){let i=$r(n.state.facet(Yr).map(r=>r(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:D.cursor(i,i<t.from?1:-1)}var Et=class{constructor(e,t){this.pos=e,this.assoc=t}};function tc(n,e,t,i){let r=n.contentDOM.getBoundingClientRect(),s=r.top+n.viewState.paddingTop,{x:o,y:l}=e,a=l-s,c;for(;;){if(a<0)return new Et(0,1);if(a>n.viewState.docHeight)return new Et(n.state.doc.length,-1);if(c=n.elementAtHeight(a),i==null)break;if(c.type==Ge.Text){if(i<0?c.to<n.viewport.from:c.from>n.viewport.to)break;let h=n.docView.coordsAt(i<0?c.from:c.to,i>0?-1:1);if(h&&(i<0?h.top<=a+s:h.bottom>=a+s))break}let u=n.viewState.heightOracle.textHeight/2;a=i>0?c.bottom+u:c.top-u}if(n.viewport.from>=c.to||n.viewport.to<=c.from){if(t)return null;if(c.type==Ge.Text){let u=sy(n,r,c,o,l);return new Et(u,u==c.from?1:-1)}}if(c.type!=Ge.Text)return a<(c.top+c.bottom)/2?new Et(c.from,1):new Et(c.to,-1);let d=n.docView.lineAt(c.from,2);return(!d||d.length!=c.length)&&(d=n.docView.lineAt(c.from,-2)),new nc(n,o,l,n.textDirectionAt(c.from)).scanTile(d,c.from)}var nc=class{constructor(e,t,i,r){this.view=e,this.x=t,this.y=i,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:i,spans:r}=this.bidiSpansAt(e);return r[Rt.find(r,e-i.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:i,spans:r}=this.bidiSpansAt(e);return r[Rt.find(r,e-i.from,-1,t)].dir}bidiIn(e,t){let{spans:i,line:r}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from<t)}scan(e,t,i=!1){let r=0,s=e.length-1,o=new Set,l=this.bidiIn(e[0],e[s]),a,c,d=-1,u=1e9,h;e:for(;r<s;){let p=s-r,m=r+s>>1;t:if(o.has(m)){for(let v=1;v<p;v++){let k=m+v;if(k>=s&&(k-=p),!o.has(k)){m=k;break t}}break e}o.add(m);let w=t(m),b=0;if(w)for(let v=0;v<w.length;v++){let k=w[v];if(!(k.width==0&&w.length>1))if(k.bottom<this.y)(!a||a.bottom<k.bottom)&&(a=k),b=1;else if(k.top>this.y)(!c||c.top>k.top)&&(c=k),b=-1;else{let N=k.left>this.x?this.x-k.left:k.right<this.x?this.x-k.right:0,S=Math.abs(N);S<u&&(d=m,u=S,h=k),N&&(b=N<0==(this.baseDir==we.LTR)?-1:1)}}b==-1&&(!l||this.baseDirAt(e[m],1))?s=m:b==1&&(!l||this.baseDirAt(e[m+1],-1))&&(r=m+1)}if(!h){if(!c&&!a)return{i:0,after:!1};let p=a&&(!c||this.y-a.bottom<c.top-this.y)?a:c;return this.y=(p.top+p.bottom)/2,this.scan(e,t,!0)}if(u&&!i){let{top:p,bottom:m}=h;if(a&&a.bottom>(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,t,!0);if(c&&c.top<(p+m+m)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(l?this.dirAt(e[d],1):this.baseDir)==we.LTR;return{i:d,after:this.x>(h.left+h.right)/2==f}}scanText(e,t){let i=[];for(let s=0;s<e.length;s=$e(e.text,s))i.push(t+s);i.push(t+e.length);let r=this.scan(i,s=>{let o=i[s]-t,l=i[s+1]-t;return Jr(e.dom,o,l).getClientRects()});return r.after?new Et(i[r.i+1],-1):new Et(i[r.i],1)}scanTile(e,t){if(!e.length)return new Et(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let i=[t];for(let l=0,a=t;l<e.children.length;l++)i.push(a+=e.children[l].length);let r=this.scan(i,l=>{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Jr(a.dom,0,a.length)).getClientRects()}),s=e.children[r.i],o=i[r.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):r.after?new Et(i[r.i+1],-1):new Et(o,1)}},Ui="\uFFFF",ic=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(Ce.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ui}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=Te.get(r),l=r.nextSibling;if(l==t){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=Te.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:ko(r))||ko(l)&&(r.nodeName!="BR"||o?.isWidget())&&this.text.length>s)&&!dy(l,t)&&this.lineBreak(),r=l}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=s+o}}readNode(e){let t=Te.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(cy(e,i.node,i.offset)?t:0))}};function cy(n,e,t){for(;;){if(!e||t<kn(e))return!1;if(e==n)return!0;t=Hn(e)+1,e=e.parentNode}}function dy(n,e){let t;for(;!(n==e||!n);n=n.nextSibling){let i=Te.get(n);if(!i?.isWidget())return!1;i&&(t||(t=[])).push(i)}if(t)for(let i of t){let r=i.overrideDOMText;if(r?.length)return!1}return!0}var Ao=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},rc=class{constructor(e,t,i,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=bp(e.docView.tile,t,i,0))){let a=s||o?[]:hy(e),c=new ic(a,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=fy(a,this.bounds.from)}else{let a=e.observer.selectionRange,c=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!za(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),d=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!za(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),u=e.viewport;if((B.ios||B.chrome)&&c!=d&&Math.min(c,d)<=l.main.from&&Math.max(c,d)>=l.main.to&&(u.from>0||u.to<e.state.doc.length)){let h=Math.min(c,d),f=Math.max(c,d),p=u.from-h,m=u.to-f;(p==0||p==1||h==0)&&(m==0||m==-1||f==e.state.doc.length)&&(c=0,d=e.state.doc.length)}if(e.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(D.range(d,c));else if(e.lineWrapping&&d==c&&!(l.main.empty&&l.main.head==c)&&e.inputState.lastTouchTime>Date.now()-100){let h=e.coordsAtPos(c,-1),f=0;h&&(f=e.inputState.lastTouchY<=h.bottom?-1:1),this.newSel=D.create([D.cursor(c,f)])}else this.newSel=D.single(d,c)}}};function bp(n,e,t,i){if(n.isComposite()){let r=-1,s=-1,o=-1,l=-1;for(let a=0,c=i,d=i;a<n.children.length;a++){let u=n.children[a],h=c+u.length;if(c<e&&h>t)return bp(u,e,t,c);if(h>=e&&r==-1&&(r=a,s=c),c>t&&u.dom.parentNode==n.dom){o=a,l=d;break}d=h,c=h+u.breakAfter}return{from:s,to:l<0?i+n.length:l,startDOM:(r?n.children[r-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o<n.children.length&&o>=0?n.children[o].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function wp(n,e){let t,{newSel:i}=e,{state:r}=n,s=r.selection.main,o=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,c=s.from,d=null;(o===8||B.android&&e.text.length<a-l)&&(c=s.to,d="end");let u=r.doc.sliceString(l,a,Ui),h,f;!s.empty&&s.from>=l&&s.to<=a&&(e.typeOver||u!=e.text)&&u.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&u.slice(s.to-l)==e.text.slice(h=e.text.length-(u.length-(s.to-l)))?t={from:s.from,to:s.to,insert:ne.of(e.text.slice(s.from-l,h).split(Ui))}:(f=yp(u,e.text,c-l,d))&&(B.chrome&&o==13&&f.toB==f.from+2&&e.text.slice(f.from,f.toB)==Ui+Ui&&f.toB--,t={from:l+f.from,to:l+f.toA,insert:ne.of(e.text.slice(f.from,f.toB).split(Ui))})}else i&&(!n.hasFocus&&r.facet(xn)||Mo(i,s))&&(i=null);if(!t&&!i)return!1;if((B.mac||B.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=D.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:ne.of([t.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).to<s.to&&n.docView.lineHasWidget(s.to)&&n.inputState.insertingTextAt>Date.now()-50?t={from:s.from,to:s.to,insert:r.toText(n.inputState.insertingText)}:B.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==`
725
- `&&n.lineWrapping&&(i&&(i=D.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:ne.of([" "])}),t)return Pc(n,t,i,o);if(i&&!Mo(i,s)){let l=!1,a="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(l=!0),a=n.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=gp(r.facet(Yr).map(c=>c(n)),i))),n.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function Pc(n,e,t,i=-1){if(B.ios&&n.inputState.flushIOSKey(e))return!0;let r=n.state.selection.main;if(B.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&n.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Xi(n.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&Xi(n.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&Xi(n.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,l=()=>o||(o=uy(n,e,t));return n.state.facet(ip).some(a=>a(n,e.from,e.to,s,l))||n.dispatch(l()),!0}function uy(n,e,t){let i,r=n.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let a=e.from<s.from?-1:1,c=a<0?s.from:s.to,d=$r(r.facet(Yr).map(u=>u(n)),c,a);e.from==d&&(o=d)}if(o>-1)i={changes:e,selection:D.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let a=s.from<e.from?r.sliceDoc(s.from,e.from):"",c=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(a+e.insert.sliceString(0,void 0,n.state.lineBreak)+c))}else{let a=r.changes(e),c=t&&t.main.to<=a.newLength?t.main:void 0;if(r.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let d=n.state.sliceDoc(e.from,e.to),u,h=t&&mp(n,t.main.head);if(h){let p=e.insert.length-(e.to-e.from);u={from:h.from,to:h.to-p}}else u=n.state.doc.lineAt(s.head);let f=s.to-e.to;i=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:c||p.map(a)};let m=p.to-f,w=m-d.length;if(n.state.sliceDoc(w,m)!=d||m>=u.from&&w<=u.to)return{range:p};let b=r.changes({from:w,to:m,insert:e.insert}),v=p.to-s.to;return{changes:b,range:c?D.range(Math.max(0,c.anchor+v),Math.max(0,c.head+v)):p.map(b)}})}else i={changes:a,selection:c&&r.selection.replaceRange(c)}}let l="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,l+=".compose",n.inputState.compositionFirstChange&&(l+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:l,scrollIntoView:!0})}function yp(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s<r&&n.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&n.length==e.length)return null;let o=n.length,l=e.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o<s&&n.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=t<=s&&t>=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function hy(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new Ao(t,i)),(r!=t||s!=i)&&e.push(new Ao(r,s))),e}function fy(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?D.single(t+e,i+e):null}function Mo(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}var sc=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,B.safari&&e.contentDOM.addEventListener("input",()=>null),B.gecko&&Ey(e.contentDOM.ownerDocument)}handleEvent(e){!vy(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=my(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&vp.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),B.android&&B.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(B.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(xp.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||gy.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&B.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&py(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Xi(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:B.safari&&!B.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function py(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function bf(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){_t(t.state,r)}}}function my(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&t(l).handlers.push(bf(i.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(bf(i.value,a))}}for(let i in zt)t(i).handlers.push(zt[i]);for(let i in st)t(i).observers.push(st[i]);return e}var xp=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],gy="dthko",vp=[16,17,18,20,91,92,224,225],co=6;function uo(n){return Math.max(0,n)*.7+8}function by(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var oc=class{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Wf(e.contentDOM),this.atoms=e.state.facet(Yr).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Ce.allowMultipleSelections)&&wy(e,t),this.dragging=xy(e,t)&&Cp(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&by(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=fp(this.view);e.clientX-a.left<=r+co?t=-uo(r-e.clientX):e.clientX+a.right>=o-co&&(t=uo(e.clientX-o)),e.clientY-a.top<=s+co?i=-uo(s-e.clientY):e.clientY+a.bottom>=l-co&&(i=uo(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=gp(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function wy(n,e){let t=n.state.facet(Qf);return t.length?t[0](e):B.mac?e.metaKey:e.ctrlKey}function yy(n,e){let t=n.state.facet(ep);return t.length?t[0](e):B.mac?!e.altKey:!e.ctrlKey}function xy(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=qr(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function vy(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=Te.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}var zt=Object.create(null),st=Object.create(null),kp=B.ie&&B.ie_version<15||B.ios&&B.webkit_version<604;function ky(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),Sp(n,t.value)},50)}function Bo(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function Sp(n,e){e=Bo(n.state,Rc,e);let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(lc!=null&&t.selection.ranges.every(a=>a.empty)&&lc==s.toString()){let a=-1;i=t.changeByRange(c=>{let d=t.doc.lineAt(c.from);if(d.from==a)return{range:c};a=d.from;let u=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:d.from,insert:u},range:D.cursor(c.from+u.length)}})}else o?i=t.changeByRange(a=>{let c=s.line(r++);return{changes:{from:a.from,to:a.to,insert:c.text},range:D.cursor(a.from+c.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}st.scroll=n=>{let e=n.inputState;e.lastScrollTop=n.scrollDOM.scrollTop,e.lastScrollLeft=n.scrollDOM.scrollLeft,B.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};st.wheel=st.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};zt.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);st.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};st.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};st.touchend=(n,e)=>{n.inputState.touchActive=!1};zt.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(tp))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=Cy(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new oc(n,e,t,i)),i&&n.observer.ignore(()=>{Uf(n.contentDOM);let s=n.root.activeElement;s&&!s.contains(n.contentDOM)&&s.blur()});let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function wf(n,e,t,i){if(i==1)return D.cursor(e,t);if(i==2)return ry(n.state,e,t);{let r=n.docView.lineAt(e,t),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<n.state.doc.length&&l==s.to&&l++,D.undirectionalRange(o,l)}}var Sy=B.ie&&B.ie_version<=11,yf=null,xf=0,vf=0;function Cp(n){if(!Sy)return n.detail;let e=yf,t=vf;return yf=n,vf=Date.now(),xf=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(xf+1)%3:1}function Cy(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=Cp(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let a=n.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),c,d=wf(n,a.pos,a.assoc,i);if(t.pos!=a.pos&&!o){let u=wf(n,t.pos,t.assoc,i),h=Math.min(u.from,d.from),f=Math.max(u.to,d.to);d=h<d.from?D.range(h,f,d.assoc):D.range(f,h,d.assoc)}return o?r.replaceRange(r.main.extend(d.from,d.to,d.assoc)):l&&i==1&&r.ranges.length>1&&(c=Ty(r,a.pos))?c:l?r.addRange(d):D.create([d])}}}function Ty(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:r}=n.ranges[t];if(i<=e&&r>=e)return D.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}zt.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=D.undirectionalRange(s,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",Bo(n.state,Dc,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};zt.dragend=n=>(n.inputState.draggedContent=null,!1);function kf(n,e,t,i){if(t=Bo(n.state,Rc,t),!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&yy(n,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}zt.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,s=()=>{++r==t.length&&kf(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return kf(n,e,i,!0),!0}return!1};zt.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=kp?null:e.clipboardData;return t?(Sp(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(ky(n),!1)};function Ay(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function My(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:Bo(n,Dc,e.join(n.lineBreak)),ranges:t,linewise:i}}var lc=null;zt.copy=zt.cut=(n,e)=>{if(!_r(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:r}=My(n.state);if(!t&&!r)return!1;lc=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=kp?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(Ay(n,t),!1)};var Tp=ht.define();function Ap(n,e){let t=[];for(let i of n.facet(rp)){let r=i(n,e);r&&t.push(r)}return t.length?n.update({effects:t,annotations:Tp.of(!0)}):null}function Mp(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=Ap(n.state,e);t?n.dispatch(t):n.update([])}},10)}st.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),Mp(n)};st.blur=n=>{n.observer.clearSelectionRange(),Mp(n)};st.compositionstart=st.compositionupdate=n=>{if(!n.observer.editContext&&(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0)){let{main:e}=n.state.selection;!e.empty&&n.lineBlockAt(e.from).from!=n.lineBlockAt(e.to).from&&n.dispatch({changes:n.state.selection.ranges.filter(t=>!t.empty).map(t=>({from:t.from,to:t.to})),userEvent:"input"}),n.inputState.composing=0}};st.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,B.chrome&&B.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};st.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};zt.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=n.posAtDOM(l.startContainer,l.startOffset),c=n.posAtDOM(l.endContainer,l.endOffset);return Pc(n,{from:a,to:c,insert:n.state.toText(s)},null),!0}}let r;if(B.chrome&&B.android&&(r=xp.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return B.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),B.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>st.compositionend(n,e),20),!1};var Sf=new Set;function Ey(n){Sf.has(n)||(Sf.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var Cf=["pre-wrap","normal","pre-line","break-spaces"],er=!1;function Tf(){er=!1}var ac=class{constructor(e){this.lineWrapping=e,this.doc=ne.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Cf.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,i,r,s,o){let l=Cf.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let c=0;c<o.length;c++){let d=o[c];d<0?c++:this.heightSamples[Math.floor(d*10)]=!0}}return a}},cc=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},Bt=class n{constructor(e,t,i,r,s){this.from=e,this.length=t,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Ge.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof fi?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new n(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ge=(function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n})(ge||(ge={})),go=.001,yt=class n{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>go&&(er=!0),this.height=e)}replace(e,t,i){return n.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:c,fromB:d,toB:u}=r[l],h=s.lineAt(a,ge.ByPosNoHeight,i.setDoc(t),0,0),f=h.to>=c?h:s.lineAt(c,ge.ByPosNoHeight,i,0,0);for(u+=f.to-c,c=f.to;l>0&&h.from<=r[l-1].toA;)a=r[l-1].fromA,d=r[l-1].fromB,l--,a<h.from&&(h=s.lineAt(a,ge.ByPosNoHeight,i,0,0));d+=h.from-a,a=h.from;let p=uc.build(i.setDoc(o),e,d,u);s=Eo(s,s.replace(a,c,p))}return s.updateHeight(i,0)}static empty(){return new Mt(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,r=0,s=0;for(;;)if(t==i)if(r>s*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[t++];l&&(r+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new dc(n.of(e.slice(0,t)),o,n.of(e.slice(i)))}};function Eo(n,e){return n==e?n:(n.constructor!=e.constructor&&(er=!0),e)}yt.prototype.size=1;var Ry=be.replace({}),Ro=class extends yt{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new Bt(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,r){return this.spaceAbove&&e<i+this.spaceAbove?new Bt(r,0,i,this.spaceAbove,Ry):this.mainBlock(i,r)}lineAt(e,t,i,r,s){let o=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,i,r,s).join(o):o}forEachLine(e,t,i,r,s,o){e<=s+this.length&&t>=s&&o(this.lineAt(0,ge.ByPos,i,r,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},Mt=class n extends Ro{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new Bt(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof n||r instanceof Bn&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Bn?r=new n(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):yt.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},Bn=class n extends yt{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let c=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),d=t.doc.lineAt(c),u=l+d.length*a,h=Math.max(i,e-u/2);return new Bt(d.from,d.length,h,u,0)}else{let c=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:d,length:u}=t.doc.line(s+c);return new Bt(d,u,i+l*c,l,0)}}lineAt(e,t,i,r,s){if(t==ge.ByHeight)return this.blockAt(e,i,r,s);if(t==ge.ByPosNoHeight){let{from:f,to:p}=i.doc.lineAt(e);return new Bt(f,p-f,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,s),c=i.doc.lineAt(e),d=l+c.length*a,u=c.number-o,h=r+l*u+a*(c.from-s-u);return new Bt(c.from,c.length,Math.max(r,Math.min(h,r+this.height-d)),d,0)}forEachLine(e,t,i,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:a,perChar:c}=this.heightMetrics(i,s);for(let d=e,u=r;d<=t;){let h=i.doc.lineAt(d);if(d==e){let p=h.number-l;u+=a*p+c*(e-s-p)}let f=a+c*h.length;o(new Bt(h.from,h.length,u,f,0)),u+=f,d=h.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let s=i[i.length-1];s instanceof n?i[i.length-1]=new n(s.length+r):i.push(null,new n(r-1))}if(e>0){let s=i[0];s instanceof n?i[0]=new n(e+s.length):i.unshift(new n(e-1),null)}return yt.of(i)}decomposeLeft(e,t){t.push(new n(e-1),null)}decomposeRight(e,t){t.push(null,new n(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new n(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let d=e.doc.lineAt(l).length;o.length&&o.push(null);let u=r.heights[r.index++],h=0;u<0&&(h=-u,u=r.heights[r.index++]),a==-1?a=u:Math.abs(u-a)>=go&&(a=-2);let f=new Mt(d,u,h);f.outdated=!1,o.push(f),l+=d+1}l<=s&&o.push(null,new n(s-l).updateHeight(e,l));let c=yt.of(o);return(a<0||Math.abs(c.height-this.height)>=go||Math.abs(a-this.heightMetrics(e,t).perLine)>=go)&&(er=!0),Eo(this,c)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},dc=class extends yt{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,t,i,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,i,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=t==ge.ByHeight?e<o:e<l,c=a?this.left.lineAt(e,t,i,r,s):this.right.lineAt(e,t,i,o,l);if(this.break||(a?c.to<l:c.from>l))return c;let d=t==ge.ByPosNoHeight?ge.ByPosNoHeight:ge.ByPos;return a?c.join(this.right.lineAt(l,d,i,o,l)):this.left.lineAt(l,d,i,r,s).join(c)}forEachLine(e,t,i,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,r,s,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let c=this.lineAt(a,ge.ByPos,i,r,s);e<c.from&&this.left.forEachLine(e,c.from-1,i,r,s,o),c.to>=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,i,l,a,o)}}replace(e,t,i){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&Af(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),Af(s,l)}return yt.of(s)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?yt.of(this.break?[e,null,t]:[e,t]):(this.left=Eo(this.left,e),this.right=Eo(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Af(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Bn&&(i=n[e+1])instanceof Bn&&n.splice(e-1,3,new Bn(t.length+1+i.length))}var Dy=5,uc=class n{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Mt?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Mt(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new Ro(o,r,i)):(o||s||r>=Dy)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Mt(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new Bn(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Mt)return e;let t=new Mt(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Mt)&&!this.isCovered?this.nodes.push(new Mt(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof Mt&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,t,i,r){let s=new n(i,e);return he.spans(t,i,r,s,0),s.finish(i)}};function Ly(n,e,t){let i=new hc;return he.compare(n,e,t,i,0),i.changes}var hc=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&qi(e,t,this.changes,5)}};function Oy(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,r=i.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let c=n.parentNode;c&&c!=i.body;)if(c.nodeType==1){let d=c,u=window.getComputedStyle(d);if((d.scrollHeight>d.clientHeight||d.scrollWidth>d.clientWidth)&&u.overflow!="visible"){let h=d.getBoundingClientRect();s=Math.max(s,h.left),o=Math.min(o,h.right),l=Math.max(l,h.top),a=Math.min(c==n.parentNode?r.innerHeight:a,h.bottom)}c=u.position=="absolute"||u.position=="fixed"?d.offsetParent:d.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Py(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function Iy(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var Ur=class{constructor(e,t,i,r){this.from=e,this.to=t,this.size=i,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=t[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return be.replace({widget:new fc(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},fc=class extends _n{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},Do=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Mf,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=we.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=t.facet(Lc).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new ac(i),this.stateDeco=Ef(t),this.heightMap=yt.empty().applyChanges(this.stateDeco,ne.empty,this.heightOracle.setDoc(t.doc),[new Ht(0,0,0,t.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=be.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new Ki(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Mf:new pc(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Nr(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Ef(this.state);let r=e.changedRanges,s=Ht.extendWithRanges(r,Ly(i,this.stateDeco,e?e.changes:it.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Tf(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||er)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let c=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(op)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?we.RTL:we.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let c=0,d=0;if(l.width&&l.height){let{scaleX:S,scaleY:C}=zf(t,l);(S>.005&&Math.abs(this.scaleX-S)>.005||C>.005&&Math.abs(this.scaleY-C)>.005)&&(this.scaleX=S,this.scaleY=C,c|=16,o=a=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,h=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=h)&&(this.paddingTop=u,this.paddingBottom=h,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=Wf(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=jf(this.scrollParent||e.win);let m=(this.printing?Iy:Oy)(t,this.paddingTop),w=m.top-this.pixelViewport.top,b=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(a=!0)),!this.inView&&!this.scrollTarget&&!Py(e.dom))return 0;let k=l.width;if((this.contentDOMWidth!=k||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),a){let S=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(S)&&(o=!0),o||r.lineWrapping&&Math.abs(k-this.contentDOMWidth)>r.charWidth){let{lineHeight:C,charWidth:A,textHeight:$}=e.docView.measureTextSize();o=C>0&&r.refresh(s,C,A,$,Math.max(5,k/A),S),o&&(e.docView.minWidth=0,c|=16)}w>0&&b>0?d=Math.max(w,b):w<0&&b<0&&(d=Math.min(w,b)),Tf();for(let C of this.viewports){let A=C.from==this.viewport.from?S:e.docView.measureVisibleLineHeights(C);this.heightMap=(o?yt.empty().applyChanges(this.stateDeco,ne.empty,this.heightOracle,[new Ht(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new cc(C.from,A))}er&&(c|=2)}let N=!this.viewportIsAppropriate(this.viewport,d)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return N&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(d,this.scrollTarget),c|=this.updateForViewport()),(c&2||N)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Ki(r.lineAt(o-i*1e3,ge.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,ge.ByHeight,s,0,0).to);if(t){let{head:c}=t.range;if(c<a.from||c>a.to){let d=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=r.lineAt(c,ge.ByPos,s,0,0),h;t.y=="center"?h=(u.top+u.bottom)/2-d/2:t.y=="start"||t.y=="nearest"&&c<a.from?h=u.top:h=u.bottom-d,a=new Ki(r.lineAt(h-1e3/2,ge.ByHeight,s,0,0).from,r.lineAt(h+d+1e3/2,ge.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new Ki(this.heightMap.lineAt(i,ge.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,ge.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,ge.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,ge.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let r of e)t.touchesRange(r.from,r.to)||i.push(new Ur(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=we.LTR&&!i)return[];let l=[],a=(d,u,h,f)=>{if(u-d<s)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let b of m)if(b>d&&b<u){a(d,b-10,h,f),a(b+10,u,h,f);return}let w=By(e,b=>b.from>=h.from&&b.to<=h.to&&Math.abs(b.from-d)<s&&Math.abs(b.to-u)<s&&!m.some(v=>b.from<v&&b.to>v));if(!w){if(u<h.to&&t&&i&&t.visibleRanges.some(k=>k.from<=u&&k.to>=u)){let k=t.moveToLineBoundary(D.cursor(u),!1,!0).head;k>d&&(u=k)}let b=this.gapSize(h,d,u,f),v=i||b<2e6?b:2e6;w=new Ur(d,u,b,v)}l.push(w)},c=d=>{if(d.length<o||d.type!=Ge.Text)return;let u=Ny(d.from,d.to,this.stateDeco);if(u.total<o)return;let h=this.scrollTarget?this.scrollTarget.range.head:null,f,p;if(i){let m=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,w,b;if(h!=null){let v=fo(u,h),k=((this.visibleBottom-this.visibleTop)/2+m)/d.height;w=v-k,b=v+k}else w=(this.visibleTop-d.top-m)/d.height,b=(this.visibleBottom-d.top+m)/d.height;f=ho(u,w),p=ho(u,b)}else{let m=u.total*this.heightOracle.charWidth,w=r*this.heightOracle.charWidth,b=0;if(m>2e6)for(let C of e)C.from>=d.from&&C.from<d.to&&C.size!=C.displaySize&&C.from*this.heightOracle.charWidth+b<this.pixelViewport.left&&(b=C.size-C.displaySize);let v=this.pixelViewport.left+b,k=this.pixelViewport.right+b,N,S;if(h!=null){let C=fo(u,h),A=((k-v)/2+w)/m;N=C-A,S=C+A}else N=(v-w)/m,S=(k+w)/m;f=ho(u,N),p=ho(u,S)}f>d.from&&a(d.from,f,d,u),p<d.to&&a(p,d.to,d,u)};for(let d of this.viewportLines)Array.isArray(d.type)?d.type.forEach(c):c(d);return l}gapSize(e,t,i,r){let s=fo(r,i)-fo(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){Ur.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=be.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];he.spans(t,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s<i.length&&!(r&8);s++){let o=this.visibleRanges[s],l=i[s];(o.from!=l.from||o.to!=l.to)&&(r|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(r|=8))}return this.visibleRanges=i,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Nr(this.heightMap.lineAt(e,ge.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Nr(this.heightMap.lineAt(this.scaler.fromDOM(e),ge.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Nr(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Ki=class{constructor(e,t){this.from=e,this.to=t}};function Ny(n,e,t){let i=[],r=n,s=0;return he.spans(t,n,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function ho({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function fo(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function By(n,e){for(let t of n)if(e(t))return t}var Mf={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function Ef(n){let e=n.facet(No).filter(i=>typeof i!="function"),t=n.facet(Oc).filter(i=>typeof i!="function");return t.length&&e.push(he.join(t)),e}var pc=class n{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let c=t.lineAt(l,ge.ByPos,e,0,0).top,d=t.lineAt(a,ge.ByPos,e,0,0).bottom;return r+=d-c,{from:l,to:a,top:c,bottom:d,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}eq(e){return e instanceof n?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}};function Nr(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new Bt(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>Nr(r,e)):n._content)}var po=V.define({combine:n=>n.join(" ")}),mc=V.define({combine:n=>n.indexOf(!0)>-1}),gc=At.newName(),Ep=At.newName(),Rp=At.newName(),Dp={"&light":"."+Ep,"&dark":"."+Rp};function bc(n,e,t){return new At(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}var _y=bc("."+gc,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Dp),Hy={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ia=B.ie&&B.ie_version<=11,wc=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Wa,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(B.ie&&B.ie_version<=11||B.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&B.android&&e.constructor.EDIT_CONTEXT!==!1&&!(B.chrome&&B.chrome_version<126)&&(this.editContext=new yc(e),e.state.facet(xn)&&(e.contentDOM.editContext=this.editContext.editContext)),Ia&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(xn)?i.root.activeElement!=this.dom:!_r(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(B.ie&&B.ie_version<=11||B.android&&B.chrome)&&!i.state.selection.main.empty&&r.focusNode&&Fr(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=qr(e.root);if(!t)return!1;let i=B.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Fy(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let r=_r(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Pw(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Hy),Ia&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ia&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Xi(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&_r(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new rc(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=wp(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!Mo(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=Rf(t,e.previousSibling||e.target.previousSibling,-1),r=Rf(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(xn)!=e.state.facet(xn)&&(e.view.contentDOM.editContext=e.state.facet(xn)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function Rf(n,e,t){for(;e;){let i=Te.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Df(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return Fr(o.node,o.offset,r,s)&&([t,i,r,s]=[r,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}}function Fy(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return Df(n,r)}let t=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?Df(n,t):null}var yc=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let c=a-l>i.text.length;l==this.from&&s<this.from?l=s:a==this.to&&s>this.to&&(a=s);let d=yp(e.state.sliceDoc(l,a),i.text,(c?r.from:r.to)-l,c?"end":null);if(!d){let h=D.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Mo(h,r)||e.dispatch({selection:h,userEvent:"select"});return}let u={from:d.from+l,to:d.toA+l,insert:ne.of(i.text.slice(d.from,d.toB).split(`
726
- `))};if((B.mac||B.android)&&u.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:l,to:a,insert:ne.of([i.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let h=this.to-this.from+(u.to-u.from+u.insert.length);Pc(e,u,D.single(this.toEditorPos(i.selectionStart,h),this.toEditorPos(i.selectionEnd,h)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=e.coordsForChar(o);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,r.push(s)}t.updateCharacterBounds(i.rangeStart,r)},this.handlers.textformatupdate=i=>{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);if(a<c){let d=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;r.push(be.mark({attributes:{style:d}}).range(a,c))}}}e.dispatch({effects:ap.of(be.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let r=qr(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,c)=>{if(i)return;let d=c.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=d,this.to+=d;return}else r=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=d,this.to+=d;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+c.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),c.toString()),this.to+=d}t+=d}),r&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},j=class n{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Ow(e.parent)||document,this.viewState=new Do(this,e.state||Ce.create(e)),e.scrollTo&&e.scrollTo.is(ao)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ji).map(r=>new Wr(r));for(let r of this.plugins)r.update(this);this.observer=new wc(this),this.inputState=new sc(this),this.inputState.ensureHandlers(this.plugins),this.docView=new To(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Be?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,s=this.state;for(let h of e){if(h.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=h.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(h=>h.annotation(Tp))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Ap(s,o),a||(l=1));let c=this.observer.delayedAndroidKey,d=null;if(c?(this.observer.clearDelayedAndroidKey(),d=this.observer.readChange(),(d&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(d=null)):this.observer.clear(),s.facet(Ce.phrases)!=this.state.facet(Ce.phrases))return this.setState(s);r=So.create(this,s,e),r.flags|=l;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let h of e){if(u&&(u=u.map(h.changes)),h.scrollIntoView){let{main:f}=h.state.selection,{x:p,y:m}=this.state.facet(n.cursorScrollMargin);u=new zr(f.empty?f:D.cursor(f.head,f.head>f.anchor?-1:1),"nearest","nearest",m,p)}for(let f of h.effects)f.is(ao)&&(u=f.value.clip(this.state))}this.viewState.update(r,u),this.bidiCache=Lo.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(Ir)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(po)!=r.state.facet(po)&&(this.viewState.mustMeasureContent=!0),(t||i||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let h of this.state.facet(ja))try{h(r)}catch(f){_t(this.state,f,"update listener")}(a||d)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),d&&!wp(this,d)&&c.force&&Xi(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Do(this,e),this.plugins=e.facet(ji).map(i=>new Wr(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new To(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(ji),i=e.state.facet(ji);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new Wr(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){_t(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0){if(jf(i||this.win))s=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,o=p.top}l=this.viewState.scaleY}this.updateState=1;let c=this.viewState.measure();if(!c&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let d=[];c&4||([this.measureRequests,d]=[d,this.measureRequests]);let u=d.map(p=>{try{return p.read(this)}catch(m){return _t(this.state,m),Lf}}),h=So.create(this,this.state,[]),f=!1;h.flags|=c,t?t.flags|=c:t=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),f=this.docView.update(h),f&&this.docViewUpdate());for(let p=0;p<d.length;p++)if(u[p]!=Lf)try{let m=d[p];m.write&&m.write(u[p],this)}catch(m){_t(this.state,m)}if(f&&this.docView.updateSelection(!0),!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let m=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)/this.viewState.scaleY-o/l;if((m>1||m<-1)&&!(B.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+m,i?s<0?i.scrollTop=i.scrollHeight:i.scrollTop+=m:this.win.scrollBy(0,m),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(ja))a(t)}get themeClasses(){return gc+" "+(this.state.facet(mc)?Rp:Ep)+" "+this.state.facet(po)}updateAttrs(){let e=Of(this,cp,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(xn)?"true":"false",class:"cm-content",style:`${B.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Of(this,Lc,t);let i=this.observer.ignore(()=>{let r=df(this.contentDOM,this.contentAttrs,t),s=df(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(n.announce)){t&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent="\xA0"},200),t=!1);let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Ir);let e=this.state.facet(n.cspNonce);At.mount(this.root,this.styleModules.concat(_y).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return Pa(this,e,gf(this,e,t,i))}moveByGroup(e,t){return Pa(this,e,gf(this,e,t,i=>ly(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return D.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return oy(this,e,t,i)}moveVertically(e,t,i){return Pa(this,e,ay(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=tc(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),tc(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),r=this.bidiSpans(i),s=r[Rt.find(r,e-i.from,-1,t)];return this.docView.coordsAt(e,t,s.dir==we.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(sp)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>zy)return Yf(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Jf(s.isolates,i=ff(this,e))))return s.order;i||(i=ff(this,e));let r=zw(e.text,t,i);return this.bidiCache.push(new Lo(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||B.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Uf(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,r,s,o;return ao.of(new zr(typeof e=="number"?D.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(r=t.x)!==null&&r!==void 0?r:"nearest",(s=t.yMargin)!==null&&s!==void 0?s:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return ao.of(new zr(D.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Ft.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Ft.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=At.newName(),r=[po.of(i),Ir.of(bc(`.${i}`,e))];return t&&t.dark&&r.push(mc.of(!0)),r}static baseTheme(e){return Pr.lowest(Ir.of(bc("."+gc,e,Dp)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&Te.get(i)||Te.get(e);return((t=r?.root)===null||t===void 0?void 0:t.view)||null}};j.styleModule=Ir;j.inputHandler=ip;j.clipboardInputFilter=Rc;j.clipboardOutputFilter=Dc;j.scrollHandler=lp;j.focusChangeEffect=rp;j.perLineTextDirection=sp;j.exceptionSink=np;j.updateListener=ja;j.editable=xn;j.mouseSelectionStyle=tp;j.dragMovesSelection=ep;j.clickAddsSelectionRange=Qf;j.decorations=No;j.blockWrappers=dp;j.outerDecorations=Oc;j.atomicRanges=Yr;j.bidiIsolatedRanges=up;j.cursorScrollMargin=V.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});j.scrollMargins=hp;j.darkTheme=mc;j.cspNonce=V.define({combine:n=>n.length?n[0]:""});j.contentAttributes=Lc;j.editorAttributes=cp;j.lineWrapping=j.contentAttributes.of({class:"cm-lineWrapping"});j.announce=ve.define();var zy=4096,Lf={},Lo=class n{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:we.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&i.push(new n(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}};function Of(n,e,t){for(let i=n.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&Ac(o,t)}return t}var Wy=B.mac?"mac":B.windows?"win":B.linux?"linux":"key";function Vy(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let a=0;a<t.length-1;++a){let c=t[a];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function mo(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}var $y=Pr.default(j.domEventHandlers({keydown(n,e){return Gy(Uy(e.state),n,e,"editor")}})),Ic=V.define({enables:$y}),Pf=new WeakMap;function Uy(n){let e=n.facet(Ic),t=Pf.get(e);return t||Pf.set(e,t=Ky(e.reduce((i,r)=>i.concat(r),[]))),t}var Nn=null,jy=4e3;function Ky(n,e=Wy){let t=Object.create(null),i=Object.create(null),r=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,c,d)=>{var u,h;let f=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(b=>Vy(b,e));for(let b=1;b<p.length;b++){let v=p.slice(0,b).join(" ");r(v,!0),f[v]||(f[v]={preventDefault:!0,stopPropagation:!1,run:[k=>{let N=Nn={view:k,prefix:v,scope:o};return setTimeout(()=>{Nn==N&&(Nn=null)},jy),!0}]})}let m=p.join(" ");r(m,!1);let w=f[m]||(f[m]={preventDefault:!1,stopPropagation:!1,run:((h=(u=f._any)===null||u===void 0?void 0:u.run)===null||h===void 0?void 0:h.slice())||[]});a&&w.run.push(a),c&&(w.preventDefault=!0),d&&(w.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of l){let d=t[c]||(t[c]=Object.create(null));d._any||(d._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=o;for(let h in d)d[h].run.push(f=>u(f,xc))}let a=o[e]||o.key;if(a)for(let c of l)s(c,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}var xc=null;function Gy(n,e,t,i){xc=e;let r=of(e),s=$h(r,0),o=Uh(s)==r.length&&r!=" ",l="",a=!1,c=!1,d=!1;Nn&&Nn.view==t&&Nn.scope==i&&(l=Nn.prefix+" ",vp.indexOf(e.keyCode)<0&&(c=!0,Nn=null));let u=new Set,h=w=>{if(w){for(let b of w.run)if(!u.has(b)&&(u.add(b),b(t)))return w.stopPropagation&&(d=!0),!0;w.preventDefault&&(w.stopPropagation&&(d=!0),c=!0)}return!1},f=n[i],p,m;return f&&(h(f[l+mo(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(B.windows&&e.ctrlKey&&e.altKey)&&!(B.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=yn[e.keyCode])&&p!=r?(h(f[l+mo(p,e,!0)])||e.shiftKey&&(m=$i[e.keyCode])!=r&&m!=p&&h(f[l+mo(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&h(f[l+mo(r,e,!0)])&&(a=!0),!a&&h(f._any)&&(a=!0)),c&&(a=!0),a&&d&&e.stopPropagation(),xc=null,a}var hi=class n{constructor(e,t,i,r,s){this.className=e,this.left=t,this.top=i,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let r=e.coordsAtPos(i.head,i.assoc||1);if(!r)return[];let s=Lp(e);return[new n(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return qy(e,t,i)}};function Lp(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==we.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function If(n,e,t,i){let r=n.coordsAtPos(e,t*2);if(!r)return i;let s=n.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=n.posAtCoords({x:s.left+1,y:o}),a=n.posAtCoords({x:s.right-1,y:o});return l==null||a==null?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}function qy(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),r=Math.min(t.to,n.viewport.to),s=n.textDirection==we.LTR,o=n.contentDOM,l=o.getBoundingClientRect(),a=Lp(n),c=o.querySelector(".cm-line"),d=c&&window.getComputedStyle(c),u=l.left+(d?parseInt(d.paddingLeft)+Math.min(0,parseInt(d.textIndent)):0),h=l.right-(d?parseInt(d.paddingRight):0),f=ec(n,i,1),p=ec(n,r,-1),m=f.type==Ge.Text?f:null,w=p.type==Ge.Text?p:null;if(m&&(n.lineWrapping||f.widgetLineBreaks)&&(m=If(n,i,1,m)),w&&(n.lineWrapping||p.widgetLineBreaks)&&(w=If(n,r,-1,w)),m&&w&&m.from==w.from&&m.to==w.to)return v(k(t.from,t.to,m));{let S=m?k(t.from,null,m):N(f,!1),C=w?k(null,t.to,w):N(p,!0),A=[];return(m||f).to<(w||p).from-(m&&w?1:0)||f.widgetLineBreaks>1&&S.bottom+n.defaultLineHeight/2<C.top?A.push(b(u,S.bottom,h,C.top)):S.bottom<C.top&&n.elementAtHeight((S.bottom+C.top)/2).type==Ge.Text&&(S.bottom=C.top=(S.bottom+C.top)/2),v(S).concat(A).concat(v(C))}function b(S,C,A,$){return new hi(e,S-a.left,C-a.top,Math.max(0,A-S),$-C)}function v({top:S,bottom:C,horizontal:A}){let $=[];for(let F=0;F<A.length;F+=2)$.push(b(A[F],S,A[F+1],C));return $}function k(S,C,A){let $=1e9,F=-1e9,R=[];function O(z,J,q,Me,et){let Se=n.coordsAtPos(z,z==A.to?-2:2),je=n.coordsAtPos(q,q==A.from?2:-2);!Se||!je||($=Math.min(Se.top,je.top,$),F=Math.max(Se.bottom,je.bottom,F),et==we.LTR?R.push(s&&J?u:Se.left,s&&Me?h:je.right):R.push(!s&&Me?u:je.left,!s&&J?h:Se.right))}let M=S??A.from,P=C??A.to;for(let z of n.visibleRanges)if(z.to>M&&z.from<P)for(let J=Math.max(z.from,M),q=Math.min(z.to,P);;){let Me=n.state.doc.lineAt(J);for(let et of n.bidiSpans(Me)){let Se=et.from+Me.from,je=et.to+Me.from;if(Se>=q)break;je>J&&O(Math.max(Se,J),S==null&&Se<=M,Math.min(je,q),C==null&&je>=P,et.dir)}if(J=Me.to+1,J>=q)break}return R.length==0&&O(M,S==null,P,C==null,n.textDirection),{top:$,bottom:F,horizontal:R}}function N(S,C){let A=l.top+(C?S.top:S.bottom);return{top:A,bottom:A,horizontal:[]}}}function Xy(n,e){return n.constructor==e.constructor&&n.eq(e)}var vc=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(bo)!=e.state.facet(bo)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(bo);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!Xy(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[i].constructor&&r.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e,B.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},bo=V.define();function Op(n){return[Ft.define(e=>new vc(e,n)),bo.of(n)]}var tr=V.define({combine(n){return Vi(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Pp(n={}){return[tr.of(n),Jy,Yy,Qy,op.of(!0)]}function Ip(n){return n.startState.facet(tr)!=n.state.facet(tr)}var Jy=Op({above:!0,markers(n){let{state:e}=n,t=e.facet(tr),i=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty||t.drawRangeCursor&&!(s&&B.ios&&t.iosSelectionHandles)){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=r.empty?r:D.cursor(r.head,r.assoc);for(let a of hi.forRange(n,o,l))i.push(a)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Ip(n);return t&&Nf(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){Nf(e.state,n)},class:"cm-cursorLayer"});function Nf(n,e){e.style.animationDuration=n.facet(tr).cursorBlinkRate+"ms"}var Yy=Op({above:!1,markers(n){let e=[],{main:t,ranges:i}=n.state.selection;for(let r of i)if(!r.empty)for(let s of hi.forRange(n,"cm-selectionBackground",r))e.push(s);if(B.ios&&!t.empty&&n.state.facet(tr).iosSelectionHandles){for(let r of hi.forRange(n,"cm-selectionHandle cm-selectionHandle-start",D.cursor(t.from,1)))e.push(r);for(let r of hi.forRange(n,"cm-selectionHandle cm-selectionHandle-end",D.cursor(t.to,1)))e.push(r)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||Ip(n)},class:"cm-selectionLayer"}),Zy=B.gecko&&B.gecko_version==153?"#ffffff01":"transparent",Qy=Pr.highest(j.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${Zy} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Np=ve.define({map(n,e){return n==null?null:e.mapPos(n)}}),Br=Tt.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(Np)?i.value:t,n)}}),ex=Ft.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(Br);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(Br)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(Br),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(Br)!=n&&this.view.dispatch({effects:Np.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Bp(){return[Br,ex]}var pS=/x/.unicode!=null?"gu":"g";function _p(){return nx}var tx=be.line({class:"cm-activeLine"}),nx=Ft.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let r=n.lineBlockAt(i.head);r.from>e&&(t.push(tx.range(r.from)),e=r.from)}return be.set(t)}},{decorations:n=>n.decorations}),kc=class extends _n{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?Hr(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),r=Xr(t[0],i.direction!="rtl"),s=parseInt(i.lineHeight);return r.bottom-r.top>s*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+s}:r}ignoreEvent(){return!1}};function Nc(n){let e=Ft.fromClass(class{constructor(t){this.view=t,this.placeholder=n?be.set([be.widget({widget:new kc(n),side:1}).range(0)]):be.none}get decorations(){return this.view.state.doc.length?be.none:this.placeholder}},{decorations:t=>t.decorations});return typeof n=="string"?[e,j.contentAttributes.of({"aria-placeholder":n})]:e}var Wt=class extends tn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Wt.prototype.elementClass="";Wt.prototype.toDOM=void 0;Wt.prototype.mapMode=ut.TrackBefore;Wt.prototype.startSide=Wt.prototype.endSide=-1;Wt.prototype.point=!0;var wo=V.define(),ix=V.define();var yo=V.define();var Sc=V.define({combine:n=>n.some(e=>e)});function rx(n){let e=[sx];return n&&n.fixed===!1&&e.push(Sc.of(!0)),e}var sx=Ft.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(yo).map(e=>new Oo(n,e)),this.fixed=!n.state.facet(Sc);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Sc)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=he.iter(this.view.state.facet(wo),this.view.viewport.from),i=[],r=this.gutters.map(s=>new Tc(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Ge.Text&&o){Cc(t,i,l.from);for(let a of r)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==Ge.Text){Cc(t,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(yo),t=n.state.facet(yo),i=n.docChanged||n.heightChanged||n.viewportChanged||!he.eq(n.startState.facet(wo),n.state.facet(wo),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(n)&&(i=!0);else{i=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new Oo(this.view,s)):(this.gutters[o].update(n),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>j.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,r=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==we.LTR?{left:i,right:r}:{right:i,left:r}})});function Bf(n){return Array.isArray(n)?n:[n]}function Cc(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}var Tc=class{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=he.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new Po(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];Cc(this.cursor,r,t.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),r=i?[i]:null;for(let s of e.state.facet(ix)){let o=s(e,t.widget,t);o&&(r||(r=[])).push(o)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},Oo=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=Bf(t.markers(e)),t.initialSpacer&&(this.spacer=new Po(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Bf(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!he.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Po=class{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),ox(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=s<t.length?t[s++]:null,c=!1;if(a){let d=a.elementClass;d&&(i+=" "+d);for(let u=o;u<this.markers.length;u++)if(this.markers[u].compare(a)){l=u,c=!0;break}}else l=this.markers.length;for(;o<l;){let d=this.markers[o++];if(d.toDOM){d.destroy(r);let u=r.nextSibling;r.remove(),r=u}}if(!a)break;a.toDOM&&(c?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),c&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}};function ox(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}var lx=V.define(),ax=V.define(),Gi=V.define({combine(n){return Vi(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let r in t){let s=i[r],o=t[r];i[r]=s?(l,a,c)=>s(l,a,c)||o(l,a,c):o}return i}})}}),jr=class extends Wt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Na(n,e){return n.state.facet(Gi).formatNumber(e,n.state)}var cx=yo.compute([Gi],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(lx)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new jr(Na(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let r of e.state.facet(ax)){let s=r(e,t,i);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Gi)!=e.state.facet(Gi),initialSpacer(e){return new jr(Na(e,_f(e.state.doc.lines)))},updateSpacer(e,t){let i=Na(t.view,_f(t.view.state.doc.lines));return i==e.number?e:new jr(i)},domEventHandlers:n.facet(Gi).domEventHandlers,side:"before"}));function Bc(n={}){return[Gi.of(n),rx(),cx]}function _f(n){let e=9;for(;e<n;)e=e*10+9;return e}var dx=new class extends Wt{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},ux=wo.compute(["selection"],n=>{let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.head).from;r>t&&(t=r,e.push(dx.range(r)))}return he.of(e)});function Hp(){return ux}var hx=0,Zr=class{constructor(e,t){this.from=e,this.to=t}},te=class{constructor(e={}){this.id=hx++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=xt.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};te.closedBy=new te({deserialize:n=>n.split(" ")});te.openedBy=new te({deserialize:n=>n.split(" ")});te.group=new te({deserialize:n=>n.split(" ")});te.isolate=new te({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});te.contextHash=new te({perNode:!0});te.lookAhead=new te({perNode:!0});te.mounted=new te({perNode:!0});var gi=class{constructor(e,t,i,r=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[te.mounted.id]}},fx=Object.create(null),xt=class n{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):fx,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new n(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(te.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(te.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}};xt.none=new xt("",Object.create(null),0,8);var _o=new WeakMap,Fp=new WeakMap,Re;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays",n[n.EnterBracketed=16]="EnterBracketed"})(Re||(Re={}));var qe=class n{constructor(e,t,i,r,s){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=gi.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new ts(this.topNode,e)}cursorAt(e,t=0,i=0){let r=_o.get(this)||this.topNode,s=new ts(r);return s.moveTo(e,t),_o.set(this,s._tree),s}get topNode(){return new sn(this,0,0,null)}resolve(e,t=0){let i=Qr(_o.get(this)||this.topNode,e,t,!1);return _o.set(this,i),i}resolveInner(e,t=0){let i=Qr(Fp.get(this)||this.topNode,e,t,!0);return Fp.set(this,i),i}resolveStack(e,t=0){return px(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&Re.IncludeAnonymous)>0;for(let a=this.cursor(o|Re.IncludeAnonymous);;){let c=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;c=!0}for(;c&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:$c(xt.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new n(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new n(xt.none,t,i,r)))}static build(e){return mx(e)}};qe.empty=new qe(xt.none,[],[],0);var _c=class n{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new n(this.buffer,this.index)}},zn=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return xt.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,i,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(Vp(s,r,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){s[a++]=r[l++],s[a++]=r[l++]-i;let c=s[a++]=r[l++]-i;s[a++]=r[l++]-e,o=Math.max(o,c)}return new n(s,o,this.set)}};function Vp(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Qr(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof sn&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=i?0:Re.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof sn&&o.index<0&&((r=l.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(n=l);for(;;){let o=n.enter(e,t,s);if(!o)return n;n=o}}var Fo=class{cursor(e=0){return new ts(this,e)}getChild(e,t=null,i=null){let r=zp(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return zp(this,e,t,i)}resolve(e,t=0){return Qr(this,e,t,!1)}resolveInner(e,t=0){return Qr(this,e,t,!0)}matchContext(e){return Hc(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}},sn=class n extends Fo{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,c=t>0?l.length:-1;e!=c;e+=t){let d=l[e],u=a[e]+o.from,h;if(!(!(s&Re.EnterBracketed&&d instanceof qe&&(h=gi.get(d))&&!h.overlay&&h.bracketed&&i>=u&&i<=u+d.length)&&!Vp(r,i,u,u+d.length))){if(d instanceof zn){if(s&Re.ExcludeBuffers)continue;let f=d.findChild(0,d.buffer.length,t,i-u,r);if(f>-1)return new es(new Fc(o,d,e,u),null,f)}else if(s&Re.IncludeAnonymous||!d.type.isAnonymous||Vc(d)){let f;if(!(s&Re.IgnoreMounts)&&(f=gi.get(d))&&!f.overlay)return new n(f.tree,u,e,o);let p=new n(d,u,e,o);return s&Re.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?d.children.length-1:0,t,i,r,s)}}}if(s&Re.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let r;if(!(i&Re.IgnoreOverlays)&&(r=gi.get(this._tree))&&r.overlay){let s=e-this.from,o=i&Re.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((t>0||o?l<=s:l<s)&&(t<0||o?a>=s:a>s))return new n(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function zp(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function Hc(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var Fc=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},es=class n extends Fo{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new n(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&Re.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new n(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new n(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new qe(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function $p(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;s<n.length;s++){let o=n[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let i=t instanceof sn&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new zc(r,t)}var zc=class{constructor(e,t){this.heads=e,this.node=t}get next(){return $p(this.heads)}};function px(n,e,t){let i=n.resolveInner(e,t),r=null;for(let s=i instanceof sn?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,t)),s=o}else{let o=gi.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new sn(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(Qr(l,e,t,!1))}}return r?$p(r):i}var ts=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~Re.EnterBracketed,e instanceof sn)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof sn?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&Re.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Re.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Re.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&Re.IncludeAnonymous||l instanceof zn||!l.type.isAnonymous||Vc(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)t=new es(this.buffer,t,this.stack[r]);return this.bufferNode=new es(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return Hc(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return Hc(this._tree,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function Vc(n){return n.children.some(e=>e instanceof zn||!e.type.isAnonymous||Vc(e))}function mx(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new _c(t,t.length):t,a=i.types,c=0,d=0;function u(S,C,A,$,F,R){let{id:O,start:M,end:P,size:z}=l,J=d,q=c;if(z<0)if(l.next(),z==-1){let ot=s[O];A.push(ot),$.push(M-S);return}else if(z==-3){c=O;return}else if(z==-4){d=O;return}else throw new RangeError(`Unrecognized record size: ${z}`);let Me=a[O],et,Se,je=M-S;if(P-M<=r&&(Se=w(l.pos-C,F))){let ot=new Uint16Array(Se.size-Se.skip),Ke=l.pos-Se.size,Xe=ot.length;for(;l.pos>Ke;)Xe=b(Se.start,ot,Xe);et=new zn(ot,P-Se.start,i),je=Se.start-S}else{let ot=l.pos-z;l.next();let Ke=[],Xe=[],kt=O>=o?O:-1,ie=0,Tn=P;for(;l.pos>ot;)kt>=0&&l.id==kt&&l.size>=0?(l.end<=Tn-r&&(p(Ke,Xe,M,ie,l.end,Tn,kt,J,q),ie=Ke.length,Tn=l.end),l.next()):R>2500?h(M,ot,Ke,Xe):u(M,ot,Ke,Xe,kt,R+1);if(kt>=0&&ie>0&&ie<Ke.length&&p(Ke,Xe,M,ie,M,Tn,kt,J,q),Ke.reverse(),Xe.reverse(),kt>-1&&ie>0){let Mi=f(Me,q);et=$c(Me,Ke,Xe,0,Ke.length,0,P-M,Mi,Mi)}else et=m(Me,Ke,Xe,P-M,J-P,q)}A.push(et),$.push(je)}function h(S,C,A,$){let F=[],R=0,O=-1;for(;l.pos>C;){let{id:M,start:P,end:z,size:J}=l;if(J>4)l.next();else{if(O>-1&&P<O)break;O<0&&(O=z-r),F.push(M,P,z),R++,l.next()}}if(R){let M=new Uint16Array(R*4),P=F[F.length-2];for(let z=F.length-3,J=0;z>=0;z-=3)M[J++]=F[z],M[J++]=F[z+1]-P,M[J++]=F[z+2]-P,M[J++]=J;A.push(new zn(M,F[2]-P,i)),$.push(P-S)}}function f(S,C){return(A,$,F)=>{let R=0,O=A.length-1,M,P;if(O>=0&&(M=A[O])instanceof qe){if(!O&&M.type==S&&M.length==F)return M;(P=M.prop(te.lookAhead))&&(R=$[O]+M.length+P)}return m(S,A,$,F,R,C)}}function p(S,C,A,$,F,R,O,M,P){let z=[],J=[];for(;S.length>$;)z.push(S.pop()),J.push(C.pop()+A-F);S.push(m(i.types[O],z,J,R-F,M-R,P)),C.push(F-A)}function m(S,C,A,$,F,R,O){if(R){let M=[te.contextHash,R];O=O?[M].concat(O):[M]}if(F>25){let M=[te.lookAhead,F];O=O?[M].concat(O):[M]}return new qe(S,C,A,$,O)}function w(S,C){let A=l.fork(),$=0,F=0,R=0,O=A.end-r,M={size:0,start:0,skip:0};e:for(let P=A.pos-S;A.pos>P;){let z=A.size;if(A.id==C&&z>=0){M.size=$,M.start=F,M.skip=R,R+=4,$+=4,A.next();continue}let J=A.pos-z;if(z<0||J<P||A.start<O)break;let q=A.id>=o?4:0,Me=A.start;for(A.next();A.pos>J;){if(A.size<0)if(A.size==-3||A.size==-4)q+=4;else break e;else A.id>=o&&(q+=4);A.next()}F=Me,$+=z,R+=q}return(C<0||$==S)&&(M.size=$,M.start=F,M.skip=R),M.size>4?M:void 0}function b(S,C,A){let{id:$,start:F,end:R,size:O}=l;if(l.next(),O>=0&&$<o){let M=A;if(O>4){let P=l.pos-(O-4);for(;l.pos>P;)A=b(S,C,A)}C[--A]=M,C[--A]=R-S,C[--A]=F-S,C[--A]=$}else O==-3?c=$:O==-4&&(d=$);return A}let v=[],k=[];for(;l.pos>0;)u(n.start||0,n.bufferStart||0,v,k,-1,0);let N=(e=n.length)!==null&&e!==void 0?e:v.length?k[0]+v[0].length:0;return new qe(a[n.topID],v.reverse(),k.reverse(),N)}var Wp=new WeakMap;function Ho(n,e){if(!n.isAnonymous||e instanceof zn||e.type!=n)return 1;let t=Wp.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof qe)){t=1;break}t+=Ho(n,i)}Wp.set(e,t)}return t}function $c(n,e,t,i,r,s,o,l,a){let c=0;for(let p=i;p<r;p++)c+=Ho(n,e[p]);let d=Math.ceil(c*1.5/8),u=[],h=[];function f(p,m,w,b,v){for(let k=w;k<b;){let N=k,S=m[k],C=Ho(n,p[k]);for(k++;k<b;k++){let A=Ho(n,p[k]);if(C+A>=d)break;C+=A}if(k==N+1){if(C>d){let A=p[N];f(A.children,A.positions,0,A.children.length,m[N]+v);continue}u.push(p[N])}else{let A=m[k-1]+p[k-1].length-S;u.push($c(n,p,m,N,k,S,A,null,a))}h.push(S+v-s)}}return f(e,t,i,r,0),(l||a)(u,h,o)}var bi=class n{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new n(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,c=0;;l++){let d=l<t.length?t[l]:null,u=d?d.fromA:1e9;if(u-a>=i)for(;o&&o.from<u;){let h=o;if(a>=h.from||u<=h.to||c){let f=Math.max(h.from,a)-c,p=Math.min(h.to,u)-c;h=f>=p?null:new n(f,p,h.tree,h.offset+c,l>0,!!d)}if(h&&r.push(h),o.to>u)break;o=s<e.length?e[s++]:null}if(!d)break;a=d.toA,c=d.toA-d.toB}return r}},zo=class{startParse(e,t,i){return typeof e=="string"&&(e=new Wc(e)),i=i?i.length?i.map(r=>new Zr(r.from,r.to)):[new Zr(0,0)]:[new Zr(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}},Wc=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var kS=new te({perNode:!0});var gx=0,Vt=class n{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=gx++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof n&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let r=new n(i,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new Uo(e);return i=>i.modified.indexOf(t)>-1?i:Uo.get(i.base||i,i.modified.concat(t).sort((r,s)=>r.id-s.id))}},bx=0,Uo=class n{constructor(e){this.name=e,this.instances=[],this.id=bx++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&wx(t,l.modified));if(i)return i;let r=[],s=new Vt(e.name,r,e,t);for(let l of t)l.instances.push(s);let o=yx(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(n.get(l,a));return s}};function wx(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function yx(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function Kp(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let u=0;;){if(l=="..."&&u>0&&u+3==r.length){o=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!h)throw new RangeError("Invalid path: "+r);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),u+=h[0].length,u==r.length)break;let f=r[u++];if(u==r.length&&f=="!"){o=0;break}if(f!="/")throw new RangeError("Invalid path: "+r);l=r.slice(u)}let a=s.length-1,c=s[a];if(!c)throw new RangeError("Invalid path: "+r);let d=new nr(i,o,a>0?s.slice(0,a):null);e[c]=d.sort(e[c])}}return xx.add(e)}var xx=new te({combine(n,e){let t,i,r;for(;n||e;){if(!n||e&&n.depth>=e.depth?(r=e,e=e.next):(r=n,n=n.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let s=new nr(r.tags,r.mode,r.context);t?t.next=s:i=s,t=s}return i}}),nr=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};nr.empty=new nr([],2,null);function Kc(n,e){let t=Object.create(null);for(let s of n)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let c=t[a.id];if(c){o=o?o+" "+c:c;break}}return o},scope:i}}var L=Vt.define,Wo=L(),Wn=L(),Up=L(Wn),jp=L(Wn),Vn=L(),Vo=L(Vn),Uc=L(Vn),an=L(),wi=L(an),on=L(),ln=L(),jc=L(),ns=L(jc),$o=L(),I={comment:Wo,lineComment:L(Wo),blockComment:L(Wo),docComment:L(Wo),name:Wn,variableName:L(Wn),typeName:Up,tagName:L(Up),propertyName:jp,attributeName:L(jp),className:L(Wn),labelName:L(Wn),namespace:L(Wn),macroName:L(Wn),literal:Vn,string:Vo,docString:L(Vo),character:L(Vo),attributeValue:L(Vo),number:Uc,integer:L(Uc),float:L(Uc),bool:L(Vn),regexp:L(Vn),escape:L(Vn),color:L(Vn),url:L(Vn),keyword:on,self:L(on),null:L(on),atom:L(on),unit:L(on),modifier:L(on),operatorKeyword:L(on),controlKeyword:L(on),definitionKeyword:L(on),moduleKeyword:L(on),operator:ln,derefOperator:L(ln),arithmeticOperator:L(ln),logicOperator:L(ln),bitwiseOperator:L(ln),compareOperator:L(ln),updateOperator:L(ln),definitionOperator:L(ln),typeOperator:L(ln),controlOperator:L(ln),punctuation:jc,separator:L(jc),bracket:ns,angleBracket:L(ns),squareBracket:L(ns),paren:L(ns),brace:L(ns),content:an,heading:wi,heading1:L(wi),heading2:L(wi),heading3:L(wi),heading4:L(wi),heading5:L(wi),heading6:L(wi),contentSeparator:L(an),list:L(an),quote:L(an),emphasis:L(an),strong:L(an),link:L(an),monospace:L(an),strikethrough:L(an),inserted:L(),deleted:L(),changed:L(),invalid:L(),meta:$o,documentMeta:L($o),annotation:L($o),processingInstruction:L($o),definition:Vt.defineModifier("definition"),constant:Vt.defineModifier("constant"),function:Vt.defineModifier("function"),standard:Vt.defineModifier("standard"),local:Vt.defineModifier("local"),special:Vt.defineModifier("special")};for(let n in I){let e=I[n];e instanceof Vt&&(e.name=n)}var TS=Kc([{tag:I.link,class:"tok-link"},{tag:I.heading,class:"tok-heading"},{tag:I.emphasis,class:"tok-emphasis"},{tag:I.strong,class:"tok-strong"},{tag:I.keyword,class:"tok-keyword"},{tag:I.atom,class:"tok-atom"},{tag:I.bool,class:"tok-bool"},{tag:I.url,class:"tok-url"},{tag:I.labelName,class:"tok-labelName"},{tag:I.inserted,class:"tok-inserted"},{tag:I.deleted,class:"tok-deleted"},{tag:I.literal,class:"tok-literal"},{tag:I.string,class:"tok-string"},{tag:I.number,class:"tok-number"},{tag:[I.regexp,I.escape,I.special(I.string)],class:"tok-string2"},{tag:I.variableName,class:"tok-variableName"},{tag:I.local(I.variableName),class:"tok-variableName tok-local"},{tag:I.definition(I.variableName),class:"tok-variableName tok-definition"},{tag:I.special(I.variableName),class:"tok-variableName2"},{tag:I.definition(I.propertyName),class:"tok-propertyName tok-definition"},{tag:I.typeName,class:"tok-typeName"},{tag:I.namespace,class:"tok-namespace"},{tag:I.className,class:"tok-className"},{tag:I.macroName,class:"tok-macroName"},{tag:I.propertyName,class:"tok-propertyName"},{tag:I.operator,class:"tok-operator"},{tag:I.comment,class:"tok-comment"},{tag:I.meta,class:"tok-meta"},{tag:I.invalid,class:"tok-invalid"},{tag:I.punctuation,class:"tok-punctuation"}]);var Gc,rs=new te;var vx=new te,Dt=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,Ce.prototype.hasOwnProperty("tree")||Object.defineProperty(Ce.prototype,"tree",{get(){return Sn(this)}}),this.parser=t,this.extension=[ir.of(this),Ce.languageData.of((s,o,l)=>{let a=Gp(s,o,l),c=a.type.prop(rs);if(!c)return[];let d=s.facet(c),u=a.type.prop(vx);if(u){let h=a.resolve(o-a.from,l);for(let f of u)if(f.test(h,s)){let p=s.facet(f.facet);return f.type=="replace"?p:p.concat(d)}}return d})].concat(i)}isActiveAt(e,t,i=-1){return Gp(e,t,i).type.prop(rs)==this.data}findRegions(e){let t=e.facet(ir);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(rs)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(te.mounted);if(l){if(l.tree.prop(rs)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let a=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<s.children.length;a++){let c=s.children[a];c instanceof qe&&r(c,s.positions[a]+o)}};return r(Sn(e),0),i}get allowsNesting(){return!0}};Dt.setState=ve.define();function Gp(n,e,t){let i=n.facet(ir),r=Sn(n).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,t,Re.ExcludeBuffers|Re.EnterBracketed))s.type.isTop&&(r=s);return r}function Sn(n){let e=n.field(Dt.state,!1);return e?e.tree:qe.empty}var Jc=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},is=null,Yc=class n{constructor(e,t,i=[],r,s,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],qe.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Jc(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=qe.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(bi.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(bi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=is;is=this;try{return e()}finally{is=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=qp(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((c,d,u,h)=>a.push({fromA:c,toA:d,fromB:u,toB:h})),i=bi.applyChanges(i,a),r=qe.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let d=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);d<u&&l.push({from:d,to:u})}}}return new n(this.parser,t,i,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=qp(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends zo{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=is;if(a){for(let c of r)a.tempSkipped.push(c);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new qe(xt.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return is}};function qp(n,e,t){return bi.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var ss=class n{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Yc.create(e.facet(ir).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};Dt.state=Tt.define({create:ss.init,update(n,e){for(let t of e.effects)if(t.is(Dt.setState))return t.value;return e.startState.facet(ir)!=e.state.facet(ir)?ss.init(e.state):n.apply(e)}});var Zp=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Zp=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var qc=typeof navigator<"u"&&(!((Gc=navigator.scheduling)===null||Gc===void 0)&&Gc.isInputPending)?()=>navigator.scheduling.isInputPending():null,kx=Ft.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Dt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Dt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Zp(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(Dt.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!qc?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,a=s.context.work(()=>qc&&qc()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Dt.setState.of(new ss(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>_t(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ir=V.define({combine(n){return n.length?n[0]:null},enables:n=>[Dt.state,kx,j.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});var Sx=V.define(),jo=V.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function os(n){let e=n.facet(jo);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function ls(n,e){let t="",i=n.tabSize,r=n.facet(jo)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s<e;s++)t+=r;return t}function nd(n,e){n instanceof Ce&&(n=new yi(n));for(let i of n.state.facet(Sx)){let r=i(n,e);if(r!==void 0)return r}let t=Sn(n.state);return t.length>=e?Tx(n,t,e):null}var yi=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=os(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return ci(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Cx=new te;function Tx(n,e,t){let i=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return Qp(i,n,t)}function Qp(n,e,t){for(let i=n;i;i=i.next){let r=Mx(i.node);if(r)return r(Zc.create(e,t,i))}return 0}function Ax(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Mx(n){let e=n.type.prop(Cx);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(te.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>Lx(o,!0,1,void 0,s&&!Ax(o)?r.from:void 0)}return n.parent==null?Ex:null}function Ex(){return 0}var Zc=class n extends yi{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new n(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Rx(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Qp(this.context.next,this.base,this.pos)}};function Rx(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Dx(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let c=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+c}}l=a.to}}function Lx(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==n.pos+o,a=e?Dx(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}var Qc=class n{constructor(e,t){this.specs=e;let i;function r(l){let a=At.newName();return(i||(i=Object.create(null)))["."+a]=l,a}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof Dt?l=>l.prop(rs)==o.data:o?l=>l==o:void 0,this.style=Kc(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new At(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}};var BS=Qc.define([{tag:I.meta,color:"#404740"},{tag:I.link,textDecoration:"underline"},{tag:I.heading,textDecoration:"underline",fontWeight:"bold"},{tag:I.emphasis,fontStyle:"italic"},{tag:I.strong,fontWeight:"bold"},{tag:I.strikethrough,textDecoration:"line-through"},{tag:I.keyword,color:"#708"},{tag:[I.atom,I.bool,I.url,I.contentSeparator,I.labelName],color:"#219"},{tag:[I.literal,I.inserted],color:"#164"},{tag:[I.string,I.deleted],color:"#a11"},{tag:[I.regexp,I.escape,I.special(I.string)],color:"#e40"},{tag:I.definition(I.variableName),color:"#00f"},{tag:I.local(I.variableName),color:"#30a"},{tag:[I.typeName,I.namespace],color:"#085"},{tag:I.className,color:"#167"},{tag:[I.special(I.variableName),I.macroName],color:"#256"},{tag:I.definition(I.propertyName),color:"#00c"},{tag:I.comment,color:"#940"},{tag:I.invalid,color:"#f00"}]);var Ox=1e4,Px="()[]{}";var Ix=new te;function ed(n,e,t){let i=n.prop(e<0?te.openedBy:te.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function td(n){let e=n.type.prop(Ix);return e?e(n.node):n}function xi(n,e,t,i={}){let r=i.maxScanDistance||Ox,s=i.brackets||Px,o=Sn(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let c=ed(a.type,t,s);if(c&&a.from<a.to){let d=td(a);if(d&&(t>0?e>=d.from&&e<d.to:e>d.from&&e<=d.to))return Nx(n,e,t,a,d,c,s)}}return Bx(n,e,t,o,l.type,r,s)}function Nx(n,e,t,i,r,s,o){let l=i.parent,a={from:r.from,to:r.to},c=0,d=l?.cursor();if(d&&(t<0?d.childBefore(i.from):d.childAfter(i.to)))do if(t<0?d.to<=i.from:d.from>=i.to){if(c==0&&s.indexOf(d.type.name)>-1&&d.from<d.to){let u=td(d);return{start:a,end:u?{from:u.from,to:u.to}:void 0,matched:!0}}else if(ed(d.type,t,o))c++;else if(ed(d.type,-t,o)){if(c==0){let u=td(d);return{start:a,end:u&&u.from<u.to?{from:u.from,to:u.to}:void 0,matched:!1}}c--}}while(t<0?d.prevSibling():d.nextSibling());return{start:a,matched:!1}}function Bx(n,e,t,i,r,s,o){if(t<0?!e:e==n.doc.length)return null;let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},d=n.doc.iterRange(e,t>0?n.doc.length:0),u=0;for(let h=0;!d.next().done&&h<=s;){let f=d.value;t<0&&(h+=f.length);let p=e+h*t;for(let m=t>0?0:f.length-1,w=t>0?f.length:-1;m!=w;m+=t){let b=o.indexOf(f[m]);if(!(b<0||i.resolveInner(p+m,1).type!=r))if(b%2==0==t>0)u++;else{if(u==1)return{start:c,end:{from:p+m,to:p+m+1},matched:b>>1==a>>1};u--}}t>0&&(h+=f.length)}return d.done?{start:c,matched:!1}:null}var _x=Object.create(null),Xp=[xt.none];var Jp=[],Yp=Object.create(null),Hx=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Hx[n]=Fx(_x,e);function Xc(n,e){Jp.indexOf(n)>-1||(Jp.push(n),console.warn(e))}function Fx(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let c of l.split(".")){let d=n[c]||I[c];d?typeof d=="function"?a.length?a=a.map(d):Xc(c,`Modifier ${c} used at start of tag`):a.length?Xc(c,`Tag ${c} used as modifier`):a=Array.isArray(d)?d:[d]:Xc(c,`Unknown highlighting tag ${c}`)}for(let c of a)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(l=>l.id),s=Yp[r];if(s)return s.id;let o=Yp[r]=xt.define({id:Xp.length,name:i,props:[Kp({[i]:t})]});return Xp.push(o),o.id}var _S={rtl:be.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:we.RTL}),ltr:be.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:we.LTR}),auto:be.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var zx=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=cd(n.state,t.from);return i.line?Wx(n):i.block?$x(n):!1};function ad(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var Wx=ad(Kx,0);var Vx=ad(am,0);var $x=ad((n,e)=>am(n,e,jx(e)),0);function cd(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}var as=50;function Ux(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-as,i),o=n.sliceDoc(r,r+as),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,c=s.length-l;if(s.slice(c-e.length,c)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let d,u;r-i<=2*as?d=u=n.sliceDoc(i,r):(d=n.sliceDoc(i,i+as),u=n.sliceDoc(r-as,r));let h=/^\s*/.exec(d)[0].length,f=/\s*$/.exec(u)[0].length,p=u.length-f-t.length;return d.slice(h,h+e.length)==e&&u.slice(p,p+t.length)==t?{open:{pos:i+h+e.length,margin:/\s/.test(d.charAt(h+e.length))?1:0},close:{pos:r-f-t.length,margin:/\s/.test(u.charAt(p-1))?1:0}}:null}function jx(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to);r.from>i.from&&r.from==t.to&&(r=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function am(n,e,t=e.selection.ranges){let i=t.map(s=>cd(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>Ux(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=i[o],{open:c,close:d}=l;s.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:d.pos-d.margin,to:d.pos+a.close.length})}return{changes:s}}return null}function Kx(n,e,t=e.selection.ranges){let i=[],r=-1;e:for(let{from:s,to:o}of t){let l=i.length,a=1e9,c;for(let d=s;d<=o;){let u=e.doc.lineAt(d);if(c==null&&(c=cd(e,u.from).line,!c))continue e;if(u.from>r&&(s==o||o>u.from)){r=u.from;let h=/^\s*/.exec(u.text)[0].length,f=h==u.length,p=u.text.slice(h,h+c.length)==c?h:-1;h<u.text.length&&h<a&&(a=h),i.push({line:u,comment:p,token:c,indent:h,empty:f,single:!1})}d=u.to+1}if(a<1e9)for(let d=l;d<i.length;d++)i[d].indent<i[d].line.text.length&&(i[d].indent=a);i.length==l+1&&(i[l].single=!0)}if(n!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:c,empty:d,single:u}of i)(u||!d)&&s.push({from:l.from+c,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let c=o.from+l,d=c+a.length;o.text[d-o.from]==" "&&d++,s.push({from:c,to:d})}return{changes:s}}return null}var rd=ht.define(),Gx=ht.define(),qx=V.define(),cm=V.define({combine(n){return Vi(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,r)=>e(i,r)||t(i,r)})}}),dm=Tt.define({create(){return vi.empty},update(n,e){let t=e.state.facet(cm),i=e.annotation(rd);if(i){let a=$t.fromTransaction(e,i.selection),c=i.side,d=c==0?n.undone:n.done;return a?d=Go(d,d.length,t.minDepth,a):d=pm(d,e.startState.selection),new vi(c==0?i.rest:d,c==0?d:i.rest)}let r=e.annotation(Gx);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(Be.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=$t.fromTransaction(e),o=e.annotation(Be.time),l=e.annotation(Be.userEvent);return s?n=n.addChanges(s,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new vi(n.done.map($t.fromJSON),n.undone.map($t.fromJSON))}});function um(n={}){return[dm,cm.of(n),j.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?hm:e.inputType=="historyRedo"?sd:null;return i?(e.preventDefault(),i(t)):!1}})]}function qo(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(dm,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}var hm=qo(0,!1),sd=qo(1,!1),Xx=qo(0,!0),Jx=qo(1,!0);var $t=class n{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new n(e.changes&&it.fromJSON(e.changes),[],e.mapped&&bn.fromJSON(e.mapped),e.startSelection&&D.fromJSON(e.startSelection),e.selectionsAfter.map(D.fromJSON))}static fromTransaction(e,t){let i=Lt;for(let r of e.startState.facet(qx)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Lt)}static selection(e){return new n(void 0,Lt,void 0,void 0,e)}};function Go(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function Yx(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<t.length;){let c=t[a++],d=t[a++];l>=c&&o<=d&&(i=!0)}}),i}function Zx(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function fm(n,e){return n.length?e.length?n.concat(e):n:e}var Lt=[],Qx=200;function pm(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Qx));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Go(n,n.length-1,1e9,t.setSelAfter(i)))}else return[$t.selection([e])]}function e1(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function id(n,e){if(!n.length)return n;let t=n.length,i=Lt;for(;t;){let r=t1(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[$t.selection(i)]:Lt}function t1(n,e,t){let i=fm(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):Lt,t);if(!n.changes)return $t.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new $t(r,ve.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}var n1=/^(input\.type|delete)($|\.)/,vi=class n{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||n1.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,Yx(l.changes,e.changes))||i=="input.type.compose")?o=Go(o,o.length-1,r.minDepth,new $t(e.changes.compose(l.changes),fm(ve.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,Lt)):o=Go(o,o.length,r.minDepth,e),new n(o,Lt,t,i)}addSelection(e,t,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Lt;return s.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&Zx(s[s.length-1],e)?this:new n(pm(this.done,e),this.undone,t,i)}addMapping(e){return new n(id(this.done,e),id(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):t.selection);if(i&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:rd.of({side:e,rest:e1(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?Lt:r.slice(0,r.length-1);return s.mapped&&(l=id(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:rd.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};vi.empty=new vi(Lt,Lt);var mm=[{key:"Mod-z",run:hm,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:sd,preventDefault:!0},{linux:"Ctrl-Shift-z",run:sd,preventDefault:!0},{key:"Mod-u",run:Xx,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Jx,preventDefault:!0}];function rr(n,e){return D.create(n.ranges.map(e),n.mainIndex)}function Ut(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function jt({state:n,dispatch:e},t){let i=rr(n.selection,t);return i.eq(n.selection,!0)?!1:(e(Ut(n,i)),!0)}function Xo(n,e){return D.cursor(e?n.to:n.from)}function gm(n,e){return jt(n,t=>t.empty?n.moveByChar(t,e):Xo(t,e))}function Ze(n){return n.textDirectionAt(n.state.selection.main.head)==we.LTR}var bm=n=>gm(n,!Ze(n)),wm=n=>gm(n,Ze(n));function ym(n,e){return jt(n,t=>t.empty?n.moveByGroup(t,e):Xo(t,e))}var i1=n=>ym(n,!Ze(n)),r1=n=>ym(n,Ze(n));var US=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function s1(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Jo(n,e,t){let i=Sn(n).resolveInner(e.head),r=t?te.closedBy:te.openedBy;for(let a=e.head;;){let c=t?i.childAfter(a):i.childBefore(a);if(!c)break;s1(n,c,r)?i=c:a=t?c.to:c.from}let s=i.type.prop(r),o,l;return s&&(o=t?xi(n,i.from,1):xi(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,D.cursor(l,t?-1:1)}var o1=n=>jt(n,e=>Jo(n.state,e,!Ze(n))),l1=n=>jt(n,e=>Jo(n.state,e,Ze(n)));function xm(n,e){return jt(n,t=>{if(!t.empty)return Xo(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var vm=n=>xm(n,!1),km=n=>xm(n,!0);function Sm(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let s of n.state.facet(j.scrollMargins)){let o=s(n);o?.top&&(t=Math.max(o?.top,t)),o?.bottom&&(i=Math.max(o?.bottom,i))}r=n.scrollDOM.clientHeight-t-i}else r=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,r-5)}}function Cm(n,e){let t=Sm(n),{state:i}=n,r=rr(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):Xo(o,e));if(r.eq(i.selection))return!1;let s;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,c=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<c&&(s=j.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(Ut(i,r),{effects:s}),!0}var em=n=>Cm(n,!1),od=n=>Cm(n,!0);function $n(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=D.cursor(i.from+s))}return r}var a1=n=>jt(n,e=>$n(n,e,!0)),c1=n=>jt(n,e=>$n(n,e,!1)),d1=n=>jt(n,e=>$n(n,e,!Ze(n))),u1=n=>jt(n,e=>$n(n,e,Ze(n))),h1=n=>jt(n,e=>n.moveToLineBoundary(e,!1,!1)),f1=n=>jt(n,e=>n.moveToLineBoundary(e,!0,!1));function p1(n,e,t){let i=!1,r=rr(n.selection,s=>{let o=xi(n,s.head,-1)||xi(n,s.head,1)||s.head>0&&xi(n,s.head-1,1)||s.head<n.doc.length&&xi(n,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return t?D.range(s.anchor,l):D.cursor(l)});return i?(e(Ut(n,r)),!0):!1}var m1=({state:n,dispatch:e})=>p1(n,e,!1);function Ot(n,e,t){let i=rr(n.state.selection,r=>{r.undirectional&&r.head>=r.anchor!=e&&(r=D.range(r.head,r.anchor));let s=t(r);return D.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return i.eq(n.state.selection)?!1:(n.dispatch(Ut(n.state,i)),!0)}function Tm(n,e){return Ot(n,e,t=>n.moveByChar(t,e))}var Am=n=>Tm(n,!Ze(n)),Mm=n=>Tm(n,Ze(n));function Em(n,e){return Ot(n,e,t=>n.moveByGroup(t,e))}var g1=n=>Em(n,!Ze(n)),b1=n=>Em(n,Ze(n));var w1=n=>{let e=!Ze(n);return Ot(n,e,t=>Jo(n.state,t,e))},y1=n=>{let e=Ze(n);return Ot(n,e,t=>Jo(n.state,t,e))};function Rm(n,e){return Ot(n,e,t=>n.moveVertically(t,e))}var Dm=n=>Rm(n,!1),Lm=n=>Rm(n,!0);function Om(n,e){return Ot(n,e,t=>n.moveVertically(t,e,Sm(n).height))}var tm=n=>Om(n,!1),nm=n=>Om(n,!0),x1=n=>Ot(n,!0,e=>$n(n,e,!0)),v1=n=>Ot(n,!1,e=>$n(n,e,!1)),k1=n=>{let e=!Ze(n);return Ot(n,e,t=>$n(n,t,e))},S1=n=>{let e=Ze(n);return Ot(n,e,t=>$n(n,t,e))},C1=n=>Ot(n,!1,e=>D.cursor(n.lineBlockAt(e.head).from)),T1=n=>Ot(n,!0,e=>D.cursor(n.lineBlockAt(e.head).to)),im=({state:n,dispatch:e})=>(e(Ut(n,{anchor:0})),!0),rm=({state:n,dispatch:e})=>(e(Ut(n,{anchor:n.doc.length})),!0),sm=({state:n,dispatch:e})=>(e(Ut(n,{anchor:n.selection.main.anchor,head:0})),!0),om=({state:n,dispatch:e})=>(e(Ut(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),A1=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),M1=({state:n,dispatch:e})=>{let t=Yo(n).map(({from:i,to:r})=>D.undirectionalRange(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:D.create(t),userEvent:"select"})),!0},E1=({state:n,dispatch:e})=>{let t=rr(n.selection,i=>{let r=Sn(n),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return D.undirectionalRange(l.from,l.to)}return i});return t.eq(n.selection)?!1:(e(Ut(n,t)),!0)};function Pm(n,e){let{state:t}=n,i=t.selection,r=t.selection.ranges.slice();for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head);if(e?o.to<n.state.doc.length:o.from>0)for(let l=s;;){let a=n.moveVertically(l,e);if(a.head<o.from||a.head>o.to){r.some(c=>c.head==a.head)||r.push(a);break}else{if(a.head==l.head)break;l=a}}}return r.length==i.ranges.length?!1:(n.dispatch(Ut(t,D.create(r,r.length-1))),!0)}var R1=n=>Pm(n,!1),D1=n=>Pm(n,!0),L1=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=D.create([t.main]):t.main.empty||(i=D.create([D.cursor(t.main.head)])),i?(e(Ut(n,i)),!0):!1};function cs(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(t="delete.backward",a=Ko(n,a,!1)):a>o&&(t="delete.forward",a=Ko(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Ko(n,o,!1),l=Ko(n,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:D.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?j.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Ko(n,e,t){if(n instanceof j)for(let i of n.state.facet(j.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}var Im=(n,e,t)=>cs(n,i=>{let r=i.from,{state:s}=n,o=s.doc.lineAt(r),l,a;if(t&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(l[l.length-1]==" ")return r-1;let c=ci(l,s.tabSize),d=c%os(s)||os(s);for(let u=0;u<d&&l[l.length-1-u]==" ";u++)r--;a=r}else a=$e(o.text,r-o.from,e,e)+o.from,a==r&&o.number!=(e?s.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=$e(o.text,a-o.from,!1,!1)+o.from);return a}),ld=n=>Im(n,!1,!0);var Nm=n=>Im(n,!0,!1),Bm=(n,e)=>cs(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let a=$e(s.text,i-s.from,e)+s.from,c=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),d=o(c);if(l!=null&&d!=l)break;(c!=" "||i!=t.head)&&(l=d),i=a}return i}),_m=n=>Bm(n,!1),O1=n=>Bm(n,!0);var P1=n=>cs(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var I1=n=>cs(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),N1=n=>cs(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var B1=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:ne.of(["",""])},range:D.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},_1=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:$e(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:$e(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:n.doc.slice(r,l).append(n.doc.slice(o,r))},range:D.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Yo(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function Hm(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of Yo(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let a of s.ranges)r.push(D.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let a of s.ranges)r.push(D.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:D.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var H1=({state:n,dispatch:e})=>Hm(n,e,!1),F1=({state:n,dispatch:e})=>Hm(n,e,!0);function Fm(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of Yo(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});let r=n.changes(i);return e(n.update({changes:r,selection:n.selection.map(r,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var z1=({state:n,dispatch:e})=>Fm(n,e,!1),W1=({state:n,dispatch:e})=>Fm(n,e,!0),V1=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Yo(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=rr(e.selection,r=>{let s;if(n.lineWrapping){let o=n.lineBlockAt(r.head),l=n.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(r,!0,s)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function $1(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Sn(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(te.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}var lm=zm(!1),U1=zm(!0);function zm(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!n&&s==o&&$1(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let c=new yi(e,{simulateBreak:s,simulateDoubleBreak:!!a}),d=nd(c,s);for(d==null&&(d=ci(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let u=["",ls(e,d)];return a&&u.push(ls(e,c.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:ne.of(u)},range:D.cursor(s+1+u[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function dd(n,e){let t=-1;return n.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,r,i),t=l.number),o=l.to+1}let s=n.changes(r);return{changes:r,range:D.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}var j1=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new yi(n,{overrideIndentation:s=>{let o=t[s];return o??-1}}),r=dd(n,(s,o,l)=>{let a=nd(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let c=/^\s*/.exec(s.text)[0],d=ls(n,a);(c!=d||l.from<s.from+c.length)&&(t[s.from]=a,o.push({from:s.from,to:s.from+c.length,insert:d}))});return r.changes.empty||e(n.update(r,{userEvent:"indent"})),!0},Wm=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(dd(n,(t,i)=>{i.push({from:t.from,insert:n.facet(jo)})}),{userEvent:"input.indent"})),!0),Vm=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(dd(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=ci(r,n.tabSize),o=0,l=ls(n,Math.max(0,s-os(n)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),K1=n=>(n.setTabFocusMode(),!0);var G1=[{key:"Ctrl-b",run:bm,shift:Am,preventDefault:!0},{key:"Ctrl-f",run:wm,shift:Mm},{key:"Ctrl-p",run:vm,shift:Dm},{key:"Ctrl-n",run:km,shift:Lm},{key:"Ctrl-a",run:h1,shift:C1},{key:"Ctrl-e",run:f1,shift:T1},{key:"Ctrl-d",run:Nm},{key:"Ctrl-h",run:ld},{key:"Ctrl-k",run:P1},{key:"Ctrl-Alt-h",run:_m},{key:"Ctrl-o",run:B1},{key:"Ctrl-t",run:_1},{key:"Ctrl-v",run:od}],q1=[{key:"ArrowLeft",run:bm,shift:Am,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:i1,shift:g1,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:d1,shift:k1,preventDefault:!0},{key:"ArrowRight",run:wm,shift:Mm,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:r1,shift:b1,preventDefault:!0},{mac:"Cmd-ArrowRight",run:u1,shift:S1,preventDefault:!0},{key:"ArrowUp",run:vm,shift:Dm,preventDefault:!0},{mac:"Cmd-ArrowUp",run:im,shift:sm},{mac:"Ctrl-ArrowUp",run:em,shift:tm},{key:"ArrowDown",run:km,shift:Lm,preventDefault:!0},{mac:"Cmd-ArrowDown",run:rm,shift:om},{mac:"Ctrl-ArrowDown",run:od,shift:nm},{key:"PageUp",run:em,shift:tm},{key:"PageDown",run:od,shift:nm},{key:"Home",run:c1,shift:v1,preventDefault:!0},{key:"Mod-Home",run:im,shift:sm},{key:"End",run:a1,shift:x1,preventDefault:!0},{key:"Mod-End",run:rm,shift:om},{key:"Enter",run:lm,shift:lm},{key:"Mod-a",run:A1},{key:"Backspace",run:ld,shift:ld,preventDefault:!0},{key:"Delete",run:Nm,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:_m,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:O1,preventDefault:!0},{mac:"Mod-Backspace",run:I1,preventDefault:!0},{mac:"Mod-Delete",run:N1,preventDefault:!0}].concat(G1.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),$m=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:o1,shift:w1},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:l1,shift:y1},{key:"Alt-ArrowUp",run:H1},{key:"Shift-Alt-ArrowUp",run:z1},{key:"Alt-ArrowDown",run:F1},{key:"Shift-Alt-ArrowDown",run:W1},{key:"Mod-Alt-ArrowUp",run:R1},{key:"Mod-Alt-ArrowDown",run:D1},{key:"Escape",run:L1},{key:"Mod-Enter",run:U1},{key:"Alt-l",mac:"Ctrl-l",run:M1},{key:"Mod-i",run:E1,preventDefault:!0},{key:"Mod-[",run:Vm},{key:"Mod-]",run:Wm},{key:"Mod-Alt-\\",run:j1},{key:"Shift-Mod-k",run:V1},{key:"Shift-Mod-\\",run:m1},{key:"Mod-/",run:zx},{key:"Alt-A",mac:"Ctrl-A",run:Vx},{key:"Ctrl-m",mac:"Shift-Alt-m",run:K1}].concat(q1),Um={key:"Tab",run:Wm,shift:Vm};var jm=new wn,Km=new wn,Gm=new wn,ud=new wn,hd=ht.define(),cn=null;function qm(n){cn=n}function Xm(n){cn===n&&(cn=null)}function Jm(n){return[j.domEventHandlers({keydown:(e,t)=>cn?.onKeydown(t,e)??!1,compositionstart:()=>(cn?.onCompositionChange(!0),!1),compositionend:()=>(setTimeout(()=>cn?.onCompositionChange(!1),0),!1),focus:()=>(cn?.onFocusChange(!0),!1),blur:()=>(cn?.onFocusChange(!1),!1)}),um(),Pp(),Bp(),j.lineWrapping,_p(),Hp(),jm.of(n.lineNumbers?Bc():[]),Km.of(Qm(n.fontFamily)),Gm.of(Nc(n.placeholder)),ud.of(j.editable.of(n.editable)),Ic.of([...mm,...$m,Um]),j.updateListener.of(e=>{e.docChanged&&!e.transactions.some(t=>t.annotation(hd)===!0)&&cn?.onLocalChange(e.state.doc.toString()),(e.docChanged||e.selectionSet)&&cn?.onCaret(e.state.doc.toString(),e.state.selection.main.head)})]}function fd(n,e){n.dispatch({effects:[jm.reconfigure(e.lineNumbers?Bc():[]),Km.reconfigure(Qm(e.fontFamily)),Gm.reconfigure(Nc(e.placeholder)),ud.reconfigure(j.editable.of(e.editable))]})}function Ym(n,e){n.dispatch({effects:ud.reconfigure(j.editable.of(e))})}function Zm(n,e,t){return pn(()=>{let i=ue();fd(n,{lineNumbers:i.lineNumbers,fontFamily:i.fontFamily,placeholder:e,editable:t})})}function Qm(n){return j.theme({"&":{fontSize:"13px",height:"100%"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:n,lineHeight:"1.6",overflow:"auto"},".cm-content":{caretColor:"var(--dsw-alias-state-business-primary, currentColor)",paddingBottom:"8px"},".cm-line":{padding:"0 8px"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--dsw-alias-state-business-primary, currentColor)"},".cm-gutters":{backgroundColor:"transparent",border:"none",color:"color-mix(in srgb, currentColor 32%, transparent)"},".cm-activeLineGutter":{backgroundColor:"transparent",color:"currentColor",fontWeight:600},".cm-activeLine":{backgroundColor:"color-mix(in srgb, currentColor 6%, transparent)"},".cm-lineNumbers .cm-gutterElement":{minWidth:"2.2em",padding:"0 6px 0 10px"},".cm-selectionBackground":{backgroundColor:"color-mix(in srgb, currentColor 15%, transparent) !important"},".cm-placeholder":{color:"color-mix(in srgb, currentColor 38%, transparent)"}})}function eg(n,e){return Ce.create({doc:e,extensions:n})}var X1=4,ki=new Map;function tg(n){let e=ki.get(n);return e&&ki.delete(n),e}function ng(n,e){for(ki.delete(n),ki.set(n,e);ki.size>X1;){let t=ki.keys().next().value;if(t===void 0)break;ki.delete(t)}}function J1(n){return n==="plain"?{tier:"plain"}:n==="claimed"?{tier:"claimed"}:{tier:"frozen"}}function ig(n,e,t,i){if(!(!n||!i))try{n.track(e,t,J1(i.phase),i.draftRev)}catch(r){Zt("track failed",r)}}function rg(n,e,t){if(!n)return;let i=e?.snapshot,r=i?.draft??"",s=i?.draftRev??0;e?.dismissPopup();let o={trigger:"/",query:"",quoted:!1,position:r.slice(0,t).trim()===""?"leading":"inline",span:{start:t,end:t,draftRev:s}};n.toggleSource("command",o)}var Y1={ArrowUp:"up",ArrowDown:"down",Enter:"enter",Escape:"escape",Tab:"tab"};function sg(n,e,t){if(!n||!n.menu.getSnapshot().open)return!1;let r=Y1[e.key];return r?n.arbitrate(r,t)!=="pass":!1}function og(n){if(!n)return!1;try{return n.onSpace()}catch{return!1}}var Z1=new Set(["ctrl","alt","shift","meta","mod"]);function lg(n,e){let t=e===" "?"space":(e.length===1,e.toLowerCase()),i=[];return n.ctrlKey&&i.push("ctrl"),n.altKey&&i.push("alt"),n.shiftKey&&i.push("shift"),n.metaKey&&i.push("meta"),i.push(t),i.join("+")}function Q1(n){let e=new Set(n.toLowerCase().split("+").filter(Boolean)),t=[...e].filter(i=>!Z1.has(i)).join("+");return{ctrl:e.has("ctrl"),alt:e.has("alt"),shift:e.has("shift"),meta:e.has("meta"),mod:e.has("mod"),key:t}}function pd(n,e){let t=Q1(n);return!t.key||t.key!==ev(e)?!1:t.mod?e.ctrlKey||e.metaKey?e.altKey===t.alt&&e.shiftKey===t.shift:!1:e.ctrlKey===t.ctrl&&e.altKey===t.alt&&e.shiftKey===t.shift&&e.metaKey===t.meta}function ev(n){let e=n.key;return e===" "?"space":e.toLowerCase()}function ag(n){let e={ctrl:"Ctrl",alt:"Alt",shift:"Shift",meta:"Cmd",mod:"Ctrl/Cmd",enter:"Enter",tab:"Tab",space:"Space",escape:"Esc"};return n.split("+").filter(Boolean).map(t=>e[t]??(t.length===1?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1))).join(" + ")}var ds=require("react/jsx-runtime");function cg(n){let{state:e,actions:t,triggers:i,keyboard:r,onSendGesture:s,placeholder:o,autoFocus:l,viewRef:a,onCaretMoved:c,disabled:d,solo:u,stateKey:h}=n,f=(0,Pt.useRef)(null),p=(0,Pt.useRef)(!1),[m,w]=(0,Pt.useState)({line:1,col:1}),b=(0,Pt.useRef)(n);b.current=n;let v=e?.draft??"",k=h??"default";(0,Pt.useLayoutEffect)(()=>{let S=f.current;if(!S)return;let C=ue(),A={onKeydown:(M,P)=>{let z=b.current;if(sg(z.triggers,P,p.current))return P.preventDefault(),!0;if(p.current)return!1;if(P.key===" "&&!P.ctrlKey&&!P.metaKey&&!P.altKey&&og(z.triggers))return P.preventDefault(),!0;let J=ue();return pd(J.sendHotkey,P)?(P.preventDefault(),z.onSendGesture(),!0):pd(J.lineBreakHotkey,P)&&J.lineBreakHotkey!=="enter"?(P.preventDefault(),M.dispatch({changes:{from:M.state.selection.main.head,insert:`
727
- `}}),!0):!1},onLocalChange:M=>{let P=b.current;if(P.actions)try{P.actions.setDraft(M)}catch(z){Zt("setDraft failed",z)}},onCaret:(M,P)=>{let z=b.current;ig(z.triggers,M,P,z.keyboard?.snapshot??z.state);let q=a.current?.state.doc.lineAt(P);w({line:q?q.number:1,col:P-(q?q.from:0)+1}),z.onCaretMoved?.(P)},onCompositionChange:M=>{p.current=M},onFocusChange:M=>{b.current.onFocusedChange?.(M)}};qm(A);let $=tg(k),F=new j({state:$?.state??eg(Jm({lineNumbers:C.lineNumbers,fontFamily:C.fontFamily,placeholder:o,editable:!0}),""),parent:S});$&&(F.scrollDOM.scrollTop=$.scrollTop),a.current=F;let R=F.state.selection.main.head,O=F.state.doc.lineAt(R);return w({line:O.number,col:R-O.from+1}),l&&F.focus(),()=>{a.current=null,ng(k,{state:F.state,scrollTop:F.scrollDOM.scrollTop}),F.destroy(),Xm(A)}},[k]),(0,Pt.useEffect)(()=>{let S=a.current;if(!S)return;let C=S.state.doc.toString();if(v===C)return;let A=Math.min(S.state.selection.main.head,v.length);S.dispatch({annotations:[hd.of(!0),Be.addToHistory.of(!1)],changes:{from:0,to:C.length,insert:v},selection:{anchor:v===""?0:A},scrollIntoView:!0})},[v]),(0,Pt.useEffect)(()=>{let S=a.current;if(!S)return;let C=Zm(S,o,!0);return fd(S,{...tv(o),editable:!0}),C},[o]);let N=d===!0||e!==void 0&&(e.phase==="adjudicating"||e.phase==="submitting");return(0,Pt.useEffect)(()=>{let S=a.current;S&&Ym(S,!N)},[N,a]),(0,ds.jsxs)("div",{className:"dci-editor-wrap","data-solo":u||void 0,children:[(0,ds.jsx)("div",{className:"dci-cm-host",ref:f}),(0,ds.jsxs)("div",{className:"dci-pos",children:[m.line,", ",m.col]})]})}function tv(n){let e=ue();return{lineNumbers:e.lineNumbers,fontFamily:e.fontFamily,placeholder:n}}var vt=require("react");var us=require("react");function Cn(n){let e=(0,us.useCallback)(i=>n?n.subscribe(i):()=>{},[n]),t=(0,us.useCallback)(()=>n?.getSnapshot(),[n]);return(0,us.useSyncExternalStore)(e,t,t)}var re=require("react/jsx-runtime"),md=400;function nv(n){return Ii(`menu.source.${n}`)??n}function Zo(n,e){return`dsh-slash-option-${n}-${e}`}function iv(n){return n==="file"?(0,re.jsx)(wh,{size:16}):n==="folder"?(0,re.jsx)(yh,{size:16}):n==="session"?(0,re.jsx)(xh,{size:16}):typeof n=="function"?(0,re.jsx)(n,{size:16}):null}function dg({size:n=14}){return(0,re.jsx)("span",{style:{display:"inline-flex",transform:"rotate(-90deg)"},children:(0,re.jsx)(en,{size:n})})}function ug(n){let{triggers:e,dropdown:t}=n,i=Cn(e.menu),r=Cn(e.headers),s=(0,vt.useRef)(null),[o,l]=(0,vt.useState)(md),[a,c]=(0,vt.useState)(null),d=i?.open===!0,u=d?i.highlight??null:null;if((0,vt.useLayoutEffect)(()=>{if(!d)return;let f=s.current?.closest(".dci-card");if(!f)return;if(t){let m=f.querySelector(".dci-accessory"),w=f.getBoundingClientRect(),b=m?m.getBoundingClientRect().bottom-w.top:36;c(Math.round(b)+2);let k=!!s.current?.closest(".dci-float")?window.innerHeight-(w.top+b)-16:w.height-b-10;l(Math.max(120,Math.min(md,k)));return}c(null);let p=f.getBoundingClientRect().top;l(Math.max(120,Math.min(md,p-16)))},[d,i?.generation,t]),(0,vt.useEffect)(()=>{u&&document.getElementById(Zo(u.source,u.index))?.scrollIntoView({block:"nearest"})},[u]),(0,vt.useEffect)(()=>{if(!d)return;let f=p=>{p.target instanceof Node&&(s.current?.contains(p.target)||s.current?.closest("[data-composer-card]")?.contains(p.target)||e.dismiss())};return document.addEventListener("pointerdown",f,!0),()=>document.removeEventListener("pointerdown",f,!0)},[d,e]),!d||!i)return null;let h=f=>r?.get(f);return(0,re.jsxs)("div",{ref:s,className:"dci-slash-menu","data-trigger-menu":"","data-dropdown":t||void 0,style:t?{top:a??38,maxHeight:o}:{maxHeight:o},children:[i.groups.map(f=>{let p=h(f.source);return p===void 0||p.length===0?null:(0,re.jsx)("nav",{className:"dci-slash-crumbs","aria-label":x("menu.nav"),children:p.map((m,w)=>(0,re.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:2},children:[w>0?(0,re.jsx)("span",{className:"dci-slash-crumbSeparator","aria-hidden":"true",children:(0,re.jsx)(dg,{size:12})}):null,(0,re.jsx)("button",{type:"button",className:"dci-slash-crumb","data-current":m.current===!0||void 0,"aria-current":m.current===!0?"location":void 0,disabled:m.current===!0,onMouseDown:b=>{b.preventDefault(),e.pickCrumb(f.source,w)},children:m.label})]},`${w}-${m.value}`))},`${f.source}:crumbs`)}),(0,re.jsx)("div",{className:"dci-slash-viewport",role:"listbox","aria-label":x("menu.triggerCandidates"),"aria-activedescendant":u?Zo(u.source,u.index):void 0,children:i.groups.map(f=>{if(f.status==="ready"&&f.items.length===0)return null;let p=f.items.some(m=>m.section!==void 0);return(0,re.jsxs)(vt.Fragment,{children:[f.showGroupTitle===!1||p?null:(0,re.jsx)("div",{className:"dci-slash-groupTitle",role:"presentation","data-source":f.source,children:nv(f.source)}),f.status==="pending"&&f.items.length===0?(0,re.jsxs)("div",{role:"status","aria-label":Ii("menu.loading"),"data-source":f.source,children:[(0,re.jsx)("div",{className:"dci-slash-skeletonRow",children:(0,re.jsx)("span",{className:"dci-slash-skeletonBar",style:{width:"32%"}})}),(0,re.jsx)("div",{className:"dci-slash-skeletonRow",children:(0,re.jsx)("span",{className:"dci-slash-skeletonBar",style:{width:"48%"}})})]}):f.items.map((m,w)=>{let b=u?.source===f.source&&u.index===w;return(0,re.jsxs)(vt.Fragment,{children:[m.section!==void 0&&m.section!==f.items[w-1]?.section?(0,re.jsx)("div",{className:"dci-slash-sectionTitle",role:"presentation",children:m.section}):null,(0,re.jsxs)("button",{id:Zo(f.source,w),type:"button",role:"option","aria-selected":b,className:"dci-slash-item","data-active":b||void 0,onMouseDown:v=>{v.preventDefault(),e.pick(f.source,w)},onMouseMove:b?void 0:()=>e.hover(f.source,w),children:[m.icon!==void 0?(0,re.jsx)("span",{className:"dci-slash-itemIcon","aria-hidden":"true",children:iv(m.icon)}):null,(0,re.jsx)("span",{className:"dci-slash-itemName",children:m.label??m.name}),m.label!==void 0&&m.label.toLowerCase()!==m.name.toLowerCase()?(0,re.jsx)("span",{className:"dci-slash-itemAlias",children:m.name}):null,m.description!==void 0?(0,re.jsx)("span",{className:"dci-slash-itemDescription",children:m.description}):null,m.drill===!0?(0,re.jsxs)("span",{className:"dci-slash-trailing",children:[(0,re.jsx)("span",{className:"dci-slash-drillHintText","aria-hidden":"true",children:"\u8FDB\u5165\u76EE\u5F55"}),(0,re.jsx)("kbd",{className:"dci-slash-drillHint","aria-hidden":"true",children:"Tab"}),(0,re.jsx)("span",{role:"button","aria-label":Ii("menu.drill"),className:"dci-slash-drill",onMouseDown:v=>{v.preventDefault(),v.stopPropagation(),e.pick(f.source,w,"drill")},children:(0,re.jsx)(dg,{size:14})})]}):null]})]},Zo(f.source,w))})]},f.source)})})]})}var Un=require("react");function hg(n,e){let t=e.trim().toLowerCase();return t===""?n:n.filter(i=>{let r=typeof i.label=="string"?i.label.toLowerCase():"",s=typeof i.detail=="string"?i.detail.toLowerCase():"";return r.includes(t)||s.includes(t)})}var Ae=require("react/jsx-runtime");function fg(n){let{popup:e}=n,t=Cn(e.state),i=(0,Un.useRef)(null),r=(0,Un.useRef)(null),s=(0,Un.useMemo)(()=>t?hg(t.options,t.search):[],[t?.options,t?.search]);if((0,Un.useEffect)(()=>{if(!t?.open)return;let l=c=>{r.current&&c.target instanceof Node&&r.current.contains(c.target)||e.dismiss()},a=c=>{if(!(!t.open||t.submitting)){if(t.confirming){c.key==="Escape"&&(c.preventDefault(),e.cancelConfirmation());return}c.key==="ArrowDown"?(c.preventDefault(),e.move(1)):c.key==="ArrowUp"?(c.preventDefault(),e.move(-1)):c.key==="Enter"?(c.preventDefault(),e.select(t.active)):c.key==="Escape"&&(c.preventDefault(),e.dismiss({focusComposer:!0}))}};return window.addEventListener("pointerdown",l,!0),window.addEventListener("keydown",a,!0),()=>{window.removeEventListener("pointerdown",l,!0),window.removeEventListener("keydown",a,!0)}},[t?.open,t?.submitting,t?.confirming,t?.active,e]),(0,Un.useEffect)(()=>{t?.open&&i.current?.focus()},[t?.open]),!t?.open)return null;let o=t.confirming;return(0,Ae.jsxs)("div",{className:"dci-menu",ref:r,children:[t.command?(0,Ae.jsx)("div",{className:"dci-group-title",children:t.command}):null,t.status==="failed"?(0,Ae.jsx)("div",{className:"dci-error",children:t.error??x("menu.loadFailed")}):null,t.status==="failed"?(0,Ae.jsx)("button",{type:"button",className:"dci-btn",onClick:()=>e.retry(),children:"\u91CD\u8BD5"}):null,t.status==="ready"&&!o?(0,Ae.jsx)("input",{ref:i,className:"dci-search",type:"text",placeholder:x("menu.filter"),value:t.search,onChange:l=>e.setSearch(l.target.value)}):null,o?(0,Ae.jsxs)("div",{className:"dci-confirm",children:[(0,Ae.jsx)("div",{className:"dci-row-name",children:String(o.label??"")}),o.detail?(0,Ae.jsx)("div",{className:"dci-row-desc",children:String(o.detail)}):null,(0,Ae.jsxs)("label",{children:[(0,Ae.jsx)("input",{type:"checkbox",checked:t.acknowledged,onChange:l=>e.acknowledge(l.target.checked)}),(0,Ae.jsx)("span",{children:x("popup.ack")})]}),(0,Ae.jsxs)("div",{className:"dci-confirm-actions",children:[(0,Ae.jsx)("button",{type:"button",className:"dci-btn",onClick:()=>e.cancelConfirmation(),children:"\u53D6\u6D88"}),(0,Ae.jsx)("button",{type:"button",className:"dci-btn","data-primary":"true",disabled:t.submitting||!t.acknowledged,onClick:()=>void e.confirm(),children:"\u786E\u8BA4"})]})]}):(0,Ae.jsxs)("div",{className:"dci-viewport",children:[t.status==="pending"?(0,Ae.jsx)("div",{className:"dci-empty",children:x("menu.loading")}):null,t.status==="ready"&&s.length===0?(0,Ae.jsx)("div",{className:"dci-empty",children:x("menu.empty")}):null,s.map((l,a)=>(0,Ae.jsx)("button",{type:"button",className:"dci-opt","data-active":a===t.active||void 0,onMouseEnter:()=>e.highlight(a),onClick:()=>void e.select(a),children:(0,Ae.jsxs)("span",{className:"dci-opt-copy",children:[(0,Ae.jsx)("span",{className:"dci-opt-name",children:String(l.label??"")}),l.detail?(0,Ae.jsx)("span",{className:"dci-opt-desc",children:String(l.detail)}):null]})},`${String(l.label)}:${a}`))]}),t.error&&t.status==="ready"?(0,Ae.jsx)("div",{className:"dci-error",children:t.error}):null]})}var Si=require("react");var hs=require("react"),pg=require("react-dom"),dn=require("react/jsx-runtime");function rv({size:n=16}){return(0,dn.jsxs)("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",strokeWidth:1,children:[(0,dn.jsx)("path",{d:"M2.5 2.5L13.5 13.5",stroke:"currentColor"}),(0,dn.jsx)("path",{d:"M13.5 2.5L2.5 13.5",stroke:"currentColor"})]})}function mg(n){let{src:e,alt:t,labels:i,onClose:r}=n,s=(0,hs.useRef)(null),o=(0,hs.useRef)(null);return(0,hs.useEffect)(()=>{o.current=document.activeElement instanceof HTMLElement?document.activeElement:null,s.current?.focus();let l=a=>{a.key==="Escape"&&(a.stopPropagation(),r()),a.key==="Tab"&&(a.preventDefault(),s.current?.focus())};return window.addEventListener("keydown",l,!0),()=>{window.removeEventListener("keydown",l,!0),o.current?.focus()}},[r]),(0,pg.createPortal)((0,dn.jsxs)("div",{className:"dci-lightbox",role:"dialog","aria-modal":"true","aria-label":i.dialog,children:[(0,dn.jsx)("div",{className:"dci-lightbox-mask","aria-hidden":"true",onMouseDown:r}),(0,dn.jsx)("img",{className:"dci-lightbox-image",src:e,alt:t}),(0,dn.jsx)("button",{ref:s,type:"button",className:"dci-lightbox-close","aria-label":i.close,onClick:r,children:(0,dn.jsx)(rv,{})})]}),document.body)}var Q=require("react/jsx-runtime"),sv="M8.48924 28H19.5108C21.6479 28 22.7165 28 23.5594 27.6509C24.6833 27.1853 25.5762 26.2924 26.0417 25.1685C26.3909 24.3256 26.3909 23.257 26.3909 21.1199V8.79443C26.3909 8.32877 26.3909 8.09593 26.3471 7.87507C26.2887 7.58058 26.173 7.30042 26.0067 7.05048C25.882 6.86303 25.7177 6.69799 25.3893 6.36792L20.0611 1.01354C19.7304 0.681235 19.5651 0.515081 19.3769 0.38885C19.126 0.220541 18.8443 0.103463 18.5481 0.0443412C18.3259 0 18.0915 0 17.6226 0H8.48924C6.35209 0 5.28351 0 4.4406 0.349145C3.31672 0.814671 2.4238 1.70759 1.95828 2.83147C1.60913 3.67438 1.60913 4.74296 1.60913 6.88011V21.1199C1.60913 23.257 1.60913 24.3256 1.95828 25.1685C2.4238 26.2924 3.31672 27.1853 4.4406 27.6509C5.28351 28 6.35209 28 8.48924 28Z",ov="M26.3909 7.37445L19.0525 0V3.77445C19.0525 4.89271 19.0525 5.45184 19.2352 5.89289C19.4788 6.48096 19.946 6.94818 20.5341 7.19176C20.9751 7.37445 21.5342 7.37445 22.6525 7.37445H26.3909Z";function fs({size:n=28}){return(0,Q.jsxs)("svg",{width:n,height:n,viewBox:"0 0 28 28",fill:"none","aria-hidden":"true",children:[(0,Q.jsx)("path",{d:sv,fill:"currentColor"}),(0,Q.jsx)("path",{d:ov,fill:"var(--dsw-static-neutral-00, #fff)",fillOpacity:"0.7"})]})}function gd(n){let e=n.split(/[\\/]/).pop()??n,t=e.lastIndexOf(".");return t<0?"":e.slice(t+1)}function Qo(n){if(n<1024)return`${n}B`;let e=n/1024;if(e<1024)return`${e<10?e.toFixed(1):Math.round(e)}KB`;let t=e/1024;if(t<1024)return`${t<10?t.toFixed(1):Math.round(t)}MB`;let i=t/1024;return`${i<10?i.toFixed(1):Math.round(i)}GB`}function wg(n){let{state:e,sessionId:t,onRemove:i}=n,r=Y.conversation,s=Cn(r?.fileUploads),o=(0,Si.useRef)(null),[l,a]=(0,Si.useState)({left:!1,right:!1}),[c,d]=(0,Si.useState)(null),u=e===void 0||typeof r?.resolveDraftAttachments!="function"?[]:r.resolveDraftAttachments(e.attachmentIds)??[];if((0,Si.useEffect)(()=>{let f=o.current;if(!f)return;let p=()=>{let b=f.scrollWidth-f.clientWidth,v={left:f.scrollLeft>1,right:b>1&&f.scrollLeft<b-1};a(k=>k.left===v.left&&k.right===v.right?k:v)};p(),f.addEventListener("scroll",p,{passive:!0});let m=typeof ResizeObserver=="function"?new ResizeObserver(p):null;m?.observe(f);let w=b=>{Math.abs(b.deltaY)<=Math.abs(b.deltaX)||(b.preventDefault(),f.scrollLeft+=b.deltaY)};return f.addEventListener("wheel",w,{passive:!1}),()=>{f.removeEventListener("scroll",p),f.removeEventListener("wheel",w),m?.disconnect()}},[u.length]),u.length===0)return null;let h=f=>{o.current?.scrollBy({left:f*Math.max(120,(o.current?.clientWidth??240)*.8),behavior:"smooth"})};return(0,Q.jsxs)("div",{className:"dci-attach-root",children:[(0,Q.jsx)("div",{className:"dci-attach-rail",ref:o,role:"group","aria-label":x("attach.group"),children:u.map(f=>{let p=s?.[f.id],m=p?.status??"ready",w=f.kind==="image"||f.file.type.startsWith("image/"),b=m==="uploading"&&p?.total?Math.min(100,Math.round((p.loaded??0)/p.total*100)):null;if(w)return(0,Q.jsxs)("div",{className:"dci-attach-item",children:[(0,Q.jsx)("button",{type:"button",className:"dci-attach-thumb",title:x("image.openOriginal"),"aria-label":x("image.openOriginalLabel",{name:f.file.name}),onClick:()=>{f.previewUrl&&d({url:f.previewUrl,name:f.file.name})},children:f.previewUrl?(0,Q.jsx)("img",{src:f.previewUrl,alt:f.file.name}):(0,Q.jsx)(fs,{size:28})}),(0,Q.jsx)("button",{type:"button",className:"dci-attach-remove","aria-label":x("attach.remove",{name:f.file.name}),onClick:()=>i(f.id),children:(0,Q.jsx)(gg,{})}),b!==null?(0,Q.jsx)("span",{className:"dci-attach-progress",children:(0,Q.jsx)("span",{className:"dci-attach-progressBar",style:{width:`${b}%`}})}):null]},f.id);let v=m==="error",k=m==="uploading"?x("attach.uploading"):v?x("attach.failed"):[gd(f.file.name).toUpperCase().slice(0,8),Qo(f.file.size)].filter(S=>S!=="").join(" "),N=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("span",{className:"dci-attach-name",children:f.file.name}),(0,Q.jsx)("span",{className:v?"dci-attach-meta dci-attach-metaFailed":"dci-attach-meta",children:k})]});return(0,Q.jsxs)("div",{className:v?"dci-attach-card dci-attach-cardFailed":"dci-attach-card",title:f.file.name,children:[(0,Q.jsx)("span",{className:"dci-attach-icon","aria-hidden":"true",children:m==="uploading"?(0,Q.jsx)("span",{className:"dci-attach-spinner"}):(0,Q.jsx)(fs,{size:28})}),v?(0,Q.jsx)("button",{type:"button",className:"dci-attach-body dci-attach-retry","aria-label":x("attach.retry"),onClick:()=>lv(t,f.id),children:N}):(0,Q.jsx)("span",{className:"dci-attach-body","aria-label":x("attach.pending",{name:f.file.name}),children:N}),(0,Q.jsx)("button",{type:"button",className:v?"dci-attach-removeInline dci-attach-cardFailedRemove":"dci-attach-removeInline","aria-label":x("attach.remove",{name:f.file.name}),onClick:()=>i(f.id),children:(0,Q.jsx)(gg,{})}),b!==null?(0,Q.jsx)("span",{className:"dci-attach-progress",children:(0,Q.jsx)("span",{className:"dci-attach-progressBar",style:{width:`${b}%`}})}):null]},f.id)})}),l.left?(0,Q.jsx)("button",{type:"button",className:"dci-attach-arrow dci-attach-arrowLeft","aria-label":x("attach.scrollLeft"),onClick:()=>h(-1),children:(0,Q.jsx)(bg,{dir:"left"})}):null,l.right?(0,Q.jsx)("button",{type:"button",className:"dci-attach-arrow dci-attach-arrowRight","aria-label":x("attach.scrollRight"),onClick:()=>h(1),children:(0,Q.jsx)(bg,{dir:"right"})}):null,c?(0,Q.jsx)(mg,{src:c.url,alt:c.name,labels:{dialog:x("image.preview"),close:x("image.closePreview")},onClose:()=>d(null)}):null]})}function lv(n,e){let t=Y.conversation;if(!(!n||typeof t?.retryFileUpload!="function"))try{t.retryFileUpload(n,e)}catch{}}function gg(){return(0,Q.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:(0,Q.jsx)("path",{d:"M1.6 1.6L8.4 8.4M8.4 1.6L1.6 8.4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function bg({dir:n}){return(0,Q.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",style:n==="left"?{transform:"scaleX(-1)"}:void 0,children:(0,Q.jsx)("path",{d:"M5.5 3.5L9 7L5.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}var ll=require("react");var Gt=require("react");function yg(n){let e=Y.modelDirectories;if(!e||typeof e.directoryFor!="function"||!n)return null;try{return e.directoryFor(n)}catch(t){return Zt("directoryFor failed",t),null}}var ms=require("react");var Kt=require("react");var bd=[];function jn(n){let e=Y.slots,t=(0,Kt.useCallback)(r=>{if(typeof e?.subscribe!="function")return()=>{};try{return e.subscribe(n,r)??(()=>{})}catch{return()=>{}}},[e,n]),i=(0,Kt.useCallback)(()=>{if(typeof e?.entries!="function")return bd;try{return e.entries(n)??bd}catch{return bd}},[e,n]);return(0,Kt.useSyncExternalStore)(t,i,i)}var av=[Symbol.for("react.memo"),Symbol.for("react.forward_ref"),Symbol.for("react.lazy")];function Sg(n){if(typeof n=="function")return!0;if(n===null||typeof n!="object")return!1;let e=n.$$typeof;return typeof e=="symbol"&&av.includes(e)}function sr(n){for(let e of n){let t=e;if(t&&typeof t=="object"&&Sg(t.component))return t}return null}function Cg(n){let e=new Map;for(let i of n){let r=i;if(!r||typeof r!="object"||!Sg(r.component))continue;let s=r.options?.id;e.has(s)||e.set(s,r)}let t=[...e.values()];return t.sort((i,r)=>xg(i)-xg(r)),t}function xg(n){return n.options?.order??0}function el(n,e){return n.options?.id??`#${e}`}function Tg(n){let e=n.options,t=e?.priority;if(typeof t=="number"&&t<0)return!0;let i=n.registrant??e?.registrant;return typeof i=="string"&&i.startsWith("dyn/")}function tl(n,e,t){let{sessionId:i,standard:r,ownerProps:s,fallback:o}=t,l=n.component,a;try{a=ps(n)??void 0}catch{a=void 0}let c=null;try{c=uv(n,i)}catch(d){me("slot.seat.inject",d)}return(0,Kt.createElement)(Ci,{key:e,fallback:o},(0,Kt.createElement)(l,{...r??{},sessionId:i,...c??{},...a!==void 0?{t:a}:{},...s??{}}))}var vg=new WeakMap;function cv(n){let e=n;if(!e||typeof e.subscribe!="function"||typeof e.getSnapshot!="function")return null;let t=vg.get(e);return t||(t=i=>(0,Kt.useSyncExternalStore)(r=>e.subscribe(r)??(()=>{}),()=>i(e.getSnapshot()),()=>i(e.getSnapshot())),vg.set(e,t)),t}function dv(n){return n&&`use${n.charAt(0).toUpperCase()}${n.slice(1)}`}var kg=new WeakMap;function Ag(n,e){let t=kg.get(n);t||(t=new Map,kg.set(n,t));let i=t.get(e);if(i)return i;let r={props:null,failed:!1};try{let s=n.inject?.(e);if(s&&typeof s=="object"){let{hooks:o,keyedHooks:l,...a}=s;for(let[c,d]of Object.entries(o??{})){let u=cv(d);u&&(a[dv(c)]=u)}r={props:a,failed:!1}}}catch(s){me("slot.inject",s),r={props:null,failed:!0}}return t.set(e,r),r}function uv(n,e){return typeof n.inject!="function"?null:Ag(n,e).props}function Mg(n,e){return typeof n.inject!="function"?!1:Ag(n,e).failed}function ps(n,e){let t=n.locale??e;return t?pr(t):null}var Ci=class extends Kt.Component{constructor(){super(...arguments);de(this,"state",{failed:!1})}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t){me("slot.entry",t)}render(){return this.state.failed?this.props.fallback??null:this.props.children}};function nl(n,e=[]){let{variant:t,blocked:i,disabled:r,placeholder:s,workspacePickerOpen:o,onRequestWorkspace:l,accessory:a,hero:c,...d}=n;for(let u of e)delete d[u];return d}var wd=require("react/jsx-runtime"),hv="conversation.input.model.label";function yd(n){let{provider:e,model:t,placement:i,selected:r,fallback:s}=n,o=jn(hv),l=(0,ms.useMemo)(()=>sr(o),[o]),a=(0,ms.useMemo)(()=>l&&l.locale?ps(l):null,[l]),c=s;return l&&a&&(c=(0,ms.createElement)(l.component,{provider:e,model:t,placement:i,selected:r,t:a})),(0,wd.jsx)("span",{"data-provider-id":e.id,"data-model-id":t.id,children:(0,wd.jsx)(Ci,{fallback:s,children:c})})}var Kn=require("react"),gs=require("react/jsx-runtime"),il=12;function or(n){let{anchor:e,onClose:t,children:i,alignEnd:r,minWidth:s=218,side:o="top"}=n,l=(0,Kn.useRef)(null),[a,c]=(0,Kn.useState)(null);return(0,Kn.useLayoutEffect)(()=>{let d=l.current;if(!d)return;let u=()=>{let f=d.offsetWidth,p=d.offsetHeight,m=r?e.right-f:e.left,w=o==="top"?e.top-8-p:e.bottom+4;f>0&&(m=Math.min(Math.max(m,il),window.innerWidth-f-il)),p>0&&(w=Math.min(Math.max(w,il),window.innerHeight-p-il)),c(b=>b&&b.left===m&&b.top===w?b:{left:m,top:w})};u(),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u);let h=typeof ResizeObserver<"u"?new ResizeObserver(u):null;return h?.observe(d),()=>{h?.disconnect(),window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[e,r,o]),(0,Kn.useEffect)(()=>{let d=u=>{l.current&&u.target instanceof Node&&l.current.contains(u.target)||t()};return window.addEventListener("pointerdown",d,!0),()=>window.removeEventListener("pointerdown",d,!0)},[t]),(0,gs.jsx)("div",{ref:l,className:"dci-menu",style:{left:a?.left??0,top:a?.top??0,bottom:"auto",right:"auto",minWidth:s,...a?null:{visibility:"hidden"}},children:(0,gs.jsx)("div",{className:"dci-viewport",children:i})})}function bs({size:n=16}){return(0,gs.jsx)("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:(0,gs.jsx)("path",{d:"M3 8.5L6.5 12L13 4.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}var X=require("react/jsx-runtime");function xd(n,e){if(!n)return null;for(let t of e){if(t.id!==n.provider)continue;let i=t.models.find(r=>r.id===n.model);if(i)return{group:t,model:i}}return null}function fv(n,e){return n?xd(n,e)?.model.name??n.model:x("tool.modelPlain")}function pv(n,e,t){let i=xd(n,e);if(!i)return;let r=i.model.reasoning;if(!r)return t?.retainedEffort;let s=n?.reasoningEffort??r.defaultEffort;return s===void 0?"Default":r.efforts.find(o=>o.id===s)?.name??s}function Eg(n){let{sessionId:e,onNotify:t}=n,[i,r]=(0,Gt.useState)(!1),[s,o]=(0,Gt.useState)(!1),[l,a]=(0,Gt.useState)("root"),c=(0,Gt.useRef)(null),[d,u]=(0,Gt.useState)(null),h=yg(e),f=Cn(h?.store);(0,Gt.useEffect)(()=>{!s||!h||h.load().catch(()=>{})},[s]),(0,Gt.useEffect)(()=>{if(!s)return;let R=O=>{F(p.current,O.target)||w()};return window.addEventListener("pointerdown",R,!0),()=>window.removeEventListener("pointerdown",R,!0)},[s]);let p=(0,Gt.useRef)(null),m=()=>{let R=c.current;R&&(u(R.getBoundingClientRect()),a("root"),o(!0))},w=()=>{o(!1),a("root")},b=f?.current??null,v=f?.groups??[],k=xd(b,v),N=fv(b,v),S=pv(b,v,f),C=S===void 0?N:`${N} \xB7 ${S}`,A=(R,O)=>(0,X.jsx)(yd,{provider:{id:O.group.id,name:O.group.name},model:O.model,placement:R,selected:!0,fallback:N}),$=async(R,O,M)=>{if(!h||i)return;let P={provider:R.id,model:O.id,...M!==void 0?{reasoningEffort:M}:{}};r(!0);try{await h.select(P)}catch(z){t?.("error",z instanceof Error?z.message:String(z))}finally{r(!1),w()}},F=(R,O)=>!!R&&O instanceof Node&&R.contains(O);return(0,X.jsxs)("div",{style:{position:"relative",minWidth:0},children:[(0,X.jsxs)("button",{ref:c,type:"button",className:"dci-trigger","data-model":"",style:{maxWidth:"min(360px, 45cqw)"},"data-open":s,onMouseDown:R=>R.preventDefault(),disabled:!h,onClick:()=>s?w():m(),"aria-haspopup":"menu","aria-expanded":s,"aria-label":x("tool.model",{name:C}),title:x("tool.model",{name:C}),children:[(0,X.jsx)("span",{className:"dci-triggerLabel",children:k?A("trigger",k):N}),S?(0,X.jsx)("span",{className:"dci-triggerEffort",children:S}):null,(0,X.jsx)("span",{className:"dci-chev","data-open":s,children:(0,X.jsx)(en,{size:14})})]}),s&&d?(0,X.jsx)("div",{ref:p,children:(0,X.jsxs)(or,{anchor:d,onClose:w,alignEnd:!0,minWidth:240,children:[l==="root"?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)("button",{type:"button",className:"dci-cell",onClick:()=>a("models"),children:[(0,X.jsx)("span",{className:"dci-cellLabel",children:x("menu.model")}),(0,X.jsx)("span",{className:"dci-cellValue",children:k?A("menu",k):N}),(0,X.jsx)("span",{className:"dci-cellChevron",style:{transform:"rotate(-90deg)"},"aria-hidden":"true",children:(0,X.jsx)(en,{size:14})})]}),k?.model.reasoning?(0,X.jsxs)("button",{type:"button",className:"dci-cell",onClick:()=>a("efforts"),children:[(0,X.jsx)("span",{className:"dci-cellLabel",children:x("menu.reasoning")}),(0,X.jsx)("span",{className:"dci-cellValue",children:S}),(0,X.jsx)("span",{className:"dci-cellChevron",style:{transform:"rotate(-90deg)"},"aria-hidden":"true",children:(0,X.jsx)(en,{size:14})})]}):null]}):null,l==="models"?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("div",{className:"dci-menuLabel",children:x("menu.model")}),v.map(R=>(0,X.jsxs)("div",{children:[(0,X.jsx)("div",{className:"dci-menuLabel",children:R.name}),R.models.map(O=>{let M=b!==null&&b.provider===R.id&&b.model===O.id;return(0,X.jsxs)("button",{type:"button",className:"dci-item",disabled:i,title:O.description,onClick:()=>void $(R,O,O.reasoning?.defaultEffort),children:[(0,X.jsx)("span",{className:"dci-itemLabel",children:(0,X.jsx)(yd,{provider:{id:R.id,name:R.name},model:O,placement:"option",selected:M,fallback:O.name})}),M?(0,X.jsx)("span",{className:"dci-check","aria-hidden":"true",children:(0,X.jsx)(bs,{size:16})}):null]},O.id)})]},R.id)),v.length===0?(0,X.jsx)("div",{className:"dci-empty",children:f?.status==="loading"?x("menu.refreshingModels"):x("menu.noModels")}):null]}):null,l==="efforts"?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("div",{className:"dci-menuLabel",children:x("menu.reasoning")}),(()=>{let R=k?.model.reasoning;if(!R)return(0,X.jsx)("div",{className:"dci-empty",children:x("menu.reasoningNone")});let O=b?.reasoningEffort??R.defaultEffort;return[...R.defaultEffort===void 0?[{key:"provider-default",effort:void 0,label:"Default"}]:[],...R.efforts.map(P=>({key:`effort:${P.id}`,effort:P.id,label:P.name}))].map(P=>{let z=O===P.effort,J=P.effort===void 0?void 0:R.efforts.find(q=>q.id===P.effort);return(0,X.jsxs)("button",{type:"button",className:"dci-item",disabled:i,title:J?.description,onClick:()=>k&&void $(k.group,k.model,P.effort),children:[(0,X.jsx)("span",{className:"dci-itemLabel",children:P.label}),z?(0,X.jsx)("span",{className:"dci-check","aria-hidden":"true",children:(0,X.jsx)(bs,{size:16})}):null]},P.key)})})()]}):null]})}):null]})}var Rg=require("react");var lr=require("react/jsx-runtime"),mv="conversation.input.model";function gv(){let n=jn(mv);return(0,Rg.useMemo)(()=>{let e=sr(n);return e!==null&&Tg(e)?e:null},[n])}function Dg(n){let{sessionId:e,standard:t,locked:i,fallback:r}=n,s=gv();return e===void 0||s===null?(0,lr.jsx)(lr.Fragment,{children:r}):Mg(s,e)?(0,lr.jsx)(lr.Fragment,{children:r}):tl(s,`model:${el(s,0)}`,{sessionId:e,standard:t,ownerProps:{locked:i},fallback:r})}var qt=require("react");var rl=["read-only","workspace-write","danger-full-access"];function Lg(n){return Ii(`perm.preset.${n}`)??n}function Ti(){return{title:x("perm.confirmTitle"),description:x("perm.warning"),acknowledgeLabel:x("perm.ack"),cancelLabel:x("perm.cancel"),enableLabel:x("perm.confirmEnable")}}function vd(n,e){return rl.includes(n)&&(e===n||e===Lg(n))?Lg(n):/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)?e.split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" "):e}async function bv(n,e){let t=Y.sessions?.binding(n)?.session;if(!t||typeof t.command!="function")return null;try{let i=await t.command(`/permission ${e}`);return i?.ok?i.value?.matched===!1?{ok:!1,via:"command",message:x("perm.channelRejected")}:(Nl(e),{ok:!0,via:"command"}):{ok:!1,via:"command",message:x("perm.channelRejected")}}catch(i){return Zt("permission command failed",i),{ok:!1,via:"command",message:String(i)}}}function wv(n,e,t){try{return e.setDraft(`/permission ${n}`),e.submit(),setTimeout(()=>{try{e.setDraft(t)}catch(i){Zt("permission draft restore failed",i)}},600),Nl(n),{ok:!0,via:"draft-exchange"}}catch(i){return Zt("permission draft-exchange failed",i),{ok:!1,via:"draft-exchange",message:String(i)}}}async function Og(n,e,t,i){let r=await bv(n,e);return r||(t?wv(e,t,i):{ok:!1,via:"draft-exchange",message:x("perm.noInputSurface")})}var ee=require("react/jsx-runtime"),Pg="danger-full-access";function kd(n){if(n==="read-only")return(0,ee.jsx)(Sh,{size:16});if(n==="workspace-write")return(0,ee.jsx)(Ch,{size:16});if(n===Pg)return(0,ee.jsx)(Th,{size:16})}function Ig(n){let{sessionId:e,actions:t,currentDraft:i,useProjection:r,disabled:s,onNotify:o}=n,l=r?r("permissions"):void 0,[a,c]=(0,qt.useState)(null),[d,u]=(0,qt.useState)(!1),[h,f]=(0,qt.useState)(null),[p,m]=(0,qt.useState)(!1),w=(0,qt.useRef)(null),[b,v]=(0,qt.useState)(null);if((0,qt.useEffect)(()=>{s||l===void 0&&(u(!1),m(!1),f(null))},[s,l]),!l||typeof l.currentValue!="string")return null;let k=a!==null||h!==null,N=a??l.currentValue,S=vd(N,N),C=[...rl,...rl.includes(N)?[]:[N]].map(M=>({id:M,label:vd(M,M),icon:kd(M)})),A=()=>u(!1),$=M=>{e&&(c(M),Og(e,M,t,i).then(P=>{P.ok||o?.("error",P.message??x("perm.switchFailed"))}).finally(()=>c(null)))},F=M=>{if(A(),M!==l.currentValue){if(M===Pg){m(!1),f(M);return}$(M)}},R=()=>{m(!1),f(null)},O=()=>{if(s||!p||h===null)return;let M=h;R(),$(M)};return(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsxs)("button",{ref:w,type:"button",className:"dci-trigger","aria-label":x("perm.trigger",{name:S}),title:void 0,disabled:s||k,onMouseDown:M=>M.preventDefault(),onClick:()=>{d||v(w.current?.getBoundingClientRect()??null),u(!d)},children:[kd(N)!==void 0?(0,ee.jsx)("span",{className:"dci-triggerIcon","aria-hidden":"true",children:kd(N)}):null,(0,ee.jsx)("span",{className:"dci-triggerLabel",children:S}),(0,ee.jsx)("span",{className:"dci-chev","data-open":d,children:(0,ee.jsx)(en,{size:14})})]}),d&&b?(0,ee.jsx)(or,{anchor:b,onClose:A,children:C.map(M=>{let P=M.id===N;return(0,ee.jsxs)("button",{type:"button",className:"dci-item",disabled:k,onClick:()=>F(M.id),children:[M.icon!==void 0?(0,ee.jsx)("span",{className:"dci-itemIcon","aria-hidden":"true",children:M.icon}):null,(0,ee.jsx)("span",{className:"dci-itemLabel",children:M.label}),P?(0,ee.jsx)("span",{className:"dci-check","aria-hidden":"true",children:(0,ee.jsx)(bs,{size:16})}):null]},M.id)})}):null,(0,ee.jsx)(yv,{open:h!==null,acknowledged:p,disabled:s===!0,onAcknowledgedChange:m,onCancel:R,onConfirm:O})]})}function yv(n){let{open:e,acknowledged:t,disabled:i,onAcknowledgedChange:r,onCancel:s,onConfirm:o}=n;return(0,qt.useEffect)(()=>{if(!e)return;let l=a=>{a.key==="Escape"&&s()};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[e]),e?(0,ee.jsxs)("div",{className:"dci-modal-root",role:"presentation",children:[(0,ee.jsx)("div",{className:"dci-modal-mask","aria-hidden":"true",onClick:s}),(0,ee.jsxs)("div",{className:"dci-modal-dialog dci-confirm",role:"dialog","aria-modal":"true","aria-label":Ti().title,children:[(0,ee.jsxs)("div",{className:"dci-modal-content",children:[(0,ee.jsxs)("div",{className:"dci-modal-header",children:[(0,ee.jsx)("h2",{className:"dci-modal-title",children:Ti().title}),(0,ee.jsx)("button",{type:"button",className:"dci-modal-close","aria-label":x("perm.close"),onClick:s,children:(0,ee.jsx)(bh,{size:14})})]}),(0,ee.jsxs)("div",{className:"dci-modal-body",children:[(0,ee.jsxs)("div",{className:"dci-confirm-warning",children:[(0,ee.jsx)("span",{className:"dci-confirm-warningIcon","aria-hidden":"true",children:(0,ee.jsx)(Ah,{size:18})}),(0,ee.jsx)("p",{children:Ti().description})]}),(0,ee.jsxs)("label",{className:"dci-confirm-ack",children:[(0,ee.jsx)("input",{type:"checkbox",checked:t,disabled:i,autoFocus:!0,onChange:l=>r(l.currentTarget.checked)}),(0,ee.jsx)("span",{children:Ti().acknowledgeLabel})]})]})]}),(0,ee.jsxs)("div",{className:"dci-modal-footer",children:[(0,ee.jsx)("button",{type:"button",className:"dci-btn dci-btn-outline dci-btn-cancel",onClick:s,children:Ti().cancelLabel}),(0,ee.jsx)("button",{type:"button",className:"dci-btn dci-btn-primary dci-btn-confirm",disabled:i||!t,onClick:o,children:Ti().enableLabel})]})]})]}):null}var un=require("react");var xv="conversation.input.activity",vv="voice-input",Ng=new WeakMap,Bg=new WeakMap;function kv(n,e){if(typeof n.inject!="function")return null;let t=Bg.get(n);if(t||(t=new Map,Bg.set(n,t)),!t.has(e)){let i=null;try{i=n.inject(e)??null}catch(r){me("voice.inject",r),i=null}t.set(e,i)}return t.get(e)??null}function Sv(n){let e=n;if(!e||typeof e.subscribe!="function"||typeof e.getSnapshot!="function")return null;let t=Ng.get(e);return t||(t=i=>(0,un.useSyncExternalStore)(r=>e.subscribe(r)??(()=>{}),()=>i(e.getSnapshot()),()=>i(e.getSnapshot())),Ng.set(e,t)),t}function _g(n){let{sessionId:e,inputActions:t,locked:i,onActiveChange:r}=n,s=jn(xv),o=(0,un.useMemo)(()=>sr(s),[s]),l=(0,un.useMemo)(()=>o&&e?kv(o,e):null,[o,e]),a=(0,un.useMemo)(()=>o?ps(o,vv):null,[o]),c=l?.hooks?.speechReadiness,d=(0,un.useMemo)(()=>Sv(c),[c]);if(!o||!e||!l||!a||!d)return null;let{hooks:u,...h}=l;return(0,un.createElement)(Ci,{children:(0,un.createElement)(o.component,{sessionId:e,inputActions:t,locked:i,onActiveChange:r,...h,useSpeechReadiness:d,t:a})})}var Hg=require("react");var ol=require("react/jsx-runtime");function sl(n){let{slot:e,sessionId:t,standard:i}=n,r=jn(e),s=(0,Hg.useMemo)(()=>Cg(r),[r]);return t===void 0||s.length===0?null:(0,ol.jsx)(ol.Fragment,{children:s.map((o,l)=>tl(o,el(o,l),{sessionId:t,standard:i}))})}var zg=require("react/jsx-runtime"),Cv="conversation.input.left";function Fg(n){return(0,zg.jsx)(sl,{slot:Cv,sessionId:n.sessionId,standard:n.standard})}var Vg=require("react/jsx-runtime"),Tv="conversation.input.right";function Wg(n){return(0,Vg.jsx)(sl,{slot:Tv,sessionId:n.sessionId,standard:n.standard})}var Ue=require("react/jsx-runtime");function $g(n){n.preventDefault()}function Ug(n){let{sessionId:e,state:t,actions:i,triggers:r,caretRef:s,useProjection:o,disabled:l,onNotify:a,inputStandard:c}=n;St();let d=t?.attachmentIds??[],[u,h]=(0,ll.useState)(!1),f=(0,ll.useCallback)(m=>h(m),[]),p=()=>{r&&rg(r,void 0,s.current??0)};return(0,Ue.jsxs)("div",{className:"dci-row","data-voice-active":u||void 0,children:[(0,Ue.jsxs)("div",{className:"dci-tools",children:[(0,Ue.jsx)("button",{type:"button",className:"dci-add","aria-label":x("tool.command"),"aria-haspopup":"listbox",title:x("tool.command"),disabled:!r,onMouseDown:$g,onClick:p,children:(0,Ue.jsx)(vh,{size:14})}),(0,Ue.jsx)(Ig,{sessionId:e,actions:i,currentDraft:t?.draft??"",useProjection:o,disabled:l,onNotify:a}),t!==void 0&&e!==void 0?(0,Ue.jsx)(Fg,{sessionId:e,standard:c}):null]}),(0,Ue.jsxs)("div",{className:"dci-trailing",children:[(0,Ue.jsxs)("div",{className:"dci-standard-controls",children:[t!==void 0&&e!==void 0?(0,Ue.jsx)(Wg,{sessionId:e,standard:c}):null,(0,Ue.jsx)(Dg,{sessionId:e,standard:c,locked:l===!0,fallback:(0,Ue.jsx)(Eg,{sessionId:e,onNotify:a})})]}),(0,Ue.jsx)("div",{className:"dci-voice-seat",children:(0,Ue.jsx)(_g,{sessionId:e,inputActions:i,locked:l===!0,onActiveChange:f})}),(0,Ue.jsx)("button",{type:"button",className:"dci-send","aria-label":n.primaryStops?x("tool.stop"):x("tool.send"),title:n.primaryStops?x("tool.stop"):x("tool.send"),disabled:n.primaryStops?!n.onStop:n.sendDisabled,onMouseDown:$g,onClick:()=>n.primaryStops?n.onStop?.():n.onSend(),children:n.primaryStops?(0,Ue.jsx)(Eh,{size:16}):(0,Ue.jsx)(Mh,{size:16})})]})]})}var pt=require("react"),Ad=require("react-dom");var ws=["tokenUsage","contextPressure","sessionUsage","usage","sessionStats"];function ke(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function Av(n){if(!n||typeof n!="object")return;let e=n,t={cacheReadTokens:ke(e.cacheReadTokens),cacheWriteTokens:ke(e.cacheWriteTokens),outputTokens:ke(e.outputTokens),uncachedInputTokens:ke(e.uncachedInputTokens)};return Object.values(t).some(i=>i!==void 0)?t:void 0}function Mv(n){if(!n||typeof n!="object")return;let e=n,t={contextWindow:ke(e.contextWindow),pressureTokens:ke(e.pressureTokens),projectedTokens:ke(e.projectedTokens)};return t.contextWindow!==void 0&&t.pressureTokens!==void 0?t:void 0}function Ev(n){if(!n||typeof n!="object")return;let e=n,t={turns:ke(e.turns),steps:ke(e.steps),llmMs:ke(e.llmMs),toolMs:ke(e.toolMs),ttftMs:ke(e.ttftMs),ttftSteps:ke(e.ttftSteps),decodeMs:ke(e.decodeMs),decodeTokens:ke(e.decodeTokens)};return Object.values(t).some(i=>i!==void 0)?t:void 0}function Rv(n){if(!Array.isArray(n))return;let e=new Set,t=0,i=0,r=0,s=0,o=0,l=0,a=0;for(let c of n){if(!c||typeof c!="object")continue;let d=c;if(d.kind==="tool-result"){let b=ke(d.callTime),v=ke(d.time);b!==void 0&&v!==void 0&&(r+=Math.max(0,v-b));continue}if(d.kind!=="assistant")continue;e.add(d.turn),t+=1;let u=d.timing,h=ke(u?.stepStartTime),f=ke(u?.firstTokenTime),p=ke(u?.completedTime);h!==void 0&&p!==void 0&&(i+=Math.max(0,p-h)),h!==void 0&&f!==void 0&&(s+=Math.max(0,f-h),o+=1),f!==void 0&&p!==void 0&&(l+=Math.max(0,p-f));let m=d.usage,w=ke(m?.outputTokens);w!==void 0&&w>=0&&(a+=w)}if(n.length!==0)return{turns:e.size,steps:t,llmMs:i,toolMs:r,ttftMs:s,ttftSteps:o,decodeMs:l,decodeTokens:a}}function Sd(n){let e=Math.max(0,n);return e>=10?String(Math.round(e)):String(Math.round(e*10)/10)}function Cd(n,e){if(e<=0)return null;if(n>=e)return"100";for(let t=0;t<20;t++){let i=10**t,r=Math.round(n/e*100*i)/i;if(r<100)return t===0?String(r):r.toFixed(t)}return"99.99"}function al(n){let e=n/1e3;if(e<60)return`${Math.round(e*10)/10}s`;let t=Math.round(e);return`${Math.floor(t/60)}\u5206${t%60}\u79D2`}function jg(n,e,t){let i=n?n(ws[0]):void 0,r=n?n(ws[1]):void 0,s=n?n(ws[2]):void 0,o=n?n(ws[3]):void 0,l=n?n(ws[4]):void 0,a=Av(i),c=Mv(r),d=Ev(l)??Rv(t)??Dv(s,o),u={};if(d&&((d.turns!==void 0||d.steps!==void 0)&&(u.turns=d.turns,u.steps=d.steps),d.llmMs!==void 0&&(u.llmMs=d.llmMs),d.toolMs!==void 0&&(u.toolMs=d.toolMs),d.ttftMs!==void 0&&(u.ttftMs=d.ttftMs),d.ttftSteps!==void 0&&(u.ttftSteps=d.ttftSteps),d.decodeMs!==void 0&&(u.decodeMs=d.decodeMs),d.decodeTokens!==void 0&&(u.decodeTokens=d.decodeTokens),(d.decodeMs??0)>0&&(u.tokensPerSecond=(d.decodeTokens??0)/(d.decodeMs/1e3))),a){let p=(a.cacheReadTokens??0)+(a.cacheWriteTokens??0)+(a.outputTokens??0)+(a.uncachedInputTokens??0);p>0&&(u.totalTokens=p,u.uncachedInputTokens=a.uncachedInputTokens,u.cacheReadTokens=a.cacheReadTokens,u.cacheWriteTokens=a.cacheWriteTokens,u.outputTokens=a.outputTokens);let m=(a.cacheReadTokens??0)+(a.cacheWriteTokens??0)+(a.uncachedInputTokens??0);if(m>0){let w=Cd(a.cacheReadTokens??0,m);w!==null&&(u.cacheHitText=w)}}let h=c?.contextWindow,f=c?.projectedTokens??c?.pressureTokens;return h!==void 0&&h>0&&f!==void 0&&(u.contextPct=f/h*100),Object.keys(u).length>0?u:null}function Dv(n,e){let t=i=>{if(!i||typeof i!="object")return;let r=i,s=ke(r.turns)??ke(r.turnCount),o=ke(r.steps)??ke(r.stepCount);return s!==void 0||o!==void 0?{turns:s,steps:o}:void 0};return t(n)??t(e)}function cl(n){let e=t=>t>=100?String(Math.round(t)):String(Math.round(t*10)/10);return n<1e3?`${n} tok`:n<1e6?`${e(n/1e3)}K tok`:`${e(n/1e6)}M tok`}var _=require("react/jsx-runtime");function Td({size:n=14}){return(0,_.jsxs)("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,_.jsx)("path",{d:"M3.49 13.26A6.375 6.375 0 1 1 12.51 13.26",stroke:"currentColor",strokeWidth:"1.25"}),(0,_.jsx)("path",{d:"M8 8.75L11.4 5.35",stroke:"currentColor",strokeWidth:"1.25"}),(0,_.jsx)("circle",{cx:"8",cy:"8.75",r:"1.55",fill:"currentColor"})]})}function Kg({size:n=14}){return(0,_.jsxs)("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,_.jsx)("ellipse",{cx:"8",cy:"3.6",rx:"5.75",ry:"2.4",stroke:"currentColor",strokeWidth:"1.25"}),(0,_.jsx)("path",{d:"M2.25 3.6V12.3A5.75 2.4 0 0 0 13.75 12.3V3.6",stroke:"currentColor",strokeWidth:"1.25"}),(0,_.jsx)("path",{d:"M2.25 7.95A5.75 2.4 0 0 0 13.75 7.95",stroke:"currentColor",strokeWidth:"1.25"})]})}function Lv(n,e,t,i,r){let[s,o]=(0,pt.useState)(null);return(0,pt.useLayoutEffect)(()=>{if(!n){o(null);return}let l=()=>{let u=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--dsh-frame-top-clearance"));return Number.isNaN(u)?r:Math.max(r,(document.documentElement.hasAttribute("data-fullscreen")?0:u)+20)},a=()=>{let u=e.current?.getBoundingClientRect();if(u===void 0)return;let h=t.current,f=h?.offsetWidth??0,p=h?.offsetHeight??0,m=u.left,w=u.top-i-p;f>0&&(m=Math.min(Math.max(m,r),window.innerWidth-f-r)),p>0&&(w=Math.min(Math.max(w,l()),window.innerHeight-p-r)),o(b=>b&&b.left===m&&b.top===w?b:{left:m,top:w})};a(),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a);let c=t.current,d=null;return typeof ResizeObserver<"u"&&c!==null&&(d=new ResizeObserver(a),d.observe(c)),()=>{d?.disconnect(),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[n,e,t,i,r]),s}function Md(n,e){let t=(0,pt.useRef)(null),i=(0,pt.useRef)(null),r=Lv(n,t,i,8,12);return(0,pt.useEffect)(()=>{if(!n)return;let s=l=>{l.target instanceof Node&&t.current?.contains(l.target)!==!0&&i.current?.contains(l.target)!==!0&&e()},o=l=>{l.key==="Escape"&&e()};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",o),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",o)}},[n,e]),{rootRef:t,panelRef:i,position:r}}function qg(n){return n??{visibility:"hidden",left:0,top:0}}function Xg(n){let{label:e,icon:t,titleValue:i,rows:r,panelRef:s,position:o}=n;return(0,Ad.createPortal)((0,_.jsxs)("div",{className:"dci-stat-panel",role:"dialog","aria-label":e,ref:s,style:qg(o),children:[(0,_.jsxs)("div",{className:"dci-stat-panelTitle",children:[(0,_.jsxs)("span",{className:"dci-stat-panelLabel",children:[t,e]}),i!==void 0?(0,_.jsx)("span",{className:"dci-stat-panelValue",children:i}):null]}),(0,_.jsx)("div",{className:"dci-stat-panelRule","aria-hidden":"true"}),(0,_.jsx)("dl",{className:"dci-stat-details",children:r.map(([l,a])=>(0,_.jsxs)("div",{style:{display:"contents"},children:[(0,_.jsx)("dt",{children:l}),(0,_.jsx)("dd",{children:a})]},l))})]}),document.body)}function ys(n){let e=String(n??0),t=[];for(let i=e.length;i>0;i-=3)t.unshift(e.slice(Math.max(0,i-3),i));return`${t.join(",")} tok`}function Ov(n){let{stats:e,open:t,onToggle:i,onClose:r}=n,{rootRef:s,panelRef:o,position:l}=Md(t,r),a=x("stats.turns",{turns:e.turns??0,steps:e.steps??0}),c=(e.decodeMs??0)>0?Sd((e.decodeTokens??0)/((e.decodeMs??1)/1e3)):null,d=(e.llmMs??0)>0||(e.toolMs??0)>0||(e.ttftSteps??0)>0||(e.decodeMs??0)>0,u=(0,_.jsxs)("span",{className:"dci-stat-label",children:[a,c!==null?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{className:"dci-stat-sep","aria-hidden":"true",children:"\xB7"}),x("stats.tps",{tps:c})]}):null]});return d?(0,_.jsxs)("span",{className:"dci-stat-anchor",ref:s,children:[(0,_.jsxs)("button",{type:"button",className:"dci-stat-pill","aria-haspopup":"dialog","aria-expanded":t,"aria-label":c!==null?`${a} \xB7 ${x("stats.tps",{tps:c})}`:a,onClick:i,children:[(0,_.jsx)(Td,{}),u]}),t?(0,_.jsx)(Xg,{label:x("stats.session"),icon:(0,_.jsx)(Td,{}),panelRef:o,position:l,rows:[[x("stats.modelTime"),(e.llmMs??0)>0?al(e.llmMs):"\u2014"],[x("stats.toolTime"),(e.toolMs??0)>0?al(e.toolMs):"\u2014"],[x("stats.ttft"),(e.ttftSteps??0)>0?al(e.ttftMs/e.ttftSteps):"\u2014"],[x("stats.tpsLabel"),(e.decodeMs??0)>0?x("stats.tps",{tps:Sd((e.decodeTokens??0)/((e.decodeMs??1)/1e3))}):"\u2014"]]}):null]}):(0,_.jsx)("span",{className:"dci-stat-anchor",ref:s,children:(0,_.jsxs)("span",{className:"dci-stat-pill",children:[(0,_.jsx)(Td,{}),u]})})}function Pv(n){let{stats:e,open:t,onToggle:i,onClose:r}=n,{rootRef:s,panelRef:o,position:l}=Md(t,r);if(e.totalTokens===void 0)return null;let a=e.totalTokens,c=e.cacheHitText??Cd(e.cacheReadTokens??0,(e.cacheReadTokens??0)+(e.cacheWriteTokens??0)+(e.uncachedInputTokens??0));return(0,_.jsxs)("span",{className:"dci-stat-anchor",ref:s,children:[(0,_.jsxs)("button",{type:"button",className:"dci-stat-pill","aria-haspopup":"dialog","aria-expanded":t,"aria-label":c!==null?`${cl(a)} \xB7 ${x("stats.cacheHit",{percent:c})}`:cl(a),onClick:i,children:[(0,_.jsx)(Kg,{}),(0,_.jsxs)("span",{className:"dci-stat-label",children:[cl(a),c!==null?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{className:"dci-stat-sep","aria-hidden":"true",children:"\xB7"}),x("stats.cacheHit",{percent:c})]}):null]})]}),t?(0,_.jsx)(Xg,{label:x("stats.usage"),icon:(0,_.jsx)(Kg,{}),titleValue:ys(a),panelRef:o,position:l,rows:[[x("stats.cacheHitLabel"),c!==null?`${c}%`:"\u2014"],[x("stats.uncached"),ys(e.uncachedInputTokens)],[x("stats.cacheRead"),ys(e.cacheReadTokens)],...e.cacheWriteTokens?[[x("stats.cacheWrite"),ys(e.cacheWriteTokens)]]:[],[x("stats.output"),ys(e.outputTokens)]]}):null]})}function Ed(n){let{useProjection:e,sessionId:t,chatNodes:i}=n,[r,s]=(0,pt.useState)(null),o=(0,pt.useCallback)(()=>s(null),[]),l=(0,pt.useCallback)(u=>{s(h=>h===u?null:u)},[]),a=jg(e,t,i),c=e?e("contextPressure"):void 0,d=c!==void 0&&!!c.contextWindow;return(0,pt.useEffect)(()=>{if(r===null)return;(r==="gauge"?d:a!=null)||s(null)},[r,d,a]),!a&&!d?null:(0,_.jsxs)("div",{className:"dci-stat-root","data-composer-stats":"codinput",children:[a?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Ov,{stats:a,open:r==="rounds",onToggle:()=>l("rounds"),onClose:o}),(0,_.jsx)(Pv,{stats:a,open:r==="tokens",onToggle:()=>l("tokens"),onClose:o})]}):null,(0,_.jsx)(Iv,{useProjection:e,open:r==="gauge",onToggle:()=>l("gauge"),onClose:o})]})}var Gg=2*Math.PI*5.5;function xs(n){return n>=1e6?`${(n/1e6).toFixed(n%1e6===0?0:1)}M`:n>=1e3?`${(n/1e3).toFixed(n%1e3===0?0:1)}K`:`${n}`}function Iv(n){let{useProjection:e,open:t,onToggle:i,onClose:r}=n,{rootRef:s,panelRef:o,position:l}=Md(t,r),a=e?e("contextPressure"):void 0,c=e?e("contextBreakdown"):void 0;if(!a||!a.contextWindow)return null;let d=a.contextWindow,u=a.projectedTokens??a.pressureTokens??0,h=Math.min(100,Math.round(u/d*100)),f=h/100*Gg,p=[["dci-gauge-colorSystem",c?.systemTokens??0],["dci-gauge-colorTools",c?.toolsTokens??0],["dci-gauge-colorMessages",c?.messageTokens??0]];return(0,_.jsxs)("span",{className:"dci-gauge-root",ref:s,children:[(0,_.jsxs)("button",{type:"button",className:"dci-gauge-trigger","aria-label":x("tool.context",{percent:Math.round(h)}),"aria-haspopup":"dialog","aria-expanded":t,title:x("tool.context",{percent:Math.round(h)}),onClick:i,children:[(0,_.jsxs)("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[(0,_.jsx)("circle",{className:"dci-gauge-track",cx:"7",cy:"7",r:"5.5"}),(0,_.jsx)("circle",{className:"dci-gauge-fill",cx:"7",cy:"7",r:"5.5",strokeDasharray:`${f} ${Gg}`,transform:"rotate(-90 7 7)"})]}),(0,_.jsxs)("span",{children:[Math.round(h),"%"]})]}),t?(0,Ad.createPortal)((0,_.jsxs)("div",{className:"dci-gauge-panel",role:"dialog","aria-label":x("tool.contextTitle"),ref:o,style:qg(l),children:[(0,_.jsxs)("div",{className:"dci-gauge-header",children:[(0,_.jsx)("span",{className:"dci-gauge-headline",children:x("tool.contextTitle")}),(0,_.jsxs)("span",{className:"dci-gauge-percent",children:[Math.round(h),"%"]}),(0,_.jsxs)("span",{className:"dci-gauge-figures",children:["~",xs(u)," / ",xs(d)]})]}),(0,_.jsx)("div",{className:"dci-gauge-bar",children:p.map(([m,w])=>(0,_.jsx)("div",{className:`dci-gauge-segment ${m}`,style:{width:`${w/d*100}%`}},m))}),(0,_.jsxs)("dl",{className:"dci-gauge-rows",children:[(0,_.jsxs)("div",{className:"dci-gauge-row",children:[(0,_.jsxs)("dt",{children:[(0,_.jsx)("span",{className:"dci-gauge-swatch dci-gauge-colorSystem","aria-hidden":"true"}),x("stats.prompt")]}),(0,_.jsxs)("dd",{children:["~",xs(c?.systemTokens??0)]})]}),(0,_.jsxs)("div",{className:"dci-gauge-row",children:[(0,_.jsxs)("dt",{children:[(0,_.jsx)("span",{className:"dci-gauge-swatch dci-gauge-colorTools","aria-hidden":"true"}),x("stats.tools")]}),(0,_.jsxs)("dd",{children:["~",xs(c?.toolsTokens??0)]})]}),(0,_.jsxs)("div",{className:"dci-gauge-row",children:[(0,_.jsxs)("dt",{children:[(0,_.jsx)("span",{className:"dci-gauge-swatch dci-gauge-colorMessages","aria-hidden":"true"}),x("stats.messages")]}),(0,_.jsxs)("dd",{children:["~",xs(c?.messageTokens??0)]})]})]})]}),document.body):null]})}var De=require("react/jsx-runtime");ae.setOptions({gfm:!0,breaks:!0});var Nv=Ar??Mr;function dl(n){let{sessionId:e,state:t,actions:i,useProjection:r,inputStandard:s,placeholder:o,disabled:l,blocked:a,running:c,side:d,hero:u,chatNodes:h,float:f,onDragZonePointerDown:p}=n;St();let[m,w]=(0,Pe.useState)(()=>ue().defaultEdit),[b,v]=(0,Pe.useState)(()=>ue().defaultPreview),[k,N]=(0,Pe.useState)(()=>ue().composerBodyHeight),[S,C]=(0,Pe.useState)(!1),A=(0,Pe.useRef)(null),$=(0,Pe.useRef)(null),F=(0,Pe.useRef)(null),R=(0,Pe.useRef)(null),O=K=>{K.preventDefault();let Z=K.currentTarget,Ie=K.clientY,An=k??Math.max(60,A.current?.querySelector(".dci-body")?.getBoundingClientRect().height??0);Z.dataset.dragging="true";let We=k,Mn=Ts=>{We=Math.round(Math.min(window.innerHeight-260,Math.max(96,An-(Ts.clientY-Ie)))),N(We)},It=()=>{Z.dataset.dragging="false",window.removeEventListener("pointermove",Mn),window.removeEventListener("pointerup",It),window.removeEventListener("pointercancel",It),ct({composerBodyHeight:We})};try{Z.setPointerCapture(K.pointerId)}catch{}window.addEventListener("pointermove",Mn),window.addEventListener("pointerup",It),window.addEventListener("pointercancel",It)},[M,P]=(0,Pe.useState)(0);(0,Pe.useEffect)(()=>{!m&&!b&&w(!0)},[m,b]);let z=()=>{if(!(!e||!Y.conversation))try{return Y.conversation.input.inputTriggers(e)??void 0}catch{return}},J=()=>{if(!(!e||!Y.conversation))try{return Y.conversation.input.keyboard(e)}catch{return}},q=z(),Me=J();(0,Pe.useEffect)(()=>{if(!e||q&&Me)return;let K=window.setInterval(()=>P(Ie=>Ie+1),300),Z=window.setTimeout(()=>window.clearInterval(K),1e4);return()=>{window.clearInterval(K),window.clearTimeout(Z)}},[e,q,Me]);let et=(0,Pe.useMemo)(()=>{if(!(!e||!Y.sessions||!Y.commandUi)&&typeof Y.commandUi.popupFor=="function")try{return Y.commandUi.popupFor(Y.sessions.scope(e))}catch{return}},[e,M]);(0,Pe.useEffect)(()=>{if(e)return hh(e)},[e]),(0,Pe.useEffect)(()=>{if(!e||!Y.commandUi)return;let K=Y.commandUi;if(typeof K.bindComposerFocus=="function")return K.bindComposerFocus(e,()=>$.current?.focus())},[e]),(0,Pe.useEffect)(()=>{Dl(e??null);let K=Oe();return e&&(q&&(K.__dshCodinputTriggers[e]=q),Me&&(K.__dshCodinputKeyboard[e]=Me),K.__dshCodinputShell[e]={surface:!0,side:d===!0}),()=>{Dl(null)}},[e,q,Me,d]);let Se=K=>{F.current=K},ot=()=>{if(e)try{Y.sessions?.scope(e)?.get?.("conversation")?.cancel?.()?.catch?.(()=>{})}catch{}},Ke=()=>{if(!i)return;let K=t,Z=!K||K.draft.trim()==="",Ie=!K||K.attachmentIds.length===0;if(Z&&Ie){Me?.steerQueue();return}i.submit()},Xe=l===!0||a===!0,kt=(t?.draft??"").trim()==="",ie=(t?.attachmentIds.length??0)===0,Tn=c===!0&&kt&&ie,Mi=Xe||i===void 0||t!==void 0&&t.phase==="submitting"||kt&&ie,dr=(0,Pe.useMemo)(()=>Nv.sanitize(ae.parse(t?.draft??"")),[t?.draft,b]),pl=K=>{if(!m||!b)return;let Z=K.target,Ie=$.current?.scrollDOM,An=R.current;if(!Ie||!An)return;let We=Z===Ie?An:Z===An?Ie:null;if(!We)return;let Mn=Z.scrollHeight-Z.clientHeight;if(Mn<=0)return;let It=Z.scrollTop/Mn*(We.scrollHeight-We.clientHeight);Math.abs(We.scrollTop-It)>1&&(We.scrollTop=It)};(0,Pe.useEffect)(()=>{if(!m||!b)return;let K=$.current?.scrollDOM,Z=R.current;if(!K||!Z)return;let Ie=K.scrollHeight-K.clientHeight;Ie<=0||(Z.scrollTop=K.scrollTop/Ie*(Z.scrollHeight-Z.clientHeight))},[m,b,dr,e]);let ml=()=>{!m&&b?w(!0):m&&b&&w(!1)},gl=()=>{!b&&m?v(!0):b&&m&&v(!1)},ks=o??x("editor.placeholder"),Ss=Jg(e);return(0,De.jsxs)("div",{className:"dci-surface","data-side":d||void 0,"data-float":f||void 0,children:[(0,De.jsxs)("div",{className:"dci-card","data-composer-card":"codinput","data-drop":S||void 0,ref:A,onPasteCapture:K=>{let Z=K.clipboardData?.files;!Z||Z.length===0||(K.preventDefault(),K.stopPropagation(),Js(e,i,Z,Ss))},onDragOverCapture:K=>{fh(K.dataTransfer)&&(K.preventDefault(),K.dataTransfer.dropEffect="copy",S||C(!0))},onDragLeave:K=>{K.currentTarget.contains(K.relatedTarget)||C(!1)},onDropCapture:K=>{C(!1);let Z=K.dataTransfer?.files;!Z||Z.length===0||(K.preventDefault(),K.stopPropagation(),Js(e,i,Z,Ss))},children:[(0,De.jsx)("div",{className:"dci-rip","data-axis":"y","data-side":"top",onPointerDown:O}),(0,De.jsxs)("div",{className:"dci-accessory",children:[(0,De.jsx)("button",{type:"button",className:"dci-iconbtn","data-on":m,onClick:ml,title:x("head.edit"),children:(0,De.jsx)(mh,{size:14})}),(0,De.jsx)("button",{type:"button",className:"dci-iconbtn","data-on":b,onClick:gl,title:x("head.preview"),children:(0,De.jsx)(gh,{size:14})}),d?null:(0,De.jsx)("div",{className:"dci-float-dragzone",onPointerDown:p})]}),i&&(t?.attachmentIds.length??0)>0?(0,De.jsx)(wg,{state:t,sessionId:e,onRemove:K=>{let Z=Y.conversation;i.removeAttachment(K);try{Z?.releaseDraftAttachment(K)}catch(Ie){me("attachments",Ie)}}}):null,(0,De.jsxs)("div",{className:"dci-body","data-split":m&&b,onScrollCapture:pl,style:!d&&!f&&k!==null?{"--dci-body-h":`${k}px`,"--dci-body-max":`${k}px`}:void 0,children:[m?(0,De.jsx)(cg,{state:t,actions:i,triggers:q,keyboard:Me,onSendGesture:Ke,placeholder:ks,viewRef:$,onCaretMoved:Se,disabled:Xe,autoFocus:!0,solo:!b,stateKey:e??"hero"}):null,b?(0,De.jsx)("div",{className:"dci-preview","data-solo":!m,ref:R,children:dr?(0,De.jsx)("div",{dangerouslySetInnerHTML:{__html:dr}}):(0,De.jsx)("span",{style:{opacity:.4},children:x("preview.empty")})}):null]}),(0,De.jsx)(Ug,{sessionId:e,state:t,actions:i,triggers:q,caretRef:F,useProjection:r,disabled:Xe,primaryStops:Tn,onStop:ot,onNotify:Jg(e),onSend:Ke,sendDisabled:Mi,inputStandard:s}),f&&u!==!0?(0,De.jsx)(Ed,{useProjection:r,sessionId:e,chatNodes:h}):null,q?(0,De.jsx)(ug,{triggers:q,dropdown:d===!0||f===!0}):null]}),!f&&u!==!0?(0,De.jsx)(Ed,{useProjection:r,sessionId:e,chatNodes:h}):null,et?(0,De.jsx)(fg,{popup:et}):null]})}function Jg(n){if(n)return(e,t)=>{try{let i=Y.sessions?.scope(n);if(!i||!Y.conversation)return;Y.conversation.input.for(i).notify(e,t)}catch(i){me("notify",i)}}}var hn=require("react/jsx-runtime"),Rd="dsh-codinput",ul="codinput";function Yg(){return{id:Rd,kind:ul,priority:"extension",title:()=>"Codinput",keepMounted:!0,guide:[{order:0,title:()=>"Codinput",description:()=>x("side.guideDesc"),icon:aa}]}}function Zg(){return{options:{name:"sidebar.right.pane.tab",key:Rd,registrant:"dsh-codinput"},component:_v}}function Qg(){return{options:{name:"sidebar.right.pane.tab.title",key:Rd,registrant:"dsh-codinput"},component:Bv}}function Bv(n){let e=n.useTabInfo?.().tab.title??"Codinput";return(0,hn.jsxs)(hn.Fragment,{children:[(0,hn.jsx)(aa,{size:16}),e]})}function _v(n){let{sessionId:e,useInput:t,inputActions:i,useProjection:r,useSession:s,useTabInfo:o}=n,l=t(C=>C),a=nl(n,["useTabInfo"]),c=s?s(C=>C?.running)===!0:!1;St();let d=o?o():void 0,u=d?.tab.visible===!0,h=d?.sidebar.expanded===!0,f=d?.tab.actions?.close,p=(0,mt.useRef)(f);p.current=f,(0,mt.useEffect)(()=>{let C=Oe().__dshCodinputShell;C["sidebar.tabId"]=d?.tab.id??"none",C["sidebar.closeFace"]=f?"yes":"none"},[d,f]),(0,mt.useEffect)(()=>Mu(C=>{if(!(C!==e||!p.current))try{p.current()}catch(A){me("sidebar.closeTab",A)}}),[e]);let[m,w]=(0,mt.useState)(()=>ue().enabled);(0,mt.useEffect)(()=>pn(()=>w(ue().enabled)),[]);let b=(0,mt.useRef)(!1);(0,mt.useEffect)(()=>{b.current||(b.current=!0,ue().enabled||ct({enabled:!0}))},[]);let v=(0,mt.useRef)(null),[k,N]=(0,mt.useState)(0);(0,mt.useEffect)(()=>{if(!m)return;let C=Su(e,{visible:u,expanded:h});return v.current=C,N(C.token),()=>{v.current=null,C.release()}},[e,m]),(0,mt.useEffect)(()=>{v.current?.set({visible:u,expanded:h})},[u,h]);let S=Eu(e,k);return m?S?(0,hn.jsx)("div",{style:{position:"absolute",inset:0,minHeight:0,display:"flex",flexDirection:"column"},children:(0,hn.jsx)(dl,{sessionId:e,state:l,actions:i,useProjection:r,inputStandard:a,running:c,side:!0})}):(0,hn.jsx)("div",{className:"dci-side-notice",role:"note",children:x("side.notice")}):(0,hn.jsx)("div",{className:"dci-side-notice",role:"note",children:x("side.disabled")})}var Ld=require("react/jsx-runtime"),Hv=36,Fv=18,zv=12,Wv=8;function Dd(){return document.querySelector('[role="banner"]')??document.querySelector("header")}function t0(n){let{sessionId:e}=n;St();let{carried:t,collapsed:i}=Du(e),r=t&&i,[s,o]=(0,hl.useState)(null);return(0,hl.useEffect)(()=>{if(!r){o(null);return}let l=()=>{let u=Dd()?.getBoundingClientRect();if(!u||u.height===0)return;let h={left:Math.round(u.right-zv-Hv),top:Math.round(u.bottom+Wv)};o(f=>f&&f.left===h.left&&f.top===h.top?f:h)};l();let a=Dd(),c=typeof ResizeObserver=="function"?new ResizeObserver(l):null;a&&c&&c.observe(a),window.addEventListener("resize",l);let d=window.setInterval(()=>{Dd()&&(l(),window.clearInterval(d))},250);return()=>{c?.disconnect(),window.removeEventListener("resize",l),window.clearInterval(d)}},[r]),!r||!s?null:(0,e0.createPortal)((0,Ld.jsx)("button",{type:"button",className:"dci-ball","data-codinput-expand":"true",style:{left:s.left,top:s.top},"aria-label":x("ball.label"),title:x("ball.title"),onClick:()=>Vv(e),children:(0,Ld.jsx)(ph,{size:Fv})}),document.body)}function Vv(n){let e=Y.sidebarRight;if(e){try{if(n&&typeof e.openTabIn=="function"){e.openTabIn(n,ul);return}if(typeof e.openTab=="function"){e.openTab(ul);return}}catch(t){me("ball.openTab",t)}try{typeof e.isExpanded=="function"&&!e.isExpanded()&&e.toggleExpanded?.()}catch(t){me("ball.expand",t)}}}var Ai=require("react/jsx-runtime");function Id(n){let{variant:e,blocked:t,disabled:i,placeholder:r,sessionId:s,useInput:o,inputActions:l,useProjection:a,useChat:c,useSession:d}=n,u=o(N=>N),h=nl(n),f=c?c(N=>N?.legacy?.nodes):void 0,p=d?d(N=>N?.running)===!0:!1,m=Ru(s),[w,b]=(0,fn.useState)(()=>ue().mode);if((0,fn.useEffect)(()=>pn(()=>b(ue().mode)),[]),m)return(0,Ai.jsx)(t0,{sessionId:s});let v=w==="float",k=(0,Ai.jsx)(dl,{sessionId:s,state:u,actions:l,useProjection:a,inputStandard:h,placeholder:r,disabled:i===!0,blocked:t!==void 0,running:p,hero:e==="hero",chatNodes:f,float:v,onDragZonePointerDown:Gv});return v?(0,Ai.jsx)(Xv,{children:k}):k}var Qe=12,n0=6,Od=720,fl=360,vs=140,$v=6,Uv=12;function Gn(n,e,t){return Math.min(t,Math.max(e,n))}function Nd(){return Math.max(fl,window.innerWidth-Qe*2)}function jv(){return Math.max(vs,window.innerHeight-Qe*2)}function i0(){let n=ue();return{x:n.floatX??Math.round((window.innerWidth-Math.min(n.floatW??Od,Nd()))/2),y:n.floatY??Math.round(window.innerHeight*.16),w:n.floatW??Od,h:n.floatH}}var ar=null,Pd=new Set;function r0(n,e){for(let t of Pd)t(n,e)}function Kv(){let e=document.querySelector("[data-composer-seat]")?.getBoundingClientRect(),t=Math.min(window.innerHeight,(e?.bottom??window.innerHeight)+120),i=Math.max(0,t-300);return{left:(e?.left??0)-40,right:(e?.right??window.innerWidth)+40,top:i,bottom:t}}function Gv(n){if(n.button!==0)return;let e=n.currentTarget,t=e.closest("[data-composer-card]"),i=!!e.closest(".dci-float"),r=t?.getBoundingClientRect(),s=r?.left??n.clientX,o=r?.top??n.clientY,l=r?.width||Math.min(ue().floatW??Od,Nd()),a=b=>Gn(b,Qe,Math.max(Qe,window.innerWidth-l-Qe)),c=b=>Gn(b,Qe,Math.max(Qe,window.innerHeight-96)),d=a(n.clientX-s),u=c(n.clientY-o);n.preventDefault();let h=n.clientX,f=n.clientY,p={grabDX:d,grabDY:u,detached:i,fromFloat:i,lastX:a(n.clientX-d),lastY:c(n.clientY-u)},m=b=>{if(ar){if(!p.detached){if(Math.abs(b.clientX-h)<n0&&Math.abs(b.clientY-f)<n0)return;p.detached=!0,p.lastX=a(b.clientX-p.grabDX),p.lastY=c(b.clientY-p.grabDY),ct({mode:"float",floatX:p.lastX,floatY:p.lastY}),r0(p.lastX,p.lastY);return}p.lastX=a(b.clientX-p.grabDX),p.lastY=c(b.clientY-p.grabDY),r0(p.lastX,p.lastY)}},w=b=>{if(window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w),ar=null,!p.detached)return;let v=Kv();if(b.clientX>=v.left&&b.clientX<=v.right&&b.clientY>=v.top&&b.clientY<=v.bottom){ct({mode:"normal"});return}ct({floatX:p.lastX,floatY:p.lastY})};ar=p,window.addEventListener("pointermove",m),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w)}var qv=["n","s","e","w","nw","ne","sw","se"];function Xv(n){let{children:e}=n,t=(0,fn.useRef)(null),[i,r]=(0,fn.useState)(()=>ar?{...i0(),x:ar.lastX,y:ar.lastY}:i0()),s=(0,fn.useRef)(i);s.current=i,(0,fn.useLayoutEffect)(()=>{let u=(h,f)=>r(p=>({...p,x:h,y:f}));return Pd.add(u),()=>{Pd.delete(u)}},[]);let o=u=>h=>{if(h.button!==0)return;h.preventDefault(),h.stopPropagation();let f=s.current,m=t.current?.getBoundingClientRect(),w=m?.width??f.w,b=m?.height??f.h??vs,v=f.x,k=f.y,N=v+w,S=k+b,C=h.clientX,A=h.clientY,$=R=>{let O=R.clientX-C,M=R.clientY-A,P=w,z=b,J=v,q=k;u.includes("e")&&(P=Gn(w+O,fl,Math.max(fl,window.innerWidth-Qe-v))),u.includes("w")&&(J=Gn(v+O,Qe,N-fl),P=N-J),u.includes("s")&&(z=Gn(b+M,vs,Math.max(vs,window.innerHeight-Qe-k))),u.includes("n")&&(q=Gn(k+M,Qe,S-vs),z=S-q),r({x:J,y:q,w:Math.round(P),h:Math.round(z)})},F=()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",F),window.removeEventListener("pointercancel",F);let R=s.current;ct({floatX:R.x,floatY:R.y,floatW:R.w,floatH:R.h})};try{h.currentTarget.setPointerCapture(h.pointerId)}catch{}window.addEventListener("pointermove",$),window.addEventListener("pointerup",F),window.addEventListener("pointercancel",F)},l=Math.min(i.w,Nd()),a=i.h===null?null:Math.min(i.h,jv()),c=Gn(i.x,Qe,Math.max(Qe,window.innerWidth-l-Qe)),d=Gn(i.y,Qe,Math.max(Qe,window.innerHeight-96));return(0,s0.createPortal)((0,Ai.jsxs)("div",{className:"dci-float",ref:t,"data-sized":a!==null?"true":void 0,style:{left:c,top:d,width:l,height:a??void 0,"--dci-grip-edge":`${$v}px`,"--dci-grip-corner":`${Uv}px`},children:[e,qv.map(u=>(0,Ai.jsx)("div",{className:"dci-float-grip","data-dir":u,onPointerDown:o(u)},u))]}),document.body)}function o0(){return{options:{name:"conversation.composer.bar",priority:-1,registrant:"dsh-codinput"}}}var He=require("react");var se=require("react/jsx-runtime");function u0(){return["user","steering"].map(n=>({options:{name:"conversation.chat.node",key:n,priority:-1,registrant:"dsh-codinput"},component:yk}))}function Jv(n){let e={text:"",attachments:[],rest:[]};if(!Array.isArray(n))return e;let t=[];for(let i of n){let r=i;r&&r.type==="text"&&typeof r.text=="string"?t.push(r.text):r&&r.type==="image"&&r.attachment!==void 0?e.attachments.push({type:"image",image:{attachment:r.attachment}}):r&&r.type==="file"&&r.attachment!==void 0?e.attachments.push({type:"file",file:r.attachment??{}}):e.rest.push(i)}return e.text=t.join(""),e}var Yv=Ar??Mr,Zv={ALLOWED_TAGS:["p","br","strong","em","del","code","pre","blockquote","ul","ol","li","a","img","h1","h2","h3","h4","h5","h6","hr","table","thead","tbody","tr","th","td","input","span"],ALLOWED_ATTR:["href","src","alt","title","target","rel","type","checked","disabled","start","colspan","rowspan","align","data-dci-wire"],ALLOWED_URI_REGEXP:/^(?:https?:|mailto:)/i,FORBID_ATTR:["style"]};function Bd(n){return n.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}var Qv=/^@\[([^\]\n]+)\]\(dsh-session:[^)\s]+\)/,ek={name:"dshSessionWire",level:"inline",start(n){let e=n.indexOf("@[");return e<0?void 0:e},tokenizer(n){let e=Qv.exec(n);if(e)return{type:"dshSessionWire",raw:e[0],label:e[1]}},renderer(n){let e=String(n.label??"");return`<span data-dci-wire="${Bd(e)}">${Bd(e)}</span>`}},tk=new Zl({gfm:!0,breaks:!0,extensions:[ek]});function nk(n){try{return Yv.sanitize(tk.parse(n),Zv)}catch(e){return me("umsg.markdown",e),`<p>${Bd(n).replace(/\n/g,"<br>")}</p>`}}var ik=/[.,;:!?,。;:!?]+$/u,l0=/(^|\s)(\/[\w-]+(?=\s|$)|@"[^"\n]+"|@[^\s]+)/gu;function rk(n){let e=[],t=/@\[([^\]\n]+)\]\(dsh-session:[^)\s]+\)/gu,i;for(;(i=t.exec(n))!==null;)e.push({start:i.index,end:i.index+i[0].length,kind:"session",label:i[0],display:i[1],clickable:!1});return e}function sk(n,e){let t=[];for(let i of[...new Set(e)].sort((r,s)=>s.length-r.length)){let r=`@${i}`,s=n.indexOf(r);for(;s>=0;)t.push({start:s,end:s+r.length,kind:"session",label:r,display:i,clickable:!1}),s=n.indexOf(r,s+r.length)}return t}function ok(n,e){let t=[];l0.lastIndex=0;let i;for(;(i=l0.exec(n))!==null;){let r=i.index+i[1].length,s=i[2],o=s.startsWith('@"')?s:s.replace(ik,"");if(o.length<=1)continue;if(o.startsWith("/")){if(!e.includes(o.slice(1)))continue;t.push({start:r,end:r+o.length,kind:"slash",label:o,display:o,clickable:!0});continue}let l=o.slice(1).replace(/^"|"$/gu,""),a=l.endsWith("/")?"folder":"file",c=l.split(/[\\/]/u).filter(Boolean),d=c[c.length-1]??l;t.push({start:r,end:r+o.length,kind:a,label:o,display:d,clickable:!0})}return t}var h0="http://www.w3.org/2000/svg";function qn(n,e){let t=document.createElementNS(h0,"path");return t.setAttribute("d",n),t.setAttribute(e?"stroke":"fill","currentColor"),t}function lk(n){let e=document.createElementNS(h0,"svg");return e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("fill","none"),e.setAttribute("aria-hidden","true"),e.setAttribute("class","dci-umsg-chipicon"),n==="session"?(e.appendChild(qn("M5 6.75H11",!0)),e.appendChild(qn("M5 9H8",!0)),e.appendChild(qn("M2.37067 11.2497C1.5872 9.89252 1.32042 8.29798 1.61945 6.7597C1.91847 5.22141 2.76317 3.84293 3.99801 2.87809C5.23285 1.91325 6.7747 1.427 8.33964 1.50888C9.90458 1.59076 11.3873 2.23526 12.5147 3.32369C13.6422 4.41232 14.3384 5.8717 14.4751 7.43304C14.6118 8.99438 14.1797 10.5525 13.2585 11.8205C12.3372 13.0885 10.9889 13.9809 9.4617 14.3334C8.18666 14.6277 6.8587 14.529 5.64964 14.0601C5.17095 13.8745 4.76937 13.4929 4.26509 13.3963C3.67389 13.2832 2.95232 13.5595 2.0377 14.3334",!0)),e):n==="file"?(e.appendChild(qn("M4.9375 5.90295H11.0625",!0)),e.appendChild(qn("M4.9375 9.02991H8.27841",!0)),e.appendChild(qn("M12.5 1.32617C13.3039 1.32617 14 1.95171 14 2.77637V13.2246C13.9996 14.0489 13.3036 14.6738 12.5 14.6738H3.5C2.69637 14.6738 2.00042 14.0489 2 13.2246V2.77637C2 1.95171 2.69613 1.32617 3.5 1.32617H12.5ZM3.5 2.32617C3.1993 2.32617 3 2.55186 3 2.77637V13.2246C3.00044 13.4489 3.19963 13.6738 3.5 13.6738H12.5C12.8004 13.6738 12.9996 13.4489 13 13.2246V2.77637C13 2.55186 12.8007 2.32617 12.5 2.32617H3.5Z",!1)),e):n==="folder"?(e.appendChild(qn("M1.50439 3.11059C1.50439 2.55831 1.95211 2.1106 2.50439 2.1106H5.43389C5.67773 2.1106 5.91318 2.19969 6.09593 2.36113L7.71649 3.79265C7.89924 3.95409 8.1347 4.04319 8.3785 4.04319H13.4958C14.0481 4.04319 14.4958 4.4909 14.4958 5.04319V12.8894C14.4958 13.4417 14.0481 13.8894 13.4958 13.8894H2.50439C1.95211 13.8894 1.50439 13.4417 1.50439 12.8894V4.04319V3.11059Z",!0)),e.appendChild(qn("M3.63501 7.66614H12.3647",!0)),e):null}function ak(n){if(n.detail>1)return!0;let e=n.currentTarget;return n.detail!==0&&e instanceof Node&&e.ownerDocument?.getSelection()?.isCollapsed===!1}function f0(n,e){let t=e.current,i=n.clickable&&(n.kind==="file"?typeof t.openFile=="function":n.kind==="slash"&&typeof t.openSkill=="function"),r=document.createElement(i?"button":"span");i&&r.setAttribute("type","button"),r.className="dci-umsg-chip",r.dataset.chip=n.kind,r.title=n.label;let s=lk(n.kind);return s&&r.appendChild(s),r.appendChild(document.createTextNode(n.display)),i&&r.addEventListener("click",o=>{if(ak(o))return;let l=e.current;n.kind==="slash"?l.openSkill?.(n.display.slice(1)):l.openFile?.(n.label.slice(1).replace(/^"|"$/gu,""))}),r}function a0(n){return n.kind==="session"?0:1}function ck(n,e,t){let i=document.createDocumentFragment(),r=0;for(let s of e)s.start>r&&i.appendChild(document.createTextNode(n.data.slice(r,s.start))),i.appendChild(f0(s,t)),r=s.end;r<n.data.length&&i.appendChild(document.createTextNode(n.data.slice(r))),n.parentNode?.replaceChild(i,n)}function dk(n,e){let t=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,{acceptNode(l){let a=l.parentElement;return!a||a.closest("pre, code, a, .dci-umsg-chip")||l.data.length===0?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),i=[],r=t.nextNode();for(;r;)i.push(r),r=t.nextNode();let{skillNames:s,referenceLabels:o}=e.current;for(let l of i){let a=[...rk(l.data),...sk(l.data,o),...ok(l.data,s)];if(a.length===0)continue;a.sort((u,h)=>u.start-h.start||a0(u)-a0(h)||h.end-u.end);let c=[],d=0;for(let u of a)u.start<d||(c.push(u),d=u.end);c.length!==0&&ck(l,c,e)}}function uk(n,e){if(n)try{for(let t of Array.from(n.querySelectorAll("a"))){let i=t.getAttribute("href")??"";if(/^https?:/i.test(i)){t.setAttribute("target","_blank"),t.setAttribute("rel","noreferrer noopener");continue}if(/^mailto:/i.test(i)){t.setAttribute("rel","noreferrer noopener");continue}t.replaceWith(...Array.from(t.childNodes))}for(let t of Array.from(n.querySelectorAll("img")))/^https?:/i.test(t.getAttribute("src")??"")||t.replaceWith(document.createTextNode(t.getAttribute("alt")??""));for(let t of Array.from(n.querySelectorAll("input"))){if(!t.hasAttribute("disabled")){t.remove();continue}t.setAttribute("type","checkbox"),t.setAttribute("disabled","")}for(let t of Array.from(n.querySelectorAll("table"))){let i=t.parentElement;if(!i||i.classList.contains("dci-umsg-tscroll"))continue;let r=document.createElement("div");r.className="dci-umsg-tscroll",i.insertBefore(r,t),r.appendChild(t)}for(let t of Array.from(n.querySelectorAll("span[data-dci-wire]"))){let i=t.getAttribute("data-dci-wire")??"";t.replaceWith(f0({start:0,end:0,kind:"session",label:i,display:i,clickable:!1},e))}dk(n,e)}catch(t){me("umsg.decorate",t)}}function _d(n,e,t){let i=pr("chat");if(i)try{let r=i(n,t);if(r&&r!==n)return r}catch{}return x(e,t)}function hk(){let n=pr("chat");if(n)try{let e=n("message.referenceSeparator");if(e&&e!=="message.referenceSeparator")return e}catch{}return x("umsg.referenceSummary").includes("\u5F15\u7528")?"\u3001":", "}function c0(n){return n<10?`0${n}`:String(n)}function d0(n,e=Date.now()){let t=typeof n=="number"?n:typeof n=="string"?Date.parse(n):NaN;if(!Number.isFinite(t))return"";let i=new Date(t),r=new Date(e),s=`${c0(i.getHours())}:${c0(i.getMinutes())}`;if(i.getFullYear()===r.getFullYear()&&i.getMonth()===r.getMonth()&&i.getDate()===r.getDate())return s;let o={y:i.getFullYear(),m:i.getMonth()+1,d:i.getDate()};return`${_d(i.getFullYear()===r.getFullYear()?"clock.md":"clock.ymd",i.getFullYear()===r.getFullYear()?"umsg.clock.md":"umsg.clock.ymd",o)} ${s}`}async function fk(n){try{return await navigator.clipboard.writeText(n),!0}catch{try{let e=document.createElement("textarea");e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();let t=document.execCommand("copy");return e.remove(),t}catch{return!1}}}function pk(){return(0,se.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,se.jsx)("rect",{x:"1.52075",y:"4.07373",width:"10.3932",height:"10.3932",rx:"2",stroke:"currentColor"}),(0,se.jsx)("path",{d:"M11.9792 1.53296C13.36 1.53296 14.4792 2.65225 14.4792 4.03296V9.42847C14.4792 10.3756 13.9521 11.1987 13.1755 11.6228V10.3298C13.3652 10.0787 13.4792 9.7674 13.4792 9.42847V4.03296C13.4792 3.20453 12.8077 2.53296 11.9792 2.53296H6.58374C6.27966 2.53301 5.99684 2.6235 5.7605 2.77905H4.42358C4.85652 2.03463 5.66056 1.53304 6.58374 1.53296H11.9792Z",fill:"currentColor"})]})}function mk(){return(0,se.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:(0,se.jsx)("path",{d:"M2.25 8.5L5.49732 11.7473C5.90519 12.1552 6.57263 12.1344 6.95426 11.7018L13.75 4",stroke:"currentColor"})})}function gk({file:n}){let e=typeof n.name=="string"?n.name:"",t=typeof n.bytes=="number"?n.bytes:0,i=[gd(e).toUpperCase().slice(0,8),Qo(t)].filter(Boolean).join(" ");return(0,se.jsxs)("span",{className:"dci-umsg-file",title:e,children:[(0,se.jsx)("span",{className:"dci-umsg-fileglyph",children:(0,se.jsx)(fs,{})}),(0,se.jsxs)("span",{className:"dci-umsg-filecontent",children:[(0,se.jsx)("span",{className:"dci-umsg-filename",children:e}),(0,se.jsx)("span",{className:"dci-umsg-filemeta",children:i})]})]})}function bk({image:n}){let e=n.attachment??{},t=typeof e.name=="string"&&e.name!==""?e.name:x("umsg.image"),r=[typeof e.mediaType=="string"?e.mediaType.replace(/^image\//i,"").toUpperCase():"",typeof e.bytes=="number"?Qo(e.bytes):""].filter(Boolean).join(" ");return(0,se.jsxs)("span",{className:"dci-umsg-file","data-image-fallback":"true",title:t,children:[(0,se.jsx)("span",{className:"dci-umsg-fileglyph",children:(0,se.jsx)(fs,{})}),(0,se.jsxs)("span",{className:"dci-umsg-filecontent",children:[(0,se.jsx)("span",{className:"dci-umsg-filename",children:t}),(0,se.jsx)("span",{className:"dci-umsg-filemeta",children:r})]})]})}function wk(n){let{node:e,renderMessageImages:t,openFile:i,openSkill:r}=n;St();let s=e?.data??{},o=s.content,l=(0,He.useMemo)(()=>Array.isArray(s.referenceLabels)?s.referenceLabels:[],[s.referenceLabels]),a=(0,He.useMemo)(()=>Array.isArray(s.skillNames)?s.skillNames:[],[s.skillNames]),{text:c,attachments:d,rest:u}=(0,He.useMemo)(()=>Jv(o),[o]),h=d.length>1,f=c!==""||u.length>0,p=(0,He.useMemo)(()=>c===""?"":nk(c),[c]),m=(0,He.useRef)(null),w=(0,He.useRef)({openFile:i,openSkill:r,skillNames:a,referenceLabels:l});w.current={openFile:i,openSkill:r,skillNames:a,referenceLabels:l},(0,He.useEffect)(()=>{uk(m.current,w)},[p,l,a]);let[b,v]=(0,He.useState)(!1),k=(0,He.useRef)(null);(0,He.useEffect)(()=>()=>{k.current!==null&&window.clearTimeout(k.current)},[]);let N=(0,He.useCallback)(()=>{b||c===""||fk(c).then(S=>{S&&(v(!0),k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{k.current=null,v(!1)},1e3))})},[b,c]);return!f&&d.length===0&&l.length===0&&s.time===void 0?null:(0,se.jsx)("div",{className:"dci-umsg-row",children:(0,se.jsxs)("div",{className:"dci-umsg-stack",children:[d.length>0&&(0,se.jsx)("div",{className:"dci-umsg-attrow","data-message-attachments":"true",children:d.map((S,C)=>S.type==="image"?(0,se.jsx)(He.Fragment,{children:t?t({images:[S.image],align:"end",compact:h}):(0,se.jsx)(bk,{image:S.image})},`image:${C}`):(0,se.jsx)(gk,{file:S.file},`file:${C}`))}),f&&(0,se.jsxs)("div",{className:"dci-umsg-bubble",children:[c!==""&&(0,se.jsx)("div",{className:"dci-umsg-md",ref:m,dangerouslySetInnerHTML:{__html:p}}),u.map((S,C)=>(0,se.jsxs)("pre",{className:"dci-umsg-extra",children:[_d("message.extraBlock","umsg.extraBlock"),`
728
- `,JSON.stringify(S,null,2)]},C))]}),l.length>0&&(0,se.jsx)("div",{className:"dci-umsg-refsum",children:_d("message.referenceSummary","umsg.referenceSummary",{labels:l.join(hk())})}),(0,se.jsxs)("div",{className:"dci-umsg-actions","data-clock":"start",children:[s.time!==void 0&&d0(s.time)!==""&&(0,se.jsx)("span",{className:"dci-umsg-time",children:d0(s.time)}),(0,se.jsx)("button",{type:"button",className:"dci-umsg-action","aria-label":b?x("umsg.copied"):x("umsg.copy"),title:b?x("umsg.copied"):x("umsg.copy"),onClick:N,children:b?(0,se.jsx)(mk,{}):(0,se.jsx)(pk,{})})]})]})})}var yk=(0,He.memo)(wk);var Xt=require("react");var oe=require("react/jsx-runtime"),xk="codinput";function m0(){return{options:{name:"settings.section",id:xk,order:60,label:()=>"Codinput",registrant:"dsh-codinput"},component:kk}}function p0(n){let{value:e,conflictWith:t,ariaLabel:i,onChange:r}=n,[s,o]=(0,Xt.useState)(!1),[l,a]=(0,Xt.useState)(!1),c=(0,Xt.useRef)(null);return(0,Xt.useEffect)(()=>{if(!s)return;let d=u=>{c.current&&u.target instanceof Node&&c.current.contains(u.target)||o(!1)};return window.addEventListener("pointerdown",d,!0),()=>window.removeEventListener("pointerdown",d,!0)},[s]),(0,oe.jsx)("button",{ref:c,type:"button",className:"dci-set-selector","data-recording":s||void 0,"data-conflict":l||void 0,"aria-label":i,onClick:()=>o(!0),onBlur:()=>o(!1),onKeyDown:d=>{if(!s)return;if(d.preventDefault(),d.stopPropagation(),d.key==="Escape"){o(!1);return}if(d.key==="Shift"||d.key==="Control"||d.key==="Alt"||d.key==="Meta")return;let u=lg(d.nativeEvent,d.key);if(t!==void 0&&u===t){a(!0),window.setTimeout(()=>a(!1),1500);return}r(u),o(!1),c.current?.blur()},children:s?x("set.recording"):ag(e)})}function Xn(n){let{title:e,desc:t,children:i}=n;return(0,oe.jsxs)("div",{className:"dci-set-row",children:[(0,oe.jsxs)("div",{className:"dci-set-rowText",children:[(0,oe.jsx)("div",{className:"dci-set-title",children:e}),t?(0,oe.jsx)("div",{className:"dci-set-desc",children:t}):null]}),(0,oe.jsx)("div",{className:"dci-set-control",children:i})]})}function vk(n){let{value:e,options:t,onChange:i,ariaLabel:r}=n,[s,o]=(0,Xt.useState)(!1),l=(0,Xt.useRef)(null),[a,c]=(0,Xt.useState)(null),d=t.find(u=>u.value===e);return(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsxs)("button",{ref:l,type:"button",className:"dci-set-selector","aria-haspopup":"menu","aria-expanded":s,"aria-label":r,onClick:()=>{s||c(l.current?.getBoundingClientRect()??null),o(!s)},children:[d?.label??e,(0,oe.jsx)(en,{size:14})]}),s&&a?(0,oe.jsx)(or,{anchor:a,side:"bottom",alignEnd:!0,onClose:()=>o(!1),minWidth:200,children:t.map(u=>(0,oe.jsx)("button",{type:"button",className:"dci-item",onClick:()=>{i(u.value),o(!1)},children:(0,oe.jsx)("span",{className:"dci-itemLabel",children:u.label})},u.value))}):null]})}function Hd(n){let{on:e,label:t,onToggle:i}=n;return(0,oe.jsx)("button",{type:"button",role:"switch",className:"dci-switch","aria-checked":e,"aria-label":t,onClick:i})}function kk(){let[n,e]=(0,Xt.useState)(()=>ue());St();let t=i=>{e(ct(i))};return(0,oe.jsxs)("div",{className:"dci-settings",children:[(0,oe.jsx)(Xn,{title:x("set.enabled"),desc:x("set.enabledDesc"),children:(0,oe.jsx)(Hd,{on:n.enabled,label:x("set.enabled"),onToggle:()=>t({enabled:!n.enabled})})}),(0,oe.jsx)(Xn,{title:x("set.userMarkdown"),desc:x("set.userMarkdownDesc"),children:(0,oe.jsx)(Hd,{on:n.userMarkdown,label:x("set.userMarkdown"),onToggle:()=>t({userMarkdown:!n.userMarkdown})})}),(0,oe.jsx)(Xn,{title:x("set.lineNumbers"),desc:x("set.lineNumbersDesc"),children:(0,oe.jsx)(Hd,{on:n.lineNumbers,label:x("set.lineNumbers"),onToggle:()=>t({lineNumbers:!n.lineNumbers})})}),(0,oe.jsx)(Xn,{title:x("set.font"),desc:x("set.fontDesc"),children:(0,oe.jsx)("input",{type:"text",className:"dci-set-input",value:n.fontFamily,spellCheck:!1,"aria-label":x("set.font"),onChange:i=>t({fontFamily:i.target.value})})}),(0,oe.jsx)(Xn,{title:x("set.sendKey"),desc:x("set.sendKeyDesc"),children:(0,oe.jsx)(p0,{value:n.sendHotkey,conflictWith:n.lineBreakHotkey,ariaLabel:x("set.sendKey"),onChange:i=>t({sendHotkey:i})})}),(0,oe.jsx)(Xn,{title:x("set.lineBreakKey"),desc:x("set.lineBreakKeyDesc"),children:(0,oe.jsx)(p0,{value:n.lineBreakHotkey,conflictWith:n.sendHotkey,ariaLabel:x("set.lineBreakKey"),onChange:i=>t({lineBreakHotkey:i})})}),(0,oe.jsx)(Xn,{title:x("set.defaultView"),desc:x("set.defaultViewDesc"),children:(0,oe.jsx)(vk,{value:n.defaultEdit&&n.defaultPreview?"split":n.defaultPreview?"preview":"edit",ariaLabel:x("set.defaultView"),onChange:i=>t({defaultEdit:i!=="preview",defaultPreview:i!=="edit"}),options:[{value:"edit",label:x("head.editOnly")},{value:"split",label:x("head.split")},{value:"preview",label:x("head.previewOnly")}]})}),(0,oe.jsx)(Xn,{title:x("set.reset"),desc:x("set.resetAll"),children:(0,oe.jsx)("button",{type:"button",className:"dci-set-selector",onClick:()=>e(ct({...mr})),children:x("set.resetAction")})})]})}function Sk(n){if(n)try{let e=Y.sessions?.scope(n);e&&Y.conversation&&Y.conversation.input.for(e).setDraft("")}catch{}}function g0(n,e,t){let i=n.findIndex(o=>o.name===e);if(i===-1)return[...n];let r=t(n);if(r===i||r===i+1)return[...n];let s=[...n];return s.splice(i,1),s.splice(r>i?r-1:r,0,n[i]),s}function b0(n){Fe("command.register",()=>{n.inject(["commandUi"],e=>{let t=e.commandUi;if(typeof t?.register!="function"){Oe().__dshCodinputShell.command="commandUi-unavailable";return}let i;if(typeof t.candidates=="function"){let r=t.candidates.bind(t);t.candidates=(s,o)=>Promise.resolve(r(s,o)).then(l=>{if(o.query!==""||!Array.isArray(l))return l;let a=l,c=a.find(d=>d.name==="goal"||d.name==="plan"||d.name==="feedback")?.section;return c!==void 0&&(a=g0(a,"file",d=>{let u=d.findIndex(h=>h.section===c&&h.name!=="file");return u===-1?d.length:u})),a=g0(a,"codinput",d=>{let u=d.find(f=>f.name==="codinput"),h=d.findIndex(f=>f.section===u?.section&&f.name!=="codinput"&&f.name.toLowerCase()>"codinput");return h===-1?d.length:h}),a}),i=()=>{t.candidates=r}}n.effect(()=>i,"dsh-codinput: slash order patch"),n.effect(()=>t.register({name:"codinput",description:()=>ue().enabled?x("cmd.exit"):x("cmd.enter"),icon:Rh,available:()=>!0,ui:{kind:"action",run:()=>{let r=Oe().__dshCodinputSessionId??void 0;if(ct({enabled:!ue().enabled}),!ue().enabled)for(let s of Cu())Au(s);setTimeout(()=>Sk(r),80)}}}),"dsh-codinput: /codinput contribution"),Oe().__dshCodinputShell.command="registered"})})}var Ck="dsh-codinput",Tk=["slots","conversation"];function cr(n,e,t=60){try{n(),Oe().__dshCodinputShell[e]="registered";return}catch(i){if(t<=0){me(e,i),Oe().__dshCodinputShell[e]="failed";return}}setTimeout(()=>cr(n,e,t-1),250)}function Ak(n){wu(),gu(n),Fe("console.hook",()=>{let l=Oe();if(!l.__dshConsoleHooked){l.__dshConsoleHooked=!0;let a=l.console.error.bind(l.console);l.console.error=(...c)=>{let d=c.find(u=>u instanceof Error);if(d){let u=l.__dshCodinputErrs;u.push(d),u.length>200&&u.splice(0,u.length-200)}a(...c)}}}),Fe("slots.entryErrorHook",()=>{let l=n.slots,a=l._core??l;typeof a.onEntryError=="function"&&a.onEntryError(c=>{let d=c?.error;me("slot.entry",d??c),Oe().__dshCodinputErrs.push(d instanceof Error?d:new Error(JSON.stringify(c).slice(0,800)))})});let e=o0(),t=null,i=()=>{if(!t)try{t=n.slots.register(e.options,Id),Oe().__dshCodinputShell.bar="mounted"}catch(l){me("bar.register",l)}},r=()=>{let l=t;t=null;try{l?.(),Oe().__dshCodinputShell.bar="unmounted"}catch(a){me("bar.dispose",a)}},s=()=>ue().enabled||Tu(),o=()=>{s()?i():r()};cr(()=>{s()&&i()},"bar"),Fe("bar.prefs",()=>{pn(o)}),Fe("bar.sideinput",()=>{br(o)}),Fe("md.register",()=>{let l=u0(),a=new Map,c=()=>ue().userMarkdown,d=f=>{let p=f.options.key??"";a.has(p)||!c()||(a.set(p,n.slots.register(f.options,f.component)),Oe().__dshCodinputShell[`md.${p}`]="mounted")},u=f=>{let p=a.get(f);if(p){a.delete(f);try{p(),Oe().__dshCodinputShell[`md.${f}`]="unmounted"}catch(m){me("md.dispose",m)}}},h=()=>{for(let f of l){let p=f.options.key??"";c()?cr(()=>d(f),`md.${p}`):u(p)}};h(),Fe("md.prefs",()=>{pn(h)})}),Fe("sidebar.register",()=>{n.inject(["slots","sidebarRightTabs","sidebarRight"],l=>{let a=l.sidebarRightTabs;if(typeof a?.register!="function"){me("sidebar",new Error("sidebarRightTabs unavailable"));return}let c=Zg();n.effect(()=>a.register(Yg()),"dsh-codinput: sidebar tab type"),cr(()=>{n.slots.register(c.options,c.component)},"sidebar.body");let d=Qg();cr(()=>{n.slots.register(d.options,d.component)},"sidebar.title")})}),Fe("settings.register",()=>{let l=m0();cr(()=>{n.slots.register(l.options,l.component)},"settings")}),b0(n),Fe("draggate.install",()=>{let l=window;l.__dshCodinputDragGate||(l.__dshCodinputDragGate=!0,document.addEventListener("pointerdown",a=>{a.target instanceof Element&&(a.target.closest("[data-dockkit-tab-close]")||a.target.closest("[data-dockkit-tab]")&&a.stopPropagation())},{capture:!0}))}),Fe("diag.boot",()=>{Oe().__dshCodinputShell.apply="done",window.__dshCodinputCtx=n})}
723
+ `;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var yn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},$i={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Mw=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ew=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(_e=0;_e<10;_e++)yn[48+_e]=yn[96+_e]=String(_e);var _e;for(_e=1;_e<=24;_e++)yn[_e+111]="F"+_e;var _e;for(_e=65;_e<=90;_e++)yn[_e]=String.fromCharCode(_e+32),$i[_e]=String.fromCharCode(_e);var _e;for(lo in yn)$i.hasOwnProperty(lo)||($i[lo]=yn[lo]);var lo;function of(n){var e=Mw&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ew&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?$i:yn)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var rt=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Ba=typeof document<"u"?document:{documentElement:{style:{}}},_a=/Edge\/(\d+)/.exec(rt.userAgent),Hf=/MSIE \d/.test(rt.userAgent),Ha=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(rt.userAgent),Io=!!(Hf||Ha||_a),lf=!Io&&/gecko\/(\d+)/i.test(rt.userAgent),La=!Io&&/Chrome\/(\d+)/.exec(rt.userAgent),af="webkitFontSmoothing"in Ba.documentElement.style,Fa=!Io&&/Apple Computer/.test(rt.vendor),cf=Fa&&(/Mobile\/\w+/.test(rt.userAgent)||rt.maxTouchPoints>2),N={mac:cf||/Mac/.test(rt.platform),windows:/Win/.test(rt.platform),linux:/Linux|X11/.test(rt.platform),ie:Io,ie_version:Hf?Ba.documentMode||6:Ha?+Ha[1]:_a?+_a[1]:0,gecko:lf,gecko_version:lf?+(/Firefox\/(\d+)/.exec(rt.userAgent)||[0,0])[1]:0,chrome:!!La,chrome_version:La?+La[1]:0,ios:cf,android:/Android\b/.test(rt.userAgent),webkit:af,webkit_version:af?+(/\bAppleWebKit\/(\d+)/.exec(rt.userAgent)||[0,0])[1]:0,safari:Fa,safari_version:Fa?+(/\bVersion\/(\d+(\.\d+)?)/.exec(rt.userAgent)||[0,0])[1]:0,tabSize:Ba.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Ac(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}var xo=Object.create(null);function Mc(n,e,t){if(n==e)return!0;n||(n=xo),e||(e=xo);let i=Object.keys(n),r=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function Rw(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function df(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function Lw(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let i=n.attributes[t];e[i.name]=i.value}return e}var Hn=class{eq(e){return!1}updateDOM(e,t,i){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},Ge=(function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n})(Ge||(Ge={})),be=class extends tn{constructor(e,t,i,r){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Kr(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new fi(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=Ff(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new fi(e,i,r,t,e.widget||null,!0)}static line(e){return new Gr(e)}static set(e,t=!1){return he.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};be.none=he.empty;var Kr=class n extends be{constructor(e){let{start:t,end:i}=Ff(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Ac(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||xo}eq(e){return this==e||e instanceof n&&this.tagName==e.tagName&&Mc(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};Kr.prototype.point=!1;var Gr=class n extends be{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&Mc(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};Gr.prototype.mapMode=ut.TrackBefore;Gr.prototype.point=!0;var fi=class n extends be{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?ut.TrackBefore:ut.TrackAfter:ut.TrackDel}get type(){return this.startSide!=this.endSide?Ge.WidgetRange:this.startSide<=0?Ge.WidgetBefore:Ge.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&Dw(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};fi.prototype.point=!0;function Ff(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function Dw(n,e){return n==e||!!(n&&e&&n.compare(e))}function qi(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}var vo=class n extends tn{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof n&&this.tagName==e.tagName&&Mc(this.attributes,e.attributes)}static create(e){return new n(e.tagName,e.attributes||xo,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return he.of(e,t)}};vo.prototype.startSide=vo.prototype.endSide=-1;function qr(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function za(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function _r(n,e){if(!e.anchorNode)return!1;try{return za(n,e.anchorNode)}catch{return!1}}function Hr(n){return n.nodeType==3?Jr(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function Fr(n,e,t,i){return t?uf(n,e,t,i,-1)||uf(n,e,t,i,1):!1}function Fn(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function ko(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function uf(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:kn(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=Fn(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?kn(n):0}else return!1}}function kn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Xr(n,e){let{left:t,right:i}=n;if(t==i)return n;let r=e?t:i;return{left:r,right:r,top:n.top,bottom:n.bottom}}function Ow(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function zf(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function Pw(n,e,t,i,r,s,o,l){let a=n.ownerDocument,c=a.defaultView||window;for(let d=n,u=!1;d&&!u;)if(d.nodeType==1){let h,f=d==a.body,p=1,m=1;if(f)h=Ow(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(d).position)&&(u=!0),d.scrollHeight<=d.clientHeight&&d.scrollWidth<=d.clientWidth){d=d.assignedSlot||d.parentNode;continue}let k=d.getBoundingClientRect();({scaleX:p,scaleY:m}=zf(d,k)),h={left:k.left,right:k.left+d.clientWidth*p,top:k.top,bottom:k.top+d.clientHeight*m}}let w=0,b=0;if(r=="nearest")e.top<h.top+o?(b=e.top-(h.top+o),t>0&&e.bottom>h.bottom+b&&(b=e.bottom-h.bottom+o)):e.bottom>h.bottom-o&&(b=e.bottom-h.bottom+o,t<0&&e.top-b<h.top&&(b=e.top-(h.top+o)));else{let k=e.bottom-e.top,C=h.bottom-h.top;b=(r=="center"&&k<=C?e.top+k/2-C/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-C+o)-h.top}if(i=="nearest"?e.left<h.left+s?(w=e.left-(h.left+s),t>0&&e.right>h.right+w&&(w=e.right-h.right+s)):e.right>h.right-s&&(w=e.right-h.right+s,t<0&&e.left<h.left+w&&(w=e.left-(h.left+s))):w=(i=="center"?e.left+(e.right-e.left)/2-(h.right-h.left)/2:i=="start"==l?e.left-s:e.right-(h.right-h.left)+s)-h.left,w||b)if(f)c.scrollBy(w,b);else{let k=0,C=0;if(b){let P=d.scrollTop;d.scrollTop+=b/m,C=(d.scrollTop-P)*m}if(w){let P=d.scrollLeft;d.scrollLeft+=w/p,k=(d.scrollLeft-P)*p}e={left:e.left-k,top:e.top-C,right:e.right-k,bottom:e.bottom-C},k&&Math.abs(k-w)<1&&(i="nearest"),C&&Math.abs(C-b)<1&&(r="nearest")}if(f)break;(e.top<h.top||e.bottom>h.bottom||e.left<h.left||e.right>h.right)&&(e={left:Math.max(e.left,h.left),right:Math.min(e.right,h.right),top:Math.max(e.top,h.top),bottom:Math.min(e.bottom,h.bottom)}),d=d.assignedSlot||d.parentNode}else if(d.nodeType==11)d=d.host;else break}function Wf(n,e=!0){let t=n.ownerDocument,i=null,r=null;for(let s=n.parentNode;s&&!(s==t.body||(!e||i)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),e&&!i&&s.scrollWidth>s.clientWidth&&(i=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:i,y:r}}var Wa=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?kn(t):0),i,Math.min(e.focusOffset,i?kn(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}};function Vf(n){let e=[];for(let t=n;t;t=t.nodeType==11?t.host:t.parentNode)t.nodeType==1&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function $f(n,e=!0){for(let{node:t,left:i,top:r}of n)e&&t.scrollTop!=r&&(t.scrollTop=r),t.scrollLeft!=i&&(t.scrollLeft=i)}var di=null;N.safari&&N.safari_version>=26&&(di=!1);function Uf(n){if(n.setActive)return n.setActive();if(di)return n.focus(di);let e=Vf(n);n.focus(di==null?{get preventScroll(){return di={preventScroll:!0},!0}}:void 0),di||(di=!1,$f(e))}var hf;function Jr(n,e,t=e){let i=hf||(hf=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Xi(n,e,t,i){let r={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,n.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,n.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Iw(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Nw(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,kn(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=kn(t))}else{if(t==n)return!0;i=Fn(t),t=t.parentNode}}function jf(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function Kf(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=kn(t)}else if(t.parentNode&&!ko(t))i=Fn(t),t=t.parentNode;else return null}}function Gf(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i<t.nodeValue.length)return{node:t,offset:i};if(t.nodeType==1&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!ko(t))i=Fn(t)+1,t=t.parentNode;else return null}}var rn=class n{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new n(e.parentNode,Fn(e),t)}static after(e,t){return new n(e.parentNode,Fn(e)+1,t)}},we=(function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n})(we||(we={})),pi=we.LTR,Ec=we.RTL;function qf(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}var Bw=qf("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),_w=qf("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Va=Object.create(null),nn=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);Va[e]=t,Va[t]=-e}function Xf(n){return n<=247?Bw[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?_w[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}var Hw=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,Rt=class{get dir(){return this.level%2?Ec:pi}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(s<0||(r!=0?r<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function Jf(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let i=n[t],r=e[t];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!Jf(i.inner,r.inner))return!1}return!0}var fe=[];function Fw(n,e,t,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:t,a=s?256:r;for(let c=o,d=a,u=a;c<l;c++){let h=Xf(n.charCodeAt(c));h==512?h=d:h==8&&u==4&&(h=16),fe[c]=h==4?2:h,h&7&&(u=h),d=h}for(let c=o,d=a,u=a;c<l;c++){let h=fe[c];if(h==128)c<l-1&&d==fe[c+1]&&d&24?h=fe[c]=d:fe[c]=256;else if(h==64){let f=c+1;for(;f<l&&fe[f]==64;)f++;let p=c&&d==8||f<t&&fe[f]==8?u==1?1:8:256;for(let m=c;m<f;m++)fe[m]=p;c=f-1}else h==8&&u==1&&(fe[c]=1);d=h,h&7&&(u=h)}}}function zw(n,e,t,i,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let c=o?i[o-1].to:e,d=o<i.length?i[o].from:t;for(let u=c,h,f,p;u<d;u++)if(f=Va[h=n.charCodeAt(u)])if(f<0){for(let m=l-3;m>=0;m-=3)if(nn[m+1]==-f){let w=nn[m+2],b=w&2?r:w&4?w&1?s:r:0;b&&(fe[u]=fe[nn[m]]=b),l=m;break}}else{if(nn.length==189)break;nn[l++]=u,nn[l++]=h,nn[l++]=a}else if((p=fe[u])==2||p==1){let m=p==r;a=m?0:1;for(let w=l-3;w>=0;w-=3){let b=nn[w+2];if(b&2)break;if(m)nn[w+2]|=2;else{if(b&4)break;nn[w+2]|=4}}}}}function Ww(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,l=r<t.length?t[r].from:e;for(let a=o;a<l;){let c=fe[a];if(c==256){let d=a+1;for(;;)if(d==l){if(r==t.length)break;d=t[r++].to,l=r<t.length?t[r].from:e}else if(fe[d]==256)d++;else break;let u=s==1,h=(d<e?fe[d]:i)==1,f=u==h?u?1:2:i;for(let p=d,m=r,w=m?t[m-1].to:n;p>a;)p==w&&(p=t[--m].from,w=m?t[m-1].to:n),fe[--p]=f;a=d}else s=c,a++}}}function $a(n,e,t,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let a=e,c=0;a<t;){let d=!0,u=!1;if(c==s.length||a<s[c].from){let m=fe[a];m!=l&&(d=!1,u=m==16)}let h=!d&&l==1?[]:null,f=d?i:i+1,p=a;e:for(;;)if(c<s.length&&p==s[c].from){if(u)break e;let m=s[c];if(!d)for(let w=m.to,b=c+1;;){if(w==t)break e;if(b<s.length&&s[b].from==w)w=s[b++].to;else{if(fe[w]==l)break e;break}}if(c++,h)h.push(m);else{m.from>a&&o.push(new Rt(a,m.from,f));let w=m.direction==pi!=!(f%2);Ua(n,w?i+1:i,r,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(d?fe[p]!=l:fe[p]==l))break;p++}h?$a(n,a,p,i+1,r,h,o):a<p&&o.push(new Rt(a,p,f)),a=p}else for(let a=t,c=s.length;a>e;){let d=!0,u=!1;if(!c||a>s[c-1].to){let m=fe[a-1];m!=l&&(d=!1,u=m==16)}let h=!d&&l==1?[]:null,f=d?i:i+1,p=a;e:for(;;)if(c&&p==s[c-1].to){if(u)break e;let m=s[--c];if(!d)for(let w=m.from,b=c;;){if(w==e)break e;if(b&&s[b-1].to==w)w=s[--b].from;else{if(fe[w-1]==l)break e;break}}if(h)h.push(m);else{m.to<a&&o.push(new Rt(m.to,a,f));let w=m.direction==pi!=!(f%2);Ua(n,w?i+1:i,r,m.inner,m.from,m.to,o),a=m.from}p=m.from}else{if(p==e||(d?fe[p-1]!=l:fe[p-1]==l))break;p--}h?$a(n,p,a,i+1,r,h,o):p<a&&o.push(new Rt(p,a,f)),a=p}}function Ua(n,e,t,i,r,s,o){let l=e%2?2:1;Fw(n,r,s,i,l),zw(n,r,s,i,l),Ww(r,s,i,l),$a(n,r,s,e,t,i,o)}function Vw(n,e,t){if(!n)return[new Rt(0,0,e==Ec?1:0)];if(e==pi&&!t.length&&!Hw.test(n))return Yf(n.length);if(t.length)for(;n.length>fe.length;)fe[fe.length]=256;let i=[],r=e==pi?0:1;return Ua(n,r,r,t,0,n.length,i),i}function Yf(n){return[new Rt(0,n,0)]}var Zf="";function $w(n,e,t,i,r){var s;let o=i.head-n.from,l=Rt.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),a=e[l],c=a.side(r,t);if(o==c){let h=l+=r?1:-1;if(h<0||h>=e.length)return null;a=e[l=h],o=a.side(!r,t),c=a.side(r,t)}let d=$e(n.text,o,a.forward(r,t));(d<a.from||d>a.to)&&(d=c),Zf=n.text.slice(Math.min(o,d),Math.max(o,d));let u=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return u&&d==c&&u.level+(r?0:1)<a.level?L.cursor(u.side(!r,t)+n.from,u.forward(r,t)?1:-1,u.level):L.cursor(d+n.from,a.forward(r,t)?-1:1,a.level)}function Uw(n,e,t){for(let i=e;i<t;i++){let r=Xf(n.charCodeAt(i));if(r==1)return pi;if(r==2||r==4)return Ec}return pi}var Qf=$.define(),ep=$.define(),tp=$.define(),np=$.define(),ja=$.define(),ip=$.define(),rp=$.define(),Rc=$.define(),Lc=$.define(),sp=$.define({combine:n=>n.some(e=>e)}),op=$.define({combine:n=>n.some(e=>e)}),lp=$.define(),zr=class n{constructor(e,t,i,r,s,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new n(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new n(L.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},ao=ke.define({map:(n,e)=>n.map(e)}),ap=ke.define();function Ft(n,e,t){let i=n.facet(np);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}var xn=$.define({combine:n=>n.length?n[0]:!0}),jw=0,ji=$.define({combine(n){return n.filter((e,t)=>{for(let i=0;i<t;i++)if(n[i].plugin==e.plugin)return!1;return!0})}}),Wt=class n{constructor(e,t,i,r,s){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=r,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(ji.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(ji.of({plugin:this,arg:e}))}static define(e,t){let{eventHandlers:i,eventObservers:r,provide:s,decorations:o}=t||{};return new n(jw++,e,i,r,l=>{let a=[];return o&&a.push(No.of(c=>{let d=c.plugin(l);return d?o(d):be.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return n.define((i,r)=>new e(i,r),t)}},Wr=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(Ft(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Ft(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){Ft(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},cp=$.define(),Dc=$.define(),No=$.define(),dp=$.define(),Oc=$.define(),Yr=$.define(),up=$.define();function ff(n,e){let t=n.state.facet(up);if(!t.length)return t;let i=t.map(s=>s instanceof Function?s(n):s),r=[];return he.spans(i,e.from,e.to,{point(){},span(s,o,l,a){let c=s-e.from,d=o-e.from,u=r;for(let h=l.length-1;h>=0;h--,a--){let f=l[h].spec.bidiIsolate,p;if(f==null&&(f=Uw(e.text,c,d)),a>0&&u.length&&(p=u[u.length-1]).to==c&&p.direction==f)p.to=d,u=p.inner;else{let m={from:c,to:d,direction:f,inner:[]};u.push(m),u=m.inner}}}}),r}var hp=$.define();function fp(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(hp)){let o=s(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}var Ir=$.define(),zt=class n{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new n(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toA<i.fromA)break;i=i.join(r),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let r=0,s=0,o=0;;){let l=r<e.length?e[r].fromB:1e9,a=s<t.length?t[s]:1e9,c=Math.min(l,a);if(c==1e9)break;let d=c+o,u=c,h=d;for(;;)if(s<t.length&&t[s]<=u){let f=t[s+1];s+=2,u=Math.max(u,f);for(let p=r;p<e.length&&e[p].fromB<=u;p++)o=e[p].toA-e[p].toB;h=Math.max(h,f+o)}else if(r<e.length&&e[r].fromB<=u){let f=e[r++];u=Math.max(u,f.toB),h=Math.max(h,f.toA),o=f.toA-f.toB}else break;i.push(new n(d,h,c,u))}return i}},So=class n{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=it.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new zt(s,o,l,a))),this.changedRanges=r}static create(e,t,i){return new n(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},Kw=[],Ae=class{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Kw}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&Rw(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let r of this.children){if(r==e)return i;i+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=Fn(this.dom),r=this.length?e>0:t>0;return new rn(this.parent.dom,i+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Yi)return e;return null}static get(e){return e.cmTile}},Ji=class extends Ae{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,r,s=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,r=i?i.nextSibling:t.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==t)for(;r&&r!=l.dom;)r=pf(r);else t.insertBefore(l.dom,r);i=l.dom}for(r=i?i.nextSibling:t.firstChild,s&&r&&(s.written=!0);r;)r=pf(r);this.length=o}};function pf(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Yi=class extends Ji{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Ae.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,r=0,s=0;;)if(r==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&s++,r=t.pop()}else{let o=i.children[r++];if(o instanceof vn)t.push(r),i=o,r=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,t){let i,r=-1,s,o=-1;if(this.blockTiles((l,a)=>{let c=a+l.length;if(e>=a&&e<=c){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(a<e||e==c&&(t<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,r=e-a),(c>e||e==a&&(t>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!i&&!s)throw new Error("No tile at position "+e);return i&&t<0||!s?{tile:i,offset:r}:{tile:s,offset:o}}},vn=class n extends Ji{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new n(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}},Zi=class n extends Ji{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let r=new n(t||document.createElement("div"),e);return(!t||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,i){let r=null,s=-1,o=null,l=-1;function a(d,u){for(let h=0,f=0;h<d.children.length&&f<=u;h++){let p=d.children[h],m=f+p.length;m>=u&&(p.isComposite()?a(p,u-f):(!o||o.isHidden&&(t>0&&!(o.flags&32)||i&&qw(o,p)))&&(m>u||p.flags&32&&t<=1)?(o=p,l=u-f):(f<u||p.flags&16&&!p.isHidden&&t>=-1)&&(r=p,s=u-f)),f=m}}a(this,e);let c=(t<0?r:o)||r||o;return c?{tile:c,offset:c==r?s:l}:null}coordsIn(e,t,i){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,i):Gw(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:r,offset:s}=i;if(this.dom.contains(r.dom))return r.isText()?new rn(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:t);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new rn(a.dom,0);a==i.tile&&(l=!0)}}return new rn(this.dom,0)}};function Gw(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=Hr(e);return t[t.length-1]||null}function qw(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.top<t.bottom}var ft=class n extends Ji{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new n(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}},ui=class n extends Ae{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,i){let r=this.dom.nodeValue.length;e>r&&(e=r);let s=e,o=e,l=0;e==0&&t<0||e==r&&t>=0?N.chrome||N.gecko||(e?(s--,l=1):o<r&&(o++,l=-1)):t<0?s--:o<r&&o++;let a=Jr(this.dom,s,o).getClientRects();if(!a.length)return null;let c=a[(l?l<0:t>=0)?0:a.length-1];return N.safari&&!l&&c.width==0&&(c=Array.prototype.find.call(a,d=>d.width)||c),i==null?c:Xr(c,(l?l>0:t<0)==i)}static of(e,t){let i=new n(t||document.createTextNode(e),e);return t||(i.flags|=2),i}},mi=class n extends Ae{constructor(e,t,i,r){super(e,t,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(i)return Xr(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top<o.bottom);a+=l?-1:1);return Xr(o,!l)}}get overrideDOMText(){if(!this.length)return ne.empty;let{root:e}=this;if(!e)return ne.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,r,s){return s||(s=e.toDOM(t),e.editable||(s.contentEditable="false")),new n(s,i,e,r)}},Qi=class extends Ae{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return ne.empty}coordsIn(e,t,i){let r=this.dom.getBoundingClientRect();return i==null?r:Xr(r,t>0==i)}},Ka=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(s==r.children.length){if(!e&&!l.length)break;i&&i.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let a=r.children[s],c=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!i||i.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!c,s++,e-=a.length):(l.push({tile:r,index:s}),r=a,s=0,i&&a.isComposite()&&i.enter(a))}else{let a=r.length;if(s<a&&e){let c=Math.min(e,a-s);i&&i.skip(r,s,s+c),e-=c,s+=c}if(s==a)o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++;else if(!e)break}return this.tile=r,this.index=s,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},Ga=class{constructor(e,t,i,r){this.from=e,this.to=t,this.wrapper=i,this.rank=r}},qa=class{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,r){var s;this.flushBuffer();let o=this.ensureMarks(t,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new ui(l.dom,l.text+e);a.parent=o}else o.append(r||ui.of(e,(s=this.cache.find(ui))===null||s===void 0?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?Da(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=i;for(let l=t.marks.length-1;l>=0;l--){let a=t.marks[l],c=r.lastChild;if(c instanceof ft&&c.mark.eq(a.mark))c.dom!=a.dom&&c.setDOM(Da(a.dom)),r=c;else{let{dom:d}=a;this.cache.reused.get(a)&&Ae.get(a.dom)&&(d=Da(a.dom));let u=ft.of(a.mark,d);r.append(u),r=u}this.cache.reused.set(a,2)}let s=Ae.get(e.text);s&&this.cache.reused.set(s,2);let o=new ui(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,r.append(o)}addInlineWidget(e,t,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(t,i);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=pp);let r=Zi.start(e,t||((i=this.cache.find(Zi))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(t>0&&(l=r.lastChild)&&l instanceof ft&&l.mark.eq(o))r=l,t--;else{let a=ft.of(o,(i=this.cache.find(ft,c=>c.mark.eq(o)))===null||i===void 0?void 0:i.dom);r.append(a),r=a,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!mf(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(N.ios&&mf(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Oa,0,32)||new mi(Oa.toDOM(),0,Oa,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,i=new Ga(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-i.rank||this.wrappers[r-1].to-i.to)<0;)r--;this.wrappers.splice(r,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let r=t.lastChild;if(i.from<this.pos&&r instanceof vn&&r.wrapper.eq(i.wrapper))t=r;else{let s=vn.of(i.wrapper,(e=this.cache.find(vn,o=>o.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Qi,void 0,1);return i&&(i.flags=t),i||new Qi(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},Xa=class{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}},Co=[mi,Zi,ui,ft,Qi,vn,Yi];for(let n=0;n<Co.length;n++)Co[n].bucket=n;var Ja=class{constructor(e){this.view=e,this.buckets=Co.map(()=>[]),this.index=Co.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let r=e.bucket,s=this.buckets[r],o=this.index[r];for(let l=0;l<s.length;l++){let a=(l+o)%s.length,c=s[a];if((!t||t(c))&&!this.reused.has(c))return s.splice(a,1),a<o&&this.index[r]--,this.reused.set(c,i),c}return null}findWidget(e,t,i){let r=this.buckets[0];if(r.length)for(let s=0,o=0;;s++){if(s==r.length){if(o)return null;o=1,s=0}let l=r[s];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view,l.widget)))return r.splice(s,1),s<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new mi(l.dom,t,e,l.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},Ya=class{constructor(e,t,i,r,s){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new Ja(e),this.text=new Xa(e.state.doc),this.builder=new qa(this.cache,new Yi(e,e.contentDOM),he.iter(i)),this.cache.reused.set(t,2),this.old=new Ka(t),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let r=0,s=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>r){let c=a-r;this.preserve(c,!o,!l),r=a,s+=c}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(s,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(s,l.toB)),s=l.toB,r=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let r=Yw(this.old),s=this.openMarks;this.old.advance(e,i?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let c=a>0||l<o.length?mi.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);c.flags&256?(c.flags&=-2,this.builder.addBlockWidget(c)):(this.builder.ensureLine(null),this.builder.addInlineWidget(c,r,s),s=r.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,r,s,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),r,s)),s=r.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Qi)this.cache.add(o);else if(o instanceof ft)this.builder.ensureLine(null),this.builder.addMark(o,r,s),this.cache.reused.set(o,1),s=r.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof ft&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof ft&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,r=this.builder,s=-1,o=he.spans(this.decorations,e,t,{point:(l,a,c,d,u,h)=>{if(c instanceof fi){if(this.disallowBlockEffectsFor[h]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=d.length,u>d.length)r.continueWidget(a-l);else{let f=c.widget||(c.block?zn.block:zn.inline),p=Xw(c),m=this.cache.findWidget(f,a-l,p)||mi.of(f,this.view,a-l,p);c.block?(c.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(m)):(r.ensureLine(i),r.addInlineWidget(m,d,u))}i=null}else i=Jw(i,c);a>l&&this.text.skip(a-l)},span:(l,a,c,d)=>{for(let u=l;u<a;){let h=this.text.next(Math.min(512,a-u));h==null?(r.addLineStartIfNotCovered(i),r.addBreak(),u++):(r.ensureLine(i),r.addText(h,c,u==l?d:c.length),u+=h.length),i=null}s=c.length}});s>-1&&(this.openWidget=o>s),this.openWidget||r.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let r=e.parentNode;;r=r.parentNode){let s=Ae.get(r);if(r==this.view.contentDOM)break;s instanceof ft?t.push(s):s?.isLine()?i=s:s instanceof vn||(r.nodeName=="DIV"&&!i?i=new Zi(r,pp):i||t.push(ft.of(new Kr({tagName:r.nodeName.toLowerCase(),attributes:Lw(r)}),r)))}return i?{line:i,marks:t}:null}};function mf(n,e){let t=i=>{for(let r of i.children)if((e?r.isText():r.length)||t(r))return!0;return!1};return t(n)}function Xw(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}var pp={class:"cm-line"};function Jw(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&Ac(t,n),i&&(n.class+=" "+i)),n}function Yw(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof ft&&e.push(i.mark)}return e}function Da(n){let e=Ae.get(n);return e&&e.setDOM(n.cloneNode()),n}var zn=class extends Hn{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};zn.inline=new zn("span");zn.block=new zn("div");var Oa=new class extends Hn{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},To=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=be.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Yi(e,e.contentDOM),this.updateInner([new zt(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:d,toA:u})=>u<this.minWidthFrom||d>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!sy(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?Qw(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:d,to:u}=this.hasComposition;i=new zt(d,u,e.changes.mapPos(d,-1),e.changes.mapPos(u,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(N.ie||N.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=ny(o,this.decorations,e.changes);a.length&&(i=zt.extendWithRanges(i,a));let c=iy(l,this.blockWrappers,e.changes);return c.length&&(i=zt.extendWithRanges(i,c)),s&&!i.some(d=>d.fromA<=s.range.fromA&&d.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new Ya(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Ae.get(t.text)&&l.cache.reused.set(Ae.get(t.text),2),this.tile=l.run(e,t),Za(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=N.chrome||N.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof Vr&&r.push(s.dom);i.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(ap)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,r=this.view.root.activeElement,s=r==i,o=!s&&!(this.view.state.facet(xn)||i.tabIndex>-1)&&_r(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(s||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,c,d;if(a.empty?d=c=this.inlineDOMNearPos(a.anchor,a.assoc||1):(d=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),c=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),N.gecko&&a.empty&&!this.hasComposition&&Zw(c)){let h=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(h,c.node.childNodes[c.offset]||null)),c=d=new rn(h,0),l=!0}let u=this.view.observer.selectionRange;(l||!u.focusNode||(!Fr(c.node,c.offset,u.anchorNode,u.anchorOffset)||!Fr(d.node,d.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,a))&&(this.view.observer.ignore(()=>{N.android&&N.chrome&&i.contains(u.focusNode)&&ry(u.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let h=qr(this.view.root);if(h)if(a.empty){if(N.gecko){let f=ey(c.node,c.offset);if(f&&f!=3){let p=(f==1?Kf:Gf)(c.node,c.offset);p&&(c=new rn(p.node,p.offset))}}h.collapse(c.node,c.offset),a.bidiLevel!=null&&h.caretBidiLevel!==void 0&&(h.caretBidiLevel=a.bidiLevel)}else if(h.extend){h.collapse(c.node,c.offset);try{h.extend(d.node,d.offset)}catch{}}else{let f=document.createRange();a.anchor>a.head&&([c,d]=[d,c]),f.setEnd(d.node,d.offset),f.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(f)}o&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,d)),this.impreciseAnchor=c.precise?null:new rn(u.anchorNode,u.anchorOffset),this.impreciseHead=d.precise?null:new rn(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Fr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=qr(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!a||!c||a.bottom>c.top)return;let d=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(d.node,d.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&i.collapse(r,s)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let s;if(e==i.dom)s=i.dom.childNodes[t];else{let o=kn(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==i.dom.firstChild)return r;for(;s&&!Ae.get(s);)s=s.nextSibling;if(!s)return r+i.length;for(let o=0,l=r;;o++){let a=i.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?r+t:r+(t?i.length:0):r}domAtPos(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(r,t):i.domIn(r,t)}inlineDOMNearPos(e,t){let i,r=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((c,d)=>{if(c.isWidget()){if(c.flags&32&&d>=e)return!0;c.flags&16&&(s=!0)}else{let u=d+c.length;if(d<=e&&(i=c,r=e-d,s=u<e),u>=e&&!o&&(o=c,l=e-d,a=d>e),d>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(s&&o?i=null:a&&i&&(o=null),i&&t<0||!o?i.domIn(r,t):o.domIn(l,t))}coordsAt(e,t,i){let{tile:r,offset:s}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof Vr?null:r.coordsInWidget(s,t,!0):r.coordsIn(s,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=r(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&o<s.length){let l=$e(s.text,o);if(l==o)return null;let a=Jr(s.dom,o,l).getClientRects();for(let c=0;c<a.length;c++){let d=a[c];if(c==a.length-1||d.top<d.bottom&&d.left<d.right)return d}}return null}return r(t,i)}measureVisibleLineHeights(e){let t=[],{from:i,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==we.LTR,c=0,d=(u,h,f)=>{for(let p=0;p<u.children.length&&!(h>r);p++){let m=u.children[p],w=h+m.length,b=m.dom.getBoundingClientRect(),{height:k}=b;if(f&&!p&&(c+=b.top-f.top),m instanceof vn)w>i&&d(m,h,b);else if(h>=i&&(c>0&&t.push(-c),t.push(k+c),c=0,o)){let C=m.dom.lastChild,P=C?Hr(C):[];if(P.length){let S=P[P.length-1],x=a?S.right-b.left:b.right-S.left;x>l&&(l=x,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=w)}}f&&p==u.children.length-1&&(c+=f.bottom-b.bottom),h=w+m.breakAfter}};return d(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?we.RTL:we.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let c of o.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let d=Hr(c.dom);if(d.length!=1)return;l+=d[0].width,a=d[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),i,r,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=Hr(t.firstChild)[0];i=t.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(be.replace({widget:new Vr(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return be.set(e)}updateDeco(){let e=1,t=this.view.state.facet(No).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),i=!1,r=this.view.state.facet(Oc).map((s,o)=>{let l=typeof s=="function";return l&&(i=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=i,t.push(he.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(dp).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(lp))try{if(c(this.view,e.range,e))return!0}catch(d){Ft(this.view.state,d,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=fp(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(Pw(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==we.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.visualViewport.offsetTop)){let c=this.view.docView.lineAt(t.head,1);if(c){let d=Vf(c.dom);c.dom.scrollIntoView({block:"nearest"}),$f(d,!1)}}}lineHasWidget(e){let t=i=>i.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Za(this.tile)}};function Za(n,e){let t=e?.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)Za(i,e)}}function Zw(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function mp(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=Kf(t.focusNode,t.focusOffset),r=Gf(t.focusNode,t.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let l=Ae.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(n.docView.lastCompositionAfterCursor){let a=Ae.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(s=r)}}if(n.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function Qw(n,e,t){let i=mp(n,t);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new zt(a.mapPos(s),a.mapPos(o),s,o),text:r}}function ey(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}var ty=class{constructor(){this.changes=[]}compareRange(e,t){qi(e,t,this.changes)}comparePoint(e,t){qi(e,t,this.changes)}boundChange(e){qi(e,e,this.changes)}};function ny(n,e,t){let i=new ty;return he.compare(n,e,t,i),i.changes}var Qa=class{constructor(){this.changes=[]}compareRange(e,t){qi(e,t,this.changes)}comparePoint(){}boundChange(e){qi(e,e,this.changes)}};function iy(n,e,t){let i=new Qa;return he.compare(n,e,t,i),i.changes}function ry(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function sy(n,e){let t=!1;return e&&n.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}var Vr=class extends Hn{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function oy(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return L.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=$e(r.text,s,!1):l=$e(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let c=$e(r.text,o,!1);if(i(r.text.slice(c,o))!=a)break;o=c}for(;l<r.length;){let c=$e(r.text,l);if(i(r.text.slice(l,c))!=a)break;l=c}return L.undirectionalRange(o+r.from,l+r.from)}function ly(n,e,t,i,r){let s=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(n.defaultLineHeight-l)*.5)/l);s+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+tf(o,s,n.state.tabSize)}function ec(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let s of i.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!r||s.type==Ge.Text&&(r.type!=s.type||(t<0?s.from<e:s.to>e)))&&(r=s)}}return r||i}return i}function ay(n,e,t,i){let r=ec(n,e.head,e.assoc||-1),s=!i||r.type!=Ge.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let l=n.dom.getBoundingClientRect(),a=n.textDirectionAt(r.from),c=n.posAtCoords({x:t==(a==we.LTR)?l.right-1:l.left+1,y:(s.top+s.bottom)/2});if(c!=null)return L.cursor(c,t?-1:1)}let o=n.state.doc.lineAt(e.head);return(t?o.to==r.to:o.from==r.from)?n.visualLineSide(o,t):L.cursor(t?r.to:r.from,t?-1:1)}function gf(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let l=e,a=null;;){let c=$w(r,s,o,l,t),d=Zf;if(!c){if(r.number==(t?n.state.doc.lines:1))return l;d=`
724
+ `,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),c=n.visualLineSide(r,!t)}if(a){if(!a(d))return l}else{if(!i)return c;a=i(d)}l=c}}function cy(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==_t.Space&&(r=o),r==o}}function dy(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return L.cursor(r,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),c=n.coordsAtPos(r,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),d=n.documentTop;if(c)o==null&&(o=c.left-a.left),l=s<0?c.top:c.bottom;else{let p=n.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+d}let u=a.left+o,h=n.viewState.heightOracle.textHeight>>1,f=i??h;for(let p=0;;p+=h){let m=l+(f+p)*s,w=tc(n,{x:u,y:m},!1,s);if(t?m>a.bottom:m<a.top)return L.cursor(w.pos,w.assoc);let b=n.coordsAtPos(w.pos,w.assoc),k=b?(b.top+b.bottom)/2:0;if(!b||(t?k>l:k<l))return L.cursor(w.pos,w.assoc,void 0,o)}}function $r(n,e,t){for(;;){let i=0;for(let r of n)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=i||t||(e-s<o-e?-1:1);e=a<0?s:o,i=a}});if(!i)return e}}function gp(n,e){let t=null;for(let i=0;i<e.ranges.length;i++){let r=e.ranges[i],s=null;if(r.empty){let o=$r(n,r.from,0);o!=r.from&&(s=L.cursor(o,-1))}else{let o=$r(n,r.from,-1),l=$r(n,r.to,1);(o!=r.from||l!=r.to)&&(r.undirectional?s=L.undirectionalRange(r.from,r.to):s=L.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(t||(t=e.ranges.slice()),t[i]=s)}return t?L.create(t,e.mainIndex):e}function Pa(n,e,t){let i=$r(n.state.facet(Yr).map(r=>r(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:L.cursor(i,i<t.from?1:-1)}var Et=class{constructor(e,t){this.pos=e,this.assoc=t}};function tc(n,e,t,i){let r=n.contentDOM.getBoundingClientRect(),s=r.top+n.viewState.paddingTop,{x:o,y:l}=e,a=l-s,c;for(;;){if(a<0)return new Et(0,1);if(a>n.viewState.docHeight)return new Et(n.state.doc.length,-1);if(c=n.elementAtHeight(a),i==null)break;if(c.type==Ge.Text){if(i<0?c.to<n.viewport.from:c.from>n.viewport.to)break;let h=n.docView.coordsAt(i<0?c.from:c.to,i>0?-1:1);if(h&&(i<0?h.top<=a+s:h.bottom>=a+s))break}let u=n.viewState.heightOracle.textHeight/2;a=i>0?c.bottom+u:c.top-u}if(n.viewport.from>=c.to||n.viewport.to<=c.from){if(t)return null;if(c.type==Ge.Text){let u=ly(n,r,c,o,l);return new Et(u,u==c.from?1:-1)}}if(c.type!=Ge.Text)return a<(c.top+c.bottom)/2?new Et(c.from,1):new Et(c.to,-1);let d=n.docView.lineAt(c.from,2);return(!d||d.length!=c.length)&&(d=n.docView.lineAt(c.from,-2)),new nc(n,o,l,n.textDirectionAt(c.from)).scanTile(d,c.from)}var nc=class{constructor(e,t,i,r){this.view=e,this.x=t,this.y=i,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:i,spans:r}=this.bidiSpansAt(e);return r[Rt.find(r,e-i.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:i,spans:r}=this.bidiSpansAt(e);return r[Rt.find(r,e-i.from,-1,t)].dir}bidiIn(e,t){let{spans:i,line:r}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from<t)}scan(e,t,i=!1){let r=0,s=e.length-1,o=new Set,l=this.bidiIn(e[0],e[s]),a,c,d=-1,u=1e9,h;e:for(;r<s;){let p=s-r,m=r+s>>1;t:if(o.has(m)){for(let k=1;k<p;k++){let C=m+k;if(C>=s&&(C-=p),!o.has(C)){m=C;break t}}break e}o.add(m);let w=t(m),b=0;if(w)for(let k=0;k<w.length;k++){let C=w[k];if(!(C.width==0&&w.length>1))if(C.bottom<this.y)(!a||a.bottom<C.bottom)&&(a=C),b=1;else if(C.top>this.y)(!c||c.top>C.top)&&(c=C),b=-1;else{let P=C.left>this.x?this.x-C.left:C.right<this.x?this.x-C.right:0,S=Math.abs(P);S<u&&(d=m,u=S,h=C),P&&(b=P<0==(this.baseDir==we.LTR)?-1:1)}}b==-1&&(!l||this.baseDirAt(e[m],1))?s=m:b==1&&(!l||this.baseDirAt(e[m+1],-1))&&(r=m+1)}if(!h){if(!c&&!a)return{i:0,after:!1};let p=a&&(!c||this.y-a.bottom<c.top-this.y)?a:c;return this.y=(p.top+p.bottom)/2,this.scan(e,t,!0)}if(u&&!i){let{top:p,bottom:m}=h;if(a&&a.bottom>(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,t,!0);if(c&&c.top<(p+m+m)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(l?this.dirAt(e[d],1):this.baseDir)==we.LTR;return{i:d,after:this.x>(h.left+h.right)/2==f}}scanText(e,t){let i=[];for(let s=0;s<e.length;s=$e(e.text,s))i.push(t+s);i.push(t+e.length);let r=this.scan(i,s=>{let o=i[s]-t,l=i[s+1]-t;return Jr(e.dom,o,l).getClientRects()});return r.after?new Et(i[r.i+1],-1):new Et(i[r.i],1)}scanTile(e,t){if(!e.length)return new Et(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let i=[t];for(let l=0,a=t;l<e.children.length;l++)i.push(a+=e.children[l].length);let r=this.scan(i,l=>{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Jr(a.dom,0,a.length)).getClientRects()}),s=e.children[r.i],o=i[r.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):r.after?new Et(i[r.i+1],-1):new Et(o,1)}},Ui="\uFFFF",ic=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(Te.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ui}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=Ae.get(r),l=r.nextSibling;if(l==t){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=Ae.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:ko(r))||ko(l)&&(r.nodeName!="BR"||o?.isWidget())&&this.text.length>s)&&!hy(l,t)&&this.lineBreak(),r=l}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=s+o}}readNode(e){let t=Ae.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(uy(e,i.node,i.offset)?t:0))}};function uy(n,e,t){for(;;){if(!e||t<kn(e))return!1;if(e==n)return!0;t=Fn(e)+1,e=e.parentNode}}function hy(n,e){let t;for(;!(n==e||!n);n=n.nextSibling){let i=Ae.get(n);if(!i?.isWidget())return!1;i&&(t||(t=[])).push(i)}if(t)for(let i of t){let r=i.overrideDOMText;if(r?.length)return!1}return!0}var Ao=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},rc=class{constructor(e,t,i,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=bp(e.docView.tile,t,i,0))){let a=s||o?[]:py(e),c=new ic(a,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=my(a,this.bounds.from)}else{let a=e.observer.selectionRange,c=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!za(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),d=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!za(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),u=e.viewport;if((N.ios||N.chrome)&&c!=d&&Math.min(c,d)<=l.main.from&&Math.max(c,d)>=l.main.to&&(u.from>0||u.to<e.state.doc.length)){let h=Math.min(c,d),f=Math.max(c,d),p=u.from-h,m=u.to-f;(p==0||p==1||h==0)&&(m==0||m==-1||f==e.state.doc.length)&&(c=0,d=e.state.doc.length)}if(e.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(L.range(d,c));else if(e.lineWrapping&&d==c&&!(l.main.empty&&l.main.head==c)&&e.inputState.lastTouchTime>Date.now()-100){let h=e.coordsAtPos(c,-1),f=0;h&&(f=e.inputState.lastTouchY<=h.bottom?-1:1),this.newSel=L.create([L.cursor(c,f)])}else this.newSel=L.single(d,c)}}};function bp(n,e,t,i){if(n.isComposite()){let r=-1,s=-1,o=-1,l=-1;for(let a=0,c=i,d=i;a<n.children.length;a++){let u=n.children[a],h=c+u.length;if(c<e&&h>t)return bp(u,e,t,c);if(h>=e&&r==-1&&(r=a,s=c),c>t&&u.dom.parentNode==n.dom){o=a,l=d;break}d=h,c=h+u.breakAfter}return{from:s,to:l<0?i+n.length:l,startDOM:(r?n.children[r-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o<n.children.length&&o>=0?n.children[o].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function wp(n,e){let t,{newSel:i}=e,{state:r}=n,s=r.selection.main,o=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,c=s.from,d=null;(o===8||N.android&&e.text.length<a-l)&&(c=s.to,d="end");let u=r.doc.sliceString(l,a,Ui),h,f;!s.empty&&s.from>=l&&s.to<=a&&(e.typeOver||u!=e.text)&&u.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&u.slice(s.to-l)==e.text.slice(h=e.text.length-(u.length-(s.to-l)))?t={from:s.from,to:s.to,insert:ne.of(e.text.slice(s.from-l,h).split(Ui))}:(f=yp(u,e.text,c-l,d))&&(N.chrome&&o==13&&f.toB==f.from+2&&e.text.slice(f.from,f.toB)==Ui+Ui&&f.toB--,t={from:l+f.from,to:l+f.toA,insert:ne.of(e.text.slice(f.from,f.toB).split(Ui))})}else i&&(!n.hasFocus&&r.facet(xn)||Mo(i,s))&&(i=null);if(!t&&!i)return!1;if((N.mac||N.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=L.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:ne.of([t.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).to<s.to&&n.docView.lineHasWidget(s.to)&&n.inputState.insertingTextAt>Date.now()-50?t={from:s.from,to:s.to,insert:r.toText(n.inputState.insertingText)}:N.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==`
725
+ `&&n.lineWrapping&&(i&&(i=L.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:ne.of([" "])}),t)return Pc(n,t,i,o);if(i&&!Mo(i,s)){let l=!1,a="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(l=!0),a=n.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=gp(r.facet(Yr).map(c=>c(n)),i))),n.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function Pc(n,e,t,i=-1){if(N.ios&&n.inputState.flushIOSKey(e))return!0;let r=n.state.selection.main;if(N.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&n.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Xi(n.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&Xi(n.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&Xi(n.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,l=()=>o||(o=fy(n,e,t));return n.state.facet(ip).some(a=>a(n,e.from,e.to,s,l))||n.dispatch(l()),!0}function fy(n,e,t){let i,r=n.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let a=e.from<s.from?-1:1,c=a<0?s.from:s.to,d=$r(r.facet(Yr).map(u=>u(n)),c,a);e.from==d&&(o=d)}if(o>-1)i={changes:e,selection:L.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let a=s.from<e.from?r.sliceDoc(s.from,e.from):"",c=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(a+e.insert.sliceString(0,void 0,n.state.lineBreak)+c))}else{let a=r.changes(e),c=t&&t.main.to<=a.newLength?t.main:void 0;if(r.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let d=n.state.sliceDoc(e.from,e.to),u,h=t&&mp(n,t.main.head);if(h){let p=e.insert.length-(e.to-e.from);u={from:h.from,to:h.to-p}}else u=n.state.doc.lineAt(s.head);let f=s.to-e.to;i=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:c||p.map(a)};let m=p.to-f,w=m-d.length;if(n.state.sliceDoc(w,m)!=d||m>=u.from&&w<=u.to)return{range:p};let b=r.changes({from:w,to:m,insert:e.insert}),k=p.to-s.to;return{changes:b,range:c?L.range(Math.max(0,c.anchor+k),Math.max(0,c.head+k)):p.map(b)}})}else i={changes:a,selection:c&&r.selection.replaceRange(c)}}let l="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,l+=".compose",n.inputState.compositionFirstChange&&(l+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:l,scrollIntoView:!0})}function yp(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s<r&&n.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&n.length==e.length)return null;let o=n.length,l=e.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o<s&&n.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=t<=s&&t>=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function py(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new Ao(t,i)),(r!=t||s!=i)&&e.push(new Ao(r,s))),e}function my(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?L.single(t+e,i+e):null}function Mo(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}var sc=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,N.safari&&e.contentDOM.addEventListener("input",()=>null),N.gecko&&Ly(e.contentDOM.ownerDocument)}handleEvent(e){!Sy(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=by(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&vp.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),N.android&&N.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(N.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(xp.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||wy.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&N.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&gy(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Xi(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:N.safari&&!N.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function gy(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function bf(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){Ft(t.state,r)}}}function by(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&t(l).handlers.push(bf(i.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(bf(i.value,a))}}for(let i in Vt)t(i).handlers.push(Vt[i]);for(let i in st)t(i).observers.push(st[i]);return e}var xp=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],wy="dthko",vp=[16,17,18,20,91,92,224,225],co=6;function uo(n){return Math.max(0,n)*.7+8}function yy(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var oc=class{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Wf(e.contentDOM),this.atoms=e.state.facet(Yr).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Te.allowMultipleSelections)&&xy(e,t),this.dragging=ky(e,t)&&Cp(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&yy(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=fp(this.view);e.clientX-a.left<=r+co?t=-uo(r-e.clientX):e.clientX+a.right>=o-co&&(t=uo(e.clientX-o)),e.clientY-a.top<=s+co?i=-uo(s-e.clientY):e.clientY+a.bottom>=l-co&&(i=uo(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=gp(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function xy(n,e){let t=n.state.facet(Qf);return t.length?t[0](e):N.mac?e.metaKey:e.ctrlKey}function vy(n,e){let t=n.state.facet(ep);return t.length?t[0](e):N.mac?!e.altKey:!e.ctrlKey}function ky(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=qr(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Sy(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=Ae.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}var Vt=Object.create(null),st=Object.create(null),kp=N.ie&&N.ie_version<15||N.ios&&N.webkit_version<604;function Cy(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),Sp(n,t.value)},50)}function Bo(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function Sp(n,e){e=Bo(n.state,Rc,e);let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(lc!=null&&t.selection.ranges.every(a=>a.empty)&&lc==s.toString()){let a=-1;i=t.changeByRange(c=>{let d=t.doc.lineAt(c.from);if(d.from==a)return{range:c};a=d.from;let u=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:d.from,insert:u},range:L.cursor(c.from+u.length)}})}else o?i=t.changeByRange(a=>{let c=s.line(r++);return{changes:{from:a.from,to:a.to,insert:c.text},range:L.cursor(a.from+c.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}st.scroll=n=>{let e=n.inputState;e.lastScrollTop=n.scrollDOM.scrollTop,e.lastScrollLeft=n.scrollDOM.scrollLeft,N.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};st.wheel=st.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};Vt.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);st.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};st.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};st.touchend=(n,e)=>{n.inputState.touchActive=!1};Vt.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(tp))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=Ay(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new oc(n,e,t,i)),i&&n.observer.ignore(()=>{Uf(n.contentDOM);let s=n.root.activeElement;s&&!s.contains(n.contentDOM)&&s.blur()});let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function wf(n,e,t,i){if(i==1)return L.cursor(e,t);if(i==2)return oy(n.state,e,t);{let r=n.docView.lineAt(e,t),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<n.state.doc.length&&l==s.to&&l++,L.undirectionalRange(o,l)}}var Ty=N.ie&&N.ie_version<=11,yf=null,xf=0,vf=0;function Cp(n){if(!Ty)return n.detail;let e=yf,t=vf;return yf=n,vf=Date.now(),xf=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(xf+1)%3:1}function Ay(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=Cp(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let a=n.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),c,d=wf(n,a.pos,a.assoc,i);if(t.pos!=a.pos&&!o){let u=wf(n,t.pos,t.assoc,i),h=Math.min(u.from,d.from),f=Math.max(u.to,d.to);d=h<d.from?L.range(h,f,d.assoc):L.range(f,h,d.assoc)}return o?r.replaceRange(r.main.extend(d.from,d.to,d.assoc)):l&&i==1&&r.ranges.length>1&&(c=My(r,a.pos))?c:l?r.addRange(d):L.create([d])}}}function My(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:r}=n.ranges[t];if(i<=e&&r>=e)return L.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}Vt.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=L.undirectionalRange(s,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",Bo(n.state,Lc,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Vt.dragend=n=>(n.inputState.draggedContent=null,!1);function kf(n,e,t,i){if(t=Bo(n.state,Rc,t),!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&vy(n,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Vt.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,s=()=>{++r==t.length&&kf(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return kf(n,e,i,!0),!0}return!1};Vt.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=kp?null:e.clipboardData;return t?(Sp(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Cy(n),!1)};function Ey(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function Ry(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:Bo(n,Lc,e.join(n.lineBreak)),ranges:t,linewise:i}}var lc=null;Vt.copy=Vt.cut=(n,e)=>{if(!_r(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:r}=Ry(n.state);if(!t&&!r)return!1;lc=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=kp?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(Ey(n,t),!1)};var Tp=ht.define();function Ap(n,e){let t=[];for(let i of n.facet(rp)){let r=i(n,e);r&&t.push(r)}return t.length?n.update({effects:t,annotations:Tp.of(!0)}):null}function Mp(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=Ap(n.state,e);t?n.dispatch(t):n.update([])}},10)}st.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),Mp(n)};st.blur=n=>{n.observer.clearSelectionRange(),Mp(n)};st.compositionstart=st.compositionupdate=n=>{if(!n.observer.editContext&&(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0)){let{main:e}=n.state.selection;!e.empty&&n.lineBlockAt(e.from).from!=n.lineBlockAt(e.to).from&&n.dispatch({changes:n.state.selection.ranges.filter(t=>!t.empty).map(t=>({from:t.from,to:t.to})),userEvent:"input"}),n.inputState.composing=0}};st.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,N.chrome&&N.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};st.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Vt.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=n.posAtDOM(l.startContainer,l.startOffset),c=n.posAtDOM(l.endContainer,l.endOffset);return Pc(n,{from:a,to:c,insert:n.state.toText(s)},null),!0}}let r;if(N.chrome&&N.android&&(r=xp.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return N.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),N.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>st.compositionend(n,e),20),!1};var Sf=new Set;function Ly(n){Sf.has(n)||(Sf.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var Cf=["pre-wrap","normal","pre-line","break-spaces"],er=!1;function Tf(){er=!1}var ac=class{constructor(e){this.lineWrapping=e,this.doc=ne.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Cf.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,i,r,s,o){let l=Cf.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let c=0;c<o.length;c++){let d=o[c];d<0?c++:this.heightSamples[Math.floor(d*10)]=!0}}return a}},cc=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},Ht=class n{constructor(e,t,i,r,s){this.from=e,this.length=t,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Ge.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof fi?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new n(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ge=(function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n})(ge||(ge={})),go=.001,yt=class n{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>go&&(er=!0),this.height=e)}replace(e,t,i){return n.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:c,fromB:d,toB:u}=r[l],h=s.lineAt(a,ge.ByPosNoHeight,i.setDoc(t),0,0),f=h.to>=c?h:s.lineAt(c,ge.ByPosNoHeight,i,0,0);for(u+=f.to-c,c=f.to;l>0&&h.from<=r[l-1].toA;)a=r[l-1].fromA,d=r[l-1].fromB,l--,a<h.from&&(h=s.lineAt(a,ge.ByPosNoHeight,i,0,0));d+=h.from-a,a=h.from;let p=uc.build(i.setDoc(o),e,d,u);s=Eo(s,s.replace(a,c,p))}return s.updateHeight(i,0)}static empty(){return new Mt(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,r=0,s=0;for(;;)if(t==i)if(r>s*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[t++];l&&(r+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new dc(n.of(e.slice(0,t)),o,n.of(e.slice(i)))}};function Eo(n,e){return n==e?n:(n.constructor!=e.constructor&&(er=!0),e)}yt.prototype.size=1;var Dy=be.replace({}),Ro=class extends yt{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new Ht(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,r){return this.spaceAbove&&e<i+this.spaceAbove?new Ht(r,0,i,this.spaceAbove,Dy):this.mainBlock(i,r)}lineAt(e,t,i,r,s){let o=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,i,r,s).join(o):o}forEachLine(e,t,i,r,s,o){e<=s+this.length&&t>=s&&o(this.lineAt(0,ge.ByPos,i,r,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},Mt=class n extends Ro{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new Ht(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof n||r instanceof _n&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof _n?r=new n(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):yt.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},_n=class n extends yt{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let c=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),d=t.doc.lineAt(c),u=l+d.length*a,h=Math.max(i,e-u/2);return new Ht(d.from,d.length,h,u,0)}else{let c=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:d,length:u}=t.doc.line(s+c);return new Ht(d,u,i+l*c,l,0)}}lineAt(e,t,i,r,s){if(t==ge.ByHeight)return this.blockAt(e,i,r,s);if(t==ge.ByPosNoHeight){let{from:f,to:p}=i.doc.lineAt(e);return new Ht(f,p-f,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,s),c=i.doc.lineAt(e),d=l+c.length*a,u=c.number-o,h=r+l*u+a*(c.from-s-u);return new Ht(c.from,c.length,Math.max(r,Math.min(h,r+this.height-d)),d,0)}forEachLine(e,t,i,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:a,perChar:c}=this.heightMetrics(i,s);for(let d=e,u=r;d<=t;){let h=i.doc.lineAt(d);if(d==e){let p=h.number-l;u+=a*p+c*(e-s-p)}let f=a+c*h.length;o(new Ht(h.from,h.length,u,f,0)),u+=f,d=h.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let s=i[i.length-1];s instanceof n?i[i.length-1]=new n(s.length+r):i.push(null,new n(r-1))}if(e>0){let s=i[0];s instanceof n?i[0]=new n(e+s.length):i.unshift(new n(e-1),null)}return yt.of(i)}decomposeLeft(e,t){t.push(new n(e-1),null)}decomposeRight(e,t){t.push(null,new n(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new n(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let d=e.doc.lineAt(l).length;o.length&&o.push(null);let u=r.heights[r.index++],h=0;u<0&&(h=-u,u=r.heights[r.index++]),a==-1?a=u:Math.abs(u-a)>=go&&(a=-2);let f=new Mt(d,u,h);f.outdated=!1,o.push(f),l+=d+1}l<=s&&o.push(null,new n(s-l).updateHeight(e,l));let c=yt.of(o);return(a<0||Math.abs(c.height-this.height)>=go||Math.abs(a-this.heightMetrics(e,t).perLine)>=go)&&(er=!0),Eo(this,c)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},dc=class extends yt{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,t,i,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,i,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=t==ge.ByHeight?e<o:e<l,c=a?this.left.lineAt(e,t,i,r,s):this.right.lineAt(e,t,i,o,l);if(this.break||(a?c.to<l:c.from>l))return c;let d=t==ge.ByPosNoHeight?ge.ByPosNoHeight:ge.ByPos;return a?c.join(this.right.lineAt(l,d,i,o,l)):this.left.lineAt(l,d,i,r,s).join(c)}forEachLine(e,t,i,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,r,s,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let c=this.lineAt(a,ge.ByPos,i,r,s);e<c.from&&this.left.forEachLine(e,c.from-1,i,r,s,o),c.to>=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,i,l,a,o)}}replace(e,t,i){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&Af(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),Af(s,l)}return yt.of(s)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?yt.of(this.break?[e,null,t]:[e,t]):(this.left=Eo(this.left,e),this.right=Eo(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Af(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof _n&&(i=n[e+1])instanceof _n&&n.splice(e-1,3,new _n(t.length+1+i.length))}var Oy=5,uc=class n{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Mt?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Mt(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new Ro(o,r,i)):(o||s||r>=Oy)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Mt(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new _n(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Mt)return e;let t=new Mt(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Mt)&&!this.isCovered?this.nodes.push(new Mt(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof Mt&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,t,i,r){let s=new n(i,e);return he.spans(t,i,r,s,0),s.finish(i)}};function Py(n,e,t){let i=new hc;return he.compare(n,e,t,i,0),i.changes}var hc=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&qi(e,t,this.changes,5)}};function Iy(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,r=i.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let c=n.parentNode;c&&c!=i.body;)if(c.nodeType==1){let d=c,u=window.getComputedStyle(d);if((d.scrollHeight>d.clientHeight||d.scrollWidth>d.clientWidth)&&u.overflow!="visible"){let h=d.getBoundingClientRect();s=Math.max(s,h.left),o=Math.min(o,h.right),l=Math.max(l,h.top),a=Math.min(c==n.parentNode?r.innerHeight:a,h.bottom)}c=u.position=="absolute"||u.position=="fixed"?d.offsetParent:d.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Ny(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function By(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var Ur=class{constructor(e,t,i,r){this.from=e,this.to=t,this.size=i,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=t[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return be.replace({widget:new fc(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},fc=class extends Hn{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},Lo=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Mf,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=we.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=t.facet(Dc).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new ac(i),this.stateDeco=Ef(t),this.heightMap=yt.empty().applyChanges(this.stateDeco,ne.empty,this.heightOracle.setDoc(t.doc),[new zt(0,0,0,t.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=be.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new Ki(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Mf:new pc(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Nr(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Ef(this.state);let r=e.changedRanges,s=zt.extendWithRanges(r,Py(i,this.stateDeco,e?e.changes:it.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Tf(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||er)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let c=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(op)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?we.RTL:we.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let c=0,d=0;if(l.width&&l.height){let{scaleX:S,scaleY:x}=zf(t,l);(S>.005&&Math.abs(this.scaleX-S)>.005||x>.005&&Math.abs(this.scaleY-x)>.005)&&(this.scaleX=S,this.scaleY=x,c|=16,o=a=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,h=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=h)&&(this.paddingTop=u,this.paddingBottom=h,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=Wf(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=jf(this.scrollParent||e.win);let m=(this.printing?By:Iy)(t,this.paddingTop),w=m.top-this.pixelViewport.top,b=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let k=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(k!=this.inView&&(this.inView=k,k&&(a=!0)),!this.inView&&!this.scrollTarget&&!Ny(e.dom))return 0;let C=l.width;if((this.contentDOMWidth!=C||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),a){let S=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(S)&&(o=!0),o||r.lineWrapping&&Math.abs(C-this.contentDOMWidth)>r.charWidth){let{lineHeight:x,charWidth:T,textHeight:W}=e.docView.measureTextSize();o=x>0&&r.refresh(s,x,T,W,Math.max(5,C/T),S),o&&(e.docView.minWidth=0,c|=16)}w>0&&b>0?d=Math.max(w,b):w<0&&b<0&&(d=Math.min(w,b)),Tf();for(let x of this.viewports){let T=x.from==this.viewport.from?S:e.docView.measureVisibleLineHeights(x);this.heightMap=(o?yt.empty().applyChanges(this.stateDeco,ne.empty,this.heightOracle,[new zt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new cc(x.from,T))}er&&(c|=2)}let P=!this.viewportIsAppropriate(this.viewport,d)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return P&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(d,this.scrollTarget),c|=this.updateForViewport()),(c&2||P)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Ki(r.lineAt(o-i*1e3,ge.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,ge.ByHeight,s,0,0).to);if(t){let{head:c}=t.range;if(c<a.from||c>a.to){let d=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=r.lineAt(c,ge.ByPos,s,0,0),h;t.y=="center"?h=(u.top+u.bottom)/2-d/2:t.y=="start"||t.y=="nearest"&&c<a.from?h=u.top:h=u.bottom-d,a=new Ki(r.lineAt(h-1e3/2,ge.ByHeight,s,0,0).from,r.lineAt(h+d+1e3/2,ge.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new Ki(this.heightMap.lineAt(i,ge.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,ge.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,ge.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,ge.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let r of e)t.touchesRange(r.from,r.to)||i.push(new Ur(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=we.LTR&&!i)return[];let l=[],a=(d,u,h,f)=>{if(u-d<s)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let b of m)if(b>d&&b<u){a(d,b-10,h,f),a(b+10,u,h,f);return}let w=Hy(e,b=>b.from>=h.from&&b.to<=h.to&&Math.abs(b.from-d)<s&&Math.abs(b.to-u)<s&&!m.some(k=>b.from<k&&b.to>k));if(!w){if(u<h.to&&t&&i&&t.visibleRanges.some(C=>C.from<=u&&C.to>=u)){let C=t.moveToLineBoundary(L.cursor(u),!1,!0).head;C>d&&(u=C)}let b=this.gapSize(h,d,u,f),k=i||b<2e6?b:2e6;w=new Ur(d,u,b,k)}l.push(w)},c=d=>{if(d.length<o||d.type!=Ge.Text)return;let u=_y(d.from,d.to,this.stateDeco);if(u.total<o)return;let h=this.scrollTarget?this.scrollTarget.range.head:null,f,p;if(i){let m=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,w,b;if(h!=null){let k=fo(u,h),C=((this.visibleBottom-this.visibleTop)/2+m)/d.height;w=k-C,b=k+C}else w=(this.visibleTop-d.top-m)/d.height,b=(this.visibleBottom-d.top+m)/d.height;f=ho(u,w),p=ho(u,b)}else{let m=u.total*this.heightOracle.charWidth,w=r*this.heightOracle.charWidth,b=0;if(m>2e6)for(let x of e)x.from>=d.from&&x.from<d.to&&x.size!=x.displaySize&&x.from*this.heightOracle.charWidth+b<this.pixelViewport.left&&(b=x.size-x.displaySize);let k=this.pixelViewport.left+b,C=this.pixelViewport.right+b,P,S;if(h!=null){let x=fo(u,h),T=((C-k)/2+w)/m;P=x-T,S=x+T}else P=(k-w)/m,S=(C+w)/m;f=ho(u,P),p=ho(u,S)}f>d.from&&a(d.from,f,d,u),p<d.to&&a(p,d.to,d,u)};for(let d of this.viewportLines)Array.isArray(d.type)?d.type.forEach(c):c(d);return l}gapSize(e,t,i,r){let s=fo(r,i)-fo(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){Ur.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=be.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];he.spans(t,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s<i.length&&!(r&8);s++){let o=this.visibleRanges[s],l=i[s];(o.from!=l.from||o.to!=l.to)&&(r|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(r|=8))}return this.visibleRanges=i,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Nr(this.heightMap.lineAt(e,ge.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Nr(this.heightMap.lineAt(this.scaler.fromDOM(e),ge.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Nr(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Ki=class{constructor(e,t){this.from=e,this.to=t}};function _y(n,e,t){let i=[],r=n,s=0;return he.spans(t,n,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function ho({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function fo(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function Hy(n,e){for(let t of n)if(e(t))return t}var Mf={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function Ef(n){let e=n.facet(No).filter(i=>typeof i!="function"),t=n.facet(Oc).filter(i=>typeof i!="function");return t.length&&e.push(he.join(t)),e}var pc=class n{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let c=t.lineAt(l,ge.ByPos,e,0,0).top,d=t.lineAt(a,ge.ByPos,e,0,0).bottom;return r+=d-c,{from:l,to:a,top:c,bottom:d,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}eq(e){return e instanceof n?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}};function Nr(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new Ht(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>Nr(r,e)):n._content)}var po=$.define({combine:n=>n.join(" ")}),mc=$.define({combine:n=>n.indexOf(!0)>-1}),gc=At.newName(),Ep=At.newName(),Rp=At.newName(),Lp={"&light":"."+Ep,"&dark":"."+Rp};function bc(n,e,t){return new At(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}var Fy=bc("."+gc,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Lp),zy={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ia=N.ie&&N.ie_version<=11,wc=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Wa,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(N.ie&&N.ie_version<=11||N.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&N.android&&e.constructor.EDIT_CONTEXT!==!1&&!(N.chrome&&N.chrome_version<126)&&(this.editContext=new yc(e),e.state.facet(xn)&&(e.contentDOM.editContext=this.editContext.editContext)),Ia&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(xn)?i.root.activeElement!=this.dom:!_r(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(N.ie&&N.ie_version<=11||N.android&&N.chrome)&&!i.state.selection.main.empty&&r.focusNode&&Fr(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=qr(e.root);if(!t)return!1;let i=N.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Wy(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let r=_r(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Nw(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,zy),Ia&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ia&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Xi(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&_r(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new rc(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=wp(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!Mo(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=Rf(t,e.previousSibling||e.target.previousSibling,-1),r=Rf(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(xn)!=e.state.facet(xn)&&(e.view.contentDOM.editContext=e.state.facet(xn)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function Rf(n,e,t){for(;e;){let i=Ae.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Lf(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return Fr(o.node,o.offset,r,s)&&([t,i,r,s]=[r,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}}function Wy(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return Lf(n,r)}let t=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?Lf(n,t):null}var yc=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let c=a-l>i.text.length;l==this.from&&s<this.from?l=s:a==this.to&&s>this.to&&(a=s);let d=yp(e.state.sliceDoc(l,a),i.text,(c?r.from:r.to)-l,c?"end":null);if(!d){let h=L.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Mo(h,r)||e.dispatch({selection:h,userEvent:"select"});return}let u={from:d.from+l,to:d.toA+l,insert:ne.of(i.text.slice(d.from,d.toB).split(`
726
+ `))};if((N.mac||N.android)&&u.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:l,to:a,insert:ne.of([i.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let h=this.to-this.from+(u.to-u.from+u.insert.length);Pc(e,u,L.single(this.toEditorPos(i.selectionStart,h),this.toEditorPos(i.selectionEnd,h)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=e.coordsForChar(o);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,r.push(s)}t.updateCharacterBounds(i.rangeStart,r)},this.handlers.textformatupdate=i=>{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);if(a<c){let d=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;r.push(be.mark({attributes:{style:d}}).range(a,c))}}}e.dispatch({effects:ap.of(be.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let r=qr(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,c)=>{if(i)return;let d=c.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=d,this.to+=d;return}else r=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=d,this.to+=d;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+c.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),c.toString()),this.to+=d}t+=d}),r&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},j=class n{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Iw(e.parent)||document,this.viewState=new Lo(this,e.state||Te.create(e)),e.scrollTo&&e.scrollTo.is(ao)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ji).map(r=>new Wr(r));for(let r of this.plugins)r.update(this);this.observer=new wc(this),this.inputState=new sc(this),this.inputState.ensureHandlers(this.plugins),this.docView=new To(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Be?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,s=this.state;for(let h of e){if(h.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=h.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(h=>h.annotation(Tp))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Ap(s,o),a||(l=1));let c=this.observer.delayedAndroidKey,d=null;if(c?(this.observer.clearDelayedAndroidKey(),d=this.observer.readChange(),(d&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(d=null)):this.observer.clear(),s.facet(Te.phrases)!=this.state.facet(Te.phrases))return this.setState(s);r=So.create(this,s,e),r.flags|=l;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let h of e){if(u&&(u=u.map(h.changes)),h.scrollIntoView){let{main:f}=h.state.selection,{x:p,y:m}=this.state.facet(n.cursorScrollMargin);u=new zr(f.empty?f:L.cursor(f.head,f.head>f.anchor?-1:1),"nearest","nearest",m,p)}for(let f of h.effects)f.is(ao)&&(u=f.value.clip(this.state))}this.viewState.update(r,u),this.bidiCache=Do.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(Ir)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(po)!=r.state.facet(po)&&(this.viewState.mustMeasureContent=!0),(t||i||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let h of this.state.facet(ja))try{h(r)}catch(f){Ft(this.state,f,"update listener")}(a||d)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),d&&!wp(this,d)&&c.force&&Xi(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Lo(this,e),this.plugins=e.facet(ji).map(i=>new Wr(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new To(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(ji),i=e.state.facet(ji);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new Wr(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){Ft(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0){if(jf(i||this.win))s=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,o=p.top}l=this.viewState.scaleY}this.updateState=1;let c=this.viewState.measure();if(!c&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let d=[];c&4||([this.measureRequests,d]=[d,this.measureRequests]);let u=d.map(p=>{try{return p.read(this)}catch(m){return Ft(this.state,m),Df}}),h=So.create(this,this.state,[]),f=!1;h.flags|=c,t?t.flags|=c:t=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),f=this.docView.update(h),f&&this.docViewUpdate());for(let p=0;p<d.length;p++)if(u[p]!=Df)try{let m=d[p];m.write&&m.write(u[p],this)}catch(m){Ft(this.state,m)}if(f&&this.docView.updateSelection(!0),!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let m=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)/this.viewState.scaleY-o/l;if((m>1||m<-1)&&!(N.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+m,i?s<0?i.scrollTop=i.scrollHeight:i.scrollTop+=m:this.win.scrollBy(0,m),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(ja))a(t)}get themeClasses(){return gc+" "+(this.state.facet(mc)?Rp:Ep)+" "+this.state.facet(po)}updateAttrs(){let e=Of(this,cp,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(xn)?"true":"false",class:"cm-content",style:`${N.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Of(this,Dc,t);let i=this.observer.ignore(()=>{let r=df(this.contentDOM,this.contentAttrs,t),s=df(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(n.announce)){t&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent="\xA0"},200),t=!1);let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Ir);let e=this.state.facet(n.cspNonce);At.mount(this.root,this.styleModules.concat(Fy).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return Pa(this,e,gf(this,e,t,i))}moveByGroup(e,t){return Pa(this,e,gf(this,e,t,i=>cy(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return L.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return ay(this,e,t,i)}moveVertically(e,t,i){return Pa(this,e,dy(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=tc(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),tc(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),r=this.bidiSpans(i),s=r[Rt.find(r,e-i.from,-1,t)];return this.docView.coordsAt(e,t,s.dir==we.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(sp)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Vy)return Yf(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Jf(s.isolates,i=ff(this,e))))return s.order;i||(i=ff(this,e));let r=Vw(e.text,t,i);return this.bidiCache.push(new Do(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||N.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Uf(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,r,s,o;return ao.of(new zr(typeof e=="number"?L.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(r=t.x)!==null&&r!==void 0?r:"nearest",(s=t.yMargin)!==null&&s!==void 0?s:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return ao.of(new zr(L.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Wt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Wt.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=At.newName(),r=[po.of(i),Ir.of(bc(`.${i}`,e))];return t&&t.dark&&r.push(mc.of(!0)),r}static baseTheme(e){return Pr.lowest(Ir.of(bc("."+gc,e,Lp)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&Ae.get(i)||Ae.get(e);return((t=r?.root)===null||t===void 0?void 0:t.view)||null}};j.styleModule=Ir;j.inputHandler=ip;j.clipboardInputFilter=Rc;j.clipboardOutputFilter=Lc;j.scrollHandler=lp;j.focusChangeEffect=rp;j.perLineTextDirection=sp;j.exceptionSink=np;j.updateListener=ja;j.editable=xn;j.mouseSelectionStyle=tp;j.dragMovesSelection=ep;j.clickAddsSelectionRange=Qf;j.decorations=No;j.blockWrappers=dp;j.outerDecorations=Oc;j.atomicRanges=Yr;j.bidiIsolatedRanges=up;j.cursorScrollMargin=$.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});j.scrollMargins=hp;j.darkTheme=mc;j.cspNonce=$.define({combine:n=>n.length?n[0]:""});j.contentAttributes=Dc;j.editorAttributes=cp;j.lineWrapping=j.contentAttributes.of({class:"cm-lineWrapping"});j.announce=ke.define();var Vy=4096,Df={},Do=class n{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:we.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&i.push(new n(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}};function Of(n,e,t){for(let i=n.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&Ac(o,t)}return t}var $y=N.mac?"mac":N.windows?"win":N.linux?"linux":"key";function Uy(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let a=0;a<t.length-1;++a){let c=t[a];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function mo(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}var jy=Pr.default(j.domEventHandlers({keydown(n,e){return Xy(Ky(e.state),n,e,"editor")}})),Ic=$.define({enables:jy}),Pf=new WeakMap;function Ky(n){let e=n.facet(Ic),t=Pf.get(e);return t||Pf.set(e,t=qy(e.reduce((i,r)=>i.concat(r),[]))),t}var Bn=null,Gy=4e3;function qy(n,e=$y){let t=Object.create(null),i=Object.create(null),r=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,c,d)=>{var u,h;let f=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(b=>Uy(b,e));for(let b=1;b<p.length;b++){let k=p.slice(0,b).join(" ");r(k,!0),f[k]||(f[k]={preventDefault:!0,stopPropagation:!1,run:[C=>{let P=Bn={view:C,prefix:k,scope:o};return setTimeout(()=>{Bn==P&&(Bn=null)},Gy),!0}]})}let m=p.join(" ");r(m,!1);let w=f[m]||(f[m]={preventDefault:!1,stopPropagation:!1,run:((h=(u=f._any)===null||u===void 0?void 0:u.run)===null||h===void 0?void 0:h.slice())||[]});a&&w.run.push(a),c&&(w.preventDefault=!0),d&&(w.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of l){let d=t[c]||(t[c]=Object.create(null));d._any||(d._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=o;for(let h in d)d[h].run.push(f=>u(f,xc))}let a=o[e]||o.key;if(a)for(let c of l)s(c,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}var xc=null;function Xy(n,e,t,i){xc=e;let r=of(e),s=$h(r,0),o=Uh(s)==r.length&&r!=" ",l="",a=!1,c=!1,d=!1;Bn&&Bn.view==t&&Bn.scope==i&&(l=Bn.prefix+" ",vp.indexOf(e.keyCode)<0&&(c=!0,Bn=null));let u=new Set,h=w=>{if(w){for(let b of w.run)if(!u.has(b)&&(u.add(b),b(t)))return w.stopPropagation&&(d=!0),!0;w.preventDefault&&(w.stopPropagation&&(d=!0),c=!0)}return!1},f=n[i],p,m;return f&&(h(f[l+mo(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(N.windows&&e.ctrlKey&&e.altKey)&&!(N.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=yn[e.keyCode])&&p!=r?(h(f[l+mo(p,e,!0)])||e.shiftKey&&(m=$i[e.keyCode])!=r&&m!=p&&h(f[l+mo(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&h(f[l+mo(r,e,!0)])&&(a=!0),!a&&h(f._any)&&(a=!0)),c&&(a=!0),a&&d&&e.stopPropagation(),xc=null,a}var hi=class n{constructor(e,t,i,r,s){this.className=e,this.left=t,this.top=i,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let r=e.coordsAtPos(i.head,i.assoc||1);if(!r)return[];let s=Dp(e);return[new n(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return Jy(e,t,i)}};function Dp(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==we.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function If(n,e,t,i){let r=n.coordsAtPos(e,t*2);if(!r)return i;let s=n.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=n.posAtCoords({x:s.left+1,y:o}),a=n.posAtCoords({x:s.right-1,y:o});return l==null||a==null?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}function Jy(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),r=Math.min(t.to,n.viewport.to),s=n.textDirection==we.LTR,o=n.contentDOM,l=o.getBoundingClientRect(),a=Dp(n),c=o.querySelector(".cm-line"),d=c&&window.getComputedStyle(c),u=l.left+(d?parseInt(d.paddingLeft)+Math.min(0,parseInt(d.textIndent)):0),h=l.right-(d?parseInt(d.paddingRight):0),f=ec(n,i,1),p=ec(n,r,-1),m=f.type==Ge.Text?f:null,w=p.type==Ge.Text?p:null;if(m&&(n.lineWrapping||f.widgetLineBreaks)&&(m=If(n,i,1,m)),w&&(n.lineWrapping||p.widgetLineBreaks)&&(w=If(n,r,-1,w)),m&&w&&m.from==w.from&&m.to==w.to)return k(C(t.from,t.to,m));{let S=m?C(t.from,null,m):P(f,!1),x=w?C(null,t.to,w):P(p,!0),T=[];return(m||f).to<(w||p).from-(m&&w?1:0)||f.widgetLineBreaks>1&&S.bottom+n.defaultLineHeight/2<x.top?T.push(b(u,S.bottom,h,x.top)):S.bottom<x.top&&n.elementAtHeight((S.bottom+x.top)/2).type==Ge.Text&&(S.bottom=x.top=(S.bottom+x.top)/2),k(S).concat(T).concat(k(x))}function b(S,x,T,W){return new hi(e,S-a.left,x-a.top,Math.max(0,T-S),W-x)}function k({top:S,bottom:x,horizontal:T}){let W=[];for(let H=0;H<T.length;H+=2)W.push(b(T[H],S,T[H+1],x));return W}function C(S,x,T){let W=1e9,H=-1e9,z=[];function D(M,K,X,ye,et){let Ce=n.coordsAtPos(M,M==T.to?-2:2),je=n.coordsAtPos(X,X==T.from?2:-2);!Ce||!je||(W=Math.min(Ce.top,je.top,W),H=Math.max(Ce.bottom,je.bottom,H),et==we.LTR?z.push(s&&K?u:Ce.left,s&&ye?h:je.right):z.push(!s&&ye?u:je.left,!s&&K?h:Ce.right))}let R=S??T.from,F=x??T.to;for(let M of n.visibleRanges)if(M.to>R&&M.from<F)for(let K=Math.max(M.from,R),X=Math.min(M.to,F);;){let ye=n.state.doc.lineAt(K);for(let et of n.bidiSpans(ye)){let Ce=et.from+ye.from,je=et.to+ye.from;if(Ce>=X)break;je>K&&D(Math.max(Ce,K),S==null&&Ce<=R,Math.min(je,X),x==null&&je>=F,et.dir)}if(K=ye.to+1,K>=X)break}return z.length==0&&D(R,S==null,F,x==null,n.textDirection),{top:W,bottom:H,horizontal:z}}function P(S,x){let T=l.top+(x?S.top:S.bottom);return{top:T,bottom:T,horizontal:[]}}}function Yy(n,e){return n.constructor==e.constructor&&n.eq(e)}var vc=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(bo)!=e.state.facet(bo)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(bo);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!Yy(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[i].constructor&&r.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e,N.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},bo=$.define();function Op(n){return[Wt.define(e=>new vc(e,n)),bo.of(n)]}var tr=$.define({combine(n){return Vi(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Pp(n={}){return[tr.of(n),Zy,Qy,tx,op.of(!0)]}function Ip(n){return n.startState.facet(tr)!=n.state.facet(tr)}var Zy=Op({above:!0,markers(n){let{state:e}=n,t=e.facet(tr),i=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty||t.drawRangeCursor&&!(s&&N.ios&&t.iosSelectionHandles)){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=r.empty?r:L.cursor(r.head,r.assoc);for(let a of hi.forRange(n,o,l))i.push(a)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Ip(n);return t&&Nf(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){Nf(e.state,n)},class:"cm-cursorLayer"});function Nf(n,e){e.style.animationDuration=n.facet(tr).cursorBlinkRate+"ms"}var Qy=Op({above:!1,markers(n){let e=[],{main:t,ranges:i}=n.state.selection;for(let r of i)if(!r.empty)for(let s of hi.forRange(n,"cm-selectionBackground",r))e.push(s);if(N.ios&&!t.empty&&n.state.facet(tr).iosSelectionHandles){for(let r of hi.forRange(n,"cm-selectionHandle cm-selectionHandle-start",L.cursor(t.from,1)))e.push(r);for(let r of hi.forRange(n,"cm-selectionHandle cm-selectionHandle-end",L.cursor(t.to,1)))e.push(r)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||Ip(n)},class:"cm-selectionLayer"}),ex=N.gecko&&N.gecko_version==153?"#ffffff01":"transparent",tx=Pr.highest(j.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${ex} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Np=ke.define({map(n,e){return n==null?null:e.mapPos(n)}}),Br=Tt.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(Np)?i.value:t,n)}}),nx=Wt.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(Br);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(Br)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(Br),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(Br)!=n&&this.view.dispatch({effects:Np.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Bp(){return[Br,nx]}var gS=/x/.unicode!=null?"gu":"g";function _p(){return rx}var ix=be.line({class:"cm-activeLine"}),rx=Wt.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let r=n.lineBlockAt(i.head);r.from>e&&(t.push(ix.range(r.from)),e=r.from)}return be.set(t)}},{decorations:n=>n.decorations}),kc=class extends Hn{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?Hr(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),r=Xr(t[0],i.direction!="rtl"),s=parseInt(i.lineHeight);return r.bottom-r.top>s*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+s}:r}ignoreEvent(){return!1}};function Nc(n){let e=Wt.fromClass(class{constructor(t){this.view=t,this.placeholder=n?be.set([be.widget({widget:new kc(n),side:1}).range(0)]):be.none}get decorations(){return this.view.state.doc.length?be.none:this.placeholder}},{decorations:t=>t.decorations});return typeof n=="string"?[e,j.contentAttributes.of({"aria-placeholder":n})]:e}var $t=class extends tn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};$t.prototype.elementClass="";$t.prototype.toDOM=void 0;$t.prototype.mapMode=ut.TrackBefore;$t.prototype.startSide=$t.prototype.endSide=-1;$t.prototype.point=!0;var wo=$.define(),sx=$.define();var yo=$.define();var Sc=$.define({combine:n=>n.some(e=>e)});function ox(n){let e=[lx];return n&&n.fixed===!1&&e.push(Sc.of(!0)),e}var lx=Wt.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(yo).map(e=>new Oo(n,e)),this.fixed=!n.state.facet(Sc);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Sc)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=he.iter(this.view.state.facet(wo),this.view.viewport.from),i=[],r=this.gutters.map(s=>new Tc(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Ge.Text&&o){Cc(t,i,l.from);for(let a of r)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==Ge.Text){Cc(t,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(yo),t=n.state.facet(yo),i=n.docChanged||n.heightChanged||n.viewportChanged||!he.eq(n.startState.facet(wo),n.state.facet(wo),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(n)&&(i=!0);else{i=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new Oo(this.view,s)):(this.gutters[o].update(n),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>j.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,r=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==we.LTR?{left:i,right:r}:{right:i,left:r}})});function Bf(n){return Array.isArray(n)?n:[n]}function Cc(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}var Tc=class{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=he.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new Po(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];Cc(this.cursor,r,t.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),r=i?[i]:null;for(let s of e.state.facet(sx)){let o=s(e,t.widget,t);o&&(r||(r=[])).push(o)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},Oo=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=Bf(t.markers(e)),t.initialSpacer&&(this.spacer=new Po(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Bf(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!he.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Po=class{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),ax(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=s<t.length?t[s++]:null,c=!1;if(a){let d=a.elementClass;d&&(i+=" "+d);for(let u=o;u<this.markers.length;u++)if(this.markers[u].compare(a)){l=u,c=!0;break}}else l=this.markers.length;for(;o<l;){let d=this.markers[o++];if(d.toDOM){d.destroy(r);let u=r.nextSibling;r.remove(),r=u}}if(!a)break;a.toDOM&&(c?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),c&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}};function ax(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}var cx=$.define(),dx=$.define(),Gi=$.define({combine(n){return Vi(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let r in t){let s=i[r],o=t[r];i[r]=s?(l,a,c)=>s(l,a,c)||o(l,a,c):o}return i}})}}),jr=class extends $t{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Na(n,e){return n.state.facet(Gi).formatNumber(e,n.state)}var ux=yo.compute([Gi],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(cx)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new jr(Na(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let r of e.state.facet(dx)){let s=r(e,t,i);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Gi)!=e.state.facet(Gi),initialSpacer(e){return new jr(Na(e,_f(e.state.doc.lines)))},updateSpacer(e,t){let i=Na(t.view,_f(t.view.state.doc.lines));return i==e.number?e:new jr(i)},domEventHandlers:n.facet(Gi).domEventHandlers,side:"before"}));function Bc(n={}){return[Gi.of(n),ox(),ux]}function _f(n){let e=9;for(;e<n;)e=e*10+9;return e}var hx=new class extends $t{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},fx=wo.compute(["selection"],n=>{let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.head).from;r>t&&(t=r,e.push(hx.range(r)))}return he.of(e)});function Hp(){return fx}var px=0,Zr=class{constructor(e,t){this.from=e,this.to=t}},te=class{constructor(e={}){this.id=px++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=xt.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};te.closedBy=new te({deserialize:n=>n.split(" ")});te.openedBy=new te({deserialize:n=>n.split(" ")});te.group=new te({deserialize:n=>n.split(" ")});te.isolate=new te({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});te.contextHash=new te({perNode:!0});te.lookAhead=new te({perNode:!0});te.mounted=new te({perNode:!0});var gi=class{constructor(e,t,i,r=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[te.mounted.id]}},mx=Object.create(null),xt=class n{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):mx,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new n(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(te.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(te.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}};xt.none=new xt("",Object.create(null),0,8);var _o=new WeakMap,Fp=new WeakMap,Re;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays",n[n.EnterBracketed=16]="EnterBracketed"})(Re||(Re={}));var qe=class n{constructor(e,t,i,r,s){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=gi.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new ts(this.topNode,e)}cursorAt(e,t=0,i=0){let r=_o.get(this)||this.topNode,s=new ts(r);return s.moveTo(e,t),_o.set(this,s._tree),s}get topNode(){return new sn(this,0,0,null)}resolve(e,t=0){let i=Qr(_o.get(this)||this.topNode,e,t,!1);return _o.set(this,i),i}resolveInner(e,t=0){let i=Qr(Fp.get(this)||this.topNode,e,t,!0);return Fp.set(this,i),i}resolveStack(e,t=0){return gx(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&Re.IncludeAnonymous)>0;for(let a=this.cursor(o|Re.IncludeAnonymous);;){let c=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;c=!0}for(;c&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:$c(xt.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new n(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new n(xt.none,t,i,r)))}static build(e){return bx(e)}};qe.empty=new qe(xt.none,[],[],0);var _c=class n{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new n(this.buffer,this.index)}},Wn=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return xt.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,i,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(Vp(s,r,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){s[a++]=r[l++],s[a++]=r[l++]-i;let c=s[a++]=r[l++]-i;s[a++]=r[l++]-e,o=Math.max(o,c)}return new n(s,o,this.set)}};function Vp(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Qr(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof sn&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=i?0:Re.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof sn&&o.index<0&&((r=l.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(n=l);for(;;){let o=n.enter(e,t,s);if(!o)return n;n=o}}var Fo=class{cursor(e=0){return new ts(this,e)}getChild(e,t=null,i=null){let r=zp(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return zp(this,e,t,i)}resolve(e,t=0){return Qr(this,e,t,!1)}resolveInner(e,t=0){return Qr(this,e,t,!0)}matchContext(e){return Hc(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}},sn=class n extends Fo{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,c=t>0?l.length:-1;e!=c;e+=t){let d=l[e],u=a[e]+o.from,h;if(!(!(s&Re.EnterBracketed&&d instanceof qe&&(h=gi.get(d))&&!h.overlay&&h.bracketed&&i>=u&&i<=u+d.length)&&!Vp(r,i,u,u+d.length))){if(d instanceof Wn){if(s&Re.ExcludeBuffers)continue;let f=d.findChild(0,d.buffer.length,t,i-u,r);if(f>-1)return new es(new Fc(o,d,e,u),null,f)}else if(s&Re.IncludeAnonymous||!d.type.isAnonymous||Vc(d)){let f;if(!(s&Re.IgnoreMounts)&&(f=gi.get(d))&&!f.overlay)return new n(f.tree,u,e,o);let p=new n(d,u,e,o);return s&Re.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?d.children.length-1:0,t,i,r,s)}}}if(s&Re.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let r;if(!(i&Re.IgnoreOverlays)&&(r=gi.get(this._tree))&&r.overlay){let s=e-this.from,o=i&Re.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((t>0||o?l<=s:l<s)&&(t<0||o?a>=s:a>s))return new n(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function zp(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function Hc(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var Fc=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},es=class n extends Fo{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new n(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&Re.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new n(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new n(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new qe(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function $p(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;s<n.length;s++){let o=n[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let i=t instanceof sn&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new zc(r,t)}var zc=class{constructor(e,t){this.heads=e,this.node=t}get next(){return $p(this.heads)}};function gx(n,e,t){let i=n.resolveInner(e,t),r=null;for(let s=i instanceof sn?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,t)),s=o}else{let o=gi.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new sn(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(Qr(l,e,t,!1))}}return r?$p(r):i}var ts=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~Re.EnterBracketed,e instanceof sn)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof sn?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&Re.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Re.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Re.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&Re.IncludeAnonymous||l instanceof Wn||!l.type.isAnonymous||Vc(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)t=new es(this.buffer,t,this.stack[r]);return this.bufferNode=new es(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return Hc(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return Hc(this._tree,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function Vc(n){return n.children.some(e=>e instanceof Wn||!e.type.isAnonymous||Vc(e))}function bx(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new _c(t,t.length):t,a=i.types,c=0,d=0;function u(S,x,T,W,H,z){let{id:D,start:R,end:F,size:M}=l,K=d,X=c;if(M<0)if(l.next(),M==-1){let ot=s[D];T.push(ot),W.push(R-S);return}else if(M==-3){c=D;return}else if(M==-4){d=D;return}else throw new RangeError(`Unrecognized record size: ${M}`);let ye=a[D],et,Ce,je=R-S;if(F-R<=r&&(Ce=w(l.pos-x,H))){let ot=new Uint16Array(Ce.size-Ce.skip),Ke=l.pos-Ce.size,Xe=ot.length;for(;l.pos>Ke;)Xe=b(Ce.start,ot,Xe);et=new Wn(ot,F-Ce.start,i),je=Ce.start-S}else{let ot=l.pos-M;l.next();let Ke=[],Xe=[],kt=D>=o?D:-1,ie=0,An=F;for(;l.pos>ot;)kt>=0&&l.id==kt&&l.size>=0?(l.end<=An-r&&(p(Ke,Xe,R,ie,l.end,An,kt,K,X),ie=Ke.length,An=l.end),l.next()):z>2500?h(R,ot,Ke,Xe):u(R,ot,Ke,Xe,kt,z+1);if(kt>=0&&ie>0&&ie<Ke.length&&p(Ke,Xe,R,ie,R,An,kt,K,X),Ke.reverse(),Xe.reverse(),kt>-1&&ie>0){let Mi=f(ye,X);et=$c(ye,Ke,Xe,0,Ke.length,0,F-R,Mi,Mi)}else et=m(ye,Ke,Xe,F-R,K-F,X)}T.push(et),W.push(je)}function h(S,x,T,W){let H=[],z=0,D=-1;for(;l.pos>x;){let{id:R,start:F,end:M,size:K}=l;if(K>4)l.next();else{if(D>-1&&F<D)break;D<0&&(D=M-r),H.push(R,F,M),z++,l.next()}}if(z){let R=new Uint16Array(z*4),F=H[H.length-2];for(let M=H.length-3,K=0;M>=0;M-=3)R[K++]=H[M],R[K++]=H[M+1]-F,R[K++]=H[M+2]-F,R[K++]=K;T.push(new Wn(R,H[2]-F,i)),W.push(F-S)}}function f(S,x){return(T,W,H)=>{let z=0,D=T.length-1,R,F;if(D>=0&&(R=T[D])instanceof qe){if(!D&&R.type==S&&R.length==H)return R;(F=R.prop(te.lookAhead))&&(z=W[D]+R.length+F)}return m(S,T,W,H,z,x)}}function p(S,x,T,W,H,z,D,R,F){let M=[],K=[];for(;S.length>W;)M.push(S.pop()),K.push(x.pop()+T-H);S.push(m(i.types[D],M,K,z-H,R-z,F)),x.push(H-T)}function m(S,x,T,W,H,z,D){if(z){let R=[te.contextHash,z];D=D?[R].concat(D):[R]}if(H>25){let R=[te.lookAhead,H];D=D?[R].concat(D):[R]}return new qe(S,x,T,W,D)}function w(S,x){let T=l.fork(),W=0,H=0,z=0,D=T.end-r,R={size:0,start:0,skip:0};e:for(let F=T.pos-S;T.pos>F;){let M=T.size;if(T.id==x&&M>=0){R.size=W,R.start=H,R.skip=z,z+=4,W+=4,T.next();continue}let K=T.pos-M;if(M<0||K<F||T.start<D)break;let X=T.id>=o?4:0,ye=T.start;for(T.next();T.pos>K;){if(T.size<0)if(T.size==-3||T.size==-4)X+=4;else break e;else T.id>=o&&(X+=4);T.next()}H=ye,W+=M,z+=X}return(x<0||W==S)&&(R.size=W,R.start=H,R.skip=z),R.size>4?R:void 0}function b(S,x,T){let{id:W,start:H,end:z,size:D}=l;if(l.next(),D>=0&&W<o){let R=T;if(D>4){let F=l.pos-(D-4);for(;l.pos>F;)T=b(S,x,T)}x[--T]=R,x[--T]=z-S,x[--T]=H-S,x[--T]=W}else D==-3?c=W:D==-4&&(d=W);return T}let k=[],C=[];for(;l.pos>0;)u(n.start||0,n.bufferStart||0,k,C,-1,0);let P=(e=n.length)!==null&&e!==void 0?e:k.length?C[0]+k[0].length:0;return new qe(a[n.topID],k.reverse(),C.reverse(),P)}var Wp=new WeakMap;function Ho(n,e){if(!n.isAnonymous||e instanceof Wn||e.type!=n)return 1;let t=Wp.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof qe)){t=1;break}t+=Ho(n,i)}Wp.set(e,t)}return t}function $c(n,e,t,i,r,s,o,l,a){let c=0;for(let p=i;p<r;p++)c+=Ho(n,e[p]);let d=Math.ceil(c*1.5/8),u=[],h=[];function f(p,m,w,b,k){for(let C=w;C<b;){let P=C,S=m[C],x=Ho(n,p[C]);for(C++;C<b;C++){let T=Ho(n,p[C]);if(x+T>=d)break;x+=T}if(C==P+1){if(x>d){let T=p[P];f(T.children,T.positions,0,T.children.length,m[P]+k);continue}u.push(p[P])}else{let T=m[C-1]+p[C-1].length-S;u.push($c(n,p,m,P,C,S,T,null,a))}h.push(S+k-s)}}return f(e,t,i,r,0),(l||a)(u,h,o)}var bi=class n{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new n(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,c=0;;l++){let d=l<t.length?t[l]:null,u=d?d.fromA:1e9;if(u-a>=i)for(;o&&o.from<u;){let h=o;if(a>=h.from||u<=h.to||c){let f=Math.max(h.from,a)-c,p=Math.min(h.to,u)-c;h=f>=p?null:new n(f,p,h.tree,h.offset+c,l>0,!!d)}if(h&&r.push(h),o.to>u)break;o=s<e.length?e[s++]:null}if(!d)break;a=d.toA,c=d.toA-d.toB}return r}},zo=class{startParse(e,t,i){return typeof e=="string"&&(e=new Wc(e)),i=i?i.length?i.map(r=>new Zr(r.from,r.to)):[new Zr(0,0)]:[new Zr(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}},Wc=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var CS=new te({perNode:!0});var wx=0,Ut=class n{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=wx++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof n&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let r=new n(i,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new Uo(e);return i=>i.modified.indexOf(t)>-1?i:Uo.get(i.base||i,i.modified.concat(t).sort((r,s)=>r.id-s.id))}},yx=0,Uo=class n{constructor(e){this.name=e,this.instances=[],this.id=yx++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&xx(t,l.modified));if(i)return i;let r=[],s=new Ut(e.name,r,e,t);for(let l of t)l.instances.push(s);let o=vx(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(n.get(l,a));return s}};function xx(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function vx(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function Kp(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let u=0;;){if(l=="..."&&u>0&&u+3==r.length){o=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!h)throw new RangeError("Invalid path: "+r);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),u+=h[0].length,u==r.length)break;let f=r[u++];if(u==r.length&&f=="!"){o=0;break}if(f!="/")throw new RangeError("Invalid path: "+r);l=r.slice(u)}let a=s.length-1,c=s[a];if(!c)throw new RangeError("Invalid path: "+r);let d=new nr(i,o,a>0?s.slice(0,a):null);e[c]=d.sort(e[c])}}return kx.add(e)}var kx=new te({combine(n,e){let t,i,r;for(;n||e;){if(!n||e&&n.depth>=e.depth?(r=e,e=e.next):(r=n,n=n.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let s=new nr(r.tags,r.mode,r.context);t?t.next=s:i=s,t=s}return i}}),nr=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};nr.empty=new nr([],2,null);function Kc(n,e){let t=Object.create(null);for(let s of n)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let c=t[a.id];if(c){o=o?o+" "+c:c;break}}return o},scope:i}}var O=Ut.define,Wo=O(),Vn=O(),Up=O(Vn),jp=O(Vn),$n=O(),Vo=O($n),Uc=O($n),an=O(),wi=O(an),on=O(),ln=O(),jc=O(),ns=O(jc),$o=O(),I={comment:Wo,lineComment:O(Wo),blockComment:O(Wo),docComment:O(Wo),name:Vn,variableName:O(Vn),typeName:Up,tagName:O(Up),propertyName:jp,attributeName:O(jp),className:O(Vn),labelName:O(Vn),namespace:O(Vn),macroName:O(Vn),literal:$n,string:Vo,docString:O(Vo),character:O(Vo),attributeValue:O(Vo),number:Uc,integer:O(Uc),float:O(Uc),bool:O($n),regexp:O($n),escape:O($n),color:O($n),url:O($n),keyword:on,self:O(on),null:O(on),atom:O(on),unit:O(on),modifier:O(on),operatorKeyword:O(on),controlKeyword:O(on),definitionKeyword:O(on),moduleKeyword:O(on),operator:ln,derefOperator:O(ln),arithmeticOperator:O(ln),logicOperator:O(ln),bitwiseOperator:O(ln),compareOperator:O(ln),updateOperator:O(ln),definitionOperator:O(ln),typeOperator:O(ln),controlOperator:O(ln),punctuation:jc,separator:O(jc),bracket:ns,angleBracket:O(ns),squareBracket:O(ns),paren:O(ns),brace:O(ns),content:an,heading:wi,heading1:O(wi),heading2:O(wi),heading3:O(wi),heading4:O(wi),heading5:O(wi),heading6:O(wi),contentSeparator:O(an),list:O(an),quote:O(an),emphasis:O(an),strong:O(an),link:O(an),monospace:O(an),strikethrough:O(an),inserted:O(),deleted:O(),changed:O(),invalid:O(),meta:$o,documentMeta:O($o),annotation:O($o),processingInstruction:O($o),definition:Ut.defineModifier("definition"),constant:Ut.defineModifier("constant"),function:Ut.defineModifier("function"),standard:Ut.defineModifier("standard"),local:Ut.defineModifier("local"),special:Ut.defineModifier("special")};for(let n in I){let e=I[n];e instanceof Ut&&(e.name=n)}var MS=Kc([{tag:I.link,class:"tok-link"},{tag:I.heading,class:"tok-heading"},{tag:I.emphasis,class:"tok-emphasis"},{tag:I.strong,class:"tok-strong"},{tag:I.keyword,class:"tok-keyword"},{tag:I.atom,class:"tok-atom"},{tag:I.bool,class:"tok-bool"},{tag:I.url,class:"tok-url"},{tag:I.labelName,class:"tok-labelName"},{tag:I.inserted,class:"tok-inserted"},{tag:I.deleted,class:"tok-deleted"},{tag:I.literal,class:"tok-literal"},{tag:I.string,class:"tok-string"},{tag:I.number,class:"tok-number"},{tag:[I.regexp,I.escape,I.special(I.string)],class:"tok-string2"},{tag:I.variableName,class:"tok-variableName"},{tag:I.local(I.variableName),class:"tok-variableName tok-local"},{tag:I.definition(I.variableName),class:"tok-variableName tok-definition"},{tag:I.special(I.variableName),class:"tok-variableName2"},{tag:I.definition(I.propertyName),class:"tok-propertyName tok-definition"},{tag:I.typeName,class:"tok-typeName"},{tag:I.namespace,class:"tok-namespace"},{tag:I.className,class:"tok-className"},{tag:I.macroName,class:"tok-macroName"},{tag:I.propertyName,class:"tok-propertyName"},{tag:I.operator,class:"tok-operator"},{tag:I.comment,class:"tok-comment"},{tag:I.meta,class:"tok-meta"},{tag:I.invalid,class:"tok-invalid"},{tag:I.punctuation,class:"tok-punctuation"}]);var Gc,rs=new te;var Sx=new te,Lt=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,Te.prototype.hasOwnProperty("tree")||Object.defineProperty(Te.prototype,"tree",{get(){return Sn(this)}}),this.parser=t,this.extension=[ir.of(this),Te.languageData.of((s,o,l)=>{let a=Gp(s,o,l),c=a.type.prop(rs);if(!c)return[];let d=s.facet(c),u=a.type.prop(Sx);if(u){let h=a.resolve(o-a.from,l);for(let f of u)if(f.test(h,s)){let p=s.facet(f.facet);return f.type=="replace"?p:p.concat(d)}}return d})].concat(i)}isActiveAt(e,t,i=-1){return Gp(e,t,i).type.prop(rs)==this.data}findRegions(e){let t=e.facet(ir);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(rs)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(te.mounted);if(l){if(l.tree.prop(rs)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let a=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<s.children.length;a++){let c=s.children[a];c instanceof qe&&r(c,s.positions[a]+o)}};return r(Sn(e),0),i}get allowsNesting(){return!0}};Lt.setState=ke.define();function Gp(n,e,t){let i=n.facet(ir),r=Sn(n).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,t,Re.ExcludeBuffers|Re.EnterBracketed))s.type.isTop&&(r=s);return r}function Sn(n){let e=n.field(Lt.state,!1);return e?e.tree:qe.empty}var Jc=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},is=null,Yc=class n{constructor(e,t,i=[],r,s,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],qe.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Jc(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=qe.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(bi.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(bi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=is;is=this;try{return e()}finally{is=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=qp(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((c,d,u,h)=>a.push({fromA:c,toA:d,fromB:u,toB:h})),i=bi.applyChanges(i,a),r=qe.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let d=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);d<u&&l.push({from:d,to:u})}}}return new n(this.parser,t,i,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=qp(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends zo{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=is;if(a){for(let c of r)a.tempSkipped.push(c);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new qe(xt.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return is}};function qp(n,e,t){return bi.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var ss=class n{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Yc.create(e.facet(ir).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};Lt.state=Tt.define({create:ss.init,update(n,e){for(let t of e.effects)if(t.is(Lt.setState))return t.value;return e.startState.facet(ir)!=e.state.facet(ir)?ss.init(e.state):n.apply(e)}});var Zp=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Zp=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var qc=typeof navigator<"u"&&(!((Gc=navigator.scheduling)===null||Gc===void 0)&&Gc.isInputPending)?()=>navigator.scheduling.isInputPending():null,Cx=Wt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Lt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Lt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Zp(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(Lt.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!qc?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,a=s.context.work(()=>qc&&qc()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Lt.setState.of(new ss(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ft(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ir=$.define({combine(n){return n.length?n[0]:null},enables:n=>[Lt.state,Cx,j.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});var Tx=$.define(),jo=$.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function os(n){let e=n.facet(jo);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function ls(n,e){let t="",i=n.tabSize,r=n.facet(jo)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s<e;s++)t+=r;return t}function nd(n,e){n instanceof Te&&(n=new yi(n));for(let i of n.state.facet(Tx)){let r=i(n,e);if(r!==void 0)return r}let t=Sn(n.state);return t.length>=e?Mx(n,t,e):null}var yi=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=os(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return ci(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Ax=new te;function Mx(n,e,t){let i=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return Qp(i,n,t)}function Qp(n,e,t){for(let i=n;i;i=i.next){let r=Rx(i.node);if(r)return r(Zc.create(e,t,i))}return 0}function Ex(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Rx(n){let e=n.type.prop(Ax);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(te.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>Px(o,!0,1,void 0,s&&!Ex(o)?r.from:void 0)}return n.parent==null?Lx:null}function Lx(){return 0}var Zc=class n extends yi{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new n(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Dx(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Qp(this.context.next,this.base,this.pos)}};function Dx(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Ox(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let c=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+c}}l=a.to}}function Px(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==n.pos+o,a=e?Ox(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}var Qc=class n{constructor(e,t){this.specs=e;let i;function r(l){let a=At.newName();return(i||(i=Object.create(null)))["."+a]=l,a}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof Lt?l=>l.prop(rs)==o.data:o?l=>l==o:void 0,this.style=Kc(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new At(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}};var HS=Qc.define([{tag:I.meta,color:"#404740"},{tag:I.link,textDecoration:"underline"},{tag:I.heading,textDecoration:"underline",fontWeight:"bold"},{tag:I.emphasis,fontStyle:"italic"},{tag:I.strong,fontWeight:"bold"},{tag:I.strikethrough,textDecoration:"line-through"},{tag:I.keyword,color:"#708"},{tag:[I.atom,I.bool,I.url,I.contentSeparator,I.labelName],color:"#219"},{tag:[I.literal,I.inserted],color:"#164"},{tag:[I.string,I.deleted],color:"#a11"},{tag:[I.regexp,I.escape,I.special(I.string)],color:"#e40"},{tag:I.definition(I.variableName),color:"#00f"},{tag:I.local(I.variableName),color:"#30a"},{tag:[I.typeName,I.namespace],color:"#085"},{tag:I.className,color:"#167"},{tag:[I.special(I.variableName),I.macroName],color:"#256"},{tag:I.definition(I.propertyName),color:"#00c"},{tag:I.comment,color:"#940"},{tag:I.invalid,color:"#f00"}]);var Ix=1e4,Nx="()[]{}";var Bx=new te;function ed(n,e,t){let i=n.prop(e<0?te.openedBy:te.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function td(n){let e=n.type.prop(Bx);return e?e(n.node):n}function xi(n,e,t,i={}){let r=i.maxScanDistance||Ix,s=i.brackets||Nx,o=Sn(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let c=ed(a.type,t,s);if(c&&a.from<a.to){let d=td(a);if(d&&(t>0?e>=d.from&&e<d.to:e>d.from&&e<=d.to))return _x(n,e,t,a,d,c,s)}}return Hx(n,e,t,o,l.type,r,s)}function _x(n,e,t,i,r,s,o){let l=i.parent,a={from:r.from,to:r.to},c=0,d=l?.cursor();if(d&&(t<0?d.childBefore(i.from):d.childAfter(i.to)))do if(t<0?d.to<=i.from:d.from>=i.to){if(c==0&&s.indexOf(d.type.name)>-1&&d.from<d.to){let u=td(d);return{start:a,end:u?{from:u.from,to:u.to}:void 0,matched:!0}}else if(ed(d.type,t,o))c++;else if(ed(d.type,-t,o)){if(c==0){let u=td(d);return{start:a,end:u&&u.from<u.to?{from:u.from,to:u.to}:void 0,matched:!1}}c--}}while(t<0?d.prevSibling():d.nextSibling());return{start:a,matched:!1}}function Hx(n,e,t,i,r,s,o){if(t<0?!e:e==n.doc.length)return null;let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},d=n.doc.iterRange(e,t>0?n.doc.length:0),u=0;for(let h=0;!d.next().done&&h<=s;){let f=d.value;t<0&&(h+=f.length);let p=e+h*t;for(let m=t>0?0:f.length-1,w=t>0?f.length:-1;m!=w;m+=t){let b=o.indexOf(f[m]);if(!(b<0||i.resolveInner(p+m,1).type!=r))if(b%2==0==t>0)u++;else{if(u==1)return{start:c,end:{from:p+m,to:p+m+1},matched:b>>1==a>>1};u--}}t>0&&(h+=f.length)}return d.done?{start:c,matched:!1}:null}var Fx=Object.create(null),Xp=[xt.none];var Jp=[],Yp=Object.create(null),zx=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])zx[n]=Wx(Fx,e);function Xc(n,e){Jp.indexOf(n)>-1||(Jp.push(n),console.warn(e))}function Wx(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let c of l.split(".")){let d=n[c]||I[c];d?typeof d=="function"?a.length?a=a.map(d):Xc(c,`Modifier ${c} used at start of tag`):a.length?Xc(c,`Tag ${c} used as modifier`):a=Array.isArray(d)?d:[d]:Xc(c,`Unknown highlighting tag ${c}`)}for(let c of a)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(l=>l.id),s=Yp[r];if(s)return s.id;let o=Yp[r]=xt.define({id:Xp.length,name:i,props:[Kp({[i]:t})]});return Xp.push(o),o.id}var FS={rtl:be.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:we.RTL}),ltr:be.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:we.LTR}),auto:be.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var Vx=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=cd(n.state,t.from);return i.line?$x(n):i.block?jx(n):!1};function ad(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var $x=ad(qx,0);var Ux=ad(am,0);var jx=ad((n,e)=>am(n,e,Gx(e)),0);function cd(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}var as=50;function Kx(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-as,i),o=n.sliceDoc(r,r+as),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,c=s.length-l;if(s.slice(c-e.length,c)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let d,u;r-i<=2*as?d=u=n.sliceDoc(i,r):(d=n.sliceDoc(i,i+as),u=n.sliceDoc(r-as,r));let h=/^\s*/.exec(d)[0].length,f=/\s*$/.exec(u)[0].length,p=u.length-f-t.length;return d.slice(h,h+e.length)==e&&u.slice(p,p+t.length)==t?{open:{pos:i+h+e.length,margin:/\s/.test(d.charAt(h+e.length))?1:0},close:{pos:r-f-t.length,margin:/\s/.test(u.charAt(p-1))?1:0}}:null}function Gx(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to);r.from>i.from&&r.from==t.to&&(r=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function am(n,e,t=e.selection.ranges){let i=t.map(s=>cd(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>Kx(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=i[o],{open:c,close:d}=l;s.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:d.pos-d.margin,to:d.pos+a.close.length})}return{changes:s}}return null}function qx(n,e,t=e.selection.ranges){let i=[],r=-1;e:for(let{from:s,to:o}of t){let l=i.length,a=1e9,c;for(let d=s;d<=o;){let u=e.doc.lineAt(d);if(c==null&&(c=cd(e,u.from).line,!c))continue e;if(u.from>r&&(s==o||o>u.from)){r=u.from;let h=/^\s*/.exec(u.text)[0].length,f=h==u.length,p=u.text.slice(h,h+c.length)==c?h:-1;h<u.text.length&&h<a&&(a=h),i.push({line:u,comment:p,token:c,indent:h,empty:f,single:!1})}d=u.to+1}if(a<1e9)for(let d=l;d<i.length;d++)i[d].indent<i[d].line.text.length&&(i[d].indent=a);i.length==l+1&&(i[l].single=!0)}if(n!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:c,empty:d,single:u}of i)(u||!d)&&s.push({from:l.from+c,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let c=o.from+l,d=c+a.length;o.text[d-o.from]==" "&&d++,s.push({from:c,to:d})}return{changes:s}}return null}var rd=ht.define(),Xx=ht.define(),Jx=$.define(),cm=$.define({combine(n){return Vi(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,r)=>e(i,r)||t(i,r)})}}),dm=Tt.define({create(){return vi.empty},update(n,e){let t=e.state.facet(cm),i=e.annotation(rd);if(i){let a=jt.fromTransaction(e,i.selection),c=i.side,d=c==0?n.undone:n.done;return a?d=Go(d,d.length,t.minDepth,a):d=pm(d,e.startState.selection),new vi(c==0?i.rest:d,c==0?d:i.rest)}let r=e.annotation(Xx);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(Be.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=jt.fromTransaction(e),o=e.annotation(Be.time),l=e.annotation(Be.userEvent);return s?n=n.addChanges(s,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new vi(n.done.map(jt.fromJSON),n.undone.map(jt.fromJSON))}});function um(n={}){return[dm,cm.of(n),j.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?hm:e.inputType=="historyRedo"?sd:null;return i?(e.preventDefault(),i(t)):!1}})]}function qo(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(dm,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}var hm=qo(0,!1),sd=qo(1,!1),Yx=qo(0,!0),Zx=qo(1,!0);var jt=class n{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new n(e.changes&&it.fromJSON(e.changes),[],e.mapped&&bn.fromJSON(e.mapped),e.startSelection&&L.fromJSON(e.startSelection),e.selectionsAfter.map(L.fromJSON))}static fromTransaction(e,t){let i=Dt;for(let r of e.startState.facet(Jx)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Dt)}static selection(e){return new n(void 0,Dt,void 0,void 0,e)}};function Go(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function Qx(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<t.length;){let c=t[a++],d=t[a++];l>=c&&o<=d&&(i=!0)}}),i}function e1(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function fm(n,e){return n.length?e.length?n.concat(e):n:e}var Dt=[],t1=200;function pm(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-t1));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Go(n,n.length-1,1e9,t.setSelAfter(i)))}else return[jt.selection([e])]}function n1(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function id(n,e){if(!n.length)return n;let t=n.length,i=Dt;for(;t;){let r=i1(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[jt.selection(i)]:Dt}function i1(n,e,t){let i=fm(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):Dt,t);if(!n.changes)return jt.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new jt(r,ke.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}var r1=/^(input\.type|delete)($|\.)/,vi=class n{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||r1.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,Qx(l.changes,e.changes))||i=="input.type.compose")?o=Go(o,o.length-1,r.minDepth,new jt(e.changes.compose(l.changes),fm(ke.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,Dt)):o=Go(o,o.length,r.minDepth,e),new n(o,Dt,t,i)}addSelection(e,t,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Dt;return s.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&e1(s[s.length-1],e)?this:new n(pm(this.done,e),this.undone,t,i)}addMapping(e){return new n(id(this.done,e),id(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):t.selection);if(i&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:rd.of({side:e,rest:n1(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?Dt:r.slice(0,r.length-1);return s.mapped&&(l=id(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:rd.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};vi.empty=new vi(Dt,Dt);var mm=[{key:"Mod-z",run:hm,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:sd,preventDefault:!0},{linux:"Ctrl-Shift-z",run:sd,preventDefault:!0},{key:"Mod-u",run:Yx,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Zx,preventDefault:!0}];function rr(n,e){return L.create(n.ranges.map(e),n.mainIndex)}function Kt(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Gt({state:n,dispatch:e},t){let i=rr(n.selection,t);return i.eq(n.selection,!0)?!1:(e(Kt(n,i)),!0)}function Xo(n,e){return L.cursor(e?n.to:n.from)}function gm(n,e){return Gt(n,t=>t.empty?n.moveByChar(t,e):Xo(t,e))}function Ze(n){return n.textDirectionAt(n.state.selection.main.head)==we.LTR}var bm=n=>gm(n,!Ze(n)),wm=n=>gm(n,Ze(n));function ym(n,e){return Gt(n,t=>t.empty?n.moveByGroup(t,e):Xo(t,e))}var s1=n=>ym(n,!Ze(n)),o1=n=>ym(n,Ze(n));var KS=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function l1(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Jo(n,e,t){let i=Sn(n).resolveInner(e.head),r=t?te.closedBy:te.openedBy;for(let a=e.head;;){let c=t?i.childAfter(a):i.childBefore(a);if(!c)break;l1(n,c,r)?i=c:a=t?c.to:c.from}let s=i.type.prop(r),o,l;return s&&(o=t?xi(n,i.from,1):xi(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,L.cursor(l,t?-1:1)}var a1=n=>Gt(n,e=>Jo(n.state,e,!Ze(n))),c1=n=>Gt(n,e=>Jo(n.state,e,Ze(n)));function xm(n,e){return Gt(n,t=>{if(!t.empty)return Xo(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var vm=n=>xm(n,!1),km=n=>xm(n,!0);function Sm(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let s of n.state.facet(j.scrollMargins)){let o=s(n);o?.top&&(t=Math.max(o?.top,t)),o?.bottom&&(i=Math.max(o?.bottom,i))}r=n.scrollDOM.clientHeight-t-i}else r=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,r-5)}}function Cm(n,e){let t=Sm(n),{state:i}=n,r=rr(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):Xo(o,e));if(r.eq(i.selection))return!1;let s;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,c=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<c&&(s=j.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(Kt(i,r),{effects:s}),!0}var em=n=>Cm(n,!1),od=n=>Cm(n,!0);function Un(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=L.cursor(i.from+s))}return r}var d1=n=>Gt(n,e=>Un(n,e,!0)),u1=n=>Gt(n,e=>Un(n,e,!1)),h1=n=>Gt(n,e=>Un(n,e,!Ze(n))),f1=n=>Gt(n,e=>Un(n,e,Ze(n))),p1=n=>Gt(n,e=>n.moveToLineBoundary(e,!1,!1)),m1=n=>Gt(n,e=>n.moveToLineBoundary(e,!0,!1));function g1(n,e,t){let i=!1,r=rr(n.selection,s=>{let o=xi(n,s.head,-1)||xi(n,s.head,1)||s.head>0&&xi(n,s.head-1,1)||s.head<n.doc.length&&xi(n,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return t?L.range(s.anchor,l):L.cursor(l)});return i?(e(Kt(n,r)),!0):!1}var b1=({state:n,dispatch:e})=>g1(n,e,!1);function Ot(n,e,t){let i=rr(n.state.selection,r=>{r.undirectional&&r.head>=r.anchor!=e&&(r=L.range(r.head,r.anchor));let s=t(r);return L.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return i.eq(n.state.selection)?!1:(n.dispatch(Kt(n.state,i)),!0)}function Tm(n,e){return Ot(n,e,t=>n.moveByChar(t,e))}var Am=n=>Tm(n,!Ze(n)),Mm=n=>Tm(n,Ze(n));function Em(n,e){return Ot(n,e,t=>n.moveByGroup(t,e))}var w1=n=>Em(n,!Ze(n)),y1=n=>Em(n,Ze(n));var x1=n=>{let e=!Ze(n);return Ot(n,e,t=>Jo(n.state,t,e))},v1=n=>{let e=Ze(n);return Ot(n,e,t=>Jo(n.state,t,e))};function Rm(n,e){return Ot(n,e,t=>n.moveVertically(t,e))}var Lm=n=>Rm(n,!1),Dm=n=>Rm(n,!0);function Om(n,e){return Ot(n,e,t=>n.moveVertically(t,e,Sm(n).height))}var tm=n=>Om(n,!1),nm=n=>Om(n,!0),k1=n=>Ot(n,!0,e=>Un(n,e,!0)),S1=n=>Ot(n,!1,e=>Un(n,e,!1)),C1=n=>{let e=!Ze(n);return Ot(n,e,t=>Un(n,t,e))},T1=n=>{let e=Ze(n);return Ot(n,e,t=>Un(n,t,e))},A1=n=>Ot(n,!1,e=>L.cursor(n.lineBlockAt(e.head).from)),M1=n=>Ot(n,!0,e=>L.cursor(n.lineBlockAt(e.head).to)),im=({state:n,dispatch:e})=>(e(Kt(n,{anchor:0})),!0),rm=({state:n,dispatch:e})=>(e(Kt(n,{anchor:n.doc.length})),!0),sm=({state:n,dispatch:e})=>(e(Kt(n,{anchor:n.selection.main.anchor,head:0})),!0),om=({state:n,dispatch:e})=>(e(Kt(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),E1=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),R1=({state:n,dispatch:e})=>{let t=Yo(n).map(({from:i,to:r})=>L.undirectionalRange(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:L.create(t),userEvent:"select"})),!0},L1=({state:n,dispatch:e})=>{let t=rr(n.selection,i=>{let r=Sn(n),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return L.undirectionalRange(l.from,l.to)}return i});return t.eq(n.selection)?!1:(e(Kt(n,t)),!0)};function Pm(n,e){let{state:t}=n,i=t.selection,r=t.selection.ranges.slice();for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head);if(e?o.to<n.state.doc.length:o.from>0)for(let l=s;;){let a=n.moveVertically(l,e);if(a.head<o.from||a.head>o.to){r.some(c=>c.head==a.head)||r.push(a);break}else{if(a.head==l.head)break;l=a}}}return r.length==i.ranges.length?!1:(n.dispatch(Kt(t,L.create(r,r.length-1))),!0)}var D1=n=>Pm(n,!1),O1=n=>Pm(n,!0),P1=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=L.create([t.main]):t.main.empty||(i=L.create([L.cursor(t.main.head)])),i?(e(Kt(n,i)),!0):!1};function cs(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(t="delete.backward",a=Ko(n,a,!1)):a>o&&(t="delete.forward",a=Ko(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Ko(n,o,!1),l=Ko(n,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:L.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?j.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Ko(n,e,t){if(n instanceof j)for(let i of n.state.facet(j.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}var Im=(n,e,t)=>cs(n,i=>{let r=i.from,{state:s}=n,o=s.doc.lineAt(r),l,a;if(t&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(l[l.length-1]==" ")return r-1;let c=ci(l,s.tabSize),d=c%os(s)||os(s);for(let u=0;u<d&&l[l.length-1-u]==" ";u++)r--;a=r}else a=$e(o.text,r-o.from,e,e)+o.from,a==r&&o.number!=(e?s.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=$e(o.text,a-o.from,!1,!1)+o.from);return a}),ld=n=>Im(n,!1,!0);var Nm=n=>Im(n,!0,!1),Bm=(n,e)=>cs(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let a=$e(s.text,i-s.from,e)+s.from,c=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),d=o(c);if(l!=null&&d!=l)break;(c!=" "||i!=t.head)&&(l=d),i=a}return i}),_m=n=>Bm(n,!1),I1=n=>Bm(n,!0);var N1=n=>cs(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var B1=n=>cs(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),_1=n=>cs(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var H1=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:ne.of(["",""])},range:L.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},F1=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:$e(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:$e(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:n.doc.slice(r,l).append(n.doc.slice(o,r))},range:L.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Yo(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function Hm(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of Yo(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let a of s.ranges)r.push(L.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let a of s.ranges)r.push(L.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:L.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var z1=({state:n,dispatch:e})=>Hm(n,e,!1),W1=({state:n,dispatch:e})=>Hm(n,e,!0);function Fm(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of Yo(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});let r=n.changes(i);return e(n.update({changes:r,selection:n.selection.map(r,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var V1=({state:n,dispatch:e})=>Fm(n,e,!1),$1=({state:n,dispatch:e})=>Fm(n,e,!0),U1=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Yo(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=rr(e.selection,r=>{let s;if(n.lineWrapping){let o=n.lineBlockAt(r.head),l=n.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(r,!0,s)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function j1(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Sn(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(te.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}var lm=zm(!1),K1=zm(!0);function zm(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!n&&s==o&&j1(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let c=new yi(e,{simulateBreak:s,simulateDoubleBreak:!!a}),d=nd(c,s);for(d==null&&(d=ci(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let u=["",ls(e,d)];return a&&u.push(ls(e,c.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:ne.of(u)},range:L.cursor(s+1+u[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function dd(n,e){let t=-1;return n.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,r,i),t=l.number),o=l.to+1}let s=n.changes(r);return{changes:r,range:L.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}var G1=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new yi(n,{overrideIndentation:s=>{let o=t[s];return o??-1}}),r=dd(n,(s,o,l)=>{let a=nd(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let c=/^\s*/.exec(s.text)[0],d=ls(n,a);(c!=d||l.from<s.from+c.length)&&(t[s.from]=a,o.push({from:s.from,to:s.from+c.length,insert:d}))});return r.changes.empty||e(n.update(r,{userEvent:"indent"})),!0},Wm=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(dd(n,(t,i)=>{i.push({from:t.from,insert:n.facet(jo)})}),{userEvent:"input.indent"})),!0),Vm=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(dd(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=ci(r,n.tabSize),o=0,l=ls(n,Math.max(0,s-os(n)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),q1=n=>(n.setTabFocusMode(),!0);var X1=[{key:"Ctrl-b",run:bm,shift:Am,preventDefault:!0},{key:"Ctrl-f",run:wm,shift:Mm},{key:"Ctrl-p",run:vm,shift:Lm},{key:"Ctrl-n",run:km,shift:Dm},{key:"Ctrl-a",run:p1,shift:A1},{key:"Ctrl-e",run:m1,shift:M1},{key:"Ctrl-d",run:Nm},{key:"Ctrl-h",run:ld},{key:"Ctrl-k",run:N1},{key:"Ctrl-Alt-h",run:_m},{key:"Ctrl-o",run:H1},{key:"Ctrl-t",run:F1},{key:"Ctrl-v",run:od}],J1=[{key:"ArrowLeft",run:bm,shift:Am,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:s1,shift:w1,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:h1,shift:C1,preventDefault:!0},{key:"ArrowRight",run:wm,shift:Mm,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:o1,shift:y1,preventDefault:!0},{mac:"Cmd-ArrowRight",run:f1,shift:T1,preventDefault:!0},{key:"ArrowUp",run:vm,shift:Lm,preventDefault:!0},{mac:"Cmd-ArrowUp",run:im,shift:sm},{mac:"Ctrl-ArrowUp",run:em,shift:tm},{key:"ArrowDown",run:km,shift:Dm,preventDefault:!0},{mac:"Cmd-ArrowDown",run:rm,shift:om},{mac:"Ctrl-ArrowDown",run:od,shift:nm},{key:"PageUp",run:em,shift:tm},{key:"PageDown",run:od,shift:nm},{key:"Home",run:u1,shift:S1,preventDefault:!0},{key:"Mod-Home",run:im,shift:sm},{key:"End",run:d1,shift:k1,preventDefault:!0},{key:"Mod-End",run:rm,shift:om},{key:"Enter",run:lm,shift:lm},{key:"Mod-a",run:E1},{key:"Backspace",run:ld,shift:ld,preventDefault:!0},{key:"Delete",run:Nm,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:_m,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:I1,preventDefault:!0},{mac:"Mod-Backspace",run:B1,preventDefault:!0},{mac:"Mod-Delete",run:_1,preventDefault:!0}].concat(X1.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),$m=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:a1,shift:x1},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:c1,shift:v1},{key:"Alt-ArrowUp",run:z1},{key:"Shift-Alt-ArrowUp",run:V1},{key:"Alt-ArrowDown",run:W1},{key:"Shift-Alt-ArrowDown",run:$1},{key:"Mod-Alt-ArrowUp",run:D1},{key:"Mod-Alt-ArrowDown",run:O1},{key:"Escape",run:P1},{key:"Mod-Enter",run:K1},{key:"Alt-l",mac:"Ctrl-l",run:R1},{key:"Mod-i",run:L1,preventDefault:!0},{key:"Mod-[",run:Vm},{key:"Mod-]",run:Wm},{key:"Mod-Alt-\\",run:G1},{key:"Shift-Mod-k",run:U1},{key:"Shift-Mod-\\",run:b1},{key:"Mod-/",run:Vx},{key:"Alt-A",mac:"Ctrl-A",run:Ux},{key:"Ctrl-m",mac:"Shift-Alt-m",run:q1}].concat(J1),Um={key:"Tab",run:Wm,shift:Vm};var jm=new wn,Km=new wn,Gm=new wn,ud=new wn,hd=ht.define(),cn=null;function qm(n){cn=n}function Xm(n){cn===n&&(cn=null)}function Jm(n){return[j.domEventHandlers({keydown:(e,t)=>cn?.onKeydown(t,e)??!1,compositionstart:()=>(cn?.onCompositionChange(!0),!1),compositionend:()=>(setTimeout(()=>cn?.onCompositionChange(!1),0),!1),focus:()=>(cn?.onFocusChange(!0),!1),blur:()=>(cn?.onFocusChange(!1),!1)}),um(),Pp(),Bp(),j.lineWrapping,_p(),Hp(),jm.of(n.lineNumbers?Bc():[]),Km.of(Qm(n.fontFamily)),Gm.of(Nc(n.placeholder)),ud.of(j.editable.of(n.editable)),Ic.of([...mm,...$m,Um]),j.updateListener.of(e=>{e.docChanged&&!e.transactions.some(t=>t.annotation(hd)===!0)&&cn?.onLocalChange(e.state.doc.toString()),(e.docChanged||e.selectionSet)&&cn?.onCaret(e.state.doc.toString(),e.state.selection.main.head)})]}function fd(n,e){n.dispatch({effects:[jm.reconfigure(e.lineNumbers?Bc():[]),Km.reconfigure(Qm(e.fontFamily)),Gm.reconfigure(Nc(e.placeholder)),ud.reconfigure(j.editable.of(e.editable))]})}function Ym(n,e){n.dispatch({effects:ud.reconfigure(j.editable.of(e))})}function Zm(n,e,t){return pn(()=>{let i=ue();fd(n,{lineNumbers:i.lineNumbers,fontFamily:i.fontFamily,placeholder:e,editable:t})})}function Qm(n){return j.theme({"&":{fontSize:"13px",height:"100%"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:n,lineHeight:"1.6",overflow:"auto"},".cm-content":{caretColor:"var(--dsw-alias-state-business-primary, currentColor)",paddingBottom:"8px"},".cm-line":{padding:"0 8px"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--dsw-alias-state-business-primary, currentColor)"},".cm-gutters":{backgroundColor:"transparent",border:"none",color:"color-mix(in srgb, currentColor 32%, transparent)"},".cm-activeLineGutter":{backgroundColor:"transparent",color:"currentColor",fontWeight:600},".cm-activeLine":{backgroundColor:"color-mix(in srgb, currentColor 6%, transparent)"},".cm-lineNumbers .cm-gutterElement":{minWidth:"2.2em",padding:"0 6px 0 10px"},".cm-selectionBackground":{backgroundColor:"color-mix(in srgb, currentColor 15%, transparent) !important"},".cm-placeholder":{color:"color-mix(in srgb, currentColor 38%, transparent)"}})}function eg(n,e){return Te.create({doc:e,extensions:n})}var Y1=4,ki=new Map;function tg(n){let e=ki.get(n);return e&&ki.delete(n),e}function ng(n,e){for(ki.delete(n),ki.set(n,e);ki.size>Y1;){let t=ki.keys().next().value;if(t===void 0)break;ki.delete(t)}}function Z1(n){return n==="plain"?{tier:"plain"}:n==="claimed"?{tier:"claimed"}:{tier:"frozen"}}function ig(n,e,t,i){if(!(!n||!i))try{n.track(e,t,Z1(i.phase),i.draftRev)}catch(r){Zt("track failed",r)}}function rg(n,e,t){if(!n)return;let i=e?.snapshot,r=i?.draft??"",s=i?.draftRev??0;e?.dismissPopup();let o={trigger:"/",query:"",quoted:!1,position:r.slice(0,t).trim()===""?"leading":"inline",span:{start:t,end:t,draftRev:s}};n.toggleSource("command",o)}var Q1={ArrowUp:"up",ArrowDown:"down",Enter:"enter",Escape:"escape",Tab:"tab"};function sg(n,e,t){if(!n||!n.menu.getSnapshot().open)return!1;let r=Q1[e.key];return r?n.arbitrate(r,t)!=="pass":!1}function og(n){if(!n)return!1;try{return n.onSpace()}catch{return!1}}var ev=new Set(["ctrl","alt","shift","meta","mod"]);function lg(n,e){let t=e===" "?"space":(e.length===1,e.toLowerCase()),i=[];return n.ctrlKey&&i.push("ctrl"),n.altKey&&i.push("alt"),n.shiftKey&&i.push("shift"),n.metaKey&&i.push("meta"),i.push(t),i.join("+")}function tv(n){let e=new Set(n.toLowerCase().split("+").filter(Boolean)),t=[...e].filter(i=>!ev.has(i)).join("+");return{ctrl:e.has("ctrl"),alt:e.has("alt"),shift:e.has("shift"),meta:e.has("meta"),mod:e.has("mod"),key:t}}function pd(n,e){let t=tv(n);return!t.key||t.key!==nv(e)?!1:t.mod?e.ctrlKey||e.metaKey?e.altKey===t.alt&&e.shiftKey===t.shift:!1:e.ctrlKey===t.ctrl&&e.altKey===t.alt&&e.shiftKey===t.shift&&e.metaKey===t.meta}function nv(n){let e=n.key;return e===" "?"space":e.toLowerCase()}function ag(n){let e={ctrl:"Ctrl",alt:"Alt",shift:"Shift",meta:"Cmd",mod:"Ctrl/Cmd",enter:"Enter",tab:"Tab",space:"Space",escape:"Esc"};return n.split("+").filter(Boolean).map(t=>e[t]??(t.length===1?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1))).join(" + ")}var ds=require("react/jsx-runtime");function cg(n){let{state:e,actions:t,triggers:i,keyboard:r,onSendGesture:s,placeholder:o,autoFocus:l,viewRef:a,onCaretMoved:c,disabled:d,solo:u,stateKey:h}=n,f=(0,Pt.useRef)(null),p=(0,Pt.useRef)(!1),[m,w]=(0,Pt.useState)({line:1,col:1}),b=(0,Pt.useRef)(n);b.current=n;let k=e?.draft??"",C=h??"default";(0,Pt.useLayoutEffect)(()=>{let S=f.current;if(!S)return;let x=ue(),T={onKeydown:(R,F)=>{let M=b.current;if(sg(M.triggers,F,p.current))return F.preventDefault(),!0;if(p.current)return!1;if(F.key===" "&&!F.ctrlKey&&!F.metaKey&&!F.altKey&&og(M.triggers))return F.preventDefault(),!0;let K=ue();return pd(K.sendHotkey,F)?(F.preventDefault(),M.onSendGesture(),!0):pd(K.lineBreakHotkey,F)&&K.lineBreakHotkey!=="enter"?(F.preventDefault(),R.dispatch({changes:{from:R.state.selection.main.head,insert:`
727
+ `}}),!0):!1},onLocalChange:R=>{let F=b.current;if(F.actions)try{F.actions.setDraft(R)}catch(M){Zt("setDraft failed",M)}},onCaret:(R,F)=>{let M=b.current;ig(M.triggers,R,F,M.keyboard?.snapshot??M.state);let X=a.current?.state.doc.lineAt(F);w({line:X?X.number:1,col:F-(X?X.from:0)+1}),M.onCaretMoved?.(F)},onCompositionChange:R=>{p.current=R},onFocusChange:R=>{b.current.onFocusedChange?.(R)}};qm(T);let W=tg(C),H=new j({state:W?.state??eg(Jm({lineNumbers:x.lineNumbers,fontFamily:x.fontFamily,placeholder:o,editable:!0}),""),parent:S});W&&(H.scrollDOM.scrollTop=W.scrollTop),a.current=H;let z=H.state.selection.main.head,D=H.state.doc.lineAt(z);return w({line:D.number,col:z-D.from+1}),l&&H.focus(),()=>{a.current=null,ng(C,{state:H.state,scrollTop:H.scrollDOM.scrollTop}),H.destroy(),Xm(T)}},[C]),(0,Pt.useEffect)(()=>{let S=a.current;if(!S)return;let x=S.state.doc.toString();if(k===x)return;let T=Math.min(S.state.selection.main.head,k.length);S.dispatch({annotations:[hd.of(!0),Be.addToHistory.of(!1)],changes:{from:0,to:x.length,insert:k},selection:{anchor:k===""?0:T},scrollIntoView:!0})},[k]),(0,Pt.useEffect)(()=>{let S=a.current;if(!S)return;let x=Zm(S,o,!0);return fd(S,{...iv(o),editable:!0}),x},[o]);let P=d===!0||e!==void 0&&(e.phase==="adjudicating"||e.phase==="submitting");return(0,Pt.useEffect)(()=>{let S=a.current;S&&Ym(S,!P)},[P,a]),(0,ds.jsxs)("div",{className:"dci-editor-wrap","data-solo":u||void 0,children:[(0,ds.jsx)("div",{className:"dci-cm-host",ref:f}),(0,ds.jsxs)("div",{className:"dci-pos",children:[m.line,", ",m.col]})]})}function iv(n){let e=ue();return{lineNumbers:e.lineNumbers,fontFamily:e.fontFamily,placeholder:n}}var vt=require("react");var us=require("react");function Cn(n){let e=(0,us.useCallback)(i=>n?n.subscribe(i):()=>{},[n]),t=(0,us.useCallback)(()=>n?.getSnapshot(),[n]);return(0,us.useSyncExternalStore)(e,t,t)}var re=require("react/jsx-runtime"),md=400;function rv(n){return Ii(`menu.source.${n}`)??n}function Zo(n,e){return`dsh-slash-option-${n}-${e}`}function sv(n){return n==="file"?(0,re.jsx)(wh,{size:16}):n==="folder"?(0,re.jsx)(yh,{size:16}):n==="session"?(0,re.jsx)(xh,{size:16}):typeof n=="function"?(0,re.jsx)(n,{size:16}):null}function dg({size:n=14}){return(0,re.jsx)("span",{style:{display:"inline-flex",transform:"rotate(-90deg)"},children:(0,re.jsx)(en,{size:n})})}function ug(n){let{triggers:e,dropdown:t}=n,i=Cn(e.menu),r=Cn(e.headers),s=(0,vt.useRef)(null),[o,l]=(0,vt.useState)(md),[a,c]=(0,vt.useState)(null),d=i?.open===!0,u=d?i.highlight??null:null;if((0,vt.useLayoutEffect)(()=>{if(!d)return;let f=s.current?.closest(".dci-card");if(!f)return;if(t){let m=f.querySelector(".dci-accessory"),w=f.getBoundingClientRect(),b=m?m.getBoundingClientRect().bottom-w.top:36;c(Math.round(b)+2);let C=!!s.current?.closest(".dci-float")?window.innerHeight-(w.top+b)-16:w.height-b-10;l(Math.max(120,Math.min(md,C)));return}c(null);let p=f.getBoundingClientRect().top;l(Math.max(120,Math.min(md,p-16)))},[d,i?.generation,t]),(0,vt.useEffect)(()=>{u&&document.getElementById(Zo(u.source,u.index))?.scrollIntoView({block:"nearest"})},[u]),(0,vt.useEffect)(()=>{if(!d)return;let f=p=>{p.target instanceof Node&&(s.current?.contains(p.target)||s.current?.closest("[data-composer-card]")?.contains(p.target)||e.dismiss())};return document.addEventListener("pointerdown",f,!0),()=>document.removeEventListener("pointerdown",f,!0)},[d,e]),!d||!i)return null;let h=f=>r?.get(f);return(0,re.jsxs)("div",{ref:s,className:"dci-slash-menu","data-trigger-menu":"","data-dropdown":t||void 0,style:t?{top:a??38,maxHeight:o}:{maxHeight:o},children:[i.groups.map(f=>{let p=h(f.source);return p===void 0||p.length===0?null:(0,re.jsx)("nav",{className:"dci-slash-crumbs","aria-label":v("menu.nav"),children:p.map((m,w)=>(0,re.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:2},children:[w>0?(0,re.jsx)("span",{className:"dci-slash-crumbSeparator","aria-hidden":"true",children:(0,re.jsx)(dg,{size:12})}):null,(0,re.jsx)("button",{type:"button",className:"dci-slash-crumb","data-current":m.current===!0||void 0,"aria-current":m.current===!0?"location":void 0,disabled:m.current===!0,onMouseDown:b=>{b.preventDefault(),e.pickCrumb(f.source,w)},children:m.label})]},`${w}-${m.value}`))},`${f.source}:crumbs`)}),(0,re.jsx)("div",{className:"dci-slash-viewport",role:"listbox","aria-label":v("menu.triggerCandidates"),"aria-activedescendant":u?Zo(u.source,u.index):void 0,children:i.groups.map(f=>{if(f.status==="ready"&&f.items.length===0)return null;let p=f.items.some(m=>m.section!==void 0);return(0,re.jsxs)(vt.Fragment,{children:[f.showGroupTitle===!1||p?null:(0,re.jsx)("div",{className:"dci-slash-groupTitle",role:"presentation","data-source":f.source,children:rv(f.source)}),f.status==="pending"&&f.items.length===0?(0,re.jsxs)("div",{role:"status","aria-label":Ii("menu.loading"),"data-source":f.source,children:[(0,re.jsx)("div",{className:"dci-slash-skeletonRow",children:(0,re.jsx)("span",{className:"dci-slash-skeletonBar",style:{width:"32%"}})}),(0,re.jsx)("div",{className:"dci-slash-skeletonRow",children:(0,re.jsx)("span",{className:"dci-slash-skeletonBar",style:{width:"48%"}})})]}):f.items.map((m,w)=>{let b=u?.source===f.source&&u.index===w;return(0,re.jsxs)(vt.Fragment,{children:[m.section!==void 0&&m.section!==f.items[w-1]?.section?(0,re.jsx)("div",{className:"dci-slash-sectionTitle",role:"presentation",children:m.section}):null,(0,re.jsxs)("button",{id:Zo(f.source,w),type:"button",role:"option","aria-selected":b,className:"dci-slash-item","data-active":b||void 0,onMouseDown:k=>{k.preventDefault(),e.pick(f.source,w)},onMouseMove:b?void 0:()=>e.hover(f.source,w),children:[m.icon!==void 0?(0,re.jsx)("span",{className:"dci-slash-itemIcon","aria-hidden":"true",children:sv(m.icon)}):null,(0,re.jsx)("span",{className:"dci-slash-itemName",children:m.label??m.name}),m.label!==void 0&&m.label.toLowerCase()!==m.name.toLowerCase()?(0,re.jsx)("span",{className:"dci-slash-itemAlias",children:m.name}):null,m.description!==void 0?(0,re.jsx)("span",{className:"dci-slash-itemDescription",children:m.description}):null,m.drill===!0?(0,re.jsxs)("span",{className:"dci-slash-trailing",children:[(0,re.jsx)("span",{className:"dci-slash-drillHintText","aria-hidden":"true",children:"\u8FDB\u5165\u76EE\u5F55"}),(0,re.jsx)("kbd",{className:"dci-slash-drillHint","aria-hidden":"true",children:"Tab"}),(0,re.jsx)("span",{role:"button","aria-label":Ii("menu.drill"),className:"dci-slash-drill",onMouseDown:k=>{k.preventDefault(),k.stopPropagation(),e.pick(f.source,w,"drill")},children:(0,re.jsx)(dg,{size:14})})]}):null]})]},Zo(f.source,w))})]},f.source)})})]})}var jn=require("react");function hg(n,e){let t=e.trim().toLowerCase();return t===""?n:n.filter(i=>{let r=typeof i.label=="string"?i.label.toLowerCase():"",s=typeof i.detail=="string"?i.detail.toLowerCase():"";return r.includes(t)||s.includes(t)})}var Me=require("react/jsx-runtime");function fg(n){let{popup:e}=n,t=Cn(e.state),i=(0,jn.useRef)(null),r=(0,jn.useRef)(null),s=(0,jn.useMemo)(()=>t?hg(t.options,t.search):[],[t?.options,t?.search]);if((0,jn.useEffect)(()=>{if(!t?.open)return;let l=c=>{r.current&&c.target instanceof Node&&r.current.contains(c.target)||e.dismiss()},a=c=>{if(!(!t.open||t.submitting)){if(t.confirming){c.key==="Escape"&&(c.preventDefault(),e.cancelConfirmation());return}c.key==="ArrowDown"?(c.preventDefault(),e.move(1)):c.key==="ArrowUp"?(c.preventDefault(),e.move(-1)):c.key==="Enter"?(c.preventDefault(),e.select(t.active)):c.key==="Escape"&&(c.preventDefault(),e.dismiss({focusComposer:!0}))}};return window.addEventListener("pointerdown",l,!0),window.addEventListener("keydown",a,!0),()=>{window.removeEventListener("pointerdown",l,!0),window.removeEventListener("keydown",a,!0)}},[t?.open,t?.submitting,t?.confirming,t?.active,e]),(0,jn.useEffect)(()=>{t?.open&&i.current?.focus()},[t?.open]),!t?.open)return null;let o=t.confirming;return(0,Me.jsxs)("div",{className:"dci-menu",ref:r,children:[t.command?(0,Me.jsx)("div",{className:"dci-group-title",children:t.command}):null,t.status==="failed"?(0,Me.jsx)("div",{className:"dci-error",children:t.error??v("menu.loadFailed")}):null,t.status==="failed"?(0,Me.jsx)("button",{type:"button",className:"dci-btn",onClick:()=>e.retry(),children:"\u91CD\u8BD5"}):null,t.status==="ready"&&!o?(0,Me.jsx)("input",{ref:i,className:"dci-search",type:"text",placeholder:v("menu.filter"),value:t.search,onChange:l=>e.setSearch(l.target.value)}):null,o?(0,Me.jsxs)("div",{className:"dci-confirm",children:[(0,Me.jsx)("div",{className:"dci-row-name",children:String(o.label??"")}),o.detail?(0,Me.jsx)("div",{className:"dci-row-desc",children:String(o.detail)}):null,(0,Me.jsxs)("label",{children:[(0,Me.jsx)("input",{type:"checkbox",checked:t.acknowledged,onChange:l=>e.acknowledge(l.target.checked)}),(0,Me.jsx)("span",{children:v("popup.ack")})]}),(0,Me.jsxs)("div",{className:"dci-confirm-actions",children:[(0,Me.jsx)("button",{type:"button",className:"dci-btn",onClick:()=>e.cancelConfirmation(),children:"\u53D6\u6D88"}),(0,Me.jsx)("button",{type:"button",className:"dci-btn","data-primary":"true",disabled:t.submitting||!t.acknowledged,onClick:()=>void e.confirm(),children:"\u786E\u8BA4"})]})]}):(0,Me.jsxs)("div",{className:"dci-viewport",children:[t.status==="pending"?(0,Me.jsx)("div",{className:"dci-empty",children:v("menu.loading")}):null,t.status==="ready"&&s.length===0?(0,Me.jsx)("div",{className:"dci-empty",children:v("menu.empty")}):null,s.map((l,a)=>(0,Me.jsx)("button",{type:"button",className:"dci-opt","data-active":a===t.active||void 0,onMouseEnter:()=>e.highlight(a),onClick:()=>void e.select(a),children:(0,Me.jsxs)("span",{className:"dci-opt-copy",children:[(0,Me.jsx)("span",{className:"dci-opt-name",children:String(l.label??"")}),l.detail?(0,Me.jsx)("span",{className:"dci-opt-desc",children:String(l.detail)}):null]})},`${String(l.label)}:${a}`))]}),t.error&&t.status==="ready"?(0,Me.jsx)("div",{className:"dci-error",children:t.error}):null]})}var Si=require("react");var hs=require("react"),pg=require("react-dom"),dn=require("react/jsx-runtime");function ov({size:n=16}){return(0,dn.jsxs)("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",strokeWidth:1,children:[(0,dn.jsx)("path",{d:"M2.5 2.5L13.5 13.5",stroke:"currentColor"}),(0,dn.jsx)("path",{d:"M13.5 2.5L2.5 13.5",stroke:"currentColor"})]})}function mg(n){let{src:e,alt:t,labels:i,onClose:r}=n,s=(0,hs.useRef)(null),o=(0,hs.useRef)(null);return(0,hs.useEffect)(()=>{o.current=document.activeElement instanceof HTMLElement?document.activeElement:null,s.current?.focus();let l=a=>{a.key==="Escape"&&(a.stopPropagation(),r()),a.key==="Tab"&&(a.preventDefault(),s.current?.focus())};return window.addEventListener("keydown",l,!0),()=>{window.removeEventListener("keydown",l,!0),o.current?.focus()}},[r]),(0,pg.createPortal)((0,dn.jsxs)("div",{className:"dci-lightbox",role:"dialog","aria-modal":"true","aria-label":i.dialog,children:[(0,dn.jsx)("div",{className:"dci-lightbox-mask","aria-hidden":"true",onMouseDown:r}),(0,dn.jsx)("img",{className:"dci-lightbox-image",src:e,alt:t}),(0,dn.jsx)("button",{ref:s,type:"button",className:"dci-lightbox-close","aria-label":i.close,onClick:r,children:(0,dn.jsx)(ov,{})})]}),document.body)}var Q=require("react/jsx-runtime"),lv="M8.48924 28H19.5108C21.6479 28 22.7165 28 23.5594 27.6509C24.6833 27.1853 25.5762 26.2924 26.0417 25.1685C26.3909 24.3256 26.3909 23.257 26.3909 21.1199V8.79443C26.3909 8.32877 26.3909 8.09593 26.3471 7.87507C26.2887 7.58058 26.173 7.30042 26.0067 7.05048C25.882 6.86303 25.7177 6.69799 25.3893 6.36792L20.0611 1.01354C19.7304 0.681235 19.5651 0.515081 19.3769 0.38885C19.126 0.220541 18.8443 0.103463 18.5481 0.0443412C18.3259 0 18.0915 0 17.6226 0H8.48924C6.35209 0 5.28351 0 4.4406 0.349145C3.31672 0.814671 2.4238 1.70759 1.95828 2.83147C1.60913 3.67438 1.60913 4.74296 1.60913 6.88011V21.1199C1.60913 23.257 1.60913 24.3256 1.95828 25.1685C2.4238 26.2924 3.31672 27.1853 4.4406 27.6509C5.28351 28 6.35209 28 8.48924 28Z",av="M26.3909 7.37445L19.0525 0V3.77445C19.0525 4.89271 19.0525 5.45184 19.2352 5.89289C19.4788 6.48096 19.946 6.94818 20.5341 7.19176C20.9751 7.37445 21.5342 7.37445 22.6525 7.37445H26.3909Z";function fs({size:n=28}){return(0,Q.jsxs)("svg",{width:n,height:n,viewBox:"0 0 28 28",fill:"none","aria-hidden":"true",children:[(0,Q.jsx)("path",{d:lv,fill:"currentColor"}),(0,Q.jsx)("path",{d:av,fill:"var(--dsw-static-neutral-00, #fff)",fillOpacity:"0.7"})]})}function gd(n){let e=n.split(/[\\/]/).pop()??n,t=e.lastIndexOf(".");return t<0?"":e.slice(t+1)}function Qo(n){if(n<1024)return`${n}B`;let e=n/1024;if(e<1024)return`${e<10?e.toFixed(1):Math.round(e)}KB`;let t=e/1024;if(t<1024)return`${t<10?t.toFixed(1):Math.round(t)}MB`;let i=t/1024;return`${i<10?i.toFixed(1):Math.round(i)}GB`}function wg(n){let{state:e,sessionId:t,onRemove:i}=n,r=Y.conversation,s=Cn(r?.fileUploads),o=(0,Si.useRef)(null),[l,a]=(0,Si.useState)({left:!1,right:!1}),[c,d]=(0,Si.useState)(null),u=e===void 0||typeof r?.resolveDraftAttachments!="function"?[]:r.resolveDraftAttachments(e.attachmentIds)??[];if((0,Si.useEffect)(()=>{let f=o.current;if(!f)return;let p=()=>{let b=f.scrollWidth-f.clientWidth,k={left:f.scrollLeft>1,right:b>1&&f.scrollLeft<b-1};a(C=>C.left===k.left&&C.right===k.right?C:k)};p(),f.addEventListener("scroll",p,{passive:!0});let m=typeof ResizeObserver=="function"?new ResizeObserver(p):null;m?.observe(f);let w=b=>{Math.abs(b.deltaY)<=Math.abs(b.deltaX)||(b.preventDefault(),f.scrollLeft+=b.deltaY)};return f.addEventListener("wheel",w,{passive:!1}),()=>{f.removeEventListener("scroll",p),f.removeEventListener("wheel",w),m?.disconnect()}},[u.length]),u.length===0)return null;let h=f=>{o.current?.scrollBy({left:f*Math.max(120,(o.current?.clientWidth??240)*.8),behavior:"smooth"})};return(0,Q.jsxs)("div",{className:"dci-attach-root",children:[(0,Q.jsx)("div",{className:"dci-attach-rail",ref:o,role:"group","aria-label":v("attach.group"),children:u.map(f=>{let p=s?.[f.id],m=p?.status??"ready",w=f.kind==="image"||f.file.type.startsWith("image/"),b=m==="uploading"&&p?.total?Math.min(100,Math.round((p.loaded??0)/p.total*100)):null;if(w)return(0,Q.jsxs)("div",{className:"dci-attach-item",children:[(0,Q.jsx)("button",{type:"button",className:"dci-attach-thumb",title:v("image.openOriginal"),"aria-label":v("image.openOriginalLabel",{name:f.file.name}),onClick:()=>{f.previewUrl&&d({url:f.previewUrl,name:f.file.name})},children:f.previewUrl?(0,Q.jsx)("img",{src:f.previewUrl,alt:f.file.name}):(0,Q.jsx)(fs,{size:28})}),(0,Q.jsx)("button",{type:"button",className:"dci-attach-remove","aria-label":v("attach.remove",{name:f.file.name}),onClick:()=>i(f.id),children:(0,Q.jsx)(gg,{})}),b!==null?(0,Q.jsx)("span",{className:"dci-attach-progress",children:(0,Q.jsx)("span",{className:"dci-attach-progressBar",style:{width:`${b}%`}})}):null]},f.id);let k=m==="error",C=m==="uploading"?v("attach.uploading"):k?v("attach.failed"):[gd(f.file.name).toUpperCase().slice(0,8),Qo(f.file.size)].filter(S=>S!=="").join(" "),P=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("span",{className:"dci-attach-name",children:f.file.name}),(0,Q.jsx)("span",{className:k?"dci-attach-meta dci-attach-metaFailed":"dci-attach-meta",children:C})]});return(0,Q.jsxs)("div",{className:k?"dci-attach-card dci-attach-cardFailed":"dci-attach-card",title:f.file.name,children:[(0,Q.jsx)("span",{className:"dci-attach-icon","aria-hidden":"true",children:m==="uploading"?(0,Q.jsx)("span",{className:"dci-attach-spinner"}):(0,Q.jsx)(fs,{size:28})}),k?(0,Q.jsx)("button",{type:"button",className:"dci-attach-body dci-attach-retry","aria-label":v("attach.retry"),onClick:()=>cv(t,f.id),children:P}):(0,Q.jsx)("span",{className:"dci-attach-body","aria-label":v("attach.pending",{name:f.file.name}),children:P}),(0,Q.jsx)("button",{type:"button",className:k?"dci-attach-removeInline dci-attach-cardFailedRemove":"dci-attach-removeInline","aria-label":v("attach.remove",{name:f.file.name}),onClick:()=>i(f.id),children:(0,Q.jsx)(gg,{})}),b!==null?(0,Q.jsx)("span",{className:"dci-attach-progress",children:(0,Q.jsx)("span",{className:"dci-attach-progressBar",style:{width:`${b}%`}})}):null]},f.id)})}),l.left?(0,Q.jsx)("button",{type:"button",className:"dci-attach-arrow dci-attach-arrowLeft","aria-label":v("attach.scrollLeft"),onClick:()=>h(-1),children:(0,Q.jsx)(bg,{dir:"left"})}):null,l.right?(0,Q.jsx)("button",{type:"button",className:"dci-attach-arrow dci-attach-arrowRight","aria-label":v("attach.scrollRight"),onClick:()=>h(1),children:(0,Q.jsx)(bg,{dir:"right"})}):null,c?(0,Q.jsx)(mg,{src:c.url,alt:c.name,labels:{dialog:v("image.preview"),close:v("image.closePreview")},onClose:()=>d(null)}):null]})}function cv(n,e){let t=Y.conversation;if(!(!n||typeof t?.retryFileUpload!="function"))try{t.retryFileUpload(n,e)}catch{}}function gg(){return(0,Q.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:(0,Q.jsx)("path",{d:"M1.6 1.6L8.4 8.4M8.4 1.6L1.6 8.4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function bg({dir:n}){return(0,Q.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",style:n==="left"?{transform:"scaleX(-1)"}:void 0,children:(0,Q.jsx)("path",{d:"M5.5 3.5L9 7L5.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}var ll=require("react");var Xt=require("react");function yg(n){let e=Y.modelDirectories;if(!e||typeof e.directoryFor!="function"||!n)return null;try{return e.directoryFor(n)}catch(t){return Zt("directoryFor failed",t),null}}var ms=require("react");var qt=require("react");var bd=[];function Kn(n){let e=Y.slots,t=(0,qt.useCallback)(r=>{if(typeof e?.subscribe!="function")return()=>{};try{return e.subscribe(n,r)??(()=>{})}catch{return()=>{}}},[e,n]),i=(0,qt.useCallback)(()=>{if(typeof e?.entries!="function")return bd;try{return e.entries(n)??bd}catch{return bd}},[e,n]);return(0,qt.useSyncExternalStore)(t,i,i)}var dv=[Symbol.for("react.memo"),Symbol.for("react.forward_ref"),Symbol.for("react.lazy")];function Sg(n){if(typeof n=="function")return!0;if(n===null||typeof n!="object")return!1;let e=n.$$typeof;return typeof e=="symbol"&&dv.includes(e)}function sr(n){for(let e of n){let t=e;if(t&&typeof t=="object"&&Sg(t.component))return t}return null}function Cg(n){let e=new Map;for(let i of n){let r=i;if(!r||typeof r!="object"||!Sg(r.component))continue;let s=r.options?.id;e.has(s)||e.set(s,r)}let t=[...e.values()];return t.sort((i,r)=>xg(i)-xg(r)),t}function xg(n){return n.options?.order??0}function el(n,e){return n.options?.id??`#${e}`}function Tg(n){let e=n.options,t=e?.priority;if(typeof t=="number"&&t<0)return!0;let i=n.registrant??e?.registrant;return typeof i=="string"&&i.startsWith("dyn/")}function tl(n,e,t){let{sessionId:i,standard:r,ownerProps:s,fallback:o}=t,l=n.component,a;try{a=ps(n)??void 0}catch{a=void 0}let c=null;try{c=fv(n,i)}catch(d){me("slot.seat.inject",d)}return(0,qt.createElement)(Ci,{key:e,fallback:o},(0,qt.createElement)(l,{...r??{},sessionId:i,...c??{},...a!==void 0?{t:a}:{},...s??{}}))}var vg=new WeakMap;function uv(n){let e=n;if(!e||typeof e.subscribe!="function"||typeof e.getSnapshot!="function")return null;let t=vg.get(e);return t||(t=i=>(0,qt.useSyncExternalStore)(r=>e.subscribe(r)??(()=>{}),()=>i(e.getSnapshot()),()=>i(e.getSnapshot())),vg.set(e,t)),t}function hv(n){return n&&`use${n.charAt(0).toUpperCase()}${n.slice(1)}`}var kg=new WeakMap;function Ag(n,e){let t=kg.get(n);t||(t=new Map,kg.set(n,t));let i=t.get(e);if(i)return i;let r={props:null,failed:!1};try{let s=n.inject?.(e);if(s&&typeof s=="object"){let{hooks:o,keyedHooks:l,...a}=s;for(let[c,d]of Object.entries(o??{})){let u=uv(d);u&&(a[hv(c)]=u)}r={props:a,failed:!1}}}catch(s){me("slot.inject",s),r={props:null,failed:!0}}return t.set(e,r),r}function fv(n,e){return typeof n.inject!="function"?null:Ag(n,e).props}function Mg(n,e){return typeof n.inject!="function"?!1:Ag(n,e).failed}function ps(n,e){let t=n.locale??e;return t?pr(t):null}var Ci=class extends qt.Component{constructor(){super(...arguments);de(this,"state",{failed:!1})}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t){me("slot.entry",t)}render(){return this.state.failed?this.props.fallback??null:this.props.children}};function nl(n,e=[]){let{variant:t,blocked:i,disabled:r,placeholder:s,workspacePickerOpen:o,onRequestWorkspace:l,accessory:a,hero:c,...d}=n;for(let u of e)delete d[u];return d}var wd=require("react/jsx-runtime"),pv="conversation.input.model.label";function yd(n){let{provider:e,model:t,placement:i,selected:r,fallback:s}=n,o=Kn(pv),l=(0,ms.useMemo)(()=>sr(o),[o]),a=(0,ms.useMemo)(()=>l&&l.locale?ps(l):null,[l]),c=s;return l&&a&&(c=(0,ms.createElement)(l.component,{provider:e,model:t,placement:i,selected:r,t:a})),(0,wd.jsx)("span",{"data-provider-id":e.id,"data-model-id":t.id,children:(0,wd.jsx)(Ci,{fallback:s,children:c})})}var Tn=require("react"),Rg=require("react-dom"),gs=require("react/jsx-runtime"),il=12,Eg=1;function or(n){let{anchor:e,initialRect:t,onClose:i,children:r,alignEnd:s,minWidth:o=218,side:l="top"}=n,a=(0,Tn.useRef)(!0),c=(0,Tn.useRef)(null),[d,u]=(0,Tn.useState)(null);return(0,Tn.useLayoutEffect)(()=>{let h=c.current;if(!h||!e)return;let f=()=>{let P=h.offsetWidth,S=h.offsetHeight,x=a.current&&t||e.getBoundingClientRect();if(x.right-x.left===0||x.bottom-x.top===0||P===0||S===0)return;a.current=!1;let T=s?x.right-P:x.left,W=l==="top"?x.top-8-S:x.bottom+4;T=Math.min(Math.max(T,il),window.innerWidth-P-il),W=Math.min(Math.max(W,il),window.innerHeight-S-il),u(H=>H&&Math.abs(H.left-T)<.5&&Math.abs(H.top-W)<.5?H:{left:T,top:W})};f(),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f);let p=typeof ResizeObserver<"u"?new ResizeObserver(f):null;p?.observe(h),p?.observe(e);let m=e.getBoundingClientRect(),w=m.left,b=m.top,k=0,C=()=>{let P=e.getBoundingClientRect();(Math.abs(P.left-w)>Eg||Math.abs(P.top-b)>Eg)&&(w=P.left,b=P.top,f()),k=requestAnimationFrame(C)};return k=requestAnimationFrame(C),()=>{cancelAnimationFrame(k),p?.disconnect(),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[e,s,l]),(0,Tn.useEffect)(()=>{let h=f=>{c.current&&f.target instanceof Node&&c.current.contains(f.target)||e&&f.target instanceof Node&&e.contains(f.target)||i()};return window.addEventListener("pointerdown",h,!0),()=>window.removeEventListener("pointerdown",h,!0)},[e,i]),(0,Rg.createPortal)((0,gs.jsx)("div",{ref:c,className:"dci-menu",style:{left:d?.left??0,top:d?.top??0,bottom:"auto",right:"auto",minWidth:o,...d?null:{visibility:"hidden"}},children:(0,gs.jsx)("div",{className:"dci-viewport",children:r})}),document.body)}function bs({size:n=16}){return(0,gs.jsx)("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:(0,gs.jsx)("path",{d:"M3 8.5L6.5 12L13 4.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}var J=require("react/jsx-runtime");function xd(n,e){if(!n)return null;for(let t of e){if(t.id!==n.provider)continue;let i=t.models.find(r=>r.id===n.model);if(i)return{group:t,model:i}}return null}function mv(n,e){return n?xd(n,e)?.model.name??n.model:v("tool.modelPlain")}function gv(n,e,t){let i=xd(n,e);if(!i)return;let r=i.model.reasoning;if(!r)return t?.retainedEffort;let s=n?.reasoningEffort??r.defaultEffort;return s===void 0?"Default":r.efforts.find(o=>o.id===s)?.name??s}function Lg(n){let{sessionId:e,onNotify:t}=n,[i,r]=(0,Xt.useState)(!1),[s,o]=(0,Xt.useState)(!1),[l,a]=(0,Xt.useState)("root"),c=(0,Xt.useRef)(null),[d,u]=(0,Xt.useState)(null),[h,f]=(0,Xt.useState)(null),p=yg(e),m=Cn(p?.store);(0,Xt.useEffect)(()=>{!s||!p||p.load().catch(()=>{})},[s]);let w=(0,Xt.useRef)(null),b=()=>{let D=c.current;D&&(u(D),f(D.getBoundingClientRect()),a("root"),o(!0))},k=()=>{o(!1),a("root")},C=m?.current??null,P=m?.groups??[],S=xd(C,P),x=mv(C,P),T=gv(C,P,m),W=T===void 0?x:`${x} \xB7 ${T}`,H=(D,R)=>(0,J.jsx)(yd,{provider:{id:R.group.id,name:R.group.name},model:R.model,placement:D,selected:!0,fallback:x}),z=async(D,R,F)=>{if(!p||i)return;let M={provider:D.id,model:R.id,...F!==void 0?{reasoningEffort:F}:{}};r(!0);try{await p.select(M)}catch(K){t?.("error",K instanceof Error?K.message:String(K))}finally{r(!1),k()}};return(0,J.jsxs)("div",{style:{position:"relative",minWidth:0},children:[(0,J.jsxs)("button",{ref:c,type:"button",className:"dci-trigger","data-model":"",style:{maxWidth:"min(360px, 45cqw)"},"data-open":s,onMouseDown:D=>D.preventDefault(),disabled:!p,onClick:()=>s?k():b(),"aria-haspopup":"menu","aria-expanded":s,"aria-label":v("tool.model",{name:W}),title:v("tool.model",{name:W}),children:[(0,J.jsx)("span",{className:"dci-triggerLabel",children:S?H("trigger",S):x}),T?(0,J.jsx)("span",{className:"dci-triggerEffort",children:T}):null,(0,J.jsx)("span",{className:"dci-chev","data-open":s,children:(0,J.jsx)(en,{size:14})})]}),s&&d?(0,J.jsx)("div",{ref:w,children:(0,J.jsxs)(or,{anchor:d,initialRect:h,onClose:k,alignEnd:!0,minWidth:240,children:[l==="root"?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)("button",{type:"button",className:"dci-cell",onClick:()=>a("models"),children:[(0,J.jsx)("span",{className:"dci-cellLabel",children:v("menu.model")}),(0,J.jsx)("span",{className:"dci-cellValue",children:S?H("menu",S):x}),(0,J.jsx)("span",{className:"dci-cellChevron",style:{transform:"rotate(-90deg)"},"aria-hidden":"true",children:(0,J.jsx)(en,{size:14})})]}),S?.model.reasoning?(0,J.jsxs)("button",{type:"button",className:"dci-cell",onClick:()=>a("efforts"),children:[(0,J.jsx)("span",{className:"dci-cellLabel",children:v("menu.reasoning")}),(0,J.jsx)("span",{className:"dci-cellValue",children:T}),(0,J.jsx)("span",{className:"dci-cellChevron",style:{transform:"rotate(-90deg)"},"aria-hidden":"true",children:(0,J.jsx)(en,{size:14})})]}):null]}):null,l==="models"?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("div",{className:"dci-menuLabel",children:v("menu.model")}),P.map(D=>(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"dci-menuLabel",children:D.name}),D.models.map(R=>{let F=C!==null&&C.provider===D.id&&C.model===R.id;return(0,J.jsxs)("button",{type:"button",className:"dci-item",disabled:i,title:R.description,onClick:()=>void z(D,R,R.reasoning?.defaultEffort),children:[(0,J.jsx)("span",{className:"dci-itemLabel",children:(0,J.jsx)(yd,{provider:{id:D.id,name:D.name},model:R,placement:"option",selected:F,fallback:R.name})}),F?(0,J.jsx)("span",{className:"dci-check","aria-hidden":"true",children:(0,J.jsx)(bs,{size:16})}):null]},R.id)})]},D.id)),P.length===0?(0,J.jsx)("div",{className:"dci-empty",children:m?.status==="loading"?v("menu.refreshingModels"):v("menu.noModels")}):null]}):null,l==="efforts"?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("div",{className:"dci-menuLabel",children:v("menu.reasoning")}),(()=>{let D=S?.model.reasoning;if(!D)return(0,J.jsx)("div",{className:"dci-empty",children:v("menu.reasoningNone")});let R=C?.reasoningEffort??D.defaultEffort;return[...D.defaultEffort===void 0?[{key:"provider-default",effort:void 0,label:"Default"}]:[],...D.efforts.map(M=>({key:`effort:${M.id}`,effort:M.id,label:M.name}))].map(M=>{let K=R===M.effort,X=M.effort===void 0?void 0:D.efforts.find(ye=>ye.id===M.effort);return(0,J.jsxs)("button",{type:"button",className:"dci-item",disabled:i,title:X?.description,onClick:()=>S&&void z(S.group,S.model,M.effort),children:[(0,J.jsx)("span",{className:"dci-itemLabel",children:M.label}),K?(0,J.jsx)("span",{className:"dci-check","aria-hidden":"true",children:(0,J.jsx)(bs,{size:16})}):null]},M.key)})})()]}):null]})}):null]})}var Dg=require("react");var lr=require("react/jsx-runtime"),bv="conversation.input.model";function wv(){let n=Kn(bv);return(0,Dg.useMemo)(()=>{let e=sr(n);return e!==null&&Tg(e)?e:null},[n])}function Og(n){let{sessionId:e,standard:t,locked:i,fallback:r}=n,s=wv();return e===void 0||s===null?(0,lr.jsx)(lr.Fragment,{children:r}):Mg(s,e)?(0,lr.jsx)(lr.Fragment,{children:r}):tl(s,`model:${el(s,0)}`,{sessionId:e,standard:t,ownerProps:{locked:i},fallback:r})}var It=require("react");var rl=["read-only","workspace-write","danger-full-access"];function Pg(n){return Ii(`perm.preset.${n}`)??n}function Ti(){return{title:v("perm.confirmTitle"),description:v("perm.warning"),acknowledgeLabel:v("perm.ack"),cancelLabel:v("perm.cancel"),enableLabel:v("perm.confirmEnable")}}function vd(n,e){return rl.includes(n)&&(e===n||e===Pg(n))?Pg(n):/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)?e.split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" "):e}async function yv(n,e){let t=Y.sessions?.binding(n)?.session;if(!t||typeof t.command!="function")return null;try{let i=await t.command(`/permission ${e}`);return i?.ok?i.value?.matched===!1?{ok:!1,via:"command",message:v("perm.channelRejected")}:(Nl(e),{ok:!0,via:"command"}):{ok:!1,via:"command",message:v("perm.channelRejected")}}catch(i){return Zt("permission command failed",i),{ok:!1,via:"command",message:String(i)}}}function xv(n,e,t){try{return e.setDraft(`/permission ${n}`),e.submit(),setTimeout(()=>{try{e.setDraft(t)}catch(i){Zt("permission draft restore failed",i)}},600),Nl(n),{ok:!0,via:"draft-exchange"}}catch(i){return Zt("permission draft-exchange failed",i),{ok:!1,via:"draft-exchange",message:String(i)}}}async function Ig(n,e,t,i){let r=await yv(n,e);return r||(t?xv(e,t,i):{ok:!1,via:"draft-exchange",message:v("perm.noInputSurface")})}var ee=require("react/jsx-runtime"),Ng="danger-full-access";function kd(n){if(n==="read-only")return(0,ee.jsx)(Sh,{size:16});if(n==="workspace-write")return(0,ee.jsx)(Ch,{size:16});if(n===Ng)return(0,ee.jsx)(Th,{size:16})}function Bg(n){let{sessionId:e,actions:t,currentDraft:i,useProjection:r,disabled:s,onNotify:o}=n,l=r?r("permissions"):void 0,[a,c]=(0,It.useState)(null),[d,u]=(0,It.useState)(!1),[h,f]=(0,It.useState)(null),[p,m]=(0,It.useState)(!1),w=(0,It.useRef)(null),[b,k]=(0,It.useState)(null),[C,P]=(0,It.useState)(null);if((0,It.useEffect)(()=>{s||l===void 0&&(u(!1),m(!1),f(null))},[s,l]),!l||typeof l.currentValue!="string")return null;let S=a!==null||h!==null,x=a??l.currentValue,T=vd(x,x),W=[...rl,...rl.includes(x)?[]:[x]].map(M=>({id:M,label:vd(M,M),icon:kd(M)})),H=()=>u(!1),z=M=>{e&&(c(M),Ig(e,M,t,i).then(K=>{K.ok||o?.("error",K.message??v("perm.switchFailed"))}).finally(()=>c(null)))},D=M=>{if(H(),M!==l.currentValue){if(M===Ng){m(!1),f(M);return}z(M)}},R=()=>{m(!1),f(null)},F=()=>{if(s||!p||h===null)return;let M=h;R(),z(M)};return(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsxs)("button",{ref:w,type:"button",className:"dci-trigger","aria-label":v("perm.trigger",{name:T}),title:void 0,disabled:s||S,onMouseDown:M=>M.preventDefault(),onClick:()=>{if(!d){let M=w.current??null;k(M),P(M?M.getBoundingClientRect():null)}u(!d)},children:[kd(x)!==void 0?(0,ee.jsx)("span",{className:"dci-triggerIcon","aria-hidden":"true",children:kd(x)}):null,(0,ee.jsx)("span",{className:"dci-triggerLabel",children:T}),(0,ee.jsx)("span",{className:"dci-chev","data-open":d,children:(0,ee.jsx)(en,{size:14})})]}),d&&b?(0,ee.jsx)(or,{anchor:b,initialRect:C,onClose:H,children:W.map(M=>{let K=M.id===x;return(0,ee.jsxs)("button",{type:"button",className:"dci-item",disabled:S,onClick:()=>D(M.id),children:[M.icon!==void 0?(0,ee.jsx)("span",{className:"dci-itemIcon","aria-hidden":"true",children:M.icon}):null,(0,ee.jsx)("span",{className:"dci-itemLabel",children:M.label}),K?(0,ee.jsx)("span",{className:"dci-check","aria-hidden":"true",children:(0,ee.jsx)(bs,{size:16})}):null]},M.id)})}):null,(0,ee.jsx)(vv,{open:h!==null,acknowledged:p,disabled:s===!0,onAcknowledgedChange:m,onCancel:R,onConfirm:F})]})}function vv(n){let{open:e,acknowledged:t,disabled:i,onAcknowledgedChange:r,onCancel:s,onConfirm:o}=n;return(0,It.useEffect)(()=>{if(!e)return;let l=a=>{a.key==="Escape"&&s()};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[e]),e?(0,ee.jsxs)("div",{className:"dci-modal-root",role:"presentation",children:[(0,ee.jsx)("div",{className:"dci-modal-mask","aria-hidden":"true",onClick:s}),(0,ee.jsxs)("div",{className:"dci-modal-dialog dci-confirm",role:"dialog","aria-modal":"true","aria-label":Ti().title,children:[(0,ee.jsxs)("div",{className:"dci-modal-content",children:[(0,ee.jsxs)("div",{className:"dci-modal-header",children:[(0,ee.jsx)("h2",{className:"dci-modal-title",children:Ti().title}),(0,ee.jsx)("button",{type:"button",className:"dci-modal-close","aria-label":v("perm.close"),onClick:s,children:(0,ee.jsx)(bh,{size:14})})]}),(0,ee.jsxs)("div",{className:"dci-modal-body",children:[(0,ee.jsxs)("div",{className:"dci-confirm-warning",children:[(0,ee.jsx)("span",{className:"dci-confirm-warningIcon","aria-hidden":"true",children:(0,ee.jsx)(Ah,{size:18})}),(0,ee.jsx)("p",{children:Ti().description})]}),(0,ee.jsxs)("label",{className:"dci-confirm-ack",children:[(0,ee.jsx)("input",{type:"checkbox",checked:t,disabled:i,autoFocus:!0,onChange:l=>r(l.currentTarget.checked)}),(0,ee.jsx)("span",{children:Ti().acknowledgeLabel})]})]})]}),(0,ee.jsxs)("div",{className:"dci-modal-footer",children:[(0,ee.jsx)("button",{type:"button",className:"dci-btn dci-btn-outline dci-btn-cancel",onClick:s,children:Ti().cancelLabel}),(0,ee.jsx)("button",{type:"button",className:"dci-btn dci-btn-primary dci-btn-confirm",disabled:i||!t,onClick:o,children:Ti().enableLabel})]})]})]}):null}var un=require("react");var kv="conversation.input.activity",Sv="voice-input",_g=new WeakMap,Hg=new WeakMap;function Cv(n,e){if(typeof n.inject!="function")return null;let t=Hg.get(n);if(t||(t=new Map,Hg.set(n,t)),!t.has(e)){let i=null;try{i=n.inject(e)??null}catch(r){me("voice.inject",r),i=null}t.set(e,i)}return t.get(e)??null}function Tv(n){let e=n;if(!e||typeof e.subscribe!="function"||typeof e.getSnapshot!="function")return null;let t=_g.get(e);return t||(t=i=>(0,un.useSyncExternalStore)(r=>e.subscribe(r)??(()=>{}),()=>i(e.getSnapshot()),()=>i(e.getSnapshot())),_g.set(e,t)),t}function Fg(n){let{sessionId:e,inputActions:t,locked:i,onActiveChange:r}=n,s=Kn(kv),o=(0,un.useMemo)(()=>sr(s),[s]),l=(0,un.useMemo)(()=>o&&e?Cv(o,e):null,[o,e]),a=(0,un.useMemo)(()=>o?ps(o,Sv):null,[o]),c=l?.hooks?.speechReadiness,d=(0,un.useMemo)(()=>Tv(c),[c]);if(!o||!e||!l||!a||!d)return null;let{hooks:u,...h}=l;return(0,un.createElement)(Ci,{children:(0,un.createElement)(o.component,{sessionId:e,inputActions:t,locked:i,onActiveChange:r,...h,useSpeechReadiness:d,t:a})})}var zg=require("react");var ol=require("react/jsx-runtime");function sl(n){let{slot:e,sessionId:t,standard:i}=n,r=Kn(e),s=(0,zg.useMemo)(()=>Cg(r),[r]);return t===void 0||s.length===0?null:(0,ol.jsx)(ol.Fragment,{children:s.map((o,l)=>tl(o,el(o,l),{sessionId:t,standard:i}))})}var Vg=require("react/jsx-runtime"),Av="conversation.input.left";function Wg(n){return(0,Vg.jsx)(sl,{slot:Av,sessionId:n.sessionId,standard:n.standard})}var Ug=require("react/jsx-runtime"),Mv="conversation.input.right";function $g(n){return(0,Ug.jsx)(sl,{slot:Mv,sessionId:n.sessionId,standard:n.standard})}var Ue=require("react/jsx-runtime");function jg(n){n.preventDefault()}function Kg(n){let{sessionId:e,state:t,actions:i,triggers:r,caretRef:s,useProjection:o,disabled:l,onNotify:a,inputStandard:c}=n;St();let d=t?.attachmentIds??[],[u,h]=(0,ll.useState)(!1),f=(0,ll.useCallback)(m=>h(m),[]),p=()=>{r&&rg(r,void 0,s.current??0)};return(0,Ue.jsxs)("div",{className:"dci-row","data-voice-active":u||void 0,children:[(0,Ue.jsxs)("div",{className:"dci-tools",children:[(0,Ue.jsx)("button",{type:"button",className:"dci-add","aria-label":v("tool.command"),"aria-haspopup":"listbox",title:v("tool.command"),disabled:!r,onMouseDown:jg,onClick:p,children:(0,Ue.jsx)(vh,{size:14})}),(0,Ue.jsx)(Bg,{sessionId:e,actions:i,currentDraft:t?.draft??"",useProjection:o,disabled:l,onNotify:a}),t!==void 0&&e!==void 0?(0,Ue.jsx)(Wg,{sessionId:e,standard:c}):null]}),(0,Ue.jsxs)("div",{className:"dci-trailing",children:[(0,Ue.jsxs)("div",{className:"dci-standard-controls",children:[t!==void 0&&e!==void 0?(0,Ue.jsx)($g,{sessionId:e,standard:c}):null,(0,Ue.jsx)(Og,{sessionId:e,standard:c,locked:l===!0,fallback:(0,Ue.jsx)(Lg,{sessionId:e,onNotify:a})})]}),(0,Ue.jsx)("div",{className:"dci-voice-seat",children:(0,Ue.jsx)(Fg,{sessionId:e,inputActions:i,locked:l===!0,onActiveChange:f})}),(0,Ue.jsx)("button",{type:"button",className:"dci-send","aria-label":n.primaryStops?v("tool.stop"):v("tool.send"),title:n.primaryStops?v("tool.stop"):v("tool.send"),disabled:n.primaryStops?!n.onStop:n.sendDisabled,onMouseDown:jg,onClick:()=>n.primaryStops?n.onStop?.():n.onSend(),children:n.primaryStops?(0,Ue.jsx)(Eh,{size:16}):(0,Ue.jsx)(Mh,{size:16})})]})]})}var pt=require("react"),Ad=require("react-dom");var ws=["tokenUsage","contextPressure","sessionUsage","usage","sessionStats"];function Se(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function Ev(n){if(!n||typeof n!="object")return;let e=n,t={cacheReadTokens:Se(e.cacheReadTokens),cacheWriteTokens:Se(e.cacheWriteTokens),outputTokens:Se(e.outputTokens),uncachedInputTokens:Se(e.uncachedInputTokens)};return Object.values(t).some(i=>i!==void 0)?t:void 0}function Rv(n){if(!n||typeof n!="object")return;let e=n,t={contextWindow:Se(e.contextWindow),pressureTokens:Se(e.pressureTokens),projectedTokens:Se(e.projectedTokens)};return t.contextWindow!==void 0&&t.pressureTokens!==void 0?t:void 0}function Lv(n){if(!n||typeof n!="object")return;let e=n,t={turns:Se(e.turns),steps:Se(e.steps),llmMs:Se(e.llmMs),toolMs:Se(e.toolMs),ttftMs:Se(e.ttftMs),ttftSteps:Se(e.ttftSteps),decodeMs:Se(e.decodeMs),decodeTokens:Se(e.decodeTokens)};return Object.values(t).some(i=>i!==void 0)?t:void 0}function Dv(n){if(!Array.isArray(n))return;let e=new Set,t=0,i=0,r=0,s=0,o=0,l=0,a=0;for(let c of n){if(!c||typeof c!="object")continue;let d=c;if(d.kind==="tool-result"){let b=Se(d.callTime),k=Se(d.time);b!==void 0&&k!==void 0&&(r+=Math.max(0,k-b));continue}if(d.kind!=="assistant")continue;e.add(d.turn),t+=1;let u=d.timing,h=Se(u?.stepStartTime),f=Se(u?.firstTokenTime),p=Se(u?.completedTime);h!==void 0&&p!==void 0&&(i+=Math.max(0,p-h)),h!==void 0&&f!==void 0&&(s+=Math.max(0,f-h),o+=1),f!==void 0&&p!==void 0&&(l+=Math.max(0,p-f));let m=d.usage,w=Se(m?.outputTokens);w!==void 0&&w>=0&&(a+=w)}if(n.length!==0)return{turns:e.size,steps:t,llmMs:i,toolMs:r,ttftMs:s,ttftSteps:o,decodeMs:l,decodeTokens:a}}function Sd(n){let e=Math.max(0,n);return e>=10?String(Math.round(e)):String(Math.round(e*10)/10)}function Cd(n,e){if(e<=0)return null;if(n>=e)return"100";for(let t=0;t<20;t++){let i=10**t,r=Math.round(n/e*100*i)/i;if(r<100)return t===0?String(r):r.toFixed(t)}return"99.99"}function al(n){let e=n/1e3;if(e<60)return`${Math.round(e*10)/10}s`;let t=Math.round(e);return`${Math.floor(t/60)}\u5206${t%60}\u79D2`}function Gg(n,e,t){let i=n?n(ws[0]):void 0,r=n?n(ws[1]):void 0,s=n?n(ws[2]):void 0,o=n?n(ws[3]):void 0,l=n?n(ws[4]):void 0,a=Ev(i),c=Rv(r),d=Lv(l)??Dv(t)??Ov(s,o),u={};if(d&&((d.turns!==void 0||d.steps!==void 0)&&(u.turns=d.turns,u.steps=d.steps),d.llmMs!==void 0&&(u.llmMs=d.llmMs),d.toolMs!==void 0&&(u.toolMs=d.toolMs),d.ttftMs!==void 0&&(u.ttftMs=d.ttftMs),d.ttftSteps!==void 0&&(u.ttftSteps=d.ttftSteps),d.decodeMs!==void 0&&(u.decodeMs=d.decodeMs),d.decodeTokens!==void 0&&(u.decodeTokens=d.decodeTokens),(d.decodeMs??0)>0&&(u.tokensPerSecond=(d.decodeTokens??0)/(d.decodeMs/1e3))),a){let p=(a.cacheReadTokens??0)+(a.cacheWriteTokens??0)+(a.outputTokens??0)+(a.uncachedInputTokens??0);p>0&&(u.totalTokens=p,u.uncachedInputTokens=a.uncachedInputTokens,u.cacheReadTokens=a.cacheReadTokens,u.cacheWriteTokens=a.cacheWriteTokens,u.outputTokens=a.outputTokens);let m=(a.cacheReadTokens??0)+(a.cacheWriteTokens??0)+(a.uncachedInputTokens??0);if(m>0){let w=Cd(a.cacheReadTokens??0,m);w!==null&&(u.cacheHitText=w)}}let h=c?.contextWindow,f=c?.projectedTokens??c?.pressureTokens;return h!==void 0&&h>0&&f!==void 0&&(u.contextPct=f/h*100),Object.keys(u).length>0?u:null}function Ov(n,e){let t=i=>{if(!i||typeof i!="object")return;let r=i,s=Se(r.turns)??Se(r.turnCount),o=Se(r.steps)??Se(r.stepCount);return s!==void 0||o!==void 0?{turns:s,steps:o}:void 0};return t(n)??t(e)}function cl(n){let e=t=>t>=100?String(Math.round(t)):String(Math.round(t*10)/10);return n<1e3?`${n} tok`:n<1e6?`${e(n/1e3)}K tok`:`${e(n/1e6)}M tok`}var B=require("react/jsx-runtime");function Td({size:n=14}){return(0,B.jsxs)("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,B.jsx)("path",{d:"M3.49 13.26A6.375 6.375 0 1 1 12.51 13.26",stroke:"currentColor",strokeWidth:"1.25"}),(0,B.jsx)("path",{d:"M8 8.75L11.4 5.35",stroke:"currentColor",strokeWidth:"1.25"}),(0,B.jsx)("circle",{cx:"8",cy:"8.75",r:"1.55",fill:"currentColor"})]})}function qg({size:n=14}){return(0,B.jsxs)("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,B.jsx)("ellipse",{cx:"8",cy:"3.6",rx:"5.75",ry:"2.4",stroke:"currentColor",strokeWidth:"1.25"}),(0,B.jsx)("path",{d:"M2.25 3.6V12.3A5.75 2.4 0 0 0 13.75 12.3V3.6",stroke:"currentColor",strokeWidth:"1.25"}),(0,B.jsx)("path",{d:"M2.25 7.95A5.75 2.4 0 0 0 13.75 7.95",stroke:"currentColor",strokeWidth:"1.25"})]})}function Pv(n,e,t,i,r){let[s,o]=(0,pt.useState)(null);return(0,pt.useLayoutEffect)(()=>{if(!n){o(null);return}let l=()=>{let u=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--dsh-frame-top-clearance"));return Number.isNaN(u)?r:Math.max(r,(document.documentElement.hasAttribute("data-fullscreen")?0:u)+20)},a=()=>{let u=e.current?.getBoundingClientRect();if(u===void 0)return;let h=t.current,f=h?.offsetWidth??0,p=h?.offsetHeight??0,m=u.left,w=u.top-i-p;f>0&&(m=Math.min(Math.max(m,r),window.innerWidth-f-r)),p>0&&(w=Math.min(Math.max(w,l()),window.innerHeight-p-r)),o(b=>b&&b.left===m&&b.top===w?b:{left:m,top:w})};a(),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a);let c=t.current,d=null;return typeof ResizeObserver<"u"&&c!==null&&(d=new ResizeObserver(a),d.observe(c)),()=>{d?.disconnect(),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[n,e,t,i,r]),s}function Md(n,e){let t=(0,pt.useRef)(null),i=(0,pt.useRef)(null),r=Pv(n,t,i,8,12);return(0,pt.useEffect)(()=>{if(!n)return;let s=l=>{l.target instanceof Node&&t.current?.contains(l.target)!==!0&&i.current?.contains(l.target)!==!0&&e()},o=l=>{l.key==="Escape"&&e()};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",o),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",o)}},[n,e]),{rootRef:t,panelRef:i,position:r}}function Jg(n){return n??{visibility:"hidden",left:0,top:0}}function Yg(n){let{label:e,icon:t,titleValue:i,rows:r,panelRef:s,position:o}=n;return(0,Ad.createPortal)((0,B.jsxs)("div",{className:"dci-stat-panel",role:"dialog","aria-label":e,ref:s,style:Jg(o),children:[(0,B.jsxs)("div",{className:"dci-stat-panelTitle",children:[(0,B.jsxs)("span",{className:"dci-stat-panelLabel",children:[t,e]}),i!==void 0?(0,B.jsx)("span",{className:"dci-stat-panelValue",children:i}):null]}),(0,B.jsx)("div",{className:"dci-stat-panelRule","aria-hidden":"true"}),(0,B.jsx)("dl",{className:"dci-stat-details",children:r.map(([l,a])=>(0,B.jsxs)("div",{style:{display:"contents"},children:[(0,B.jsx)("dt",{children:l}),(0,B.jsx)("dd",{children:a})]},l))})]}),document.body)}function ys(n){let e=String(n??0),t=[];for(let i=e.length;i>0;i-=3)t.unshift(e.slice(Math.max(0,i-3),i));return`${t.join(",")} tok`}function Iv(n){let{stats:e,open:t,onToggle:i,onClose:r}=n,{rootRef:s,panelRef:o,position:l}=Md(t,r),a=v("stats.turns",{turns:e.turns??0,steps:e.steps??0}),c=(e.decodeMs??0)>0?Sd((e.decodeTokens??0)/((e.decodeMs??1)/1e3)):null,d=(e.llmMs??0)>0||(e.toolMs??0)>0||(e.ttftSteps??0)>0||(e.decodeMs??0)>0,u=(0,B.jsxs)("span",{className:"dci-stat-label",children:[a,c!==null?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("span",{className:"dci-stat-sep","aria-hidden":"true",children:"\xB7"}),v("stats.tps",{tps:c})]}):null]});return d?(0,B.jsxs)("span",{className:"dci-stat-anchor",ref:s,children:[(0,B.jsxs)("button",{type:"button",className:"dci-stat-pill","aria-haspopup":"dialog","aria-expanded":t,"aria-label":c!==null?`${a} \xB7 ${v("stats.tps",{tps:c})}`:a,onClick:i,children:[(0,B.jsx)(Td,{}),u]}),t?(0,B.jsx)(Yg,{label:v("stats.session"),icon:(0,B.jsx)(Td,{}),panelRef:o,position:l,rows:[[v("stats.modelTime"),(e.llmMs??0)>0?al(e.llmMs):"\u2014"],[v("stats.toolTime"),(e.toolMs??0)>0?al(e.toolMs):"\u2014"],[v("stats.ttft"),(e.ttftSteps??0)>0?al(e.ttftMs/e.ttftSteps):"\u2014"],[v("stats.tpsLabel"),(e.decodeMs??0)>0?v("stats.tps",{tps:Sd((e.decodeTokens??0)/((e.decodeMs??1)/1e3))}):"\u2014"]]}):null]}):(0,B.jsx)("span",{className:"dci-stat-anchor",ref:s,children:(0,B.jsxs)("span",{className:"dci-stat-pill",children:[(0,B.jsx)(Td,{}),u]})})}function Nv(n){let{stats:e,open:t,onToggle:i,onClose:r}=n,{rootRef:s,panelRef:o,position:l}=Md(t,r);if(e.totalTokens===void 0)return null;let a=e.totalTokens,c=e.cacheHitText??Cd(e.cacheReadTokens??0,(e.cacheReadTokens??0)+(e.cacheWriteTokens??0)+(e.uncachedInputTokens??0));return(0,B.jsxs)("span",{className:"dci-stat-anchor",ref:s,children:[(0,B.jsxs)("button",{type:"button",className:"dci-stat-pill","aria-haspopup":"dialog","aria-expanded":t,"aria-label":c!==null?`${cl(a)} \xB7 ${v("stats.cacheHit",{percent:c})}`:cl(a),onClick:i,children:[(0,B.jsx)(qg,{}),(0,B.jsxs)("span",{className:"dci-stat-label",children:[cl(a),c!==null?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("span",{className:"dci-stat-sep","aria-hidden":"true",children:"\xB7"}),v("stats.cacheHit",{percent:c})]}):null]})]}),t?(0,B.jsx)(Yg,{label:v("stats.usage"),icon:(0,B.jsx)(qg,{}),titleValue:ys(a),panelRef:o,position:l,rows:[[v("stats.cacheHitLabel"),c!==null?`${c}%`:"\u2014"],[v("stats.uncached"),ys(e.uncachedInputTokens)],[v("stats.cacheRead"),ys(e.cacheReadTokens)],...e.cacheWriteTokens?[[v("stats.cacheWrite"),ys(e.cacheWriteTokens)]]:[],[v("stats.output"),ys(e.outputTokens)]]}):null]})}function Ed(n){let{useProjection:e,sessionId:t,chatNodes:i}=n,[r,s]=(0,pt.useState)(null),o=(0,pt.useCallback)(()=>s(null),[]),l=(0,pt.useCallback)(u=>{s(h=>h===u?null:u)},[]),a=Gg(e,t,i),c=e?e("contextPressure"):void 0,d=c!==void 0&&!!c.contextWindow;return(0,pt.useEffect)(()=>{if(r===null)return;(r==="gauge"?d:a!=null)||s(null)},[r,d,a]),!a&&!d?null:(0,B.jsxs)("div",{className:"dci-stat-root","data-composer-stats":"codinput",children:[a?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Iv,{stats:a,open:r==="rounds",onToggle:()=>l("rounds"),onClose:o}),(0,B.jsx)(Nv,{stats:a,open:r==="tokens",onToggle:()=>l("tokens"),onClose:o})]}):null,(0,B.jsx)(Bv,{useProjection:e,open:r==="gauge",onToggle:()=>l("gauge"),onClose:o})]})}var Xg=2*Math.PI*5.5;function xs(n){return n>=1e6?`${(n/1e6).toFixed(n%1e6===0?0:1)}M`:n>=1e3?`${(n/1e3).toFixed(n%1e3===0?0:1)}K`:`${n}`}function Bv(n){let{useProjection:e,open:t,onToggle:i,onClose:r}=n,{rootRef:s,panelRef:o,position:l}=Md(t,r),a=e?e("contextPressure"):void 0,c=e?e("contextBreakdown"):void 0;if(!a||!a.contextWindow)return null;let d=a.contextWindow,u=a.projectedTokens??a.pressureTokens??0,h=Math.min(100,Math.round(u/d*100)),f=h/100*Xg,p=[["dci-gauge-colorSystem",c?.systemTokens??0],["dci-gauge-colorTools",c?.toolsTokens??0],["dci-gauge-colorMessages",c?.messageTokens??0]];return(0,B.jsxs)("span",{className:"dci-gauge-root",ref:s,children:[(0,B.jsxs)("button",{type:"button",className:"dci-gauge-trigger","aria-label":v("tool.context",{percent:Math.round(h)}),"aria-haspopup":"dialog","aria-expanded":t,title:v("tool.context",{percent:Math.round(h)}),onClick:i,children:[(0,B.jsxs)("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[(0,B.jsx)("circle",{className:"dci-gauge-track",cx:"7",cy:"7",r:"5.5"}),(0,B.jsx)("circle",{className:"dci-gauge-fill",cx:"7",cy:"7",r:"5.5",strokeDasharray:`${f} ${Xg}`,transform:"rotate(-90 7 7)"})]}),(0,B.jsxs)("span",{children:[Math.round(h),"%"]})]}),t?(0,Ad.createPortal)((0,B.jsxs)("div",{className:"dci-gauge-panel",role:"dialog","aria-label":v("tool.contextTitle"),ref:o,style:Jg(l),children:[(0,B.jsxs)("div",{className:"dci-gauge-header",children:[(0,B.jsx)("span",{className:"dci-gauge-headline",children:v("tool.contextTitle")}),(0,B.jsxs)("span",{className:"dci-gauge-percent",children:[Math.round(h),"%"]}),(0,B.jsxs)("span",{className:"dci-gauge-figures",children:["~",xs(u)," / ",xs(d)]})]}),(0,B.jsx)("div",{className:"dci-gauge-bar",children:p.map(([m,w])=>(0,B.jsx)("div",{className:`dci-gauge-segment ${m}`,style:{width:`${w/d*100}%`}},m))}),(0,B.jsxs)("dl",{className:"dci-gauge-rows",children:[(0,B.jsxs)("div",{className:"dci-gauge-row",children:[(0,B.jsxs)("dt",{children:[(0,B.jsx)("span",{className:"dci-gauge-swatch dci-gauge-colorSystem","aria-hidden":"true"}),v("stats.prompt")]}),(0,B.jsxs)("dd",{children:["~",xs(c?.systemTokens??0)]})]}),(0,B.jsxs)("div",{className:"dci-gauge-row",children:[(0,B.jsxs)("dt",{children:[(0,B.jsx)("span",{className:"dci-gauge-swatch dci-gauge-colorTools","aria-hidden":"true"}),v("stats.tools")]}),(0,B.jsxs)("dd",{children:["~",xs(c?.toolsTokens??0)]})]}),(0,B.jsxs)("div",{className:"dci-gauge-row",children:[(0,B.jsxs)("dt",{children:[(0,B.jsx)("span",{className:"dci-gauge-swatch dci-gauge-colorMessages","aria-hidden":"true"}),v("stats.messages")]}),(0,B.jsxs)("dd",{children:["~",xs(c?.messageTokens??0)]})]})]})]}),document.body):null]})}var Le=require("react/jsx-runtime");ae.setOptions({gfm:!0,breaks:!0});var _v=Ar??Mr;function dl(n){let{sessionId:e,state:t,actions:i,useProjection:r,inputStandard:s,placeholder:o,disabled:l,blocked:a,running:c,side:d,hero:u,chatNodes:h,float:f,onDragZonePointerDown:p}=n;St();let[m,w]=(0,Pe.useState)(()=>ue().defaultEdit),[b,k]=(0,Pe.useState)(()=>ue().defaultPreview),[C,P]=(0,Pe.useState)(()=>ue().composerBodyHeight),[S,x]=(0,Pe.useState)(!1),T=(0,Pe.useRef)(null),W=(0,Pe.useRef)(null),H=(0,Pe.useRef)(null),z=(0,Pe.useRef)(null),D=G=>{G.preventDefault();let Z=G.currentTarget,Ie=G.clientY,Mn=C??Math.max(60,T.current?.querySelector(".dci-body")?.getBoundingClientRect().height??0);Z.dataset.dragging="true";let We=C,En=Ts=>{We=Math.round(Math.min(window.innerHeight-260,Math.max(96,Mn-(Ts.clientY-Ie)))),P(We)},Bt=()=>{Z.dataset.dragging="false",window.removeEventListener("pointermove",En),window.removeEventListener("pointerup",Bt),window.removeEventListener("pointercancel",Bt),ct({composerBodyHeight:We})};try{Z.setPointerCapture(G.pointerId)}catch{}window.addEventListener("pointermove",En),window.addEventListener("pointerup",Bt),window.addEventListener("pointercancel",Bt)},[R,F]=(0,Pe.useState)(0);(0,Pe.useEffect)(()=>{!m&&!b&&w(!0)},[m,b]);let M=()=>{if(!(!e||!Y.conversation))try{return Y.conversation.input.inputTriggers(e)??void 0}catch{return}},K=()=>{if(!(!e||!Y.conversation))try{return Y.conversation.input.keyboard(e)}catch{return}},X=M(),ye=K();(0,Pe.useEffect)(()=>{if(!e||X&&ye)return;let G=window.setInterval(()=>F(Ie=>Ie+1),300),Z=window.setTimeout(()=>window.clearInterval(G),1e4);return()=>{window.clearInterval(G),window.clearTimeout(Z)}},[e,X,ye]);let et=(0,Pe.useMemo)(()=>{if(!(!e||!Y.sessions||!Y.commandUi)&&typeof Y.commandUi.popupFor=="function")try{return Y.commandUi.popupFor(Y.sessions.scope(e))}catch{return}},[e,R]);(0,Pe.useEffect)(()=>{if(e)return hh(e)},[e]),(0,Pe.useEffect)(()=>{if(!e||!Y.commandUi)return;let G=Y.commandUi;if(typeof G.bindComposerFocus=="function")return G.bindComposerFocus(e,()=>W.current?.focus())},[e]),(0,Pe.useEffect)(()=>{Ll(e??null);let G=Oe();return e&&(X&&(G.__dshCodinputTriggers[e]=X),ye&&(G.__dshCodinputKeyboard[e]=ye),G.__dshCodinputShell[e]={surface:!0,side:d===!0}),()=>{Ll(null)}},[e,X,ye,d]);let Ce=G=>{H.current=G},ot=()=>{if(e)try{Y.sessions?.scope(e)?.get?.("conversation")?.cancel?.()?.catch?.(()=>{})}catch{}},Ke=()=>{if(!i)return;let G=t,Z=!G||G.draft.trim()==="",Ie=!G||G.attachmentIds.length===0;if(Z&&Ie){ye?.steerQueue();return}i.submit()},Xe=l===!0||a===!0,kt=(t?.draft??"").trim()==="",ie=(t?.attachmentIds.length??0)===0,An=c===!0&&kt&&ie,Mi=Xe||i===void 0||t!==void 0&&t.phase==="submitting"||kt&&ie,dr=(0,Pe.useMemo)(()=>_v.sanitize(ae.parse(t?.draft??"")),[t?.draft,b]),pl=G=>{if(!m||!b)return;let Z=G.target,Ie=W.current?.scrollDOM,Mn=z.current;if(!Ie||!Mn)return;let We=Z===Ie?Mn:Z===Mn?Ie:null;if(!We)return;let En=Z.scrollHeight-Z.clientHeight;if(En<=0)return;let Bt=Z.scrollTop/En*(We.scrollHeight-We.clientHeight);Math.abs(We.scrollTop-Bt)>1&&(We.scrollTop=Bt)};(0,Pe.useEffect)(()=>{if(!m||!b)return;let G=W.current?.scrollDOM,Z=z.current;if(!G||!Z)return;let Ie=G.scrollHeight-G.clientHeight;Ie<=0||(Z.scrollTop=G.scrollTop/Ie*(Z.scrollHeight-Z.clientHeight))},[m,b,dr,e]);let ml=()=>{!m&&b?w(!0):m&&b&&w(!1)},gl=()=>{!b&&m?k(!0):b&&m&&k(!1)},ks=o??v("editor.placeholder"),Ss=Zg(e);return(0,Le.jsxs)("div",{className:"dci-surface","data-side":d||void 0,"data-float":f||void 0,children:[(0,Le.jsxs)("div",{className:"dci-card","data-composer-card":"codinput","data-drop":S||void 0,ref:T,onPasteCapture:G=>{let Z=G.clipboardData?.files;!Z||Z.length===0||(G.preventDefault(),G.stopPropagation(),Js(e,i,Z,Ss))},onDragOverCapture:G=>{fh(G.dataTransfer)&&(G.preventDefault(),G.dataTransfer.dropEffect="copy",S||x(!0))},onDragLeave:G=>{G.currentTarget.contains(G.relatedTarget)||x(!1)},onDropCapture:G=>{x(!1);let Z=G.dataTransfer?.files;!Z||Z.length===0||(G.preventDefault(),G.stopPropagation(),Js(e,i,Z,Ss))},children:[(0,Le.jsx)("div",{className:"dci-rip","data-axis":"y","data-side":"top",onPointerDown:D}),(0,Le.jsxs)("div",{className:"dci-accessory",children:[(0,Le.jsx)("button",{type:"button",className:"dci-iconbtn","data-on":m,onClick:ml,title:v("head.edit"),children:(0,Le.jsx)(mh,{size:14})}),(0,Le.jsx)("button",{type:"button",className:"dci-iconbtn","data-on":b,onClick:gl,title:v("head.preview"),children:(0,Le.jsx)(gh,{size:14})}),d?null:(0,Le.jsx)("div",{className:"dci-float-dragzone",onPointerDown:p})]}),i&&(t?.attachmentIds.length??0)>0?(0,Le.jsx)(wg,{state:t,sessionId:e,onRemove:G=>{let Z=Y.conversation;i.removeAttachment(G);try{Z?.releaseDraftAttachment(G)}catch(Ie){me("attachments",Ie)}}}):null,(0,Le.jsxs)("div",{className:"dci-body","data-split":m&&b,onScrollCapture:pl,style:!d&&!f&&C!==null?{"--dci-body-h":`${C}px`,"--dci-body-max":`${C}px`}:void 0,children:[m?(0,Le.jsx)(cg,{state:t,actions:i,triggers:X,keyboard:ye,onSendGesture:Ke,placeholder:ks,viewRef:W,onCaretMoved:Ce,disabled:Xe,autoFocus:!0,solo:!b,stateKey:e??"hero"}):null,b?(0,Le.jsx)("div",{className:"dci-preview","data-solo":!m,ref:z,children:dr?(0,Le.jsx)("div",{dangerouslySetInnerHTML:{__html:dr}}):(0,Le.jsx)("span",{style:{opacity:.4},children:v("preview.empty")})}):null]}),(0,Le.jsx)(Kg,{sessionId:e,state:t,actions:i,triggers:X,caretRef:H,useProjection:r,disabled:Xe,primaryStops:An,onStop:ot,onNotify:Zg(e),onSend:Ke,sendDisabled:Mi,inputStandard:s}),f&&u!==!0?(0,Le.jsx)(Ed,{useProjection:r,sessionId:e,chatNodes:h}):null,X?(0,Le.jsx)(ug,{triggers:X,dropdown:d===!0||f===!0}):null]}),!f&&u!==!0?(0,Le.jsx)(Ed,{useProjection:r,sessionId:e,chatNodes:h}):null,et?(0,Le.jsx)(fg,{popup:et}):null]})}function Zg(n){if(n)return(e,t)=>{try{let i=Y.sessions?.scope(n);if(!i||!Y.conversation)return;Y.conversation.input.for(i).notify(e,t)}catch(i){me("notify",i)}}}var hn=require("react/jsx-runtime"),Rd="dsh-codinput",ul="codinput";function Qg(){return{id:Rd,kind:ul,priority:"extension",title:()=>"Codinput",keepMounted:!0,guide:[{order:0,title:()=>"Codinput",description:()=>v("side.guideDesc"),icon:aa}]}}function e0(){return{options:{name:"sidebar.right.pane.tab",key:Rd,registrant:"dsh-codinput"},component:Fv}}function t0(){return{options:{name:"sidebar.right.pane.tab.title",key:Rd,registrant:"dsh-codinput"},component:Hv}}function Hv(n){let e=n.useTabInfo?.().tab.title??"Codinput";return(0,hn.jsxs)(hn.Fragment,{children:[(0,hn.jsx)(aa,{size:16}),e]})}function Fv(n){let{sessionId:e,useInput:t,inputActions:i,useProjection:r,useSession:s,useTabInfo:o}=n,l=t(x=>x),a=nl(n,["useTabInfo"]),c=s?s(x=>x?.running)===!0:!1;St();let d=o?o():void 0,u=d?.tab.visible===!0,h=d?.sidebar.expanded===!0,f=d?.tab.actions?.close,p=(0,mt.useRef)(f);p.current=f,(0,mt.useEffect)(()=>{let x=Oe().__dshCodinputShell;x["sidebar.tabId"]=d?.tab.id??"none",x["sidebar.closeFace"]=f?"yes":"none"},[d,f]),(0,mt.useEffect)(()=>Mu(x=>{if(!(x!==e||!p.current))try{p.current()}catch(T){me("sidebar.closeTab",T)}}),[e]);let[m,w]=(0,mt.useState)(()=>ue().enabled);(0,mt.useEffect)(()=>pn(()=>w(ue().enabled)),[]);let b=(0,mt.useRef)(!1);(0,mt.useEffect)(()=>{b.current||(b.current=!0,ue().enabled||ct({enabled:!0}))},[]);let k=(0,mt.useRef)(null),[C,P]=(0,mt.useState)(0);(0,mt.useEffect)(()=>{if(!m)return;let x=Su(e,{visible:u,expanded:h});return k.current=x,P(x.token),()=>{k.current=null,x.release()}},[e,m]),(0,mt.useEffect)(()=>{k.current?.set({visible:u,expanded:h})},[u,h]);let S=Eu(e,C);return m?S?(0,hn.jsx)("div",{style:{position:"absolute",inset:0,minHeight:0,display:"flex",flexDirection:"column"},children:(0,hn.jsx)(dl,{sessionId:e,state:l,actions:i,useProjection:r,inputStandard:a,running:c,side:!0})}):(0,hn.jsx)("div",{className:"dci-side-notice",role:"note",children:v("side.notice")}):(0,hn.jsx)("div",{className:"dci-side-notice",role:"note",children:v("side.disabled")})}var Dd=require("react/jsx-runtime"),zv=36,Wv=18,Vv=12,$v=8;function Ld(){return document.querySelector('[role="banner"]')??document.querySelector("header")}function i0(n){let{sessionId:e}=n;St();let{carried:t,collapsed:i}=Lu(e),r=t&&i,[s,o]=(0,hl.useState)(null);return(0,hl.useEffect)(()=>{if(!r){o(null);return}let l=()=>{let u=Ld()?.getBoundingClientRect();if(!u||u.height===0)return;let h={left:Math.round(u.right-Vv-zv),top:Math.round(u.bottom+$v)};o(f=>f&&f.left===h.left&&f.top===h.top?f:h)};l();let a=Ld(),c=typeof ResizeObserver=="function"?new ResizeObserver(l):null;a&&c&&c.observe(a),window.addEventListener("resize",l);let d=window.setInterval(()=>{Ld()&&(l(),window.clearInterval(d))},250);return()=>{c?.disconnect(),window.removeEventListener("resize",l),window.clearInterval(d)}},[r]),!r||!s?null:(0,n0.createPortal)((0,Dd.jsx)("button",{type:"button",className:"dci-ball","data-codinput-expand":"true",style:{left:s.left,top:s.top},"aria-label":v("ball.label"),title:v("ball.title"),onClick:()=>Uv(e),children:(0,Dd.jsx)(ph,{size:Wv})}),document.body)}function Uv(n){let e=Y.sidebarRight;if(e){try{if(n&&typeof e.openTabIn=="function"){e.openTabIn(n,ul);return}if(typeof e.openTab=="function"){e.openTab(ul);return}}catch(t){me("ball.openTab",t)}try{typeof e.isExpanded=="function"&&!e.isExpanded()&&e.toggleExpanded?.()}catch(t){me("ball.expand",t)}}}var Ai=require("react/jsx-runtime");function Id(n){let{variant:e,blocked:t,disabled:i,placeholder:r,sessionId:s,useInput:o,inputActions:l,useProjection:a,useChat:c,useSession:d}=n,u=o(P=>P),h=nl(n),f=c?c(P=>P?.legacy?.nodes):void 0,p=d?d(P=>P?.running)===!0:!1,m=Ru(s),[w,b]=(0,fn.useState)(()=>ue().mode);if((0,fn.useEffect)(()=>pn(()=>b(ue().mode)),[]),m)return(0,Ai.jsx)(i0,{sessionId:s});let k=w==="float",C=(0,Ai.jsx)(dl,{sessionId:s,state:u,actions:l,useProjection:a,inputStandard:h,placeholder:r,disabled:i===!0,blocked:t!==void 0,running:p,hero:e==="hero",chatNodes:f,float:k,onDragZonePointerDown:Xv});return k?(0,Ai.jsx)(Yv,{children:C}):C}var Qe=12,r0=6,Od=720,fl=360,vs=140,jv=6,Kv=12;function Gn(n,e,t){return Math.min(t,Math.max(e,n))}function Nd(){return Math.max(fl,window.innerWidth-Qe*2)}function Gv(){return Math.max(vs,window.innerHeight-Qe*2)}function s0(){let n=ue();return{x:n.floatX??Math.round((window.innerWidth-Math.min(n.floatW??Od,Nd()))/2),y:n.floatY??Math.round(window.innerHeight*.16),w:n.floatW??Od,h:n.floatH}}var ar=null,Pd=new Set;function o0(n,e){for(let t of Pd)t(n,e)}function qv(){let e=document.querySelector("[data-composer-seat]")?.getBoundingClientRect(),t=Math.min(window.innerHeight,(e?.bottom??window.innerHeight)+120),i=Math.max(0,t-300);return{left:(e?.left??0)-40,right:(e?.right??window.innerWidth)+40,top:i,bottom:t}}function Xv(n){if(n.button!==0)return;let e=n.currentTarget,t=e.closest("[data-composer-card]"),i=!!e.closest(".dci-float"),r=t?.getBoundingClientRect(),s=r?.left??n.clientX,o=r?.top??n.clientY,l=r?.width||Math.min(ue().floatW??Od,Nd()),a=b=>Gn(b,Qe,Math.max(Qe,window.innerWidth-l-Qe)),c=b=>Gn(b,Qe,Math.max(Qe,window.innerHeight-96)),d=a(n.clientX-s),u=c(n.clientY-o);n.preventDefault();let h=n.clientX,f=n.clientY,p={grabDX:d,grabDY:u,detached:i,fromFloat:i,lastX:a(n.clientX-d),lastY:c(n.clientY-u)},m=b=>{if(ar){if(!p.detached){if(Math.abs(b.clientX-h)<r0&&Math.abs(b.clientY-f)<r0)return;p.detached=!0,p.lastX=a(b.clientX-p.grabDX),p.lastY=c(b.clientY-p.grabDY),ct({mode:"float",floatX:p.lastX,floatY:p.lastY}),o0(p.lastX,p.lastY);return}p.lastX=a(b.clientX-p.grabDX),p.lastY=c(b.clientY-p.grabDY),o0(p.lastX,p.lastY)}},w=b=>{if(window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w),ar=null,!p.detached)return;let k=qv();if(b.clientX>=k.left&&b.clientX<=k.right&&b.clientY>=k.top&&b.clientY<=k.bottom){ct({mode:"normal"});return}ct({floatX:p.lastX,floatY:p.lastY})};ar=p,window.addEventListener("pointermove",m),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w)}var Jv=["n","s","e","w","nw","ne","sw","se"];function Yv(n){let{children:e}=n,t=(0,fn.useRef)(null),[i,r]=(0,fn.useState)(()=>ar?{...s0(),x:ar.lastX,y:ar.lastY}:s0()),s=(0,fn.useRef)(i);s.current=i,(0,fn.useLayoutEffect)(()=>{let u=(h,f)=>r(p=>({...p,x:h,y:f}));return Pd.add(u),()=>{Pd.delete(u)}},[]);let o=u=>h=>{if(h.button!==0)return;h.preventDefault(),h.stopPropagation();let f=s.current,m=t.current?.getBoundingClientRect(),w=m?.width??f.w,b=m?.height??f.h??vs,k=f.x,C=f.y,P=k+w,S=C+b,x=h.clientX,T=h.clientY,W=z=>{let D=z.clientX-x,R=z.clientY-T,F=w,M=b,K=k,X=C;u.includes("e")&&(F=Gn(w+D,fl,Math.max(fl,window.innerWidth-Qe-k))),u.includes("w")&&(K=Gn(k+D,Qe,P-fl),F=P-K),u.includes("s")&&(M=Gn(b+R,vs,Math.max(vs,window.innerHeight-Qe-C))),u.includes("n")&&(X=Gn(C+R,Qe,S-vs),M=S-X),r({x:K,y:X,w:Math.round(F),h:Math.round(M)})},H=()=>{window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",H),window.removeEventListener("pointercancel",H);let z=s.current;ct({floatX:z.x,floatY:z.y,floatW:z.w,floatH:z.h})};try{h.currentTarget.setPointerCapture(h.pointerId)}catch{}window.addEventListener("pointermove",W),window.addEventListener("pointerup",H),window.addEventListener("pointercancel",H)},l=Math.min(i.w,Nd()),a=i.h===null?null:Math.min(i.h,Gv()),c=Gn(i.x,Qe,Math.max(Qe,window.innerWidth-l-Qe)),d=Gn(i.y,Qe,Math.max(Qe,window.innerHeight-96));return(0,l0.createPortal)((0,Ai.jsxs)("div",{className:"dci-float",ref:t,"data-sized":a!==null?"true":void 0,style:{left:c,top:d,width:l,height:a??void 0,"--dci-grip-edge":`${jv}px`,"--dci-grip-corner":`${Kv}px`},children:[e,Jv.map(u=>(0,Ai.jsx)("div",{className:"dci-float-grip","data-dir":u,onPointerDown:o(u)},u))]}),document.body)}function a0(){return{options:{name:"conversation.composer.bar",priority:-1,registrant:"dsh-codinput"}}}var He=require("react");var se=require("react/jsx-runtime");function f0(){return["user","steering"].map(n=>({options:{name:"conversation.chat.node",key:n,priority:-1,registrant:"dsh-codinput"},component:vk}))}function Zv(n){let e={text:"",attachments:[],rest:[]};if(!Array.isArray(n))return e;let t=[];for(let i of n){let r=i;r&&r.type==="text"&&typeof r.text=="string"?t.push(r.text):r&&r.type==="image"&&r.attachment!==void 0?e.attachments.push({type:"image",image:{attachment:r.attachment}}):r&&r.type==="file"&&r.attachment!==void 0?e.attachments.push({type:"file",file:r.attachment??{}}):e.rest.push(i)}return e.text=t.join(""),e}var Qv=Ar??Mr,ek={ALLOWED_TAGS:["p","br","strong","em","del","code","pre","blockquote","ul","ol","li","a","img","h1","h2","h3","h4","h5","h6","hr","table","thead","tbody","tr","th","td","input","span"],ALLOWED_ATTR:["href","src","alt","title","target","rel","type","checked","disabled","start","colspan","rowspan","align","data-dci-wire"],ALLOWED_URI_REGEXP:/^(?:https?:|mailto:)/i,FORBID_ATTR:["style"]};function Bd(n){return n.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}var tk=/^@\[([^\]\n]+)\]\(dsh-session:[^)\s]+\)/,nk={name:"dshSessionWire",level:"inline",start(n){let e=n.indexOf("@[");return e<0?void 0:e},tokenizer(n){let e=tk.exec(n);if(e)return{type:"dshSessionWire",raw:e[0],label:e[1]}},renderer(n){let e=String(n.label??"");return`<span data-dci-wire="${Bd(e)}">${Bd(e)}</span>`}},ik=new Zl({gfm:!0,breaks:!0,extensions:[nk]});function rk(n){try{return Qv.sanitize(ik.parse(n),ek)}catch(e){return me("umsg.markdown",e),`<p>${Bd(n).replace(/\n/g,"<br>")}</p>`}}var sk=/[.,;:!?,。;:!?]+$/u,c0=/(^|\s)(\/[\w-]+(?=\s|$)|@"[^"\n]+"|@[^\s]+)/gu;function ok(n){let e=[],t=/@\[([^\]\n]+)\]\(dsh-session:[^)\s]+\)/gu,i;for(;(i=t.exec(n))!==null;)e.push({start:i.index,end:i.index+i[0].length,kind:"session",label:i[0],display:i[1],clickable:!1});return e}function lk(n,e){let t=[];for(let i of[...new Set(e)].sort((r,s)=>s.length-r.length)){let r=`@${i}`,s=n.indexOf(r);for(;s>=0;)t.push({start:s,end:s+r.length,kind:"session",label:r,display:i,clickable:!1}),s=n.indexOf(r,s+r.length)}return t}function ak(n,e){let t=[];c0.lastIndex=0;let i;for(;(i=c0.exec(n))!==null;){let r=i.index+i[1].length,s=i[2],o=s.startsWith('@"')?s:s.replace(sk,"");if(o.length<=1)continue;if(o.startsWith("/")){if(!e.includes(o.slice(1)))continue;t.push({start:r,end:r+o.length,kind:"slash",label:o,display:o,clickable:!0});continue}let l=o.slice(1).replace(/^"|"$/gu,""),a=l.endsWith("/")?"folder":"file",c=l.split(/[\\/]/u).filter(Boolean),d=c[c.length-1]??l;t.push({start:r,end:r+o.length,kind:a,label:o,display:d,clickable:!0})}return t}var p0="http://www.w3.org/2000/svg";function qn(n,e){let t=document.createElementNS(p0,"path");return t.setAttribute("d",n),t.setAttribute(e?"stroke":"fill","currentColor"),t}function ck(n){let e=document.createElementNS(p0,"svg");return e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("fill","none"),e.setAttribute("aria-hidden","true"),e.setAttribute("class","dci-umsg-chipicon"),n==="session"?(e.appendChild(qn("M5 6.75H11",!0)),e.appendChild(qn("M5 9H8",!0)),e.appendChild(qn("M2.37067 11.2497C1.5872 9.89252 1.32042 8.29798 1.61945 6.7597C1.91847 5.22141 2.76317 3.84293 3.99801 2.87809C5.23285 1.91325 6.7747 1.427 8.33964 1.50888C9.90458 1.59076 11.3873 2.23526 12.5147 3.32369C13.6422 4.41232 14.3384 5.8717 14.4751 7.43304C14.6118 8.99438 14.1797 10.5525 13.2585 11.8205C12.3372 13.0885 10.9889 13.9809 9.4617 14.3334C8.18666 14.6277 6.8587 14.529 5.64964 14.0601C5.17095 13.8745 4.76937 13.4929 4.26509 13.3963C3.67389 13.2832 2.95232 13.5595 2.0377 14.3334",!0)),e):n==="file"?(e.appendChild(qn("M4.9375 5.90295H11.0625",!0)),e.appendChild(qn("M4.9375 9.02991H8.27841",!0)),e.appendChild(qn("M12.5 1.32617C13.3039 1.32617 14 1.95171 14 2.77637V13.2246C13.9996 14.0489 13.3036 14.6738 12.5 14.6738H3.5C2.69637 14.6738 2.00042 14.0489 2 13.2246V2.77637C2 1.95171 2.69613 1.32617 3.5 1.32617H12.5ZM3.5 2.32617C3.1993 2.32617 3 2.55186 3 2.77637V13.2246C3.00044 13.4489 3.19963 13.6738 3.5 13.6738H12.5C12.8004 13.6738 12.9996 13.4489 13 13.2246V2.77637C13 2.55186 12.8007 2.32617 12.5 2.32617H3.5Z",!1)),e):n==="folder"?(e.appendChild(qn("M1.50439 3.11059C1.50439 2.55831 1.95211 2.1106 2.50439 2.1106H5.43389C5.67773 2.1106 5.91318 2.19969 6.09593 2.36113L7.71649 3.79265C7.89924 3.95409 8.1347 4.04319 8.3785 4.04319H13.4958C14.0481 4.04319 14.4958 4.4909 14.4958 5.04319V12.8894C14.4958 13.4417 14.0481 13.8894 13.4958 13.8894H2.50439C1.95211 13.8894 1.50439 13.4417 1.50439 12.8894V4.04319V3.11059Z",!0)),e.appendChild(qn("M3.63501 7.66614H12.3647",!0)),e):null}function dk(n){if(n.detail>1)return!0;let e=n.currentTarget;return n.detail!==0&&e instanceof Node&&e.ownerDocument?.getSelection()?.isCollapsed===!1}function m0(n,e){let t=e.current,i=n.clickable&&(n.kind==="file"?typeof t.openFile=="function":n.kind==="slash"&&typeof t.openSkill=="function"),r=document.createElement(i?"button":"span");i&&r.setAttribute("type","button"),r.className="dci-umsg-chip",r.dataset.chip=n.kind,r.title=n.label;let s=ck(n.kind);return s&&r.appendChild(s),r.appendChild(document.createTextNode(n.display)),i&&r.addEventListener("click",o=>{if(dk(o))return;let l=e.current;n.kind==="slash"?l.openSkill?.(n.display.slice(1)):l.openFile?.(n.label.slice(1).replace(/^"|"$/gu,""))}),r}function d0(n){return n.kind==="session"?0:1}function uk(n,e,t){let i=document.createDocumentFragment(),r=0;for(let s of e)s.start>r&&i.appendChild(document.createTextNode(n.data.slice(r,s.start))),i.appendChild(m0(s,t)),r=s.end;r<n.data.length&&i.appendChild(document.createTextNode(n.data.slice(r))),n.parentNode?.replaceChild(i,n)}function hk(n,e){let t=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,{acceptNode(l){let a=l.parentElement;return!a||a.closest("pre, code, a, .dci-umsg-chip")||l.data.length===0?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),i=[],r=t.nextNode();for(;r;)i.push(r),r=t.nextNode();let{skillNames:s,referenceLabels:o}=e.current;for(let l of i){let a=[...ok(l.data),...lk(l.data,o),...ak(l.data,s)];if(a.length===0)continue;a.sort((u,h)=>u.start-h.start||d0(u)-d0(h)||h.end-u.end);let c=[],d=0;for(let u of a)u.start<d||(c.push(u),d=u.end);c.length!==0&&uk(l,c,e)}}function fk(n,e){if(n)try{for(let t of Array.from(n.querySelectorAll("a"))){let i=t.getAttribute("href")??"";if(/^https?:/i.test(i)){t.setAttribute("target","_blank"),t.setAttribute("rel","noreferrer noopener");continue}if(/^mailto:/i.test(i)){t.setAttribute("rel","noreferrer noopener");continue}t.replaceWith(...Array.from(t.childNodes))}for(let t of Array.from(n.querySelectorAll("img")))/^https?:/i.test(t.getAttribute("src")??"")||t.replaceWith(document.createTextNode(t.getAttribute("alt")??""));for(let t of Array.from(n.querySelectorAll("input"))){if(!t.hasAttribute("disabled")){t.remove();continue}t.setAttribute("type","checkbox"),t.setAttribute("disabled","")}for(let t of Array.from(n.querySelectorAll("table"))){let i=t.parentElement;if(!i||i.classList.contains("dci-umsg-tscroll"))continue;let r=document.createElement("div");r.className="dci-umsg-tscroll",i.insertBefore(r,t),r.appendChild(t)}for(let t of Array.from(n.querySelectorAll("span[data-dci-wire]"))){let i=t.getAttribute("data-dci-wire")??"";t.replaceWith(m0({start:0,end:0,kind:"session",label:i,display:i,clickable:!1},e))}hk(n,e)}catch(t){me("umsg.decorate",t)}}function _d(n,e,t){let i=pr("chat");if(i)try{let r=i(n,t);if(r&&r!==n)return r}catch{}return v(e,t)}function pk(){let n=pr("chat");if(n)try{let e=n("message.referenceSeparator");if(e&&e!=="message.referenceSeparator")return e}catch{}return v("umsg.referenceSummary").includes("\u5F15\u7528")?"\u3001":", "}function u0(n){return n<10?`0${n}`:String(n)}function h0(n,e=Date.now()){let t=typeof n=="number"?n:typeof n=="string"?Date.parse(n):NaN;if(!Number.isFinite(t))return"";let i=new Date(t),r=new Date(e),s=`${u0(i.getHours())}:${u0(i.getMinutes())}`;if(i.getFullYear()===r.getFullYear()&&i.getMonth()===r.getMonth()&&i.getDate()===r.getDate())return s;let o={y:i.getFullYear(),m:i.getMonth()+1,d:i.getDate()};return`${_d(i.getFullYear()===r.getFullYear()?"clock.md":"clock.ymd",i.getFullYear()===r.getFullYear()?"umsg.clock.md":"umsg.clock.ymd",o)} ${s}`}async function mk(n){try{return await navigator.clipboard.writeText(n),!0}catch{try{let e=document.createElement("textarea");e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();let t=document.execCommand("copy");return e.remove(),t}catch{return!1}}}function gk(){return(0,se.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,se.jsx)("rect",{x:"1.52075",y:"4.07373",width:"10.3932",height:"10.3932",rx:"2",stroke:"currentColor"}),(0,se.jsx)("path",{d:"M11.9792 1.53296C13.36 1.53296 14.4792 2.65225 14.4792 4.03296V9.42847C14.4792 10.3756 13.9521 11.1987 13.1755 11.6228V10.3298C13.3652 10.0787 13.4792 9.7674 13.4792 9.42847V4.03296C13.4792 3.20453 12.8077 2.53296 11.9792 2.53296H6.58374C6.27966 2.53301 5.99684 2.6235 5.7605 2.77905H4.42358C4.85652 2.03463 5.66056 1.53304 6.58374 1.53296H11.9792Z",fill:"currentColor"})]})}function bk(){return(0,se.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:(0,se.jsx)("path",{d:"M2.25 8.5L5.49732 11.7473C5.90519 12.1552 6.57263 12.1344 6.95426 11.7018L13.75 4",stroke:"currentColor"})})}function wk({file:n}){let e=typeof n.name=="string"?n.name:"",t=typeof n.bytes=="number"?n.bytes:0,i=[gd(e).toUpperCase().slice(0,8),Qo(t)].filter(Boolean).join(" ");return(0,se.jsxs)("span",{className:"dci-umsg-file",title:e,children:[(0,se.jsx)("span",{className:"dci-umsg-fileglyph",children:(0,se.jsx)(fs,{})}),(0,se.jsxs)("span",{className:"dci-umsg-filecontent",children:[(0,se.jsx)("span",{className:"dci-umsg-filename",children:e}),(0,se.jsx)("span",{className:"dci-umsg-filemeta",children:i})]})]})}function yk({image:n}){let e=n.attachment??{},t=typeof e.name=="string"&&e.name!==""?e.name:v("umsg.image"),r=[typeof e.mediaType=="string"?e.mediaType.replace(/^image\//i,"").toUpperCase():"",typeof e.bytes=="number"?Qo(e.bytes):""].filter(Boolean).join(" ");return(0,se.jsxs)("span",{className:"dci-umsg-file","data-image-fallback":"true",title:t,children:[(0,se.jsx)("span",{className:"dci-umsg-fileglyph",children:(0,se.jsx)(fs,{})}),(0,se.jsxs)("span",{className:"dci-umsg-filecontent",children:[(0,se.jsx)("span",{className:"dci-umsg-filename",children:t}),(0,se.jsx)("span",{className:"dci-umsg-filemeta",children:r})]})]})}function xk(n){let{node:e,renderMessageImages:t,openFile:i,openSkill:r}=n;St();let s=e?.data??{},o=s.content,l=(0,He.useMemo)(()=>Array.isArray(s.referenceLabels)?s.referenceLabels:[],[s.referenceLabels]),a=(0,He.useMemo)(()=>Array.isArray(s.skillNames)?s.skillNames:[],[s.skillNames]),{text:c,attachments:d,rest:u}=(0,He.useMemo)(()=>Zv(o),[o]),h=d.length>1,f=c!==""||u.length>0,p=(0,He.useMemo)(()=>c===""?"":rk(c),[c]),m=(0,He.useRef)(null),w=(0,He.useRef)({openFile:i,openSkill:r,skillNames:a,referenceLabels:l});w.current={openFile:i,openSkill:r,skillNames:a,referenceLabels:l},(0,He.useEffect)(()=>{fk(m.current,w)},[p,l,a]);let[b,k]=(0,He.useState)(!1),C=(0,He.useRef)(null);(0,He.useEffect)(()=>()=>{C.current!==null&&window.clearTimeout(C.current)},[]);let P=(0,He.useCallback)(()=>{b||c===""||mk(c).then(S=>{S&&(k(!0),C.current!==null&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>{C.current=null,k(!1)},1e3))})},[b,c]);return!f&&d.length===0&&l.length===0&&s.time===void 0?null:(0,se.jsx)("div",{className:"dci-umsg-row",children:(0,se.jsxs)("div",{className:"dci-umsg-stack",children:[d.length>0&&(0,se.jsx)("div",{className:"dci-umsg-attrow","data-message-attachments":"true",children:d.map((S,x)=>S.type==="image"?(0,se.jsx)(He.Fragment,{children:t?t({images:[S.image],align:"end",compact:h}):(0,se.jsx)(yk,{image:S.image})},`image:${x}`):(0,se.jsx)(wk,{file:S.file},`file:${x}`))}),f&&(0,se.jsxs)("div",{className:"dci-umsg-bubble",children:[c!==""&&(0,se.jsx)("div",{className:"dci-umsg-md",ref:m,dangerouslySetInnerHTML:{__html:p}}),u.map((S,x)=>(0,se.jsxs)("pre",{className:"dci-umsg-extra",children:[_d("message.extraBlock","umsg.extraBlock"),`
728
+ `,JSON.stringify(S,null,2)]},x))]}),l.length>0&&(0,se.jsx)("div",{className:"dci-umsg-refsum",children:_d("message.referenceSummary","umsg.referenceSummary",{labels:l.join(pk())})}),(0,se.jsxs)("div",{className:"dci-umsg-actions","data-clock":"start",children:[s.time!==void 0&&h0(s.time)!==""&&(0,se.jsx)("span",{className:"dci-umsg-time",children:h0(s.time)}),(0,se.jsx)("button",{type:"button",className:"dci-umsg-action","aria-label":b?v("umsg.copied"):v("umsg.copy"),title:b?v("umsg.copied"):v("umsg.copy"),onClick:P,children:b?(0,se.jsx)(bk,{}):(0,se.jsx)(gk,{})})]})]})})}var vk=(0,He.memo)(xk);var Nt=require("react");var oe=require("react/jsx-runtime"),kk="codinput";function b0(){return{options:{name:"settings.section",id:kk,order:60,label:()=>"Codinput",registrant:"dsh-codinput"},component:Ck}}function g0(n){let{value:e,conflictWith:t,ariaLabel:i,onChange:r}=n,[s,o]=(0,Nt.useState)(!1),[l,a]=(0,Nt.useState)(!1),c=(0,Nt.useRef)(null);return(0,Nt.useEffect)(()=>{if(!s)return;let d=u=>{c.current&&u.target instanceof Node&&c.current.contains(u.target)||o(!1)};return window.addEventListener("pointerdown",d,!0),()=>window.removeEventListener("pointerdown",d,!0)},[s]),(0,oe.jsx)("button",{ref:c,type:"button",className:"dci-set-selector","data-recording":s||void 0,"data-conflict":l||void 0,"aria-label":i,onClick:()=>o(!0),onBlur:()=>o(!1),onKeyDown:d=>{if(!s)return;if(d.preventDefault(),d.stopPropagation(),d.key==="Escape"){o(!1);return}if(d.key==="Shift"||d.key==="Control"||d.key==="Alt"||d.key==="Meta")return;let u=lg(d.nativeEvent,d.key);if(t!==void 0&&u===t){a(!0),window.setTimeout(()=>a(!1),1500);return}r(u),o(!1),c.current?.blur()},children:s?v("set.recording"):ag(e)})}function Xn(n){let{title:e,desc:t,children:i}=n;return(0,oe.jsxs)("div",{className:"dci-set-row",children:[(0,oe.jsxs)("div",{className:"dci-set-rowText",children:[(0,oe.jsx)("div",{className:"dci-set-title",children:e}),t?(0,oe.jsx)("div",{className:"dci-set-desc",children:t}):null]}),(0,oe.jsx)("div",{className:"dci-set-control",children:i})]})}function Sk(n){let{value:e,options:t,onChange:i,ariaLabel:r}=n,[s,o]=(0,Nt.useState)(!1),l=(0,Nt.useRef)(null),[a,c]=(0,Nt.useState)(null),[d,u]=(0,Nt.useState)(null),h=t.find(f=>f.value===e);return(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsxs)("button",{ref:l,type:"button",className:"dci-set-selector","aria-haspopup":"menu","aria-expanded":s,"aria-label":r,onClick:()=>{if(!s){let f=l.current??null;c(f),u(f?f.getBoundingClientRect():null)}o(!s)},children:[h?.label??e,(0,oe.jsx)(en,{size:14})]}),s&&a?(0,oe.jsx)(or,{anchor:a,initialRect:d,side:"bottom",alignEnd:!0,onClose:()=>o(!1),minWidth:200,children:t.map(f=>(0,oe.jsx)("button",{type:"button",className:"dci-item",onClick:()=>{i(f.value),o(!1)},children:(0,oe.jsx)("span",{className:"dci-itemLabel",children:f.label})},f.value))}):null]})}function Hd(n){let{on:e,label:t,onToggle:i}=n;return(0,oe.jsx)("button",{type:"button",role:"switch",className:"dci-switch","aria-checked":e,"aria-label":t,onClick:i})}function Ck(){let[n,e]=(0,Nt.useState)(()=>ue());St();let t=i=>{e(ct(i))};return(0,oe.jsxs)("div",{className:"dci-settings",children:[(0,oe.jsx)(Xn,{title:v("set.enabled"),desc:v("set.enabledDesc"),children:(0,oe.jsx)(Hd,{on:n.enabled,label:v("set.enabled"),onToggle:()=>t({enabled:!n.enabled})})}),(0,oe.jsx)(Xn,{title:v("set.userMarkdown"),desc:v("set.userMarkdownDesc"),children:(0,oe.jsx)(Hd,{on:n.userMarkdown,label:v("set.userMarkdown"),onToggle:()=>t({userMarkdown:!n.userMarkdown})})}),(0,oe.jsx)(Xn,{title:v("set.lineNumbers"),desc:v("set.lineNumbersDesc"),children:(0,oe.jsx)(Hd,{on:n.lineNumbers,label:v("set.lineNumbers"),onToggle:()=>t({lineNumbers:!n.lineNumbers})})}),(0,oe.jsx)(Xn,{title:v("set.font"),desc:v("set.fontDesc"),children:(0,oe.jsx)("input",{type:"text",className:"dci-set-input",value:n.fontFamily,spellCheck:!1,"aria-label":v("set.font"),onChange:i=>t({fontFamily:i.target.value})})}),(0,oe.jsx)(Xn,{title:v("set.sendKey"),desc:v("set.sendKeyDesc"),children:(0,oe.jsx)(g0,{value:n.sendHotkey,conflictWith:n.lineBreakHotkey,ariaLabel:v("set.sendKey"),onChange:i=>t({sendHotkey:i})})}),(0,oe.jsx)(Xn,{title:v("set.lineBreakKey"),desc:v("set.lineBreakKeyDesc"),children:(0,oe.jsx)(g0,{value:n.lineBreakHotkey,conflictWith:n.sendHotkey,ariaLabel:v("set.lineBreakKey"),onChange:i=>t({lineBreakHotkey:i})})}),(0,oe.jsx)(Xn,{title:v("set.defaultView"),desc:v("set.defaultViewDesc"),children:(0,oe.jsx)(Sk,{value:n.defaultEdit&&n.defaultPreview?"split":n.defaultPreview?"preview":"edit",ariaLabel:v("set.defaultView"),onChange:i=>t({defaultEdit:i!=="preview",defaultPreview:i!=="edit"}),options:[{value:"edit",label:v("head.editOnly")},{value:"split",label:v("head.split")},{value:"preview",label:v("head.previewOnly")}]})}),(0,oe.jsx)(Xn,{title:v("set.reset"),desc:v("set.resetAll"),children:(0,oe.jsx)("button",{type:"button",className:"dci-set-selector",onClick:()=>e(ct({...mr})),children:v("set.resetAction")})})]})}function Tk(n){if(n)try{let e=Y.sessions?.scope(n);e&&Y.conversation&&Y.conversation.input.for(e).setDraft("")}catch{}}function w0(n,e,t){let i=n.findIndex(o=>o.name===e);if(i===-1)return[...n];let r=t(n);if(r===i||r===i+1)return[...n];let s=[...n];return s.splice(i,1),s.splice(r>i?r-1:r,0,n[i]),s}function y0(n){Fe("command.register",()=>{n.inject(["commandUi"],e=>{let t=e.commandUi;if(typeof t?.register!="function"){Oe().__dshCodinputShell.command="commandUi-unavailable";return}let i;if(typeof t.candidates=="function"){let r=t.candidates.bind(t);t.candidates=(s,o)=>Promise.resolve(r(s,o)).then(l=>{if(o.query!==""||!Array.isArray(l))return l;let a=l,c=a.find(d=>d.name==="goal"||d.name==="plan"||d.name==="feedback")?.section;return c!==void 0&&(a=w0(a,"file",d=>{let u=d.findIndex(h=>h.section===c&&h.name!=="file");return u===-1?d.length:u})),a=w0(a,"codinput",d=>{let u=d.find(f=>f.name==="codinput"),h=d.findIndex(f=>f.section===u?.section&&f.name!=="codinput"&&f.name.toLowerCase()>"codinput");return h===-1?d.length:h}),a}),i=()=>{t.candidates=r}}n.effect(()=>i,"dsh-codinput: slash order patch"),n.effect(()=>t.register({name:"codinput",description:()=>ue().enabled?v("cmd.exit"):v("cmd.enter"),icon:Rh,available:()=>!0,ui:{kind:"action",run:()=>{let r=Oe().__dshCodinputSessionId??void 0;if(ct({enabled:!ue().enabled}),!ue().enabled)for(let s of Cu())Au(s);setTimeout(()=>Tk(r),80)}}}),"dsh-codinput: /codinput contribution"),Oe().__dshCodinputShell.command="registered"})})}var Ak="dsh-codinput",Mk=["slots","conversation"];function cr(n,e,t=60){try{n(),Oe().__dshCodinputShell[e]="registered";return}catch(i){if(t<=0){me(e,i),Oe().__dshCodinputShell[e]="failed";return}}setTimeout(()=>cr(n,e,t-1),250)}function Ek(n){wu(),gu(n),Fe("console.hook",()=>{let l=Oe();if(!l.__dshConsoleHooked){l.__dshConsoleHooked=!0;let a=l.console.error.bind(l.console);l.console.error=(...c)=>{let d=c.find(u=>u instanceof Error);if(d){let u=l.__dshCodinputErrs;u.push(d),u.length>200&&u.splice(0,u.length-200)}a(...c)}}}),Fe("slots.entryErrorHook",()=>{let l=n.slots,a=l._core??l;typeof a.onEntryError=="function"&&a.onEntryError(c=>{let d=c?.error;me("slot.entry",d??c),Oe().__dshCodinputErrs.push(d instanceof Error?d:new Error(JSON.stringify(c).slice(0,800)))})});let e=a0(),t=null,i=()=>{if(!t)try{t=n.slots.register(e.options,Id),Oe().__dshCodinputShell.bar="mounted"}catch(l){me("bar.register",l)}},r=()=>{let l=t;t=null;try{l?.(),Oe().__dshCodinputShell.bar="unmounted"}catch(a){me("bar.dispose",a)}},s=()=>ue().enabled||Tu(),o=()=>{s()?i():r()};cr(()=>{s()&&i()},"bar"),Fe("bar.prefs",()=>{pn(o)}),Fe("bar.sideinput",()=>{br(o)}),Fe("md.register",()=>{let l=f0(),a=new Map,c=()=>ue().userMarkdown,d=f=>{let p=f.options.key??"";a.has(p)||!c()||(a.set(p,n.slots.register(f.options,f.component)),Oe().__dshCodinputShell[`md.${p}`]="mounted")},u=f=>{let p=a.get(f);if(p){a.delete(f);try{p(),Oe().__dshCodinputShell[`md.${f}`]="unmounted"}catch(m){me("md.dispose",m)}}},h=()=>{for(let f of l){let p=f.options.key??"";c()?cr(()=>d(f),`md.${p}`):u(p)}};h(),Fe("md.prefs",()=>{pn(h)})}),Fe("sidebar.register",()=>{n.inject(["slots","sidebarRightTabs","sidebarRight"],l=>{let a=l.sidebarRightTabs;if(typeof a?.register!="function"){me("sidebar",new Error("sidebarRightTabs unavailable"));return}let c=e0();n.effect(()=>a.register(Qg()),"dsh-codinput: sidebar tab type"),cr(()=>{n.slots.register(c.options,c.component)},"sidebar.body");let d=t0();cr(()=>{n.slots.register(d.options,d.component)},"sidebar.title")})}),Fe("settings.register",()=>{let l=b0();cr(()=>{n.slots.register(l.options,l.component)},"settings")}),y0(n),Fe("draggate.install",()=>{let l=window;l.__dshCodinputDragGate||(l.__dshCodinputDragGate=!0,document.addEventListener("pointerdown",a=>{a.target instanceof Element&&(a.target.closest("[data-dockkit-tab-close]")||a.target.closest("[data-dockkit-tab]")&&a.stopPropagation())},{capture:!0}))}),Fe("diag.boot",()=>{Oe().__dshCodinputShell.apply="done",window.__dshCodinputCtx=n})}
729
729
  return module.exports; } })