5594 lines
1.3 MiB
Plaintext
5594 lines
1.3 MiB
Plaintext
import triliumKoreanEditorTranslations from "./ckeditor-ko.js";
|
||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./launcher_context_menu.js","./app_context.js","./preload-helper.js","./syntax_highlight.js","./utils.js","./_commonjsHelpers.js","./auto-render.js","./auto-render.css","./tree_context_menu.js","./jquery.js","./index_jquery.js","./ckeditor5.js","./marked.esm.js","./math.js","./mermaid.core.js","./transform.js","./isObjectLike.js","./linear.js","./index-DMWsby55.js","./index-5hH8q7CL.js","./index-DgK5Tp-l.js","./eslint-BLaL04kV.js","./index-ChAH7PmL.js","./index-C-bx8VHj.js","./batch-X8TaNpXx.js","./simple-mode-B0dvCdAA.js","./index-Dzlwgv2b.js","./index-DVtO9wPE.js","./dockerfile-DIy8NleC.js","./factor-DDOC7X6P.js","./gdscript-fVwPZpIE.js","./index-DfHtIUQk.js","./index-DGP8gWJD.js","./index-BOZ6ZR_8.js","./nsis-fePjrhq7.js","./index-iV4hneWX.js","./pug-CwAQJzGR.js","./javascript-C2yteZeJ.js","./rust-DZOEz86s.js","./sass-DXRO2mSp.js","./css-D7hGgwrb.js","./index-BVDyGn0z.js","./index-Byvc7VQm.js","./index-Dqpe0q7-.js","./index-BDUNLGjv.js","./index-xqhK_p3_.js","./index-Co2ZowoL.js","./index-m6eB99Pt.js","./index-CtyT9BpA.js","./index-DzzK8sxM.js","./index-BsQdGQZO.js","./index-BNHmbid4.js","./index-B-_mzY9b.js","./index-BQbQdyQd.js","./index-CkgmqLZz.js","./index-B7IbnQNR.js","./index-F9F1O8fB.js","./index-C-bZr3zn.js","./index-CGkKWkW-.js","./index-C83-juky.js","./index-BLvbl8ks.js","./index-Bm2pFVA9.js","./index-gs0O0rSY.js","./index-BEqJy_lh.js","./index-Dw3iqOwU.js","./index-CWDzYz2u.js","./index-CSTtsAHM.js","./jsplumb.js","./index7.js","./percentages-BXMCSKIN.js","./compat.module.js","./preact.module.js","./percentages-BXMCSKIN.css","./force-graph.js","./toNumber.js","./isSymbol.js","./ordinal.js","./init.js","./colors.js","./min.js","./svg-pan-zoom.js","./index2.js","./index.js","./internal.js","./index5.js","./index6.js","./index3.js","./index4.js","./mark.js"])))=>i.map(i=>d[i]);
|
||
import{t as m,o as Qt,s as pt,e as ib,h as nb,u as ob,j as sb,k as Nf,m as al,c as Mf,f as Yd,b as rb,d as Pf,l as ab,n as lb}from"./syntax_highlight.js";import{T as cb,B as ge,f as Mt,c as Ho,a as Pt,k as qo,b as ft,m as li,w as yi,l as Pe,N as hi,t as fe,n as yr,d as Me,s as Bi,i as ll,q as Mi,S as Hi,r as Of,u as Jd,A as db,v as Qd,x as hb,o as en,y as ub,j as Df,W as pb,D as fb,E as $r,F as mb,g as gb,G as vb,H as yb,I as cl,h as bb}from"./app_context.js";import{u as ct,T as As,D as Ko,h as Sr,d as br,e as Qn,M as Pi}from"./utils.js";import{g as Br}from"./_commonjsHelpers.js";import{_ as Z}from"./preload-helper.js";import{r as Ll}from"./jquery.js";import{n as Xe}from"./index_jquery.js";import{EditorWatchdog as uu,ClassicEditor as Yc,PopupEditor as pu}from"./ckeditor5.js";import{r as Rf}from"./auto-render.js";import{m as wb}from"./marked.esm.js";class Bf extends cb{doRender(){this.$widget=$("<div>"),this.renderChildren()}renderChildren(){for(const t of this.children){if(!("render"in t))throw"Non-renderable widget encountered.";const e=t;try{"render"in t&&this.$widget.append(e.render())}catch(i){e.logRenderingError(i)}}}}class Xd extends Bf{constructor(t){if(super(),!t||!["row","column"].includes(t))throw new Error(`Direction argument given as '${t}', use either 'row' or 'column'`);this.attrs.style=`display: flex; flex-direction: ${t};`}}const _b=`
|
||
<div style="display: none;">
|
||
<style>
|
||
.global-menu-button-update-available-button {
|
||
width: 21px !important;
|
||
height: 21px !important;
|
||
padding: 0 !important;
|
||
|
||
border-radius: var(--button-border-radius);
|
||
transform: scale(0.9);
|
||
border: none;
|
||
opacity: 0.8;
|
||
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.global-menu-button-wrapper:hover .global-menu-button-update-available-button {
|
||
opacity: 1;
|
||
}
|
||
</style>
|
||
|
||
<span class="bx bx-sync global-menu-button-update-available-button" title="${m("update_available.update_available")}"></span>
|
||
</div>
|
||
`;class xb extends ge{doRender(){this.$widget=$(_b)}updateVersionStatus(t){this.$widget.toggle(ct.isUpdateAvailable(t,glob.triliumVersion))}}const kb=`
|
||
<div class="dropdown global-menu">
|
||
<style>
|
||
.global-menu {
|
||
width: 53px;
|
||
height: 53px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.global-menu .dropdown-menu {
|
||
min-width: 20em;
|
||
}
|
||
|
||
.global-menu-button {
|
||
width: 100%;
|
||
height: 100%;
|
||
position: relative;
|
||
padding: 6px;
|
||
border: 0;
|
||
}
|
||
|
||
.global-menu-button > svg path {
|
||
fill: var(--launcher-pane-text-color);
|
||
}
|
||
|
||
.global-menu-button:hover { border: 0; }
|
||
.global-menu-button:hover > svg path {
|
||
transition: 200ms ease-in-out fill;
|
||
}
|
||
.global-menu-button:hover > svg path.st0 { fill:#95C980; }
|
||
.global-menu-button:hover > svg path.st1 { fill:#72B755; }
|
||
.global-menu-button:hover > svg path.st2 { fill:#4FA52B; }
|
||
.global-menu-button:hover > svg path.st3 { fill:#EE8C89; }
|
||
.global-menu-button:hover > svg path.st4 { fill:#E96562; }
|
||
.global-menu-button:hover > svg path.st5 { fill:#E33F3B; }
|
||
.global-menu-button:hover > svg path.st6 { fill:#EFB075; }
|
||
.global-menu-button:hover > svg path.st7 { fill:#E99547; }
|
||
.global-menu-button:hover > svg path.st8 { fill:#E47B19; }
|
||
|
||
.global-menu-button-update-available {
|
||
position: absolute;
|
||
right: -30px;
|
||
bottom: -30px;
|
||
width: 100%;
|
||
height: 100%;
|
||
pointer-events: none;
|
||
}
|
||
|
||
.global-menu .zoom-container {
|
||
display: flex;
|
||
flex-direction: row;
|
||
justify-content: space-between;
|
||
align-items: baseline;
|
||
}
|
||
|
||
.global-menu .zoom-buttons a {
|
||
display: inline-block;
|
||
border: 1px solid var(--button-border-color);
|
||
border-radius: var(--button-border-radius);
|
||
color: var(--button-text-color);
|
||
background-color: var(--button-background-color);
|
||
padding: 3px;
|
||
margin-left: 3px;
|
||
text-decoration: none;
|
||
}
|
||
|
||
.global-menu .zoom-buttons a:hover {
|
||
text-decoration: none;
|
||
}
|
||
|
||
.global-menu .zoom-state {
|
||
margin-left: 5px;
|
||
margin-right: 5px;
|
||
}
|
||
|
||
.global-menu .dropdown-item .bx {
|
||
position: relative;
|
||
top: 3px;
|
||
font-size: 120%;
|
||
margin-right: 6px;
|
||
}
|
||
</style>
|
||
|
||
<button type="button" data-bs-toggle="dropdown" aria-haspopup="true"
|
||
aria-expanded="false" class="icon-action global-menu-button">
|
||
<div class="global-menu-button-update-available"></div>
|
||
</button>
|
||
|
||
<ul class="dropdown-menu dropdown-menu-right">
|
||
<li class="dropdown-item" data-trigger-command="openNewWindow">
|
||
<span class="bx bx-window-open"></span>
|
||
${m("global_menu.open_new_window")}
|
||
<kbd data-command="openNewWindow"></kbd>
|
||
</li>
|
||
|
||
<li class="dropdown-item" data-trigger-command="showShareSubtree">
|
||
<span class="bx bx-share-alt"></span>
|
||
${m("global_menu.show_shared_notes_subtree")}
|
||
</li>
|
||
|
||
<div class="dropdown-divider"></div>
|
||
|
||
<span class="zoom-container dropdown-item dropdown-item-container">
|
||
<div>
|
||
<span class="bx bx-empty"></span>
|
||
${m("global_menu.zoom")}
|
||
</div>
|
||
|
||
<div class="zoom-buttons">
|
||
<a data-trigger-command="toggleFullscreen" title="${m("global_menu.toggle_fullscreen")}" class="bx bx-expand-alt"></a>
|
||
|
||
|
||
|
||
<a data-trigger-command="zoomOut" title="${m("global_menu.zoom_out")}" class="bx bx-minus"></a>
|
||
|
||
<span data-trigger-command="zoomReset" title="${m("global_menu.reset_zoom_level")}" class="zoom-state"></span>
|
||
|
||
<a data-trigger-command="zoomIn" title="${m("global_menu.zoom_in")}" class="bx bx-plus"></a>
|
||
</div>
|
||
</span>
|
||
|
||
<li class="dropdown-item toggle-pin">
|
||
<span class="bx bx-pin"></span>
|
||
${m("title_bar_buttons.window-on-top")}
|
||
</li>
|
||
|
||
<li class="dropdown-item" data-trigger-command="toggleZenMode">
|
||
<span class="bx bxs-yin-yang"></span>
|
||
${m("global_menu.toggle-zen-mode")}
|
||
<kbd data-command="toggleZenMode"></kbd>
|
||
</li>
|
||
|
||
<div class="dropdown-divider desktop-only"></div>
|
||
|
||
<li class="dropdown-item switch-to-mobile-version-button" data-trigger-command="switchToMobileVersion">
|
||
<span class="bx bx-mobile"></span>
|
||
${m("global_menu.switch_to_mobile_version")}
|
||
</li>
|
||
|
||
<li class="dropdown-item switch-to-desktop-version-button" data-trigger-command="switchToDesktopVersion">
|
||
<span class="bx bx-desktop"></span>
|
||
${m("global_menu.switch_to_desktop_version")}
|
||
</li>
|
||
|
||
<li class="dropdown-item" data-trigger-command="showLaunchBarSubtree">
|
||
<span class="bx ${ct.isMobile()?"bx-mobile":"bx-sidebar"}"></span>
|
||
${m("global_menu.configure_launchbar")}
|
||
</li>
|
||
|
||
<li class="dropdown-item dropdown-submenu">
|
||
<span class="dropdown-toggle">
|
||
<span class="bx bx-chip"></span>${m("global_menu.advanced")}
|
||
</span>
|
||
|
||
<ul class="dropdown-menu">
|
||
<li class="dropdown-item" data-trigger-command="showHiddenSubtree">
|
||
<span class="bx bx-hide"></span>
|
||
${m("global_menu.show_hidden_subtree")}
|
||
</li>
|
||
|
||
<li class="dropdown-item" data-trigger-command="showSearchHistory">
|
||
<span class="bx bx-search-alt"></span>
|
||
${m("global_menu.open_search_history")}
|
||
</li>
|
||
|
||
<div class="dropdown-divider"></div>
|
||
|
||
<li class="dropdown-item" data-trigger-command="showBackendLog">
|
||
<span class="bx bx-detail"></span>
|
||
${m("global_menu.show_backend_log")}
|
||
<kbd data-command="showBackendLog"></kbd>
|
||
</li>
|
||
|
||
<li class="dropdown-item" data-trigger-command="showSQLConsole">
|
||
<span class="bx bx-data"></span>
|
||
${m("global_menu.open_sql_console")}
|
||
<kbd data-command="showSQLConsole"></kbd>
|
||
</li>
|
||
|
||
<li class="dropdown-item" data-trigger-command="showSQLConsoleHistory">
|
||
<span class="bx bx-data"></span>
|
||
${m("global_menu.open_sql_console_history")}
|
||
</li>
|
||
|
||
<div class="dropdown-divider"></div>
|
||
|
||
<li class="dropdown-item open-dev-tools-button" data-trigger-command="openDevTools">
|
||
<span class="bx bx-bug-alt"></span>
|
||
${m("global_menu.open_dev_tools")}
|
||
<kbd data-command="openDevTools"></kbd>
|
||
</li>
|
||
|
||
<li class="dropdown-item" data-trigger-command="reloadFrontendApp"
|
||
title="${m("global_menu.reload_hint")}">
|
||
<span class="bx bx-refresh"></span>
|
||
${m("global_menu.reload_frontend")}
|
||
<kbd data-command="reloadFrontendApp"></kbd>
|
||
</li>
|
||
|
||
</ul>
|
||
</li>
|
||
|
||
<li class="dropdown-item" data-trigger-command="showOptions">
|
||
<span class="bx bx-cog"></span>
|
||
${m("global_menu.options")}
|
||
</li>
|
||
|
||
<div class="dropdown-divider desktop-only"></div>
|
||
|
||
<li class="dropdown-item show-help-button" data-trigger-command="showHelp">
|
||
<span class="bx bx-help-circle"></span>
|
||
${m("global_menu.show_help")}
|
||
<kbd data-command="showHelp"></kbd>
|
||
</li>
|
||
|
||
<li class="dropdown-item show-help-button" data-trigger-command="showCheatsheet">
|
||
<span class="bx bxs-keyboard"></span>
|
||
${m("global_menu.show-cheatsheet")}
|
||
<kbd data-command="showCheatsheet"></kbd>
|
||
</li>
|
||
|
||
<li class="dropdown-item show-about-dialog-button">
|
||
<span class="bx bx-info-circle"></span>
|
||
${m("global_menu.about")}
|
||
</li>
|
||
|
||
<li class="dropdown-item update-to-latest-version-button" style="display: none;" data-trigger-command="downloadLatestVersion">
|
||
<span class="bx bx-sync"></span>
|
||
|
||
<span class="version-text"></span>
|
||
</li>
|
||
|
||
<div class="dropdown-divider logout-button-separator"></div>
|
||
|
||
<li class="dropdown-item logout-button" data-trigger-command="logout">
|
||
<span class="bx bx-log-out"></span>
|
||
${m("global_menu.logout")}
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
`;class TA extends ge{updateAvailableWidget;isHorizontalLayout;tooltip;dropdown;$updateToLatestVersionButton;$zoomState;$toggleZenMode;constructor(t){super(),this.updateAvailableWidget=new xb,this.isHorizontalLayout=t}doRender(){this.$widget=$(kb),this.isHorizontalLayout||this.$widget.addClass("dropend");const t=this.$widget.find(".global-menu-button");this.isHorizontalLayout?t.toggleClass("bx bx-menu"):(t.prepend($(` <svg viewBox="0 0 256 256" data-bs-toggle="tooltip" title="${m("global_menu.menu")}">
|
||
<g>
|
||
<path class="st0" d="m202.9 112.7c-22.5 16.1-54.5 12.8-74.9 6.3l14.8-11.8 14.1-11.3 49.1-39.3-51.2 35.9-14.3 10-14.9 10.5c0.7-21.2 7-49.9 28.6-65.4 1.8-1.3 3.9-2.6 6.1-3.8 2.7-1.5 5.7-2.9 8.8-4.1 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.9 65.9-2.4 2.8-4.9 5.4-7.4 7.8-3.4 3.5-6.8 6.4-10.1 8.8z"/>
|
||
<path class="st1" d="m213.1 104c-22.2 12.6-51.4 9.3-70.3 3.2l14.1-11.3 49.1-39.3-51.2 35.9-14.3 10c0.5-18.1 4.9-42.1 19.7-58.6 2.7-1.5 5.7-2.9 8.8-4.1 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.9 65.9-2.3 2.8-4.8 5.4-7.2 7.8z"/>
|
||
<path class="st2" d="m220.5 96.2c-21.1 8.6-46.6 5.3-63.7-0.2l49.2-39.4-51.2 35.9c0.3-15.8 3.5-36.6 14.3-52.8 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.8 66z"/>
|
||
|
||
<path class="st3" d="m106.7 179c-5.8-21 5.2-43.8 15.5-57.2l4.8 14.2 4.5 13.4 15.9 47-12.8-47.6-3.6-13.2-3.7-13.9c15.5 6.2 35.1 18.6 40.7 38.8 0.5 1.7 0.9 3.6 1.2 5.5 0.4 2.4 0.6 5 0.7 7.7 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8-1.4-2.6-2.7-5.1-3.8-7.6-1.6-3.5-2.9-6.8-3.8-10z"/>
|
||
<path class="st4" d="m110.4 188.9c-3.4-19.8 6.9-40.5 16.6-52.9l4.5 13.4 15.9 47-12.8-47.6-3.6-13.2c13.3 5.2 29.9 15 38.1 30.4 0.4 2.4 0.6 5 0.7 7.7 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8-1.4-2.6-2.7-5.2-3.8-7.7z"/>
|
||
<path class="st5" d="m114.2 196.5c-0.7-18 8.6-35.9 17.3-47.1l15.9 47-12.8-47.6c11.6 4.4 26.1 12.4 35.2 24.8 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8z"/>
|
||
|
||
<path class="st6" d="m86.3 59.1c21.7 10.9 32.4 36.6 35.8 54.9l-15.2-6.6-14.5-6.3-50.6-22 48.8 24.9 13.6 6.9 14.3 7.3c-16.6 7.9-41.3 14.5-62.1 4.1-1.8-0.9-3.6-1.9-5.4-3.2-2.3-1.5-4.5-3.2-6.8-5.1-19.9-16.4-40.3-46.4-42.7-61.5 12.4-6.5 41.5-5.8 64.8-0.3 3.2 0.8 6.2 1.6 9.1 2.5 4 1.3 7.6 2.8 10.9 4.4z"/>
|
||
<path class="st7" d="m75.4 54.8c18.9 12 28.4 35.6 31.6 52.6l-14.5-6.3-50.6-22 48.7 24.9 13.6 6.9c-14.1 6.8-34.5 13-53.3 8.2-2.3-1.5-4.5-3.2-6.8-5.1-19.8-16.4-40.2-46.4-42.6-61.5 12.4-6.5 41.5-5.8 64.8-0.3 3.1 0.8 6.2 1.6 9.1 2.6z"/>
|
||
<path class="st8" d="m66.3 52.2c15.3 12.8 23.3 33.6 26.1 48.9l-50.6-22 48.8 24.9c-12.2 6-29.6 11.8-46.5 10-19.8-16.4-40.2-46.4-42.6-61.5 12.4-6.5 41.5-5.8 64.8-0.3z"/>
|
||
</g>
|
||
</svg>`)),this.tooltip=new As(this.$widget.find("[data-bs-toggle='tooltip']")[0],{trigger:"hover"})),this.dropdown=Ko.getOrCreateInstance(this.$widget.find("[data-bs-toggle='dropdown']")[0],{popperConfig:{placement:"bottom"}}),this.$widget.find(".show-about-dialog-button").on("click",()=>this.triggerCommand("openAboutDialog"));const e=ct.isElectron();this.$widget.find(".toggle-pin").toggle(e),e&&this.$widget.on("click",".toggle-pin",i=>{const n=$(i.target),a=ct.dynamicRequire("@electron/remote").BrowserWindow.getFocusedWindow();a.isAlwaysOnTop()?(a.setAlwaysOnTop(!1),n.removeClass("active")):(a.setAlwaysOnTop(!0),n.addClass("active"))}),this.$widget.find(".logout-button").toggle(!e),this.$widget.find(".logout-button-separator").toggle(!e),this.$widget.find(".open-dev-tools-button").toggle(e),this.$widget.find(".switch-to-mobile-version-button").toggle(!e&&ct.isDesktop()),this.$widget.find(".switch-to-desktop-version-button").toggle(!e&&ct.isMobile()),this.$widget.on("click",".dropdown-item",i=>{$(i.target).parent(".zoom-buttons")||this.dropdown.toggle()}),ct.isMobile()&&this.$widget.on("click",".dropdown-submenu .dropdown-toggle",i=>{const n=$(i.target).closest(".dropdown-item");n.toggleClass("submenu-open"),n.find("ul.dropdown-menu").toggleClass("show"),i.stopPropagation()}),this.$widget.on("click",".dropdown-submenu",i=>{($(i.target).children(".dropdown-menu").length===1||$(i.target).hasClass("dropdown-toggle"))&&i.stopPropagation()}),this.$widget.find(".global-menu-button-update-available").append(this.updateAvailableWidget.render()),this.$updateToLatestVersionButton=this.$widget.find(".update-to-latest-version-button"),ct.isElectron()||this.$widget.find(".zoom-container").hide(),this.$zoomState=this.$widget.find(".zoom-state"),this.$toggleZenMode=this.$widget.find('[data-trigger-command="toggleZenMode"'),this.$toggleZenMode.toggle(!ct.isMobile()),this.$widget.on("show.bs.dropdown",()=>this.#t()),this.tooltip&&this.$widget.on("hide.bs.dropdown",()=>this.tooltip.enable()),this.$widget.find(".zoom-buttons").on("click",()=>setTimeout(()=>this.updateZoomState(),300)),this.updateVersionStatus(),setInterval(()=>this.updateVersionStatus(),8*60*60*1e3)}#t(){this.$toggleZenMode.toggleClass("active",$("body").hasClass("zen")),this.updateZoomState(),this.tooltip&&(this.tooltip.hide(),this.tooltip.disable())}updateZoomState(){if(!ct.isElectron())return;const t=ct.dynamicRequire("electron").webFrame.getZoomFactor(),e=Math.round(t*100);this.$zoomState.text(`${e}%`)}async updateVersionStatus(){if(await Qt.initializedPromise,Qt.get("checkForUpdates")!=="true")return;const t=await this.fetchLatestVersion();this.updateAvailableWidget.updateVersionStatus(t),this.$updateToLatestVersionButton.toggle(ct.isUpdateAvailable(t,glob.triliumVersion)),this.$updateToLatestVersionButton.find(".version-text").text(`Version ${t} is available, click to download.`)}async fetchLatestVersion(){return(await(await fetch("https://api.github.com/repos/TriliumNext/Notes/releases/latest")).json())?.tag_name?.substring(1)}downloadLatestVersionCommand(){window.open("https://github.com/TriliumNext/Notes/releases/latest")}activeContextChangedEvent(){this.dropdown.hide()}noteSwitchedEvent(){this.dropdown.hide()}}var Ka={exports:{}},gc={exports:{}};/*!
|
||
* Infinite Scroll v2.0.4
|
||
* measure size of elements
|
||
* MIT license
|
||
*/var fu;function Cb(){return fu||(fu=1,function(o){(function(t,e){o.exports?o.exports=e():t.getSize=e()})(window,function(){function e(a){let l=parseFloat(a);return a.indexOf("%")==-1&&!isNaN(l)&&l}let i=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"];function n(){let a={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0};return i.forEach(l=>{a[l]=0}),a}function s(a){if(typeof a=="string"&&(a=document.querySelector(a)),!(a&&typeof a=="object"&&a.nodeType))return;let c=getComputedStyle(a);if(c.display=="none")return n();let u={};u.width=a.offsetWidth,u.height=a.offsetHeight;let p=u.isBorderBox=c.boxSizing=="border-box";i.forEach(H=>{let Q=c[H],tt=parseFloat(Q);u[H]=isNaN(tt)?0:tt});let v=u.paddingLeft+u.paddingRight,x=u.paddingTop+u.paddingBottom,T=u.marginLeft+u.marginRight,M=u.marginTop+u.marginBottom,P=u.borderLeftWidth+u.borderRightWidth,F=u.borderTopWidth+u.borderBottomWidth,R=e(c.width);R!==!1&&(u.width=R+(p?0:v+P));let q=e(c.height);return q!==!1&&(u.height=q+(p?0:x+F)),u.innerWidth=u.width-(v+P),u.innerHeight=u.height-(x+F),u.outerWidth=u.width+T,u.outerHeight=u.height+M,u}return s})}(gc)),gc.exports}var Za={exports:{}},Ga={exports:{}},$b=Ga.exports,mu;function Sb(){return mu||(mu=1,function(o){(function(t,e){o.exports?o.exports=e():t.EvEmitter=e()})(typeof window<"u"?window:$b,function(){function t(){}let e=t.prototype;return e.on=function(i,n){if(!i||!n)return this;let s=this._events=this._events||{},a=s[i]=s[i]||[];return a.includes(n)||a.push(n),this},e.once=function(i,n){if(!i||!n)return this;this.on(i,n);let s=this._onceEvents=this._onceEvents||{},a=s[i]=s[i]||{};return a[n]=!0,this},e.off=function(i,n){let s=this._events&&this._events[i];if(!s||!s.length)return this;let a=s.indexOf(n);return a!=-1&&s.splice(a,1),this},e.emitEvent=function(i,n){let s=this._events&&this._events[i];if(!s||!s.length)return this;s=s.slice(0),n=n||[];let a=this._onceEvents&&this._onceEvents[i];for(let l of s)a&&a[l]&&(this.off(i,l),delete a[l]),l.apply(this,n);return this},e.allOff=function(){return delete this._events,delete this._onceEvents,this},t})}(Ga)),Ga.exports}/*!
|
||
* Unidragger v3.0.1
|
||
* Draggable base class
|
||
* MIT license
|
||
*/var Tb=Za.exports,gu;function Eb(){return gu||(gu=1,function(o){(function(t,e){o.exports?o.exports=e(t,Sb()):t.Unidragger=e(t,t.EvEmitter)})(typeof window<"u"?window:Tb,function(e,i){function n(){}let s=n.prototype=Object.create(i.prototype);s.handleEvent=function(p){let v="on"+p.type;this[v]&&this[v](p)};let a,l;"ontouchstart"in e?(a="touchstart",l=["touchmove","touchend","touchcancel"]):e.PointerEvent?(a="pointerdown",l=["pointermove","pointerup","pointercancel"]):(a="mousedown",l=["mousemove","mouseup"]),s.touchActionValue="none",s.bindHandles=function(){this._bindHandles("addEventListener",this.touchActionValue)},s.unbindHandles=function(){this._bindHandles("removeEventListener","")},s._bindHandles=function(p,v){this.handles.forEach(x=>{x[p](a,this),x[p]("click",this),e.PointerEvent&&(x.style.touchAction=v)})},s.bindActivePointerEvents=function(){l.forEach(p=>{e.addEventListener(p,this)})},s.unbindActivePointerEvents=function(){l.forEach(p=>{e.removeEventListener(p,this)})},s.withPointer=function(p,v){v.pointerId===this.pointerIdentifier&&this[p](v,v)},s.withTouch=function(p,v){let x;for(let T of v.changedTouches)T.identifier===this.pointerIdentifier&&(x=T);x&&this[p](v,x)},s.onmousedown=function(p){this.pointerDown(p,p)},s.ontouchstart=function(p){this.pointerDown(p,p.changedTouches[0])},s.onpointerdown=function(p){this.pointerDown(p,p)};const c=["TEXTAREA","INPUT","SELECT","OPTION"],u=["radio","checkbox","button","submit","image","file"];return s.pointerDown=function(p,v){let x=c.includes(p.target.nodeName),T=u.includes(p.target.type),M=!x||T;!this.isPointerDown&&!p.button&&M&&(this.isPointerDown=!0,this.pointerIdentifier=v.pointerId!==void 0?v.pointerId:v.identifier,this.pointerDownPointer={pageX:v.pageX,pageY:v.pageY},this.bindActivePointerEvents(),this.emitEvent("pointerDown",[p,v]))},s.onmousemove=function(p){this.pointerMove(p,p)},s.onpointermove=function(p){this.withPointer("pointerMove",p)},s.ontouchmove=function(p){this.withTouch("pointerMove",p)},s.pointerMove=function(p,v){let x={x:v.pageX-this.pointerDownPointer.pageX,y:v.pageY-this.pointerDownPointer.pageY};this.emitEvent("pointerMove",[p,v,x]),!this.isDragging&&this.hasDragStarted(x)&&this.dragStart(p,v),this.isDragging&&this.dragMove(p,v,x)},s.hasDragStarted=function(p){return Math.abs(p.x)>3||Math.abs(p.y)>3},s.dragStart=function(p,v){this.isDragging=!0,this.isPreventingClicks=!0,this.emitEvent("dragStart",[p,v])},s.dragMove=function(p,v,x){this.emitEvent("dragMove",[p,v,x])},s.onmouseup=function(p){this.pointerUp(p,p)},s.onpointerup=function(p){this.withPointer("pointerUp",p)},s.ontouchend=function(p){this.withTouch("pointerUp",p)},s.pointerUp=function(p,v){this.pointerDone(),this.emitEvent("pointerUp",[p,v]),this.isDragging?this.dragEnd(p,v):this.staticClick(p,v)},s.dragEnd=function(p,v){this.isDragging=!1,setTimeout(()=>delete this.isPreventingClicks),this.emitEvent("dragEnd",[p,v])},s.pointerDone=function(){this.isPointerDown=!1,delete this.pointerIdentifier,this.unbindActivePointerEvents(),this.emitEvent("pointerDone")},s.onpointercancel=function(p){this.withPointer("pointerCancel",p)},s.ontouchcancel=function(p){this.withTouch("pointerCancel",p)},s.pointerCancel=function(p,v){this.pointerDone(),this.emitEvent("pointerCancel",[p,v])},s.onclick=function(p){this.isPreventingClicks&&p.preventDefault()},s.staticClick=function(p,v){let x=p.type==="mouseup";x&&this.isIgnoringMouseUp||(this.emitEvent("staticClick",[p,v]),x&&(this.isIgnoringMouseUp=!0,setTimeout(()=>{delete this.isIgnoringMouseUp},400)))},n})}(Za)),Za.exports}/*!
|
||
* Draggabilly v3.0.0
|
||
* Make that shiz draggable
|
||
* https://draggabilly.desandro.com
|
||
* MIT license
|
||
*/var Ib=Ka.exports,vu;function Ab(){return vu||(vu=1,function(o){(function(t,e){o.exports?o.exports=e(t,Cb(),Eb()):t.Draggabilly=e(t,t.getSize,t.Unidragger)})(typeof window<"u"?window:Ib,function(e,i,n){function s(){}let a=e.jQuery;function l(M,P){this.element=typeof M=="string"?document.querySelector(M):M,a&&(this.$element=a(this.element)),this.options={},this.option(P),this._create()}let c=l.prototype=Object.create(n.prototype);c.option=function(M){this.options={...this.options,...M}};const u=["relative","absolute","fixed"];c._create=function(){this.position={},this._getPosition(),this.startPoint={x:0,y:0},this.dragPoint={x:0,y:0},this.startPosition={...this.position};let M=getComputedStyle(this.element);u.includes(M.position)||(this.element.style.position="relative"),this.on("pointerDown",this.handlePointerDown),this.on("pointerUp",this.handlePointerUp),this.on("dragStart",this.handleDragStart),this.on("dragMove",this.handleDragMove),this.on("dragEnd",this.handleDragEnd),this.setHandles(),this.enable()},c.setHandles=function(){let{handle:M}=this.options;typeof M=="string"?this.handles=this.element.querySelectorAll(M):typeof M=="object"&&M.length?this.handles=M:M instanceof HTMLElement?this.handles=[M]:this.handles=[this.element]};const p=["dragStart","dragMove","dragEnd"];let v=c.emitEvent;c.emitEvent=function(M,P){if(!this.isEnabled&&p.includes(M))return;v.call(this,M,P);let R=e.jQuery;if(!R||!this.$element)return;let q,H=P;P&&P[0]instanceof Event&&([q,...H]=P);let tt=R.Event(q);tt.type=M,this.$element.trigger(tt,H)},c._getPosition=function(){let M=getComputedStyle(this.element),P=this._getPositionCoord(M.left,"width"),F=this._getPositionCoord(M.top,"height");this.position.x=isNaN(P)?0:P,this.position.y=isNaN(F)?0:F,this._addTransformPosition(M)},c._getPositionCoord=function(M,P){if(M.includes("%")){let F=i(this.element.parentNode);return F?parseFloat(M)/100*F[P]:0}return parseInt(M,10)},c._addTransformPosition=function(M){let P=M.transform;if(!P.startsWith("matrix"))return;let F=P.split(","),R=P.startsWith("matrix3d")?12:4,q=parseInt(F[R],10),H=parseInt(F[R+1],10);this.position.x+=q,this.position.y+=H},c.handlePointerDown=function(M,P){this.isEnabled&&(this.pointerDownPointer={pageX:P.pageX,pageY:P.pageY},M.preventDefault(),document.activeElement.blur(),this.bindActivePointerEvents(M),this.element.classList.add("is-pointer-down"))},c.handleDragStart=function(){this.isEnabled&&(this._getPosition(),this.measureContainment(),this.startPosition.x=this.position.x,this.startPosition.y=this.position.y,this.setLeftTop(),this.dragPoint.x=0,this.dragPoint.y=0,this.element.classList.add("is-dragging"),this.animate())},c.measureContainment=function(){let M=this.getContainer();if(!M)return;let P=i(this.element),F=i(M),{borderLeftWidth:R,borderRightWidth:q,borderTopWidth:H,borderBottomWidth:Q}=F,tt=this.element.getBoundingClientRect(),it=M.getBoundingClientRect(),rt=R+q,vt=H+Q,Dt=this.relativeStartPosition={x:tt.left-(it.left+R),y:tt.top-(it.top+H)};this.containSize={width:F.width-rt-Dt.x-P.width,height:F.height-vt-Dt.y-P.height}},c.getContainer=function(){let M=this.options.containment;return M?M instanceof HTMLElement?M:typeof M=="string"?document.querySelector(M):this.element.parentNode:void 0},c.handleDragMove=function(M,P,F){if(!this.isEnabled)return;let R=F.x,q=F.y,H=this.options.grid,Q=H&&H[0],tt=H&&H[1];R=x(R,Q),q=x(q,tt),R=this.containDrag("x",R,Q),q=this.containDrag("y",q,tt),R=this.options.axis=="y"?0:R,q=this.options.axis=="x"?0:q,this.position.x=this.startPosition.x+R,this.position.y=this.startPosition.y+q,this.dragPoint.x=R,this.dragPoint.y=q};function x(M,P,F){return P?(F=F||"round",Math[F](M/P)*P):M}c.containDrag=function(M,P,F){if(!this.options.containment)return P;let R=M=="x"?"width":"height",q=this.relativeStartPosition[M],H=x(-q,F,"ceil"),Q=this.containSize[R];return Q=x(Q,F,"floor"),Math.max(H,Math.min(Q,P))},c.handlePointerUp=function(){this.element.classList.remove("is-pointer-down")},c.handleDragEnd=function(){this.isEnabled&&(this.element.style.transform="",this.setLeftTop(),this.element.classList.remove("is-dragging"))},c.animate=function(){this.isDragging&&(this.positionDrag(),requestAnimationFrame(()=>this.animate()))},c.setLeftTop=function(){let{x:M,y:P}=this.position;this.element.style.left=`${M}px`,this.element.style.top=`${P}px`},c.positionDrag=function(){let{x:M,y:P}=this.dragPoint;this.element.style.transform=`translate3d(${M}px, ${P}px, 0)`},c.setPosition=function(M,P){this.position.x=M,this.position.y=P,this.setLeftTop()},c.enable=function(){this.isEnabled||(this.isEnabled=!0,this.bindHandles())},c.disable=function(){this.isEnabled&&(this.isEnabled=!1,this.isDragging&&this.dragEnd(),this.unbindHandles())};const T=["transform","left","top","position"];return c.destroy=function(){this.disable(),T.forEach(M=>{this.element.style[M]=""}),this.unbindHandles(),this.$element&&this.$element.removeData("draggabilly")},c._init=s,a&&a.bridget&&a.bridget("draggabilly",l),l})}(Ka)),Ka.exports}var Lb=Ab();const Nb=Br(Lb);async function Mb(o,t,e=""){await pt.put(`notes/${o}/attribute`,{type:"label",name:t,value:e})}async function Pb(o,t,e=""){await pt.put(`notes/${o}/set-attribute`,{type:"label",name:t,value:e})}async function zf(o,t){await pt.remove(`notes/${o}/attributes/${t}`)}function Ob(o,t){const e=o.getOwnedLabel(t);return e?(zf(o.noteId,e.attributeId),!0):!1}async function Db(o,t,e,i){if(i)await pt.put(`notes/${o.noteId}/set-attribute`,{type:t,name:e,value:i});else{const n=o.getAttribute(t,e)?.attributeId;n&&await pt.remove(`notes/${o.noteId}/attributes/${n}`)}}function Rb(o,t){if(!t||!o)return!1;const e=o.noteId&&Mt.notes[o.noteId];if(!e)return!1;const i=[t,...t.getNotesToInheritAttributesFrom()];for(const n of i)if(n.noteId===e.noteId)return!0;if(this.isInheritable){for(const n of i)if(n.hasAncestor(e.noteId,!0))return!0}return!1}const Be={addLabel:Mb,setLabel:Pb,setAttribute:Db,removeAttributeById:zf,removeOwnedLabelByName:Ob,isAffecting:Rb},Bb=ct.isDesktop(),yu=100,bu=240,wu=5,_u=36,xu=36,Ff=Bb?50:15,ma=5,zb=84,Fb=60,Wb=48,Hb=`
|
||
<div class="note-tab">
|
||
<div class="note-tab-wrapper">
|
||
<div class="note-tab-drag-handle"></div>
|
||
<div class="note-tab-icon"></div>
|
||
<div class="note-tab-title"></div>
|
||
<div class="note-tab-close bx bx-x" title="${m("tab_row.close_tab")}"></div>
|
||
</div>
|
||
</div>`,Vb='<div class="tab-row-container-anchor"></div>',Ub=`<div class="note-new-tab" data-trigger-command="openNewTab" title="${m("tab_row.add_new_tab")}">+</div>`,jb='<div class="tab-row-filler"></div>',qb=`
|
||
<div class="tab-row-widget">
|
||
<style>
|
||
.tab-row-widget {
|
||
display:flex;
|
||
box-sizing: border-box;
|
||
position: relative;
|
||
width: 100%;
|
||
background: var(--main-background-color);
|
||
user-select: none;
|
||
}
|
||
|
||
.tab-row-widget.full-width {
|
||
background: var(--launcher-pane-background-color);
|
||
}
|
||
|
||
.tab-row-widget * {
|
||
box-sizing: inherit;
|
||
font: inherit;
|
||
}
|
||
|
||
.tab-row-widget .tab-row-widget-container {
|
||
box-sizing: border-box;
|
||
position: relative;
|
||
height: 100%;
|
||
}
|
||
|
||
.tab-row-widget .note-tab {
|
||
position: absolute;
|
||
left: 0;
|
||
width: 240px;
|
||
border: 0;
|
||
margin: 0;
|
||
z-index: 1;
|
||
pointer-events: none;
|
||
}
|
||
|
||
.note-new-tab {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex: 0 0 ${xu}px;
|
||
height: ${xu}px;
|
||
padding: 1px;
|
||
font-size: 24px;
|
||
cursor: pointer;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.note-new-tab:hover {
|
||
background-color: var(--accented-background-color);
|
||
border-radius: var(--button-border-radius);
|
||
}
|
||
|
||
.tab-row-filler {
|
||
box-sizing: border-box;
|
||
-webkit-app-region: drag;
|
||
height: 100%;
|
||
min-width: ${Ff}px;
|
||
flex-grow: 1;
|
||
}
|
||
|
||
.tab-row-container-anchor{
|
||
position: absolute;
|
||
left: 0;
|
||
width: 0px;
|
||
height: 36px;
|
||
border: 0;
|
||
margin: 0;
|
||
z-index: 1;
|
||
cursor: pointer;
|
||
box-sizing: border-box;
|
||
}
|
||
body.mobile .tab-row-filler {
|
||
display: none;
|
||
}
|
||
|
||
.tab-row-widget .note-tab[active] {
|
||
z-index: 5;
|
||
}
|
||
|
||
.tab-row-widget .note-tab,
|
||
.tab-row-widget .note-tab * {
|
||
cursor: default;
|
||
}
|
||
|
||
.tab-row-widget .note-tab.note-tab-was-just-added {
|
||
top: 10px;
|
||
animation: note-tab-was-just-added 120ms forwards ease-in-out;
|
||
}
|
||
|
||
.tab-row-widget .note-tab .note-tab-wrapper {
|
||
position: absolute;
|
||
display: flex;
|
||
align-items: center;
|
||
top: 0;
|
||
bottom: 0;
|
||
left: 0;
|
||
right: 0;
|
||
height: 36px;
|
||
padding: 7px 5px 7px 11px;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
pointer-events: all;
|
||
color: var(--inactive-tab-text-color);
|
||
--tab-background-color: var(--workspace-tab-background-color);
|
||
background-color: var(--tab-background-color, var(--inactive-tab-background-color));
|
||
}
|
||
|
||
.tab-row-widget .note-tab[active] .note-tab-wrapper {
|
||
font-weight: bold;
|
||
color: var(--active-tab-text-color);
|
||
background-color : var(--tab-background-color, var(--active-tab-background-color));
|
||
}
|
||
|
||
.tab-row-widget .note-tab[is-mini] .note-tab-wrapper {
|
||
padding-left: 2px;
|
||
padding-right: 2px;
|
||
}
|
||
|
||
.tab-row-widget .note-tab .note-tab-title {
|
||
flex: 1;
|
||
vertical-align: top;
|
||
overflow: hidden;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.tab-row-widget .note-tab .note-tab-icon {
|
||
position: relative;
|
||
top: -1px;
|
||
padding-right: 3px;
|
||
}
|
||
|
||
.tab-row-widget .note-tab[is-small] .note-tab-title {
|
||
margin-left: 0;
|
||
}
|
||
|
||
.tab-row-widget .note-tab .note-tab-drag-handle {
|
||
position: absolute;
|
||
top: 0;
|
||
bottom: 0;
|
||
right: 0;
|
||
left: 0;
|
||
z-index: 50;
|
||
}
|
||
|
||
.tab-row-widget .note-tab .note-tab-close {
|
||
flex: 0 0 22px;
|
||
border-radius: 50%;
|
||
z-index: 100;
|
||
width: 22px;
|
||
height: 22px;
|
||
cursor: pointer;
|
||
text-align: center;
|
||
}
|
||
|
||
.tab-scroll-button-left, .tab-scroll-button-right {
|
||
display: none;
|
||
flex: 0 0 ${_u}px;
|
||
height: ${_u}px;
|
||
padding: 1px 1px 1px 1px;
|
||
align-items: center;
|
||
justify-content: center;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.tab-scroll-button-left {
|
||
color: var(--active-tab-text-color);
|
||
box-shadow: inset -1px 0 0 0 var(--main-border-color);
|
||
}
|
||
|
||
.tab-scroll-button-right {
|
||
color: var(--active-tab-text-color);
|
||
box-shadow: inset 1px 0 0 0 var(--main-border-color);
|
||
}
|
||
|
||
.tab-scroll-button-left.disabled,
|
||
.tab-scroll-button-right.disabled {
|
||
color: var(--inactive-tab-text-color);
|
||
box-shadow: none;
|
||
pointer-events: none;
|
||
}
|
||
|
||
.tab-scroll-button-left:hover,
|
||
.tab-scroll-button-right:hover {
|
||
background-color: var(--tab-background-color, var(--inactive-tab-hover-background-color));
|
||
}
|
||
|
||
.tab-row-widget .note-tab:hover .note-tab-wrapper {
|
||
background-color: var(--tab-background-color, var(--inactive-tab-hover-background-color));
|
||
}
|
||
|
||
.tab-row-widget .note-tab[active]:hover .note-tab-wrapper {
|
||
background-color: var(--tab-background-color, var(--active-tab-hover-background-color));
|
||
}
|
||
|
||
body.desktop .tab-row-widget .note-tab .note-tab-close:hover {
|
||
background-color: var(--hover-item-background-color);
|
||
color: var(--hover-item-text-color);
|
||
}
|
||
|
||
.tab-row-widget .note-tab[is-smaller] .note-tab-close {
|
||
margin-left: auto;
|
||
}
|
||
.tab-row-widget .note-tab[is-mini]:not([active]) .note-tab-close {
|
||
display: none;
|
||
}
|
||
.tab-row-widget .note-tab[is-mini][active] .note-tab-close {
|
||
margin-left: auto;
|
||
margin-right: auto;
|
||
}
|
||
@-moz-keyframes note-tab-was-just-added {
|
||
to {
|
||
top: 0;
|
||
}
|
||
}
|
||
@-webkit-keyframes note-tab-was-just-added {
|
||
to {
|
||
top: 0;
|
||
}
|
||
}
|
||
@-o-keyframes note-tab-was-just-added {
|
||
to {
|
||
top: 0;
|
||
}
|
||
}
|
||
@keyframes note-tab-was-just-added {
|
||
to {
|
||
top: 0;
|
||
}
|
||
}
|
||
.tab-row-widget.tab-row-widget-is-sorting .note-tab:not(.note-tab-is-dragging),
|
||
.tab-row-widget:not(.tab-row-widget-is-sorting) .note-tab.note-tab-was-just-dragged {
|
||
transition: transform 120ms ease-in-out;
|
||
}
|
||
.tab-row-widget-wrapper {
|
||
display: flex;
|
||
box-sizing: border-box;
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
|
||
.tab-row-widget-scrolling-container {
|
||
overflow-x: auto;
|
||
overflow-y: hidden;
|
||
scrollbar-width: none; /* Firefox */
|
||
}
|
||
|
||
/* Chrome/Safari */
|
||
.tab-row-widget-scrolling-container::-webkit-scrollbar {
|
||
display: none;
|
||
}
|
||
|
||
</style>
|
||
<div class="tab-scroll-button-left bx bx-chevron-left"></div>
|
||
<div class="tab-row-widget-scrolling-container">
|
||
<div class="tab-row-widget-container"></div>
|
||
</div>
|
||
<div class="tab-scroll-button-right bx bx-chevron-right"></div>
|
||
</div>`;class EA extends ge{isDragging;showNoteIcons;draggabillies;draggabillyDragging;$style;$tabScrollingContainer;$tabContainer;$scrollButtonLeft;$scrollButtonRight;$containerAnchor;$filler;$newTab;updateScrollTimeout;newTabOuterWidth=0;scrollButtonsOuterWidth=0;doRender(){this.$widget=$(qb),this.$tabScrollingContainer=this.$widget.children(".tab-row-widget-scrolling-container"),this.$tabContainer=this.$widget.find(".tab-row-widget-container"),this.$scrollButtonLeft=this.$widget.children(".tab-scroll-button-left"),this.$scrollButtonRight=this.$widget.children(".tab-scroll-button-right");const t=window.getComputedStyle(document.documentElement);this.showNoteIcons=t.getPropertyValue("--tab-note-icons")==="true",this.draggabillies=[],this.setupStyle(),this.setupEvents(),this.setupContainerAnchor(),this.setupDraggabilly(),this.setupNewButton(),this.setupFiller(),this.layoutTabs(),this.setVisibility(),this.setupScrollEvents(),this.$widget.on("contextmenu",".note-tab",e=>{e.preventDefault();const i=$(e.target).closest(".note-tab").attr("data-ntx-id");Ho.show({x:e.pageX,y:e.pageY,items:[{title:m("tab_row.close"),command:"closeTab",uiIcon:"bx bx-x"},{title:m("tab_row.close_other_tabs"),command:"closeOtherTabs",uiIcon:"bx bx-empty",enabled:Pt.tabManager.noteContexts.length!==1},{title:m("tab_row.close_right_tabs"),command:"closeRightTabs",uiIcon:"bx bx-empty",enabled:Pt.tabManager.noteContexts?.at(-1)?.ntxId!==i},{title:m("tab_row.close_all_tabs"),command:"closeAllTabs",uiIcon:"bx bx-empty"},{title:"----"},{title:m("tab_row.reopen_last_tab"),command:"reopenLastTab",uiIcon:"bx bx-undo",enabled:Pt.tabManager.recentlyClosedTabs.length!==0},{title:"----"},{title:m("tab_row.move_tab_to_new_window"),command:"moveTabToNewWindow",uiIcon:"bx bx-window-open"},{title:m("tab_row.copy_tab_to_new_window"),command:"copyTabToNewWindow",uiIcon:"bx bx-empty"}],selectMenuItemHandler:({command:n})=>{n&&this.triggerCommand(n,{ntxId:i})}})})}setupStyle(){this.$style=$("<style>"),this.$widget.append(this.$style)}scrollTabContainer(t,e="smooth"){this.$tabScrollingContainer[0].scrollBy({left:t,behavior:e})}setupScrollEvents(){this.$tabScrollingContainer.on("wheel",t=>{const e=t.originalEvent;ct.isCtrlKey(t)||t.altKey||t.shiftKey||(t.preventDefault(),t.stopImmediatePropagation(),t.currentTarget.scrollLeft+=e.deltaY+e.deltaX)}),this.$scrollButtonLeft[0].addEventListener("click",()=>this.scrollTabContainer(-210)),this.$scrollButtonRight[0].addEventListener("click",()=>this.scrollTabContainer(210)),this.$tabScrollingContainer[0].addEventListener("scroll",()=>{clearTimeout(this.updateScrollTimeout),this.updateScrollTimeout=setTimeout(()=>{this.updateScrollButtonState()},100)})}updateScrollButtonState(){const t=this.$tabScrollingContainer[0].scrollLeft,e=this.$tabScrollingContainer[0].scrollWidth,i=this.$tabScrollingContainer[0].clientWidth;this.$scrollButtonLeft.toggleClass("disabled",Math.abs(t)<=1),this.$scrollButtonRight.toggleClass("disabled",Math.abs(t+i-e)<=1)}setScrollButtonVisibility(t=!0){t?(this.$scrollButtonLeft.css("display","flex"),this.$scrollButtonRight.css("display","flex"),clearTimeout(this.updateScrollTimeout),this.updateScrollTimeout=setTimeout(()=>{this.updateScrollButtonState()},200)):(this.$scrollButtonLeft.css("display","none"),this.$scrollButtonRight.css("display","none"))}setupEvents(){new ResizeObserver(t=>{this.cleanUpPreviouslyDraggedTabs(),this.layoutTabs()}).observe(this.$widget[0]),this.tabEls.forEach(t=>this.setTabCloseEvent(t))}setVisibility(){this.$widget.show()}get tabEls(){return Array.prototype.slice.call(this.$widget.find(".note-tab"))}updateOuterWidth(){this.newTabOuterWidth==0&&(this.newTabOuterWidth=this.$newTab?.outerWidth(!0)??0),this.scrollButtonsOuterWidth==0&&(this.scrollButtonsOuterWidth=(this.$scrollButtonLeft?.outerWidth(!0)??0)+(this.$scrollButtonRight?.outerWidth(!0)??0))}get tabWidths(){const t=this.tabEls.length;this.updateOuterWidth();let e=Math.floor((this.$widget.width()??0)-this.newTabOuterWidth-Ff);(yu+ma)*t>e?(e-=this.scrollButtonsOuterWidth,this.setScrollButtonVisibility(!0)):this.setScrollButtonVisibility(!1);const i=(t-1)*ma+wu,n=(e-i)/t,s=Math.max(yu,Math.min(bu,n)),a=Math.floor(s),l=a*t+i,c=e-l,u=[];let p=c;for(let v=0;v<t;v+=1){const x=a<bu&&p>=1?1:0;u.push(a+x),p>=1&&(p-=1)}return u}getTabPositions(){const t=[];let e=wu;return this.tabWidths.forEach(n=>{t.push(e),e+=n+ma}),e-=ma,{tabPositions:t,anchorPosition:e}}layoutTabs(){const t=this.tabWidths;this.tabEls.forEach((s,a)=>{const l=t[a];s.style.width=`${l}px`,s.removeAttribute("is-small"),s.removeAttribute("is-smaller"),s.removeAttribute("is-mini"),l<zb&&s.setAttribute("is-small",""),l<Fb&&s.setAttribute("is-smaller",""),l<Wb&&s.setAttribute("is-mini","")});let e="";const{tabPositions:i,anchorPosition:n}=this.getTabPositions();i.forEach((s,a)=>{e+=`.note-tab:nth-child(${a+1}) { transform: translate3d(${s}px, 0, 0)} `}),e+=`.tab-row-container-anchor { transform: translate3d(${n}px, 0, 0) } `,e+=`.tab-row-widget-container {width: ${n}px}`,this.$style.html(e)}addTab(t){const e=$(Hb).attr("data-ntx-id",t);qo.updateDisplayedShortcuts(e),e.addClass("note-tab-was-just-added"),setTimeout(()=>e.removeClass("note-tab-was-just-added"),500),this.$containerAnchor.before(e),this.setVisibility(),this.setTabCloseEvent(e),this.updateTitle(e,m("tab_row.new_tab")),this.cleanUpPreviouslyDraggedTabs(),this.layoutTabs(),this.setupDraggabilly()}closeActiveTabCommand({$el:t}){const e=t.closest(".note-tab").attr("data-ntx-id");Pt.tabManager.removeNoteContext(e??null)}setTabCloseEvent(t){t.on("mousedown",e=>{if(e.which===2)return Pt.tabManager.removeNoteContext(t.attr("data-ntx-id")??null),!0}),t.find(".note-tab-close").on("click",e=>(this.triggerCommand("closeActiveTab",{$el:$(e.target)}),!0))}get activeTabEl(){return this.$widget.find(".note-tab[active]")[0]}activeContextChangedEvent(){let t=Pt.tabManager.getActiveContext();if(!t)return;t.mainNtxId&&(t=Pt.tabManager.getNoteContextById(t.mainNtxId));const e=this.getTabById(t.ntxId)[0],i=this.activeTabEl;i!==e&&(i&&i.removeAttribute("active"),e&&e.setAttribute("active",""))}newNoteContextCreatedEvent({noteContext:t}){!t.mainNtxId&&t.ntxId&&this.addTab(t.ntxId)}removeTab(t){const e=this.getTabById(t)[0];e&&(e.parentNode?.removeChild(e),this.cleanUpPreviouslyDraggedTabs(),this.layoutTabs(),this.setupDraggabilly(),this.setVisibility())}getNtxIdsInOrder(){return this.tabEls.map(t=>t.getAttribute("data-ntx-id"))}updateTitle(t,e){t.attr("title",e),t.find(".note-tab-title").text(e)}getTabById(t){return this.$widget.find(`[data-ntx-id='${t}']`)}getTabId(t){return t.attr("data-ntx-id")}noteContextRemovedEvent({ntxIds:t}){for(const e of t)this.removeTab(e)}cleanUpPreviouslyDraggedTabs(){this.tabEls.forEach(t=>t.classList.remove("note-tab-was-just-dragged"))}setupDraggabilly(){const t=this.tabEls,{tabPositions:e}=this.getTabPositions();let i=0;this.isDragging&&this.draggabillyDragging&&(this.isDragging=!1,this.$widget.removeClass("tab-row-widget-is-sorting"),this.draggabillyDragging.element.classList.remove("note-tab-is-dragging"),this.draggabillyDragging.element.style.transform="",this.draggabillyDragging.dragEnd(),this.draggabillyDragging.isDragging=!1,this.draggabillyDragging.positionDrag=()=>{},this.draggabillyDragging.destroy(),this.draggabillyDragging=null),this.draggabillies.forEach(n=>n.destroy()),t.forEach((n,s)=>{const a=e[s],l=new Nb(n,{axis:"x",handle:".note-tab-drag-handle",containment:this.$tabContainer[0]});this.draggabillies.push(l),l.on("staticClick",()=>{Pt.tabManager.activateNoteContext(n.getAttribute("data-ntx-id"))}),l.on("dragStart",()=>{this.isDragging=!0,this.draggabillyDragging=l,n.classList.add("note-tab-is-dragging"),this.$widget.addClass("tab-row-widget-is-sorting"),i=this.$tabScrollingContainer?.scrollLeft()??0,l.positionDrag=()=>{}}),l.on("dragEnd",()=>{this.isDragging=!1;const u=(this.$tabScrollingContainer?.scrollLeft()??0)-i,p=parseFloat(n.style.left)+u,v=this.$tabContainer[0]?.offsetWidth-n.offsetWidth,T=Math.min(v,Math.max(0,p));n.style.transform="translate3d(0, 0, 0)",requestAnimationFrame(M=>{n.style.left="0",n.style.transform=`translate3d(${T}px, 0, 0)`,requestAnimationFrame(P=>{n.classList.remove("note-tab-is-dragging"),this.$widget.removeClass("tab-row-widget-is-sorting"),n.classList.add("note-tab-was-just-dragged"),requestAnimationFrame(F=>{n.style.transform="",this.layoutTabs(),this.setupDraggabilly()})})})}),l.on("dragMove",(c,u,p)=>{const v=this.tabEls,x=v.indexOf(n),T=this.$tabScrollingContainer[0]?.getBoundingClientRect(),M=u.pageX;M<T.left?this.scrollTabContainer(-105):M>T.right&&this.scrollTabContainer(105);const R=(this.$tabScrollingContainer?.scrollLeft()??0)-i;let q=p.x+R;const H=this.$tabContainer[0]?.offsetWidth-n.offsetWidth-a,Q=-a;q=Math.min(H,Math.max(Q,q)),n.style.transform=`translate3d(${q}px, 0, 0)`;const tt=a+q,it=this.closest(tt,e),rt=Math.max(0,Math.min(v.length,it));x!==rt&&this.animateTabMove(n,x,rt),Math.abs(p.y)>100&&this.triggerCommand("moveTabToNewWindow",{ntxId:this.getTabId($(n))})})})}animateTabMove(t,e,i){if(i<e)t.parentNode?.insertBefore(t,this.tabEls[i]);else{const n=this.tabEls[i+1]||this.$containerAnchor[0];t.parentNode?.insertBefore(t,n)}this.triggerEvent("tabReorder",{ntxIdsInOrder:this.getNtxIdsInOrder()}),this.layoutTabs()}setupNewButton(){this.$newTab=$(Ub),this.$widget.append(this.$newTab)}setupFiller(){this.$filler=$(jb),this.$widget.append(this.$filler)}setupContainerAnchor(){this.$containerAnchor=$(Vb),this.$tabContainer.append(this.$containerAnchor)}closest(t,e){let i=1/0,n=-1;return e.forEach((s,a)=>{Math.abs(t-s)<i&&(i=Math.abs(t-s),n=a)}),n}noteSwitchedAndActivatedEvent({noteContext:t}){this.activeContextChangedEvent(),this.updateTabById(t.mainNtxId||t.ntxId)}noteSwitchedEvent({noteContext:t}){this.updateTabById(t.mainNtxId||t.ntxId)}noteContextReorderEvent({oldMainNtxId:t,newMainNtxId:e}){!t||!e||(this.getTabById(t).attr("data-ntx-id",e),this.updateTabById(e))}contextsReopenedEvent({mainNtxId:t,tabPosition:e}){if(!t||!e)return;const i=this.getTabById(t)[0];i.parentNode?.insertBefore(i,this.tabEls[e])}updateTabById(t){const e=this.getTabById(t);e[0].scrollIntoView({behavior:"smooth"});const i=Pt.tabManager.getNoteContextById(t);this.updateTab(e,i)}async updateTab(t,e){if(!t.length)return;for(const a of Array.from(t[0].classList))a!=="note-tab"&&t.removeClass(a);let i="";if(e){const a=Mt.getNoteFromCache(e.hoistedNoteId);a?(t.find(".note-tab-wrapper").css("--workspace-tab-background-color",a.getWorkspaceTabBackgroundColor()),this.showNoteIcons||(i=a.getWorkspaceIconClass())):t.find(".note-tab-wrapper").removeAttr("style")}const{note:n}=e;if(!n){this.updateTitle(t,m("tab_row.new_tab"));return}const s=await e.getNavigationTitle();s&&this.updateTitle(t,s),t.addClass(n.getCssClass()),t.addClass(ct.getNoteTypeClass(n.type)),t.addClass(ct.getMimeTypeClass(n.mime)),this.showNoteIcons&&(i=n.getIcon()),i&&t.find(".note-tab-icon").removeClass().addClass("note-tab-icon").addClass(i)}async entitiesReloadedEvent({loadResults:t}){for(const e of Pt.tabManager.noteContexts)if(e.noteId&&(t.isNoteReloaded(e.noteId)||t.getAttributeRows().find(i=>["workspace","workspaceIconClass","workspaceTabBackgroundColor"].includes(i.name||"")&&Be.isAffecting(i,e.note)))){const i=this.getTabById(e.ntxId);this.updateTab(i,e)}}frocaReloadedEvent(){for(const t of Pt.tabManager.noteContexts){const e=this.getTabById(t.ntxId);this.updateTab(e,t)}}hoistedNoteChangedEvent({ntxId:t}){const e=this.getTabById(t);if(e&&t){const i=Pt.tabManager.getNoteContextById(t);this.updateTab(e,i)}}}async function Kb(o,t){o=Nl(o),o=Wf(o);const e=Mt.getBranch(t);if(e){if(e.noteId==="root"||ct.isLaunchBarConfig(e.noteId)){ft.showError(m("branches.cannot-move-notes-here"));return}for(const i of o){const n=await pt.put(`branches/${i}/move-before/${t}`);if(!n.success){ft.showError(n.message);return}}}}async function Zb(o,t){o=Nl(o),o=Wf(o);const e=await Mt.getBranch(t)?.getNote();if(!e)return;if(["root",li.getHoistedNoteId(),"_lbRoot","_lbAvailableLaunchers","_lbVisibleLaunchers"].includes(e.noteId)){ft.showError(m("branches.cannot-move-notes-here"));return}o.reverse();for(const n of o){const s=await pt.put(`branches/${n}/move-after/${t}`);if(!s.success){ft.showError(s.message);return}}}async function Gb(o,t){const e=Mt.getBranch(t);if(e){if(e.noteId==="_lbRoot"){ft.showError(m("branches.cannot-move-notes-here"));return}o=Nl(o);for(const i of o){const n=Mt.getBranch(i);if(!n||n.noteId===li.getHoistedNoteId()||(await n.getParentNote())?.type==="search")continue;const s=await pt.put(`branches/${i}/move-to/${t}`);if(!s.success){ft.showError(s.message);return}}}}async function Yb(o,t=!1){if(o=Nl(o),o.length===0)return!1;const{proceed:e,deleteAllClones:i,eraseNotes:n}=await new Promise(l=>Pt.triggerCommand("showDeleteNotesDialog",{branchIdsToDelete:o,callback:l,forceDeleteAllClones:t}));if(!e)return!1;try{await Jb()}catch(l){console.error(l)}const s=ct.randomString(10);let a=0;for(const l of o){a++;const c=a===o.length,u=`?taskId=${s}&eraseNotes=${n?"true":"false"}&last=${c?"true":"false"}`,p=Mt.getBranch(l);i&&p?await pt.remove(`notes/${p.noteId}${u}`):await pt.remove(`branches/${l}${u}`)}return n&&ct.reloadFrontendApp("erasing notes requires reload"),!0}async function Jb(){const o=Pt.tabManager.getActiveContext(),t=o?.notePathArray.slice(0,-1);t&&t.length>0&&o?.setNote(t.join("/"))}async function Qb(o){if(li.isHoistedNode(o)||li.isTopLevelNode(o)||o.getParent().data.noteType==="search")return;const t=o.getParent().data.branchId,e=o.data.branchId,i=await pt.put(`branches/${e}/move-after/${t}`);if(!i.success){ft.showError(i.message);return}!li.isTopLevelNode(o)&&o.getParent().getChildren().length<=1&&(o.getParent().folder=!1,o.getParent().renderTitle())}function Wf(o){return o.filter(t=>!t.startsWith("virt-"))}function Nl(o){const t=li.getHoistedNoteId();return o.filter(e=>{const i=Mt.getBranch(e);return i?i.noteId!=="root"&&i.noteId!==t:!1})}function dl(o,t){return{id:o,title:m("branches.delete-status"),message:t,icon:"trash"}}yi.subscribeToMessages(async o=>{if(o.taskType==="deleteNotes"){if(o.type==="taskError")ft.closePersistent(o.taskId),ft.showError(o.message);else if(o.type==="taskProgressCount")ft.showPersistent(dl(o.taskId,m("branches.delete-notes-in-progress",{count:o.progressCount})));else if(o.type==="taskSucceeded"){const t=dl(o.taskId,m("branches.delete-finished-successfully"));t.closeAfter=5e3,ft.showPersistent(t)}}});yi.subscribeToMessages(async o=>{if(o.taskType==="undeleteNotes"){if(o.type==="taskError")ft.closePersistent(o.taskId),ft.showError(o.message);else if(o.type==="taskProgressCount")ft.showPersistent(dl(o.taskId,m("branches.undeleting-notes-in-progress",{count:o.progressCount})));else if(o.type==="taskSucceeded"){const t=dl(o.taskId,m("branches.undeleting-notes-finished-successfully"));t.closeAfter=5e3,ft.showPersistent(t)}}});async function Xb(o,t,e){const i=await pt.put(`notes/${o}/clone-to-branch/${t}`,{prefix:e});i.success||ft.showError(i.message)}async function tw(o,t,e){const i=await pt.put(`notes/${o}/clone-to-note/${t}`,{prefix:e});i.success||ft.showError(i.message)}async function ew(o,t){const e=await pt.put(`notes/${o}/clone-after/${t}`);e.success||ft.showError(e.message)}const ri={moveBeforeBranch:Kb,moveAfterBranch:Zb,moveToParentNote:Gb,deleteNotes:Yb,moveNodeUpInHierarchy:Qb,cloneNoteAfter:ew,cloneNoteToBranch:Xb,cloneNoteToParentNote:tw};let Fi=[],An=null;async function iw(o){if(!th())if(An==="cut")await ri.moveAfterBranch(Fi,o),Fi=[],An=null;else if(An==="copy"){const t=Fi.map(e=>Mt.getBranch(e));for(const e of t){if(!e)continue;const i=await e.getNote();i&&await ri.cloneNoteAfter(i.noteId,o)}}else ft.throwError(`Unrecognized clipboard mode=${An}`)}async function nw(o){if(!th())if(An==="cut")await ri.moveToParentNote(Fi,o),Fi=[],An=null;else if(An==="copy"){const t=Fi.map(e=>Mt.getBranch(e));for(const e of t){if(!e)continue;const i=await e.getNote();i&&await ri.cloneNoteToBranch(i.noteId,o)}}else ft.throwError(`Unrecognized clipboard mode=${An}`)}async function ow(o){if(Fi=o,An="copy",ct.isElectron()){const{clipboard:t}=require("electron"),e=[];for(const i of Mt.getBranches(Fi)){const n=await Pe.createLink(`${i.parentNoteId}/${i.noteId}`,{referenceLink:!0});e.push(n[0].outerHTML)}t.writeHTML(e.join(", "))}ft.showMessage(m("clipboard.copied"))}function sw(o){Fi=o,Fi.length>0&&(An="cut",ft.showMessage(m("clipboard.cut")))}function th(){return Fi=Fi.filter(o=>!!Mt.getBranch(o)),Fi.length===0}const ga={pasteAfter:iw,pasteInto:nw,cut:sw,copy:ow,isClipboardEmpty:th};var vc={exports:{}},ku={};/*! jQuery UI - v1.14.1 - 2025-03-26
|
||
* https://jqueryui.com
|
||
* Includes: widget.js, position.js, jquery-patch.js, keycode.js, scroll-parent.js, unique-id.js
|
||
* Copyright OpenJS Foundation and other contributors; Licensed MIT */var Cu;function rw(){return Cu||(Cu=1,function(o){o(jQuery)}(function(o){o.ui=o.ui||{},o.ui.version="1.14.1";/*!
|
||
* jQuery UI Widget 1.14.1
|
||
* https://jqueryui.com
|
||
*
|
||
* Copyright OpenJS Foundation and other contributors
|
||
* Released under the MIT license.
|
||
* https://jquery.org/license
|
||
*/var t=0,e=Array.prototype.hasOwnProperty,i=Array.prototype.slice;o.cleanData=o.cleanData||function(n){return function(s){var a,l,c;for(c=0;(l=s[c])!=null;c++)a=o._data(l,"events"),a&&a.remove&&o(l).triggerHandler("remove");n(s)}}(o.cleanData),o.widget=o.widget||function(n,s,a){var l,c,u,p={},v=n.split(".")[0];if(n=n.split(".")[1],n==="__proto__"||n==="constructor")return o.error("Invalid widget name: "+n);var x=v+"-"+n;return a||(a=s,s=o.Widget),Array.isArray(a)&&(a=o.extend.apply(null,[{}].concat(a))),o.expr.pseudos[x.toLowerCase()]=function(T){return!!o.data(T,x)},o[v]=o[v]||{},l=o[v][n],c=o[v][n]=function(T,M){if(!this||!this._createWidget)return new c(T,M);arguments.length&&this._createWidget(T,M)},o.extend(c,l,{version:a.version,_proto:o.extend({},a),_childConstructors:[]}),u=new s,u.options=o.widget.extend({},u.options),o.each(a,function(T,M){if(typeof M!="function"){p[T]=M;return}p[T]=function(){function P(){return s.prototype[T].apply(this,arguments)}function F(R){return s.prototype[T].apply(this,R)}return function(){var R=this._super,q=this._superApply,H;return this._super=P,this._superApply=F,H=M.apply(this,arguments),this._super=R,this._superApply=q,H}}()}),c.prototype=o.widget.extend(u,{widgetEventPrefix:l&&u.widgetEventPrefix||n},p,{constructor:c,namespace:v,widgetName:n,widgetFullName:x}),l?(o.each(l._childConstructors,function(T,M){var P=M.prototype;o.widget(P.namespace+"."+P.widgetName,c,M._proto)}),delete l._childConstructors):s._childConstructors.push(c),o.widget.bridge(n,c),c},o.widget.extend=function(n){for(var s=i.call(arguments,1),a=0,l=s.length,c,u;a<l;a++)for(c in s[a])u=s[a][c],e.call(s[a],c)&&u!==void 0&&(o.isPlainObject(u)?n[c]=o.isPlainObject(n[c])?o.widget.extend({},n[c],u):o.widget.extend({},u):n[c]=u);return n},o.widget.bridge=function(n,s){var a=s.prototype.widgetFullName||n;o.fn[n]=function(l){var c=typeof l=="string",u=i.call(arguments,1),p=this;return c?!this.length&&l==="instance"?p=void 0:this.each(function(){var v,x=o.data(this,a);if(l==="instance")return p=x,!1;if(!x)return o.error("cannot call methods on "+n+" prior to initialization; attempted to call method '"+l+"'");if(typeof x[l]!="function"||l.charAt(0)==="_")return o.error("no such method '"+l+"' for "+n+" widget instance");if(v=x[l].apply(x,u),v!==x&&v!==void 0)return p=v&&v.jquery?p.pushStack(v.get()):v,!1}):(u.length&&(l=o.widget.extend.apply(null,[l].concat(u))),this.each(function(){var v=o.data(this,a);v?(v.option(l||{}),v._init&&v._init()):o.data(this,a,new s(l,this))})),p}},o.Widget=o.Widget||function(){},o.Widget._childConstructors=[],o.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{classes:{},disabled:!1,create:null},_createWidget:function(n,s){s=o(s||this.defaultElement||this)[0],this.element=o(s),this.uuid=t++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=o(),this.hoverable=o(),this.focusable=o(),this.classesElementLookup={},s!==this&&(o.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(a){a.target===s&&this.destroy()}}),this.document=o(s.style?s.ownerDocument:s.document||s),this.window=o(this.document[0].defaultView||this.document[0].parentWindow)),this.options=o.widget.extend({},this.options,this._getCreateOptions(),n),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:o.noop,_create:o.noop,_init:o.noop,destroy:function(){var n=this;this._destroy(),o.each(this.classesElementLookup,function(s,a){n._removeClass(a,s)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:o.noop,widget:function(){return this.element},option:function(n,s){var a=n,l,c,u;if(arguments.length===0)return o.widget.extend({},this.options);if(typeof n=="string")if(a={},l=n.split("."),n=l.shift(),l.length){for(c=a[n]=o.widget.extend({},this.options[n]),u=0;u<l.length-1;u++)c[l[u]]=c[l[u]]||{},c=c[l[u]];if(n=l.pop(),arguments.length===1)return c[n]===void 0?null:c[n];c[n]=s}else{if(arguments.length===1)return this.options[n]===void 0?null:this.options[n];a[n]=s}return this._setOptions(a),this},_setOptions:function(n){var s;for(s in n)this._setOption(s,n[s]);return this},_setOption:function(n,s){return n==="classes"&&this._setOptionClasses(s),this.options[n]=s,n==="disabled"&&this._setOptionDisabled(s),this},_setOptionClasses:function(n){var s,a,l;for(s in n)l=this.classesElementLookup[s],!(n[s]===this.options.classes[s]||!l||!l.length)&&(a=o(l.get()),this._removeClass(l,s),a.addClass(this._classes({element:a,keys:s,classes:n,add:!0})))},_setOptionDisabled:function(n){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!n),n&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(n){var s=[],a=this;n=o.extend({element:this.element,classes:this.options.classes||{}},n);function l(){var u=[];n.element.each(function(p,v){var x=o.map(a.classesElementLookup,function(T){return T}).some(function(T){return T.is(v)});x||u.push(v)}),a._on(o(u),{remove:"_untrackClassesElement"})}function c(u,p){var v,x;for(x=0;x<u.length;x++)v=a.classesElementLookup[u[x]]||o(),n.add?(l(),v=o(o.uniqueSort(v.get().concat(n.element.get())))):v=o(v.not(n.element).get()),a.classesElementLookup[u[x]]=v,s.push(u[x]),p&&n.classes[u[x]]&&s.push(n.classes[u[x]])}return n.keys&&c(n.keys.match(/\S+/g)||[],!0),n.extra&&c(n.extra.match(/\S+/g)||[]),s.join(" ")},_untrackClassesElement:function(n){var s=this;o.each(s.classesElementLookup,function(a,l){o.inArray(n.target,l)!==-1&&(s.classesElementLookup[a]=o(l.not(n.target).get()))}),this._off(o(n.target))},_removeClass:function(n,s,a){return this._toggleClass(n,s,a,!1)},_addClass:function(n,s,a){return this._toggleClass(n,s,a,!0)},_toggleClass:function(n,s,a,l){l=typeof l=="boolean"?l:a;var c=typeof n=="string"||n===null,u={extra:c?s:a,keys:c?n:s,element:c?this.element:n,add:l};return u.element.toggleClass(this._classes(u),l),this},_on:function(n,s,a){var l,c=this;typeof n!="boolean"&&(a=s,s=n,n=!1),a?(s=l=o(s),this.bindings=this.bindings.add(s)):(a=s,s=this.element,l=this.widget()),o.each(a,function(u,p){function v(){if(!(!n&&(c.options.disabled===!0||o(this).hasClass("ui-state-disabled"))))return(typeof p=="string"?c[p]:p).apply(c,arguments)}typeof p!="string"&&(v.guid=p.guid=p.guid||v.guid||o.guid++);var x=u.match(/^([\w:-]*)\s*(.*)$/),T=x[1]+c.eventNamespace,M=x[2];M?l.on(T,M,v):s.on(T,v)})},_off:function(n,s){s=(s||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,n.off(s),this.bindings=o(this.bindings.not(n).get()),this.focusable=o(this.focusable.not(n).get()),this.hoverable=o(this.hoverable.not(n).get())},_delay:function(n,s){function a(){return(typeof n=="string"?l[n]:n).apply(l,arguments)}var l=this;return setTimeout(a,s||0)},_hoverable:function(n){this.hoverable=this.hoverable.add(n),this._on(n,{mouseenter:function(s){this._addClass(o(s.currentTarget),null,"ui-state-hover")},mouseleave:function(s){this._removeClass(o(s.currentTarget),null,"ui-state-hover")}})},_focusable:function(n){this.focusable=this.focusable.add(n),this._on(n,{focusin:function(s){this._addClass(o(s.currentTarget),null,"ui-state-focus")},focusout:function(s){this._removeClass(o(s.currentTarget),null,"ui-state-focus")}})},_trigger:function(n,s,a){var l,c,u=this.options[n];if(a=a||{},s=o.Event(s),s.type=(n===this.widgetEventPrefix?n:this.widgetEventPrefix+n).toLowerCase(),s.target=this.element[0],c=s.originalEvent,c)for(l in c)l in s||(s[l]=c[l]);return this.element.trigger(s,a),!(typeof u=="function"&&u.apply(this.element[0],[s].concat(a))===!1||s.isDefaultPrevented())}},o.each({show:"fadeIn",hide:"fadeOut"},function(n,s){o.Widget.prototype["_"+n]=function(a,l,c){typeof l=="string"&&(l={effect:l});var u,p=l?l===!0||typeof l=="number"?s:l.effect||s:n;l=l||{},typeof l=="number"?l={duration:l}:l===!0&&(l={}),u=!o.isEmptyObject(l),l.complete=c,l.delay&&a.delay(l.delay),u&&o.effects&&o.effects.effect[p]?a[n](l):p!==n&&a[p]?a[p](l.duration,l.easing,c):a.queue(function(v){o(this)[n](),c&&c.call(a[0]),v()})}}),o.widget;/*!
|
||
* jQuery UI Position 1.14.1
|
||
* https://jqueryui.com
|
||
*
|
||
* Copyright OpenJS Foundation and other contributors
|
||
* Released under the MIT license.
|
||
* https://jquery.org/license
|
||
*
|
||
* https://api.jqueryui.com/position/
|
||
*/(function(){var n,s=Math.max,a=Math.abs,l=/left|center|right/,c=/top|center|bottom/,u=/[\+\-]\d+(\.[\d]+)?%?/,p=/^\w+/,v=/%$/,x=o.fn.position;function T(R,q,H){return[parseFloat(R[0])*(v.test(R[0])?q/100:1),parseFloat(R[1])*(v.test(R[1])?H/100:1)]}function M(R,q){return parseInt(o.css(R,q),10)||0}function P(R){return R!=null&&R===R.window}function F(R){var q=R[0];return q.nodeType===9?{width:R.width(),height:R.height(),offset:{top:0,left:0}}:P(q)?{width:R.width(),height:R.height(),offset:{top:R.scrollTop(),left:R.scrollLeft()}}:q.preventDefault?{width:0,height:0,offset:{top:q.pageY,left:q.pageX}}:{width:R.outerWidth(),height:R.outerHeight(),offset:R.offset()}}o.position=o.position||{scrollbarWidth:function(){if(n!==void 0)return n;var R,q,H=o("<div style='display:block;position:absolute;width:200px;height:200px;overflow:hidden;'><div style='height:300px;width:auto;'></div></div>"),Q=H.children()[0];return o("body").append(H),R=Q.offsetWidth,H.css("overflow","scroll"),q=Q.offsetWidth,R===q&&(q=H[0].clientWidth),H.remove(),n=R-q},getScrollInfo:function(R){var q=R.isWindow||R.isDocument?"":R.element.css("overflow-x"),H=R.isWindow||R.isDocument?"":R.element.css("overflow-y"),Q=q==="scroll"||q==="auto"&&R.width<R.element[0].scrollWidth,tt=H==="scroll"||H==="auto"&&R.height<R.element[0].scrollHeight;return{width:tt?o.position.scrollbarWidth():0,height:Q?o.position.scrollbarWidth():0}},getWithinInfo:function(R){var q=o(R||window),H=P(q[0]),Q=!!q[0]&&q[0].nodeType===9,tt=!H&&!Q;return{element:q,isWindow:H,isDocument:Q,offset:tt?o(R).offset():{left:0,top:0},scrollLeft:q.scrollLeft(),scrollTop:q.scrollTop(),width:q.outerWidth(),height:q.outerHeight()}}},o.fn.position=function(R){if(!R||!R.of)return x.apply(this,arguments);R=o.extend({},R);var q,H,Q,tt,it,rt,vt=typeof R.of=="string"?o(document).find(R.of):o(R.of),Dt=o.position.getWithinInfo(R.within),jt=o.position.getScrollInfo(Dt),gt=(R.collision||"flip").split(" "),Ct={};return rt=F(vt),vt[0].preventDefault&&(R.at="left top"),H=rt.width,Q=rt.height,tt=rt.offset,it=o.extend({},tt),o.each(["my","at"],function(){var St=(R[this]||"").split(" "),Nt,Zt;St.length===1&&(St=l.test(St[0])?St.concat(["center"]):c.test(St[0])?["center"].concat(St):["center","center"]),St[0]=l.test(St[0])?St[0]:"center",St[1]=c.test(St[1])?St[1]:"center",Nt=u.exec(St[0]),Zt=u.exec(St[1]),Ct[this]=[Nt?Nt[0]:0,Zt?Zt[0]:0],R[this]=[p.exec(St[0])[0],p.exec(St[1])[0]]}),gt.length===1&&(gt[1]=gt[0]),R.at[0]==="right"?it.left+=H:R.at[0]==="center"&&(it.left+=H/2),R.at[1]==="bottom"?it.top+=Q:R.at[1]==="center"&&(it.top+=Q/2),q=T(Ct.at,H,Q),it.left+=q[0],it.top+=q[1],this.each(function(){var St,Nt,Zt=o(this),re=Zt.outerWidth(),te=Zt.outerHeight(),ut=M(this,"marginLeft"),bt=M(this,"marginTop"),ht=re+ut+M(this,"marginRight")+jt.width,Tt=te+bt+M(this,"marginBottom")+jt.height,mt=o.extend({},it),At=T(Ct.my,Zt.outerWidth(),Zt.outerHeight());R.my[0]==="right"?mt.left-=re:R.my[0]==="center"&&(mt.left-=re/2),R.my[1]==="bottom"?mt.top-=te:R.my[1]==="center"&&(mt.top-=te/2),mt.left+=At[0],mt.top+=At[1],St={marginLeft:ut,marginTop:bt},o.each(["left","top"],function(Et,dt){o.ui.position[gt[Et]]&&o.ui.position[gt[Et]][dt](mt,{targetWidth:H,targetHeight:Q,elemWidth:re,elemHeight:te,collisionPosition:St,collisionWidth:ht,collisionHeight:Tt,offset:[q[0]+At[0],q[1]+At[1]],my:R.my,at:R.at,within:Dt,elem:Zt})}),R.using&&(Nt=function(Et){var dt=tt.left-mt.left,b=dt+H-re,k=tt.top-mt.top,S=k+Q-te,I={target:{element:vt,left:tt.left,top:tt.top,width:H,height:Q},element:{element:Zt,left:mt.left,top:mt.top,width:re,height:te},horizontal:b<0?"left":dt>0?"right":"center",vertical:S<0?"top":k>0?"bottom":"middle"};H<re&&a(dt+b)<H&&(I.horizontal="center"),Q<te&&a(k+S)<Q&&(I.vertical="middle"),s(a(dt),a(b))>s(a(k),a(S))?I.important="horizontal":I.important="vertical",R.using.call(this,Et,I)}),Zt.offset(o.extend(mt,{using:Nt}))})},o.ui.position={fit:{left:function(R,q){var H=q.within,Q=H.isWindow?H.scrollLeft:H.offset.left,tt=H.width,it=R.left-q.collisionPosition.marginLeft,rt=Q-it,vt=it+q.collisionWidth-tt-Q,Dt;q.collisionWidth>tt?rt>0&&vt<=0?(Dt=R.left+rt+q.collisionWidth-tt-Q,R.left+=rt-Dt):vt>0&&rt<=0?R.left=Q:rt>vt?R.left=Q+tt-q.collisionWidth:R.left=Q:rt>0?R.left+=rt:vt>0?R.left-=vt:R.left=s(R.left-it,R.left)},top:function(R,q){var H=q.within,Q=H.isWindow?H.scrollTop:H.offset.top,tt=q.within.height,it=R.top-q.collisionPosition.marginTop,rt=Q-it,vt=it+q.collisionHeight-tt-Q,Dt;q.collisionHeight>tt?rt>0&&vt<=0?(Dt=R.top+rt+q.collisionHeight-tt-Q,R.top+=rt-Dt):vt>0&&rt<=0?R.top=Q:rt>vt?R.top=Q+tt-q.collisionHeight:R.top=Q:rt>0?R.top+=rt:vt>0?R.top-=vt:R.top=s(R.top-it,R.top)}},flip:{left:function(R,q){var H=q.within,Q=H.offset.left+H.scrollLeft,tt=H.width,it=H.isWindow?H.scrollLeft:H.offset.left,rt=R.left-q.collisionPosition.marginLeft,vt=rt-it,Dt=rt+q.collisionWidth-tt-it,jt=q.my[0]==="left"?-q.elemWidth:q.my[0]==="right"?q.elemWidth:0,gt=q.at[0]==="left"?q.targetWidth:q.at[0]==="right"?-q.targetWidth:0,Ct=-2*q.offset[0],St,Nt;vt<0?(St=R.left+jt+gt+Ct+q.collisionWidth-tt-Q,(St<0||St<a(vt))&&(R.left+=jt+gt+Ct)):Dt>0&&(Nt=R.left-q.collisionPosition.marginLeft+jt+gt+Ct-it,(Nt>0||a(Nt)<Dt)&&(R.left+=jt+gt+Ct))},top:function(R,q){var H=q.within,Q=H.offset.top+H.scrollTop,tt=H.height,it=H.isWindow?H.scrollTop:H.offset.top,rt=R.top-q.collisionPosition.marginTop,vt=rt-it,Dt=rt+q.collisionHeight-tt-it,jt=q.my[1]==="top",gt=jt?-q.elemHeight:q.my[1]==="bottom"?q.elemHeight:0,Ct=q.at[1]==="top"?q.targetHeight:q.at[1]==="bottom"?-q.targetHeight:0,St=-2*q.offset[1],Nt,Zt;vt<0?(Zt=R.top+gt+Ct+St+q.collisionHeight-tt-Q,(Zt<0||Zt<a(vt))&&(R.top+=gt+Ct+St)):Dt>0&&(Nt=R.top-q.collisionPosition.marginTop+gt+Ct+St-it,(Nt>0||a(Nt)<Dt)&&(R.top+=gt+Ct+St))}},flipfit:{left:function(){o.ui.position.flip.left.apply(this,arguments),o.ui.position.fit.left.apply(this,arguments)},top:function(){o.ui.position.flip.top.apply(this,arguments),o.ui.position.fit.top.apply(this,arguments)}}}})(),o.ui.position;/*!
|
||
* jQuery UI Legacy jQuery Core patches 1.14.1
|
||
* https://jqueryui.com
|
||
*
|
||
* Copyright OpenJS Foundation and other contributors
|
||
* Released under the MIT license.
|
||
* https://jquery.org/license
|
||
*
|
||
*/o.escapeSelector||(o.escapeSelector=function(n){return CSS.escape(n+"")}),(!o.fn.even||!o.fn.odd)&&o.fn.extend({even:function(){return this.filter(function(n){return n%2===0})},odd:function(){return this.filter(function(n){return n%2===1})}});/*!
|
||
* jQuery UI Keycode 1.14.1
|
||
* https://jqueryui.com
|
||
*
|
||
* Copyright OpenJS Foundation and other contributors
|
||
* Released under the MIT license.
|
||
* https://jquery.org/license
|
||
*/o.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38};/*!
|
||
* jQuery UI Scroll Parent 1.14.1
|
||
* https://jqueryui.com
|
||
*
|
||
* Copyright OpenJS Foundation and other contributors
|
||
* Released under the MIT license.
|
||
* https://jquery.org/license
|
||
*/o.fn.scrollParent=function(n){var s=this.css("position"),a=s==="absolute",l=n?/(auto|scroll|hidden)/:/(auto|scroll)/,c=this.parents().filter(function(){var u=o(this);return a&&u.css("position")==="static"?!1:l.test(u.css("overflow")+u.css("overflow-y")+u.css("overflow-x"))}).eq(0);return s==="fixed"||!c.length?o(this[0].ownerDocument||document):c};/*!
|
||
* jQuery UI Unique ID 1.14.1
|
||
* https://jqueryui.com
|
||
*
|
||
* Copyright OpenJS Foundation and other contributors
|
||
* Released under the MIT license.
|
||
* https://jquery.org/license
|
||
*/o.fn.extend({uniqueId:function(){var n=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++n)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&o(this).removeAttr("id")})}})})),ku}/*!
|
||
* jquery.fancytree.js
|
||
* Tree view control with support for lazy loading and much more.
|
||
* https://github.com/mar10/fancytree/
|
||
*
|
||
* Copyright (c) 2008-2023, Martin Wendt (https://wwWendt.de)
|
||
* Released under the MIT license
|
||
* https://github.com/mar10/fancytree/wiki/LicenseInfo
|
||
*
|
||
* @version 2.38.5
|
||
* @date 2025-04-05T06:40:00Z
|
||
*/var $u;function Ml(){return $u||($u=1,function(o){(function(t){o.exports?(rw(),o.exports=t(Ll())):t(jQuery)})(function(t){if(t.ui&&t.ui.fancytree){t.ui.fancytree.warn("Fancytree: ignored duplicate include");return}var e,i,n=null,s=new RegExp(/\.|\//),a=/[&<>"'/]/g,l=/[<>"'/]/g,c="$recursive_request",u="$request_target_invalid",p={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},v={16:!0,17:!0,18:!0},x={8:"backspace",9:"tab",10:"return",13:"return",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",59:";",61:"=",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},T={16:"shift",17:"ctrl",18:"alt",91:"meta",93:"meta"},M={0:"",1:"left",2:"middle",3:"right"},P="active expanded focus folder lazy radiogroup selected unselectable unselectableIgnore".split(" "),F={},R="columns types".split(" "),q="checkbox expanded extraClasses folder icon iconTooltip key lazy partsel radiogroup refKey selected statusNodeType title tooltip type unselectable unselectableIgnore unselectableStatus".split(" "),H={},Q={},tt={active:!0,children:!0,data:!0,focus:!0};for(e=0;e<P.length;e++)F[P[e]]=!0;for(e=0;e<q.length;e++)i=q[e],H[i]=!0,i!==i.toLowerCase()&&(Q[i.toLowerCase()]=i);function it(b,k){b||(k=k?": "+k:"",k="Fancytree assertion failed"+k,t.ui&&t.ui.fancytree&&t.ui.fancytree.error(k),t.error(k))}function rt(b,k){return Object.prototype.hasOwnProperty.call(b,k)}function vt(b){return typeof b=="function"}function Dt(b){return b==null?"":b.trim()}var jt=Array.isArray;it(t.ui,"Fancytree requires jQuery UI (http://jqueryui.com)");function gt(b,k){var S,I,N=window.console?window.console[b]:null;if(N)try{N.apply(window.console,k)}catch{for(I="",S=0;S<k.length;S++)I+=k[S];N(I)}}Date.now||(Date.now=function(){return new Date().getTime()});function Ct(b){return!!(b.tree&&b.statusNodeType!==void 0)}function St(b,k,S,I){var N,B,V,G=t.map(Dt(b).split("."),function(X){return parseInt(X,10)}),J=t.map(Array.prototype.slice.call(arguments,1),function(X){return parseInt(X,10)});for(N=0;N<J.length;N++)if(B=G[N]||0,V=J[N]||0,B!==V)return B>V;return!0}function Nt(){var b,k,S,I,N,B=arguments[0]||{},V=1,G=arguments.length;if(typeof B!="object"&&!vt(B)&&(B={}),V===G)throw Error("need at least two args");for(;V<G;V++)if((b=arguments[V])!=null){for(k in b)if(rt(b,k)){if(S=B[k],I=b[k],B===I)continue;I&&t.isPlainObject(I)?(N=S&&t.isPlainObject(S)?S:{},B[k]=Nt(N,I)):I!==void 0&&(B[k]=I)}}return B}function Zt(b,k,S,I,N){var B=function(){var V=k[b],G=I[b],J=k.ext[N],X=function(){return V.apply(k,arguments)},wt=function($t){return V.apply(k,$t)};return function(){var $t=k._local,lt=k._super,Ht=k._superApply;try{return k._local=J,k._super=X,k._superApply=wt,G.apply(k,arguments)}finally{k._local=$t,k._super=lt,k._superApply=Ht}}}();return B}function re(b,k,S,I){for(var N in S)typeof S[N]=="function"?typeof b[N]=="function"?b[N]=Zt(N,b,k,S,I):N.charAt(0)==="_"?b.ext[I][N]=Zt(N,b,k,S,I):t.error("Could not override tree."+N+". Use prefix '_' to create tree."+I+"._"+N):N!=="options"&&(b.ext[I][N]=S[N])}function te(b,k){return b===void 0?t.Deferred(function(){this.resolve()}).promise():t.Deferred(function(){this.resolveWith(b,k)}).promise()}function ut(b,k){return b===void 0?t.Deferred(function(){this.reject()}).promise():t.Deferred(function(){this.rejectWith(b,k)}).promise()}function bt(b,k){return function(){b.resolveWith(k)}}function ht(b){var k=t.extend({},b.data()),S=k.json;return delete k.fancytree,delete k.uiFancytree,S&&(delete k.json,k=t.extend(k,S)),k}function Tt(b){return(""+b).replace(l,function(k){return p[k]})}function mt(b){return b=b.toLowerCase(),function(k){return k.title.toLowerCase().indexOf(b)>=0}}function At(b){var k=new RegExp("^"+b,"i");return function(S){return k.test(S.title)}}function Et(b,k){var S,I,N,B;for(this.parent=b,this.tree=b.tree,this.ul=null,this.li=null,this.statusNodeType=null,this._isLoading=!1,this._error=null,this.data={},S=0,I=q.length;S<I;S++)N=q[S],this[N]=k[N];(this.unselectableIgnore!=null||this.unselectableStatus!=null)&&(this.unselectable=!0),k.hideCheckbox&&t.error("'hideCheckbox' node option was removed in v2.23.0: use 'checkbox: false'"),k.data&&t.extend(this.data,k.data);for(N in k)!H[N]&&(this.tree.options.copyFunctionsToData||!vt(k[N]))&&!tt[N]&&(this.data[N]=k[N]);this.key==null?this.tree.options.defaultKey?(this.key=""+this.tree.options.defaultKey(this),it(this.key,"defaultKey() must return a unique key")):this.key="_"+n._nextNodeKey++:this.key=""+this.key,k.active&&(it(this.tree.activeNode===null,"only one active node allowed"),this.tree.activeNode=this),k.selected&&(this.tree.lastSelectedNode=this),B=k.children,B?B.length?this._setChildren(B):this.children=this.lazy?[]:null:this.children=null,this.tree._callHook("treeRegisterNode",this.tree,!0,this)}Et.prototype={_findDirectChild:function(b){var k,S,I=this.children;if(I)if(typeof b=="string"){for(k=0,S=I.length;k<S;k++)if(I[k].key===b)return I[k]}else{if(typeof b=="number")return this.children[b];if(b.parent===this)return b}return null},_setChildren:function(b){it(b&&(!this.children||this.children.length===0),"only init supported"),this.children=[];for(var k=0,S=b.length;k<S;k++)this.children.push(new Et(this,b[k]));this.tree._callHook("treeStructureChanged",this.tree,"setChildren")},addChildren:function(b,k){var S,I,N,B=this.getFirstChild(),V=this.getLastChild(),G=null,J=[];for(t.isPlainObject(b)&&(b=[b]),this.children||(this.children=[]),S=0,I=b.length;S<I;S++)J.push(new Et(this,b[S]));if(G=J[0],k==null?this.children=this.children.concat(J):(k=this._findDirectChild(k),N=t.inArray(k,this.children),it(N>=0,"insertBefore must be an existing child"),this.children.splice.apply(this.children,[N,0].concat(J))),B&&!k){for(S=0,I=J.length;S<I;S++)J[S].render();B!==this.getFirstChild()&&B.renderStatus(),V!==this.getLastChild()&&V.renderStatus()}else(!this.parent||this.parent.ul||this.tr)&&this.render();return this.tree.options.selectMode===3&&this.fixSelection3FromEndNodes(),this.triggerModifyChild("add",J.length===1?J[0]:null),G},addClass:function(b){return this.toggleClass(b,!0)},addNode:function(b,k){switch((k===void 0||k==="over")&&(k="child"),k){case"after":return this.getParent().addChildren(b,this.getNextSibling());case"before":return this.getParent().addChildren(b,this);case"firstChild":var S=this.children?this.children[0]:null;return this.addChildren(b,S);case"child":case"over":return this.addChildren(b)}it(!1,"Invalid mode: "+k)},addPagingNode:function(b,k){var S,I;if(k=k||"child",b===!1){for(S=this.children.length-1;S>=0;S--)I=this.children[S],I.statusNodeType==="paging"&&this.removeChild(I);this.partload=!1;return}return b=t.extend({title:this.tree.options.strings.moreData,statusNodeType:"paging",icon:!1},b),this.partload=!0,this.addNode(b,k)},appendSibling:function(b){return this.addNode(b,"after")},applyCommand:function(b,k){return this.tree.applyCommand(b,this,k)},applyPatch:function(b){if(b===null)return this.remove(),te(this);var k,S,I,N={children:!0,expanded:!0,parent:!0};for(k in b)rt(b,k)&&(I=b[k],!N[k]&&!vt(I)&&(H[k]?this[k]=I:this.data[k]=I));return rt(b,"children")&&(this.removeChildren(),b.children&&this._setChildren(b.children)),this.isVisible()&&(this.renderTitle(),this.renderStatus()),rt(b,"expanded")?S=this.setExpanded(b.expanded):S=te(this),S},collapseSiblings:function(){return this.tree._callHook("nodeCollapseSiblings",this)},copyTo:function(b,k,S){return b.addNode(this.toDict(!0,S),k)},countChildren:function(b){var k=this.children,S,I,N;if(!k)return 0;if(N=k.length,b!==!1)for(S=0,I=N;S<I;S++)N+=k[S].countChildren();return N},debug:function(b){this.tree.options.debugLevel>=4&&(Array.prototype.unshift.call(arguments,this.toString()),gt("log",arguments))},discard:function(){return this.warn("FancytreeNode.discard() is deprecated since 2014-02-16. Use .resetLazy() instead."),this.resetLazy()},discardMarkup:function(b){var k=b?"nodeRemoveMarkup":"nodeRemoveChildMarkup";this.tree._callHook(k,this)},error:function(b){this.tree.options.debugLevel>=1&&(Array.prototype.unshift.call(arguments,this.toString()),gt("error",arguments))},findAll:function(b){b=vt(b)?b:mt(b);var k=[];return this.visit(function(S){b(S)&&k.push(S)}),k},findFirst:function(b){b=vt(b)?b:mt(b);var k=null;return this.visit(function(S){if(b(S))return k=S,!1}),k},findRelatedNode:function(b,k){return this.tree.findRelatedNode(this,b,k)},_changeSelectStatusAttrs:function(b){var k=!1,S=this.tree.options,I=n.evalOption("unselectable",this,this,S,!1),N=n.evalOption("unselectableStatus",this,this,S,void 0);switch(I&&N!=null&&(b=N),b){case!1:k=this.selected||this.partsel,this.selected=!1,this.partsel=!1;break;case!0:k=!this.selected||!this.partsel,this.selected=!0,this.partsel=!0;break;case void 0:k=this.selected||!this.partsel,this.selected=!1,this.partsel=!0;break;default:it(!1,"invalid state: "+b)}return k&&this.renderStatus(),k},fixSelection3AfterClick:function(b){var k=this.isSelected();this.visit(function(S){if(S._changeSelectStatusAttrs(k),S.radiogroup)return"skip"}),this.fixSelection3FromEndNodes(b)},fixSelection3FromEndNodes:function(b){var k=this.tree.options;it(k.selectMode===3,"expected selectMode 3");function S(I){var N,B,V,G,J,X,wt,$t,lt,Ht=I.children;if(Ht&&Ht.length){for(X=!0,wt=!1,N=0,B=Ht.length;N<B;N++)V=Ht[N],G=S(V),$t=n.evalOption("unselectableIgnore",V,V,k,!1),$t||(G!==!1&&(wt=!0),G!==!0&&(X=!1));J=X?!0:wt?void 0:!1}else lt=n.evalOption("unselectableStatus",I,I,k,void 0),J=lt==null?!!I.selected:!!lt;return I.partsel&&!I.selected&&I.lazy&&I.children==null&&(J=void 0),I._changeSelectStatusAttrs(J),J}S(this),this.visitParents(function(I){var N,B,V,G,J,X,wt=I.children,$t=!0,lt=!1;for(N=0,B=wt.length;N<B;N++)V=wt[N],J=n.evalOption("unselectableIgnore",V,V,k,!1),J||(X=n.evalOption("unselectableStatus",V,V,k,void 0),G=X==null?!!V.selected:!!X,(G||V.partsel)&&(lt=!0),G||($t=!1));G=$t?!0:lt?void 0:!1,I._changeSelectStatusAttrs(G)})},fromDict:function(b){for(var k in b)H[k]?this[k]=b[k]:k==="data"?t.extend(this.data,b.data):!vt(b[k])&&!tt[k]&&(this.data[k]=b[k]);b.children&&(this.removeChildren(),this.addChildren(b.children)),this.renderTitle()},getChildren:function(){if(this.hasChildren()!==void 0)return this.children},getFirstChild:function(){return this.children?this.children[0]:null},getIndex:function(){return t.inArray(this,this.parent.children)},getIndexHier:function(b,k){b=b||".";var S,I=[];return t.each(this.getParentList(!1,!0),function(N,B){S=""+(B.getIndex()+1),k&&(S=("0000000"+S).substr(-k)),I.push(S)}),I.join(b)},getKeyPath:function(b){var k=this.tree.options.keyPathSeparator;return k+this.getPath(!b,"key",k)},getLastChild:function(){return this.children?this.children[this.children.length-1]:null},getLevel:function(){for(var b=0,k=this.parent;k;)b++,k=k.parent;return b},getNextSibling:function(){if(this.parent){var b,k,S=this.parent.children;for(b=0,k=S.length-1;b<k;b++)if(S[b]===this)return S[b+1]}return null},getParent:function(){return this.parent},getParentList:function(b,k){for(var S=[],I=k?this:this.parent;I;)(b||I.parent)&&S.unshift(I),I=I.parent;return S},getPath:function(b,k,S){b=b!==!1,k=k||"title",S=S||"/";var I,N=[],B=vt(k);return this.visitParents(function(V){V.parent&&(I=B?k(V):V[k],N.unshift(I))},b),N.join(S)},getPrevSibling:function(){if(this.parent){var b,k,S=this.parent.children;for(b=1,k=S.length;b<k;b++)if(S[b]===this)return S[b-1]}return null},getSelectedNodes:function(b){var k=[];return this.visit(function(S){if(S.selected&&(k.push(S),b===!0))return"skip"}),k},hasChildren:function(){return this.lazy?this.children==null?void 0:this.children.length===0?!1:this.children.length===1&&this.children[0].isStatusNode()?void 0:!0:!!(this.children&&this.children.length)},hasClass:function(b){return(" "+(this.extraClasses||"")+" ").indexOf(" "+b+" ")>=0},hasFocus:function(){return this.tree.hasFocus()&&this.tree.focusNode===this},info:function(b){this.tree.options.debugLevel>=3&&(Array.prototype.unshift.call(arguments,this.toString()),gt("info",arguments))},isActive:function(){return this.tree.activeNode===this},isBelowOf:function(b){return this.getIndexHier(".",5)>b.getIndexHier(".",5)},isChildOf:function(b){return this.parent&&this.parent===b},isDescendantOf:function(b){if(!b||b.tree!==this.tree)return!1;for(var k=this.parent;k;){if(k===b)return!0;k===k.parent&&t.error("Recursive parent link: "+k),k=k.parent}return!1},isExpanded:function(){return!!this.expanded},isFirstSibling:function(){var b=this.parent;return!b||b.children[0]===this},isFolder:function(){return!!this.folder},isLastSibling:function(){var b=this.parent;return!b||b.children[b.children.length-1]===this},isLazy:function(){return!!this.lazy},isLoaded:function(){return!this.lazy||this.hasChildren()!==void 0},isLoading:function(){return!!this._isLoading},isRoot:function(){return this.isRootNode()},isPartsel:function(){return!this.selected&&!!this.partsel},isPartload:function(){return!!this.partload},isRootNode:function(){return this.tree.rootNode===this},isSelected:function(){return!!this.selected},isStatusNode:function(){return!!this.statusNodeType},isPagingNode:function(){return this.statusNodeType==="paging"},isTopLevel:function(){return this.tree.rootNode===this.parent},isUndefined:function(){return this.hasChildren()===void 0},isVisible:function(){var b,k,S,I=this.tree.enableFilter,N=this.getParentList(!1,!1);if(I&&!this.match&&!this.subMatchCount)return!1;for(b=0,k=N.length;b<k;b++)if(S=N[b],!S.expanded)return!1;return!0},lazyLoad:function(b){t.error("FancytreeNode.lazyLoad() is deprecated since 2014-02-16. Use .load() instead.")},load:function(b){var k,S,I=this,N=this.isExpanded();return it(this.isLazy(),"load() requires a lazy node"),!b&&!this.isUndefined()?te(this):(this.isLoaded()&&this.resetLazy(),S=this.tree._triggerNodeEvent("lazyLoad",this),S===!1?te(this):(it(typeof S!="boolean","lazyLoad event must return source in data.result"),k=this.tree._callHook("nodeLoadChildren",this,S),N?(this.expanded=!0,k.always(function(){I.render()})):k.always(function(){I.renderStatus()}),k))},makeVisible:function(b){var k,S=this,I=[],N=new t.Deferred,B=this.getParentList(!1,!1),V=B.length,G=!(b&&b.noAnimation===!0),J=!(b&&b.scrollIntoView===!1);for(k=V-1;k>=0;k--)I.push(B[k].setExpanded(!0,b));return t.when.apply(t,I).done(function(){J?S.scrollIntoView(G).done(function(){N.resolve()}):N.resolve()}),N.promise()},moveTo:function(b,k,S){k===void 0||k==="over"?k="child":k==="firstChild"&&(b.children&&b.children.length?(k="before",b=b.children[0]):k="child");var I,N=this.tree,B=this.parent,V=k==="child"?b:b.parent;if(this!==b){if(this.parent?V.isDescendantOf(this)&&t.error("Cannot move a node to its own descendant"):t.error("Cannot move system root"),V!==B&&B.triggerModifyChild("remove",this),this.parent.children.length===1){if(this.parent===V)return;this.parent.children=this.parent.lazy?[]:null,this.parent.expanded=!1}else I=t.inArray(this,this.parent.children),it(I>=0,"invalid source parent"),this.parent.children.splice(I,1);if(this.parent=V,V.hasChildren())switch(k){case"child":V.children.push(this);break;case"before":I=t.inArray(b,V.children),it(I>=0,"invalid target parent"),V.children.splice(I,0,this);break;case"after":I=t.inArray(b,V.children),it(I>=0,"invalid target parent"),V.children.splice(I+1,0,this);break;default:t.error("Invalid mode "+k)}else V.children=[this];S&&b.visit(S,!0),V===B?V.triggerModifyChild("move",this):V.triggerModifyChild("add",this),N!==b.tree&&(this.warn("Cross-tree moveTo is experimental!"),this.visit(function(G){G.tree=b.tree},!0)),N._callHook("treeStructureChanged",N,"moveTo"),B.isDescendantOf(V)||B.render(),!V.isDescendantOf(B)&&V!==B&&V.render()}},navigate:function(b,k){var S,I=t.ui.keyCode;switch(b){case"left":case I.LEFT:if(this.expanded)return this.setExpanded(!1);break;case"right":case I.RIGHT:if(!this.expanded&&(this.children||this.lazy))return this.setExpanded();break}if(S=this.findRelatedNode(b),S){try{S.makeVisible({scrollIntoView:!1})}catch{}return k===!1?(S.setFocus(),te()):S.setActive()}return this.warn("Could not find related node '"+b+"'."),te()},remove:function(){return this.parent.removeChild(this)},removeChild:function(b){return this.tree._callHook("nodeRemoveChild",this,b)},removeChildren:function(){return this.tree._callHook("nodeRemoveChildren",this)},removeClass:function(b){return this.toggleClass(b,!1)},render:function(b,k){return this.tree._callHook("nodeRender",this,b,k)},renderTitle:function(){return this.tree._callHook("nodeRenderTitle",this)},renderStatus:function(){return this.tree._callHook("nodeRenderStatus",this)},replaceWith:function(b){var k,S=this.parent,I=t.inArray(this,S.children),N=this;return it(this.isPagingNode(),"replaceWith() currently requires a paging status node"),k=this.tree._callHook("nodeLoadChildren",this,b),k.done(function(B){var V=N.children;for(e=0;e<V.length;e++)V[e].parent=S;S.children.splice.apply(S.children,[I+1,0].concat(V)),N.children=null,N.remove(),S.render()}).fail(function(){N.setExpanded()}),k},resetLazy:function(){this.removeChildren(),this.expanded=!1,this.lazy=!0,this.children=void 0,this.renderStatus()},scheduleAction:function(b,k){this.tree.timer&&(clearTimeout(this.tree.timer),this.tree.debug("clearTimeout(%o)",this.tree.timer)),this.tree.timer=null;var S=this;switch(b){case"cancel":break;case"expand":this.tree.timer=setTimeout(function(){S.tree.debug("setTimeout: trigger expand"),S.setExpanded(!0)},k);break;case"activate":this.tree.timer=setTimeout(function(){S.tree.debug("setTimeout: trigger activate"),S.setActive(!0)},k);break;default:t.error("Invalid mode "+b)}},scrollIntoView:function(b,k){if(k!==void 0&&Ct(k))throw Error("scrollIntoView() with 'topNode' option is deprecated since 2014-05-08. Use 'options.topNode' instead.");var S=t.extend({effects:b===!0?{duration:200,queue:!1}:b,scrollOfs:this.tree.options.scrollOfs,scrollParent:this.tree.options.scrollParent,topNode:null},k),I=S.scrollParent,N=this.tree.$container,B=N.css("overflow-y");I?I.jquery||(I=t(I)):this.tree.tbody?I=N.scrollParent():B==="scroll"||B==="auto"?I=N:I=N.scrollParent(),(I[0]===document||I[0]===document.body)&&(this.debug("scrollIntoView(): normalizing scrollParent to 'window':",I[0]),I=t(window));var V,G,J,X,wt=new t.Deferred,$t=this,lt=t(this.span).height(),Ht=S.scrollOfs.top||0,Kt=S.scrollOfs.bottom||0,qt=I.height(),Vt=I.scrollTop(),be=I,Ce=I[0]===window,_e=S.topNode||null,je=null;return this.isRootNode()||!this.isVisible()?(this.info("scrollIntoView(): node is invisible."),te()):(Ce?(G=t(this.span).offset().top,V=_e&&_e.span?t(_e.span).offset().top:0,be=t("html,body")):(it(I[0]!==document&&I[0]!==document.body,"scrollParent should be a simple element or `window`, not document or body."),X=I.offset().top,G=t(this.span).offset().top-X+Vt,V=_e?t(_e.span).offset().top-X+Vt:0,J=Math.max(0,I.innerHeight()-I[0].clientHeight),qt-=J),G<Vt+Ht?je=G-Ht:G+lt>Vt+qt-Kt&&(je=G+lt-qt+Kt,_e&&(it(_e.isRootNode()||_e.isVisible(),"topNode must be visible"),V<je&&(je=V-Ht))),je===null?wt.resolveWith(this):S.effects?(S.effects.complete=function(){wt.resolveWith($t)},be.stop(!0).animate({scrollTop:je},S.effects)):(be[0].scrollTop=je,wt.resolveWith(this)),wt.promise())},setActive:function(b,k){return this.tree._callHook("nodeSetActive",this,b,k)},setExpanded:function(b,k){return this.tree._callHook("nodeSetExpanded",this,b,k)},setFocus:function(b){return this.tree._callHook("nodeSetFocus",this,b)},setSelected:function(b,k){return this.tree._callHook("nodeSetSelected",this,b,k)},setStatus:function(b,k,S){return this.tree._callHook("nodeSetStatus",this,b,k,S)},setTitle:function(b){this.title=b,this.renderTitle(),this.triggerModify("rename")},sortChildren:function(b,k){var S,I,N=this.children;if(N){if(b=b||function(B,V){var G=B.title.toLowerCase(),J=V.title.toLowerCase();return G===J?0:G>J?1:-1},N.sort(b),k)for(S=0,I=N.length;S<I;S++)N[S].children&&N[S].sortChildren(b,"$norender$");k!=="$norender$"&&this.render(),this.triggerModifyChild("sort")}},toDict:function(b,k){var S,I,N,B,V={},G=this;if(t.each(q,function(J,X){(G[X]||G[X]===!1)&&(V[X]=G[X])}),t.isEmptyObject(this.data)||(V.data=t.extend({},this.data),t.isEmptyObject(V.data)&&delete V.data),k){if(B=k(V,G),B===!1)return!1;B==="skip"&&(b=!1)}if(b&&jt(this.children))for(V.children=[],S=0,I=this.children.length;S<I;S++)N=this.children[S],N.isStatusNode()||(B=N.toDict(!0,k),B!==!1&&V.children.push(B));return V},toggleClass:function(b,k){var S,I,N=/\S+/g,B=b.match(N)||[],V=0,G=!1,J=this[this.tree.statusClassPropName],X=" "+(this.extraClasses||"")+" ";for(J&&t(J).toggleClass(b,k);S=B[V++];)if(I=X.indexOf(" "+S+" ")>=0,k=k===void 0?!I:!!k,k)I||(X+=S+" ",G=!0);else for(;X.indexOf(" "+S+" ")>-1;)X=X.replace(" "+S+" "," ");return this.extraClasses=Dt(X),G},toggleExpanded:function(){return this.tree._callHook("nodeToggleExpanded",this)},toggleSelected:function(){return this.tree._callHook("nodeToggleSelected",this)},toString:function(){return"FancytreeNode@"+this.key+"[title='"+this.title+"']"},triggerModifyChild:function(b,k,S){var I,N=this.tree.options.modifyChild;N&&(k&&k.parent!==this&&t.error("childNode "+k+" is not a child of "+this),I={node:this,tree:this.tree,operation:b,childNode:k||null},S&&t.extend(I,S),N({type:"modifyChild"},I))},triggerModify:function(b,k){this.parent.triggerModifyChild(b,this,k)},visit:function(b,k){var S,I,N=!0,B=this.children;if(k===!0&&(N=b(this),N===!1||N==="skip"))return N;if(B)for(S=0,I=B.length;S<I&&(N=B[S].visit(b,!0),N!==!1);S++);return N},visitAndLoad:function(b,k,S){var I,N,B,V=this;return b&&k===!0&&(N=b(V),N===!1||N==="skip")?S?N:te():!V.children&&!V.lazy?te():(I=new t.Deferred,B=[],V.load().done(function(){for(var G=0,J=V.children.length;G<J;G++)if(N=V.children[G].visitAndLoad(b,!0,!0),N===!1){I.reject();break}else N!=="skip"&&B.push(N);t.when.apply(this,B).then(function(){I.resolve()})}),I.promise())},visitParents:function(b,k){if(k&&b(this)===!1)return!1;for(var S=this.parent;S;){if(b(S)===!1)return!1;S=S.parent}return!0},visitSiblings:function(b,k){var S,I,N,B=this.parent.children;for(S=0,I=B.length;S<I;S++)if(N=B[S],(k||N!==this)&&b(N)===!1)return!1;return!0},warn:function(b){this.tree.options.debugLevel>=2&&(Array.prototype.unshift.call(arguments,this.toString()),gt("warn",arguments))}};function dt(b){this.widget=b,this.$div=b.element,this.options=b.options,this.options&&(this.options.lazyload!==void 0&&t.error("The 'lazyload' event is deprecated since 2014-02-25. Use 'lazyLoad' (with uppercase L) instead."),this.options.loaderror!==void 0&&t.error("The 'loaderror' event was renamed since 2014-07-03. Use 'loadError' (with uppercase E) instead."),this.options.fx!==void 0&&t.error("The 'fx' option was replaced by 'toggleEffect' since 2014-11-30."),this.options.removeNode!==void 0&&t.error("The 'removeNode' event was replaced by 'modifyChild' since 2.20 (2016-09-10).")),this.ext={},this.types={},this.columns={},this.data=ht(this.$div),this._id=""+(this.options.treeId||t.ui.fancytree._nextId++),this._ns=".fancytree-"+this._id,this.activeNode=null,this.focusNode=null,this._hasFocus=null,this._tempCache={},this._lastMousedownNode=null,this._enableUpdate=!0,this.lastSelectedNode=null,this.systemFocusElement=null,this.lastQuicksearchTerm="",this.lastQuicksearchTime=0,this.viewport=null,this.statusClassPropName="span",this.ariaPropName="li",this.nodeContainerAttrName="li",this.$div.find(">ul.fancytree-container").remove();var k={tree:this},S;this.rootNode=new Et(k,{title:"root",key:"root_"+this._id,children:null,expanded:!0}),this.rootNode.parent=null,S=t("<ul>",{id:"ft-id-"+this._id,class:"ui-fancytree fancytree-container fancytree-plain"}).appendTo(this.$div),this.$container=S,this.rootNode.ul=S[0],this.options.debugLevel==null&&(this.options.debugLevel=n.debugLevel)}return dt.prototype={_makeHookContext:function(b,k,S){var I,N;return b.node!==void 0?(k&&b.originalEvent!==k&&t.error("invalid args"),I=b):b.tree?(N=b.tree,I={node:b,tree:N,widget:N.widget,options:N.widget.options,originalEvent:k,typeInfo:N.types[b.type]||{}}):b.widget?I={node:null,tree:b,widget:b.widget,options:b.widget.options,originalEvent:k}:t.error("invalid args"),S&&t.extend(I,S),I},_callHook:function(b,k,S){var I=this._makeHookContext(k),N=this[b],B=Array.prototype.slice.call(arguments,2);return vt(N)||t.error("_callHook('"+b+"') is not a function"),B.unshift(I),N.apply(this,B)},_setExpiringValue:function(b,k,S){this._tempCache[b]={value:k,expire:Date.now()+(+S||50)}},_getExpiringValue:function(b){var k=this._tempCache[b];return k&&k.expire>Date.now()?k.value:(delete this._tempCache[b],null)},_usesExtension:function(b){return t.inArray(b,this.options.extensions)>=0},_requireExtension:function(b,k,S,I){S!=null&&(S=!!S);var N=this._local.name,B=this.options.extensions,V=t.inArray(b,B)<t.inArray(N,B),G=k&&this.ext[b]==null,J=!G&&S!=null&&S!==V;return it(N&&N!==b,"invalid or same name '"+N+"' (require yourself?)"),G||J?(I||(G||k?(I="'"+N+"' extension requires '"+b+"'",J&&(I+=" to be registered "+(S?"before":"after")+" itself")):I="If used together, `"+b+"` must be registered "+(S?"before":"after")+" `"+N+"`"),t.error(I),!1):!0},activateKey:function(b,k){var S=this.getNodeByKey(b);return S?S.setActive(!0,k):this.activeNode&&this.activeNode.setActive(!1,k),S},addPagingNode:function(b,k){return this.rootNode.addPagingNode(b,k)},applyCommand:function(b,k,S){var I;switch(k=k||this.getActiveNode(),b){case"moveUp":I=k.getPrevSibling(),I&&(k.moveTo(I,"before"),k.setActive());break;case"moveDown":I=k.getNextSibling(),I&&(k.moveTo(I,"after"),k.setActive());break;case"indent":I=k.getPrevSibling(),I&&(k.moveTo(I,"child"),I.setExpanded(),k.setActive());break;case"outdent":k.isTopLevel()||(k.moveTo(k.getParent(),"after"),k.setActive());break;case"remove":I=k.getPrevSibling()||k.getParent(),k.remove(),I&&I.setActive();break;case"addChild":k.editCreateNode("child","");break;case"addSibling":k.editCreateNode("after","");break;case"rename":k.editStart();break;case"down":case"first":case"last":case"left":case"parent":case"right":case"up":return k.navigate(b);default:t.error("Unhandled command: '"+b+"'")}},applyPatch:function(b){var k,S,I,N,B,V,G=b.length,J=[];for(S=0;S<G;S++)I=b[S],it(I.length===2,"patchList must be an array of length-2-arrays"),N=I[0],B=I[1],V=N===null?this.rootNode:this.getNodeByKey(N),V?(k=new t.Deferred,J.push(k),V.applyPatch(B).always(bt(k,V))):this.warn("could not find node with key '"+N+"'");return t.when.apply(t,J).promise()},clear:function(b){this._callHook("treeClear",this)},count:function(){return this.rootNode.countChildren()},debug:function(b){this.options.debugLevel>=4&&(Array.prototype.unshift.call(arguments,this.toString()),gt("log",arguments))},destroy:function(){this.widget.destroy()},enable:function(b){b===!1?this.widget.disable():this.widget.enable()},enableUpdate:function(b){return b=b!==!1,!!this._enableUpdate==!!b?b:(this._enableUpdate=b,b?(this.debug("enableUpdate(true): redraw "),this._callHook("treeStructureChanged",this,"enableUpdate"),this.render()):this.debug("enableUpdate(false)..."),!b)},error:function(b){this.options.debugLevel>=1&&(Array.prototype.unshift.call(arguments,this.toString()),gt("error",arguments))},expandAll:function(b,k){var S=this.enableUpdate(!1);b=b!==!1,this.visit(function(I){I.hasChildren()!==!1&&I.isExpanded()!==b&&I.setExpanded(b,k)}),this.enableUpdate(S)},findAll:function(b){return this.rootNode.findAll(b)},findFirst:function(b){return this.rootNode.findFirst(b)},findNextNode:function(b,k){var S=null,I=this.getFirstChild();b=typeof b=="string"?At(b):b,k=k||I;function N(B){if(b(B)&&(S=B),S||B===k)return!1}return this.visitRows(N,{start:k,includeSelf:!1}),!S&&k!==I&&this.visitRows(N,{start:I,includeSelf:!0}),S},findRelatedNode:function(b,k,S){var I=null,N=t.ui.keyCode;switch(k){case"parent":case N.BACKSPACE:b.parent&&b.parent.parent&&(I=b.parent);break;case"first":case N.HOME:this.visit(function(B){if(B.isVisible())return I=B,!1});break;case"last":case N.END:this.visit(function(B){B.isVisible()&&(I=B)});break;case"left":case N.LEFT:b.expanded?b.setExpanded(!1):b.parent&&b.parent.parent&&(I=b.parent);break;case"right":case N.RIGHT:!b.expanded&&(b.children||b.lazy)?(b.setExpanded(),I=b):b.children&&b.children.length&&(I=b.children[0]);break;case"up":case N.UP:this.visitRows(function(B){return I=B,!1},{start:b,reverse:!0,includeSelf:!1});break;case"down":case N.DOWN:this.visitRows(function(B){return I=B,!1},{start:b,includeSelf:!1});break;default:this.tree.warn("Unknown relation '"+k+"'.")}return I},generateFormElements:function(b,k,S){S=S||{};var I,N=typeof b=="string"?b:"ft_"+this._id+"[]",B=typeof k=="string"?k:"ft_"+this._id+"_active",V="fancytree_result_"+this._id,G=t("#"+V),J=this.options.selectMode===3&&S.stopOnParents!==!1;G.length?G.empty():G=t("<div>",{id:V}).hide().insertAfter(this.$container),k!==!1&&this.activeNode&&G.append(t("<input>",{type:"radio",name:B,value:this.activeNode.key,checked:!0}));function X(wt){G.append(t("<input>",{type:"checkbox",name:N,value:wt.key,checked:!0}))}S.filter?this.visit(function(wt){var $t=S.filter(wt);if($t==="skip")return $t;$t!==!1&&X(wt)}):b!==!1&&(I=this.getSelectedNodes(J),t.each(I,function(wt,$t){X($t)}))},getActiveNode:function(){return this.activeNode},getFirstChild:function(){return this.rootNode.getFirstChild()},getFocusNode:function(){return this.focusNode},getOption:function(b){return this.widget.option(b)},getNodeByKey:function(b,k){var S,I;return!k&&(S=document.getElementById(this.options.idPrefix+b),S)?S.ftnode?S.ftnode:null:(k=k||this.rootNode,I=null,b=""+b,k.visit(function(N){if(N.key===b)return I=N,!1},!0),I)},getRootNode:function(){return this.rootNode},getSelectedNodes:function(b){return this.rootNode.getSelectedNodes(b)},hasFocus:function(){return!!this._hasFocus},info:function(b){this.options.debugLevel>=3&&(Array.prototype.unshift.call(arguments,this.toString()),gt("info",arguments))},isLoading:function(){var b=!1;return this.rootNode.visit(function(k){if(k._isLoading||k._requestId)return b=!0,!1},!0),b},loadKeyPath:function(b,k){var S,I,N,B=this,V=new t.Deferred,G=this.getRootNode(),J=this.options.keyPathSeparator,X=[],wt=t.extend({},k);for(typeof k=="function"?S=k:k&&k.callback&&(S=k.callback),wt.callback=function($t,lt,Ht){S&&S.call($t,lt,Ht),V.notifyWith($t,[{node:lt,status:Ht}])},wt.matchKey==null&&(wt.matchKey=function($t,lt){return $t.key===lt}),jt(b)||(b=[b]),I=0;I<b.length;I++)N=b[I],N.charAt(0)===J&&(N=N.substr(1)),X.push(N.split(J));return setTimeout(function(){B._loadKeyPathImpl(V,wt,G,X).done(function(){V.resolve()})},0),V.promise()},_loadKeyPathImpl:function(b,k,S,I){var N,B,V,G,J,X,wt,$t,lt,Ht,Kt=this;function qt(be,Ce){var _e,je,Si=be.children;if(Si){for(_e=0,je=Si.length;_e<je;_e++)if(k.matchKey(Si[_e],Ce))return Si[_e]}return null}for(wt={},B=0;B<I.length;B++)for(lt=I[B],$t=S;lt.length;)if(V=lt.shift(),G=qt($t,V),G)if(lt.length===0){k.callback(this,G,"ok");break}else if(!G.lazy||G.hasChildren()!==void 0)k.callback(this,G,"loaded"),$t=G;else{k.callback(this,G,"loaded"),V=G.key,wt[V]?wt[V].pathSegList.push(lt):wt[V]={parent:G,pathSegList:[lt]};break}else{this.warn("loadKeyPath: key not found: "+V+" (parent: "+$t+")"),k.callback(this,V,"error");break}N=[];function Vt(be,Ce,_e){k.callback(Kt,Ce,"loading"),Ce.load().done(function(){Kt._loadKeyPathImpl.call(Kt,be,k,Ce,_e).always(bt(be,Kt))}).fail(function(je){Kt.warn("loadKeyPath: error loading lazy "+Ce),k.callback(Kt,G,"error"),be.rejectWith(Kt)})}for(J in wt)rt(wt,J)&&(X=wt[J],Ht=new t.Deferred,N.push(Ht),Vt(Ht,X.parent,X.pathSegList));return t.when.apply(t,N).promise()},reactivate:function(b){var k,S=this.activeNode;return S?(this.activeNode=null,k=S.setActive(!0,{noFocus:!0}),b&&S.setFocus(),k):te()},reload:function(b){return this._callHook("treeClear",this),this._callHook("treeLoad",this,b)},render:function(b,k){return this.rootNode.render(b,k)},selectAll:function(b){this.visit(function(k){k.setSelected(b)})},setFocus:function(b){return this._callHook("treeSetFocus",this,b)},setOption:function(b,k){return this.widget.option(b,k)},debugTime:function(b){this.options.debugLevel>=4&&window.console.time(this+" - "+b)},debugTimeEnd:function(b){this.options.debugLevel>=4&&window.console.timeEnd(this+" - "+b)},toDict:function(b,k){var S=this.rootNode.toDict(!0,k);return b?S:S.children},toString:function(){return"Fancytree@"+this._id},_triggerNodeEvent:function(b,k,S,I){var N=this._makeHookContext(k,S,I),B=this.widget._trigger(b,S,N);return B!==!1&&N.result!==void 0?N.result:B},_triggerTreeEvent:function(b,k,S){var I=this._makeHookContext(this,k,S),N=this.widget._trigger(b,k,I);return N!==!1&&I.result!==void 0?I.result:N},visit:function(b){return this.rootNode.visit(b,!1)},visitRows:function(b,k){if(!this.rootNode.hasChildren())return!1;if(k&&k.reverse)return delete k.reverse,this._visitRowsUp(b,k);k=k||{};var S,I,N,B,V,G=0,J=k.includeSelf===!1,X=!!k.includeHidden,wt=!X&&this.enableFilter,$t=k.start||this.rootNode.children[0];for(N=$t.parent;N;){for(V=N.children,I=V.indexOf($t)+G,it(I>=0,"Could not find "+$t+" in parent's children: "+N),S=I;S<V.length;S++)if($t=V[S],!(wt&&!$t.match&&!$t.subMatchCount)&&(!J&&b($t)===!1||(J=!1,$t.children&&$t.children.length&&(X||$t.expanded)&&(B=$t.visit(function(lt){if(wt&&!lt.match&&!lt.subMatchCount)return"skip";if(b(lt)===!1)return!1;if(!X&<.children&&!lt.expanded)return"skip"},!1),B===!1))))return!1;$t=N,N=N.parent,G=1}return!0},_visitRowsUp:function(b,k){for(var S,I,N,B=!!k.includeHidden,V=k.start||this.rootNode.children[0];;){if(N=V.parent,S=N.children,S[0]===V){if(V=N,!V.parent)break;S=N.children}else for(I=S.indexOf(V),V=S[I-1];(B||V.expanded)&&V.children&&V.children.length;)S=V.children,N=V,V=S[S.length-1];if(!(!B&&!V.isVisible())&&b(V)===!1)return!1}},warn:function(b){this.options.debugLevel>=2&&(Array.prototype.unshift.call(arguments,this.toString()),gt("warn",arguments))}},t.extend(dt.prototype,{nodeClick:function(b){var k,S,I=b.targetType,N=b.node;if(I==="expander"){if(N.isLoading()){N.debug("Got 2nd click while loading: ignored");return}this._callHook("nodeToggleExpanded",b)}else if(I==="checkbox")this._callHook("nodeToggleSelected",b),b.options.focusOnSelect&&this._callHook("nodeSetFocus",b,!0);else{if(S=!1,k=!0,N.folder)switch(b.options.clickFolderMode){case 2:S=!0,k=!1;break;case 3:k=!0,S=!0;break}k&&(this.nodeSetFocus(b),this._callHook("nodeSetActive",b,!0)),S&&this._callHook("nodeToggleExpanded",b)}},nodeCollapseSiblings:function(b,k){var S,I,N,B=b.node;if(B.parent)for(S=B.parent.children,I=0,N=S.length;I<N;I++)S[I]!==B&&S[I].expanded&&this._callHook("nodeSetExpanded",S[I],!1,k)},nodeDblclick:function(b){b.targetType==="title"&&b.options.clickFolderMode===4&&this._callHook("nodeToggleExpanded",b),b.targetType==="title"&&b.originalEvent.preventDefault()},nodeKeydown:function(b){var k,S,I,N=b.originalEvent,B=b.node,V=b.tree,G=b.options,J=N.which,X=N.key||String.fromCharCode(J),wt=!!(N.altKey||N.ctrlKey||N.metaKey),$t=!T[J]&&!x[J]&&!wt,lt=t(N.target),Ht=!0,Kt=!(N.ctrlKey||!G.autoActivate);if(B||(I=this.getActiveNode()||this.getFirstChild(),I&&(I.setFocus(),B=b.node=this.focusNode,B.debug("Keydown force focus on active node"))),G.quicksearch&&$t&&!lt.is(":input:enabled")){S=Date.now(),S-V.lastQuicksearchTime>500&&(V.lastQuicksearchTerm=""),V.lastQuicksearchTime=S,V.lastQuicksearchTerm+=X,k=V.findNextNode(V.lastQuicksearchTerm,V.getActiveNode()),k&&k.setActive(),N.preventDefault();return}switch(n.eventToString(N)){case"+":case"=":V.nodeSetExpanded(b,!0);break;case"-":V.nodeSetExpanded(b,!1);break;case"space":B.isPagingNode()?V._triggerNodeEvent("clickPaging",b,N):n.evalOption("checkbox",B,B,G,!1)?V.nodeToggleSelected(b):V.nodeSetActive(b,!0);break;case"return":V.nodeSetActive(b,!0);break;case"home":case"end":case"backspace":case"left":case"right":case"up":case"down":B.navigate(N.which,Kt);break;default:Ht=!1}Ht&&N.preventDefault()},nodeLoadChildren:function(b,k){var S,I,N=null,B,V=!0,G=b.tree,J=b.node,X=J.parent,wt="nodeLoadChildren",$t=Date.now();return vt(k)&&(k=k.call(G,{type:"source"},b),it(!vt(k),"source callback must not return another function")),vt(k.then)?N=k:k.url?(S=t.extend({},b.options.ajax,k),S.debugDelay?(I=S.debugDelay,delete S.debugDelay,jt(I)&&(I=I[0]+Math.random()*(I[1]-I[0])),J.warn("nodeLoadChildren waiting debugDelay "+Math.round(I)+" ms ..."),N=t.Deferred(function(lt){setTimeout(function(){t.ajax(S).done(function(){lt.resolveWith(this,arguments)}).fail(function(){lt.rejectWith(this,arguments)})},I)})):N=t.ajax(S)):t.isPlainObject(k)||jt(k)?(N={then:function(lt,Ht){lt(k,null,null)}},V=!1):t.error("Invalid source type: "+k),J._requestId&&(J.warn("Recursive load request #"+$t+" while #"+J._requestId+" is pending."),J._requestId=$t),V&&(G.debugTime(wt),G.nodeSetStatus(b,"loading")),B=new t.Deferred,N.then(function(lt,Ht,Kt){var qt,Vt;if((k.dataType==="json"||k.dataType==="jsonp")&&typeof lt=="string"&&t.error("Ajax request returned a string (did you get the JSON dataType wrong?)."),J._requestId&&J._requestId>$t){B.rejectWith(this,[c]);return}if(J.parent===null&&X!==null){B.rejectWith(this,[u]);return}if(b.options.postProcess){try{Vt=G._triggerNodeEvent("postProcess",b,b.originalEvent,{response:lt,error:null,dataType:k.dataType}),Vt.error&&G.warn("postProcess returned error:",Vt)}catch(be){Vt={error:be,message:""+be,details:"postProcess failed"}}if(Vt.error){qt=t.isPlainObject(Vt.error)?Vt.error:{message:Vt.error},qt=G._makeHookContext(J,null,qt),B.rejectWith(this,[qt]);return}(jt(Vt)||t.isPlainObject(Vt)&&jt(Vt.children))&&(lt=Vt)}else lt&&rt(lt,"d")&&b.options.enableAspx&&(b.options.enableAspx===42&&G.warn("The default for enableAspx will change to `false` in the fututure. Pass `enableAspx: true` or implement postProcess to silence this warning."),lt=typeof lt.d=="string"?t.parseJSON(lt.d):lt.d);B.resolveWith(this,[lt])},function(lt,Ht,Kt){var qt=G._makeHookContext(J,null,{error:lt,args:Array.prototype.slice.call(arguments),message:Kt,details:lt.status+": "+Kt});B.rejectWith(this,[qt])}),B.done(function(lt){G.nodeSetStatus(b,"ok");var Ht,Kt,qt;t.isPlainObject(lt)?(it(J.isRootNode(),"source may only be an object for root nodes (expecting an array of child objects otherwise)"),it(jt(lt.children),"if an object is passed as source, it must contain a 'children' array (all other properties are added to 'tree.data')"),Kt=lt,Ht=lt.children,delete Kt.children,t.each(R,function(Vt,be){Kt[be]!==void 0&&(G[be]=Kt[be],delete Kt[be])}),t.extend(G.data,Kt)):Ht=lt,it(jt(Ht),"expected array of children"),J._setChildren(Ht),G.options.nodata&&Ht.length===0&&(vt(G.options.nodata)?qt=G.options.nodata.call(G,{type:"nodata"},b):G.options.nodata===!0&&J.isRootNode()?qt=G.options.strings.noData:typeof G.options.nodata=="string"&&J.isRootNode()&&(qt=G.options.nodata),qt&&J.setStatus("nodata",qt)),G._triggerNodeEvent("loadChildren",J)}).fail(function(lt){var Ht;if(lt===c){J.warn("Ignored response for obsolete load request #"+$t+" (expected #"+J._requestId+")");return}else if(lt===u){J.warn("Lazy parent node was removed while loading: discarding response.");return}else lt.node&<.error&<.message?Ht=lt:(Ht=G._makeHookContext(J,null,{error:lt,args:Array.prototype.slice.call(arguments),message:lt?lt.message||lt.toString():""}),Ht.message==="[object Object]"&&(Ht.message=""));J.warn("Load children failed ("+Ht.message+")",Ht),G._triggerNodeEvent("loadError",Ht,null)!==!1&&G.nodeSetStatus(b,"error",Ht.message,Ht.details)}).always(function(){J._requestId=null,V&&G.debugTimeEnd(wt)}),B.promise()},nodeLoadKeyPath:function(b,k){},nodeRemoveChild:function(b,k){var S,I=b.node,N=t.extend({},b,{node:k}),B=I.children;if(B.length===1)return it(k===B[0],"invalid single child"),this.nodeRemoveChildren(b);this.activeNode&&(k===this.activeNode||this.activeNode.isDescendantOf(k))&&this.activeNode.setActive(!1),this.focusNode&&(k===this.focusNode||this.focusNode.isDescendantOf(k))&&(this.focusNode=null),this.nodeRemoveMarkup(N),this.nodeRemoveChildren(N),S=t.inArray(k,B),it(S>=0,"invalid child"),I.triggerModifyChild("remove",k),k.visit(function(V){V.parent=null},!0),this._callHook("treeRegisterNode",this,!1,k),B.splice(S,1)},nodeRemoveChildMarkup:function(b){var k=b.node;k.ul&&(k.isRootNode()?t(k.ul).empty():(t(k.ul).remove(),k.ul=null),k.visit(function(S){S.li=S.ul=null}))},nodeRemoveChildren:function(b){var k=b.tree,S=b.node,I=S.children;I&&(this.activeNode&&this.activeNode.isDescendantOf(S)&&this.activeNode.setActive(!1),this.focusNode&&this.focusNode.isDescendantOf(S)&&(this.focusNode=null),this.nodeRemoveChildMarkup(b),S.triggerModifyChild("remove",null),S.visit(function(N){N.parent=null,k._callHook("treeRegisterNode",k,!1,N)}),S.lazy?S.children=[]:S.children=null,S.isRootNode()||(S.expanded=!1),this.nodeRenderStatus(b))},nodeRemoveMarkup:function(b){var k=b.node;k.li&&(t(k.li).remove(),k.li=null),this.nodeRemoveChildMarkup(b)},nodeRender:function(b,k,S,I,N){var B,V,G,J,X,wt,$t,lt=b.node,Ht=b.tree,Kt=b.options,qt=Kt.aria,Vt=!1,be=lt.parent,Ce=!be,_e=lt.children,je=null;if(Ht._enableUpdate!==!1&&!(!Ce&&!be.ul)){if(it(Ce||be.ul,"parent UL must exist"),Ce||(lt.li&&(k||lt.li.parentNode!==lt.parent.ul)&&(lt.li.parentNode===lt.parent.ul?je=lt.li.nextSibling:this.debug("Unlinking "+lt+" (must be child of "+lt.parent+")"),this.nodeRemoveMarkup(b)),lt.li?this.nodeRenderStatus(b):(Vt=!0,lt.li=document.createElement("li"),lt.li.ftnode=lt,lt.key&&Kt.generateIds&&(lt.li.id=Kt.idPrefix+lt.key),lt.span=document.createElement("span"),lt.span.className="fancytree-node",qt&&!lt.tr&&t(lt.li).attr("role","treeitem"),lt.li.appendChild(lt.span),this.nodeRenderTitle(b),Kt.createNode&&Kt.createNode.call(Ht,{type:"createNode"},b)),Kt.renderNode&&Kt.renderNode.call(Ht,{type:"renderNode"},b)),_e){if(Ce||lt.expanded||S===!0){for(lt.ul||(lt.ul=document.createElement("ul"),(I===!0&&!N||!lt.expanded)&&(lt.ul.style.display="none"),qt&&t(lt.ul).attr("role","group"),lt.li?lt.li.appendChild(lt.ul):lt.tree.$div.append(lt.ul)),J=0,X=_e.length;J<X;J++)$t=t.extend({},b,{node:_e[J]}),this.nodeRender($t,k,S,!1,!0);for(B=lt.ul.firstChild;B;)G=B.ftnode,G&&G.parent!==lt?(lt.debug("_fixParent: remove missing "+G,B),wt=B.nextSibling,B.parentNode.removeChild(B),B=wt):B=B.nextSibling;for(B=lt.ul.firstChild,J=0,X=_e.length-1;J<X;J++)V=_e[J],G=B.ftnode,V===G?B=B.nextSibling:lt.ul.insertBefore(V.li,G.li)}}else lt.ul&&(this.warn("remove child markup for "+lt),this.nodeRemoveChildMarkup(b));Ce||Vt&&be.ul.insertBefore(lt.li,je)}},nodeRenderTitle:function(b,k){var S,I,N,B,V,G,J,X,wt=b.node,$t=b.tree,lt=b.options,Ht=lt.aria,Kt=wt.getLevel(),qt=[];k!==void 0&&(wt.title=k),!(!wt.span||$t._enableUpdate===!1)&&(V=Ht&&wt.hasChildren()!==!1?" role='button'":"",Kt<lt.minExpandLevel?(wt.lazy||(wt.expanded=!0),Kt>1&&qt.push("<span "+V+" class='fancytree-expander fancytree-expander-fixed'></span>")):qt.push("<span "+V+" class='fancytree-expander'></span>"),S=n.evalOption("checkbox",wt,wt,lt,!1),S&&!wt.isStatusNode()&&(V=Ht?" role='checkbox'":"",I="fancytree-checkbox",(S==="radio"||wt.parent&&wt.parent.radiogroup)&&(I+=" fancytree-radio"),qt.push("<span "+V+" class='"+I+"'></span>")),wt.data.iconClass!==void 0&&(wt.icon?t.error("'iconClass' node option is deprecated since v2.14.0: use 'icon' only instead"):(wt.warn("'iconClass' node option is deprecated since v2.14.0: use 'icon' instead"),wt.icon=wt.data.iconClass)),N=n.evalOption("icon",wt,wt,lt,!0),N!==!1&&(V=Ht?" role='presentation'":"",X=n.evalOption("iconTooltip",wt,wt,lt,null),X=X?" title='"+Tt(X)+"'":"",typeof N=="string"?s.test(N)?(N=N.charAt(0)==="/"?N:(lt.imagePath||"")+N,qt.push("<img src='"+N+"' class='fancytree-icon'"+X+" alt='' />")):qt.push("<span "+V+" class='fancytree-custom-icon "+N+"'"+X+"></span>"):N.text?qt.push("<span "+V+" class='fancytree-custom-icon "+(N.addClass||"")+"'"+X+">"+n.escapeHtml(N.text)+"</span>"):N.html?qt.push("<span "+V+" class='fancytree-custom-icon "+(N.addClass||"")+"'"+X+">"+N.html+"</span>"):qt.push("<span "+V+" class='fancytree-icon'"+X+"></span>")),B="",lt.renderTitle&&(B=lt.renderTitle.call($t,{type:"renderTitle"},b)||""),B||(J=n.evalOption("tooltip",wt,wt,lt,null),J===!0&&(J=wt.title),J=J?" title='"+Tt(J)+"'":"",G=lt.titlesTabbable?" tabindex='0'":"",B="<span class='fancytree-title'"+J+G+">"+(lt.escapeTitles?n.escapeHtml(wt.title):wt.title)+"</span>"),qt.push(B),wt.span.innerHTML=qt.join(""),this.nodeRenderStatus(b),lt.enhanceTitle&&(b.$title=t(">span.fancytree-title",wt.span),B=lt.enhanceTitle.call($t,{type:"enhanceTitle"},b)||""))},nodeRenderStatus:function(b){var k,S=b.node,I=b.tree,N=b.options,B=S.hasChildren(),V=S.isLastSibling(),G=N.aria,J=N._classNames,X=[],wt=S[I.statusClassPropName];!wt||I._enableUpdate===!1||(G&&(k=t(S.tr||S.li)),X.push(J.node),I.activeNode===S&&X.push(J.active),I.focusNode===S&&X.push(J.focused),S.expanded&&X.push(J.expanded),G&&(B===!1?k.removeAttr("aria-expanded"):k.attr("aria-expanded",!!S.expanded)),S.folder&&X.push(J.folder),B!==!1&&X.push(J.hasChildren),V&&X.push(J.lastsib),S.lazy&&S.children==null&&X.push(J.lazy),S.partload&&X.push(J.partload),S.partsel&&X.push(J.partsel),n.evalOption("unselectable",S,S,N,!1)&&X.push(J.unselectable),S._isLoading&&X.push(J.loading),S._error&&X.push(J.error),S.statusNodeType&&X.push(J.statusNodePrefix+S.statusNodeType),S.selected?(X.push(J.selected),G&&k.attr("aria-selected",!0)):G&&k.attr("aria-selected",!1),S.extraClasses&&X.push(S.extraClasses),B===!1?X.push(J.combinedExpanderPrefix+"n"+(V?"l":"")):X.push(J.combinedExpanderPrefix+(S.expanded?"e":"c")+(S.lazy&&S.children==null?"d":"")+(V?"l":"")),X.push(J.combinedIconPrefix+(S.expanded?"e":"c")+(S.folder?"f":"")),wt.className=X.join(" "),S.li&&t(S.li).toggleClass(J.lastsib,V))},nodeSetActive:function(b,k,S){S=S||{};var I,N=b.node,B=b.tree,V=b.options,G=S.noEvents===!0,J=S.noFocus===!0,X=S.scrollIntoView!==!1,wt=N===B.activeNode;return k=k!==!1,wt===k?te(N):(X&&b.originalEvent&&t(b.originalEvent.target).is("a,:checkbox")&&(N.info("Not scrolling while clicking an embedded link."),X=!1),k&&!G&&this._triggerNodeEvent("beforeActivate",N,b.originalEvent)===!1?ut(N,["rejected"]):(k?(B.activeNode&&(it(B.activeNode!==N,"node was active (inconsistency)"),I=t.extend({},b,{node:B.activeNode}),B.nodeSetActive(I,!1),it(B.activeNode===null,"deactivate was out of sync?")),V.activeVisible&&N.makeVisible({scrollIntoView:X}),B.activeNode=N,B.nodeRenderStatus(b),J||B.nodeSetFocus(b),G||B._triggerNodeEvent("activate",N,b.originalEvent)):(it(B.activeNode===N,"node was not active (inconsistency)"),B.activeNode=null,this.nodeRenderStatus(b),G||b.tree._triggerNodeEvent("deactivate",N,b.originalEvent)),te(N)))},nodeSetExpanded:function(b,k,S){S=S||{};var I,N,B,V,G,J,X=b.node,wt=b.tree,$t=b.options,lt=S.noAnimation===!0,Ht=S.noEvents===!0;if(k=k!==!1,t(X.li).hasClass($t._classNames.animating))return X.warn("setExpanded("+k+") while animating: ignored."),ut(X,["recursion"]);if(X.expanded&&k||!X.expanded&&!k)return te(X);if(k&&!X.lazy&&!X.hasChildren())return te(X);if(!k&&X.getLevel()<$t.minExpandLevel)return ut(X,["locked"]);if(!Ht&&this._triggerNodeEvent("beforeExpand",X,b.originalEvent)===!1)return ut(X,["rejected"]);if(!lt&&!X.isVisible()&&(lt=S.noAnimation=!0),N=new t.Deferred,k&&!X.expanded&&$t.autoCollapse){G=X.getParentList(!1,!0),J=$t.autoCollapse;try{for($t.autoCollapse=!1,B=0,V=G.length;B<V;B++)this._callHook("nodeCollapseSiblings",G[B],S)}finally{$t.autoCollapse=J}}return N.done(function(){var Kt=X.getLastChild();k&&$t.autoScroll&&!lt&&Kt&&wt._enableUpdate?Kt.scrollIntoView(!0,{topNode:X}).always(function(){Ht||b.tree._triggerNodeEvent(k?"expand":"collapse",b)}):Ht||b.tree._triggerNodeEvent(k?"expand":"collapse",b)}),I=function(Kt){var qt=$t._classNames,Vt,be,Ce=$t.toggleEffect;if(X.expanded=k,wt._callHook("treeStructureChanged",b,k?"expand":"collapse"),wt._callHook("nodeRender",b,!1,!1,!0),X.ul)if(Vt=X.ul.style.display!=="none",be=!!X.expanded,Vt===be)X.warn("nodeSetExpanded: UL.style.display already set");else if(!Ce||lt)X.ul.style.display=X.expanded||!parent?"":"none";else{t(X.li).addClass(qt.animating),vt(t(X.ul)[Ce.effect])?t(X.ul)[Ce.effect]({duration:Ce.duration,always:function(){t(this).removeClass(qt.animating),t(X.li).removeClass(qt.animating),Kt()}}):(t(X.ul).stop(!0,!0),t(X.ul).parent().find(".ui-effects-placeholder").remove(),t(X.ul).toggle(Ce.effect,Ce.options,Ce.duration,function(){t(this).removeClass(qt.animating),t(X.li).removeClass(qt.animating),Kt()}));return}Kt()},k&&X.lazy&&X.hasChildren()===void 0?X.load().done(function(){N.notifyWith&&N.notifyWith(X,["loaded"]),I(function(){N.resolveWith(X)})}).fail(function(Kt){I(function(){N.rejectWith(X,["load failed ("+Kt+")"])})}):I(function(){N.resolveWith(X)}),N.promise()},nodeSetFocus:function(b,k){var S,I=b.tree,N=b.node,B=I.options,V=b.originalEvent?t(b.originalEvent.target).is(":input"):!1;if(k=k!==!1,I.focusNode){if(I.focusNode===N&&k)return;S=t.extend({},b,{node:I.focusNode}),I.focusNode=null,this._triggerNodeEvent("blur",S),this._callHook("nodeRenderStatus",S)}if(k){this.hasFocus()||(N.debug("nodeSetFocus: forcing container focus"),this._callHook("treeSetFocus",b,!0,{calledByNode:!0})),N.makeVisible({scrollIntoView:!1}),I.focusNode=N,B.titlesTabbable&&(V||t(N.span).find(".fancytree-title").trigger("focus")),B.aria&&t(I.$container).attr("aria-activedescendant",t(N.tr||N.li).uniqueId().attr("id")),this._triggerNodeEvent("focus",b);var G=document.activeElement===I.$container.get(0)||t(document.activeElement,I.$container).length>=1;G||t(I.$container).trigger("focus"),B.autoScroll&&N.scrollIntoView(),this._callHook("nodeRenderStatus",b)}},nodeSetSelected:function(b,k,S){S=S||{};var I=b.node,N=b.tree,B=b.options,V=S.noEvents===!0,G=I.parent;if(k=k!==!1,!n.evalOption("unselectable",I,I,B,!1)){if(I._lastSelectIntent=k,!!I.selected===k&&!(B.selectMode===3&&I.partsel&&!k))return k;if(!V&&this._triggerNodeEvent("beforeSelect",I,b.originalEvent)===!1)return!!I.selected;k&&B.selectMode===1?(N.lastSelectedNode&&N.lastSelectedNode.setSelected(!1),I.selected=k):B.selectMode===3&&G&&!G.radiogroup&&!I.radiogroup?(I.selected=k,I.fixSelection3AfterClick(S)):G&&G.radiogroup?I.visitSiblings(function(J){J._changeSelectStatusAttrs(k&&J===I)},!0):I.selected=k,this.nodeRenderStatus(b),N.lastSelectedNode=k?I:null,V||N._triggerNodeEvent("select",b)}},nodeSetStatus:function(b,k,S,I){var N=b.node,B=b.tree;function V(){var J=N.children?N.children[0]:null;if(J&&J.isStatusNode()){try{N.ul&&(N.ul.removeChild(J.li),J.li=null)}catch{}N.children.length===1?N.children=[]:N.children.shift(),B._callHook("treeStructureChanged",b,"clearStatusNode")}}function G(J,X){var wt=N.children?N.children[0]:null;return wt&&wt.isStatusNode()?(t.extend(wt,J),wt.statusNodeType=X,B._callHook("nodeRenderTitle",wt)):(N._setChildren([J]),B._callHook("treeStructureChanged",b,"setStatusNode"),N.children[0].statusNodeType=X,B.render()),N.children[0]}switch(k){case"ok":V(),N._isLoading=!1,N._error=null,N.renderStatus();break;case"loading":N.parent||G({title:B.options.strings.loading+(S?" ("+S+")":""),checkbox:!1,tooltip:I},k),N._isLoading=!0,N._error=null,N.renderStatus();break;case"error":G({title:B.options.strings.loadError+(S?" ("+S+")":""),checkbox:!1,tooltip:I},k),N._isLoading=!1,N._error={message:S,details:I},N.renderStatus();break;case"nodata":G({title:S||B.options.strings.noData,checkbox:!1,tooltip:I},k),N._isLoading=!1,N._error=null,N.renderStatus();break;default:t.error("invalid node status "+k)}},nodeToggleExpanded:function(b){return this.nodeSetExpanded(b,!b.node.expanded)},nodeToggleSelected:function(b){var k=b.node,S=!k.selected;return k.partsel&&!k.selected&&k._lastSelectIntent===!0&&(S=!1,k.selected=!0),k._lastSelectIntent=S,this.nodeSetSelected(b,S)},treeClear:function(b){var k=b.tree;k.activeNode=null,k.focusNode=null,k.$div.find(">ul.fancytree-container").empty(),k.rootNode.children=null,k._callHook("treeStructureChanged",b,"clear")},treeCreate:function(b){},treeDestroy:function(b){this.$div.find(">ul.fancytree-container").remove(),this.$source&&this.$source.removeClass("fancytree-helper-hidden")},treeInit:function(b){var k=b.tree,S=k.options;k.$container.attr("tabindex",S.tabindex),t.each(R,function(I,N){S[N]!==void 0&&(k.info("Move option "+N+" to tree"),k[N]=S[N],delete S[N])}),S.checkboxAutoHide&&k.$container.addClass("fancytree-checkbox-auto-hide"),S.rtl?k.$container.attr("DIR","RTL").addClass("fancytree-rtl"):k.$container.removeAttr("DIR").removeClass("fancytree-rtl"),S.aria&&(k.$container.attr("role","tree"),S.selectMode!==1&&k.$container.attr("aria-multiselectable",!0)),this.treeLoad(b)},treeLoad:function(b,k){var S,I,N,B=b.tree,V=b.widget.element,G,J=t.extend({},b,{node:this.rootNode});if(B.rootNode.children&&this.treeClear(b),k=k||this.options.source,k)typeof k=="string"&&t.error("Not implemented");else switch(I=V.data("type")||"html",I){case"html":N=V.find(">ul").not(".fancytree-container").first(),N.length?(N.addClass("ui-fancytree-source fancytree-helper-hidden"),k=t.ui.fancytree.parseHtml(N),this.data=t.extend(this.data,ht(N))):(n.warn("No `source` option was passed and container does not contain `<ul>`: assuming `source: []`."),k=[]);break;case"json":k=t.parseJSON(V.text()),V.contents().filter(function(){return this.nodeType===3}).remove(),t.isPlainObject(k)&&(it(jt(k.children),"if an object is passed as source, it must contain a 'children' array (all other properties are added to 'tree.data')"),S=k,k=k.children,delete S.children,t.each(R,function(X,wt){S[wt]!==void 0&&(B[wt]=S[wt],delete S[wt])}),t.extend(B.data,S));break;default:t.error("Invalid data-type: "+I)}return B._triggerTreeEvent("preInit",null),G=this.nodeLoadChildren(J,k).done(function(){B._callHook("treeStructureChanged",b,"loadChildren"),B.render(),b.options.selectMode===3&&B.rootNode.fixSelection3FromEndNodes(),B.activeNode&&B.options.activeVisible&&B.activeNode.makeVisible(),B._triggerTreeEvent("init",null,{status:!0})}).fail(function(){B.render(),B._triggerTreeEvent("init",null,{status:!1})}),G},treeRegisterNode:function(b,k,S){b.tree._callHook("treeStructureChanged",b,k?"addNode":"removeNode")},treeSetFocus:function(b,k,S){var I;k=k!==!1,k!==this.hasFocus()&&(this._hasFocus=k,!k&&this.focusNode?this.focusNode.setFocus(!1):k&&(!S||!S.calledByNode)&&t(this.$container).trigger("focus"),this.$container.toggleClass("fancytree-treefocus",k),this._triggerTreeEvent(k?"focusTree":"blurTree"),k&&!this.activeNode&&(I=this._lastMousedownNode||this.getFirstChild(),I&&I.setFocus()))},treeSetOption:function(b,k,S){var I=b.tree,N=!0,B=!1,V=!1;switch(k){case"aria":case"checkbox":case"icon":case"minExpandLevel":case"tabindex":B=!0,V=!0;break;case"checkboxAutoHide":I.$container.toggleClass("fancytree-checkbox-auto-hide",!!S);break;case"escapeTitles":case"tooltip":V=!0;break;case"rtl":S===!1?I.$container.removeAttr("DIR").removeClass("fancytree-rtl"):I.$container.attr("DIR","RTL").addClass("fancytree-rtl"),V=!0;break;case"source":N=!1,I._callHook("treeLoad",I,S),V=!0;break}I.debug("set option "+k+"="+S+" <"+typeof S+">"),N&&(this.widget._super?this.widget._super.call(this.widget,k,S):t.Widget.prototype._setOption.call(this.widget,k,S)),B&&I._callHook("treeCreate",I),V&&I.render(!0,!1)},treeStructureChanged:function(b,k){}}),t.widget("ui.fancytree",{options:{activeVisible:!0,ajax:{type:"GET",cache:!1,dataType:"json"},aria:!0,autoActivate:!0,autoCollapse:!1,autoScroll:!1,checkbox:!1,clickFolderMode:4,copyFunctionsToData:!1,debugLevel:null,disabled:!1,enableAspx:42,escapeTitles:!1,extensions:[],focusOnSelect:!1,generateIds:!1,icon:!0,idPrefix:"ft_",keyboard:!0,keyPathSeparator:"/",minExpandLevel:1,nodata:!0,quicksearch:!1,rtl:!1,scrollOfs:{top:0,bottom:0},scrollParent:null,selectMode:2,strings:{loading:"Loading...",loadError:"Load error!",moreData:"More...",noData:"No data."},tabindex:"0",titlesTabbable:!1,toggleEffect:{effect:"slideToggle",duration:200},tooltip:!1,treeId:null,_classNames:{active:"fancytree-active",animating:"fancytree-animating",combinedExpanderPrefix:"fancytree-exp-",combinedIconPrefix:"fancytree-ico-",error:"fancytree-error",expanded:"fancytree-expanded",focused:"fancytree-focused",folder:"fancytree-folder",hasChildren:"fancytree-has-children",lastsib:"fancytree-lastsib",lazy:"fancytree-lazy",loading:"fancytree-loading",node:"fancytree-node",partload:"fancytree-partload",partsel:"fancytree-partsel",radio:"fancytree-radio",selected:"fancytree-selected",statusNodePrefix:"fancytree-statusnode-",unselectable:"fancytree-unselectable"},lazyLoad:null,postProcess:null},_deprecationWarning:function(b){var k=this.tree;k&&k.options.debugLevel>=3&&k.warn("$().fancytree('"+b+"') is deprecated (see https://wwwendt.de/tech/fancytree/doc/jsdoc/Fancytree_Widget.html")},_create:function(){this.tree=new dt(this),this.$source=this.source||this.element.data("type")==="json"?this.element:this.element.find(">ul").first();var b,k,S,I=this.options,N=I.extensions,B=this.tree;for(S=0;S<N.length;S++)k=N[S],b=t.ui.fancytree._extensions[k],b||t.error("Could not apply extension '"+k+"' (it is not registered, did you forget to include it?)"),this.tree.options[k]=Nt({},b.options,this.tree.options[k]),it(this.tree.ext[k]===void 0,"Extension name must not exist as Fancytree.ext attribute: '"+k+"'"),this.tree.ext[k]={},re(this.tree,B,b,k),B=b;I.icons!==void 0&&(I.icon===!0?(this.tree.warn("'icons' tree option is deprecated since v2.14.0: use 'icon' instead"),I.icon=I.icons):t.error("'icons' tree option is deprecated since v2.14.0: use 'icon' only instead")),I.iconClass!==void 0&&(I.icon?t.error("'iconClass' tree option is deprecated since v2.14.0: use 'icon' only instead"):(this.tree.warn("'iconClass' tree option is deprecated since v2.14.0: use 'icon' instead"),I.icon=I.iconClass)),I.tabbable!==void 0&&(I.tabindex=I.tabbable?"0":"-1",this.tree.warn("'tabbable' tree option is deprecated since v2.17.0: use 'tabindex='"+I.tabindex+"' instead")),this.tree._callHook("treeCreate",this.tree)},_init:function(){this.tree._callHook("treeInit",this.tree),this._bind()},_setOption:function(b,k){return this.tree._callHook("treeSetOption",this.tree,b,k)},_destroy:function(){this._unbind(),this.tree._callHook("treeDestroy",this.tree)},_unbind:function(){var b=this.tree._ns;this.element.off(b),this.tree.$container.off(b),t(document).off(b)},_bind:function(){var b=this,k=this.options,S=this.tree,I=S._ns;this._unbind(),S.$container.on("focusin"+I+" focusout"+I,function(N){var B=n.getNode(N),V=N.type==="focusin";if(!V&&B&&t(N.target).is("a")){B.debug("Ignored focusout on embedded <a> element.");return}if(V){if(S._getExpiringValue("focusin")){S.debug("Ignored double focusin.");return}S._setExpiringValue("focusin",!0,50),B||(B=S._getExpiringValue("mouseDownNode"),B&&S.debug("Reconstruct mouse target for focusin from recent event."))}B?S._callHook("nodeSetFocus",S._makeHookContext(B,N),V):S.tbody&&t(N.target).parents("table.fancytree-container > thead").length?S.debug("Ignore focus event outside table body.",N):S._callHook("treeSetFocus",S,V)}).on("selectstart"+I,"span.fancytree-title",function(N){N.preventDefault()}).on("keydown"+I,function(N){if(k.disabled||k.keyboard===!1)return!0;var B,V=S.focusNode,G=S._makeHookContext(V||S,N),J=S.phase;try{return S.phase="userEvent",V?B=S._triggerNodeEvent("keydown",V,N):B=S._triggerTreeEvent("keydown",N),B==="preventNav"?B=!0:B!==!1&&(B=S._callHook("nodeKeydown",G)),B}finally{S.phase=J}}).on("mousedown"+I,function(N){var B=n.getEventTarget(N);S._lastMousedownNode=B?B.node:null,S._setExpiringValue("mouseDownNode",S._lastMousedownNode)}).on("click"+I+" dblclick"+I,function(N){if(k.disabled)return!0;var B,V=n.getEventTarget(N),G=V.node,J=b.tree,X=J.phase;if(!G)return!0;B=J._makeHookContext(G,N);try{switch(J.phase="userEvent",N.type){case"click":return B.targetType=V.type,G.isPagingNode()?J._triggerNodeEvent("clickPaging",B,N)===!0:J._triggerNodeEvent("click",B,N)===!1?!1:J._callHook("nodeClick",B);case"dblclick":return B.targetType=V.type,J._triggerNodeEvent("dblclick",B,N)===!1?!1:J._callHook("nodeDblclick",B)}}finally{J.phase=X}})},getActiveNode:function(){return this._deprecationWarning("getActiveNode"),this.tree.activeNode},getNodeByKey:function(b){return this._deprecationWarning("getNodeByKey"),this.tree.getNodeByKey(b)},getRootNode:function(){return this._deprecationWarning("getRootNode"),this.tree.rootNode},getTree:function(){return this._deprecationWarning("getTree"),this.tree}}),n=t.ui.fancytree,t.extend(t.ui.fancytree,{version:"2.38.5",buildType:"production",debugLevel:3,_nextId:1,_nextNodeKey:1,_extensions:{},_FancytreeClass:dt,_FancytreeNodeClass:Et,jquerySupports:{positionMyOfs:St(t.ui.version,1,9)},assert:function(b,k){return it(b,k)},createTree:function(b,k){var S=t(b).fancytree(k);return n.getTree(S)},debounce:function(b,k,S,I){var N;return arguments.length===3&&typeof S!="boolean"&&(I=S,S=!1),function(){var B=arguments;I=I||this,S&&!N&&k.apply(I,B),clearTimeout(N),N=setTimeout(function(){S||k.apply(I,B),N=null},b)}},debug:function(b){t.ui.fancytree.debugLevel>=4&>("log",arguments)},error:function(b){t.ui.fancytree.debugLevel>=1&>("error",arguments)},escapeHtml:function(b){return(""+b).replace(a,function(k){return p[k]})},fixPositionOptions:function(b){if((b.offset||(""+b.my+b.at).indexOf("%")>=0)&&t.error("expected new position syntax (but '%' is not supported)"),!t.ui.fancytree.jquerySupports.positionMyOfs){var k=/(\w+)([+-]?\d+)?\s+(\w+)([+-]?\d+)?/.exec(b.my),S=/(\w+)([+-]?\d+)?\s+(\w+)([+-]?\d+)?/.exec(b.at),I=(k[2]?+k[2]:0)+(S[2]?+S[2]:0),N=(k[4]?+k[4]:0)+(S[4]?+S[4]:0);b=t.extend({},b,{my:k[1]+" "+k[3],at:S[1]+" "+S[3]}),(I||N)&&(b.offset=""+I+" "+N)}return b},getEventTarget:function(b){var k,S,I=b&&b.target?b.target.className:"",N={node:this.getNode(b.target),type:void 0};return/\bfancytree-title\b/.test(I)?N.type="title":/\bfancytree-expander\b/.test(I)?N.type=N.node.hasChildren()===!1?"prefix":"expander":/\bfancytree-checkbox\b/.test(I)?N.type="checkbox":/\bfancytree(-custom)?-icon\b/.test(I)?N.type="icon":/\bfancytree-node\b/.test(I)?N.type="title":b&&b.target&&(k=t(b.target),k.is("ul[role=group]")?(S=N.node&&N.node.tree,(S||n).debug("Ignoring click on outer UL."),N.node=null):k.closest(".fancytree-title").length?N.type="title":k.closest(".fancytree-checkbox").length?N.type="checkbox":k.closest(".fancytree-expander").length&&(N.type="expander")),N},getEventTargetType:function(b){return this.getEventTarget(b).type},getNode:function(b){if(b instanceof Et)return b;for(b instanceof t?b=b[0]:b.originalEvent!==void 0&&(b=b.target);b;){if(b.ftnode)return b.ftnode;b=b.parentNode}return null},getTree:function(b){var k,S=b;return b instanceof dt?b:(b===void 0&&(b=0),typeof b=="number"?b=t(".fancytree-container").eq(b):typeof b=="string"?(b=t("#ft-id-"+S).eq(0),b.length||(b=t(S).eq(0))):b instanceof Element||b instanceof HTMLDocument?b=t(b):b instanceof t?b=b.eq(0):b.originalEvent!==void 0&&(b=t(b.target)),b=b.closest(":ui-fancytree"),k=b.data("ui-fancytree")||b.data("fancytree"),k?k.tree:null)},evalOption:function(b,k,S,I,N){var B,V,G=k.tree,J=I[b],X=S[b];return vt(J)?(B={node:k,tree:G,widget:G.widget,options:G.widget.options,typeInfo:G.types[k.type]||{}},V=J.call(G,{type:b},B),V==null&&(V=X)):V=X??J,V==null&&(V=N),V},setSpanIcon:function(b,k,S){var I=t(b);typeof S=="string"?I.attr("class",k+" "+S):(S.text?I.text(""+S.text):S.html&&(b.innerHTML=S.html),I.attr("class",k+" "+(S.addClass||"")))},eventToString:function(b){var k=b.which,S=b.type,I=[];return b.altKey&&I.push("alt"),b.ctrlKey&&I.push("ctrl"),b.metaKey&&I.push("meta"),b.shiftKey&&I.push("shift"),S==="click"||S==="dblclick"?I.push(M[b.button]+S):S==="wheel"?I.push(S):v[k]||I.push(x[k]||String.fromCharCode(k).toLowerCase()),I.join("+")},info:function(b){t.ui.fancytree.debugLevel>=3&>("info",arguments)},keyEventToString:function(b){return this.warn("keyEventToString() is deprecated: use eventToString()"),this.eventToString(b)},overrideMethod:function(b,k,S,I){var N,B=b[k]||t.noop;b[k]=function(){var V=I||this;try{return N=V._super,V._super=B,S.apply(V,arguments)}finally{V._super=N}}},parseHtml:function(b){var k,S,I,N,B,V,G,J,X=b.find(">li"),wt=[];return X.each(function(){var $t,lt,Ht=t(this),Kt=Ht.find(">span",this).first(),qt=Kt.length?null:Ht.find(">a").first(),Vt={tooltip:null,data:{}};for(Kt.length?Vt.title=Kt.html():qt&&qt.length?(Vt.title=qt.html(),Vt.data.href=qt.attr("href"),Vt.data.target=qt.attr("target"),Vt.tooltip=qt.attr("title")):(Vt.title=Ht.html(),B=Vt.title.search(/<ul/i),B>=0&&(Vt.title=Vt.title.substring(0,B))),Vt.title=Dt(Vt.title),N=0,V=P.length;N<V;N++)Vt[P[N]]=void 0;for(k=this.className.split(" "),I=[],N=0,V=k.length;N<V;N++)S=k[N],F[S]?Vt[S]=!0:I.push(S);if(Vt.extraClasses=I.join(" "),G=Ht.attr("title"),G&&(Vt.tooltip=G),G=Ht.attr("id"),G&&(Vt.key=G),Ht.attr("hideCheckbox")&&(Vt.checkbox=!1),$t=ht(Ht),$t&&!t.isEmptyObject($t)){for(lt in Q)rt($t,lt)&&($t[Q[lt]]=$t[lt],delete $t[lt]);for(N=0,V=q.length;N<V;N++)G=q[N],J=$t[G],J!=null&&(delete $t[G],Vt[G]=J);t.extend(Vt.data,$t)}b=Ht.find(">ul").first(),b.length?Vt.children=t.ui.fancytree.parseHtml(b):Vt.children=Vt.lazy?void 0:null,wt.push(Vt)}),wt},registerExtension:function(b){it(b.name!=null,"extensions must have a `name` property."),it(b.version!=null,"extensions must have a `version` property."),t.ui.fancytree._extensions[b.name]=b},trim:Dt,unescapeHtml:function(b){var k=document.createElement("div");return k.innerHTML=b,k.childNodes.length===0?"":k.childNodes[0].nodeValue},warn:function(b){t.ui.fancytree.debugLevel>=2&>("warn",arguments)}}),t.ui.fancytree})}(vc)),vc.exports}Ml();var yc={exports:{}};/*!
|
||
* jquery.fancytree.dnd5.js
|
||
*
|
||
* Drag-and-drop support (native HTML5).
|
||
* (Extension module for jquery.fancytree.js: https://github.com/mar10/fancytree/)
|
||
*
|
||
* Copyright (c) 2008-2023, Martin Wendt (https://wwWendt.de)
|
||
*
|
||
* Released under the MIT license
|
||
* https://github.com/mar10/fancytree/wiki/LicenseInfo
|
||
*
|
||
* @version 2.38.5
|
||
* @date 2025-04-05T06:40:00Z
|
||
*/var Su;function aw(){return Su||(Su=1,function(o){(function(t){o.exports?(Ml(),o.exports=t(Ll())):t(jQuery)})(function(t){var e=t.ui.fancytree,i=/Mac/.test(navigator.platform),n="fancytree-drag-source",s="fancytree-drag-remove",a="fancytree-drop-accept",l="fancytree-drop-after",c="fancytree-drop-before",u="fancytree-drop-over",p="fancytree-drop-reject",v="fancytree-drop-target",x="application/x-fancytree-node",T=null,M,P,F=null,R=null,q=null,H=null,Q=null,tt=null,it=null,rt=null,vt=null;function Dt(){H=null,vt=null,tt=null,it=null,Q=null,F=null,R=null,q&&q.removeClass(n+" "+s),q=null,T&&T.hide(),P&&(P.remove(),P=null)}function jt(bt){return bt===0?"":bt>0?"+"+bt:""+bt}function gt(bt){var ht;return!bt||(t.isPlainObject(bt)?ht={over:!!bt.over,before:!!bt.before,after:!!bt.after}:Array.isArray(bt)?ht={over:t.inArray("over",bt)>=0,before:t.inArray("before",bt)>=0,after:t.inArray("after",bt)>=0}:ht={over:bt===!0||bt==="over",before:bt===!0||bt==="before",after:bt===!0||bt==="after"},Object.keys(ht).length===0)?!1:ht}function Ct(bt,ht){var Tt,mt,At,Et=bt.options.dnd5,dt=bt.$scrollParent[0],b=Et.scrollSensitivity,k=Et.scrollSpeed,S=0;return dt!==document&&dt.tagName!=="HTML"?(Tt=bt.$scrollParent.offset(),mt=dt.scrollTop,Tt.top+dt.offsetHeight-ht.pageY<b?(At=dt.scrollHeight-bt.$scrollParent.innerHeight()-mt,At>0&&(dt.scrollTop=S=mt+k)):mt>0&&ht.pageY-Tt.top<b&&(dt.scrollTop=S=mt-k)):(mt=t(document).scrollTop(),mt>0&&ht.pageY-mt<b?(S=mt-k,t(document).scrollTop(S)):t(window).height()-(ht.pageY-mt)<b&&(S=mt+k,t(document).scrollTop(S))),S&&bt.debug("autoScroll: "+S+"px"),S}function St(bt,ht,Tt){var mt=Tt;return i?ht.metaKey&&ht.altKey||ht.ctrlKey?mt="link":ht.metaKey?mt="move":ht.altKey&&(mt="copy"):ht.ctrlKey?mt="copy":ht.shiftKey?mt="move":ht.altKey&&(mt="link"),mt!==Q&&bt.info("evalEffectModifiers: "+ht.type+" - evalEffectModifiers(): "+Q+" -> "+mt),Q=mt,mt}function Nt(bt,ht){var Tt=ht.tree,mt=ht.dataTransfer;bt.type==="dragstart"?(ht.effectAllowed=Tt.options.dnd5.effectAllowed,ht.dropEffect=Tt.options.dnd5.dropEffectDefault):(ht.effectAllowed=it,ht.dropEffect=tt),ht.dropEffectSuggested=St(Tt,bt,Tt.options.dnd5.dropEffectDefault),ht.isMove=ht.dropEffect==="move",ht.files=mt.files||[]}function Zt(bt,ht,Tt){var mt=ht.tree,At=ht.dataTransfer;return bt.type!=="dragstart"&&it!==ht.effectAllowed&&mt.warn("effectAllowed should only be changed in dragstart event: "+bt.type+": data.effectAllowed changed from "+it+" -> "+ht.effectAllowed),Tt===!1&&(mt.info("applyDropEffectCallback: allowDrop === false"),ht.effectAllowed="none",ht.dropEffect="none"),ht.isMove=ht.dropEffect==="move",bt.type==="dragstart"&&(it=ht.effectAllowed,tt=ht.dropEffect),At.effectAllowed=it,At.dropEffect=tt,tt}function re(bt,ht){if(ht.options.dnd5.scroll&&Ct(ht.tree,bt),!ht.node)return ht.tree.warn("Ignored dragover for non-node"),rt;var Tt,mt,At,Et,dt=null,b=ht.tree,k=b.options,S=k.dnd5,I=ht.node,N=ht.otherNode,B="center",V=t(I.span),G=V.find("span.fancytree-title");if(H===!1)return b.debug("Ignored dragover, since dragenter returned false."),!1;if(typeof H=="string"&&t.error("assert failed: dragenter returned string"),mt=V.offset(),Et=(bt.pageY-mt.top)/V.height(),bt.pageY===void 0&&b.warn("event.pageY is undefined: see issue #1013."),H.after&&Et>.75||!H.over&&H.after&&Et>.5?dt="after":H.before&&Et<=.25||!H.over&&H.before&&Et<=.5?dt="before":H.over&&(dt="over"),S.preventVoidMoves&&ht.dropEffect==="move"&&(I===N?(I.debug("Drop over source node prevented."),dt=null):dt==="before"&&N&&I===N.getNextSibling()?(I.debug("Drop after source node prevented."),dt=null):dt==="after"&&N&&I===N.getPrevSibling()?(I.debug("Drop before source node prevented."),dt=null):dt==="over"&&N&&N.parent===I&&N.isLastSibling()&&(I.debug("Drop last child over own parent prevented."),dt=null)),ht.hitMode=dt,dt&&S.dragOver){Nt(bt,ht),S.dragOver(I,ht);var J=!!dt;Zt(bt,ht,J),dt=ht.hitMode}if(rt=dt,dt==="after"||dt==="before"||dt==="over"){switch(Tt=S.dropMarkerOffsetX||0,dt){case"before":B="top",Tt+=S.dropMarkerInsertOffsetX||0;break;case"after":B="bottom",Tt+=S.dropMarkerInsertOffsetX||0;break}At={my:"left"+jt(Tt)+" center",at:"left "+B,of:G},k.rtl&&(At.my="right"+jt(-Tt)+" center",At.at="right "+B),T.toggleClass(l,dt==="after").toggleClass(u,dt==="over").toggleClass(c,dt==="before").show().position(e.fixPositionOptions(At))}else T.hide();return t(I.span).toggleClass(v,dt==="after"||dt==="before"||dt==="over").toggleClass(l,dt==="after").toggleClass(c,dt==="before").toggleClass(a,dt==="over").toggleClass(p,dt===!1),dt}function te(bt){var ht,Tt=this,mt=Tt.options.dnd5,At=e.getNode(bt),Et=bt.dataTransfer||bt.originalEvent.dataTransfer,dt={tree:Tt,node:At,options:Tt.options,originalEvent:bt.originalEvent,widget:Tt.widget,dataTransfer:Et,useDefaultImage:!0,dropEffect:void 0,dropEffectSuggested:void 0,effectAllowed:void 0,files:void 0,isCancelled:void 0,isMove:void 0};switch(bt.type){case"dragstart":if(!At)return Tt.info("Ignored dragstart on a non-node."),!1;F=At,mt.multiSource===!1?R=[At]:mt.multiSource===!0?At.isSelected()?R=Tt.getSelectedNodes():R=[At]:R=mt.multiSource(At,dt),q=t(t.map(R,function(k){return k.span})),q.addClass(n);var b=At.toDict(!0,mt.sourceCopyHook);b.treeId=At.tree._id,ht=JSON.stringify(b);try{Et.setData(x,ht),Et.setData("text/html",t(At.span).html()),Et.setData("text/plain",At.title)}catch(k){Tt.warn("Could not set data (IE only accepts 'text') - "+k)}return mt.setTextTypeJson?Et.setData("text",ht):Et.setData("text",At.title),Nt(bt,dt),mt.dragStart(At,dt)===!1?(Dt(),!1):(Zt(bt,dt),P=null,dt.useDefaultImage&&(M=t(At.span).find(".fancytree-title"),R&&R.length>1&&(P=t("<span class='fancytree-childcounter'/>").text("+"+(R.length-1)).appendTo(M)),Et.setDragImage&&Et.setDragImage(M[0],-10,-10)),!0);case"drag":Nt(bt,dt),mt.dragDrag(At,dt),Zt(bt,dt),q.toggleClass(s,dt.isMove);break;case"dragend":Nt(bt,dt),Dt(),dt.isCancelled=!rt,mt.dragEnd(At,dt,!rt);break}}function ut(bt){var ht,Tt,mt,At,Et,dt,b=this,k=b.options.dnd5,S=null,I=e.getNode(bt),N=bt.dataTransfer||bt.originalEvent.dataTransfer,B={tree:b,node:I,options:b.options,originalEvent:bt.originalEvent,widget:b.widget,hitMode:H,dataTransfer:N,otherNode:F||null,otherNodeList:R||null,otherNodeData:null,useDefaultImage:!0,dropEffect:void 0,dropEffectSuggested:void 0,effectAllowed:void 0,files:null,isCancelled:void 0,isMove:void 0};switch(bt.type){case"dragenter":if(vt=null,!I){b.debug("Ignore non-node "+bt.type+": "+bt.target.tagName+"."+bt.target.className),H=!1;break}if(t(I.span).addClass(u).removeClass(a+" "+p),At=t.inArray(x,N.types)>=0,k.preventNonNodes&&!At){I.debug("Reject dropping a non-node."),H=!1;break}else if(k.preventForeignNodes&&(!F||F.tree!==I.tree)){I.debug("Reject dropping a foreign node."),H=!1;break}else if(k.preventSameParent&&B.otherNode&&B.otherNode.tree===I.tree&&I.parent===B.otherNode.parent){I.debug("Reject dropping as sibling (same parent)."),H=!1;break}else if(k.preventRecursion&&B.otherNode&&B.otherNode.tree===I.tree&&I.isDescendantOf(B.otherNode)){I.debug("Reject dropping below own ancestor."),H=!1;break}else if(k.preventLazyParents&&!I.isLoaded()){I.warn("Drop over unloaded target node prevented."),H=!1;break}T.show(),Nt(bt,B),Et=k.dragEnter(I,B),dt=gt(Et),H=dt,S=dt&&(dt.over||dt.before||dt.after),Zt(bt,B,S);break;case"dragover":if(!I){b.debug("Ignore non-node "+bt.type+": "+bt.target.tagName+"."+bt.target.className);break}Nt(bt,B),rt=re(bt,B),S=!!rt,Tt=rt==="over"||rt===!1,Tt&&!I.expanded&&I.hasChildren()!==!1?vt?k.autoExpandMS&&Date.now()-vt>k.autoExpandMS&&!I.isLoading()&&(!k.dragExpand||k.dragExpand(I,B)!==!1)&&I.setExpanded():vt=Date.now():vt=null;break;case"dragleave":if(!I){b.debug("Ignore non-node "+bt.type+": "+bt.target.tagName+"."+bt.target.className);break}if(!t(I.span).hasClass(u)){I.debug("Ignore dragleave (multi).");break}t(I.span).removeClass(u+" "+a+" "+p),I.scheduleAction("cancel"),k.dragLeave(I,B),T.hide();break;case"drop":if(t.inArray(x,N.types)>=0&&(mt=N.getData(x),b.info(bt.type+": getData('application/x-fancytree-node'): '"+mt+"'")),mt||(mt=N.getData("text"),b.info(bt.type+": getData('text'): '"+mt+"'")),mt)try{ht=JSON.parse(mt),ht.title!==void 0&&(B.otherNodeData=ht)}catch{}b.debug(bt.type+": nodeData: '"+mt+"', otherNodeData: ",B.otherNodeData),t(I.span).removeClass(u+" "+a+" "+p),B.hitMode=rt,Nt(bt,B),B.isCancelled=!rt;var V=F&&F.span,G=F&&F.tree;k.dragDrop(I,B),bt.preventDefault(),V&&!document.body.contains(V)&&(G===b?(b.debug("Drop handler removed source element: generating dragEnd."),k.dragEnd(F,B)):b.warn("Drop handler removed source element: dragend event may be lost.")),Dt();break}if(S)return bt.preventDefault(),!1}return t.ui.fancytree.getDragNodeList=function(){return R||[]},t.ui.fancytree.getDragNode=function(){return F},t.ui.fancytree.registerExtension({name:"dnd5",version:"2.38.5",options:{autoExpandMS:1500,dropMarkerInsertOffsetX:-16,dropMarkerOffsetX:-24,dropMarkerParent:"body",multiSource:!1,effectAllowed:"all",dropEffectDefault:"move",preventForeignNodes:!1,preventLazyParents:!0,preventNonNodes:!1,preventRecursion:!0,preventSameParent:!1,preventVoidMoves:!0,scroll:!0,scrollSensitivity:20,scrollSpeed:5,setTextTypeJson:!1,sourceCopyHook:null,dragStart:null,dragDrag:t.noop,dragEnd:t.noop,dragEnter:null,dragOver:t.noop,dragExpand:t.noop,dragDrop:t.noop,dragLeave:t.noop},treeInit:function(bt){var ht,Tt=bt.tree,mt=bt.options,At=mt.glyph||null,Et=mt.dnd5;t.inArray("dnd",mt.extensions)>=0&&t.error("Extensions 'dnd' and 'dnd5' are mutually exclusive."),Et.dragStop&&t.error("dragStop is not used by ext-dnd5. Use dragEnd instead."),Et.preventRecursiveMoves!=null&&t.error("preventRecursiveMoves was renamed to preventRecursion."),Et.dragStart&&e.overrideMethod(bt.options,"createNode",function(dt,b){this._super.apply(this,arguments),b.node.span?b.node.span.draggable=!0:b.node.warn("Cannot add `draggable`: no span tag")}),this._superApply(arguments),this.$container.addClass("fancytree-ext-dnd5"),ht=t("<span>").appendTo(this.$container),this.$scrollParent=ht.scrollParent(),ht.remove(),T=t("#fancytree-drop-marker"),T.length||(T=t("<div id='fancytree-drop-marker'></div>").hide().css({"z-index":1e3,"pointer-events":"none"}).prependTo(Et.dropMarkerParent),At&&e.setSpanIcon(T[0],At.map._addClass,At.map.dropMarker)),T.toggleClass("fancytree-rtl",!!mt.rtl),Et.dragStart&&Tt.$container.on("dragstart drag dragend",te.bind(Tt)),Et.dragEnter&&Tt.$container.on("dragenter dragover dragleave drop",ut.bind(Tt))}}),t.ui.fancytree})}(yc)),yc.exports}aw();var bc={exports:{}};/*!
|
||
*
|
||
* jquery.fancytree.clones.js
|
||
* Support faster lookup of nodes by key and shared ref-ids.
|
||
* (Extension module for jquery.fancytree.js: https://github.com/mar10/fancytree/)
|
||
*
|
||
* Copyright (c) 2008-2023, Martin Wendt (https://wwWendt.de)
|
||
*
|
||
* Released under the MIT license
|
||
* https://github.com/mar10/fancytree/wiki/LicenseInfo
|
||
*
|
||
* @version 2.38.5
|
||
* @date 2025-04-05T06:40:00Z
|
||
*/var Tu;function lw(){return Tu||(Tu=1,function(o){(function(t){o.exports?(Ml(),o.exports=t(Ll())):t(jQuery)})(function(t){var e=t.ui.fancytree.assert;function i(a,l){var c;for(c=a.length-1;c>=0;c--)if(a[c]===l)return a.splice(c,1),!0;return!1}function n(a,l,c){for(var u,p,v=a.length&3,x=a.length-v,T=c,M=3432918353,P=461845907,F=0;F<x;)p=a.charCodeAt(F)&255|(a.charCodeAt(++F)&255)<<8|(a.charCodeAt(++F)&255)<<16|(a.charCodeAt(++F)&255)<<24,++F,p=(p&65535)*M+(((p>>>16)*M&65535)<<16)&4294967295,p=p<<15|p>>>17,p=(p&65535)*P+(((p>>>16)*P&65535)<<16)&4294967295,T^=p,T=T<<13|T>>>19,u=(T&65535)*5+(((T>>>16)*5&65535)<<16)&4294967295,T=(u&65535)+27492+(((u>>>16)+58964&65535)<<16);switch(p=0,v){case 3:p^=(a.charCodeAt(F+2)&255)<<16;case 2:p^=(a.charCodeAt(F+1)&255)<<8;case 1:p^=a.charCodeAt(F)&255,p=(p&65535)*M+(((p>>>16)*M&65535)<<16)&4294967295,p=p<<15|p>>>17,p=(p&65535)*P+(((p>>>16)*P&65535)<<16)&4294967295,T^=p}return T^=a.length,T^=T>>>16,T=(T&65535)*2246822507+(((T>>>16)*2246822507&65535)<<16)&4294967295,T^=T>>>13,T=(T&65535)*3266489909+(((T>>>16)*3266489909&65535)<<16)&4294967295,T^=T>>>16,("0000000"+(T>>>0).toString(16)).substr(-8)}function s(a){var l,c,u=t.map(a.getParentList(!1,!0),function(p){return p.refKey||p.key});return u=u.join("/"),c=n(u),l="id_"+c+n(c+u),l}return t.ui.fancytree._FancytreeNodeClass.prototype.getCloneList=function(a){var l,c=this.tree,u=c.refMap[this.refKey]||null,p=c.keyMap;return u&&(l=this.key,a?u=t.map(u,function(v){return p[v]}):(u=t.map(u,function(v){return v===l?null:p[v]}),u.length<1&&(u=null))),u},t.ui.fancytree._FancytreeNodeClass.prototype.isClone=function(){var a=this.refKey||null,l=a&&this.tree.refMap[a]||null;return!!(l&&l.length>1)},t.ui.fancytree._FancytreeNodeClass.prototype.reRegister=function(a,l){a=a==null?null:""+a,l=l==null?null:""+l;var c=this.tree,u=this.key,p=this.refKey,v=c.keyMap,x=c.refMap,T=x[p]||null,M=!1;return a!=null&&a!==this.key&&(v[a]&&t.error("[ext-clones] reRegister("+a+"): already exists: "+this),delete v[u],v[a]=this,T&&(x[p]=t.map(T,function(P){return P===u?a:P})),this.key=a,M=!0),l!=null&&l!==this.refKey&&(T&&(T.length===1?delete x[p]:x[p]=t.map(T,function(P){return P===u?null:P})),x[l]?x[l].append(a):x[l]=[this.key],this.refKey=l,M=!0),M},t.ui.fancytree._FancytreeNodeClass.prototype.setRefKey=function(a){return this.reRegister(null,a)},t.ui.fancytree._FancytreeClass.prototype.getNodesByRef=function(a,l){var c=this.keyMap,u=this.refMap[a]||null;return u&&(l?u=t.map(u,function(p){var v=c[p];return v.isDescendantOf(l)?v:null}):u=t.map(u,function(p){return c[p]}),u.length<1&&(u=null)),u},t.ui.fancytree._FancytreeClass.prototype.changeRefKey=function(a,l){var c,u,p=this.keyMap,v=this.refMap[a]||null;if(v){for(c=0;c<v.length;c++)u=p[v[c]],u.refKey=l;delete this.refMap[a],this.refMap[l]=v}},t.ui.fancytree.registerExtension({name:"clones",version:"2.38.5",options:{highlightActiveClones:!0,highlightClones:!1},treeCreate:function(a){this._superApply(arguments),a.tree.refMap={},a.tree.keyMap={}},treeInit:function(a){this.$container.addClass("fancytree-ext-clones"),e(a.options.defaultKey==null),a.options.defaultKey=function(l){return s(l)},this._superApply(arguments)},treeClear:function(a){return a.tree.refMap={},a.tree.keyMap={},this._superApply(arguments)},treeRegisterNode:function(a,l,c){var u,p,v=a.tree,x=v.keyMap,T=v.refMap,M=c.key,P=c&&c.refKey!=null?""+c.refKey:null;if(c.isStatusNode())return this._super(a,l,c);if(l){if(x[c.key]!=null){var F=x[c.key],R="clones.treeRegisterNode: duplicate key '"+c.key+"': /"+c.getPath(!0)+" => "+F.getPath(!0);v.error(R),t.error(R)}x[M]=c,P&&(u=T[P],u?(u.push(M),u.length===2&&a.options.clones.highlightClones&&x[u[0]].renderStatus()):T[P]=[M])}else x[M]==null&&t.error("clones.treeRegisterNode: node.key not registered: "+c.key),delete x[M],P&&(u=T[P],u&&(p=u.length,p<=1?(e(p===1),e(u[0]===M),delete T[P]):(i(u,M),p===2&&a.options.clones.highlightClones&&x[u[0]].renderStatus())));return this._super(a,l,c)},nodeRenderStatus:function(a){var l,c,u=a.node;return c=this._super(a),a.options.clones.highlightClones&&(l=t(u[a.tree.statusClassPropName]),l.length&&u.isClone()&&l.addClass("fancytree-clone")),c},nodeSetActive:function(a,l,c){var u,p=a.tree.statusClassPropName,v=a.node;return u=this._superApply(arguments),a.options.clones.highlightActiveClones&&v.isClone()&&t.each(v.getCloneList(!0),function(x,T){t(T[p]).toggleClass("fancytree-active-clone",l!==!1)}),u}}),t.ui.fancytree})}(bc)),bc.exports}lw();var wc={exports:{}};/*!
|
||
* jquery.fancytree.filter.js
|
||
*
|
||
* Remove or highlight tree nodes, based on a filter.
|
||
* (Extension module for jquery.fancytree.js: https://github.com/mar10/fancytree/)
|
||
*
|
||
* Copyright (c) 2008-2023, Martin Wendt (https://wwWendt.de)
|
||
*
|
||
* Released under the MIT license
|
||
* https://github.com/mar10/fancytree/wiki/LicenseInfo
|
||
*
|
||
* @version 2.38.5
|
||
* @date 2025-04-05T06:40:00Z
|
||
*/var Eu;function cw(){return Eu||(Eu=1,function(o){(function(t){o.exports?(Ml(),o.exports=t(Ll())):t(jQuery)})(function(t){var e="__not_found__",i=t.ui.fancytree.escapeHtml,n="",s="";function a(u){return(u+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}function l(u){return u.indexOf(">")>=0?t("<div/>").html(u).text():u}function c(u,p,v){for(var x=[],T=1;T<p.length;T++){var M=p[T].length+(T===1?0:1)+(x[x.length-1]||0);x.push(M)}var P=u.split("");return v?x.forEach(function(F){P[F]=n+P[F]+s}):x.forEach(function(F){P[F]="<mark>"+P[F]+"</mark>"}),P.join("")}return t.ui.fancytree._FancytreeClass.prototype._applyFilterImpl=function(u,p,v){var x,T,M,P,F,R,q,H,Q=0,tt=this.options,it=tt.escapeTitles,rt=tt.autoCollapse,vt=t.extend({},tt.filter,v),Dt=vt.mode==="hide",jt=!!vt.leavesOnly&&!p;if(typeof u=="string"){if(u===""){this.warn("Fancytree passing an empty string as a filter is handled as clearFilter()."),this.clearFilter();return}vt.fuzzy?x=u.split("").map(a).reduce(function(gt,Ct){return gt+"([^"+Ct+"]*)"+Ct},""):x=a(u),M=new RegExp(x,"i"),P=new RegExp(a(u),"gi"),it&&(F=new RegExp(a(n),"g"),R=new RegExp(a(s),"g")),u=function(gt){if(!gt.title)return!1;var Ct=it?gt.title:l(gt.title),St=Ct.match(M);return St&&vt.highlight&&(it?(vt.fuzzy?q=c(Ct,St,it):q=Ct.replace(P,function(Nt){return n+Nt+s}),gt.titleWithHighlight=i(q).replace(F,"<mark>").replace(R,"</mark>")):vt.fuzzy?gt.titleWithHighlight=c(Ct,St):gt.titleWithHighlight=Ct.replace(P,function(Nt){return"<mark>"+Nt+"</mark>"})),!!St}}return this.enableFilter=!0,this.lastFilterArgs=arguments,H=this.enableUpdate(!1),this.$div.addClass("fancytree-ext-filter"),Dt?this.$div.addClass("fancytree-ext-filter-hide"):this.$div.addClass("fancytree-ext-filter-dimm"),this.$div.toggleClass("fancytree-ext-filter-hide-expanders",!!vt.hideExpanders),this.rootNode.subMatchCount=0,this.visit(function(gt){delete gt.match,delete gt.titleWithHighlight,gt.subMatchCount=0}),T=this.getRootNode()._findDirectChild(e),T&&T.remove(),tt.autoCollapse=!1,this.visit(function(gt){if(!(jt&>.children!=null)){var Ct=u(gt),St=!1;if(Ct==="skip")return gt.visit(function(Nt){Nt.match=!1},!0),"skip";!Ct&&(p||Ct==="branch")&>.parent.match&&(Ct=!0,St=!0),Ct&&(Q++,gt.match=!0,gt.visitParents(function(Nt){Nt!==gt&&(Nt.subMatchCount+=1),vt.autoExpand&&!St&&!Nt.expanded&&(Nt.setExpanded(!0,{noAnimation:!0,noEvents:!0,scrollIntoView:!1}),Nt._filterAutoExpanded=!0)},!0))}}),tt.autoCollapse=rt,Q===0&&vt.nodata&&Dt&&(T=vt.nodata,typeof T=="function"&&(T=T()),T===!0?T={}:typeof T=="string"&&(T={title:T}),T=t.extend({statusNodeType:"nodata",key:e,title:this.options.strings.noData},T),this.getRootNode().addNode(T).match=!0),this._callHook("treeStructureChanged",this,"applyFilter"),this.enableUpdate(H),Q},t.ui.fancytree._FancytreeClass.prototype.filterNodes=function(u,p){return typeof p=="boolean"&&(p={leavesOnly:p},this.warn("Fancytree.filterNodes() leavesOnly option is deprecated since 2.9.0 / 2015-04-19. Use opts.leavesOnly instead.")),this._applyFilterImpl(u,!1,p)},t.ui.fancytree._FancytreeClass.prototype.filterBranches=function(u,p){return this._applyFilterImpl(u,!0,p)},t.ui.fancytree._FancytreeClass.prototype.updateFilter=function(){this.enableFilter&&this.lastFilterArgs&&this.options.filter.autoApply?this._applyFilterImpl.apply(this,this.lastFilterArgs):this.warn("updateFilter(): no filter active.")},t.ui.fancytree._FancytreeClass.prototype.clearFilter=function(){var u,p=this.getRootNode()._findDirectChild(e),v=this.options.escapeTitles,x=this.options.enhanceTitle,T=this.enableUpdate(!1);p&&p.remove(),delete this.rootNode.match,delete this.rootNode.subMatchCount,this.visit(function(M){M.match&&M.span&&(u=t(M.span).find(">span.fancytree-title"),v?u.text(M.title):u.html(M.title),x&&x({type:"enhanceTitle"},{node:M,$title:u})),delete M.match,delete M.subMatchCount,delete M.titleWithHighlight,M.$subMatchBadge&&(M.$subMatchBadge.remove(),delete M.$subMatchBadge),M._filterAutoExpanded&&M.expanded&&M.setExpanded(!1,{noAnimation:!0,noEvents:!0,scrollIntoView:!1}),delete M._filterAutoExpanded}),this.enableFilter=!1,this.lastFilterArgs=null,this.$div.removeClass("fancytree-ext-filter fancytree-ext-filter-dimm fancytree-ext-filter-hide"),this._callHook("treeStructureChanged",this,"clearFilter"),this.enableUpdate(T)},t.ui.fancytree._FancytreeClass.prototype.isFilterActive=function(){return!!this.enableFilter},t.ui.fancytree._FancytreeNodeClass.prototype.isMatched=function(){return!(this.tree.enableFilter&&!this.match)},t.ui.fancytree.registerExtension({name:"filter",version:"2.38.5",options:{autoApply:!0,autoExpand:!1,counter:!0,fuzzy:!1,hideExpandedCounter:!0,hideExpanders:!1,highlight:!0,leavesOnly:!1,nodata:!0,mode:"dimm"},nodeLoadChildren:function(u,p){var v=u.tree;return this._superApply(arguments).done(function(){v.enableFilter&&v.lastFilterArgs&&u.options.filter.autoApply&&v._applyFilterImpl.apply(v,v.lastFilterArgs)})},nodeSetExpanded:function(u,p,v){var x=u.node;return delete x._filterAutoExpanded,!p&&u.options.filter.hideExpandedCounter&&x.$subMatchBadge&&x.$subMatchBadge.show(),this._superApply(arguments)},nodeRenderStatus:function(u){var p,v=u.node,x=u.tree,T=u.options.filter,M=t(v.span).find("span.fancytree-title"),P=t(v[x.statusClassPropName]),F=u.options.enhanceTitle,R=u.options.escapeTitles;return p=this._super(u),!P.length||!x.enableFilter||(P.toggleClass("fancytree-match",!!v.match).toggleClass("fancytree-submatch",!!v.subMatchCount).toggleClass("fancytree-hide",!(v.match||v.subMatchCount)),T.counter&&v.subMatchCount&&(!v.isExpanded()||!T.hideExpandedCounter)?(v.$subMatchBadge||(v.$subMatchBadge=t("<span class='fancytree-childcounter'/>"),t("span.fancytree-icon, span.fancytree-custom-icon",v.span).append(v.$subMatchBadge)),v.$subMatchBadge.show().text(v.subMatchCount)):v.$subMatchBadge&&v.$subMatchBadge.hide(),v.span&&(!v.isEditing||!v.isEditing.call(v))&&(v.titleWithHighlight?M.html(v.titleWithHighlight):R?M.text(v.title):M.html(v.title),F&&F({type:"enhanceTitle"},{node:v,$title:M}))),p}}),t.ui.fancytree})}(wc)),wc.exports}cw();const dw=`
|
||
<div class="tree-wrapper">
|
||
<style>
|
||
.tree-wrapper {
|
||
flex-grow: 1;
|
||
flex-shrink: 1;
|
||
flex-basis: 60%;
|
||
font-family: var(--tree-font-family);
|
||
font-size: var(--tree-font-size);
|
||
position: relative;
|
||
min-height: 0;
|
||
}
|
||
|
||
.tree {
|
||
height: 100%;
|
||
overflow: auto;
|
||
padding-bottom: 35px;
|
||
padding-top: 5px;
|
||
}
|
||
|
||
.tree-actions {
|
||
background-color: var(--launcher-pane-background-color);
|
||
z-index: 100;
|
||
position: absolute;
|
||
bottom: 0;
|
||
display: flex;
|
||
align-items: flex-end;
|
||
justify-content: flex-end;
|
||
right: 17px;
|
||
border-radius: 7px;
|
||
border: 1px solid var(--main-border-color);
|
||
}
|
||
|
||
button.tree-floating-button {
|
||
margin: 1px;
|
||
font-size: 1.5em;
|
||
padding: 5px;
|
||
max-height: 34px;
|
||
color: var(--launcher-pane-text-color);
|
||
background-color: var(--button-background-color);
|
||
border-radius: var(--button-border-radius);
|
||
border: 1px solid transparent;
|
||
}
|
||
|
||
button.tree-floating-button:hover {
|
||
border: 1px solid var(--button-border-color);
|
||
}
|
||
|
||
.collapse-tree-button {
|
||
right: 100px;
|
||
}
|
||
|
||
.scroll-to-active-note-button {
|
||
right: 55px;
|
||
}
|
||
|
||
.tree-settings-button {
|
||
right: 10px;
|
||
}
|
||
|
||
.tree-settings-popup {
|
||
display: none;
|
||
position: absolute;
|
||
background-color: var(--accented-background-color);
|
||
border: 1px solid var(--main-border-color);
|
||
padding: 20px;
|
||
z-index: 1000;
|
||
width: 340px;
|
||
border-radius: 10px;
|
||
}
|
||
|
||
.tree .hidden-node-is-hidden {
|
||
display: none;
|
||
}
|
||
</style>
|
||
|
||
<div class="tree"></div>
|
||
|
||
<div class="tree-actions">
|
||
<button class="tree-floating-button bx bx-layer-minus collapse-tree-button"
|
||
title="${m("note_tree.collapse-title")}"
|
||
data-trigger-command="collapseTree"></button>
|
||
|
||
<button class="tree-floating-button bx bx-crosshair scroll-to-active-note-button"
|
||
title="${m("note_tree.scroll-active-title")}"
|
||
data-trigger-command="scrollToActiveNote"></button>
|
||
|
||
<button class="tree-floating-button bx bxs-tree tree-settings-button"
|
||
title="${m("note_tree.tree-settings-title")}"></button>
|
||
</div>
|
||
|
||
|
||
<div class="tree-settings-popup">
|
||
<h4>${m("note_tree.tree-settings-title")}</h4>
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-checkbox">
|
||
<input class="form-check-input hide-archived-notes" type="checkbox" value="">
|
||
${m("note_tree.hide-archived-notes")}
|
||
</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-checkbox">
|
||
<input class="form-check-input auto-collapse-note-tree" type="checkbox" value="">
|
||
${m("note_tree.automatically-collapse-notes")}
|
||
<span class="bx bx-info-circle"
|
||
title="${m("note_tree.automatically-collapse-notes-title")}"></span>
|
||
</label>
|
||
</div>
|
||
|
||
<br/>
|
||
|
||
<button class="btn btn-sm btn-primary save-tree-settings-button" type="submit">${m("note_tree.save-changes")}</button>
|
||
</div>
|
||
</div>
|
||
`,va=100,ya=o=>o.stopPropagation();class IA extends hi{$tree;$treeActions;$treeSettingsButton;$treeSettingsPopup;$saveTreeSettingsButton;$hideArchivedNotesCheckbox;$autoCollapseNoteTree;treeName;autoCollapseTimeoutId;lastFilteredHoistedNotePath;tree;constructor(){super(),this.treeName="main"}doRender(){this.$widget=$(dw),this.$tree=this.$widget.find(".tree"),this.$treeActions=this.$widget.find(".tree-actions"),this.$tree.on("mousedown",".unhoist-button",()=>li.unhoist()),this.$tree.on("mousedown",".refresh-search-button",t=>this.refreshSearch(t)),this.$tree.on("mousedown",".add-note-button",t=>{const e=$.ui.fancytree.getNode(t),i=fe.getNotePath(e);yr.createNote(i,{isProtected:e.data.isProtected})}),this.$tree.on("mousedown",".enter-workspace-button",t=>{const e=$.ui.fancytree.getNode(t);this.triggerCommand("hoistNote",{noteId:e.data.noteId})}),this.$tree.on("mousedown",".fancytree-title",t=>{if(t.which===2){const e=$.ui.fancytree.getNode(t),i=fe.getNotePath(e);i&&Pt.tabManager.openTabWithNoteWithHoisting(i,{activate:!!t.shiftKey}),t.stopPropagation(),t.preventDefault()}}),this.$treeSettingsPopup=this.$widget.find(".tree-settings-popup"),this.$hideArchivedNotesCheckbox=this.$treeSettingsPopup.find(".hide-archived-notes"),this.$autoCollapseNoteTree=this.$treeSettingsPopup.find(".auto-collapse-note-tree"),this.$treeSettingsButton=this.$widget.find(".tree-settings-button"),this.$treeSettingsButton.on("click",t=>{if(this.$treeSettingsPopup.is(":visible")){this.$treeSettingsPopup.hide();return}this.$hideArchivedNotesCheckbox.prop("checked",this.hideArchivedNotes),this.$autoCollapseNoteTree.prop("checked",this.autoCollapseNoteTree);const e=this.$treeActions[0].offsetTop-(this.$treeSettingsPopup.outerHeight()??0),i=Math.max(0,this.$treeActions[0].offsetLeft-(this.$treeSettingsPopup.outerWidth()??0)+(this.$treeActions.outerWidth()??0));return this.$treeSettingsPopup.css({top:e,left:i}).show(),!1}),this.$treeSettingsPopup.on("click",t=>{t.stopPropagation()}),$(document).on("click",()=>this.$treeSettingsPopup.hide()),this.$saveTreeSettingsButton=this.$treeSettingsPopup.find(".save-tree-settings-button"),this.$saveTreeSettingsButton.on("click",async()=>{await this.setHideArchivedNotes(this.$hideArchivedNotesCheckbox.prop("checked")),await this.setAutoCollapseNoteTree(this.$autoCollapseNoteTree.prop("checked")),this.$treeSettingsPopup.hide(),this.reloadTreeFromCache()}),Promise.all([Qt.initializedPromise,Mt.initializedPromise]).then(()=>this.initFancyTree()),this.setupNoteTitleTooltip()}setupNoteTitleTooltip(){const t=(e,i)=>{const n=e.offset(),s=(n?.top??0)+(e.outerHeight(!0)??0),a=(n?.left??0)+(e.outerWidth(!0)??0),l=i.offset(),c=(l?.top??0)+(i.outerHeight(!0)??0),u=(l?.left??0)+(i.outerWidth(!0)??0);return s>c&&(n?.top??0)<(l?.top??0)&&a>u&&(n?.left??0)<(l?.left??0)};this.$tree.on("mouseenter","span.fancytree-title",e=>{e.currentTarget.title=t(this.$tree,$(e.currentTarget))?"":e.currentTarget.innerText})}get hideArchivedNotes(){return Qt.is(`hideArchivedNotes_${this.treeName}`)}async setHideArchivedNotes(t){await Qt.save(`hideArchivedNotes_${this.treeName}`,t.toString())}get autoCollapseNoteTree(){return Qt.is("autoCollapseNoteTree")}async setAutoCollapseNoteTree(t){await Qt.save("autoCollapseNoteTree",t.toString())}initFancyTree(){const t=[this.prepareRootNode()];if(this.$tree.fancytree({titlesTabbable:!0,keyboard:!0,extensions:["dnd5","clones","filter"],source:t,scrollOfs:{top:100,bottom:100},scrollParent:this.$tree,minExpandLevel:2,click:(i,n)=>{this.activityDetected();const s=n.targetType,a=n.node,l=ct.isCtrlKey(i);if(a.isSelected()&&s==="icon")return this.triggerCommand("openBulkActionsDialog",{selectedOrActiveNoteIds:this.getSelectedOrActiveNoteIds(a)}),!1;if(s==="title"||s==="icon"){if(i.shiftKey&&!l){let c=function(p,v){for(let x=0;p&&p!==v&&x<1e4;x++)p.setSelected(!0),p=p.getNextSibling();v.setSelected()};const u=this.getActiveNode();if(u.getParent()!==a.getParent())return!0;this.clearSelectedNodes(),u.getIndex()<a.getIndex()?c(u,a):c(a,u),a.setFocus(!0)}else if(l){const c=fe.getNotePath(a);Pt.tabManager.openTabWithNoteWithHoisting(c,{activate:!!i.shiftKey})}else i.altKey?(a.setSelected(!a.isSelected()),a.setFocus(!0)):n.node.isActive()?this.tree.reactivate():a.setActive();return!1}return!0},beforeActivate:(i,{node:n})=>li.getHoistedNoteId()==="_hidden"?n.data.noteId!=="root":n.data.noteId!=="_hidden",activate:async(i,n)=>{Ho.hide(),$(".dropdown-menu").parent(".dropdown").find('[data-bs-toggle="dropdown"]').dropdown("hide"),this.clearSelectedNodes();const s=fe.getNotePath(n.node),a=Pt.tabManager.getActiveContext(),l={};a?.viewScope?.viewMode==="contextual-help"&&(l.viewScope=a.viewScope),await a?.setNote(s,l)},expand:(i,n)=>this.setExpanded(n.node.data.branchId,!0),collapse:(i,n)=>this.setExpanded(n.node.data.branchId,!1),filter:{counter:!1,mode:"hide",autoExpand:!0},dnd5:{autoExpandMS:600,preventLazyParents:!1,dragStart:(i,n)=>{if(i.data.noteId==="root"||ct.isLaunchBarConfig(i.data.noteId)||i.data.noteId.startsWith("_options"))return!1;const s=this.getSelectedOrActiveNodes(i).map(a=>({noteId:a.data.noteId,branchId:a.data.branchId,title:a.title}));return s.length===1?Pe.createLink(s[0].noteId,{referenceLink:!0,autoConvertToImage:!0}).then(a=>n.dataTransfer.setData("text/html",a[0].outerHTML)):Promise.all(s.map(a=>Pe.createLink(a.noteId,{referenceLink:!0,autoConvertToImage:!0}))).then(a=>{const l=$("<ul>").append(...a.map(c=>$("<li>").append(c)));n.dataTransfer.setData("text/html",l[0].outerHTML)}),n.dataTransfer.setData("text",JSON.stringify(s)),!0},dragEnter:(i,n)=>i.data.noteType==="search"||i.data.noteId==="_lbRoot"||i.data.noteId.startsWith("_options")?!1:i.data.noteType==="launcher"?["before","after"]:["_lbAvailableLaunchers","_lbVisibleLaunchers"].includes(i.data.noteId)?["over"]:!0,dragDrop:async(i,n)=>{if(n.hitMode==="over"&&i.data.noteType==="search"||["after","before"].includes(n.hitMode)&&(i.data.noteId===li.getHoistedNoteId()||i.getParent().data.noteType==="search")){await Me.info("Dropping notes into this location is not allowed.");return}const s=n.dataTransfer;if(s&&s.files&&s.files.length>0){const a=[...s.files];(await Z(()=>Promise.resolve().then(()=>kI),void 0,import.meta.url)).uploadFiles("notes",i.data.noteId,a,{safeImport:!0,shrinkImages:!0,textImportedAsText:!0,codeImportedAsCode:!0,explodeArchives:!0,replaceUnderscoresWithSpaces:!0})}else{const a=s.getData("text");let l;try{l=JSON.parse(a)}catch{logError(`Cannot parse JSON '${a}' into notes for drop`);return}const c=l.map(u=>u.branchId).filter(u=>u);if(n.hitMode==="before")ri.moveBeforeBranch(c,i.data.branchId);else if(n.hitMode==="after")ri.moveAfterBranch(c,i.data.branchId);else if(n.hitMode==="over")ri.moveToParentNote(c,i.data.branchId);else throw new Error(`Unknown hitMode '${n.hitMode}'`)}}},lazyLoad:(i,n)=>{const{noteId:s,noteType:a}=n.node.data;if(a==="search"){if(fe.getNotePath(n.node.getParent()).includes(s)){n.result=[];return}n.result=Mt.loadSearchNote(s).then(()=>{const c=Mt.getNoteFromCache(s);let u=c.getChildNoteIds();return c.type==="search"&&u.length>va&&(u=u.slice(0,va)),Mt.getNotes(u)}).then(()=>{const c=Mt.getNoteFromCache(s);return this.prepareChildren(c)})}else n.result=Mt.loadSubTree(s).then(l=>this.prepareChildren(l))},clones:{highlightActiveClones:!0},enhanceTitle:async function(i,n){const s=n.node;if(!s.data.noteId)return;const a=await Mt.getNote(s.data.noteId,!0);if(!a)return;const l=Pt.tabManager.getActiveContext(),c=$(s.span);c.find(".tree-item-button").remove();const u=l&&l.hoistedNoteId===a.noteId&&a.noteId!=="root";if(a.hasLabel("workspace")&&!u){const p=$(`<span class="tree-item-button enter-workspace-button bx bx-door-open" title="${m("note_tree.hoist-this-note-workspace")}"></span>`).on("click",ya);c.append(p)}if(a.type==="search"){const p=$(`<span class="tree-item-button refresh-search-button bx bx-refresh" title="${m("note_tree.refresh-saved-search-results")}"></span>`).on("click",ya);c.append(p)}if(!["search","launcher"].includes(a.type)&&!a.isOptions()&&!a.isLaunchBarConfig()&&!a.noteId.startsWith("_help")){const p=$(`<span class="tree-item-button add-note-button bx bx-plus" title="${m("note_tree.create-child-note")}"></span>`).on("click",ya);c.append(p)}if(u){const p=$(`<span class="tree-item-button unhoist-button bx bx-door-open" title="${m("note_tree.unhoist")}"></span>`).on("click",ya);c.append(p)}},loadChildren:(i,n)=>{n.node.visit(s=>{s.isUndefined()&&s.isExpanded()&&s.load()})},select:(i,{node:n})=>{if(li.getHoistedNoteId()==="root"&&n.data.noteId==="_hidden"&&n.isSelected()){n.setSelected(!1);return}$(n.span).find(".fancytree-custom-icon").attr("title",n.isSelected()?"Apply bulk actions on selected notes":"")}}),ct.isMobile()){let i;this.$tree.on("touchstart",".fancytree-node",n=>{new Date().getTime(),i=setTimeout(()=>{this.showContextMenu(n)},300)}),this.$tree.on("touchmove",".fancytree-node",n=>{clearTimeout(i)}),this.$tree.on("touchend",".fancytree-node",n=>{clearTimeout(i)})}else this.$tree.on("contextmenu",".fancytree-node",i=>(this.showContextMenu(i),!1)),this.getHotKeys().then(i=>{for(const n in i){const s=i[n];$(this.tree.$container).on("keydown",null,n,a=>{const l=this.tree.getActiveNode();return s(l,a)})}});this.tree=$.ui.fancytree.getTree(this.$tree)}showContextMenu(t){const e=$.ui.fancytree.getNode(t);Mt.getNoteFromCache(e.data.noteId).isLaunchBarConfig()?Z(async()=>{const{default:n}=await import("./launcher_context_menu.js");return{default:n}},__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url).then(({default:n})=>{new n(this,e).show(t)}):Z(async()=>{const{default:n}=await import("./tree_context_menu.js");return{default:n}},__vite__mapDeps([8,1,2,3,4,5,6,7,9,10,11,12]),import.meta.url).then(({default:n})=>{new n(this,e).show(t)})}prepareRootNode(){const t=Mt.getBranch("none_root");return t&&this.prepareNode(t)}prepareChildren(t){ct.assertArguments(t);const e=[],i=this.hideArchivedNotes;let n=t.getFilteredChildBranches();t.type==="search"&&n.length>va&&(n=n.slice(0,va));for(const s of n){if(i&&s.getNoteFromCache().hasLabel("archived"))continue;const a=this.prepareNode(s);a&&e.push(a)}return e}async updateNode(t){const e=Mt.getNoteFromCache(t.data.noteId),i=Mt.getBranch(t.data.branchId);if(e){if(!i){console.log(`Node update not possible because branch '${t.data.branchId}' was not found.`);return}}else{console.log(`Node update not possible because note '${t.data.noteId}' was not found.`);return}const n=`${i.prefix?`${i.prefix} - `:""}${e.title}`;t.data.isProtected=e.isProtected,t.data.noteType=e.type,t.folder=e.isFolder(),t.icon=e.getIcon(),t.extraClasses=this.getExtraClasses(e),t.title=ct.escapeHtml(n),t.isExpanded()!==i.isExpanded&&await t.setExpanded(i.isExpanded,{noEvents:!0,noAnimation:!0}),t.renderTitle()}prepareNode(t,e=!1){const i=t.getNoteFromCache();if(!i)return console.warn(`Branch '${t.branchId}' has no child note '${t.noteId}'`),null;const n=`${t.prefix?`${t.prefix} - `:""}${i.title}`,s=i.isFolder(),a={noteId:i.noteId,parentNoteId:t.parentNoteId,branchId:t.branchId,isProtected:i.isProtected,noteType:i.type,title:ct.escapeHtml(n),extraClasses:this.getExtraClasses(i),icon:i.getIcon(),refKey:i.noteId,lazy:!0,folder:s,expanded:t.isExpanded&&i.type!=="search",key:ct.randomString(12)};return s&&a.expanded&&!e&&(a.children=this.prepareChildren(i)),a}getExtraClasses(t){ct.assertArguments(t);const e=[];t.isProtected&&e.push("protected"),t.isShared()&&e.push("shared"),t.getParentNoteIds().length>1&&t.getParentNoteIds().map(a=>Mt.notes[a]).filter(a=>!!a).filter(a=>!["_share","_lbBookmarks"].includes(a.noteId)&&a.type!=="search").length>1&&e.push("multiple-parents");const i=t.getCssClass();i&&e.push(i),e.push(ct.getNoteTypeClass(t.type)),t.mime&&e.push(ct.getMimeTypeClass(t.mime)),t.hasLabel("archived")&&e.push("archived");const n=t.getColorClass();return n&&e.push(n),e.join(" ")}getSelectedNodes(t=!1){return this.tree.getSelectedNodes(t)}getSelectedOrActiveNodes(t=null){const e=this.getSelectedNodes(!0);return t&&!e.find(i=>i.key===t.key)&&e.push(t),e.length===0&&e.push(this.getActiveNode()),e.filter(i=>li.getHoistedNoteId()!=="root"||i.data.noteId!=="_hidden")}async setExpandedStatusForSubtree(t,e){if(!t){const n=li.getHoistedNoteId();t=this.getNodesByNoteId(n)[0]}const{branchIds:i}=await pt.put(`branches/${t.data.branchId}/expanded-subtree/${e?1:0}`);Mt.getBranches(i,!0).forEach(n=>n.isExpanded=!!e),await this.batchUpdate(async()=>{await t.load(!0),t.data.noteId!==li.getHoistedNoteId()&&await t.setExpanded(e,{noEvents:!0,noAnimation:!0})}),await this.filterHoistedBranch(!0)}async expandTree(t=null){await this.setExpandedStatusForSubtree(t,!0)}async collapseTree(t=null){await this.setExpandedStatusForSubtree(t,!1)}collapseTreeEvent(){this.collapseTree()}getActiveNode(){return this.tree.getActiveNode()}getFocusedNode(){return this.tree.getFocusNode()}clearSelectedNodes(){for(const t of this.getSelectedNodes())t.setSelected(!1)}async scrollToActiveNoteEvent(){const t=Pt.tabManager.getActiveContext();if(t&&t.notePath){this.tree.$container.focus(),this.tree.setFocus(!0);const e=await this.expandToNote(t.notePath);e&&(await e.makeVisible({scrollIntoView:!0}),e.setActive(!0,{noEvents:!0,noFocus:!1}))}}async focusTreeEvent(){this.tree.$container.focus(),this.tree.setFocus(!0)}async getNodeFromPath(t,e=!1,i=!0){ct.assertArguments(t);let n=this.getNodesByNoteId("root")[0],s=await fe.resolveNotePathToSegments(t,this.hoistedNoteId,i);if(!s){i&&logError("Could not find run path for notePath:",t);return}s=s.slice(1);for(const a of s)if(n){if(n.isLoaded()||await n.load(),e){n.isExpanded()||await n.setExpanded(!0,{noAnimation:!0});const c=Mt.getBranch(n.data.branchId);c&&(c.isExpanded=!0)}await this.updateNode(n);let l=this.findChildNode(n,a);if(!l&&(await n.load(!0),l=this.findChildNode(n,a),!l)){if(i){const c=await Mt.getNote(a);(!c||c.type!=="image")&&yi.logError(`Can't find node for child node of noteId=${a} for parent of noteId=${n.data.noteId} and hoistedNoteId=${li.getHoistedNoteId()}, requested path is ${t}`)}return}n=l}return n}findChildNode(t,e){return t.getChildren().find(i=>i.data.noteId===e)}async expandToNote(t,e=!0){return this.getNodeFromPath(t,!0,e)}getNodesByBranch(t){return ct.assertArguments(t),t.noteId?this.getNodesByNoteId(t.noteId).filter(e=>e.data.branchId===t.branchId):[]}getNodesByNoteId(t){ct.assertArguments(t);const e=this.tree.getNodesByRef(t);return e||[]}isEnabled(){return!!this.noteContext}async refresh(){this.toggleInt(this.isEnabled()),this.$treeSettingsPopup.hide(),this.activityDetected();const t=this.getActiveNode(),e=this.noteContext?.notePath&&(!fe.isNotePathInHiddenSubtree(this.noteContext.notePath)||await li.isHoistedInHiddenSubtree())&&await this.getNodeFromPath(this.noteContext.notePath);if(e!==t){let i=!1;t&&(i=t.hasFocus(),t.setActive(!1),t.setFocus(!1)),e&&(!e.isVisible()&&this.noteContext?.notePath&&await this.expandToNote(this.noteContext.notePath),e.setActive(!0,{noEvents:!0,noFocus:!i}),e.makeVisible({scrollIntoView:!0}))}this.filterHoistedBranch(!1)}async refreshSearch(t){const e=$.ui.fancytree.getNode(t);e.load(!0),e.setExpanded(!0,{noAnimation:!0}),ft.showMessage(m("note_tree.saved-search-note-refreshed"))}async batchUpdate(t){try{this.tree.enableUpdate(!1),await t()}finally{this.tree.enableUpdate(!0)}}activityDetected(){this.autoCollapseTimeoutId&&clearTimeout(this.autoCollapseTimeoutId),this.autoCollapseTimeoutId=setTimeout(()=>{if(!this.autoCollapseNoteTree)return;const t=new Set(Pt.tabManager.getNoteContexts().map(i=>i.notePathArray).flat());let e=!0;Qt.is("databaseReadonly")||this.tree.getRootNode().visit(i=>{i.isExpanded()&&!t.has(i.data.noteId)&&(i.setExpanded(!1),e&&(ft.showMessage(m("note_tree.auto-collapsing-notes-after-inactivity")),e=!1))},!1),this.filterHoistedBranch(!0)},600*1e3)}async entitiesReloadedEvent({loadResults:t}){if(this.activityDetected(),t.isEmptyForTree())return;const e=this.getActiveNode(),i=e?.hasFocus(),n=e?fe.getNotePath(e):null,s={noteIdsToUpdate:new Set,noteIdsToReload:new Set};this.#t(t.getAttributeRows(),s);const a=t.getBranchRows(),{movedActiveNode:l,parentsOfAddedNodes:c}=await this.#i(a,s);for(const u of t.getNoteIds())s.noteIdsToUpdate.add(u);await this.#e(s,t),await this.#o(n,i,l,c),(s.noteIdsToReload.size>0||s.noteIdsToUpdate.size>0)&&this.filterHoistedBranch(!0)}#t(t,e){for(const i of t){const n=["iconClass","cssClass","workspace","workspaceIconClass","color"];if(i.type==="label"&&n.includes(i.name??"")&&i.noteId)i.isInheritable?e.noteIdsToReload.add(i.noteId):e.noteIdsToUpdate.add(i.noteId);else if(i.type==="label"&&i.name==="archived"&&i.noteId){const s=Mt.getNoteFromCache(i.noteId);if(s)for(const a of s.getParentNotes())e.noteIdsToReload.add(a.noteId)}else if(i.type==="relation"&&(i.name==="template"||i.name==="inherit")&&i.noteId)e.noteIdsToReload.add(i.noteId);else if(i.type==="relation"&&i.name==="imageLink"&&i.noteId){const s=Mt.getNoteFromCache(i.noteId);s&&s.getChildNoteIds().includes(i.value??"")&&e.noteIdsToReload.add(i.noteId)}}}async#i(t,e){const i=t.every(a=>!!a.isDeleted);let n=null,s=[];for(const a of t)if(a.noteId&&(a.parentNoteId==="_share"?e.noteIdsToReload.add(a.noteId):e.noteIdsToUpdate.add(a.noteId)),a.isDeleted)for(const l of this.getNodesByBranch(a)){if(l.isActive())if(i){const c=l.getNextSibling()||l.getPrevSibling()||l.getParent();c&&c.setActive(!0,{noEvents:!0,noFocus:!0})}else n=l;l.getParent()&&l.remove(),a.parentNoteId&&e.noteIdsToUpdate.add(a.parentNoteId)}else if(a.parentNoteId)for(const l of this.getNodesByNoteId(a.parentNoteId)){if(s.push(l),!a.noteId||l.isFolder()&&!l.isLoaded())continue;const c=await Mt.getNote(a.noteId),u=a.branchId?Mt.getBranch(a.branchId):null,p=(l.getChildren()||[]).find(v=>v.data.noteId===a.noteId);if(p)a.isExpanded!==p.isExpanded()&&u&&e.noteIdsToReload.add(u.noteId);else if(u){const v=this.prepareNode(u,!0);v&&l.addChildren([v]),u?.isExpanded&&c&&c.hasChildren()&&e.noteIdsToReload.add(u.noteId),this.sortChildren(l),a.parentNoteId&&e.noteIdsToUpdate.add(a.parentNoteId)}}return{movedActiveNode:n,parentsOfAddedNodes:s}}async#e(t,e){await this.batchUpdate(async()=>{for(const i of t.noteIdsToReload)for(const n of this.getNodesByNoteId(i))await n.load(!0),t.noteIdsToUpdate.add(i);for(const i of e.getNoteReorderings())for(const n of this.getNodesByNoteId(i))n.isLoaded()&&this.sortChildren(n)});for(const i of t.noteIdsToUpdate)for(const n of this.getNodesByNoteId(i))await this.updateNode(n)}async#o(t,e,i,n){if(i)for(const a of n){const l=(a.getChildren()||[]).find(c=>c.data.noteId===i.data.noteId);if(l){t=fe.getNotePath(l);break}}if(!t)return;let s=await this.expandToNote(t,!1);if(s&&s.data.noteId!==fe.getNoteIdFromUrl(t)){const a=fe.getNoteIdFromUrl(t);if(a){const l=this.getNodesByNoteId(a);s=l.length===1?l[0]:null}}s&&(e&&this.tree.$container.focus(),await s.setActive(!0,{noEvents:!0,noFocus:!e}))}sortChildren(t){t.sortChildren((e,i)=>{const n=Mt.branches[e.data.branchId],s=Mt.branches[i.data.branchId];return!n||!s?0:n.notePosition-s.notePosition})}setExpanded(t,e){ct.assertArguments(t);const i=Mt.getBranch(t,!0);if(!i){if(t&&t.startsWith("virt"))return;logError(`Cannot find branch=${t}`);return}i.isExpanded=e,pt.put(`branches/${t}/expanded/${e?1:0}`)}async reloadTreeFromCache(){const t=this.getActiveNode(),e=t!==null?fe.getNotePath(t):null,i=this.prepareRootNode();if(await this.batchUpdate(async()=>{await this.tree.reload([i])}),await this.filterHoistedBranch(!0),e){const n=await this.getNodeFromPath(e,!0);n&&await n.setActive(!0,{noEvents:!0,noFocus:!0})}}async hoistedNoteChangedEvent({ntxId:t}){this.isNoteContext(t)&&await this.filterHoistedBranch(!0)}async filterHoistedBranch(t=!1){if(!this.noteContext)return;const e=await fe.resolveNotePath(this.noteContext.hoistedNoteId);if(!(!t&&this.lastFilteredHoistedNotePath===e))if(this.lastFilteredHoistedNotePath=e,e&&await this.getNodeFromPath(e),this.noteContext.hoistedNoteId==="root")this.tree.clearFilter(),this.toggleHiddenNode(!1);else{this.tree.filterBranches(n=>n.data.noteId===this.noteContext?.hoistedNoteId&&fe.getNotePath(n)===e),this.toggleHiddenNode(!0);const i=this.getActiveNode();i.data.noteId===this.noteContext.hoistedNoteId&&this.setExpanded(i.data.branchId,!0)}}toggleHiddenNode(t){const e=this.getNodesByNoteId("_hidden")[0];$(e.li).toggleClass("hidden-node-is-hidden",!t)}async frocaReloadedEvent(){this.reloadTreeFromCache()}async getHotKeys(){const t=await qo.getActionsForScope("note-tree"),e={};for(const i of t)for(const n of i.effectiveShortcuts)e[Bi.normalizeShortcut(n)]=s=>{const a=fe.getNotePath(s);return this.triggerCommand(i.actionName,{node:s,notePath:a}),!1};return e}getSelectedOrActiveBranchIds(t){return this.getSelectedOrActiveNodes(t).map(i=>i.data.branchId)}getSelectedOrActiveNoteIds(t){return this.getSelectedOrActiveNodes(t).map(i=>i.data.noteId)}async deleteNotesCommand({node:t}){const e=this.getSelectedOrActiveBranchIds(t).filter(i=>!i.startsWith("virt-"));e.length&&(await ri.deleteNotes(e),this.clearSelectedNodes())}canBeMovedUpOrDown(t){return t.data.noteId==="root"?!1:!Mt.getNoteFromCache(t.getParent().data.noteId)?.hasLabel("sorted")}moveNoteUpCommand({node:t}){if(!t||!this.canBeMovedUpOrDown(t))return;const e=t.getPrevSibling();e!==null&&ri.moveBeforeBranch([t.data.branchId],e.data.branchId)}moveNoteDownCommand({node:t}){if(!this.canBeMovedUpOrDown(t))return;const e=t.getNextSibling();e!==null&&ri.moveAfterBranch([t.data.branchId],e.data.branchId)}moveNoteUpInHierarchyCommand({node:t}){ri.moveNodeUpInHierarchy(t)}moveNoteDownInHierarchyCommand({node:t}){const e=t.getPrevSibling();e!==null&&ri.moveToParentNote([t.data.branchId],e.data.branchId)}addNoteAboveToSelectionCommand(){const t=this.getFocusedNode();if(!t)return;t.isActive()&&t.setSelected(!0);const e=t.getPrevSibling();e&&(e.setActive(!0,{noEvents:!0}),e.isSelected()&&t.setSelected(!1),e.setSelected(!0))}addNoteBelowToSelectionCommand(){const t=this.getFocusedNode();if(!t)return;t.isActive()&&t.setSelected(!0);const e=t.getNextSibling();e&&(e.setActive(!0,{noEvents:!0}),e.isSelected()&&t.setSelected(!1),e.setSelected(!0))}expandSubtreeCommand({node:t}){this.expandTree(t)}collapseSubtreeCommand({node:t}){this.collapseTree(t)}async recentChangesInSubtreeCommand({node:t}){this.triggerCommand("showRecentChanges",{ancestorNoteId:t.data.noteId})}selectAllNotesInParentCommand({node:t}){for(const e of t.getParent().getChildren())e.setSelected(!0)}copyNotesToClipboardCommand({node:t}){ga.copy(this.getSelectedOrActiveBranchIds(t))}cutNotesToClipboardCommand({node:t}){ga.cut(this.getSelectedOrActiveBranchIds(t))}pasteNotesFromClipboardCommand({node:t}){ga.pasteInto(t.data.branchId)}pasteNotesAfterFromClipboardCommand({node:t}){ga.pasteAfter(t.data.branchId)}async exportNoteCommand({node:t}){const e=fe.getNotePath(t);this.triggerCommand("showExportDialog",{notePath:e,defaultType:"subtree"})}async importIntoNoteCommand({node:t}){this.triggerCommand("showImportDialog",{noteId:t.data.noteId})}editNoteTitleCommand(){Pt.triggerCommand("focusOnTitle")}protectSubtreeCommand({node:t}){ll.protectNote(t.data.noteId,!0,!0)}unprotectSubtreeCommand({node:t}){ll.protectNote(t.data.noteId,!1,!0)}duplicateSubtreeCommand({node:t}){const e=this.getSelectedOrActiveNodes(t);for(const i of e){if(Mt.getNoteFromCache(i.data.noteId).isProtected&&!Mi.isProtectedSessionAvailable())continue;const s=Mt.getBranch(i.data.branchId);s?.parentNoteId&&yr.duplicateSubtree(i.data.noteId,s.parentNoteId)}}moveLauncherToVisibleCommand({selectedOrActiveBranchIds:t}){this.#n(t,"_lbVisibleLaunchers","_lbMobileVisibleLaunchers")}moveLauncherToAvailableCommand({selectedOrActiveBranchIds:t}){this.#n(t,"_lbAvailableLaunchers","_lbMobileAvailableLaunchers")}#n(t,e,i){const n=t.filter(a=>!a.startsWith("_lbMobile"));n&&ri.moveToParentNote(n,"_lbRoot_"+e);const s=t.filter(a=>a.startsWith("_lbMobile"));s&&ri.moveToParentNote(s,"_lbMobileRoot_"+i)}addNoteLauncherCommand({node:t}){this.createLauncherNote(t,"note")}addScriptLauncherCommand({node:t}){this.createLauncherNote(t,"script")}addWidgetLauncherCommand({node:t}){this.createLauncherNote(t,"customWidget")}addSpacerLauncherCommand({node:t}){this.createLauncherNote(t,"spacer")}async createLauncherNote(t,e){const i=await pt.post(`special-notes/launchers/${t.data.noteId}/${e}`);i.success||ft.showError(i.message),await yi.waitForMaxKnownEntityChangeId(),Pt.tabManager.getActiveContext()?.setNote(i.note.noteId)}buildTouchBarCommand({TouchBar:t,buildIcon:e}){const i=s=>{const a=this.getActiveNode(),l=fe.getNotePath(a);this.triggerCommand(s,{node:a,notePath:l,noteId:a.data.noteId,selectedOrActiveBranchIds:this.getSelectedOrActiveBranchIds(a),selectedOrActiveNoteIds:this.getSelectedOrActiveNoteIds(a)})};return[new t.TouchBarButton({icon:e("NSImageNameTouchBarAddTemplate"),click:()=>{const s=this.getActiveNode(),a=fe.getNotePath(s);yr.createNote(a,{isProtected:s.data.isProtected})}}),new t.TouchBarButton({icon:e("NSImageNameTouchBarDeleteTemplate"),click:()=>i("deleteNotes")})]}}const hw=`
|
||
<div class="note-title-widget">
|
||
<style>
|
||
.note-title-widget {
|
||
flex-grow: 1000;
|
||
height: 100%;
|
||
}
|
||
|
||
.note-title-widget input.note-title {
|
||
font-size: 110%;
|
||
border: 0;
|
||
margin: 2px 0px;
|
||
min-width: 5em;
|
||
width: 100%;
|
||
}
|
||
|
||
body.mobile .note-title-widget input.note-title {
|
||
padding: 0;
|
||
}
|
||
|
||
body.desktop .note-title-widget input.note-title {
|
||
font-size: 180%;
|
||
}
|
||
|
||
.note-title-widget input.note-title.protected {
|
||
text-shadow: 4px 4px 4px var(--muted-text-color);
|
||
}
|
||
</style>
|
||
|
||
<input autocomplete="off" value="" placeholder="${m("note_title.placeholder")}" class="note-title" tabindex="100">
|
||
</div>`;class AA extends hi{$noteTitle;deleteNoteOnEscape;spacedUpdate;constructor(){super(),this.spacedUpdate=new Hi(async()=>{const t=this.$noteTitle.val();this.note&&Mi.touchProtectedSessionIfNecessary(this.note),await pt.put(`notes/${this.noteId}/title`,{title:t},this.componentId)}),this.deleteNoteOnEscape=!1,Pt.addBeforeUnloadListener(this)}doRender(){this.$widget=$(hw),this.$noteTitle=this.$widget.find(".note-title"),this.$noteTitle.on("input",()=>this.spacedUpdate.scheduleUpdate()),this.$noteTitle.on("blur",()=>{this.spacedUpdate.updateNowIfNecessary(),this.deleteNoteOnEscape=!1}),Bi.bindElShortcut(this.$noteTitle,"esc",()=>{this.deleteNoteOnEscape&&this.noteContext?.isActive()&&this.noteContext?.note&&ri.deleteNotes(Object.values(this.noteContext.note.parentToBranch))}),Bi.bindElShortcut(this.$noteTitle,"return",()=>{this.triggerCommand("focusOnDetail",{ntxId:this.noteContext?.ntxId})})}async refreshWithNote(t){const e=t.isProtected&&!Mi.isProtectedSessionAvailable()||ct.isLaunchBarConfig(t.noteId)||this.noteContext?.viewScope?.viewMode!=="default";this.$noteTitle.val(e?await this.noteContext?.getNavigationTitle()||"":t.title),this.$noteTitle.prop("readonly",e),this.setProtectedStatus(t)}setProtectedStatus(t){this.$noteTitle.toggleClass("protected",!!t.isProtected)}async beforeNoteSwitchEvent({noteContext:t}){this.isNoteContext(t.ntxId)&&await this.spacedUpdate.updateNowIfNecessary()}async beforeNoteContextRemoveEvent({ntxIds:t}){this.isNoteContext(t)&&await this.spacedUpdate.updateNowIfNecessary()}focusOnTitleEvent(){this.noteContext&&this.noteContext.isActive()&&this.$noteTitle.trigger("focus")}focusAndSelectTitleEvent({isNewNote:t}={isNewNote:!1}){this.noteContext&&this.noteContext.isActive()&&(this.$noteTitle.trigger("focus").trigger("select"),this.deleteNoteOnEscape=t)}entitiesReloadedEvent({loadResults:t}){t.isNoteReloaded(this.noteId)&&this.note&&this.setProtectedStatus(this.note),t.isNoteReloaded(this.noteId,this.componentId)&&this.refresh()}beforeUnloadEvent(){return this.spacedUpdate.isAllSavedAndTriggerUpdate()}}function uw({$el:o,attributeType:t,open:e}){o.hasClass("aa-input")||(o.autocomplete({appendTo:document.querySelector("body"),hint:!1,openOnFocus:!0,minLength:0,tabAutocomplete:!1},[{displayKey:"name",cache:!1,source:async(i,n)=>{const s=typeof t=="function"?t():t,l=(await pt.get(`attribute-names/?type=${s}&query=${encodeURIComponent(i)}`)).map(c=>({name:c}));n(l)}}]),o.on("autocomplete:opened",()=>{o.attr("readonly")&&o.autocomplete("close")})),e&&o.autocomplete("open")}async function pw({$el:o,open:t,nameCallback:e}){o.hasClass("aa-input")&&o.autocomplete("destroy");let i="";if(e&&(i=e()),i.trim()==="")return;const n=(await pt.get(`attribute-values/${encodeURIComponent(i)}`)).map(s=>({value:s}));n.length!==0&&(o.autocomplete({appendTo:document.querySelector("body"),hint:!1,openOnFocus:!1,minLength:0,tabAutocomplete:!1},[{displayKey:"value",cache:!1,source:async function(s,a){s=s.toLowerCase();const l=n.filter(c=>c.value.toLowerCase().includes(s));a(l)}}]),o.on("autocomplete:opened",()=>{o.attr("readonly")&&o.autocomplete("close")}),t&&o.autocomplete("open"))}const fw={initAttributeNameAutocomplete:uw,initLabelValueAutocomplete:pw};class Ue extends hi{spacedUpdate;static getType(){}doRender(){return this.contentSized(),super.doRender()}doRefresh(t){}async refresh(){const t=this.constructor.getType(),e=await this.parent.getWidgetType();t!==e?(this.toggleInt(!1),this.cleanup()):(this.toggleInt(!0),t!=="empty"&&this.note?await this.doRefresh(this.note):t==="empty"&&await this.doRefresh(),this.triggerEvent("noteDetailRefreshed",{ntxId:this.noteContext?.ntxId}))}isActive(){return this.$widget.is(":visible")&&this.noteContext?.ntxId===Pt.tabManager.activeNtxId}getData(){}focus(){}scrollToEnd(){}dataSaved(){}async readOnlyTemporarilyDisabledEvent({noteContext:t}){this.isNoteContext(t.ntxId)&&(await this.refresh(),this.focus())}handleEventInChildren(t,e){return["activeContextChanged","setNoteContext"].includes(t)?super.handleEventInChildren("setNoteContext",e):t==="entitiesReloaded"||t==="refreshData"?super.handleEventInChildren(t,e):Promise.resolve()}}const mw=`
|
||
<div class="note-detail-empty note-detail-printable">
|
||
<style>
|
||
.workspace-notes {
|
||
display: flex;
|
||
flex-direction: row;
|
||
flex-wrap: wrap;
|
||
justify-content: space-evenly;
|
||
}
|
||
|
||
.workspace-notes .workspace-note {
|
||
width: 130px;
|
||
text-align: center;
|
||
margin: 10px;
|
||
border: 1px transparent solid;
|
||
}
|
||
|
||
.workspace-notes .workspace-note:hover {
|
||
cursor: pointer;
|
||
border: 1px solid var(--main-border-color);
|
||
}
|
||
|
||
.note-detail-empty-results .aa-dropdown-menu {
|
||
max-height: 50vh;
|
||
overflow: scroll;
|
||
border: var(--bs-border-width) solid var(--bs-border-color);
|
||
border-top: 0;
|
||
}
|
||
|
||
.empty-tab-search .note-autocomplete-input {
|
||
border-bottom-left-radius: 0;
|
||
}
|
||
|
||
.empty-tab-search .input-clearer-button {
|
||
border-bottom-right-radius: 0;
|
||
}
|
||
|
||
.workspace-icon {
|
||
text-align: center;
|
||
font-size: 500%;
|
||
}
|
||
</style>
|
||
|
||
<div class="workspace-notes"></div>
|
||
<div class="form-group empty-tab-search">
|
||
<label>${m("empty.open_note_instruction")}</label>
|
||
<div class="input-group mt-1">
|
||
<input class="form-control note-autocomplete" placeholder="${m("empty.search_placeholder")}">
|
||
</div>
|
||
</div>
|
||
<div class="note-detail-empty-results"></div>
|
||
</div>`;class gw extends Ue{$autoComplete;$results;$workspaceNotes;static getType(){return"empty"}doRender(){this.$widget=$(mw),this.$autoComplete=this.$widget.find(".note-autocomplete"),this.$results=this.$widget.find(".note-detail-empty-results"),Xe.initNoteAutocomplete(this.$autoComplete,{hideGoToSelectedNoteButton:!0,allowCreatingNotes:!0,allowJumpToSearchNotes:!0,container:this.$results[0]}).on("autocomplete:noteselected",function(t,e,i){if(!e.notePath)return!1;const n=Pt.tabManager.getActiveContext();n&&n.setNote(e.notePath)}),this.$workspaceNotes=this.$widget.find(".workspace-notes"),Xe.showRecentNotes(this.$autoComplete),super.doRender()}async doRefresh(){const t=await Of.searchForNotes("#workspace #!template");this.$workspaceNotes.empty();for(const e of t)this.$workspaceNotes.append($('<div class="workspace-note">').append($("<div>").addClass(`${e.getIcon()} workspace-icon`)).append($("<div>").text(e.title)).attr("title",m("empty.enter_workspace",{title:e.title})).on("click",()=>this.triggerCommand("hoistNote",{noteId:e.noteId})));this.$autoComplete.trigger("focus").trigger("select")}}class Hf extends Ue{doRender(){super.doRender(),this.refreshCodeBlockOptions()}setupImageOpening(t){this.$widget.on("dblclick","img",e=>this.openImageInCurrentTab($(e.target))),this.$widget.on("click","img",e=>{e.stopPropagation();const i=e.which===1,n=e.which===2,s=ct.isCtrlKey(e),a=i&&s&&e.shiftKey||n&&e.shiftKey;i&&s||n?this.openImageInNewTab($(e.target),a):i&&t&&this.openImageInCurrentTab($(e.target))})}async openImageInCurrentTab(t){const e=await this.parseFromImage(t);e?Pt.tabManager.getActiveContext()?.setNote(e.noteId,{viewScope:e.viewScope}):window.open(t.prop("src"),"_blank")}async openImageInNewTab(t,e=!1){const i=await this.parseFromImage(t);i?Pt.tabManager.openTabWithNoteWithHoisting(i.noteId,{activate:e,viewScope:i.viewScope}):window.open(t.prop("src"),"_blank")}async parseFromImage(t){const e=t.prop("src"),i=e.match(/\/api\/images\/([A-Za-z0-9_]+)\//);if(i)return{noteId:i[1],viewScope:{}};const n=e.match(/\/api\/attachments\/([A-Za-z0-9_]+)\/image\//);if(n){const s=n[1];return{noteId:(await Mt.getAttachment(s))?.ownerId,viewScope:{viewMode:"attachments",attachmentId:s}}}return null}async loadIncludedNote(t,e){const i=await Mt.getNote(t);if(i){const n=$('<div class="include-note-wrapper">'),s=await Pe.createLink(i.noteId,{showTooltip:!1});n.empty().append($('<h4 class="include-note-title">').append(s));const{$renderedContent:a,type:l}=await Jd.getRenderedContent(i);n.append($(`<div class="include-note-content type-${l}">`).append(a)),e.empty().append(n)}}async loadReferenceLinkTitle(t,e=null){await Pe.loadReferenceLinkTitle(t,e)}refreshIncludedNote(t,e){t&&t.find(`section[data-note-id="${e}"]`).each((i,n)=>{this.loadIncludedNote(e,$(n))})}refreshCodeBlockOptions(){const t=Qt.is("codeBlockWordWrap");this.$widget.toggleClass("word-wrap",t)}async entitiesReloadedEvent({loadResults:t}){t.isOptionReloaded("codeBlockWordWrap")&&this.refreshCodeBlockOptions(),t.getAttributeRows().find(e=>e.type==="label"&&e.name==="language"&&Be.isAffecting(e,this.note))&&await this.onLanguageChanged()}async onLanguageChanged(){}}const Iu=""+new URL("emoji-ko.json",import.meta.url).href,Vf={label:"글자 서식",icon:"text"};function vw(){return{image:{styles:{options:["inline","alignBlockLeft","alignCenter","alignBlockRight","alignLeft","alignRight","side"]},resizeOptions:[{name:"imageResize:original",value:null,icon:"original"},{name:"imageResize:25",value:"25",icon:"small"},{name:"imageResize:50",value:"50",icon:"medium"},{name:"imageResize:75",value:"75",icon:"medium"}],toolbar:["imageStyle:inline","imageStyle:alignCenter",{name:"imageStyle:wrapText",title:"Wrap text",items:["imageStyle:alignLeft","imageStyle:alignRight"],defaultItem:"imageStyle:alignRight"},{name:"imageStyle:block",title:"블록 정렬",items:["imageStyle:alignBlockLeft","imageStyle:alignBlockRight"],defaultItem:"imageStyle:alignBlockLeft"},"|","imageResize:25","imageResize:50","imageResize:original","|","toggleImageCaption"],upload:{types:["jpeg","png","gif","bmp","webp","tiff","svg","svg+xml","avif"]}},heading:{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading2",view:"h2",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h3",title:"Heading 3",class:"ck-heading_heading3"},{model:"heading4",view:"h4",title:"Heading 4",class:"ck-heading_heading4"},{model:"heading5",view:"h5",title:"Heading 5",class:"ck-heading_heading5"},{model:"heading6",view:"h6",title:"Heading 6",class:"ck-heading_heading6"}]},table:{contentToolbar:["tableColumn","tableRow","mergeTableCells","tableProperties","tableCellProperties","toggleTableCaption"]},list:{properties:{styles:!0,startIndex:!0,reversed:!0}},alignment:{options:["left","right","center","justify"]},link:{defaultProtocol:"https://",allowedProtocols:db},emoji:{definitionsUrl:window.glob.isDev?new URL(import.meta.url).origin+Iu:Iu},syntaxHighlighting:{loadHighlightJs:async()=>(await Nf(),await Z(()=>import("./marked.esm.js").then(o=>o.i),__vite__mapDeps([12,3,2,4,5]),import.meta.url)),mapLanguageName:sb,defaultMimeType:ob,enabled:nb()},clipboard:{copy:ib},language:"ko",translations:triliumKoreanEditorTranslations}}function yw(o){if(ct.isMobile())return bw();if(o){const t=ct.isDesktop()&&Qt.get("textNoteEditorMultilineToolbar")==="true";return Uf(t)}else return ww()}function bw(){const o=Uf(!1),t=[];for(const e of o.toolbar.items)if(typeof e=="object"&&"items"in e)for(const i of e.items)t.push(i);else t.push(e);return{...o,toolbar:{...o.toolbar,items:t}}}function Uf(o){return{toolbar:{items:["heading","fontSize","|","bold","italic",{...Vf,items:["underline","strikethrough","|","superscript","subscript","|","kbd"]},"|","fontColor","fontBackgroundColor","removeFormat","|","bulletedList","numberedList","todoList","|","blockQuote","admonition","insertTable","|","code","codeBlock","|","footnote",{label:"Insert",icon:"plus",items:["imageUpload","|","link","bookmark","internallink","includeNote","|","specialCharacters","emoji","math","mermaid","horizontalLine","pageBreak","dateTime"]},"|","alignment","outdent","indent","|","markdownImport","cuttonote","findAndReplace"],shouldNotGroupWhenFull:o}}}function ww(){return{toolbar:{items:["fontSize","bold","italic","underline",{...Vf,items:["strikethrough","|","superscript","subscript","|","kbd"]},"|","fontColor","fontBackgroundColor","|","code","link","bookmark","removeFormat","internallink","cuttonote"]},blockToolbar:["heading","|","bulletedList","numberedList","todoList","|","blockQuote","admonition","codeBlock","insertTable","footnote",{label:"Insert",icon:"plus",items:["link","bookmark","internallink","includeNote","|","math","mermaid","horizontalLine","pageBreak","dateTime"]},"|","alignment","outdent","indent","|","imageUpload","markdownImport","specialCharacters","emoji","findAndReplace"]}}const _w=!1,xw=[{marker:"@",feed:o=>Xe.autocompleteSourceForCKEditor(o),itemRenderer:o=>{const t=document.createElement("button");return t.innerHTML=`${o.highlightedNotePathTitle} `,t},minimumCharacters:0}],kw=`
|
||
<div class="note-detail-editable-text note-detail-printable">
|
||
<style>
|
||
.note-detail-editable-text {
|
||
font-family: var(--detail-font-family);
|
||
padding-left: 14px;
|
||
padding-top: 10px;
|
||
height: 100%;
|
||
}
|
||
|
||
/* Workaround for #1327 */
|
||
body.desktop.electron .note-detail-editable-text {
|
||
letter-spacing: -0.01px;
|
||
}
|
||
|
||
body.mobile .note-detail-editable-text {
|
||
padding-left: 4px;
|
||
}
|
||
|
||
.note-detail-editable-text a:hover {
|
||
cursor: pointer;
|
||
}
|
||
|
||
.note-detail-editable-text a[href^="http://"], .note-detail-editable-text a[href^="https://"] {
|
||
cursor: text !important;
|
||
}
|
||
|
||
.note-detail-editable-text *:not(figure, .include-note, hr):first-child {
|
||
margin-top: 0 !important;
|
||
}
|
||
|
||
.note-detail-editable-text h2 { font-size: 1.6em; }
|
||
.note-detail-editable-text h3 { font-size: 1.4em; }
|
||
.note-detail-editable-text h4 { font-size: 1.2em; }
|
||
.note-detail-editable-text h5 { font-size: 1.1em; }
|
||
.note-detail-editable-text h6 { font-size: 1.0em; }
|
||
|
||
body.heading-style-markdown .note-detail-editable-text h2::before { content: "##\\2004"; color: var(--muted-text-color); }
|
||
body.heading-style-markdown .note-detail-editable-text h3::before { content: "###\\2004"; color: var(--muted-text-color); }
|
||
body.heading-style-markdown .note-detail-editable-text h4:not(.include-note-title)::before { content: "####\\2004"; color: var(--muted-text-color); }
|
||
body.heading-style-markdown .note-detail-editable-text h5::before { content: "#####\\2004"; color: var(--muted-text-color); }
|
||
body.heading-style-markdown .note-detail-editable-text h6::before { content: "######\\2004"; color: var(--muted-text-color); }
|
||
|
||
body.heading-style-underline .note-detail-editable-text h2 { border-bottom: 1px solid var(--main-border-color); }
|
||
body.heading-style-underline .note-detail-editable-text h3 { border-bottom: 1px solid var(--main-border-color); }
|
||
body.heading-style-underline .note-detail-editable-text h4:not(.include-note-title) { border-bottom: 1px solid var(--main-border-color); }
|
||
body.heading-style-underline .note-detail-editable-text h5 { border-bottom: 1px solid var(--main-border-color); }
|
||
body.heading-style-underline .note-detail-editable-text h6 { border-bottom: 1px solid var(--main-border-color); }
|
||
|
||
.note-detail-editable-text-editor {
|
||
padding-top: 10px;
|
||
border: 0 !important;
|
||
box-shadow: none !important;
|
||
min-height: 50px;
|
||
height: 100%;
|
||
}
|
||
</style>
|
||
|
||
<div class="note-detail-editable-text-editor use-tn-links" tabindex="300"></div>
|
||
</div>
|
||
`;function Cw(){const o=al.getMimeTypes().filter(t=>t.enabled).map(t=>({language:Mf(t.mime),label:t.title}));return[{language:al.MIME_TYPE_AUTO,label:m("editable-text.auto-detect-language")},...o]}class $w extends Hf{contentLanguage;watchdog;$editor;static getType(){return"editableText"}doRender(){this.$widget=$(kw),this.$editor=this.$widget.find(".note-detail-editable-text-editor"),this.initialized=this.initEditor(),qo.setupActionsForElement("text-detail",this.$widget,this),this.setupImageOpening(!1),super.doRender()}async initEditor(){const t=ct.isMobile()||Qt.get("textNoteEditorType")==="ckeditor-classic",e=t?Yc:pu;this.$widget.show();const i={minimumNonErrorTimePeriod:5e3,crashNumberLimit:10,saveInterval:5e3};this.watchdog=t?new uu(Yc,i):new uu(pu,i),this.watchdog.on("stateChange",()=>{const n=this.watchdog.state;logInfo(`CKEditor state changed to ${n}`),["crashed","crashedPermanently"].includes(n)&&(logError(`CKEditor crash logs: ${JSON.stringify(this.watchdog.crashes,null,4)}`),n==="crashedPermanently"&&(Me.info("Editing component keeps crashing. Please try restarting Trilium. If problem persists, consider creating a bug report."),this.watchdog.editor?.enableReadOnlyMode("crashed-editor")))}),this.watchdog.setCreator(async(n,s)=>{logInfo("Creating new CKEditor");const a={...s,...vw(),...yw(t),htmlSupport:{allow:JSON.parse(Qt.get("allowedHtmlTags")),styles:!0,classes:!0,attributes:!0},licenseKey:"GPL"},l=this.note?.getLabelValue("language");l?(a.language={ui:typeof a.language=="string"?a.language:"ko",content:l},this.contentLanguage=l):this.contentLanguage=null;const c=await e.create(this.$editor[0],a);if(c.plugins.get("Notification").on("show:warning",(p,v)=>{const x=v.title,T=v.message.message;x&&T?ft.showErrorTitleAndMessage(v.title,v.message.message):x&&ft.showError(x||T),p.stop()}),t){let p;if(ct.isMobile()?p=$("body").find(".classic-toolbar-widget"):p=this.$widget.parents(".note-split.type-text").find("> .ribbon-container .classic-toolbar-widget"),p.empty(),p.length){const v=c.ui.view.toolbar;v.element&&p[0].appendChild(v.element)}if(ct.isMobile()){p.addClass("visible");const v=c.ui.view.toolbar;for(const x of v.items)"panelView"in x&&x.on("change:isOpen",()=>{!("isOpen"in x)||!x.isOpen||(x.panelView.position=x.panelView.position.replace("s","n"))})}}if(c.model.document.on("change:data",()=>this.spacedUpdate.scheduleUpdate()),glob.isDev,Sr)for(const p of["bold","italic","underline","paragraph","heading"])c.commands.get(p)?.on("change",()=>this.triggerCommand("refreshTouchBar"));return c}),await this.createEditor()}async createEditor(){await this.watchdog.create(this.$editor[0],{placeholder:m("editable_text.placeholder"),mention:{feeds:xw},codeBlock:{languages:Cw()},math:{engine:"katex",outputType:"span",lazyLoad:async()=>{window.katex=(await Z(async()=>{const{default:t}=await import("./math.js");return{default:t}},__vite__mapDeps([13,6,7]),import.meta.url)).default},forceOutputType:!1,enablePreview:!0},mermaid:{lazyLoad:async()=>(await Z(async()=>{const{default:t}=await import("./mermaid.core.js").then(e=>e.bh);return{default:t}},__vite__mapDeps([14,2,4,5,15,16,17,12,3]),import.meta.url)).default,config:Qd()}})}async doRefresh(t){const e=await t.getBlob();await this.spacedUpdate.allowUpdateWithoutChange(async()=>{const i=e?.content||"",n=this.note?.getLabelValue("language");this.contentLanguage!==n?await this.reinitialize(i):this.watchdog.editor?.setData(i)})}getData(){if(!this.watchdog.editor)return;const t=this.watchdog.editor?.getData()??"";return{content:ct.isHtmlEmpty(t)?"":t}}focus(){this.$editor.trigger("focus")}scrollToEnd(){this.watchdog?.editor?.model.change(t=>{const e=this.watchdog?.editor?.model.document.getRoot();e&&t.setSelection(t.createPositionAt(e,"end"))}),this.watchdog?.editor?.editing.view.focus()}show(){}getEditor(){return this.watchdog?.editor}cleanup(){this.watchdog?.editor&&this.spacedUpdate.allowUpdateWithoutChange(()=>{this.watchdog.editor?.setData("")})}insertDateTimeToTextCommand(){const t=new Date,e=Qt.get("customDateTimeFormat"),i=ct.formatDateTime(t,e);this.addTextToEditor(i)}async addLinkToEditor(t,e){await this.initialized,this.watchdog.editor?.model.change(i=>{const n=this.watchdog.editor?.model.document.selection.getFirstPosition();n&&i.insertText(e,{linkHref:t},n)})}async addTextToEditor(t){await this.initialized,this.watchdog.editor?.model.change(e=>{const i=this.watchdog.editor?.model.document.selection.getLastPosition();i&&e.insertText(t,i)})}addTextToActiveEditorEvent({text:t}){this.isActive()&&this.addTextToEditor(t)}async addLink(t,e,i=!1){await this.initialized,e?this.hasSelection()?this.watchdog.editor?.execute("link",i?`${t}`:`#${t}`):await this.addLinkToEditor(i?`${t}`:`#${t}`,e):this.watchdog.editor?.execute("referenceLink",{href:"#"+t}),this.watchdog.editor?.editing.view.focus()}hasSelection(){return!this.watchdog.editor?.model?.document.selection?.isCollapsed}async executeWithTextEditorEvent({callback:t,resolve:e,ntxId:i}){this.isNoteContext(i)&&(await this.initialized,this.watchdog.editor&&(t&&t(this.watchdog.editor),e(this.watchdog.editor)))}addLinkToTextCommand(){const t=this.getSelectedText();this.triggerCommand("showAddLinkDialog",{textTypeWidget:this,text:t})}getSelectedText(){const t=this.watchdog.editor?.model.document.selection.getFirstRange();let e="";if(!t)return e;for(const i of t.getItems())"data"in i&&i.data&&(e+=i.data);return e}async followLinkUnderCursorCommand(){await this.initialized;const t=this.watchdog.editor?.model.document.selection,e=t?.getSelectedElement();if(e?.name==="reference"){const s=e.getAttribute("notePath");if(s){await Pt.tabManager.getActiveContext()?.setNote(s);return}}if(!t?.hasAttribute("linkHref"))return;const i=t.getAttribute("linkHref"),n=Pe.getNotePathFromUrl(i);n?await Pt.tabManager.getActiveContext()?.setNote(n):window.open(i,"_blank")}addIncludeNoteToTextCommand(){this.triggerCommand("showIncludeNoteDialog",{textTypeWidget:this})}addIncludeNote(t,e){this.watchdog.editor?.model.change(i=>{this.watchdog.editor?.model.insertContent(i.createElement("includeNote",{noteId:t,boxSize:e}))})}async addImage(t){const e=await Mt.getNote(t);!e||!this.watchdog.editor||this.watchdog.editor.model.change(i=>{const n=encodeURIComponent(e.title),s=`api/images/${e.noteId}/${n}`;this.watchdog.editor?.execute("insertImage",{source:s})})}async createNoteForReferenceLink(t){if(!this.notePath)return;const e=await yr.createNoteWithTypePrompt(this.notePath,{activate:!1,title:t});if(!(!e||!e.note))return e.note.getBestNotePathString()}async refreshIncludedNoteEvent({noteId:t}){this.refreshIncludedNote(this.$editor,t)}async reinitialize(t){this.watchdog&&(this.watchdog.destroy(),await this.createEditor(),this.watchdog.editor?.setData(t))}async onLanguageChanged(){const t=this.watchdog.editor?.getData();await this.reinitialize(t??"")}buildTouchBarCommand(t){const{TouchBar:e,buildIcon:i}=t,{TouchBarSegmentedControl:n,TouchBarGroup:s,TouchBarButton:a}=e,{editor:l}=this.watchdog;if(!l)return;const c=(x,T)=>new a({icon:i(x),click:()=>l.execute(T),backgroundColor:hb(l.commands.get(T)?.value)});let u;const p=l.commands.get("heading");return l.commands.get("paragraph")?.value?u=0:p?.value==="heading2"?u=1:p?.value==="heading3"&&(u=2),[new n({segments:[{label:"P"},{label:"H2"},{label:"H3"}],change(x,T){switch(x){case 0:l.execute("paragraph");break;case 1:l.execute("heading",{value:"heading2"});break;case 2:l.execute("heading",{value:"heading3"});break}},selectedIndex:u}),new s({items:new e({items:[c("NSTouchBarTextBoldTemplate","bold"),c("NSTouchBarTextItalicTemplate","italic"),c("NSTouchBarTextUnderlineTemplate","underline")]})})]}}var Sw=Object.defineProperty,jf=o=>{throw TypeError(o)},Tw=(o,t,e)=>t in o?Sw(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,xi=(o,t,e)=>Tw(o,typeof t!="symbol"?t+"":t,e),Ew=(o,t,e)=>t.has(o)||jf("Cannot "+e),qf=(o,t,e)=>t.has(o)?jf("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(o):t.set(o,e),Ya=(o,t,e)=>(Ew(o,t,"access private method"),e);let Jc=[],Kf=[];(()=>{let o="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,e=0;t<o.length;t++)(t%2?Kf:Jc).push(e=e+o[t])})();function Iw(o){if(o<768)return!1;for(let t=0,e=Jc.length;;){let i=t+e>>1;if(o<Jc[i])e=i;else if(o>=Kf[i])t=i+1;else return!0;if(t==e)return!1}}function Au(o){return o>=127462&&o<=127487}const Lu=8205;function Aw(o,t,e=!0,i=!0){return(e?Zf:Lw)(o,t,i)}function Zf(o,t,e){if(t==o.length)return t;t&&Gf(o.charCodeAt(t))&&Yf(o.charCodeAt(t-1))&&t--;let i=_c(o,t);for(t+=Nu(i);t<o.length;){let n=_c(o,t);if(i==Lu||n==Lu||e&&Iw(n))t+=Nu(n),i=n;else if(Au(n)){let s=0,a=t-2;for(;a>=0&&Au(_c(o,a));)s++,a-=2;if(s%2==0)break;t+=2}else break}return t}function Lw(o,t,e){for(;t>0;){let i=Zf(o,t-2,e);if(i<t)return i;t--}return 0}function _c(o,t){let e=o.charCodeAt(t);if(!Yf(e)||t+1==o.length)return e;let i=o.charCodeAt(t+1);return Gf(i)?(e-55296<<10)+(i-56320)+65536:e}function Gf(o){return o>=56320&&o<57344}function Yf(o){return o>=55296&&o<56320}function Nu(o){return o<65536?1:2}let ye=class Jf{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=bs(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),Tn.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=bs(this,t,e);let i=[];return this.decompose(t,e,i,0),Tn.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new wr(this),s=new wr(t);for(let a=e,l=e;;){if(n.next(a),s.next(a),a=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(t=1){return new wr(this,t)}iterRange(t,e=this.length){return new Qf(this,t,e)}iterLines(t,e){let i;if(t==null)i=this.iter();else{e==null&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new Xf(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?Jf.empty:t.length<=32?new He(t):Tn.from(He.split(t,[]))}};class He extends ye{constructor(t,e=Nw(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let a=this.text[s],l=n+a.length;if((e?i:l)>=t)return new Mw(n,l,i,a);n=l+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new He(Mu(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(n&1){let a=i.pop(),l=Ja(s.text,a.text.slice(),0,s.length);if(l.length<=32)i.push(new He(l,a.length+s.length));else{let c=l.length>>1;i.push(new He(l.slice(0,c)),new He(l.slice(c)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof He))return super.replace(t,e,i);[t,e]=bs(this,t,e);let n=Ja(this.text,Ja(i.text,Mu(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new He(n,s):Tn.from(He.split(n,[]),s)}sliceString(t,e=this.length,i=`
|
||
`){[t,e]=bs(this,t,e);let n="";for(let s=0,a=0;s<=e&&a<this.text.length;a++){let l=this.text[a],c=s+l.length;s>t&&a&&(n+=i),t<c&&e>s&&(n+=l.slice(Math.max(0,t-s),e-s)),s=c+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,i.length==32&&(e.push(new He(i,n)),i=[],n=-1);return n>-1&&e.push(new He(i,n)),e}}class Tn extends ye{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let i of t)this.lines+=i.lines}lineInner(t,e,i,n){for(let s=0;;s++){let a=this.children[s],l=n+a.length,c=i+a.lines-1;if((e?c:l)>=t)return a.lineInner(t,e,i,n);n=l+1,i=c+1}}decompose(t,e,i,n){for(let s=0,a=0;a<=e&&s<this.children.length;s++){let l=this.children[s],c=a+l.length;if(t<=c&&e>=a){let u=n&((a<=t?1:0)|(c>=e?2:0));a>=t&&c<=e&&!u?i.push(l):l.decompose(t-a,e-a,i,u)}a=c+1}}replace(t,e,i){if([t,e]=bs(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let a=this.children[n],l=s+a.length;if(t>=s&&e<=l){let c=a.replace(t-s,e-s,i),u=this.lines-a.lines+c.lines;if(c.lines<u>>4&&c.lines>u>>6){let p=this.children.slice();return p[n]=c,new Tn(p,this.length-(e-t)+i.length)}return super.replace(s,l,c)}s=l+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i=`
|
||
`){[t,e]=bs(this,t,e);let n="";for(let s=0,a=0;s<this.children.length&&a<=e;s++){let l=this.children[s],c=a+l.length;a>t&&s&&(n+=i),t<c&&e>a&&(n+=l.sliceString(t-a,e-a,i)),a=c+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Tn))return 0;let i=0,[n,s,a,l]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==a||s==l)return i;let c=this.children[n],u=t.children[s];if(c!=u)return i+c.scanIdentical(u,e);i+=c.length+1}}static from(t,e=t.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let T of t)i+=T.lines;if(i<32){let T=[];for(let M of t)M.flatten(T);return new He(T,e)}let n=Math.max(32,i>>5),s=n<<1,a=n>>1,l=[],c=0,u=-1,p=[];function v(T){let M;if(T.lines>s&&T instanceof Tn)for(let P of T.children)v(P);else T.lines>a&&(c>a||!c)?(x(),l.push(T)):T instanceof He&&c&&(M=p[p.length-1])instanceof He&&T.lines+M.lines<=32?(c+=T.lines,u+=T.length+1,p[p.length-1]=new He(M.text.concat(T.text),M.length+1+T.length)):(c+T.lines>n&&x(),c+=T.lines,u+=T.length+1,p.push(T))}function x(){c!=0&&(l.push(p.length==1?p[0]:Tn.from(p,u)),u=-1,c=p.length=0)}for(let T of t)v(T);return x(),l.length==1?l[0]:new Tn(l,e)}}ye.empty=new He([""],0);function Nw(o){let t=-1;for(let e of o)t+=e.length+1;return t}function Ja(o,t,e=0,i=1e9){for(let n=0,s=0,a=!0;s<o.length&&n<=i;s++){let l=o[s],c=n+l.length;c>=e&&(c>i&&(l=l.slice(0,i-n)),n<e&&(l=l.slice(e-n)),a?(t[t.length-1]+=l,a=!1):t.push(l)),n=c+1}return t}function Mu(o,t,e){return Ja(o,[""],t,e)}class wr{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof He?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],a=s>>1,l=n instanceof He?n.text.length:n.children.length;if(a==(e>0?l:0)){if(i==0)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(e>0?0:1)){if(this.offsets[i]+=e,t==0)return this.lineBreak=!0,this.value=`
|
||
`,this;t--}else if(n instanceof He){let c=n.text[a+(e<0?-1:0)];if(this.offsets[i]+=e,c.length>Math.max(0,t))return this.value=t==0?c:e>0?c.slice(t):c.slice(0,c.length-t),this;t-=c.length}else{let c=n.children[a+(e<0?-1:0)];t>c.length?(t-=c.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(c),this.offsets.push(e>0?1:(c instanceof He?c.text.length:c.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class Qf{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new wr(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Xf{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(ye.prototype[Symbol.iterator]=function(){return this.iter()},wr.prototype[Symbol.iterator]=Qf.prototype[Symbol.iterator]=Xf.prototype[Symbol.iterator]=function(){return this});class Mw{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function bs(o,t,e){return t=Math.max(0,Math.min(o.length,t)),[t,Math.max(t,Math.min(o.length,e))]}function di(o,t,e=!0,i=!0){return Aw(o,t,e,i)}function Pw(o){return o>=56320&&o<57344}function Ow(o){return o>=55296&&o<56320}function tm(o,t){let e=o.charCodeAt(t);if(!Ow(e)||t+1==o.length)return e;let i=o.charCodeAt(t+1);return Pw(i)?(e-55296<<10)+(i-56320)+65536:e}function Dw(o){return o<=65535?String.fromCharCode(o):(o-=65536,String.fromCharCode((o>>10)+55296,(o&1023)+56320))}function em(o){return o<65536?1:2}const Qc=/\r\n?|\n/;var mi=function(o){return o[o.Simple=0]="Simple",o[o.TrackDel=1]="TrackDel",o[o.TrackBefore=2]="TrackBefore",o[o.TrackAfter=3]="TrackAfter",o}(mi||(mi={}));class Pn{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],a=this.sections[e++];a<0?(t(i,n,s),n+=s):n+=a,i+=s}}iterChangedRanges(t,e=!1){Xc(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new Pn(t)}composeDesc(t){return this.empty?t:t.empty?this:im(this,t)}mapDesc(t,e=!1){return t.empty?this:td(this,t,e)}mapPos(t,e=-1,i=mi.Simple){let n=0,s=0;for(let a=0;a<this.sections.length;){let l=this.sections[a++],c=this.sections[a++],u=n+l;if(c<0){if(u>t)return s+(t-n);s+=l}else{if(i!=mi.Simple&&u>=t&&(i==mi.TrackDel&&n<t&&u>t||i==mi.TrackBefore&&n<t||i==mi.TrackAfter&&u>t))return null;if(u>t||u==t&&e<0&&!l)return t==n||e<0?s:s+c;s+=c}n=u}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=this.sections[i++],a=this.sections[i++],l=n+s;if(a>=0&&n<=e&&l>=t)return n<t&&l>e?"cover":!0;n=l}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Pn(t)}static create(t){return new Pn(t)}}class Je extends Pn{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return Xc(this,(e,i,n,s,a)=>t=t.replace(n,n+(i-e),a),!1),t}mapDesc(t,e=!1){return td(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,s=0;n<e.length;n+=2){let a=e[n],l=e[n+1];if(l>=0){e[n]=l,e[n+1]=a;let c=n>>1;for(;i.length<c;)i.push(ye.empty);i.push(a?t.slice(s,s+a):ye.empty)}s+=a}return new Je(e,i)}compose(t){return this.empty?t:t.empty?this:im(this,t,!0)}map(t,e=!1){return t.empty?this:td(this,t,e,!0)}iterChanges(t,e=!1){Xc(this,t,e)}get desc(){return Pn.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new Tr(this);t:for(let a=0,l=0;;){let c=a==t.length?1e9:t[a++];for(;l<c||l==c&&s.len==0;){if(s.done)break t;let p=Math.min(s.len,c-l);fi(n,p,-1);let v=s.ins==-1?-1:s.off==0?s.ins:0;fi(e,p,v),v>0&&bo(i,e,s.text),s.forward(p),l+=p}let u=t[a++];for(;l<u;){if(s.done)break t;let p=Math.min(s.len,u-l);fi(e,p,-1),fi(n,p,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(p),l+=p}}return{changes:new Je(e,i),filtered:Pn.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):n==0?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],s=[],a=0,l=null;function c(p=!1){if(!p&&!n.length)return;a<e&&fi(n,e-a,-1);let v=new Je(n,s);l=l?l.compose(v.map(l)):v,n=[],s=[],a=0}function u(p){if(Array.isArray(p))for(let v of p)u(v);else if(p instanceof Je){if(p.length!=e)throw new RangeError(`Mismatched change set length (got ${p.length}, expected ${e})`);c(),l=l?l.compose(p.map(l)):p}else{let{from:v,to:x=v,insert:T}=p;if(v>x||v<0||x>e)throw new RangeError(`Invalid change range ${v} to ${x} (in doc of length ${e})`);let M=T?typeof T=="string"?ye.of(T.split(i||Qc)):T:ye.empty,P=M.length;if(v==x&&P==0)return;v<a&&c(),v>a&&fi(n,v-a,-1),fi(n,x-v,P),bo(s,n,M),a=x}}return u(t),c(!l),l}static empty(t){return new Je(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let s=t[n];if(typeof s=="number")e.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((a,l)=>l&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)e.push(s[0],0);else{for(;i.length<n;)i.push(ye.empty);i[n]=ye.of(s.slice(1)),e.push(s[0],i[n].length)}}}return new Je(e,i)}static createSet(t,e){return new Je(t,e)}}function fi(o,t,e,i=!1){if(t==0&&e<=0)return;let n=o.length-2;n>=0&&e<=0&&e==o[n+1]?o[n]+=t:n>=0&&t==0&&o[n]==0?o[n+1]+=e:i?(o[n]+=t,o[n+1]+=e):o.push(t,e)}function bo(o,t,e){if(e.length==0)return;let i=t.length-2>>1;if(i<o.length)o[o.length-1]=o[o.length-1].append(e);else{for(;o.length<i;)o.push(ye.empty);o.push(e)}}function Xc(o,t,e){let i=o.inserted;for(let n=0,s=0,a=0;a<o.sections.length;){let l=o.sections[a++],c=o.sections[a++];if(c<0)n+=l,s+=l;else{let u=n,p=s,v=ye.empty;for(;u+=l,p+=c,c&&i&&(v=v.append(i[a-2>>1])),!(e||a==o.sections.length||o.sections[a+1]<0);)l=o.sections[a++],c=o.sections[a++];t(n,u,s,p,v),n=u,s=p}}}function td(o,t,e,i=!1){let n=[],s=i?[]:null,a=new Tr(o),l=new Tr(t);for(let c=-1;;){if(a.done&&l.len||l.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&l.ins==-1){let u=Math.min(a.len,l.len);fi(n,u,-1),a.forward(u),l.forward(u)}else if(l.ins>=0&&(a.ins<0||c==a.i||a.off==0&&(l.len<a.len||l.len==a.len&&!e))){let u=l.len;for(fi(n,l.ins,-1);u;){let p=Math.min(a.len,u);a.ins>=0&&c<a.i&&a.len<=p&&(fi(n,0,a.ins),s&&bo(s,n,a.text),c=a.i),a.forward(p),u-=p}l.next()}else if(a.ins>=0){let u=0,p=a.len;for(;p;)if(l.ins==-1){let v=Math.min(p,l.len);u+=v,p-=v,l.forward(v)}else if(l.ins==0&&l.len<p)p-=l.len,l.next();else break;fi(n,u,c<a.i?a.ins:0),s&&c<a.i&&bo(s,n,a.text),c=a.i,a.forward(a.len-p)}else{if(a.done&&l.done)return s?Je.createSet(n,s):Pn.create(n);throw new Error("Mismatched change set lengths")}}}function im(o,t,e=!1){let i=[],n=e?[]:null,s=new Tr(o),a=new Tr(t);for(let l=!1;;){if(s.done&&a.done)return n?Je.createSet(i,n):Pn.create(i);if(s.ins==0)fi(i,s.len,0,l),s.next();else if(a.len==0&&!a.done)fi(i,0,a.ins,l),n&&bo(n,i,a.text),a.next();else{if(s.done||a.done)throw new Error("Mismatched change set lengths");{let c=Math.min(s.len2,a.len),u=i.length;if(s.ins==-1){let p=a.ins==-1?-1:a.off?0:a.ins;fi(i,c,p,l),n&&p&&bo(n,i,a.text)}else a.ins==-1?(fi(i,s.off?0:s.len,c,l),n&&bo(n,i,s.textBit(c))):(fi(i,s.off?0:s.len,a.off?0:a.ins,l),n&&!a.off&&bo(n,i,a.text));l=(s.ins>c||a.ins>=0&&a.len>c)&&(l||i.length>u),s.forward2(c),a.forward(c)}}}}class Tr{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[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:t}=this.set,e=this.i-2>>1;return e>=t.length?ye.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?ye.empty:e[i].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class zo{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}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 bidiLevel(){let t=this.flags&7;return t==7?null:t}get goalColumn(){let t=this.flags>>6;return t==16777215?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new zo(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return xt.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return xt.range(this.anchor,i)}eq(t,e=!1){return this.anchor==t.anchor&&this.head==t.head&&(!e||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return xt.range(t.anchor,t.head)}static create(t,e,i){return new zo(t,e,i)}}class xt{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:xt.create(this.ranges.map(i=>i.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new xt([this.main],0)}addRange(t,e=!0){return xt.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,xt.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new xt(t.ranges.map(e=>zo.fromJSON(e)),t.main)}static single(t,e=t){return new xt([xt.range(t,e)],0)}static create(t,e=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return xt.normalized(t.slice(),e);i=s.to}return new xt(t,e)}static cursor(t,e=0,i,n){return zo.create(t,t,(e==0?0:e<0?8:16)|(i==null?7:Math.min(6,i))|(n??16777215)<<6)}static range(t,e,i,n){let s=(i??16777215)<<6|(n==null?7:Math.min(6,n));return e<t?zo.create(e,t,48|s):zo.create(t,e,(e>t?8:0)|s)}static normalized(t,e=0){let i=t[e];t.sort((n,s)=>n.from-s.from),e=t.indexOf(i);for(let n=1;n<t.length;n++){let s=t[n],a=t[n-1];if(s.empty?s.from<=a.to:s.from<a.to){let l=a.from,c=Math.max(s.to,a.to);n<=e&&e--,t.splice(--n,2,s.anchor>s.head?xt.range(c,l):xt.range(l,c))}}return new xt(t,e)}}function nm(o,t){for(let e of o.ranges)if(e.to>t)throw new RangeError("Selection points outside of document")}let eh=0;class Ft{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=eh++,this.default=t([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(t={}){return new Ft(t.combine||(e=>e),t.compareInput||((e,i)=>e===i),t.compare||(t.combine?(e,i)=>e===i:ih),!!t.static,t.enables)}of(t){return new Qa([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Qa(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Qa(t,this,2,e)}from(t,e){return e||(e=i=>i),this.compute([t],i=>e(i.field(t)))}}function ih(o,t){return o==t||o.length==t.length&&o.every((e,i)=>e===t[i])}class Qa{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=eh++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,a=t[s]>>1,l=this.type==2,c=!1,u=!1,p=[];for(let v of this.dependencies)v=="doc"?c=!0:v=="selection"?u=!0:(((e=t[v.id])!==null&&e!==void 0?e:1)&1)==0&&p.push(t[v.id]);return{create(v){return v.values[a]=i(v),1},update(v,x){if(c&&x.docChanged||u&&(x.docChanged||x.selection)||ed(v,p)){let T=i(v);if(l?!Pu(T,v.values[a],n):!n(T,v.values[a]))return v.values[a]=T,1}return 0},reconfigure:(v,x)=>{let T,M=x.config.address[s];if(M!=null){let P=ul(x,M);if(this.dependencies.every(F=>F instanceof Ft?x.facet(F)===v.facet(F):F instanceof $i?x.field(F,!1)==v.field(F,!1):!0)||(l?Pu(T=i(v),P,n):n(T=i(v),P)))return v.values[a]=P,0}else T=i(v);return v.values[a]=T,1}}}}function Pu(o,t,e){if(o.length!=t.length)return!1;for(let i=0;i<o.length;i++)if(!e(o[i],t[i]))return!1;return!0}function ed(o,t){let e=!1;for(let i of t)_r(o,i)&1&&(e=!0);return e}function Rw(o,t,e){let i=e.map(c=>o[c.id]),n=e.map(c=>c.type),s=i.filter(c=>!(c&1)),a=o[t.id]>>1;function l(c){let u=[];for(let p=0;p<i.length;p++){let v=ul(c,i[p]);if(n[p]==2)for(let x of v)u.push(x);else u.push(v)}return t.combine(u)}return{create(c){for(let u of i)_r(c,u);return c.values[a]=l(c),1},update(c,u){if(!ed(c,s))return 0;let p=l(c);return t.compare(p,c.values[a])?0:(c.values[a]=p,1)},reconfigure(c,u){let p=ed(c,i),v=u.config.facets[t.id],x=u.facet(t);if(v&&!p&&ih(e,v))return c.values[a]=x,0;let T=l(c);return t.compare(T,x)?(c.values[a]=x,0):(c.values[a]=T,1)}}}const ba=Ft.define({static:!0});class $i{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new $i(eh++,t.create,t.update,t.compare||((i,n)=>i===n),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(ba).find(i=>i.field==this);return(e?.create||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:i=>(i.values[e]=this.create(i),1),update:(i,n)=>{let s=i.values[e],a=this.updateF(s,n);return this.compareF(s,a)?0:(i.values[e]=a,1)},reconfigure:(i,n)=>{let s=i.facet(ba),a=n.facet(ba),l;return(l=s.find(c=>c.field==this))&&l!=a.find(c=>c.field==this)?(i.values[e]=l.create(i),1):n.config.address[this.id]!=null?(i.values[e]=n.field(this),0):(i.values[e]=this.create(i),1)}}}init(t){return[this,ba.of({field:this,create:t})]}get extension(){return this}}const Ro={lowest:4,low:3,default:2,high:1,highest:0};function or(o){return t=>new om(t,o)}const Pl={highest:or(Ro.highest),high:or(Ro.high),default:or(Ro.default),low:or(Ro.low),lowest:or(Ro.lowest)};class om{constructor(t,e){this.inner=t,this.prec=e}}class Xn{of(t){return new id(this,t)}reconfigure(t){return Xn.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class id{constructor(t,e){this.compartment=t,this.inner=e}}class hl{constructor(t,e,i,n,s,a){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return e==null?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),a=new Map;for(let x of Bw(t,e,a))x instanceof $i?n.push(x):(s[x.facet.id]||(s[x.facet.id]=[])).push(x);let l=Object.create(null),c=[],u=[];for(let x of n)l[x.id]=u.length<<1,u.push(T=>x.slot(T));let p=i?.config.facets;for(let x in s){let T=s[x],M=T[0].facet,P=p&&p[x]||[];if(T.every(F=>F.type==0))if(l[M.id]=c.length<<1|1,ih(P,T))c.push(i.facet(M));else{let F=M.combine(T.map(R=>R.value));c.push(i&&M.compare(F,i.facet(M))?i.facet(M):F)}else{for(let F of T)F.type==0?(l[F.id]=c.length<<1|1,c.push(F.value)):(l[F.id]=u.length<<1,u.push(R=>F.dynamicSlot(R)));l[M.id]=u.length<<1,u.push(F=>Rw(F,M,T))}}let v=u.map(x=>x(l));return new hl(t,a,v,l,c,s)}}function Bw(o,t,e){let i=[[],[],[],[],[]],n=new Map;function s(a,l){let c=n.get(a);if(c!=null){if(c<=l)return;let u=i[c].indexOf(a);u>-1&&i[c].splice(u,1),a instanceof id&&e.delete(a.compartment)}if(n.set(a,l),Array.isArray(a))for(let u of a)s(u,l);else if(a instanceof id){if(e.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=t.get(a.compartment)||a.inner;e.set(a.compartment,u),s(u,l)}else if(a instanceof om)s(a.inner,a.prec);else if(a instanceof $i)i[l].push(a),a.provides&&s(a.provides,l);else if(a instanceof Qa)i[l].push(a),a.facet.extensions&&s(a.facet.extensions,Ro.default);else{let u=a.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(o,Ro.default),i.reduce((a,l)=>a.concat(l))}function _r(o,t){if(t&1)return 2;let e=t>>1,i=o.status[e];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;o.status[e]=4;let n=o.computeSlot(o,o.config.dynamicSlots[e]);return o.status[e]=2|n}function ul(o,t){return t&1?o.config.staticValues[t>>1]:o.values[t>>1]}const sm=Ft.define(),nd=Ft.define({combine:o=>o.some(t=>t),static:!0}),rm=Ft.define({combine:o=>o.length?o[0]:void 0,static:!0}),am=Ft.define(),lm=Ft.define(),cm=Ft.define(),dm=Ft.define({combine:o=>o.length?o[0]:!1});class To{constructor(t,e){this.type=t,this.value=e}static define(){return new zw}}class zw{of(t){return new To(this,t)}}class Fw{constructor(t){this.map=t}of(t){return new me(this,t)}}class me{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return e===void 0?void 0:e==this.value?this:new me(this.type,e)}is(t){return this.type==t}static define(t={}){return new Fw(t.map||(e=>e))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let s=n.map(e);s&&i.push(s)}return i}}me.reconfigure=me.define();me.appendConfig=me.define();class Qe{constructor(t,e,i,n,s,a){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=a,this._doc=null,this._state=null,i&&nm(i,e.newLength),s.some(l=>l.type==Qe.time)||(this.annotations=s.concat(Qe.time.of(Date.now())))}static create(t,e,i,n,s,a){return new Qe(t,e,i,n,s,a)}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(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(Qe.userEvent);return!!(e&&(e==t||e.length>t.length&&e.slice(0,t.length)==t&&e[t.length]=="."))}}Qe.time=To.define();Qe.userEvent=To.define();Qe.addToHistory=To.define();Qe.remote=To.define();function Ww(o,t){let e=[];for(let i=0,n=0;;){let s,a;if(i<o.length&&(n==t.length||t[n]>=o[i]))s=o[i++],a=o[i++];else if(n<t.length)s=t[n++],a=t[n++];else return e;!e.length||e[e.length-1]<s?e.push(s,a):e[e.length-1]<a&&(e[e.length-1]=a)}}function hm(o,t,e){var i;let n,s,a;return e?(n=t.changes,s=Je.empty(t.changes.length),a=o.changes.compose(t.changes)):(n=t.changes.map(o.changes),s=o.changes.mapDesc(t.changes,!0),a=o.changes.compose(n)),{changes:a,selection:t.selection?t.selection.map(s):(i=o.selection)===null||i===void 0?void 0:i.map(n),effects:me.mapEffects(o.effects,n).concat(me.mapEffects(t.effects,s)),annotations:o.annotations.length?o.annotations.concat(t.annotations):t.annotations,scrollIntoView:o.scrollIntoView||t.scrollIntoView}}function od(o,t,e){let i=t.selection,n=ms(t.annotations);return t.userEvent&&(n=n.concat(Qe.userEvent.of(t.userEvent))),{changes:t.changes instanceof Je?t.changes:Je.of(t.changes||[],e,o.facet(rm)),selection:i&&(i instanceof xt?i:xt.single(i.anchor,i.head)),effects:ms(t.effects),annotations:n,scrollIntoView:!!t.scrollIntoView}}function um(o,t,e){let i=od(o,t.length?t[0]:{},o.doc.length);t.length&&t[0].filter===!1&&(e=!1);for(let s=1;s<t.length;s++){t[s].filter===!1&&(e=!1);let a=!!t[s].sequential;i=hm(i,od(o,t[s],a?i.changes.newLength:o.doc.length),a)}let n=Qe.create(o,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Vw(e?Hw(n):n)}function Hw(o){let t=o.startState,e=!0;for(let n of t.facet(am)){let s=n(o);if(s===!1){e=!1;break}Array.isArray(s)&&(e=e===!0?s:Ww(e,s))}if(e!==!0){let n,s;if(e===!1)s=o.changes.invertedDesc,n=Je.empty(t.doc.length);else{let a=o.changes.filter(e);n=a.changes,s=a.filtered.mapDesc(a.changes).invertedDesc}o=Qe.create(t,n,o.selection&&o.selection.map(s),me.mapEffects(o.effects,s),o.annotations,o.scrollIntoView)}let i=t.facet(lm);for(let n=i.length-1;n>=0;n--){let s=i[n](o);s instanceof Qe?o=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Qe?o=s[0]:o=um(t,ms(s),!1)}return o}function Vw(o){let t=o.startState,e=t.facet(cm),i=o;for(let n=e.length-1;n>=0;n--){let s=e[n](o);s&&Object.keys(s).length&&(i=hm(i,od(t,s,o.changes.newLength),!0))}return i==o?o:Qe.create(t,o.changes,o.selection,i.effects,i.annotations,i.scrollIntoView)}const Uw=[];function ms(o){return o==null?Uw:Array.isArray(o)?o:[o]}var Ve=function(o){return o[o.Word=0]="Word",o[o.Space=1]="Space",o[o.Other=2]="Other",o}(Ve||(Ve={}));const jw=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let sd;try{sd=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function qw(o){if(sd)return sd.test(o);for(let t=0;t<o.length;t++){let e=o[t];if(/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||jw.test(e)))return!0}return!1}function Kw(o){return t=>{if(!/\S/.test(t))return Ve.Space;if(qw(t))return Ve.Word;for(let e=0;e<o.length;e++)if(t.indexOf(o[e])>-1)return Ve.Word;return Ve.Other}}class ve{constructor(t,e,i,n,s,a){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,a&&(a._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)_r(this,l<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(i==null){if(e)throw new RangeError("Field is not present in this state");return}return _r(this,i),ul(this,i)}update(...t){return um(this,t,!0)}applyTransaction(t){let e=this.config,{base:i,compartments:n}=e;for(let l of t.effects)l.is(Xn.reconfigure)?(e&&(n=new Map,e.compartments.forEach((c,u)=>n.set(u,c)),e=null),n.set(l.value.compartment,l.value.extension)):l.is(me.reconfigure)?(e=null,i=l.value):l.is(me.appendConfig)&&(e=null,i=ms(i).concat(l.value));let s;e?s=t.startState.values.slice():(e=hl.resolve(i,n,this),s=new ve(e,this.doc,this.selection,e.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let a=t.startState.facet(nd)?t.newSelection:t.newSelection.asSingle();new ve(e,t.newDoc,a,s,(l,c)=>c.update(l,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:xt.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],a=ms(i.effects);for(let l=1;l<e.ranges.length;l++){let c=t(e.ranges[l]),u=this.changes(c.changes),p=u.map(n);for(let x=0;x<l;x++)s[x]=s[x].map(p);let v=n.mapDesc(u,!0);s.push(c.range.map(v)),n=n.compose(p),a=me.mapEffects(a,p).concat(me.mapEffects(ms(c.effects),v))}return{changes:n,selection:xt.create(s,e.mainIndex),effects:a}}changes(t=[]){return t instanceof Je?t:Je.of(t,this.doc.length,this.facet(ve.lineSeparator))}toText(t){return ye.of(t.split(this.facet(ve.lineSeparator)||Qc))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return e==null?t.default:(_r(this,e),ul(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof $i&&this.config.address[n.id]!=null&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||typeof t.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(t,s)){let a=i[s],l=t[s];n.push(a.init(c=>a.spec.fromJSON(l,c)))}}return ve.create({doc:t.doc,selection:xt.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=hl.resolve(t.extensions||[],new Map),i=t.doc instanceof ye?t.doc:ye.of((t.doc||"").split(e.staticFacet(ve.lineSeparator)||Qc)),n=t.selection?t.selection instanceof xt?t.selection:xt.single(t.selection.anchor,t.selection.head):xt.single(0);return nm(n,i.length),e.staticFacet(nd)||(n=n.asSingle()),new ve(e,i,n,e.dynamicSlots.map(()=>null),(s,a)=>a.create(s),null)}get tabSize(){return this.facet(ve.tabSize)}get lineBreak(){return this.facet(ve.lineSeparator)||`
|
||
`}get readOnly(){return this.facet(dm)}phrase(t,...e){for(let i of this.facet(ve.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(i,n)=>{if(n=="$")return"$";let s=+(n||1);return!s||s>e.length?i:e[s-1]})),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(sm))for(let a of s(this,e,i))Object.prototype.hasOwnProperty.call(a,t)&&n.push(a[t]);return n}charCategorizer(t){return Kw(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),a=t-i,l=t-i;for(;a>0;){let c=di(e,a,!1);if(s(e.slice(c,a))!=Ve.Word)break;a=c}for(;l<n;){let c=di(e,l);if(s(e.slice(l,c))!=Ve.Word)break;l=c}return a==l?null:xt.range(a+i,l+i)}}ve.allowMultipleSelections=nd;ve.tabSize=Ft.define({combine:o=>o.length?o[0]:4});ve.lineSeparator=rm;ve.readOnly=dm;ve.phrases=Ft.define({compare(o,t){let e=Object.keys(o),i=Object.keys(t);return e.length==i.length&&e.every(n=>o[n]==t[n])}});ve.languageData=sm;ve.changeFilter=am;ve.transactionFilter=lm;ve.transactionExtender=cm;Xn.reconfigure=me.define();function ro(o,t,e={}){let i={};for(let n of o)for(let s of Object.keys(n)){let a=n[s],l=i[s];if(l===void 0)i[s]=a;else if(!(l===a||a===void 0))if(Object.hasOwnProperty.call(e,s))i[s]=e[s](l,a);else throw new Error("Config merge conflict for field "+s)}for(let n in t)i[n]===void 0&&(i[n]=t[n]);return i}class ws{eq(t){return this==t}range(t,e=t){return rd.create(t,e,this)}}ws.prototype.startSide=ws.prototype.endSide=0;ws.prototype.point=!1;ws.prototype.mapMode=mi.TrackDel;let rd=class pm{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new pm(t,e,i)}};function ad(o,t){return o.from-t.from||o.value.startSide-t.value.startSide}class nh{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let a=n,l=s.length;;){if(a==l)return a;let c=a+l>>1,u=s[c]-t||(i?this.value[c].endSide:this.value[c].startSide)-e;if(c==a)return u>=0?a:l;u>=0?l=c:a=c+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),a=this.findIndex(i,1e9,!1,s);s<a;s++)if(n(this.from[s]+t,this.to[s]+t,this.value[s])===!1)return!1}map(t,e){let i=[],n=[],s=[],a=-1,l=-1;for(let c=0;c<this.value.length;c++){let u=this.value[c],p=this.from[c]+t,v=this.to[c]+t,x,T;if(p==v){let M=e.mapPos(p,u.startSide,u.mapMode);if(M==null||(x=T=M,u.startSide!=u.endSide&&(T=e.mapPos(p,u.endSide),T<x)))continue}else if(x=e.mapPos(p,u.startSide),T=e.mapPos(v,u.endSide),x>T||x==T&&u.startSide>0&&u.endSide<=0)continue;(T-x||u.endSide-u.startSide)<0||(a<0&&(a=x),u.point&&(l=Math.max(l,T-x)),i.push(u),n.push(x-a),s.push(T-a))}return{mapped:i.length?new nh(n,s,i,l):null,pos:a}}}class ue{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new ue(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,a=t.filter;if(e.length==0&&!a)return this;if(i&&(e=e.slice().sort(ad)),this.isEmpty)return e.length?ue.of(e):this;let l=new fm(this,null,-1).goto(0),c=0,u=[],p=new On;for(;l.value||c<e.length;)if(c<e.length&&(l.from-e[c].from||l.startSide-e[c].value.startSide)>=0){let v=e[c++];p.addInner(v.from,v.to,v.value)||u.push(v)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(c==e.length||this.chunkEnd(l.chunkIndex)<e[c].from)&&(!a||n>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&p.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!a||n>l.to||s<l.from||a(l.from,l.to,l.value))&&(p.addInner(l.from,l.to,l.value)||u.push(rd.create(l.from,l.to,l.value))),l.next());return p.finishInner(this.nextLayer.isEmpty&&!u.length?ue.empty:this.nextLayer.update({add:u,filter:a,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let a=0;a<this.chunk.length;a++){let l=this.chunkPos[a],c=this.chunk[a],u=t.touchesRange(l,l+c.length);if(u===!1)n=Math.max(n,c.maxPoint),e.push(c),i.push(t.mapPos(l));else if(u===!0){let{mapped:p,pos:v}=c.map(l,t);p&&(n=Math.max(n,p.maxPoint),e.push(p),i.push(v))}}let s=this.nextLayer.map(t);return e.length==0?s:new ue(i,e,s||ue.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],a=this.chunk[n];if(e>=s&&t<=s+a.length&&a.between(s,t-s,e-s,i)===!1)return}this.nextLayer.between(t,e,i)}}iter(t=0){return Er.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Er.from(t).goto(e)}static compare(t,e,i,n,s=-1){let a=t.filter(v=>v.maxPoint>0||!v.isEmpty&&v.maxPoint>=s),l=e.filter(v=>v.maxPoint>0||!v.isEmpty&&v.maxPoint>=s),c=Ou(a,l,i),u=new sr(a,c,s),p=new sr(l,c,s);i.iterGaps((v,x,T)=>Du(u,v,p,x,T,n)),i.empty&&i.length==0&&Du(u,0,p,0,0,n)}static eq(t,e,i=0,n){n==null&&(n=999999999);let s=t.filter(p=>!p.isEmpty&&e.indexOf(p)<0),a=e.filter(p=>!p.isEmpty&&t.indexOf(p)<0);if(s.length!=a.length)return!1;if(!s.length)return!0;let l=Ou(s,a),c=new sr(s,l,0).goto(i),u=new sr(a,l,0).goto(i);for(;;){if(c.to!=u.to||!ld(c.active,u.active)||c.point&&(!u.point||!c.point.eq(u.point)))return!1;if(c.to>n)return!0;c.next(),u.next()}}static spans(t,e,i,n,s=-1){let a=new sr(t,null,s).goto(e),l=e,c=a.openStart;for(;;){let u=Math.min(a.to,i);if(a.point){let p=a.activeForPoint(a.to),v=a.pointFrom<e?p.length+1:a.point.startSide<0?p.length:Math.min(p.length,c);n.point(l,u,a.point,p,v,a.pointRank),c=Math.min(a.openEnd(u),p.length)}else u>l&&(n.span(l,u,a.active,c),c=a.openEnd(u));if(a.to>i)return c+(a.point&&a.to>i?1:0);l=a.to,a.next()}}static of(t,e=!1){let i=new On;for(let n of t instanceof rd?[t]:e?Zw(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return ue.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=ue.empty;n=n.nextLayer)e=new ue(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}ue.empty=new ue([],[],null,-1);function Zw(o){if(o.length>1)for(let t=o[0],e=1;e<o.length;e++){let i=o[e];if(ad(t,i)>0)return o.slice().sort(ad);t=i}return o}ue.empty.nextLayer=ue.empty;class On{finishChunk(t){this.chunks.push(new nh(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,t&&(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(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new On)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return n<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(ue.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return t;let e=ue.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Ou(o,t,e){let i=new Map;for(let s of o)for(let a=0;a<s.chunk.length;a++)s.chunk[a].maxPoint<=0&&i.set(s.chunk[a],s.chunkPos[a]);let n=new Set;for(let s of t)for(let a=0;a<s.chunk.length;a++){let l=i.get(s.chunk[a]);l!=null&&(e?e.mapPos(l):l)==s.chunkPos[a]&&!(e!=null&&e.touchesRange(l,l+s.chunk[a].length))&&n.add(s.chunk[a])}return n}class fm{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let n=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(n)||this.layer.chunkEnd(this.chunkIndex)<t||n.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(t){if(t==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=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Er{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let a=t[s];!a.isEmpty;a=a.nextLayer)a.maxPoint>=i&&n.push(new fm(a,e,i,s));return n.length==1?n[0]:new Er(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let i=this.heap.length>>1;i>=0;i--)xc(this.heap,i);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let i=this.heap.length>>1;i>=0;i--)xc(this.heap,i);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),xc(this.heap,0)}}}function xc(o,t){for(let e=o[t];;){let i=(t<<1)+1;if(i>=o.length)break;let n=o[i];if(i+1<o.length&&n.compare(o[i+1])>=0&&(n=o[i+1],i++),e.compare(n)<0)break;o[i]=e,o[t]=n,t=i}}class sr{constructor(t,e,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=Er.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){wa(this.active,t),wa(this.activeTo,t),wa(this.activeRank,t),this.minActive=Ru(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;_a(this.active,e,i),_a(this.activeTo,e,n),_a(this.activeRank,e,s),t&&_a(t,e,this.cursor.from),this.minActive=Ru(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&wa(i,n)}else if(this.cursor.value)if(this.cursor.from>t){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(e&&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 n=i.length-1;n>=0&&i[n]<t;n--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Du(o,t,e,i,n,s){o.goto(t),e.goto(i);let a=i+n,l=i,c=i-t;for(;;){let u=o.to+c-e.to,p=u||o.endSide-e.endSide,v=p<0?o.to+c:e.to,x=Math.min(v,a);if(o.point||e.point?o.point&&e.point&&(o.point==e.point||o.point.eq(e.point))&&ld(o.activeForPoint(o.to),e.activeForPoint(e.to))||s.comparePoint(l,x,o.point,e.point):x>l&&!ld(o.active,e.active)&&s.compareRange(l,x,o.active,e.active),v>a)break;(u||o.openEnd!=e.openEnd)&&s.boundChange&&s.boundChange(v),l=v,p<=0&&o.next(),p>=0&&e.next()}}function ld(o,t){if(o.length!=t.length)return!1;for(let e=0;e<o.length;e++)if(o[e]!=t[e]&&!o[e].eq(t[e]))return!1;return!0}function wa(o,t){for(let e=t,i=o.length-1;e<i;e++)o[e]=o[e+1];o.pop()}function _a(o,t,e){for(let i=o.length-1;i>=t;i--)o[i+1]=o[i];o[t]=e}function Ru(o,t){let e=-1,i=1e9;for(let n=0;n<t.length;n++)(t[n]-i||o[n].endSide-o[e].endSide)<0&&(e=n,i=t[n]);return e}function Ol(o,t,e=o.length){let i=0;for(let n=0;n<e&&n<o.length;)o.charCodeAt(n)==9?(i+=t-i%t,n++):(i++,n=di(o,n));return i}function Gw(o,t,e,i){for(let n=0,s=0;;){if(s>=t)return n;if(n==o.length)break;s+=o.charCodeAt(n)==9?e-s%e:1,n=di(o,n)}return o.length}const cd="ͼ",Bu=typeof Symbol>"u"?"__"+cd:Symbol.for(cd),dd=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),zu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class xo{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function s(a,l,c,u){let p=[],v=/^@(\w+)\b/.exec(a[0]),x=v&&v[1]=="keyframes";if(v&&l==null)return c.push(a[0]+";");for(let T in l){let M=l[T];if(/&/.test(T))s(T.split(/,\s*/).map(P=>a.map(F=>P.replace(/&/,F))).reduce((P,F)=>P.concat(F)),M,c);else if(M&&typeof M=="object"){if(!v)throw new RangeError("The value of a property ("+T+") should be a primitive value.");s(n(T),M,p,x)}else M!=null&&p.push(T.replace(/_.*/,"").replace(/[A-Z]/g,P=>"-"+P.toLowerCase())+": "+M+";")}(p.length||x)&&c.push((i&&!v&&!u?a.map(i):a).join(", ")+" {"+p.join(" ")+"}")}for(let a in t)s(n(a),t[a],this.rules)}getRules(){return this.rules.join(`
|
||
`)}static newName(){let t=zu[Bu]||1;return zu[Bu]=t+1,cd+t.toString(36)}static mount(t,e,i){let n=t[dd],s=i&&i.nonce;n?s&&n.setNonce(s):n=new Yw(t,s),n.mount(Array.isArray(e)?e:[e],t)}}let Fu=new Map;class Yw{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let s=Fu.get(i);if(s)return t[dd]=s;this.sheet=new n.CSSStyleSheet,Fu.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[dd]=this}mount(t,e){let i=this.sheet,n=0,s=0;for(let a=0;a<t.length;a++){let l=t[a],c=this.modules.indexOf(l);if(c<s&&c>-1&&(this.modules.splice(c,1),s--,c=-1),c==-1){if(this.modules.splice(s++,0,l),i)for(let u=0;u<l.rules.length;u++)i.insertRule(l.rules[u],n++)}else{for(;s<c;)n+=this.modules[s++].rules.length;n+=l.rules.length,s++}}if(i)e.adoptedStyleSheets.indexOf(this.sheet)<0&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{let a="";for(let c=0;c<this.modules.length;c++)a+=this.modules[c].getRules()+`
|
||
`;this.styleTag.textContent=a;let l=e.head||e;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}var ko={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:"'"},Ir={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Jw=typeof navigator<"u"&&/Mac/.test(navigator.platform),Qw=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ci=0;ci<10;ci++)ko[48+ci]=ko[96+ci]=String(ci);for(var ci=1;ci<=24;ci++)ko[ci+111]="F"+ci;for(var ci=65;ci<=90;ci++)ko[ci]=String.fromCharCode(ci+32),Ir[ci]=String.fromCharCode(ci);for(var kc in ko)Ir.hasOwnProperty(kc)||(Ir[kc]=ko[kc]);function Xw(o){var t=Jw&&o.metaKey&&o.shiftKey&&!o.ctrlKey&&!o.altKey||Qw&&o.shiftKey&&o.key&&o.key.length==1||o.key=="Unidentified",e=!t&&o.key||(o.shiftKey?Ir:ko)[o.keyCode]||o.key||"Unidentified";return e=="Esc"&&(e="Escape"),e=="Del"&&(e="Delete"),e=="Left"&&(e="ArrowLeft"),e=="Up"&&(e="ArrowUp"),e=="Right"&&(e="ArrowRight"),e=="Down"&&(e="ArrowDown"),e}function En(){var o=arguments[0];typeof o=="string"&&(o=document.createElement(o));var t=1,e=arguments[1];if(e&&typeof e=="object"&&e.nodeType==null&&!Array.isArray(e)){for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var n=e[i];typeof n=="string"?o.setAttribute(i,n):n!=null&&(o[i]=n)}t++}for(;t<arguments.length;t++)mm(o,arguments[t]);return o}function mm(o,t){if(typeof t=="string")o.appendChild(document.createTextNode(t));else if(t!=null)if(t.nodeType!=null)o.appendChild(t);else if(Array.isArray(t))for(var e=0;e<t.length;e++)mm(o,t[e]);else throw new RangeError("Unsupported child node: "+t)}function Ar(o){let t;return o.nodeType==11?t=o.getSelection?o:o.ownerDocument:t=o,t.getSelection()}function hd(o,t){return t?o==t||o.contains(t.nodeType!=1?t.parentNode:t):!1}function Xa(o,t){if(!t.anchorNode)return!1;try{return hd(o,t.anchorNode)}catch{return!1}}function _s(o){return o.nodeType==3?Uo(o,0,o.nodeValue.length).getClientRects():o.nodeType==1?o.getClientRects():[]}function xr(o,t,e,i){return e?Wu(o,t,e,i,-1)||Wu(o,t,e,i,1):!1}function Vo(o){for(var t=0;;t++)if(o=o.previousSibling,!o)return t}function pl(o){return o.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(o.nodeName)}function Wu(o,t,e,i,n){for(;;){if(o==e&&t==i)return!0;if(t==(n<0?0:Dn(o))){if(o.nodeName=="DIV")return!1;let s=o.parentNode;if(!s||s.nodeType!=1)return!1;t=Vo(o)+(n<0?0:1),o=s}else if(o.nodeType==1){if(o=o.childNodes[t+(n<0?-1:0)],o.nodeType==1&&o.contentEditable=="false")return!1;t=n<0?Dn(o):0}else return!1}}function Dn(o){return o.nodeType==3?o.nodeValue.length:o.childNodes.length}function zr(o,t){let e=t?o.left:o.right;return{left:e,right:e,top:o.top,bottom:o.bottom}}function t_(o){let t=o.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:o.innerWidth,top:0,bottom:o.innerHeight}}function gm(o,t){let e=t.width/o.offsetWidth,i=t.height/o.offsetHeight;return(e>.995&&e<1.005||!isFinite(e)||Math.abs(t.width-o.offsetWidth)<1)&&(e=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-o.offsetHeight)<1)&&(i=1),{scaleX:e,scaleY:i}}function e_(o,t,e,i,n,s,a,l){let c=o.ownerDocument,u=c.defaultView||window;for(let p=o,v=!1;p&&!v;)if(p.nodeType==1){let x,T=p==c.body,M=1,P=1;if(T)x=t_(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(p).position)&&(v=!0),p.scrollHeight<=p.clientHeight&&p.scrollWidth<=p.clientWidth){p=p.assignedSlot||p.parentNode;continue}let q=p.getBoundingClientRect();({scaleX:M,scaleY:P}=gm(p,q)),x={left:q.left,right:q.left+p.clientWidth*M,top:q.top,bottom:q.top+p.clientHeight*P}}let F=0,R=0;if(n=="nearest")t.top<x.top?(R=t.top-(x.top+a),e>0&&t.bottom>x.bottom+R&&(R=t.bottom-x.bottom+a)):t.bottom>x.bottom&&(R=t.bottom-x.bottom+a,e<0&&t.top-R<x.top&&(R=t.top-(x.top+a)));else{let q=t.bottom-t.top,H=x.bottom-x.top;R=(n=="center"&&q<=H?t.top+q/2-H/2:n=="start"||n=="center"&&e<0?t.top-a:t.bottom-H+a)-x.top}if(i=="nearest"?t.left<x.left?(F=t.left-(x.left+s),e>0&&t.right>x.right+F&&(F=t.right-x.right+s)):t.right>x.right&&(F=t.right-x.right+s,e<0&&t.left<x.left+F&&(F=t.left-(x.left+s))):F=(i=="center"?t.left+(t.right-t.left)/2-(x.right-x.left)/2:i=="start"==l?t.left-s:t.right-(x.right-x.left)+s)-x.left,F||R)if(T)u.scrollBy(F,R);else{let q=0,H=0;if(R){let Q=p.scrollTop;p.scrollTop+=R/P,H=(p.scrollTop-Q)*P}if(F){let Q=p.scrollLeft;p.scrollLeft+=F/M,q=(p.scrollLeft-Q)*M}t={left:t.left-q,top:t.top-H,right:t.right-q,bottom:t.bottom-H},q&&Math.abs(q-F)<1&&(i="nearest"),H&&Math.abs(H-R)<1&&(n="nearest")}if(T)break;(t.top<x.top||t.bottom>x.bottom||t.left<x.left||t.right>x.right)&&(t={left:Math.max(t.left,x.left),right:Math.min(t.right,x.right),top:Math.max(t.top,x.top),bottom:Math.min(t.bottom,x.bottom)}),p=p.assignedSlot||p.parentNode}else if(p.nodeType==11)p=p.host;else break}function i_(o){let t=o.ownerDocument,e,i;for(let n=o.parentNode;n&&!(n==t.body||e&&i);)if(n.nodeType==1)!i&&n.scrollHeight>n.clientHeight&&(i=n),!e&&n.scrollWidth>n.clientWidth&&(e=n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;return{x:e,y:i}}class n_{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?Dn(e):0),i,Math.min(t.focusOffset,i?Dn(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let ls=null;function vm(o){if(o.setActive)return o.setActive();if(ls)return o.focus(ls);let t=[];for(let e=o;e&&(t.push(e,e.scrollTop,e.scrollLeft),e!=e.ownerDocument);e=e.parentNode);if(o.focus(ls==null?{get preventScroll(){return ls={preventScroll:!0},!0}}:void 0),!ls){ls=!1;for(let e=0;e<t.length;){let i=t[e++],n=t[e++],s=t[e++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}let Hu;function Uo(o,t,e=t){let i=Hu||(Hu=document.createRange());return i.setEnd(o,e),i.setStart(o,t),i}function gs(o,t,e,i){let n={key:t,code:t,keyCode:e,which:e,cancelable:!0};i&&({altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,metaKey:n.metaKey}=i);let s=new KeyboardEvent("keydown",n);s.synthetic=!0,o.dispatchEvent(s);let a=new KeyboardEvent("keyup",n);return a.synthetic=!0,o.dispatchEvent(a),s.defaultPrevented||a.defaultPrevented}function o_(o){for(;o;){if(o&&(o.nodeType==9||o.nodeType==11&&o.host))return o;o=o.assignedSlot||o.parentNode}return null}function ym(o){for(;o.attributes.length;)o.removeAttributeNode(o.attributes[0])}function s_(o,t){let e=t.focusNode,i=t.focusOffset;if(!e||t.anchorNode!=e||t.anchorOffset!=i)return!1;for(i=Math.min(i,Dn(e));;)if(i){if(e.nodeType!=1)return!1;let n=e.childNodes[i-1];n.contentEditable=="false"?i--:(e=n,i=Dn(e))}else{if(e==o)return!0;i=Vo(e),e=e.parentNode}}function bm(o){return o.scrollTop>Math.max(1,o.scrollHeight-o.clientHeight-4)}function wm(o,t){for(let e=o,i=t;;){if(e.nodeType==3&&i>0)return{node:e,offset:i};if(e.nodeType==1&&i>0){if(e.contentEditable=="false")return null;e=e.childNodes[i-1],i=Dn(e)}else if(e.parentNode&&!pl(e))i=Vo(e),e=e.parentNode;else return null}}function _m(o,t){for(let e=o,i=t;;){if(e.nodeType==3&&i<e.nodeValue.length)return{node:e,offset:i};if(e.nodeType==1&&i<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[i],i=0}else if(e.parentNode&&!pl(e))i=Vo(e)+1,e=e.parentNode;else return null}}class gi{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new gi(t.parentNode,Vo(t),e)}static after(t,e){return new gi(t.parentNode,Vo(t)+1,e)}}const oh=[];class Te{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(this.flags&2){let i=this.dom,n=null,s;for(let a of this.children){if(a.flags&7){if(!a.dom&&(s=n?n.nextSibling:i.firstChild)){let l=Te.get(s);(!l||!l.parent&&l.canReuseDOM(a))&&a.reuseDOM(s)}a.sync(t,e),a.flags&=-8}if(s=n?n.nextSibling:i.firstChild,e&&!e.written&&e.node==i&&s!=a.dom&&(e.written=!0),a.dom.parentNode==i)for(;s&&s!=a.dom;)s=Vu(s);else i.insertBefore(a.dom,s);n=a.dom}for(s=n?n.nextSibling:i.firstChild,s&&e&&e.node==i&&(e.written=!0);s;)s=Vu(s)}else if(this.flags&1)for(let i of this.children)i.flags&7&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=Dn(t)==0?0:e==0?-1:1;for(;;){let s=t.parentNode;if(s==this.dom)break;n==0&&s.firstChild!=s.lastChild&&(t==s.firstChild?n=-1:n=1),t=s}n<0?i=t:i=t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!Te.get(i);)i=i.nextSibling;if(!i)return this.length;for(let n=0,s=0;;n++){let a=this.children[n];if(a.dom==i)return s;s+=a.length+a.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,a=-1,l=-1;for(let c=0,u=i,p=i;c<this.children.length;c++){let v=this.children[c],x=u+v.length;if(u<t&&x>e)return v.domBoundsAround(t,e,u);if(x>=t&&n==-1&&(n=c,s=u),u>e&&v.dom.parentNode==this.dom){a=c,l=p;break}p=x,u=x+v.breakAfter}return{from:s,to:l<0?i+this.length:l,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:a<this.children.length&&a>=0?this.children[a].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),e.flags&1)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,this.flags&7&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=oh){this.markDirty();for(let n=t;n<e;n++){let s=this.children[n];s.parent==this&&i.indexOf(s)<0&&s.destroy()}i.length<250?this.children.splice(t,e-t,...i):this.children=[].concat(this.children.slice(0,t),i,this.children.slice(e));for(let n=0;n<i.length;n++)i[n].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new xm(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+(t=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,a){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!((this.flags|t.flags)&8)}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}Te.prototype.breakAfter=0;function Vu(o){let t=o.nextSibling;return o.parentNode.removeChild(o),t}class xm{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function km(o,t,e,i,n,s,a,l,c){let{children:u}=o,p=u.length?u[t]:null,v=s.length?s[s.length-1]:null,x=v?v.breakAfter:a;if(!(t==i&&p&&!a&&!x&&s.length<2&&p.merge(e,n,s.length?v:null,e==0,l,c))){if(i<u.length){let T=u[i];T&&(n<T.length||T.breakAfter&&v!=null&&v.breakAfter)?(t==i&&(T=T.split(n),n=0),!x&&v&&T.merge(0,n,v,!0,0,c)?s[s.length-1]=T:((n||T.children.length&&!T.children[0].length)&&T.merge(0,n,null,!1,0,c),s.push(T))):T!=null&&T.breakAfter&&(v?v.breakAfter=1:a=1),i++}for(p&&(p.breakAfter=a,e>0&&(!a&&s.length&&p.merge(e,p.length,s[0],!1,l,0)?p.breakAfter=s.shift().breakAfter:(e<p.length||p.children.length&&p.children[p.children.length-1].length==0)&&p.merge(e,p.length,null,!1,l,0),t++));t<i&&s.length;)if(u[i-1].become(s[s.length-1]))i--,s.pop(),c=s.length?0:l;else if(u[t].become(s[0]))t++,s.shift(),l=s.length?0:c;else break;!s.length&&t&&i<u.length&&!u[t-1].breakAfter&&u[i].merge(0,0,u[t-1],!1,l,c)&&t--,(t<i||s.length)&&o.replaceChildren(t,i,s)}}function Cm(o,t,e,i,n,s){let a=o.childCursor(),{i:l,off:c}=a.findPos(e,1),{i:u,off:p}=a.findPos(t,-1),v=t-e;for(let x of i)v+=x.length;o.length+=v,km(o,u,p,l,c,i,0,n,s)}let Li=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},ud=typeof document<"u"?document:{documentElement:{style:{}}};const pd=/Edge\/(\d+)/.exec(Li.userAgent),$m=/MSIE \d/.test(Li.userAgent),fd=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Li.userAgent),Dl=!!($m||fd||pd),Uu=!Dl&&/gecko\/(\d+)/i.test(Li.userAgent),Cc=!Dl&&/Chrome\/(\d+)/.exec(Li.userAgent),r_="webkitFontSmoothing"in ud.documentElement.style,Sm=!Dl&&/Apple Computer/.test(Li.vendor),ju=Sm&&(/Mobile\/\w+/.test(Li.userAgent)||Li.maxTouchPoints>2);var Bt={mac:ju||/Mac/.test(Li.platform),windows:/Win/.test(Li.platform),linux:/Linux|X11/.test(Li.platform),ie:Dl,ie_version:$m?ud.documentMode||6:fd?+fd[1]:pd?+pd[1]:0,gecko:Uu,gecko_version:Uu?+(/Firefox\/(\d+)/.exec(Li.userAgent)||[0,0])[1]:0,chrome:!!Cc,chrome_version:Cc?+Cc[1]:0,ios:ju,android:/Android\b/.test(Li.userAgent),safari:Sm,webkit_version:r_?+(/\bAppleWebKit\/(\d+)/.exec(Li.userAgent)||[0,0])[1]:0,tabSize:ud.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const a_=256;class gn extends Te{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){t.nodeType==3&&this.createDOM(t)}merge(t,e,i){return this.flags&8||i&&(!(i instanceof gn)||this.length-(e-t)+i.length>a_||i.flags&8)?!1:(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new gn(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=this.flags&8,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new gi(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return l_(this.dom,t,e)}}class no extends Te{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let n of e)n.setParent(this)}setAttrs(t){if(ym(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!((this.flags|t.flags)&8)}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,a){return i&&(!(i instanceof no&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&a<=0)?!1:(Cm(this,t,e,i?i.children.slice():[],s-1,a-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let l of this.children){let c=i+l.length;c>t&&e.push(i<t?l.split(t-i):l),n<0&&i>=t&&(n=s),i=c,s++}let a=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new no(this.mark,e,a)}domAtPos(t){return Tm(this,t)}coordsAt(t,e){return Im(this,t,e)}}function l_(o,t,e){let i=o.nodeValue.length;t>i&&(t=i);let n=t,s=t,a=0;t==0&&e<0||t==i&&e>=0?Bt.chrome||Bt.gecko||(t?(n--,a=1):s<i&&(s++,a=-1)):e<0?n--:s<i&&s++;let l=Uo(o,n,s).getClientRects();if(!l.length)return null;let c=l[(a?a<0:e>=0)?0:l.length-1];return Bt.safari&&!a&&c.width==0&&(c=Array.prototype.find.call(l,u=>u.width)||c),a?zr(c,a<0):c||null}class wo extends Te{static create(t,e,i){return new wo(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=wo.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){(!this.dom||!this.widget.updateDOM(this.dom,t))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,s,a){return i&&(!(i instanceof wo)||!this.widget.compare(i.widget)||t>0&&s<=0||e<this.length&&a<=0)?!1:(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof wo&&t.side==this.side&&this.widget.constructor==t.widget.constructor?(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(this.length==0)return ye.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):ye.empty}domAtPos(t){return(this.length?t==0:this.side>0)?gi.before(this.dom):gi.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let a=this.side?this.side<0:t>0;for(let l=a?n.length-1:0;s=n[l],!(t>0?l==0:l==n.length-1||s.top<s.bottom);l+=a?-1:1);return zr(s,!a)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class xs extends Te{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof xs&&t.side==this.side}split(){return new xs(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?gi.before(this.dom):gi.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return ye.empty}get isHidden(){return!0}}gn.prototype.children=wo.prototype.children=xs.prototype.children=oh;function Tm(o,t){let e=o.dom,{children:i}=o,n=0;for(let s=0;n<i.length;n++){let a=i[n],l=s+a.length;if(!(l==s&&a.getSide()<=0)){if(t>s&&t<l&&a.dom.parentNode==e)return a.domAtPos(t-s);if(t<=s)break;s=l}}for(let s=n;s>0;s--){let a=i[s-1];if(a.dom.parentNode==e)return a.domAtPos(a.length)}for(let s=n;s<i.length;s++){let a=i[s];if(a.dom.parentNode==e)return a.domAtPos(0)}return new gi(e,0)}function Em(o,t,e){let i,{children:n}=o;e>0&&t instanceof no&&n.length&&(i=n[n.length-1])instanceof no&&i.mark.eq(t.mark)?Em(i,t.children[0],e-1):(n.push(t),t.setParent(o)),o.length+=t.length}function Im(o,t,e){let i=null,n=-1,s=null,a=-1;function l(u,p){for(let v=0,x=0;v<u.children.length&&x<=p;v++){let T=u.children[v],M=x+T.length;M>=p&&(T.children.length?l(T,p-x):(!s||s.isHidden&&(e>0||d_(s,T)))&&(M>p||x==M&&T.getSide()>0)?(s=T,a=p-x):(x<p||x==M&&T.getSide()<0&&!T.isHidden)&&(i=T,n=p-x)),x=M}}l(o,t);let c=(e<0?i:s)||i||s;return c?c.coordsAt(Math.max(0,c==i?n:a),e):c_(o)}function c_(o){let t=o.dom.lastChild;if(!t)return o.dom.getBoundingClientRect();let e=_s(t);return e[e.length-1]||null}function d_(o,t){let e=o.coordsAt(0,1),i=t.coordsAt(0,1);return e&&i&&i.top<e.bottom}function md(o,t){for(let e in o)e=="class"&&t.class?t.class+=" "+o.class:e=="style"&&t.style?t.style+=";"+o.style:t[e]=o[e];return t}const qu=Object.create(null);function fl(o,t,e){if(o==t)return!0;o||(o=qu),t||(t=qu);let i=Object.keys(o),n=Object.keys(t);if(i.length-(e&&i.indexOf(e)>-1?1:0)!=n.length-(e&&n.indexOf(e)>-1?1:0))return!1;for(let s of i)if(s!=e&&(n.indexOf(s)==-1||o[s]!==t[s]))return!1;return!0}function gd(o,t,e){let i=!1;if(t)for(let n in t)e&&n in e||(i=!0,n=="style"?o.style.cssText="":o.removeAttribute(n));if(e)for(let n in e)t&&t[n]==e[n]||(i=!0,n=="style"?o.style.cssText=e[n]:o.setAttribute(n,e[n]));return i}function h_(o){let t=Object.create(null);for(let e=0;e<o.attributes.length;e++){let i=o.attributes[e];t[i.name]=i.value}return t}class Zo{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var nn=function(o){return o[o.Text=0]="Text",o[o.WidgetBefore=1]="WidgetBefore",o[o.WidgetAfter=2]="WidgetAfter",o[o.WidgetRange=3]="WidgetRange",o}(nn||(nn={}));class Yt extends ws{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new Fr(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new Co(t,e,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,i,n;if(t.isBlockGap)i=-5e8,n=4e8;else{let{start:s,end:a}=Am(t,e);i=(s?e?-3e8:-1:5e8)-1,n=(a?e?2e8:1:-6e8)+1}return new Co(t,i,n,e,t.widget||null,!0)}static line(t){return new Wr(t)}static set(t,e=!1){return ue.of(t,e)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Yt.none=ue.empty;class Fr extends Yt{constructor(t){let{start:e,end:i}=Am(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof Fr&&this.tagName==t.tagName&&(this.class||((e=this.attrs)===null||e===void 0?void 0:e.class))==(t.class||((i=t.attrs)===null||i===void 0?void 0:i.class))&&fl(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}Fr.prototype.point=!1;class Wr extends Yt{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof Wr&&this.spec.class==t.spec.class&&fl(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}Wr.prototype.mapMode=mi.TrackBefore;Wr.prototype.point=!0;class Co extends Yt{constructor(t,e,i,n,s,a){super(e,i,s,t),this.block=n,this.isReplace=a,this.mapMode=n?e<=0?mi.TrackBefore:mi.TrackAfter:mi.TrackDel}get type(){return this.startSide!=this.endSide?nn.WidgetRange:this.startSide<=0?nn.WidgetBefore:nn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Co&&u_(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}Co.prototype.point=!0;function Am(o,t=!1){let{inclusiveStart:e,inclusiveEnd:i}=o;return e==null&&(e=o.inclusive),i==null&&(i=o.inclusive),{start:e??t,end:i??t}}function u_(o,t){return o==t||!!(o&&t&&o.compare(t))}function tl(o,t,e,i=0){let n=e.length-1;n>=0&&e[n]+i>=o?e[n]=Math.max(e[n],t):e.push(o,t)}class Ge extends Te{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,s,a){if(i){if(!(i instanceof Ge))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),Cm(this,t,e,i?i.children.slice():[],s,a),!0}split(t){let e=new Ge;if(e.breakAfter=this.breakAfter,this.length==0)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let s=i;s<this.children.length;s++)e.append(this.children[s],0);for(;i>0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){fl(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){Em(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=md(e,this.attrs||{})),i&&(this.attrs=md({class:i},this.attrs||{}))}domAtPos(t){return Tm(this,t)}reuseDOM(t){t.nodeName=="DIV"&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?this.flags&4&&(ym(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(gd(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&Te.get(n)instanceof no;)n=n.lastChild;if(!n||!this.length||n.nodeName!="BR"&&((i=Te.get(n))===null||i===void 0?void 0:i.isEditable)==!1&&(!Bt.ios||!this.children.some(s=>s instanceof gn))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let t=0,e;for(let i of this.children){if(!(i instanceof gn)||/[^ -~]/.test(i.text))return null;let n=_s(i.dom);if(n.length!=1)return null;t+=n[0].width,e=n[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(t,e){let i=Im(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:n}=this.parent.view.viewState,s=i.bottom-i.top;if(Math.abs(s-n.lineHeight)<2&&n.textHeight<s){let a=(s-n.textHeight)/2;return{top:i.top+a,bottom:i.bottom-a,left:i.left,right:i.left}}}return i}become(t){return t instanceof Ge&&this.children.length==0&&t.children.length==0&&fl(this.attrs,t.attrs)&&this.breakAfter==t.breakAfter}covers(){return!0}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],a=n+s.length;if(a>=e){if(s instanceof Ge)return s;if(a>e)break}n=a+s.breakAfter}return null}}class eo extends Te{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,a){return i&&(!(i instanceof eo)||!this.widget.compare(i.widget)||t>0&&s<=0||e<this.length&&a<=0)?!1:(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return t==0?gi.before(this.dom):gi.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new eo(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return oh}sync(t){(!this.dom||!this.widget.updateDOM(this.dom,t))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):ye.empty}domBoundsAround(){return null}become(t){return t instanceof eo&&t.widget.constructor==this.widget.constructor?(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)||(this.widget instanceof vd?null:zr(this.dom.getBoundingClientRect(),this.length?t==0:e<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e==i?!1:t<0?e<0:i>0}}class vd extends Zo{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class kr{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof eo&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ge),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(xa(new xs(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(t&&this.content.length&&this.content[this.content.length-1]instanceof eo)&&this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(a){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}else this.text=s,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(xa(new gn(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,s,a){if(this.disallowBlockEffectsFor[a]&&i instanceof Co){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=e-t;if(i instanceof Co)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new eo(i.widget||ks.block,l,i));else{let c=wo.create(i.widget||ks.inline,l,l?0:i.startSide),u=this.atCursorPos&&!c.isEditable&&s<=n.length&&(t<e||i.startSide>0),p=!c.isEditable&&(t<e||s>n.length||i.startSide<=0),v=this.getLine();this.pendingBuffer==2&&!u&&!c.isEditable&&(this.pendingBuffer=0),this.flushBuffer(n),u&&(v.append(xa(new xs(1),n),s),s=n.length+Math.max(0,s-n.length)),v.append(xa(c,n),s),this.atCursorPos=p,this.pendingBuffer=p?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,n,s){let a=new kr(t,e,i,s);return a.openEnd=ue.spans(n,e,i,a),a.openStart<0&&(a.openStart=a.openEnd),a.finish(a.openEnd),a}}function xa(o,t){for(let e of t)o=new no(e,[o],o.length);return o}class ks extends Zo{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}ks.inline=new ks("span");ks.block=new ks("div");var Fe=function(o){return o[o.LTR=0]="LTR",o[o.RTL=1]="RTL",o}(Fe||(Fe={}));const jo=Fe.LTR,sh=Fe.RTL;function Lm(o){let t=[];for(let e=0;e<o.length;e++)t.push(1<<+o[e]);return t}const p_=Lm("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),f_=Lm("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),yd=Object.create(null),xn=[];for(let o of["()","[]","{}"]){let t=o.charCodeAt(0),e=o.charCodeAt(1);yd[t]=e,yd[e]=-t}function Nm(o){return o<=247?p_[o]:1424<=o&&o<=1524?2:1536<=o&&o<=1785?f_[o-1536]:1774<=o&&o<=2220?4:8192<=o&&o<=8204?256:64336<=o&&o<=65023?4:1}const m_=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class _o{get dir(){return this.level%2?sh:jo}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let s=-1;for(let a=0;a<t.length;a++){let l=t[a];if(l.from<=e&&l.to>=e){if(l.level==i)return a;(s<0||(n!=0?n<0?l.from<e:l.to>e:t[s].level>l.level))&&(s=a)}}if(s<0)throw new RangeError("Index out of range");return s}}function Mm(o,t){if(o.length!=t.length)return!1;for(let e=0;e<o.length;e++){let i=o[e],n=t[e];if(i.from!=n.from||i.to!=n.to||i.direction!=n.direction||!Mm(i.inner,n.inner))return!1}return!0}const Se=[];function g_(o,t,e,i,n){for(let s=0;s<=i.length;s++){let a=s?i[s-1].to:t,l=s<i.length?i[s].from:e,c=s?256:n;for(let u=a,p=c,v=c;u<l;u++){let x=Nm(o.charCodeAt(u));x==512?x=p:x==8&&v==4&&(x=16),Se[u]=x==4?2:x,x&7&&(v=x),p=x}for(let u=a,p=c,v=c;u<l;u++){let x=Se[u];if(x==128)u<l-1&&p==Se[u+1]&&p&24?x=Se[u]=p:Se[u]=256;else if(x==64){let T=u+1;for(;T<l&&Se[T]==64;)T++;let M=u&&p==8||T<e&&Se[T]==8?v==1?1:8:256;for(let P=u;P<T;P++)Se[P]=M;u=T-1}else x==8&&v==1&&(Se[u]=1);p=x,x&7&&(v=x)}}}function v_(o,t,e,i,n){let s=n==1?2:1;for(let a=0,l=0,c=0;a<=i.length;a++){let u=a?i[a-1].to:t,p=a<i.length?i[a].from:e;for(let v=u,x,T,M;v<p;v++)if(T=yd[x=o.charCodeAt(v)])if(T<0){for(let P=l-3;P>=0;P-=3)if(xn[P+1]==-T){let F=xn[P+2],R=F&2?n:F&4?F&1?s:n:0;R&&(Se[v]=Se[xn[P]]=R),l=P;break}}else{if(xn.length==189)break;xn[l++]=v,xn[l++]=x,xn[l++]=c}else if((M=Se[v])==2||M==1){let P=M==n;c=P?0:1;for(let F=l-3;F>=0;F-=3){let R=xn[F+2];if(R&2)break;if(P)xn[F+2]|=2;else{if(R&4)break;xn[F+2]|=4}}}}}function y_(o,t,e,i){for(let n=0,s=i;n<=e.length;n++){let a=n?e[n-1].to:o,l=n<e.length?e[n].from:t;for(let c=a;c<l;){let u=Se[c];if(u==256){let p=c+1;for(;;)if(p==l){if(n==e.length)break;p=e[n++].to,l=n<e.length?e[n].from:t}else if(Se[p]==256)p++;else break;let v=s==1,x=(p<t?Se[p]:i)==1,T=v==x?v?1:2:i;for(let M=p,P=n,F=P?e[P-1].to:o;M>c;)M==F&&(M=e[--P].from,F=P?e[P-1].to:o),Se[--M]=T;c=p}else s=u,c++}}}function bd(o,t,e,i,n,s,a){let l=i%2?2:1;if(i%2==n%2)for(let c=t,u=0;c<e;){let p=!0,v=!1;if(u==s.length||c<s[u].from){let P=Se[c];P!=l&&(p=!1,v=P==16)}let x=!p&&l==1?[]:null,T=p?i:i+1,M=c;t:for(;;)if(u<s.length&&M==s[u].from){if(v)break t;let P=s[u];if(!p)for(let F=P.to,R=u+1;;){if(F==e)break t;if(R<s.length&&s[R].from==F)F=s[R++].to;else{if(Se[F]==l)break t;break}}if(u++,x)x.push(P);else{P.from>c&&a.push(new _o(c,P.from,T));let F=P.direction==jo!=!(T%2);wd(o,F?i+1:i,n,P.inner,P.from,P.to,a),c=P.to}M=P.to}else{if(M==e||(p?Se[M]!=l:Se[M]==l))break;M++}x?bd(o,c,M,i+1,n,x,a):c<M&&a.push(new _o(c,M,T)),c=M}else for(let c=e,u=s.length;c>t;){let p=!0,v=!1;if(!u||c>s[u-1].to){let P=Se[c-1];P!=l&&(p=!1,v=P==16)}let x=!p&&l==1?[]:null,T=p?i:i+1,M=c;t:for(;;)if(u&&M==s[u-1].to){if(v)break t;let P=s[--u];if(!p)for(let F=P.from,R=u;;){if(F==t)break t;if(R&&s[R-1].to==F)F=s[--R].from;else{if(Se[F-1]==l)break t;break}}if(x)x.push(P);else{P.to<c&&a.push(new _o(P.to,c,T));let F=P.direction==jo!=!(T%2);wd(o,F?i+1:i,n,P.inner,P.from,P.to,a),c=P.from}M=P.from}else{if(M==t||(p?Se[M-1]!=l:Se[M-1]==l))break;M--}x?bd(o,M,c,i+1,n,x,a):M<c&&a.push(new _o(M,c,T)),c=M}}function wd(o,t,e,i,n,s,a){let l=t%2?2:1;g_(o,n,s,i,l),v_(o,n,s,i,l),y_(n,s,i,l),bd(o,n,s,t,e,i,a)}function b_(o,t,e){if(!o)return[new _o(0,0,t==sh?1:0)];if(t==jo&&!e.length&&!m_.test(o))return Pm(o.length);if(e.length)for(;o.length>Se.length;)Se[Se.length]=256;let i=[],n=t==jo?0:1;return wd(o,n,n,e,0,o.length,i),i}function Pm(o){return[new _o(0,o,0)]}let Om="";function w_(o,t,e,i,n){var s;let a=i.head-o.from,l=_o.find(t,a,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),c=t[l],u=c.side(n,e);if(a==u){let x=l+=n?1:-1;if(x<0||x>=t.length)return null;c=t[l=x],a=c.side(!n,e),u=c.side(n,e)}let p=di(o.text,a,c.forward(n,e));(p<c.from||p>c.to)&&(p=u),Om=o.text.slice(Math.min(a,p),Math.max(a,p));let v=l==(n?t.length-1:0)?null:t[l+(n?1:-1)];return v&&p==u&&v.level+(n?0:1)<c.level?xt.cursor(v.side(!n,e)+o.from,v.forward(n,e)?1:-1,v.level):xt.cursor(p+o.from,c.forward(n,e)?-1:1,c.level)}function __(o,t,e){for(let i=t;i<e;i++){let n=Nm(o.charCodeAt(i));if(n==1)return jo;if(n==2||n==4)return sh}return jo}const Dm=Ft.define(),Rm=Ft.define(),Bm=Ft.define(),zm=Ft.define(),_d=Ft.define(),Fm=Ft.define(),Wm=Ft.define(),rh=Ft.define(),ah=Ft.define(),Hm=Ft.define({combine:o=>o.some(t=>t)}),x_=Ft.define({combine:o=>o.some(t=>t)}),Vm=Ft.define();class vs{constructor(t,e="nearest",i="nearest",n=5,s=5,a=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=a}map(t){return t.empty?this:new vs(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new vs(xt.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const ka=me.define({map:(o,t)=>o.map(t)}),Um=me.define();function Ji(o,t,e){let i=o.facet(zm);i.length?i[0](t):window.onerror&&window.onerror(String(t),e,void 0,void 0,t)||(e?console.error(e+":",t):console.error(t))}const to=Ft.define({combine:o=>o.length?o[0]:!0});let k_=0;const us=Ft.define({combine(o){return o.filter((t,e)=>{for(let i=0;i<e;i++)if(o[i].plugin==t.plugin)return!1;return!0})}});class ti{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(us.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(us.of({plugin:this,arg:t}))}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:a}=e||{};return new ti(k_++,t,i,n,l=>{let c=[];return a&&c.push(Lr.of(u=>{let p=u.plugin(l);return p?a(p):Yt.none})),s&&c.push(s(l)),c})}static fromClass(t,e){return ti.define((i,n)=>new t(i,n),e)}}class $c{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(i){if(Ji(e.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(t,this.spec.arg)}catch(e){Ji(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(!((e=this.value)===null||e===void 0)&&e.destroy)try{this.value.destroy()}catch(i){Ji(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jm=Ft.define(),lh=Ft.define(),Lr=Ft.define(),qm=Ft.define(),ch=Ft.define(),Km=Ft.define();function Ku(o,t){let e=o.state.facet(Km);if(!e.length)return e;let i=e.map(s=>s instanceof Function?s(o):s),n=[];return ue.spans(i,t.from,t.to,{point(){},span(s,a,l,c){let u=s-t.from,p=a-t.from,v=n;for(let x=l.length-1;x>=0;x--,c--){let T=l[x].spec.bidiIsolate,M;if(T==null&&(T=__(t.text,u,p)),c>0&&v.length&&(M=v[v.length-1]).to==u&&M.direction==T)M.to=p,v=M.inner;else{let P={from:u,to:p,direction:T,inner:[]};v.push(P),v=P.inner}}}}),n}const Zm=Ft.define();function dh(o){let t=0,e=0,i=0,n=0;for(let s of o.state.facet(Zm)){let a=s(o);a&&(a.left!=null&&(t=Math.max(t,a.left)),a.right!=null&&(e=Math.max(e,a.right)),a.top!=null&&(i=Math.max(i,a.top)),a.bottom!=null&&(n=Math.max(n,a.bottom)))}return{left:t,right:e,top:i,bottom:n}}const ur=Ft.define();class on{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new on(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(e.length==0)return t;let i=[];for(let n=0,s=0,a=0,l=0;;n++){let c=n==t.length?null:t[n],u=a-l,p=c?c.fromB:1e9;for(;s<e.length&&e[s]<p;){let v=e[s],x=e[s+1],T=Math.max(l,v),M=Math.min(p,x);if(T<=M&&new on(T+u,M+u,T,M).addToSet(i),x>p)break;s+=2}if(!c)return i;new on(c.fromA,c.toA,c.fromB,c.toB).addToSet(i),a=c.toA,l=c.toB}}}class ml{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=Je.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let n=[];this.changes.iterChangedRanges((s,a,l,c)=>n.push(new on(s,a,l,c))),this.changedRanges=n}static create(t,e,i){return new ml(t,e,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(t=>t.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class Zu extends Te{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Yt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new Ge],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new on(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:u,toA:p})=>p<this.minWidthFrom||u>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((e=this.domChanged)===null||e===void 0)&&e.newSel?n=this.domChanged.newSel.head:!A_(t.changes,this.hasComposition)&&!t.selectionSet&&(n=t.state.selection.main.head));let s=n>-1?$_(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:u,to:p}=this.hasComposition;i=new on(u,p,t.changes.mapPos(u,-1),t.changes.mapPos(p,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Bt.ie||Bt.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,l=this.updateDeco(),c=E_(a,l,t.changes);return i=on.extendWithRanges(i,c),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,t.startState.doc.length,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Bt.chrome||Bt.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,a),this.flags&=-8,a&&(a.written||n.selectionRange.focusNode!=a.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(a=>a.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let a of this.children)a instanceof eo&&a.widget instanceof vd&&s.push(a.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let a=n.length-1;;a--){let l=a>=0?n[a]:null;if(!l)break;let{fromA:c,toA:u,fromB:p,toB:v}=l,x,T,M,P;if(i&&i.range.fromB<v&&i.range.toB>p){let Q=kr.build(this.view.state.doc,p,i.range.fromB,this.decorations,this.dynamicDecorationMap),tt=kr.build(this.view.state.doc,i.range.toB,v,this.decorations,this.dynamicDecorationMap);T=Q.breakAtStart,M=Q.openStart,P=tt.openEnd;let it=this.compositionView(i);tt.breakAtStart?it.breakAfter=1:tt.content.length&&it.merge(it.length,it.length,tt.content[0],!1,tt.openStart,0)&&(it.breakAfter=tt.content[0].breakAfter,tt.content.shift()),Q.content.length&&it.merge(0,0,Q.content[Q.content.length-1],!0,0,Q.openEnd)&&Q.content.pop(),x=Q.content.concat(it).concat(tt.content)}else({content:x,breakAtStart:T,openStart:M,openEnd:P}=kr.build(this.view.state.doc,p,v,this.decorations,this.dynamicDecorationMap));let{i:F,off:R}=s.findPos(u,1),{i:q,off:H}=s.findPos(c,-1);km(this,q,H,F,R,x,T,M,P)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let i of e.effects)i.is(Um)&&(this.editContextFormatting=i.value)}compositionView(t){let e=new gn(t.text.nodeValue);e.flags|=8;for(let{deco:n}of t.marks)e=new no(n,[e],e.length);let i=new Ge;return i.append(e,0),i}fixCompositionDOM(t){let e=(s,a)=>{a.flags|=8|(a.children.some(c=>c.flags&7)?1:0),this.markedForComposition.add(a);let l=Te.get(s);l&&l!=a&&(l.dom=null),a.setDOM(s)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let s=t.marks.length-1;s>=-1;s--)i=n.childPos(i.off,1),n=n.children[i.i],e(s>=0?t.marks[s].node:t.text,n)}updateSelection(t=!1,e=!1){(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&!(this.view.state.facet(to)||this.dom.tabIndex>-1)&&Xa(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let a=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,c=this.moveToLine(this.domAtPos(l.anchor)),u=l.empty?c:this.moveToLine(this.domAtPos(l.head));if(Bt.gecko&&l.empty&&!this.hasComposition&&C_(c)){let v=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(v,c.node.childNodes[c.offset]||null)),c=u=new gi(v,0),a=!0}let p=this.view.observer.selectionRange;(a||!p.focusNode||(!xr(c.node,c.offset,p.anchorNode,p.anchorOffset)||!xr(u.node,u.offset,p.focusNode,p.focusOffset))&&!this.suppressWidgetCursorChange(p,l))&&(this.view.observer.ignore(()=>{Bt.android&&Bt.chrome&&this.dom.contains(p.focusNode)&&I_(p.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let v=Ar(this.view.root);if(v)if(l.empty){if(Bt.gecko){let x=S_(c.node,c.offset);if(x&&x!=3){let T=(x==1?wm:_m)(c.node,c.offset);T&&(c=new gi(T.node,T.offset))}}v.collapse(c.node,c.offset),l.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=l.bidiLevel)}else if(v.extend){v.collapse(c.node,c.offset);try{v.extend(u.node,u.offset)}catch{}}else{let x=document.createRange();l.anchor>l.head&&([c,u]=[u,c]),x.setEnd(u.node,u.offset),x.setStart(c.node,c.offset),v.removeAllRanges(),v.addRange(x)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(c,u)),this.impreciseAnchor=c.precise?null:new gi(p.anchorNode,p.anchorOffset),this.impreciseHead=u.precise?null:new gi(p.focusNode,p.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&xr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=Ar(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let a=Ge.find(this,e.head);if(!a)return;let l=a.posAtStart;if(e.head==l||e.head==l+a.length)return;let c=this.coordsAt(e.head,-1),u=this.coordsAt(e.head,1);if(!c||!u||c.bottom>u.top)return;let p=this.domAtPos(e.head+e.assoc);i.collapse(p.node,p.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let v=t.observer.selectionRange;t.docView.posFromDOM(v.anchorNode,v.anchorOffset)!=e.from&&i.collapse(n,s)}moveToLine(t){let e=this.dom,i;if(t.node!=e)return t;for(let n=t.offset;!i&&n<e.childNodes.length;n++){let s=Te.get(e.childNodes[n]);s instanceof Ge&&(i=s.domAtPos(0))}for(let n=t.offset-1;!i&&n>=0;n--){let s=Te.get(e.childNodes[n]);s instanceof Ge&&(i=s.domAtPos(s.length))}return i?new gi(i.node,i.offset,!0):t}nearest(t){for(let e=t;e;){let i=Te.get(e);if(i&&i.rootView==this)return i;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let n=this.children[e];if(i<n.length||n instanceof Ge)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let s=this.length,a=this.children.length-1;a>=0;a--){let l=this.children[a],c=s-l.breakAfter,u=c-l.length;if(c<t)break;if(u<=t&&(u<t||l.covers(-1))&&(c>t||l.covers(1))&&(!i||l instanceof Ge&&!(i instanceof Ge&&e>=0)))i=l,n=u;else if(i&&u==t&&c==t&&l instanceof eo&&Math.abs(e)<2){if(l.deco.startSide<0)break;a&&(i=null)}s=u}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof Ge))return null;for(;n.children.length;){let{i:l,off:c}=n.childPos(i,1);for(;;l++){if(l==n.children.length)return null;if((n=n.children[l]).length)break}i=c}if(!(n instanceof gn))return null;let s=di(n.text,i);if(s==i)return null;let a=Uo(n.dom,i,s).getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(l==a.length-1||c.top<c.bottom&&c.left<c.right)return c}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,a=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,c=this.view.textDirection==Fe.LTR;for(let u=0,p=0;p<this.children.length;p++){let v=this.children[p],x=u+v.length;if(x>n)break;if(u>=i){let T=v.dom.getBoundingClientRect();if(e.push(T.height),a){let M=v.dom.lastChild,P=M?_s(M):[];if(P.length){let F=P[P.length-1],R=c?F.right-T.left:T.right-F.left;R>l&&(l=R,this.minWidth=s,this.minWidthFrom=u,this.minWidthTo=x)}}}u=x+v.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return getComputedStyle(this.children[e].dom).direction=="rtl"?Fe.RTL:Fe.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Ge){let a=s.measureTextSize();if(a)return a}let t=document.createElement("div"),e,i,n;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.dom.appendChild(t);let s=_s(t.firstChild)[0];e=t.getBoundingClientRect().height,i=s?s.width/27:7,n=s?s.height:e,t.remove()}),{lineHeight:e,charWidth:i,textHeight:n}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new xm(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let s=n==e.viewports.length?null:e.viewports[n],a=s?s.from-1:this.length;if(a>i){let l=(e.lineBlockAt(a).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(Yt.replace({widget:new vd(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,a))}if(!s)break;i=s.to+1}return Yt.set(t)}updateDeco(){let t=1,e=this.view.state.facet(Lr).map(s=>(this.dynamicDecorationMap[t++]=typeof s=="function")?s(this.view):s),i=!1,n=this.view.state.facet(qm).map((s,a)=>{let l=typeof s=="function";return l&&(i=!0),l?s(this.view):s});for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(ue.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let u=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=u.top-t.yMargin,this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let u of this.view.state.facet(Vm))try{if(u(this.view,t.range,t))return!0}catch(p){Ji(this.view.state,p,"scroll handler")}let{range:e}=t,i=this.coordsAt(e.head,e.empty?e.assoc:e.head>e.anchor?-1:1),n;if(!i)return;!e.empty&&(n=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let s=dh(this.view),a={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:c}=this.view.scrollDOM;e_(this.view.scrollDOM,a,e.head<e.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,l),-l),Math.max(Math.min(t.yMargin,c),-c),this.view.textDirection==Fe.LTR)}}function C_(o){return o.node.nodeType==1&&o.node.firstChild&&(o.offset==0||o.node.childNodes[o.offset-1].contentEditable=="false")&&(o.offset==o.node.childNodes.length||o.node.childNodes[o.offset].contentEditable=="false")}function Gm(o,t){let e=o.observer.selectionRange;if(!e.focusNode)return null;let i=wm(e.focusNode,e.focusOffset),n=_m(e.focusNode,e.focusOffset),s=i||n;if(n&&i&&n.node!=i.node){let l=Te.get(n.node);if(!l||l instanceof gn&&l.text!=n.node.nodeValue)s=n;else if(o.docView.lastCompositionAfterCursor){let c=Te.get(i.node);!c||c instanceof gn&&c.text!=i.node.nodeValue||(s=n)}}if(o.docView.lastCompositionAfterCursor=s!=i,!s)return null;let a=t-s.offset;return{from:a,to:a+s.node.nodeValue.length,node:s.node}}function $_(o,t,e){let i=Gm(o,e);if(!i)return null;let{node:n,from:s,to:a}=i,l=n.nodeValue;if(/[\n\r]/.test(l)||o.state.doc.sliceString(i.from,i.to)!=l)return null;let c=t.invertedDesc,u=new on(c.mapPos(s),c.mapPos(a),s,a),p=[];for(let v=n.parentNode;;v=v.parentNode){let x=Te.get(v);if(x instanceof no)p.push({node:v,deco:x.mark});else{if(x instanceof Ge||v.nodeName=="DIV"&&v.parentNode==o.contentDOM)return{range:u,text:n,marks:p,line:v};if(v!=o.contentDOM)p.push({node:v,deco:new Fr({inclusive:!0,attributes:h_(v),tagName:v.tagName.toLowerCase()})});else return null}}}function S_(o,t){return o.nodeType!=1?0:(t&&o.childNodes[t-1].contentEditable=="false"?1:0)|(t<o.childNodes.length&&o.childNodes[t].contentEditable=="false"?2:0)}let T_=class{constructor(){this.changes=[]}compareRange(o,t){tl(o,t,this.changes)}comparePoint(o,t){tl(o,t,this.changes)}boundChange(o){tl(o,o,this.changes)}};function E_(o,t,e){let i=new T_;return ue.compare(o,t,e,i),i.changes}function I_(o,t){for(let e=o;e&&e!=t;e=e.assignedSlot||e.parentNode)if(e.nodeType==1&&e.contentEditable=="false")return!0;return!1}function A_(o,t){let e=!1;return t&&o.iterChangedRanges((i,n)=>{i<t.to&&n>t.from&&(e=!0)}),e}function L_(o,t,e=1){let i=o.charCategorizer(t),n=o.doc.lineAt(t),s=t-n.from;if(n.length==0)return xt.cursor(t);s==0?e=1:s==n.length&&(e=-1);let a=s,l=s;e<0?a=di(n.text,s,!1):l=di(n.text,s);let c=i(n.text.slice(a,l));for(;a>0;){let u=di(n.text,a,!1);if(i(n.text.slice(u,a))!=c)break;a=u}for(;l<n.length;){let u=di(n.text,l);if(i(n.text.slice(l,u))!=c)break;l=u}return xt.range(a+n.from,l+n.from)}function N_(o,t){return t.left>o?t.left-o:Math.max(0,o-t.right)}function M_(o,t){return t.top>o?t.top-o:Math.max(0,o-t.bottom)}function Sc(o,t){return o.top<t.bottom-1&&o.bottom>t.top+1}function Gu(o,t){return t<o.top?{top:t,left:o.left,right:o.right,bottom:o.bottom}:o}function Yu(o,t){return t>o.bottom?{top:o.top,left:o.left,right:o.right,bottom:t}:o}function xd(o,t,e){let i,n,s,a,l=!1,c,u,p,v;for(let M=o.firstChild;M;M=M.nextSibling){let P=_s(M);for(let F=0;F<P.length;F++){let R=P[F];n&&Sc(n,R)&&(R=Gu(Yu(R,n.bottom),n.top));let q=N_(t,R),H=M_(e,R);if(q==0&&H==0)return M.nodeType==3?Ju(M,t,e):xd(M,t,e);(!i||a>H||a==H&&s>q)&&(i=M,n=R,s=q,a=H,l=q?t<R.left?F>0:F<P.length-1:!0),q==0?e>R.bottom&&(!p||p.bottom<R.bottom)?(c=M,p=R):e<R.top&&(!v||v.top>R.top)&&(u=M,v=R):p&&Sc(p,R)?p=Yu(p,R.bottom):v&&Sc(v,R)&&(v=Gu(v,R.top))}}if(p&&p.bottom>=e?(i=c,n=p):v&&v.top<=e&&(i=u,n=v),!i)return{node:o,offset:0};let x=Math.max(n.left,Math.min(n.right,t));if(i.nodeType==3)return Ju(i,x,e);if(l&&i.contentEditable!="false")return xd(i,x,e);let T=Array.prototype.indexOf.call(o.childNodes,i)+(t>=(n.left+n.right)/2?1:0);return{node:o,offset:T}}function Ju(o,t,e){let i=o.nodeValue.length,n=-1,s=1e9,a=0;for(let l=0;l<i;l++){let c=Uo(o,l,l+1).getClientRects();for(let u=0;u<c.length;u++){let p=c[u];if(p.top==p.bottom)continue;a||(a=t-p.left);let v=(p.top>e?p.top-e:e-p.bottom)-1;if(p.left-1<=t&&p.right+1>=t&&v<s){let x=t>=(p.left+p.right)/2,T=x;if((Bt.chrome||Bt.gecko)&&Uo(o,l).getBoundingClientRect().left==p.right&&(T=!x),v<=0)return{node:o,offset:l+(T?1:0)};n=l+(T?1:0),s=v}}}return{node:o,offset:n>-1?n:a>0?o.nodeValue.length:0}}function Ym(o,t,e,i=-1){var n,s;let a=o.contentDOM.getBoundingClientRect(),l=a.top+o.viewState.paddingTop,c,{docHeight:u}=o.viewState,{x:p,y:v}=t,x=v-l;if(x<0)return 0;if(x>u)return o.state.doc.length;for(let Q=o.viewState.heightOracle.textHeight/2,tt=!1;c=o.elementAtHeight(x),c.type!=nn.Text;)for(;x=i>0?c.bottom+Q:c.top-Q,!(x>=0&&x<=u);){if(tt)return e?null:0;tt=!0,i=-i}v=l+x;let T=c.from;if(T<o.viewport.from)return o.viewport.from==0?0:e?null:Qu(o,a,c,p,v);if(T>o.viewport.to)return o.viewport.to==o.state.doc.length?o.state.doc.length:e?null:Qu(o,a,c,p,v);let M=o.dom.ownerDocument,P=o.root.elementFromPoint?o.root:M,F=P.elementFromPoint(p,v);F&&!o.contentDOM.contains(F)&&(F=null),F||(p=Math.max(a.left+1,Math.min(a.right-1,p)),F=P.elementFromPoint(p,v),F&&!o.contentDOM.contains(F)&&(F=null));let R,q=-1;if(F&&((n=o.docView.nearest(F))===null||n===void 0?void 0:n.isEditable)!=!1){if(M.caretPositionFromPoint){let Q=M.caretPositionFromPoint(p,v);Q&&({offsetNode:R,offset:q}=Q)}else if(M.caretRangeFromPoint){let Q=M.caretRangeFromPoint(p,v);Q&&({startContainer:R,startOffset:q}=Q,(!o.contentDOM.contains(R)||Bt.safari&&P_(R,q,p)||Bt.chrome&&O_(R,q,p))&&(R=void 0))}R&&(q=Math.min(Dn(R),q))}if(!R||!o.docView.dom.contains(R)){let Q=Ge.find(o.docView,T);if(!Q)return x>c.top+c.height/2?c.to:c.from;({node:R,offset:q}=xd(Q.dom,p,v))}let H=o.docView.nearest(R);if(!H)return null;if(H.isWidget&&((s=H.dom)===null||s===void 0?void 0:s.nodeType)==1){let Q=H.dom.getBoundingClientRect();return t.y<Q.top||t.y<=Q.bottom&&t.x<=(Q.left+Q.right)/2?H.posAtStart:H.posAtEnd}else return H.localPosFromDOM(R,q)+H.posAtStart}function Qu(o,t,e,i,n){let s=Math.round((i-t.left)*o.defaultCharacterWidth);if(o.lineWrapping&&e.height>o.defaultLineHeight*1.5){let l=o.viewState.heightOracle.textHeight,c=Math.floor((n-e.top-(o.defaultLineHeight-l)*.5)/l);s+=c*o.viewState.heightOracle.lineLength}let a=o.state.sliceDoc(e.from,e.to);return e.from+Gw(a,s,o.state.tabSize)}function P_(o,t,e){let i,n=o;if(o.nodeType!=3||t!=(i=o.nodeValue.length))return!1;for(;;){let s=n.nextSibling;if(s){if(s.nodeName=="BR")break;return!1}else{let a=n.parentNode;if(!a||a.nodeName=="DIV")break;n=a}}return Uo(o,i-1,i).getBoundingClientRect().right>e}function O_(o,t,e){if(t!=0)return!1;for(let n=o;;){let s=n.parentNode;if(!s||s.nodeType!=1||s.firstChild!=n)return!1;if(s.classList.contains("cm-line"))break;n=s}let i=o.nodeType==1?o.getBoundingClientRect():Uo(o,0,Math.max(o.nodeValue.length,1)).getBoundingClientRect();return e-i.left>5}function D_(o,t,e){let i=o.lineBlockAt(t);if(Array.isArray(i.type)){let n;for(let s of i.type){if(s.from>t)break;if(!(s.to<t)){if(s.from<t&&s.to>t)return s;(!n||s.type==nn.Text&&(n.type!=s.type||(e<0?s.from<t:s.to>t)))&&(n=s)}}return n||i}return i}function R_(o,t,e,i){let n=D_(o,t.head,t.assoc||-1),s=!i||n.type!=nn.Text||!(o.lineWrapping||n.widgetLineBreaks)?null:o.coordsAtPos(t.assoc<0&&t.head>n.from?t.head-1:t.head);if(s){let a=o.dom.getBoundingClientRect(),l=o.textDirectionAt(n.from),c=o.posAtCoords({x:e==(l==Fe.LTR)?a.right-1:a.left+1,y:(s.top+s.bottom)/2});if(c!=null)return xt.cursor(c,e?-1:1)}return xt.cursor(e?n.to:n.from,e?-1:1)}function Xu(o,t,e,i){let n=o.state.doc.lineAt(t.head),s=o.bidiSpans(n),a=o.textDirectionAt(n.from);for(let l=t,c=null;;){let u=w_(n,s,a,l,e),p=Om;if(!u){if(n.number==(e?o.state.doc.lines:1))return l;p=`
|
||
`,n=o.state.doc.line(n.number+(e?1:-1)),s=o.bidiSpans(n),u=o.visualLineSide(n,!e)}if(c){if(!c(p))return l}else{if(!i)return u;c=i(p)}l=u}}function B_(o,t,e){let i=o.state.charCategorizer(t),n=i(e);return s=>{let a=i(s);return n==Ve.Space&&(n=a),n==a}}function z_(o,t,e,i){let n=t.head,s=e?1:-1;if(n==(e?o.state.doc.length:0))return xt.cursor(n,t.assoc);let a=t.goalColumn,l,c=o.contentDOM.getBoundingClientRect(),u=o.coordsAtPos(n,t.assoc||-1),p=o.documentTop;if(u)a==null&&(a=u.left-c.left),l=s<0?u.top:u.bottom;else{let T=o.viewState.lineBlockAt(n);a==null&&(a=Math.min(c.right-c.left,o.defaultCharacterWidth*(n-T.from))),l=(s<0?T.top:T.bottom)+p}let v=c.left+a,x=i??o.viewState.heightOracle.textHeight>>1;for(let T=0;;T+=10){let M=l+(x+T)*s,P=Ym(o,{x:v,y:M},!1,s);if(M<c.top||M>c.bottom||(s<0?P<n:P>n)){let F=o.docView.coordsForChar(P),R=!F||M<F.top?-1:1;return xt.cursor(P,R,void 0,a)}}}function el(o,t,e){for(;;){let i=0;for(let n of o)n.between(t-1,t+1,(s,a,l)=>{if(t>s&&t<a){let c=i||e||(t-s<a-t?-1:1);t=c<0?s:a,i=c}});if(!i)return t}}function Tc(o,t,e){let i=el(o.state.facet(ch).map(n=>n(o)),e.from,t.head>e.from?-1:1);return i==e.from?e:xt.cursor(i,i<e.from?1:-1)}const pr="";class F_{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(ve.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=pr}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let s=this.text.length;this.readNode(n);let a=n.nextSibling;if(a==e)break;let l=Te.get(n),c=Te.get(a);(l&&c?l.breakAfter:(l?l.breakAfter:pl(n))||pl(a)&&(n.nodeName!="BR"||n.cmIgnore)&&this.text.length>s)&&this.lineBreak(),n=a}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,a=1,l;if(this.lineSeparator?(s=e.indexOf(this.lineSeparator,i),a=this.lineSeparator.length):(l=n.exec(e))&&(s=l.index,a=l[0].length),this.append(e.slice(i,s<0?e.length:s)),s<0)break;if(this.lineBreak(),a>1)for(let c of this.points)c.node==t&&c.pos>this.text.length&&(c.pos-=a-1);i=s+a}}readNode(t){if(t.cmIgnore)return;let e=Te.get(t),i=e&&e.overrideDOMText;if(i!=null){this.findPointInside(t,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(t.nodeType==3?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(W_(t,i.node,i.offset)?e:0))}}function W_(o,t,e){for(;;){if(!t||e<Dn(t))return!1;if(t==o)return!0;e=Vo(t)+1,t=t.parentNode}}class tp{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class H_{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:s,impreciseAnchor:a}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let l=s||a?[]:j_(t),c=new F_(l,t.state);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=q_(l,this.bounds.from)}else{let l=t.observer.selectionRange,c=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!hd(t.contentDOM,l.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(l.focusNode,l.focusOffset),u=a&&a.node==l.anchorNode&&a.offset==l.anchorOffset||!hd(t.contentDOM,l.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(l.anchorNode,l.anchorOffset),p=t.viewport;if((Bt.ios||Bt.chrome)&&t.state.selection.main.empty&&c!=u&&(p.from>0||p.to<t.state.doc.length)){let v=Math.min(c,u),x=Math.max(c,u),T=p.from-v,M=p.to-x;(T==0||T==1||v==0)&&(M==0||M==-1||x==t.state.doc.length)&&(c=0,u=t.state.doc.length)}this.newSel=xt.single(u,c)}}}function Jm(o,t){let e,{newSel:i}=t,n=o.state.selection.main,s=o.inputState.lastKeyTime>Date.now()-100?o.inputState.lastKeyCode:-1;if(t.bounds){let{from:a,to:l}=t.bounds,c=n.from,u=null;(s===8||Bt.android&&t.text.length<l-a)&&(c=n.to,u="end");let p=U_(o.state.doc.sliceString(a,l,pr),t.text,c-a,u);p&&(Bt.chrome&&s==13&&p.toB==p.from+2&&t.text.slice(p.from,p.toB)==pr+pr&&p.toB--,e={from:a+p.from,to:a+p.toA,insert:ye.of(t.text.slice(p.from,p.toB).split(pr))})}else i&&(!o.hasFocus&&o.state.facet(to)||i.main.eq(n))&&(i=null);if(!e&&!i)return!1;if(!e&&t.typeOver&&!n.empty&&i&&i.main.empty?e={from:n.from,to:n.to,insert:o.state.doc.slice(n.from,n.to)}:(Bt.mac||Bt.android)&&e&&e.from==e.to&&e.from==n.head-1&&/^\. ?$/.test(e.insert.toString())&&o.contentDOM.getAttribute("autocorrect")=="off"?(i&&e.insert.length==2&&(i=xt.single(i.main.anchor-1,i.main.head-1)),e={from:e.from,to:e.to,insert:ye.of([e.insert.toString().replace("."," ")])}):e&&e.from>=n.from&&e.to<=n.to&&(e.from!=n.from||e.to!=n.to)&&n.to-n.from-(e.to-e.from)<=4?e={from:n.from,to:n.to,insert:o.state.doc.slice(n.from,e.from).append(e.insert).append(o.state.doc.slice(e.to,n.to))}:Bt.chrome&&e&&e.from==e.to&&e.from==n.head&&e.insert.toString()==`
|
||
`&&o.lineWrapping&&(i&&(i=xt.single(i.main.anchor-1,i.main.head-1)),e={from:n.from,to:n.to,insert:ye.of([" "])}),e)return hh(o,e,i,s);if(i&&!i.main.eq(n)){let a=!1,l="select";return o.inputState.lastSelectionTime>Date.now()-50&&(o.inputState.lastSelectionOrigin=="select"&&(a=!0),l=o.inputState.lastSelectionOrigin),o.dispatch({selection:i,scrollIntoView:a,userEvent:l}),!0}else return!1}function hh(o,t,e,i=-1){if(Bt.ios&&o.inputState.flushIOSKey(t))return!0;let n=o.state.selection.main;if(Bt.android&&(t.to==n.to&&(t.from==n.from||t.from==n.from-1&&o.state.sliceDoc(t.from,n.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&gs(o.contentDOM,"Enter",13)||(t.from==n.from-1&&t.to==n.to&&t.insert.length==0||i==8&&t.insert.length<t.to-t.from&&t.to>n.head)&&gs(o.contentDOM,"Backspace",8)||t.from==n.from&&t.to==n.to+1&&t.insert.length==0&&gs(o.contentDOM,"Delete",46)))return!0;let s=t.insert.toString();o.inputState.composing>=0&&o.inputState.composing++;let a,l=()=>a||(a=V_(o,t,e));return o.state.facet(Fm).some(c=>c(o,t.from,t.to,s,l))||o.dispatch(l()),!0}function V_(o,t,e){let i,n=o.state,s=n.selection.main;if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!e||e.main.empty&&e.main.from==t.from+t.insert.length)&&o.inputState.composing<0){let l=s.from<t.from?n.sliceDoc(s.from,t.from):"",c=s.to>t.to?n.sliceDoc(t.to,s.to):"";i=n.replaceSelection(o.state.toText(l+t.insert.sliceString(0,void 0,o.state.lineBreak)+c))}else{let l=n.changes(t),c=e&&e.main.to<=l.newLength?e.main:void 0;if(n.selection.ranges.length>1&&o.inputState.composing>=0&&t.to<=s.to&&t.to>=s.to-10){let u=o.state.sliceDoc(t.from,t.to),p,v=e&&Gm(o,e.main.head);if(v){let M=t.insert.length-(t.to-t.from);p={from:v.from,to:v.to-M}}else p=o.state.doc.lineAt(s.head);let x=s.to-t.to,T=s.to-s.from;i=n.changeByRange(M=>{if(M.from==s.from&&M.to==s.to)return{changes:l,range:c||M.map(l)};let P=M.to-x,F=P-u.length;if(M.to-M.from!=T||o.state.sliceDoc(F,P)!=u||M.to>=p.from&&M.from<=p.to)return{range:M};let R=n.changes({from:F,to:P,insert:t.insert}),q=M.to-s.to;return{changes:R,range:c?xt.range(Math.max(0,c.anchor+q),Math.max(0,c.head+q)):M.map(R)}})}else i={changes:l,selection:c&&n.selection.replaceRange(c)}}let a="input.type";return(o.composing||o.inputState.compositionPendingChange&&o.inputState.compositionEndedAt>Date.now()-50)&&(o.inputState.compositionPendingChange=!1,a+=".compose",o.inputState.compositionFirstChange&&(a+=".start",o.inputState.compositionFirstChange=!1)),n.update(i,{userEvent:a,scrollIntoView:!0})}function U_(o,t,e,i){let n=Math.min(o.length,t.length),s=0;for(;s<n&&o.charCodeAt(s)==t.charCodeAt(s);)s++;if(s==n&&o.length==t.length)return null;let a=o.length,l=t.length;for(;a>0&&l>0&&o.charCodeAt(a-1)==t.charCodeAt(l-1);)a--,l--;if(i=="end"){let c=Math.max(0,s-Math.min(a,l));e-=a+c-s}if(a<s&&o.length<t.length){let c=e<=s&&e>=a?s-e:0;s-=c,l=s+(l-a),a=s}else if(l<s){let c=e<=s&&e>=l?s-e:0;s-=c,a=s+(a-l),l=s}return{from:s,toA:a,toB:l}}function j_(o){let t=[];if(o.root.activeElement!=o.contentDOM)return t;let{anchorNode:e,anchorOffset:i,focusNode:n,focusOffset:s}=o.observer.selectionRange;return e&&(t.push(new tp(e,i)),(n!=e||s!=i)&&t.push(new tp(n,s))),t}function q_(o,t){if(o.length==0)return null;let e=o[0].pos,i=o.length==2?o[1].pos:e;return e>-1&&i>-1?xt.single(e+t,i+t):null}class K_{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,Bt.safari&&t.contentDOM.addEventListener("input",()=>null),Bt.gecko&&cx(t.contentDOM.ownerDocument)}handleEvent(t){!ex(this.view,t)||this.ignoreDuringComposition(t)||t.type=="keydown"&&this.keydown(t)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let n of i.observers)n(this.view,e);for(let n of i.handlers){if(e.defaultPrevented)break;if(n(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=Z_(t),i=this.handlers,n=this.view.contentDOM;for(let s in e)if(s!="scroll"){let a=!e[s].handlers.length,l=i[s];l&&a!=!l.handlers.length&&(n.removeEventListener(s,this.handleEvent),l=null),l||n.addEventListener(s,this.handleEvent,{passive:a})}for(let s in i)s!="scroll"&&!e[s]&&n.removeEventListener(s,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&t.keyCode!=27&&Xm.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),Bt.android&&Bt.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return Bt.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((e=Qm.find(i=>i.keyCode==t.keyCode))&&!t.ctrlKey||G_.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0):(t.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(t){let e=this.pendingIOSKey;return!e||e.key=="Enter"&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString())?!1:(this.pendingIOSKey=void 0,gs(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0))}ignoreDuringComposition(t){return/^key/.test(t.type)?this.composing>0?!0:Bt.safari&&!Bt.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function ep(o,t){return(e,i)=>{try{return t.call(o,i,e)}catch(n){Ji(e.state,n)}}}function Z_(o){let t=Object.create(null);function e(i){return t[i]||(t[i]={observers:[],handlers:[]})}for(let i of o){let n=i.spec,s=n&&n.plugin.domEventHandlers,a=n&&n.plugin.domEventObservers;if(s)for(let l in s){let c=s[l];c&&e(l).handlers.push(ep(i.value,c))}if(a)for(let l in a){let c=a[l];c&&e(l).observers.push(ep(i.value,c))}}for(let i in vn)e(i).handlers.push(vn[i]);for(let i in sn)e(i).observers.push(sn[i]);return t}const Qm=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],G_="dthko",Xm=[16,17,18,20,91,92,224,225],Ca=6;function $a(o){return Math.max(0,o)*.7+8}function Y_(o,t){return Math.max(Math.abs(o.clientX-t.clientX),Math.abs(o.clientY-t.clientY))}class J_{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=i_(t.contentDOM),this.atoms=t.state.facet(ch).map(a=>a(t));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(ve.allowMultipleSelections)&&Q_(t,e),this.dragging=tx(t,e)&&ig(e)==1?null:!1}start(t){this.dragging===!1&&this.select(t)}move(t){if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Y_(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let e=0,i=0,n=0,s=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=dh(this.view);t.clientX-c.left<=n+Ca?e=-$a(n-t.clientX):t.clientX+c.right>=a-Ca&&(e=$a(t.clientX-a)),t.clientY-c.top<=s+Ca?i=-$a(s-t.clientY):t.clientY+c.bottom>=l-Ca&&(i=$a(t.clientY-l)),this.setScrollSpeed(e,i)}up(t){this.dragging==null&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let a=el(this.atoms,n.from,0);a!=n.from&&(s=xt.cursor(a,-1))}else{let a=el(this.atoms,n.from,-1),l=el(this.atoms,n.to,1);(a!=n.from||l!=n.to)&&(s=xt.range(n.from==n.anchor?a:l,n.from==n.head?a:l))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?xt.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));(this.mustSelect||!i.eq(e.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}function Q_(o,t){let e=o.state.facet(Dm);return e.length?e[0](t):Bt.mac?t.metaKey:t.ctrlKey}function X_(o,t){let e=o.state.facet(Rm);return e.length?e[0](t):Bt.mac?!t.altKey:!t.ctrlKey}function tx(o,t){let{main:e}=o.state.selection;if(e.empty)return!1;let i=Ar(o.root);if(!i||i.rangeCount==0)return!0;let n=i.getRangeAt(0).getClientRects();for(let s=0;s<n.length;s++){let a=n[s];if(a.left<=t.clientX&&a.right>=t.clientX&&a.top<=t.clientY&&a.bottom>=t.clientY)return!0}return!1}function ex(o,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target,i;e!=o.contentDOM;e=e.parentNode)if(!e||e.nodeType==11||(i=Te.get(e))&&i.ignoreEvent(t))return!1;return!0}const vn=Object.create(null),sn=Object.create(null),tg=Bt.ie&&Bt.ie_version<15||Bt.ios&&Bt.webkit_version<604;function ix(o){let t=o.dom.parentNode;if(!t)return;let e=t.appendChild(document.createElement("textarea"));e.style.cssText="position: fixed; left: -10000px; top: 10px",e.focus(),setTimeout(()=>{o.focus(),e.remove(),eg(o,e.value)},50)}function Rl(o,t,e){for(let i of o.facet(t))e=i(e,o);return e}function eg(o,t){t=Rl(o.state,rh,t);let{state:e}=o,i,n=1,s=e.toText(t),a=s.lines==e.selection.ranges.length;if(kd!=null&&e.selection.ranges.every(l=>l.empty)&&kd==s.toString()){let l=-1;i=e.changeByRange(c=>{let u=e.doc.lineAt(c.from);if(u.from==l)return{range:c};l=u.from;let p=e.toText((a?s.line(n++).text:t)+e.lineBreak);return{changes:{from:u.from,insert:p},range:xt.cursor(c.from+p.length)}})}else a?i=e.changeByRange(l=>{let c=s.line(n++);return{changes:{from:l.from,to:l.to,insert:c.text},range:xt.cursor(l.from+c.length)}}):i=e.replaceSelection(s);o.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}sn.scroll=o=>{o.inputState.lastScrollTop=o.scrollDOM.scrollTop,o.inputState.lastScrollLeft=o.scrollDOM.scrollLeft};vn.keydown=(o,t)=>(o.inputState.setSelectionOrigin("select"),t.keyCode==27&&o.inputState.tabFocusMode!=0&&(o.inputState.tabFocusMode=Date.now()+2e3),!1);sn.touchstart=(o,t)=>{o.inputState.lastTouchTime=Date.now(),o.inputState.setSelectionOrigin("select.pointer")};sn.touchmove=o=>{o.inputState.setSelectionOrigin("select.pointer")};vn.mousedown=(o,t)=>{if(o.observer.flush(),o.inputState.lastTouchTime>Date.now()-2e3)return!1;let e=null;for(let i of o.state.facet(Bm))if(e=i(o,t),e)break;if(!e&&t.button==0&&(e=sx(o,t)),e){let i=!o.hasFocus;o.inputState.startMouseSelection(new J_(o,t,e,i)),i&&o.observer.ignore(()=>{vm(o.contentDOM);let s=o.root.activeElement;s&&!s.contains(o.contentDOM)&&s.blur()});let n=o.inputState.mouseSelection;if(n)return n.start(t),n.dragging===!1}return!1};function ip(o,t,e,i){if(i==1)return xt.cursor(t,e);if(i==2)return L_(o.state,t,e);{let n=Ge.find(o.docView,t),s=o.state.doc.lineAt(n?n.posAtEnd:t),a=n?n.posAtStart:s.from,l=n?n.posAtEnd:s.to;return l<o.state.doc.length&&l==s.to&&l++,xt.range(a,l)}}let np=(o,t,e)=>t>=e.top&&t<=e.bottom&&o>=e.left&&o<=e.right;function nx(o,t,e,i){let n=Ge.find(o.docView,t);if(!n)return 1;let s=t-n.posAtStart;if(s==0)return 1;if(s==n.length)return-1;let a=n.coordsAt(s,-1);if(a&&np(e,i,a))return-1;let l=n.coordsAt(s,1);return l&&np(e,i,l)?1:a&&a.bottom>=i?-1:1}function op(o,t){let e=o.posAtCoords({x:t.clientX,y:t.clientY},!1);return{pos:e,bias:nx(o,e,t.clientX,t.clientY)}}const ox=Bt.ie&&Bt.ie_version<=11;let sp=null,rp=0,ap=0;function ig(o){if(!ox)return o.detail;let t=sp,e=ap;return sp=o,ap=Date.now(),rp=!t||e>Date.now()-400&&Math.abs(t.clientX-o.clientX)<2&&Math.abs(t.clientY-o.clientY)<2?(rp+1)%3:1}function sx(o,t){let e=op(o,t),i=ig(t),n=o.state.selection;return{update(s){s.docChanged&&(e.pos=s.changes.mapPos(e.pos),n=n.map(s.changes))},get(s,a,l){let c=op(o,s),u,p=ip(o,c.pos,c.bias,i);if(e.pos!=c.pos&&!a){let v=ip(o,e.pos,e.bias,i),x=Math.min(v.from,p.from),T=Math.max(v.to,p.to);p=x<p.from?xt.range(x,T):xt.range(T,x)}return a?n.replaceRange(n.main.extend(p.from,p.to)):l&&i==1&&n.ranges.length>1&&(u=rx(n,c.pos))?u:l?n.addRange(p):xt.create([p])}}}function rx(o,t){for(let e=0;e<o.ranges.length;e++){let{from:i,to:n}=o.ranges[e];if(i<=t&&n>=t)return xt.create(o.ranges.slice(0,e).concat(o.ranges.slice(e+1)),o.mainIndex==e?0:o.mainIndex-(o.mainIndex>e?1:0))}return null}vn.dragstart=(o,t)=>{let{selection:{main:e}}=o.state;if(t.target.draggable){let n=o.docView.nearest(t.target);if(n&&n.isWidget){let s=n.posAtStart,a=s+n.length;(s>=e.to||a<=e.from)&&(e=xt.range(s,a))}}let{inputState:i}=o;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=e,t.dataTransfer&&(t.dataTransfer.setData("Text",Rl(o.state,ah,o.state.sliceDoc(e.from,e.to))),t.dataTransfer.effectAllowed="copyMove"),!1};vn.dragend=o=>(o.inputState.draggedContent=null,!1);function lp(o,t,e,i){if(e=Rl(o.state,rh,e),!e)return;let n=o.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:s}=o.inputState,a=i&&s&&X_(o,t)?{from:s.from,to:s.to}:null,l={from:n,insert:e},c=o.state.changes(a?[a,l]:l);o.focus(),o.dispatch({changes:c,selection:{anchor:c.mapPos(n,-1),head:c.mapPos(n,1)},userEvent:a?"move.drop":"input.drop"}),o.inputState.draggedContent=null}vn.drop=(o,t)=>{if(!t.dataTransfer)return!1;if(o.state.readOnly)return!0;let e=t.dataTransfer.files;if(e&&e.length){let i=Array(e.length),n=0,s=()=>{++n==e.length&&lp(o,t,i.filter(a=>a!=null).join(o.state.lineBreak),!1)};for(let a=0;a<e.length;a++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[a]=l.result),s()},l.readAsText(e[a])}return!0}else{let i=t.dataTransfer.getData("Text");if(i)return lp(o,t,i,!0),!0}return!1};vn.paste=(o,t)=>{if(o.state.readOnly)return!0;o.observer.flush();let e=tg?null:t.clipboardData;return e?(eg(o,e.getData("text/plain")||e.getData("text/uri-list")),!0):(ix(o),!1)};function ax(o,t){let e=o.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),o.focus()},50)}function lx(o){let t=[],e=[],i=!1;for(let n of o.selection.ranges)n.empty||(t.push(o.sliceDoc(n.from,n.to)),e.push(n));if(!t.length){let n=-1;for(let{from:s}of o.selection.ranges){let a=o.doc.lineAt(s);a.number>n&&(t.push(a.text),e.push({from:a.from,to:Math.min(o.doc.length,a.to+1)})),n=a.number}i=!0}return{text:Rl(o,ah,t.join(o.lineBreak)),ranges:e,linewise:i}}let kd=null;vn.copy=vn.cut=(o,t)=>{let{text:e,ranges:i,linewise:n}=lx(o.state);if(!e&&!n)return!1;kd=n?e:null,t.type=="cut"&&!o.state.readOnly&&o.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=tg?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",e),!0):(ax(o,e),!1)};const ng=To.define();function og(o,t){let e=[];for(let i of o.facet(Wm)){let n=i(o,t);n&&e.push(n)}return e.length?o.update({effects:e,annotations:ng.of(!0)}):null}function sg(o){setTimeout(()=>{let t=o.hasFocus;if(t!=o.inputState.notifiedFocused){let e=og(o.state,t);e?o.dispatch(e):o.update([])}},10)}sn.focus=o=>{o.inputState.lastFocusTime=Date.now(),!o.scrollDOM.scrollTop&&(o.inputState.lastScrollTop||o.inputState.lastScrollLeft)&&(o.scrollDOM.scrollTop=o.inputState.lastScrollTop,o.scrollDOM.scrollLeft=o.inputState.lastScrollLeft),sg(o)};sn.blur=o=>{o.observer.clearSelectionRange(),sg(o)};sn.compositionstart=sn.compositionupdate=o=>{o.observer.editContext||(o.inputState.compositionFirstChange==null&&(o.inputState.compositionFirstChange=!0),o.inputState.composing<0&&(o.inputState.composing=0))};sn.compositionend=o=>{o.observer.editContext||(o.inputState.composing=-1,o.inputState.compositionEndedAt=Date.now(),o.inputState.compositionPendingKey=!0,o.inputState.compositionPendingChange=o.observer.pendingRecords().length>0,o.inputState.compositionFirstChange=null,Bt.chrome&&Bt.android?o.observer.flushSoon():o.inputState.compositionPendingChange?Promise.resolve().then(()=>o.observer.flush()):setTimeout(()=>{o.inputState.composing<0&&o.docView.hasComposition&&o.update([])},50))};sn.contextmenu=o=>{o.inputState.lastContextMenu=Date.now()};vn.beforeinput=(o,t)=>{var e,i;if(t.inputType=="insertReplacementText"&&o.observer.editContext){let s=(e=t.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain"),a=t.getTargetRanges();if(s&&a.length){let l=a[0],c=o.posAtDOM(l.startContainer,l.startOffset),u=o.posAtDOM(l.endContainer,l.endOffset);return hh(o,{from:c,to:u,insert:o.state.toText(s)},null),!0}}let n;if(Bt.chrome&&Bt.android&&(n=Qm.find(s=>s.inputType==t.inputType))&&(o.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var a;(((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0)>s+10&&o.hasFocus&&(o.contentDOM.blur(),o.focus())},100)}return Bt.ios&&t.inputType=="deleteContentForward"&&o.observer.flushSoon(),Bt.safari&&t.inputType=="insertText"&&o.inputState.composing>=0&&setTimeout(()=>sn.compositionend(o,t),20),!1};const cp=new Set;function cx(o){cp.has(o)||(cp.add(o),o.addEventListener("copy",()=>{}),o.addEventListener("cut",()=>{}))}const dp=["pre-wrap","normal","pre-line","break-spaces"];let Cs=!1;function hp(){Cs=!1}class dx{constructor(t){this.lineWrapping=t,this.doc=ye.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return dp.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(n*10)]||(e=!0,this.heightSamples[Math.floor(n*10)]=!0)}return e}refresh(t,e,i,n,s,a){let l=dp.indexOf(t)>-1,c=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,c){this.heightSamples={};for(let u=0;u<a.length;u++){let p=a[u];p<0?u++:this.heightSamples[Math.floor(p*10)]=!0}}return c}}class hx{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class In{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return typeof this._content=="number"?nn.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 Co?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new In(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var Ne=function(o){return o[o.ByPos=0]="ByPos",o[o.ByHeight=1]="ByHeight",o[o.ByPosNoHeight=2]="ByPosNoHeight",o}(Ne||(Ne={}));const il=.001;class ki{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>il&&(Cs=!0),this.height=t)}replace(t,e,i){return ki.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,a=i.doc;for(let l=n.length-1;l>=0;l--){let{fromA:c,toA:u,fromB:p,toB:v}=n[l],x=s.lineAt(c,Ne.ByPosNoHeight,i.setDoc(e),0,0),T=x.to>=u?x:s.lineAt(u,Ne.ByPosNoHeight,i,0,0);for(v+=T.to-u,u=T.to;l>0&&x.from<=n[l-1].toA;)c=n[l-1].fromA,p=n[l-1].fromB,l--,c<x.from&&(x=s.lineAt(c,Ne.ByPosNoHeight,i,0,0));p+=x.from-c,c=x.from;let M=uh.build(i.setDoc(a),t,p,v);s=gl(s,s.replace(c,u,M))}return s.updateHeight(i,0)}static empty(){return new Ri(0,0)}static of(t){if(t.length==1)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>s*2){let l=t[e-1];l.break?t.splice(--e,1,l.left,null,l.right):t.splice(--e,1,l.left,l.right),i+=1+l.break,n-=l.size}else if(s>n*2){let l=t[i];l.break?t.splice(i,1,l.left,null,l.right):t.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(n<s){let l=t[e++];l&&(n+=l.size)}else{let l=t[--i];l&&(s+=l.size)}let a=0;return t[e-1]==null?(a=1,e--):t[e]==null&&(a=1,i++),new ux(ki.of(t.slice(0,e)),a,ki.of(t.slice(i)))}}function gl(o,t){return o==t?o:(o.constructor!=t.constructor&&(Cs=!0),t)}ki.prototype.size=1;class rg extends ki{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new In(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,a){t<=s+this.length&&e>=s&&a(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Ri extends rg{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new In(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return i.length==1&&(n instanceof Ri||n instanceof ai&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof ai?n=new Ri(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):ki.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(n.heights[n.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ai extends ki{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,n=t.doc.lineAt(e+this.length).number,s=n-i+1,a,l=0;if(t.lineWrapping){let c=Math.min(this.height,t.lineHeight*s);a=c/s,this.length>s+1&&(l=(this.height-c)/(this.length-s-1))}else a=this.height/s;return{firstLine:i,lastLine:n,perLine:a,perChar:l}}blockAt(t,e,i,n){let{firstLine:s,lastLine:a,perLine:l,perChar:c}=this.heightMetrics(e,n);if(e.lineWrapping){let u=n+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),p=e.doc.lineAt(u),v=l+p.length*c,x=Math.max(i,t-v/2);return new In(p.from,p.length,x,v,0)}else{let u=Math.max(0,Math.min(a-s,Math.floor((t-i)/l))),{from:p,length:v}=e.doc.line(s+u);return new In(p,v,i+l*u,l,0)}}lineAt(t,e,i,n,s){if(e==Ne.ByHeight)return this.blockAt(t,i,n,s);if(e==Ne.ByPosNoHeight){let{from:T,to:M}=i.doc.lineAt(t);return new In(T,M-T,0,0,0)}let{firstLine:a,perLine:l,perChar:c}=this.heightMetrics(i,s),u=i.doc.lineAt(t),p=l+u.length*c,v=u.number-a,x=n+l*v+c*(u.from-s-v);return new In(u.from,u.length,Math.max(n,Math.min(x,n+this.height-p)),p,0)}forEachLine(t,e,i,n,s,a){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:l,perLine:c,perChar:u}=this.heightMetrics(i,s);for(let p=t,v=n;p<=e;){let x=i.doc.lineAt(p);if(p==t){let M=x.number-l;v+=c*M+u*(t-s-M)}let T=c+u*x.length;a(new In(x.from,x.length,v,T,0)),v+=T,p=x.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let s=i[i.length-1];s instanceof ai?i[i.length-1]=new ai(s.length+n):i.push(null,new ai(n-1))}if(t>0){let s=i[0];s instanceof ai?i[0]=new ai(t+s.length):i.unshift(new ai(t-1),null)}return ki.of(i)}decomposeLeft(t,e){e.push(new ai(t-1),null)}decomposeRight(t,e){e.push(null,new ai(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let a=[],l=Math.max(e,n.from),c=-1;for(n.from>e&&a.push(new ai(n.from-e-1).updateHeight(t,e));l<=s&&n.more;){let p=t.doc.lineAt(l).length;a.length&&a.push(null);let v=n.heights[n.index++];c==-1?c=v:Math.abs(v-c)>=il&&(c=-2);let x=new Ri(p,v);x.outdated=!1,a.push(x),l+=p+1}l<=s&&a.push(null,new ai(s-l).updateHeight(t,l));let u=ki.of(a);return(c<0||Math.abs(u.height-this.height)>=il||Math.abs(c-this.heightMetrics(t,e).perLine)>=il)&&(Cs=!0),gl(this,u)}else(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class ux extends ki{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return this.flags&1}blockAt(t,e,i,n){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let a=n+this.left.height,l=s+this.left.length+this.break,c=e==Ne.ByHeight?t<a:t<l,u=c?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,a,l);if(this.break||(c?u.to<l:u.from>l))return u;let p=e==Ne.ByPosNoHeight?Ne.ByPosNoHeight:Ne.ByPos;return c?u.join(this.right.lineAt(l,p,i,a,l)):this.left.lineAt(l,p,i,n,s).join(u)}forEachLine(t,e,i,n,s,a){let l=n+this.left.height,c=s+this.left.length+this.break;if(this.break)t<c&&this.left.forEachLine(t,e,i,n,s,a),e>=c&&this.right.forEachLine(t,e,i,l,c,a);else{let u=this.lineAt(c,Ne.ByPos,i,n,s);t<u.from&&this.left.forEachLine(t,u.from-1,i,n,s,a),u.to>=t&&u.from<=e&&a(u),e>u.to&&this.right.forEachLine(u.to+1,e,i,l,c,a)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let a=s.length;for(let l of i)s.push(l);if(t>0&&up(s,a-1),e<this.length){let l=s.length;this.decomposeRight(e,s),up(s,l)}return ki.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?ki.of(this.break?[t,null,e]:[t,e]):(this.left=gl(this.left,t),this.right=gl(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:s,right:a}=this,l=e+s.length+this.break,c=null;return n&&n.from<=e+s.length&&n.more?c=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=l+a.length&&n.more?c=a=a.updateHeight(t,l,i,n):a.updateHeight(t,l,i),c?this.balanced(s,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function up(o,t){let e,i;o[t]==null&&(e=o[t-1])instanceof ai&&(i=o[t+1])instanceof ai&&o.splice(t-1,3,new ai(e.length+1+i.length))}const px=5;class uh{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let i=Math.min(e,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof Ri?n.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Ri(i-this.pos,-1)),this.writtenTo=i,e>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let a=e-t;i.block?this.addBlock(new rg(a,n,i)):(a||s||n>=px)&&this.addLineDeco(n,s,a)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new Ri(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new ai(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof Ri)return t;let e=new Ri(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(e instanceof Ri)&&!this.isCovered?this.nodes.push(new Ri(0,-1)):(this.writtenTo<this.pos||e==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=t;for(let n of this.nodes)n instanceof Ri&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(t,e,i,n){let s=new uh(i,t);return ue.spans(e,i,n,s,0),s.finish(i)}}function fx(o,t,e){let i=new mx;return ue.compare(o,t,e,i,0),i.changes}class mx{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&tl(t,e,this.changes,5)}}function gx(o,t){let e=o.getBoundingClientRect(),i=o.ownerDocument,n=i.defaultView||window,s=Math.max(0,e.left),a=Math.min(n.innerWidth,e.right),l=Math.max(0,e.top),c=Math.min(n.innerHeight,e.bottom);for(let u=o.parentNode;u&&u!=i.body;)if(u.nodeType==1){let p=u,v=window.getComputedStyle(p);if((p.scrollHeight>p.clientHeight||p.scrollWidth>p.clientWidth)&&v.overflow!="visible"){let x=p.getBoundingClientRect();s=Math.max(s,x.left),a=Math.min(a,x.right),l=Math.max(l,x.top),c=Math.min(u==o.parentNode?n.innerHeight:c,x.bottom)}u=v.position=="absolute"||v.position=="fixed"?p.offsetParent:p.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-e.left,right:Math.max(s,a)-e.left,top:l-(e.top+t),bottom:Math.max(l,c)-(e.top+t)}}function vx(o){let t=o.getBoundingClientRect(),e=o.ownerDocument.defaultView||window;return t.left<e.innerWidth&&t.right>0&&t.top<e.innerHeight&&t.bottom>0}function yx(o,t){let e=o.getBoundingClientRect();return{left:0,right:e.right-e.left,top:t,bottom:e.bottom-(e.top+t)}}class Ec{constructor(t,e,i,n){this.from=t,this.to=e,this.size=i,this.displaySize=n}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t,e){return Yt.replace({widget:new bx(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class bx extends Zo{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class pp{constructor(t){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.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=fp,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Fe.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(lh).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new dx(e),this.stateDeco=t.facet(Lr).filter(i=>typeof i!="function"),this.heightMap=ki.empty().applyChanges(this.stateDeco,ye.empty,this.heightOracle.setDoc(t.doc),[new on(0,0,0,t.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Yt.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some(({from:s,to:a})=>n>=s&&n<=a)){let{from:s,to:a}=this.lineBlockAt(n);t.push(new Sa(s,a))}}return this.viewports=t.sort((i,n)=>i.from-n.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?fp:new ph(this.heightOracle,this.heightMap,this.viewports),t.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,t=>{this.viewportLines.push(fr(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Lr).filter(p=>typeof p!="function");let n=t.changedRanges,s=on.extendWithRanges(n,fx(i,this.stateDeco,t?t.changes:Je.empty(this.state.doc.length))),a=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);hp(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=a||Cs)&&(t.flags|=2),l?(this.scrollAnchorPos=t.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let c=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<c.from||e.range.head>c.to)||!this.viewportIsAppropriate(c))&&(c=this.getViewport(0,e));let u=c.from!=this.viewport.from||c.to!=this.viewport.to;this.viewport=c,t.flags|=this.updateForViewport(),(u||!t.changes.empty||t.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(x_)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?Fe.RTL:Fe.LTR;let a=this.heightOracle.mustRefreshForWrapping(s),l=e.getBoundingClientRect(),c=a||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,p=0;if(l.width&&l.height){let{scaleX:Q,scaleY:tt}=gm(e,l);(Q>.005&&Math.abs(this.scaleX-Q)>.005||tt>.005&&Math.abs(this.scaleY-tt)>.005)&&(this.scaleX=Q,this.scaleY=tt,u|=16,a=c=!0)}let v=(parseInt(i.paddingTop)||0)*this.scaleY,x=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=v||this.paddingBottom!=x)&&(this.paddingTop=v,this.paddingBottom=x,u|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(c=!0),this.editorWidth=t.scrollDOM.clientWidth,u|=16);let T=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=T&&(this.scrollAnchorHeight=-1,this.scrollTop=T),this.scrolledToBottom=bm(t.scrollDOM);let M=(this.printing?yx:gx)(e,this.paddingTop),P=M.top-this.pixelViewport.top,F=M.bottom-this.pixelViewport.bottom;this.pixelViewport=M;let R=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(R!=this.inView&&(this.inView=R,R&&(c=!0)),!this.inView&&!this.scrollTarget&&!vx(t.dom))return 0;let q=l.width;if((this.contentDOMWidth!=q||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=t.scrollDOM.clientHeight,u|=16),c){let Q=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(Q)&&(a=!0),a||n.lineWrapping&&Math.abs(q-this.contentDOMWidth)>n.charWidth){let{lineHeight:tt,charWidth:it,textHeight:rt}=t.docView.measureTextSize();a=tt>0&&n.refresh(s,tt,it,rt,q/it,Q),a&&(t.docView.minWidth=0,u|=16)}P>0&&F>0?p=Math.max(P,F):P<0&&F<0&&(p=Math.min(P,F)),hp();for(let tt of this.viewports){let it=tt.from==this.viewport.from?Q:t.docView.measureVisibleLineHeights(tt);this.heightMap=(a?ki.empty().applyChanges(this.stateDeco,ye.empty,this.heightOracle,[new on(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,a,new hx(tt.from,it))}Cs&&(u|=2)}let H=!this.viewportIsAppropriate(this.viewport,p)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return H&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(p,this.scrollTarget),u|=this.updateForViewport()),(u&2||H)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,t)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:a,visibleBottom:l}=this,c=new Sa(n.lineAt(a-i*1e3,Ne.ByHeight,s,0,0).from,n.lineAt(l+(1-i)*1e3,Ne.ByHeight,s,0,0).to);if(e){let{head:u}=e.range;if(u<c.from||u>c.to){let p=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),v=n.lineAt(u,Ne.ByPos,s,0,0),x;e.y=="center"?x=(v.top+v.bottom)/2-p/2:e.y=="start"||e.y=="nearest"&&u<c.from?x=v.top:x=v.bottom-p,c=new Sa(n.lineAt(x-1e3/2,Ne.ByHeight,s,0,0).from,n.lineAt(x+p+1e3/2,Ne.ByHeight,s,0,0).to)}}return c}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new Sa(this.heightMap.lineAt(i,Ne.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,Ne.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,Ne.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,Ne.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:l}=this;return(t==0||n<=a-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&n>a-2*1e3&&s<l+2*1e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new Ec(e.mapPos(n.from),e.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,a=n<<1;if(this.defaultTextDirection!=Fe.LTR&&!i)return[];let l=[],c=(p,v,x,T)=>{if(v-p<s)return;let M=this.state.selection.main,P=[M.from];M.empty||P.push(M.to);for(let R of P)if(R>p&&R<v){c(p,R-10,x,T),c(R+10,v,x,T);return}let F=_x(t,R=>R.from>=x.from&&R.to<=x.to&&Math.abs(R.from-p)<s&&Math.abs(R.to-v)<s&&!P.some(q=>R.from<q&&R.to>q));if(!F){if(v<x.to&&e&&i&&e.visibleRanges.some(H=>H.from<=v&&H.to>=v)){let H=e.moveToLineBoundary(xt.cursor(v),!1,!0).head;H>p&&(v=H)}let R=this.gapSize(x,p,v,T),q=i||R<2e6?R:2e6;F=new Ec(p,v,R,q)}l.push(F)},u=p=>{if(p.length<a||p.type!=nn.Text)return;let v=wx(p.from,p.to,this.stateDeco);if(v.total<a)return;let x=this.scrollTarget?this.scrollTarget.range.head:null,T,M;if(i){let P=n/this.heightOracle.lineLength*this.heightOracle.lineHeight,F,R;if(x!=null){let q=Ea(v,x),H=((this.visibleBottom-this.visibleTop)/2+P)/p.height;F=q-H,R=q+H}else F=(this.visibleTop-p.top-P)/p.height,R=(this.visibleBottom-p.top+P)/p.height;T=Ta(v,F),M=Ta(v,R)}else{let P=v.total*this.heightOracle.charWidth,F=n*this.heightOracle.charWidth,R=0;if(P>2e6)for(let it of t)it.from>=p.from&&it.from<p.to&&it.size!=it.displaySize&&it.from*this.heightOracle.charWidth+R<this.pixelViewport.left&&(R=it.size-it.displaySize);let q=this.pixelViewport.left+R,H=this.pixelViewport.right+R,Q,tt;if(x!=null){let it=Ea(v,x),rt=((H-q)/2+F)/P;Q=it-rt,tt=it+rt}else Q=(q-F)/P,tt=(H+F)/P;T=Ta(v,Q),M=Ta(v,tt)}T>p.from&&c(p.from,T,p,v),M<p.to&&c(M,p.to,p,v)};for(let p of this.viewportLines)Array.isArray(p.type)?p.type.forEach(u):u(p);return l}gapSize(t,e,i,n){let s=Ea(n,i)-Ea(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){Ec.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Yt.set(t.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];ue.spans(e,this.viewport.from,this.viewport.to,{span(s,a){i.push({from:s,to:a})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let s=0;s<i.length&&!(n&8);s++){let a=this.visibleRanges[s],l=i[s];(a.from!=l.from||a.to!=l.to)&&(n|=4,t&&t.mapPos(a.from,-1)==l.from&&t.mapPos(a.to,1)==l.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||fr(this.heightMap.lineAt(t,Ne.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||fr(this.heightMap.lineAt(this.scaler.fromDOM(t),Ne.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return fr(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Sa{constructor(t,e){this.from=t,this.to=e}}function wx(o,t,e){let i=[],n=o,s=0;return ue.spans(e,o,t,{span(){},point(a,l){a>n&&(i.push({from:n,to:a}),s+=a-n),n=l}},20),n<t&&(i.push({from:n,to:t}),s+=t-n),{total:s,ranges:i}}function Ta({total:o,ranges:t},e){if(e<=0)return t[0].from;if(e>=1)return t[t.length-1].to;let i=Math.floor(o*e);for(let n=0;;n++){let{from:s,to:a}=t[n],l=a-s;if(i<=l)return s+i;i-=l}}function Ea(o,t){let e=0;for(let{from:i,to:n}of o.ranges){if(t<=n){e+=t-i;break}e+=n-i}return e/o.total}function _x(o,t){for(let e of o)if(t(e))return e}const fp={toDOM(o){return o},fromDOM(o){return o},scale:1,eq(o){return o==this}};class ph{constructor(t,e,i){let n=0,s=0,a=0;this.viewports=i.map(({from:l,to:c})=>{let u=e.lineAt(l,Ne.ByPos,t,0,0).top,p=e.lineAt(c,Ne.ByPos,t,0,0).bottom;return n+=p-u,{from:l,to:c,top:u,bottom:p,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(e.height-n);for(let l of this.viewports)l.domTop=a+(l.top-s)*this.scale,a=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}eq(t){return t instanceof ph?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to):!1}}function fr(o,t){if(t.scale==1)return o;let e=t.toDOM(o.top),i=t.toDOM(o.bottom);return new In(o.from,o.length,e,i-e,Array.isArray(o._content)?o._content.map(n=>fr(n,t)):o._content)}const Ia=Ft.define({combine:o=>o.join(" ")}),Cd=Ft.define({combine:o=>o.indexOf(!0)>-1}),$d=xo.newName(),ag=xo.newName(),lg=xo.newName(),cg={"&light":"."+ag,"&dark":"."+lg};function Sd(o,t,e){return new xo(t,{finish(i){return/&/.test(i)?i.replace(/&\w*/,n=>{if(n=="&")return o;if(!e||!e[n])throw new RangeError(`Unsupported selector: ${n}`);return e[n]}):o+" "+i}})}const xx=Sd("."+$d,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},cg),kx={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ic=Bt.ie&&Bt.ie_version<=11;class Cx{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new n_,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=t.contentDOM,this.observer=new MutationObserver(e=>{for(let i of e)this.queue.push(i);(Bt.ie&&Bt.ie_version<=11||Bt.ios&&t.composing)&&e.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&t.constructor.EDIT_CONTEXT!==!1&&!(Bt.chrome&&Bt.chrome_version<126)&&(this.editContext=new Sx(t),t.state.facet(to)&&(t.contentDOM.editContext=this.editContext.editContext)),Ic&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var e;((e=this.view.docView)===null||e===void 0?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){(t.type=="change"||!t.type)&&!t.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(to)?i.root.activeElement!=this.dom:!Xa(this.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);if(s&&s.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(Bt.ie&&Bt.ie_version<=11||Bt.android&&Bt.chrome)&&!i.state.selection.main.empty&&n.focusNode&&xr(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Ar(t.root);if(!e)return!1;let i=Bt.safari&&t.root.nodeType==11&&t.root.activeElement==this.dom&&$x(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=Xa(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&s_(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(i.nodeType==1)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=e)i.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,kx),Ic&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ic&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let n=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&gs(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:e,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 t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let a=this.readMutation(s);a&&(a.typeOver&&(n=!0),e==-1?{from:e,to:i}=a:(e=Math.min(a.from,e),i=Math.max(a.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&Xa(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new H_(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=Jm(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty(t.type=="attributes"),t.type=="attributes"&&(e.flags|=4),t.type=="childList"){let i=mp(e,t.previousSibling||t.target.previousSibling,-1),n=mp(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(to)!=t.state.facet(to)&&(t.view.contentDOM.editContext=t.state.facet(to)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),(t=this.intersection)===null||t===void 0||t.disconnect(),(e=this.gapIntersection)===null||e===void 0||e.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let n of this.scrollTargets)n.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 mp(o,t,e){for(;t;){let i=Te.get(t);if(i&&i.parent==o)return i;let n=t.parentNode;t=n!=o.dom?n:e>0?t.nextSibling:t.previousSibling}return null}function gp(o,t){let e=t.startContainer,i=t.startOffset,n=t.endContainer,s=t.endOffset,a=o.docView.domAtPos(o.state.selection.main.anchor);return xr(a.node,a.offset,n,s)&&([e,i,n,s]=[n,s,e,i]),{anchorNode:e,anchorOffset:i,focusNode:n,focusOffset:s}}function $x(o,t){if(t.getComposedRanges){let n=t.getComposedRanges(o.root)[0];if(n)return gp(o,n)}let e=null;function i(n){n.preventDefault(),n.stopImmediatePropagation(),e=n.getTargetRanges()[0]}return o.contentDOM.addEventListener("beforeinput",i,!0),o.dom.ownerDocument.execCommand("indent"),o.contentDOM.removeEventListener("beforeinput",i,!0),e?gp(o,e):null}class Sx{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=i=>{let n=t.state.selection.main,{anchor:s,head:a}=n,l=this.toEditorPos(i.updateRangeStart),c=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let u={from:l,to:c,insert:ye.of(i.text.split(`
|
||
`))};if(u.from==this.from&&s<this.from?u.from=s:u.to==this.to&&s>this.to&&(u.to=s),u.from==u.to&&!u.insert.length){let p=xt.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));p.main.eq(n)||t.dispatch({selection:p,userEvent:"select"});return}if((Bt.mac||Bt.android)&&u.from==a-1&&/^\. ?$/.test(i.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:l,to:c,insert:ye.of([i.text.replace("."," ")])}),this.pendingContextChange=u,!t.state.readOnly){let p=this.to-this.from+(u.to-u.from+u.insert.length);hh(t,u,xt.single(this.toEditorPos(i.selectionStart,p),this.toEditorPos(i.selectionEnd,p)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=i=>{let n=[],s=null;for(let a=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);a<l;a++){let c=t.coordsForChar(a);s=c&&new DOMRect(c.left,c.top,c.right-c.left,c.bottom-c.top)||s||new DOMRect,n.push(s)}e.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=i=>{let n=[];for(let s of i.getTextFormats()){let a=s.underlineStyle,l=s.underlineThickness;if(a!="None"&&l!="None"){let c=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(c<u){let p=`text-decoration: underline ${a=="Dashed"?"dashed ":a=="Squiggle"?"wavy ":""}${l=="Thin"?1:2}px`;n.push(Yt.mark({attributes:{style:p}}).range(c,u))}}}t.dispatch({effects:Um.of(Yt.set(n))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(t.state)}};for(let i in this.handlers)e.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let n=Ar(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges((s,a,l,c,u)=>{if(i)return;let p=u.length-(a-s);if(n&&a>=n.to)if(n.from==s&&n.to==a&&n.insert.eq(u)){n=this.pendingContextChange=null,e+=p,this.to+=p;return}else n=null,this.revertPending(t.state);if(s+=e,a+=e,a<=this.from)this.from+=p,this.to+=p;else if(s<this.to){if(s<this.from||a>this.to||this.to-this.from+u.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(a),u.toString()),this.to+=p}e+=p}),n&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(n=>!n.isUserEvent("input.type")&&n.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>1e4*3)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class Wt{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(t={}){var e;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(n=>n.forEach(s=>i(s,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=t.root||o_(t.parent)||document,this.viewState=new pp(t.state||ve.create(t)),t.scrollTo&&t.scrollTo.is(ka)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(us).map(n=>new $c(n));for(let n of this.plugins)n.update(this);this.observer=new Cx(this),this.inputState=new K_(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Zu(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((e=document.fonts)===null||e===void 0)&&e.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let e=t.length==1&&t[0]instanceof Qe?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,i=!1,n,s=this.state;for(let x of t){if(x.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=x.state}if(this.destroyed){this.viewState.state=s;return}let a=this.hasFocus,l=0,c=null;t.some(x=>x.annotation(ng))?(this.inputState.notifiedFocused=a,l=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,c=og(s,a),c||(l=1));let u=this.observer.delayedAndroidKey,p=null;if(u?(this.observer.clearDelayedAndroidKey(),p=this.observer.readChange(),(p&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(p=null)):this.observer.clear(),s.facet(ve.phrases)!=this.state.facet(ve.phrases))return this.setState(s);n=ml.create(this,s,t),n.flags|=l;let v=this.viewState.scrollTarget;try{this.updateState=2;for(let x of t){if(v&&(v=v.map(x.changes)),x.scrollIntoView){let{main:T}=x.state.selection;v=new vs(T.empty?T:xt.cursor(T.head,T.head>T.anchor?-1:1))}for(let T of x.effects)T.is(ka)&&(v=T.value.clip(this.state))}this.viewState.update(n,v),this.bidiCache=vl.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),e=this.docView.update(n),this.state.facet(ur)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(x=>x.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(Ia)!=n.state.facet(Ia)&&(this.viewState.mustMeasureContent=!0),(e||i||v||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!n.empty)for(let x of this.state.facet(_d))try{x(n)}catch(T){Ji(this.state,T,"update listener")}(c||p)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),p&&!Jm(this,p)&&u.force&&gs(this.contentDOM,u.key,u.keyCode)})}setState(t){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=t;return}this.updateState=2;let e=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new pp(t),this.plugins=t.facet(us).map(i=>new $c(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Zu(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(us),i=t.state.facet(us);if(e!=i){let n=[];for(let s of i){let a=e.indexOf(s);if(a<0)n.push(new $c(s));else{let l=this.plugins[a];l.mustUpdate=t,n.push(l)}}for(let s of this.plugins)s.mustUpdate!=t&&s.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=t;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(i){Ji(this.state,i,"doc view update listener")}}}measure(t=!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,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:a}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(a<0)if(bm(i))s=-1,a=this.viewState.heightMap.height;else{let T=this.viewState.scrollAnchorAt(n);s=T.from,a=T.top}this.updateState=1;let c=this.viewState.measure(this);if(!c&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];c&4||([this.measureRequests,u]=[u,this.measureRequests]);let p=u.map(T=>{try{return T.read(this)}catch(M){return Ji(this.state,M),vp}}),v=ml.create(this,this.state,[]),x=!1;v.flags|=c,e?e.flags|=c:e=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),x=this.docView.update(v),x&&this.docViewUpdate());for(let T=0;T<u.length;T++)if(p[T]!=vp)try{let M=u[T];M.write&&M.write(p[T],this)}catch(M){Ji(this.state,M)}if(x&&this.docView.updateSelection(!0),!v.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let T=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-a;if(T>1||T<-1){n=n+T,i.scrollTop=n/this.scaleY,a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let l of this.state.facet(_d))l(e)}get themeClasses(){return $d+" "+(this.state.facet(Cd)?lg:ag)+" "+this.state.facet(Ia)}updateAttrs(){let t=yp(this,jm,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(to)?"true":"false",class:"cm-content",style:`${Bt.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),yp(this,lh,e);let i=this.observer.ignore(()=>{let n=gd(this.contentDOM,this.contentAttrs,e),s=gd(this.dom,this.editorAttrs,t);return n||s});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let n of i.effects)if(n.is(Wt.announce)){e&&(this.announceDOM.textContent=""),e=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(ur);let t=this.state.facet(Wt.cspNonce);xo.mount(this.root,this.styleModules.concat(xx).reverse(),t?{nonce:t}: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(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(e===void 0||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(i=>i.plugin==t)||null),e&&e.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(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return Tc(this,t,Xu(this,t,e,i))}moveByGroup(t,e){return Tc(this,t,Xu(this,t,e,i=>B_(this,t.head,i)))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return xt.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return R_(this,t,e,i)}moveVertically(t,e,i){return Tc(this,t,z_(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Ym(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n),a=s[_o.find(s,t-n.from,-1,e)];return zr(i,a.dir==Fe.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Hm)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Tx)return Pm(t.length);let e=this.textDirectionAt(t.from),i;for(let s of this.bidiCache)if(s.from==t.from&&s.dir==e&&(s.fresh||Mm(s.isolates,i=Ku(this,t))))return s.order;i||(i=Ku(this,t));let n=b_(t.text,e,i);return this.bidiCache.push(new vl(t.from,t.to,e,i,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Bt.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{vm(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return ka.of(new vs(typeof t=="number"?xt.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return ka.of(new vs(xt.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return ti.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return ti.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=xo.newName(),n=[Ia.of(i),ur.of(Sd(`.${i}`,t))];return e&&e.dark&&n.push(Cd.of(!0)),n}static baseTheme(t){return Pl.lowest(ur.of(Sd("."+$d,t,cg)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&Te.get(i)||Te.get(t);return((e=n?.rootView)===null||e===void 0?void 0:e.view)||null}}Wt.styleModule=ur;Wt.inputHandler=Fm;Wt.clipboardInputFilter=rh;Wt.clipboardOutputFilter=ah;Wt.scrollHandler=Vm;Wt.focusChangeEffect=Wm;Wt.perLineTextDirection=Hm;Wt.exceptionSink=zm;Wt.updateListener=_d;Wt.editable=to;Wt.mouseSelectionStyle=Bm;Wt.dragMovesSelection=Rm;Wt.clickAddsSelectionRange=Dm;Wt.decorations=Lr;Wt.outerDecorations=qm;Wt.atomicRanges=ch;Wt.bidiIsolatedRanges=Km;Wt.scrollMargins=Zm;Wt.darkTheme=Cd;Wt.cspNonce=Ft.define({combine:o=>o.length?o[0]:""});Wt.contentAttributes=lh;Wt.editorAttributes=jm;Wt.lineWrapping=Wt.contentAttributes.of({class:"cm-lineWrapping"});Wt.announce=me.define();const Tx=4096,vp={};class vl{constructor(t,e,i,n,s,a){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=a}static update(t,e){if(e.empty&&!t.some(s=>s.fresh))return t;let i=[],n=t.length?t[t.length-1].dir:Fe.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let a=t[s];a.dir==n&&!e.touchesRange(a.from,a.to)&&i.push(new vl(e.mapPos(a.from,1),e.mapPos(a.to,-1),a.dir,a.isolates,!1,a.order))}return i}}function yp(o,t,e){for(let i=o.state.facet(t),n=i.length-1;n>=0;n--){let s=i[n],a=typeof s=="function"?s(o):s;a&&md(a,e)}return e}const Ex=Bt.mac?"mac":Bt.windows?"win":Bt.linux?"linux":"key";function Ix(o,t){const e=o.split(/-(?!$)/);let i=e[e.length-1];i=="Space"&&(i=" ");let n,s,a,l;for(let c=0;c<e.length-1;++c){const u=e[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))n=!0;else if(/^(c|ctrl|control)$/i.test(u))s=!0;else if(/^s(hift)?$/i.test(u))a=!0;else if(/^mod$/i.test(u))t=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+u)}return n&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),a&&(i="Shift-"+i),i}function Aa(o,t,e){return t.altKey&&(o="Alt-"+o),t.ctrlKey&&(o="Ctrl-"+o),t.metaKey&&(o="Meta-"+o),e!==!1&&t.shiftKey&&(o="Shift-"+o),o}const Ax=Pl.default(Wt.domEventHandlers({keydown(o,t){return ug(hg(t.state),o,t,"editor")}})),dg=Ft.define({enables:Ax}),bp=new WeakMap;function hg(o){let t=o.facet(dg),e=bp.get(t);return e||bp.set(t,e=Nx(t.reduce((i,n)=>i.concat(n),[]))),e}function cs(o,t,e){return ug(hg(o.state),t,o,e)}let yo=null;const Lx=4e3;function Nx(o,t=Ex){let e=Object.create(null),i=Object.create(null),n=(a,l)=>{let c=i[a];if(c==null)i[a]=l;else if(c!=l)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},s=(a,l,c,u,p)=>{var v,x;let T=e[a]||(e[a]=Object.create(null)),M=l.split(/ (?!$)/).map(R=>Ix(R,t));for(let R=1;R<M.length;R++){let q=M.slice(0,R).join(" ");n(q,!0),T[q]||(T[q]={preventDefault:!0,stopPropagation:!1,run:[H=>{let Q=yo={view:H,prefix:q,scope:a};return setTimeout(()=>{yo==Q&&(yo=null)},Lx),!0}]})}let P=M.join(" ");n(P,!1);let F=T[P]||(T[P]={preventDefault:!1,stopPropagation:!1,run:((x=(v=T._any)===null||v===void 0?void 0:v.run)===null||x===void 0?void 0:x.slice())||[]});c&&F.run.push(c),u&&(F.preventDefault=!0),p&&(F.stopPropagation=!0)};for(let a of o){let l=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let u of l){let p=e[u]||(e[u]=Object.create(null));p._any||(p._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:v}=a;for(let x in p)p[x].run.push(T=>v(T,Td))}let c=a[t]||a.key;if(c)for(let u of l)s(u,c,a.run,a.preventDefault,a.stopPropagation),a.shift&&s(u,"Shift-"+c,a.shift,a.preventDefault,a.stopPropagation)}return e}let Td=null;function ug(o,t,e,i){Td=t;let n=Xw(t),s=tm(n,0),a=em(s)==n.length&&n!=" ",l="",c=!1,u=!1,p=!1;yo&&yo.view==e&&yo.scope==i&&(l=yo.prefix+" ",Xm.indexOf(t.keyCode)<0&&(u=!0,yo=null));let v=new Set,x=F=>{if(F){for(let R of F.run)if(!v.has(R)&&(v.add(R),R(e)))return F.stopPropagation&&(p=!0),!0;F.preventDefault&&(F.stopPropagation&&(p=!0),u=!0)}return!1},T=o[i],M,P;return T&&(x(T[l+Aa(n,t,!a)])?c=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(Bt.windows&&t.ctrlKey&&t.altKey)&&(M=ko[t.keyCode])&&M!=n?(x(T[l+Aa(M,t,!0)])||t.shiftKey&&(P=Ir[t.keyCode])!=n&&P!=M&&x(T[l+Aa(P,t,!1)]))&&(c=!0):a&&t.shiftKey&&x(T[l+Aa(n,t,!0)])&&(c=!0),!c&&x(T._any)&&(c=!0)),u&&(c=!0),c&&p&&t.stopPropagation(),Td=null,c}const Mx=Ft.define({combine(o){return ro(o,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}});function Px(o){return o.facet(Mx)}function wp(o,t,e,i,n){t.lastIndex=0;for(let s=o.iterRange(e,i),a=e,l;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;l=t.exec(s.value);)n(a+l.index,l)}function Ox(o,t){let e=o.visibleRanges;if(e.length==1&&e[0].from==o.viewport.from&&e[0].to==o.viewport.to)return e;let i=[];for(let{from:n,to:s}of e)n=Math.max(o.state.doc.lineAt(n).from,n-t),s=Math.min(o.state.doc.lineAt(s).to,s+t),i.length&&i[i.length-1].to>=n?i[i.length-1].to=s:i.push({from:n,to:s});return i}class Dx{constructor(t){const{regexp:e,decoration:i,decorate:n,boundary:s,maxLength:a=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,n)this.addMatch=(l,c,u,p)=>n(p,u,u+l[0].length,l,c);else if(typeof i=="function")this.addMatch=(l,c,u,p)=>{let v=i(l,c,u);v&&p(u,u+l[0].length,v)};else if(i)this.addMatch=(l,c,u,p)=>p(u,u+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=a}createDeco(t){let e=new On,i=e.add.bind(e);for(let{from:n,to:s}of Ox(t,this.maxLength))wp(t.state.doc,this.regexp,n,s,(a,l)=>this.addMatch(l,t,a,i));return e.finish()}updateDeco(t,e){let i=1e9,n=-1;return t.docChanged&&t.changes.iterChanges((s,a,l,c)=>{c>=t.view.viewport.from&&l<=t.view.viewport.to&&(i=Math.min(l,i),n=Math.max(c,n))}),t.viewportMoved||n-i>1e3?this.createDeco(t.view):n>-1?this.updateRange(t.view,e.map(t.changes),i,n):e}updateRange(t,e,i,n){for(let s of t.visibleRanges){let a=Math.max(s.from,i),l=Math.min(s.to,n);if(l>=a){let c=t.state.doc.lineAt(a),u=c.to<l?t.state.doc.lineAt(l):c,p=Math.max(s.from,c.from),v=Math.min(s.to,u.to);if(this.boundary){for(;a>c.from;a--)if(this.boundary.test(c.text[a-1-c.from])){p=a;break}for(;l<u.to;l++)if(this.boundary.test(u.text[l-u.from])){v=l;break}}let x=[],T,M=(P,F,R)=>x.push(R.range(P,F));if(c==u)for(this.regexp.lastIndex=p-c.from;(T=this.regexp.exec(c.text))&&T.index<v-c.from;)this.addMatch(T,t,T.index+c.from,M);else wp(t.state.doc,this.regexp,p,v,(P,F)=>this.addMatch(F,t,P,M));e=e.update({filterFrom:p,filterTo:v,filter:(P,F)=>P<p||F>v,add:x})}}return e}}function Rx(){return zx}const Bx=Yt.line({class:"cm-activeLine"}),zx=ti.fromClass(class{constructor(o){this.decorations=this.getDeco(o)}update(o){(o.docChanged||o.selectionSet)&&(this.decorations=this.getDeco(o.view))}getDeco(o){let t=-1,e=[];for(let i of o.state.selection.ranges){let n=o.lineBlockAt(i.head);n.from>t&&(e.push(Bx.range(n.from)),t=n.from)}return Yt.set(e)}},{decorations:o=>o.decorations});class Fx extends Zo{constructor(t){super(),this.content=t}toDOM(t){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),e.setAttribute("aria-hidden","true"),e}coordsAt(t){let e=t.firstChild?_s(t.firstChild):[];if(!e.length)return null;let i=window.getComputedStyle(t.parentNode),n=zr(e[0],i.direction!="rtl"),s=parseInt(i.lineHeight);return n.bottom-n.top>s*1.5?{left:n.left,right:n.right,top:n.top,bottom:n.top+s}:n}ignoreEvent(){return!1}}function Wx(o){let t=ti.fromClass(class{constructor(e){this.view=e,this.placeholder=o?Yt.set([Yt.widget({widget:new Fx(o),side:1}).range(0)]):Yt.none}get decorations(){return this.view.state.doc.length?Yt.none:this.placeholder}},{decorations:e=>e.decorations});return typeof o=="string"?[t,Wt.contentAttributes.of({"aria-placeholder":o})]:t}const rr="-10000px";class pg{constructor(t,e,i,n){this.facet=e,this.createTooltipView=i,this.removeTooltipView=n,this.input=t.state.facet(e),this.tooltips=this.input.filter(a=>a);let s=null;this.tooltipViews=this.tooltips.map(a=>s=i(a,s))}update(t,e){var i;let n=t.state.facet(this.facet),s=n.filter(c=>c);if(n===this.input){for(let c of this.tooltipViews)c.update&&c.update(t);return!1}let a=[],l=e?[]:null;for(let c=0;c<s.length;c++){let u=s[c],p=-1;if(u){for(let v=0;v<this.tooltips.length;v++){let x=this.tooltips[v];x&&x.create==u.create&&(p=v)}if(p<0)a[c]=this.createTooltipView(u,c?a[c-1]:null),l&&(l[c]=!!u.above);else{let v=a[c]=this.tooltipViews[p];l&&(l[c]=e[p]),v.update&&v.update(t)}}}for(let c of this.tooltipViews)a.indexOf(c)<0&&(this.removeTooltipView(c),(i=c.destroy)===null||i===void 0||i.call(c));return e&&(l.forEach((c,u)=>e[u]=c),e.length=l.length),this.input=n,this.tooltips=s,this.tooltipViews=a,!0}}function Hx(o){let t=o.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const Ac=Ft.define({combine:o=>{var t,e,i;return{position:Bt.ios?"absolute":((t=o.find(n=>n.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((e=o.find(n=>n.parent))===null||e===void 0?void 0:e.parent)||null,tooltipSpace:((i=o.find(n=>n.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Hx}}}),_p=new WeakMap,fg=ti.fromClass(class{constructor(o){this.view=o,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=o.state.facet(Ac);this.position=t.position,this.parent=t.parent,this.classes=o.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new pg(o,fh,(e,i)=>this.createTooltip(e,i),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),o.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let o of this.manager.tooltipViews)this.intersectionObserver.observe(o.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(o){o.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(o,this.above);t&&this.observeIntersection();let e=t||o.geometryChanged,i=o.state.facet(Ac);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let n of this.manager.tooltipViews)n.dom.style.position=this.position;e=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let n of this.manager.tooltipViews)this.container.appendChild(n.dom);e=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);e&&this.maybeMeasure()}createTooltip(o,t){let e=o.create(this.view),i=t?t.dom:null;if(e.dom.classList.add("cm-tooltip"),o.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let n=document.createElement("div");n.className="cm-tooltip-arrow",e.dom.appendChild(n)}return e.dom.style.position=this.position,e.dom.style.top=rr,e.dom.style.left="0px",this.container.insertBefore(e.dom,i),e.mount&&e.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(e.dom),e}destroy(){var o,t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(o=i.destroy)===null||o===void 0||o.call(i);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let o=1,t=1,e=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Bt.gecko)e=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==rr&&s.style.left=="0px"){let a=s.getBoundingClientRect();e=Math.abs(a.top+1e4)>1||Math.abs(a.left)>1}}if(e||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(o=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:o,scaleY:t}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),n=dh(this.view);return{visible:{left:i.left+n.left,top:i.top+n.top,right:i.right-n.right,bottom:i.bottom-n.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,a)=>{let l=this.manager.tooltipViews[a];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Ac).tooltipSpace(this.view),scaleX:o,scaleY:t,makeAbsolute:e}}writeMeasure(o){var t;if(o.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:e,space:i,scaleX:n,scaleY:s}=o,a=[];for(let l=0;l<this.manager.tooltips.length;l++){let c=this.manager.tooltips[l],u=this.manager.tooltipViews[l],{dom:p}=u,v=o.pos[l],x=o.size[l];if(!v||c.clip!==!1&&(v.bottom<=Math.max(e.top,i.top)||v.top>=Math.min(e.bottom,i.bottom)||v.right<Math.max(e.left,i.left)-.1||v.left>Math.min(e.right,i.right)+.1)){p.style.top=rr;continue}let T=c.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,M=T?7:0,P=x.right-x.left,F=(t=_p.get(u))!==null&&t!==void 0?t:x.bottom-x.top,R=u.offset||Ux,q=this.view.textDirection==Fe.LTR,H=x.width>i.right-i.left?q?i.left:i.right-x.width:q?Math.max(i.left,Math.min(v.left-(T?14:0)+R.x,i.right-P)):Math.min(Math.max(i.left,v.left-P+(T?14:0)-R.x),i.right-P),Q=this.above[l];!c.strictSide&&(Q?v.top-F-M-R.y<i.top:v.bottom+F+M+R.y>i.bottom)&&Q==i.bottom-v.bottom>v.top-i.top&&(Q=this.above[l]=!Q);let tt=(Q?v.top-i.top:i.bottom-v.bottom)-M;if(tt<F&&u.resize!==!1){if(tt<this.view.defaultLineHeight){p.style.top=rr;continue}_p.set(u,F),p.style.height=(F=tt)/s+"px"}else p.style.height&&(p.style.height="");let it=Q?v.top-F-M-R.y:v.bottom+M+R.y,rt=H+P;if(u.overlap!==!0)for(let vt of a)vt.left<rt&&vt.right>H&&vt.top<it+F&&vt.bottom>it&&(it=Q?vt.top-F-2-M:vt.bottom+M+2);if(this.position=="absolute"?(p.style.top=(it-o.parent.top)/s+"px",xp(p,(H-o.parent.left)/n)):(p.style.top=it/s+"px",xp(p,H/n)),T){let vt=v.left+(q?R.x:-R.x)-(H+14-7);T.style.left=vt/n+"px"}u.overlap!==!0&&a.push({left:H,top:it,right:rt,bottom:it+F}),p.classList.toggle("cm-tooltip-above",Q),p.classList.toggle("cm-tooltip-below",!Q),u.positioned&&u.positioned(o.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let o of this.manager.tooltipViews)o.dom.style.top=rr}},{eventObservers:{scroll(){this.maybeMeasure()}}});function xp(o,t){let e=parseInt(o.style.left,10);(isNaN(e)||Math.abs(t-e)>1)&&(o.style.left=t+"px")}const Vx=Wt.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Ux={x:0,y:0},fh=Ft.define({enables:[fg,Vx]}),yl=Ft.define({combine:o=>o.reduce((t,e)=>t.concat(e),[])});class Bl{static create(t){return new Bl(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new pg(t,yl,(e,i)=>this.createHostedView(e,i),e=>e.dom.remove())}createHostedView(t,e){let i=t.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,e?e.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)(t=e.destroy)===null||t===void 0||t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let n=i[t];if(n!==void 0){if(e===void 0)e=n;else if(e!==n)return}}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const jx=fh.compute([yl],o=>{let t=o.facet(yl);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var i;return(i=e.end)!==null&&i!==void 0?i:e.pos})),create:Bl.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class qx{constructor(t,e,i,n,s){this.view=t,this.source=e,this.field=i,this.setHover=n,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,i=t.docView.nearest(e.target);if(!i)return;let n,s=1;if(i instanceof wo)n=i.posAtStart;else{if(n=t.posAtCoords(e),n==null)return;let l=t.coordsAtPos(n);if(!l||e.y<l.top||e.y>l.bottom||e.x<l.left-t.defaultCharacterWidth||e.x>l.right+t.defaultCharacterWidth)return;let c=t.bidiSpans(t.state.doc.lineAt(n)).find(p=>p.from<=n&&p.to>=n),u=c&&c.dir==Fe.RTL?-1:1;s=e.x<l.left?-u:u}let a=this.source(t,n,s);if(a!=null&&a.then){let l=this.pending={pos:n};a.then(c=>{this.pending==l&&(this.pending=null,c&&!(Array.isArray(c)&&!c.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(c)?c:[c])}))},c=>Ji(t.state,c,"hover tooltip"))}else a&&!(Array.isArray(a)&&!a.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])})}get tooltip(){let t=this.view.plugin(fg),e=t?t.manager.tooltips.findIndex(i=>i.create==Bl.create):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:s}=this;if(n.length&&s&&!Kx(s.dom,t)||this.pending){let{pos:a}=n[0]||this.pending,l=(i=(e=n[0])===null||e===void 0?void 0:e.end)!==null&&i!==void 0?i:a;(a==l?this.view.posAtCoords(this.lastMove)!=a:!Zx(this.view,a,l,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e.length){let{tooltip:i}=this;i&&i.dom.contains(t.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const La=4;function Kx(o,t){let{left:e,right:i,top:n,bottom:s}=o.getBoundingClientRect(),a;if(a=o.querySelector(".cm-tooltip-arrow")){let l=a.getBoundingClientRect();n=Math.min(l.top,n),s=Math.max(l.bottom,s)}return t.clientX>=e-La&&t.clientX<=i+La&&t.clientY>=n-La&&t.clientY<=s+La}function Zx(o,t,e,i,n,s){let a=o.scrollDOM.getBoundingClientRect(),l=o.documentTop+o.documentPadding.top+o.contentHeight;if(a.left>i||a.right<i||a.top>n||Math.min(a.bottom,l)<n)return!1;let c=o.posAtCoords({x:i,y:n},!1);return c>=t&&c<=e}function Gx(o,t={}){let e=me.define(),i=$i.define({create(){return[]},update(n,s){if(n.length&&(t.hideOnChange&&(s.docChanged||s.selection)?n=[]:t.hideOn&&(n=n.filter(a=>!t.hideOn(s,a))),s.docChanged)){let a=[];for(let l of n){let c=s.changes.mapPos(l.pos,-1,mi.TrackDel);if(c!=null){let u=Object.assign(Object.create(null),l);u.pos=c,u.end!=null&&(u.end=s.changes.mapPos(u.end)),a.push(u)}}n=a}for(let a of s.effects)a.is(e)&&(n=a.value),a.is(Yx)&&(n=[]);return n},provide:n=>yl.from(n)});return{active:i,extension:[i,ti.define(n=>new qx(n,o,i,e,t.hoverTime||300)),jx]}}const Yx=me.define(),kp=Ft.define({combine(o){let t,e;for(let i of o)t=t||i.topContainer,e=e||i.bottomContainer;return{topContainer:t,bottomContainer:e}}}),Jx=ti.fromClass(class{constructor(o){this.input=o.state.facet(Nr),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(e=>e(o));let t=o.state.facet(kp);this.top=new Na(o,!0,t.topContainer),this.bottom=new Na(o,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(o){let t=o.state.facet(kp);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Na(o.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Na(o.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let e=o.state.facet(Nr);if(e!=this.input){let i=e.filter(c=>c),n=[],s=[],a=[],l=[];for(let c of i){let u=this.specs.indexOf(c),p;u<0?(p=c(o.view),l.push(p)):(p=this.panels[u],p.update&&p.update(o)),n.push(p),(p.top?s:a).push(p)}this.specs=i,this.panels=n,this.top.sync(s),this.bottom.sync(a);for(let c of l)c.dom.classList.add("cm-panel"),c.mount&&c.mount()}else for(let i of this.panels)i.update&&i.update(o)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:o=>Wt.scrollMargins.of(t=>{let e=t.plugin(o);return e&&{top:e.top.scrollMargin(),bottom:e.bottom.scrollMargin()}})});class Na{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=Cp(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Cp(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function Cp(o){let t=o.nextSibling;return o.remove(),t}const Nr=Ft.define({enables:Jx});class oo extends ws{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}oo.prototype.elementClass="";oo.prototype.toDOM=void 0;oo.prototype.mapMode=mi.TrackBefore;oo.prototype.startSide=oo.prototype.endSide=-1;oo.prototype.point=!0;const Lc=Ft.define(),Qx=Ft.define(),Xx={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ue.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Cr=Ft.define();function mg(o){return[gg(),Cr.of({...Xx,...o})]}const $p=Ft.define({combine:o=>o.some(t=>t)});function gg(o){return[t0]}const t0=ti.fromClass(class{constructor(o){this.view=o,this.prevViewport=o.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=o.state.facet(Cr).map(t=>new Tp(o,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!o.state.facet($p),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),o.scrollDOM.insertBefore(this.dom,o.contentDOM)}update(o){if(this.updateGutters(o)){let t=this.prevViewport,e=o.view.viewport,i=Math.min(t.to,e.to)-Math.max(t.from,e.from);this.syncGutters(i<(e.to-e.from)*.8)}o.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet($p)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=o.view.viewport}syncGutters(o){let t=this.dom.nextSibling;o&&this.dom.remove();let e=ue.iter(this.view.state.facet(Lc),this.view.viewport.from),i=[],n=this.gutters.map(s=>new e0(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let a=!0;for(let l of s.type)if(l.type==nn.Text&&a){Ed(e,i,l.from);for(let c of n)c.line(this.view,l,i);a=!1}else if(l.widget)for(let c of n)c.widget(this.view,l)}else if(s.type==nn.Text){Ed(e,i,s.from);for(let a of n)a.line(this.view,s,i)}else if(s.widget)for(let a of n)a.widget(this.view,s);for(let s of n)s.finish();o&&this.view.scrollDOM.insertBefore(this.dom,t)}updateGutters(o){let t=o.startState.facet(Cr),e=o.state.facet(Cr),i=o.docChanged||o.heightChanged||o.viewportChanged||!ue.eq(o.startState.facet(Lc),o.state.facet(Lc),o.view.viewport.from,o.view.viewport.to);if(t==e)for(let n of this.gutters)n.update(o)&&(i=!0);else{i=!0;let n=[];for(let s of e){let a=t.indexOf(s);a<0?n.push(new Tp(this.view,s)):(this.gutters[a].update(o),n.push(this.gutters[a]))}for(let s of this.gutters)s.dom.remove(),n.indexOf(s)<0&&s.destroy();for(let s of n)this.dom.appendChild(s.dom);this.gutters=n}return i}destroy(){for(let o of this.gutters)o.destroy();this.dom.remove()}},{provide:o=>Wt.scrollMargins.of(t=>{let e=t.plugin(o);return!e||e.gutters.length==0||!e.fixed?null:t.textDirection==Fe.LTR?{left:e.dom.offsetWidth*t.scaleX}:{right:e.dom.offsetWidth*t.scaleX}})});function Sp(o){return Array.isArray(o)?o:[o]}function Ed(o,t,e){for(;o.value&&o.from<=e;)o.from==e&&t.push(o.value),o.next()}class e0{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=ue.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,s=(e.top-this.height)/t.scaleY,a=e.height/t.scaleY;if(this.i==n.elements.length){let l=new vg(t,a,s,i);n.elements.push(l),n.dom.appendChild(l.dom)}else n.elements[this.i].update(t,a,s,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];Ed(this.cursor,n,e.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(t,e,n);s&&n.unshift(s);let a=this.gutter;n.length==0&&!a.config.renderEmptyElements||this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),n=i?[i]:null;for(let s of t.state.facet(Qx)){let a=s(t,e.widget,e);a&&(n||(n=[])).push(a)}n&&this.addElement(t,e,n)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class Tp{constructor(t,e){this.view=t,this.config=e,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 e.domEventHandlers)this.dom.addEventListener(i,n=>{let s=n.target,a;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let c=s.getBoundingClientRect();a=(c.top+c.bottom)/2}else a=n.clientY;let l=t.lineBlockAtHeight(a-t.documentTop);e.domEventHandlers[i](t,l,n)&&n.preventDefault()});this.markers=Sp(e.markers(t)),e.initialSpacer&&(this.spacer=new vg(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=Sp(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],t);n!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[n])}let i=t.view.viewport;return!ue.eq(this.markers,e,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class vg{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),i0(this.markers,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let s=0,a=0;;){let l=a,c=s<e.length?e[s++]:null,u=!1;if(c){let p=c.elementClass;p&&(i+=" "+p);for(let v=a;v<this.markers.length;v++)if(this.markers[v].compare(c)){l=v,u=!0;break}}else l=this.markers.length;for(;a<l;){let p=this.markers[a++];if(p.toDOM){p.destroy(n);let v=n.nextSibling;n.remove(),n=v}}if(!c)break;c.toDOM&&(u?n=n.nextSibling:this.dom.insertBefore(c.toDOM(t),n)),u&&a++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}function i0(o,t){if(o.length!=t.length)return!1;for(let e=0;e<o.length;e++)if(!o[e].compare(t[e]))return!1;return!0}const n0=Ft.define(),o0=Ft.define(),ps=Ft.define({combine(o){return ro(o,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let n in e){let s=i[n],a=e[n];i[n]=s?(l,c,u)=>s(l,c,u)||a(l,c,u):a}return i}})}});class Nc extends oo{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function Mc(o,t){return o.state.facet(ps).formatNumber(t,o.state)}const s0=Cr.compute([ps],o=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(n0)},lineMarker(t,e,i){return i.some(n=>n.toDOM)?null:new Nc(Mc(t,t.state.doc.lineAt(e.from).number))},widgetMarker:(t,e,i)=>{for(let n of t.state.facet(o0)){let s=n(t,e,i);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(ps)!=t.state.facet(ps),initialSpacer(t){return new Nc(Mc(t,Ep(t.state.doc.lines)))},updateSpacer(t,e){let i=Mc(e.view,Ep(e.view.state.doc.lines));return i==t.number?t:new Nc(i)},domEventHandlers:o.facet(ps).domEventHandlers}));function r0(o={}){return[ps.of(o),gg(),s0]}function Ep(o){let t=9;for(;t<o;)t=t*10+9;return t}const a0=1024;let l0=0;class Qi{constructor(t,e){this.from=t,this.to=e}}class de{constructor(t={}){this.id=l0++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=Ci.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}}de.closedBy=new de({deserialize:o=>o.split(" ")});de.openedBy=new de({deserialize:o=>o.split(" ")});de.group=new de({deserialize:o=>o.split(" ")});de.isolate=new de({deserialize:o=>{if(o&&o!="rtl"&&o!="ltr"&&o!="auto")throw new RangeError("Invalid value for isolate: "+o);return o||"auto"}});de.contextHash=new de({perNode:!0});de.lookAhead=new de({perNode:!0});de.mounted=new de({perNode:!0});class Mr{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[de.mounted.id]}}const c0=Object.create(null);class Ci{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):c0,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),n=new Ci(t.name||"",e,t.id,i);if(t.props){for(let s of t.props)if(Array.isArray(s)||(s=s(n)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[s[0].id]=s[1]}}return n}prop(t){return this.props[t.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(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(de.group);return e?e.indexOf(t)>-1:!1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return i=>{for(let n=i.prop(de.group),s=-1;s<(n?n.length:0);s++){let a=e[s<0?i.name:n[s]];if(a)return a}}}}Ci.none=new Ci("",Object.create(null),0,8);class mh{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let n=null;for(let s of t){let a=s(i);a&&(n||(n=Object.assign({},i.props)),n[a[0].id]=a[1])}e.push(n?new Ci(i.name,n,i.id,i.flags):i)}return new mh(e)}}const Ma=new WeakMap,Ip=new WeakMap;var ze;(function(o){o[o.ExcludeBuffers=1]="ExcludeBuffers",o[o.IncludeAnonymous=2]="IncludeAnonymous",o[o.IgnoreMounts=4]="IgnoreMounts",o[o.IgnoreOverlays=8]="IgnoreOverlays"})(ze||(ze={}));class Le{constructor(t,e,i,n,s){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[a,l]of s)this.props[typeof a=="number"?a:a.id]=l}}toString(){let t=Mr.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let i of this.children){let n=i.toString();n&&(e&&(e+=","),e+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new bl(this.topNode,t)}cursorAt(t,e=0,i=0){let n=Ma.get(this)||this.topNode,s=new bl(n);return s.moveTo(t,e),Ma.set(this,s._tree),s}get topNode(){return new vi(this,0,0,null)}resolve(t,e=0){let i=Pr(Ma.get(this)||this.topNode,t,e,!1);return Ma.set(this,i),i}resolveInner(t,e=0){let i=Pr(Ip.get(this)||this.topNode,t,e,!0);return Ip.set(this,i),i}resolveStack(t,e=0){return u0(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,a=t.mode||0,l=(a&ze.IncludeAnonymous)>0;for(let c=this.cursor(a|ze.IncludeAnonymous);;){let u=!1;if(c.from<=s&&c.to>=n&&(!l&&c.type.isAnonymous||e(c)!==!1)){if(c.firstChild())continue;u=!0}for(;u&&i&&(l||!c.type.isAnonymous)&&i(c),!c.nextSibling();){if(!c.parent())return;u=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:yh(Ci.none,this.children,this.positions,0,this.children.length,0,this.length,(e,i,n)=>new Le(this.type,e,i,n,this.propValues),t.makeTree||((e,i,n)=>new Le(Ci.none,e,i,n)))}static build(t){return p0(t)}}Le.empty=new Le(Ci.none,[],[],0);class gh{constructor(t,e){this.buffer=t,this.index=e}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 gh(this.buffer,this.index)}}class $o{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return Ci.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),t+=4,i==t)return s;let a=[];for(;t<i;)a.push(this.childString(t)),t=this.buffer[t+3];return s+"("+a.join(",")+")"}findChild(t,e,i,n,s){let{buffer:a}=this,l=-1;for(let c=t;c!=e&&!(yg(s,n,a[c+1],a[c+2])&&(l=c,i>0));c=a[c+3]);return l}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),a=0;for(let l=t,c=0;l<e;){s[c++]=n[l++],s[c++]=n[l++]-i;let u=s[c++]=n[l++]-i;s[c++]=n[l++]-t,a=Math.max(a,u)}return new $o(s,a,this.set)}}function yg(o,t,e,i){switch(o){case-2:return e<t;case-1:return i>=t&&e<t;case 0:return e<t&&i>t;case 1:return e<=t&&i>t;case 2:return i>t;case 4:return!0}}function Pr(o,t,e,i){for(var n;o.from==o.to||(e<1?o.from>=t:o.from>t)||(e>-1?o.to<=t:o.to<t);){let a=!i&&o instanceof vi&&o.index<0?null:o.parent;if(!a)return o;o=a}let s=i?0:ze.IgnoreOverlays;if(i)for(let a=o,l=a.parent;l;a=l,l=a.parent)a instanceof vi&&a.index<0&&((n=l.enter(t,e,s))===null||n===void 0?void 0:n.from)!=a.from&&(o=l);for(;;){let a=o.enter(t,e,s);if(!a)return o;o=a}}class bg{cursor(t=0){return new bl(this,t)}getChild(t,e=null,i=null){let n=Ap(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Ap(this,t,e,i)}resolve(t,e=0){return Pr(this,t,e,!1)}resolveInner(t,e=0){return Pr(this,t,e,!0)}matchContext(t){return Id(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let n=e.lastChild;if(!n||n.to!=e.to)break;n.type.isError&&n.from==n.to?(i=e,e=n.prevSibling):e=n}return i}get node(){return this}get next(){return this.parent}}class vi extends bg{constructor(t,e,i,n){super(),this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let a=this;;){for(let{children:l,positions:c}=a._tree,u=e>0?l.length:-1;t!=u;t+=e){let p=l[t],v=c[t]+a.from;if(yg(n,i,v,v+p.length)){if(p instanceof $o){if(s&ze.ExcludeBuffers)continue;let x=p.findChild(0,p.buffer.length,e,i-v,n);if(x>-1)return new Ln(new d0(a,p,t,v),null,x)}else if(s&ze.IncludeAnonymous||!p.type.isAnonymous||vh(p)){let x;if(!(s&ze.IgnoreMounts)&&(x=Mr.get(p))&&!x.overlay)return new vi(x.tree,v,t,a);let T=new vi(p,v,t,a);return s&ze.IncludeAnonymous||!T.type.isAnonymous?T:T.nextChild(e<0?p.children.length-1:0,e,i,n)}}}if(s&ze.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?t=a.index+e:t=e<0?-1:a._parent._tree.children.length,a=a._parent,!a))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(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&ze.IgnoreOverlays)&&(n=Mr.get(this._tree))&&n.overlay){let s=t-this.from;for(let{from:a,to:l}of n.overlay)if((e>0?a<=s:a<s)&&(e<0?l>=s:l>s))return new vi(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}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 Ap(o,t,e,i){let n=o.cursor(),s=[];if(!n.firstChild())return s;if(e!=null){for(let a=!1;!a;)if(a=n.type.is(e),!n.nextSibling())return s}for(;;){if(i!=null&&n.type.is(i))return s;if(n.type.is(t)&&s.push(n.node),!n.nextSibling())return i==null?s:[]}}function Id(o,t,e=t.length-1){for(let i=o;e>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[e]&&t[e]!=i.name)return!1;e--}}return!0}class d0{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class Ln extends bg{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(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new Ln(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&ze.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new Ln(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Ln(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new Ln(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let a=i.buffer[this.index+1];t.push(i.slice(n,s,a)),e.push(0)}return new Le(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function wg(o){if(!o.length)return null;let t=0,e=o[0];for(let s=1;s<o.length;s++){let a=o[s];(a.from>e.from||a.to<e.to)&&(e=a,t=s)}let i=e instanceof vi&&e.index<0?null:e.parent,n=o.slice();return i?n[t]=i:n.splice(t,1),new h0(n,e)}class h0{constructor(t,e){this.heads=t,this.node=e}get next(){return wg(this.heads)}}function u0(o,t,e){let i=o.resolveInner(t,e),n=null;for(let s=i instanceof vi?i:i.context.parent;s;s=s.parent)if(s.index<0){let a=s.parent;(n||(n=[i])).push(a.resolve(t,e)),s=a}else{let a=Mr.get(s.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let l=new vi(a.tree,a.overlay[0].from+s.from,-1,s);(n||(n=[i])).push(Pr(l,t,e,!1))}}return n?wg(n):i}class bl{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof vi)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return t?t instanceof vi?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-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(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?i&ze.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ze.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&ze.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(e.findChild(n,this.index,-1,0,4))}else{let n=e.buffer[this.index+3];if(n<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(n.buffer.buffer[s+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;{index:e,_parent:i}=i)if(e>-1)for(let s=e+t,a=t<0?-1:i._tree.children.length;s!=a;s+=t){let l=i._tree.children[s];if(this.mode&ze.IncludeAnonymous||l instanceof $o||!l.type.isAnonymous||vh(l))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,s=this.stack.length;s>=0;){for(let a=t;a;a=a._parent)if(a.index==n){if(n==this.index)return a;e=a,i=s+1;break t}n=this.stack[--s]}for(let n=i;n<this.stack.length;n++)e=new Ln(this.buffer,e,this.stack[n]);return this.bufferNode=new Ln(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&e&&e(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return Id(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return Id(this._tree,t,n);let a=i[e.buffer[this.stack[s]]];if(!a.isAnonymous){if(t[n]&&t[n]!=a.name)return!1;n--}}return!0}}function vh(o){return o.children.some(t=>t instanceof $o||!t.type.isAnonymous||vh(t))}function p0(o){var t;let{buffer:e,nodeSet:i,maxBufferLength:n=a0,reused:s=[],minRepeatType:a=i.types.length}=o,l=Array.isArray(e)?new gh(e,e.length):e,c=i.types,u=0,p=0;function v(tt,it,rt,vt,Dt,jt){let{id:gt,start:Ct,end:St,size:Nt}=l,Zt=p,re=u;for(;Nt<0;)if(l.next(),Nt==-1){let Tt=s[gt];rt.push(Tt),vt.push(Ct-tt);return}else if(Nt==-3){u=gt;return}else if(Nt==-4){p=gt;return}else throw new RangeError(`Unrecognized record size: ${Nt}`);let te=c[gt],ut,bt,ht=Ct-tt;if(St-Ct<=n&&(bt=F(l.pos-it,Dt))){let Tt=new Uint16Array(bt.size-bt.skip),mt=l.pos-bt.size,At=Tt.length;for(;l.pos>mt;)At=R(bt.start,Tt,At);ut=new $o(Tt,St-bt.start,i),ht=bt.start-tt}else{let Tt=l.pos-Nt;l.next();let mt=[],At=[],Et=gt>=a?gt:-1,dt=0,b=St;for(;l.pos>Tt;)Et>=0&&l.id==Et&&l.size>=0?(l.end<=b-n&&(M(mt,At,Ct,dt,l.end,b,Et,Zt,re),dt=mt.length,b=l.end),l.next()):jt>2500?x(Ct,Tt,mt,At):v(Ct,Tt,mt,At,Et,jt+1);if(Et>=0&&dt>0&&dt<mt.length&&M(mt,At,Ct,dt,Ct,b,Et,Zt,re),mt.reverse(),At.reverse(),Et>-1&&dt>0){let k=T(te,re);ut=yh(te,mt,At,0,mt.length,0,St-Ct,k,k)}else ut=P(te,mt,At,St-Ct,Zt-St,re)}rt.push(ut),vt.push(ht)}function x(tt,it,rt,vt){let Dt=[],jt=0,gt=-1;for(;l.pos>it;){let{id:Ct,start:St,end:Nt,size:Zt}=l;if(Zt>4)l.next();else{if(gt>-1&&St<gt)break;gt<0&&(gt=Nt-n),Dt.push(Ct,St,Nt),jt++,l.next()}}if(jt){let Ct=new Uint16Array(jt*4),St=Dt[Dt.length-2];for(let Nt=Dt.length-3,Zt=0;Nt>=0;Nt-=3)Ct[Zt++]=Dt[Nt],Ct[Zt++]=Dt[Nt+1]-St,Ct[Zt++]=Dt[Nt+2]-St,Ct[Zt++]=Zt;rt.push(new $o(Ct,Dt[2]-St,i)),vt.push(St-tt)}}function T(tt,it){return(rt,vt,Dt)=>{let jt=0,gt=rt.length-1,Ct,St;if(gt>=0&&(Ct=rt[gt])instanceof Le){if(!gt&&Ct.type==tt&&Ct.length==Dt)return Ct;(St=Ct.prop(de.lookAhead))&&(jt=vt[gt]+Ct.length+St)}return P(tt,rt,vt,Dt,jt,it)}}function M(tt,it,rt,vt,Dt,jt,gt,Ct,St){let Nt=[],Zt=[];for(;tt.length>vt;)Nt.push(tt.pop()),Zt.push(it.pop()+rt-Dt);tt.push(P(i.types[gt],Nt,Zt,jt-Dt,Ct-jt,St)),it.push(Dt-rt)}function P(tt,it,rt,vt,Dt,jt,gt){if(jt){let Ct=[de.contextHash,jt];gt=gt?[Ct].concat(gt):[Ct]}if(Dt>25){let Ct=[de.lookAhead,Dt];gt=gt?[Ct].concat(gt):[Ct]}return new Le(tt,it,rt,vt,gt)}function F(tt,it){let rt=l.fork(),vt=0,Dt=0,jt=0,gt=rt.end-n,Ct={size:0,start:0,skip:0};t:for(let St=rt.pos-tt;rt.pos>St;){let Nt=rt.size;if(rt.id==it&&Nt>=0){Ct.size=vt,Ct.start=Dt,Ct.skip=jt,jt+=4,vt+=4,rt.next();continue}let Zt=rt.pos-Nt;if(Nt<0||Zt<St||rt.start<gt)break;let re=rt.id>=a?4:0,te=rt.start;for(rt.next();rt.pos>Zt;){if(rt.size<0)if(rt.size==-3)re+=4;else break t;else rt.id>=a&&(re+=4);rt.next()}Dt=te,vt+=Nt,jt+=re}return(it<0||vt==tt)&&(Ct.size=vt,Ct.start=Dt,Ct.skip=jt),Ct.size>4?Ct:void 0}function R(tt,it,rt){let{id:vt,start:Dt,end:jt,size:gt}=l;if(l.next(),gt>=0&&vt<a){let Ct=rt;if(gt>4){let St=l.pos-(gt-4);for(;l.pos>St;)rt=R(tt,it,rt)}it[--rt]=Ct,it[--rt]=jt-tt,it[--rt]=Dt-tt,it[--rt]=vt}else gt==-3?u=vt:gt==-4&&(p=vt);return rt}let q=[],H=[];for(;l.pos>0;)v(o.start||0,o.bufferStart||0,q,H,-1,0);let Q=(t=o.length)!==null&&t!==void 0?t:q.length?H[0]+q[0].length:0;return new Le(c[o.topID],q.reverse(),H.reverse(),Q)}const Lp=new WeakMap;function nl(o,t){if(!o.isAnonymous||t instanceof $o||t.type!=o)return 1;let e=Lp.get(t);if(e==null){e=1;for(let i of t.children){if(i.type!=o||!(i instanceof Le)){e=1;break}e+=nl(o,i)}Lp.set(t,e)}return e}function yh(o,t,e,i,n,s,a,l,c){let u=0;for(let M=i;M<n;M++)u+=nl(o,t[M]);let p=Math.ceil(u*1.5/8),v=[],x=[];function T(M,P,F,R,q){for(let H=F;H<R;){let Q=H,tt=P[H],it=nl(o,M[H]);for(H++;H<R;H++){let rt=nl(o,M[H]);if(it+rt>=p)break;it+=rt}if(H==Q+1){if(it>p){let rt=M[Q];T(rt.children,rt.positions,0,rt.children.length,P[Q]+q);continue}v.push(M[Q])}else{let rt=P[H-1]+M[H-1].length-tt;v.push(yh(o,M,P,Q,H,tt,rt,null,c))}x.push(tt+q-s)}}return T(t,e,i,n,0),(l||c)(v,x,a)}class LA{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let n=this.map.get(t);n||this.map.set(t,n=new Map),n.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof Ln?this.setBuffer(t.context.buffer,t.index,e):t instanceof vi&&this.map.set(t.tree,e)}get(t){return t instanceof Ln?this.getBuffer(t.context.buffer,t.index):t instanceof vi?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class io{constructor(t,e,i,n,s=!1,a=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(s?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],i=!1){let n=[new io(0,t.length,t,0,!1,i)];for(let s of e)s.to>t.length&&n.push(s);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],s=1,a=t.length?t[0]:null;for(let l=0,c=0,u=0;;l++){let p=l<e.length?e[l]:null,v=p?p.fromA:1e9;if(v-c>=i)for(;a&&a.from<v;){let x=a;if(c>=x.from||v<=x.to||u){let T=Math.max(x.from,c)-u,M=Math.min(x.to,v)-u;x=T>=M?null:new io(T,M,x.tree,x.offset+u,l>0,!!p)}if(x&&n.push(x),a.to>v)break;a=s<t.length?t[s++]:null}if(!p)break;c=p.toA,u=p.toA-p.toB}return n}}class _g{startParse(t,e,i){return typeof t=="string"&&(t=new f0(t)),i=i?i.length?i.map(n=>new Qi(n.from,n.to)):[new Qi(0,0)]:[new Qi(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let s=n.advance();if(s)return s}}}class f0{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}function NA(o){return(t,e,i,n)=>new g0(t,o,e,i,n)}class Np{constructor(t,e,i,n,s){this.parser=t,this.parse=e,this.overlay=i,this.target=n,this.from=s}}function Mp(o){if(!o.length||o.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(o))}class m0{constructor(t,e,i,n,s,a,l){this.parser=t,this.predicate=e,this.mounts=i,this.index=n,this.start=s,this.target=a,this.prev=l,this.depth=0,this.ranges=[]}}const Ad=new de({perNode:!0});class g0{constructor(t,e,i,n,s){this.nest=e,this.input=i,this.fragments=n,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let n of this.inner)n.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new Le(i.type,i.children,i.positions,i.length,i.propValues.concat([[Ad,this.stoppedAt]]))),i}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[de.mounted.id]=new Mr(e,t.overlay,t.parser),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].from<t&&(t=Math.min(t,this.inner[e].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].parse.stopAt(t)}startInner(){let t=new b0(this.fragments),e=null,i=null,n=new bl(new vi(this.baseTree,this.ranges[0].from,0,null),ze.IncludeAnonymous|ze.IgnoreMounts);t:for(let s,a;;){let l=!0,c;if(this.stoppedAt!=null&&n.from>=this.stoppedAt)l=!1;else if(t.hasNode(n)){if(e){let u=e.mounts.find(p=>p.frag.from<=n.from&&p.frag.to>=n.to&&p.mount.overlay);if(u)for(let p of u.mount.overlay){let v=p.from+u.pos,x=p.to+u.pos;v>=n.from&&x<=n.to&&!e.ranges.some(T=>T.from<x&&T.to>v)&&e.ranges.push({from:v,to:x})}}l=!1}else if(i&&(a=v0(i.ranges,n.from,n.to)))l=a!=2;else if(!n.type.isAnonymous&&(s=this.nest(n,this.input))&&(n.from<n.to||!s.overlay)){n.tree||y0(n);let u=t.findMounts(n.from,s.parser);if(typeof s.overlay=="function")e=new m0(s.parser,s.overlay,u,this.inner.length,n.from,n.tree,e);else{let p=Dp(this.ranges,s.overlay||(n.from<n.to?[new Qi(n.from,n.to)]:[]));p.length&&Mp(p),(p.length||!s.overlay)&&this.inner.push(new Np(s.parser,p.length?s.parser.startParse(this.input,Rp(u,p),p):s.parser.startParse(""),s.overlay?s.overlay.map(v=>new Qi(v.from-n.from,v.to-n.from)):null,n.tree,p.length?p[0].from:n.from)),s.overlay?p.length&&(i={ranges:p,depth:0,prev:i}):l=!1}}else if(e&&(c=e.predicate(n))&&(c===!0&&(c=new Qi(n.from,n.to)),c.from<c.to)){let u=e.ranges.length-1;u>=0&&e.ranges[u].to==c.from?e.ranges[u]={from:e.ranges[u].from,to:c.to}:e.ranges.push(c)}if(l&&n.firstChild())e&&e.depth++,i&&i.depth++;else for(;!n.nextSibling();){if(!n.parent())break t;if(e&&!--e.depth){let u=Dp(this.ranges,e.ranges);u.length&&(Mp(u),this.inner.splice(e.index,0,new Np(e.parser,e.parser.startParse(this.input,Rp(e.mounts,u),u),e.ranges.map(p=>new Qi(p.from-e.start,p.to-e.start)),e.target,u[0].from))),e=e.prev}i&&!--i.depth&&(i=i.prev)}}}}function v0(o,t,e){for(let i of o){if(i.from>=e)break;if(i.to>t)return i.from<=t&&i.to>=e?2:1}return 0}function Pp(o,t,e,i,n,s){if(t<e){let a=o.buffer[t+1];i.push(o.slice(t,e,a)),n.push(a-s)}}function y0(o){let{node:t}=o,e=[],i=t.context.buffer;do e.push(o.index),o.parent();while(!o.tree);let n=o.tree,s=n.children.indexOf(i),a=n.children[s],l=a.buffer,c=[s];function u(p,v,x,T,M,P){let F=e[P],R=[],q=[];Pp(a,p,F,R,q,T);let H=l[F+1],Q=l[F+2];c.push(R.length);let tt=P?u(F+4,l[F+3],a.set.types[l[F]],H,Q-H,P-1):t.toTree();return R.push(tt),q.push(H-T),Pp(a,l[F+3],v,R,q,T),new Le(x,R,q,M)}n.children[s]=u(0,l.length,Ci.none,0,a.length,e.length-1);for(let p of c){let v=o.tree.children[p],x=o.tree.positions[p];o.yield(new vi(v,x+o.from,p,o._tree))}}class Op{constructor(t,e){this.offset=e,this.done=!1,this.cursor=t.cursor(ze.IncludeAnonymous|ze.IgnoreMounts)}moveTo(t){let{cursor:e}=this,i=t-this.offset;for(;!this.done&&e.from<i;)e.to>=t&&e.enter(i,1,ze.IgnoreOverlays|ze.ExcludeBuffers)||e.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(e.children.length&&e.positions[0]==0&&e.children[0]instanceof Le)e=e.children[0];else break}return!1}}class b0{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=(e=i.tree.prop(Ad))!==null&&e!==void 0?e:i.to,this.inner=new Op(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=(t=e.tree.prop(Ad))!==null&&t!==void 0?t:e.to,this.inner=new Op(e.tree,-e.offset)}}findMounts(t,e){var i;let n=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let s=this.inner.cursor.node;s;s=s.parent){let a=(i=s.tree)===null||i===void 0?void 0:i.prop(de.mounted);if(a&&a.parser==e)for(let l=this.fragI;l<this.fragments.length;l++){let c=this.fragments[l];if(c.from>=s.to)break;c.tree==this.curFrag.tree&&n.push({frag:c,pos:s.from-c.offset,mount:a})}}}return n}}function Dp(o,t){let e=null,i=t;for(let n=1,s=0;n<o.length;n++){let a=o[n-1].to,l=o[n].from;for(;s<i.length;s++){let c=i[s];if(c.from>=l)break;c.to<=a||(e||(i=e=t.slice()),c.from<a?(e[s]=new Qi(c.from,a),c.to>l&&e.splice(s+1,0,new Qi(l,c.to))):c.to>l?e[s--]=new Qi(l,c.to):e.splice(s--,1))}}return i}function w0(o,t,e,i){let n=0,s=0,a=!1,l=!1,c=-1e9,u=[];for(;;){let p=n==o.length?1e9:a?o[n].to:o[n].from,v=s==t.length?1e9:l?t[s].to:t[s].from;if(a!=l){let x=Math.max(c,e),T=Math.min(p,v,i);x<T&&u.push(new Qi(x,T))}if(c=Math.min(p,v),c==1e9)break;p==c&&(a?(a=!1,n++):a=!0),v==c&&(l?(l=!1,s++):l=!0)}return u}function Rp(o,t){let e=[];for(let{pos:i,mount:n,frag:s}of o){let a=i+(n.overlay?n.overlay[0].from:0),l=a+n.tree.length,c=Math.max(s.from,a),u=Math.min(s.to,l);if(n.overlay){let p=n.overlay.map(x=>new Qi(x.from+i,x.to+i)),v=w0(t,p,c,u);for(let x=0,T=c;;x++){let M=x==v.length,P=M?u:v[x].from;if(P>T&&e.push(new io(T,P,n.tree,-a,s.from>=T||s.openStart,s.to<=P||s.openEnd)),M)break;T=v[x].to}}else e.push(new io(c,u,n.tree,-a,s.from>=a||s.openStart,s.to<=l||s.openEnd))}return e}let _0=0;class Yi{constructor(t,e,i,n){this.name=t,this.set=e,this.base=i,this.modified=n,this.id=_0++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i=typeof t=="string"?t:"?";if(t instanceof Yi&&(e=t),e!=null&&e.base)throw new Error("Can not derive from a modified tag");let n=new Yi(i,[],null,[]);if(n.set.push(n),e)for(let s of e.set)n.set.push(s);return n}static defineModifier(t){let e=new wl(t);return i=>i.modified.indexOf(e)>-1?i:wl.get(i.base||i,i.modified.concat(e).sort((n,s)=>n.id-s.id))}}let x0=0;class wl{constructor(t){this.name=t,this.instances=[],this.id=x0++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(l=>l.base==t&&k0(e,l.modified));if(i)return i;let n=[],s=new Yi(t.name,n,t,e);for(let l of e)l.instances.push(s);let a=C0(e);for(let l of t.set)if(!l.modified.length)for(let c of a)n.push(wl.get(l,c));return s}}function k0(o,t){return o.length==t.length&&o.every((e,i)=>e==t[i])}function C0(o){let t=[[]];for(let e=0;e<o.length;e++)for(let i=0,n=t.length;i<n;i++)t.push(t[i].concat(o[e]));return t.sort((e,i)=>i.length-e.length)}function $0(o){let t=Object.create(null);for(let e in o){let i=o[e];Array.isArray(i)||(i=[i]);for(let n of e.split(" "))if(n){let s=[],a=2,l=n;for(let v=0;;){if(l=="..."&&v>0&&v+3==n.length){a=1;break}let x=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!x)throw new RangeError("Invalid path: "+n);if(s.push(x[0]=="*"?"":x[0][0]=='"'?JSON.parse(x[0]):x[0]),v+=x[0].length,v==n.length)break;let T=n[v++];if(v==n.length&&T=="!"){a=0;break}if(T!="/")throw new RangeError("Invalid path: "+n);l=n.slice(v)}let c=s.length-1,u=s[c];if(!u)throw new RangeError("Invalid path: "+n);let p=new _l(i,a,c>0?s.slice(0,c):null);t[u]=p.sort(t[u])}}return xg.add(t)}const xg=new de;class _l{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}_l.empty=new _l([],2,null);function kg(o,t){let e=Object.create(null);for(let s of o)if(!Array.isArray(s.tag))e[s.tag.id]=s.class;else for(let a of s.tag)e[a.id]=s.class;let{scope:i,all:n=null}=t||{};return{style:s=>{let a=n;for(let l of s)for(let c of l.set){let u=e[c.id];if(u){a=a?a+" "+u:u;break}}return a},scope:i}}function S0(o,t){let e=null;for(let i of o){let n=i.style(t);n&&(e=e?e+" "+n:n)}return e}function T0(o,t,e,i=0,n=o.length){let s=new E0(i,Array.isArray(t)?t:[t],e);s.highlightRange(o.cursor(),i,n,"",s.highlighters),s.flush(n)}class E0{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,s){let{type:a,from:l,to:c}=t;if(l>=i||c<=e)return;a.isTop&&(s=this.highlighters.filter(T=>!T.scope||T.scope(a)));let u=n,p=I0(t)||_l.empty,v=S0(s,p.tags);if(v&&(u&&(u+=" "),u+=v,p.mode==1&&(n+=(n?" ":"")+v)),this.startSpan(Math.max(e,l),u),p.opaque)return;let x=t.tree&&t.tree.prop(de.mounted);if(x&&x.overlay){let T=t.node.enter(x.overlay[0].from+l,1),M=this.highlighters.filter(F=>!F.scope||F.scope(x.tree.type)),P=t.firstChild();for(let F=0,R=l;;F++){let q=F<x.overlay.length?x.overlay[F]:null,H=q?q.from+l:c,Q=Math.max(e,R),tt=Math.min(i,H);if(Q<tt&&P)for(;t.from<tt&&(this.highlightRange(t,Q,tt,n,s),this.startSpan(Math.min(tt,t.to),u),!(t.to>=H||!t.nextSibling())););if(!q||H>i)break;R=q.to+l,R>e&&(this.highlightRange(T.cursor(),Math.max(e,q.from+l),Math.min(i,R),"",M),this.startSpan(Math.min(i,R),u))}P&&t.parent()}else if(t.firstChild()){x&&(n="");do if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,s),this.startSpan(Math.min(i,t.to),u)}while(t.nextSibling());t.parent()}}}function I0(o){let t=o.type.prop(xg);for(;t&&t.context&&!o.matchContext(t.context);)t=t.next;return t||null}const It=Yi.define,Pa=It(),go=It(),Bp=It(go),zp=It(go),vo=It(),Oa=It(vo),Pc=It(vo),$n=It(),Oo=It($n),kn=It(),Cn=It(),Ld=It(),ar=It(Ld),Da=It(),Ot={comment:Pa,lineComment:It(Pa),blockComment:It(Pa),docComment:It(Pa),name:go,variableName:It(go),typeName:Bp,tagName:It(Bp),propertyName:zp,attributeName:It(zp),className:It(go),labelName:It(go),namespace:It(go),macroName:It(go),literal:vo,string:Oa,docString:It(Oa),character:It(Oa),attributeValue:It(Oa),number:Pc,integer:It(Pc),float:It(Pc),bool:It(vo),regexp:It(vo),escape:It(vo),color:It(vo),url:It(vo),keyword:kn,self:It(kn),null:It(kn),atom:It(kn),unit:It(kn),modifier:It(kn),operatorKeyword:It(kn),controlKeyword:It(kn),definitionKeyword:It(kn),moduleKeyword:It(kn),operator:Cn,derefOperator:It(Cn),arithmeticOperator:It(Cn),logicOperator:It(Cn),bitwiseOperator:It(Cn),compareOperator:It(Cn),updateOperator:It(Cn),definitionOperator:It(Cn),typeOperator:It(Cn),controlOperator:It(Cn),punctuation:Ld,separator:It(Ld),bracket:ar,angleBracket:It(ar),squareBracket:It(ar),paren:It(ar),brace:It(ar),content:$n,heading:Oo,heading1:It(Oo),heading2:It(Oo),heading3:It(Oo),heading4:It(Oo),heading5:It(Oo),heading6:It(Oo),contentSeparator:It($n),list:It($n),quote:It($n),emphasis:It($n),strong:It($n),link:It($n),monospace:It($n),strikethrough:It($n),inserted:It(),deleted:It(),changed:It(),invalid:It(),meta:Da,documentMeta:It(Da),annotation:It(Da),processingInstruction:It(Da),definition:Yi.defineModifier("definition"),constant:Yi.defineModifier("constant"),function:Yi.defineModifier("function"),standard:Yi.defineModifier("standard"),local:Yi.defineModifier("local"),special:Yi.defineModifier("special")};for(let o in Ot){let t=Ot[o];t instanceof Yi&&(t.name=o)}kg([{tag:Ot.link,class:"tok-link"},{tag:Ot.heading,class:"tok-heading"},{tag:Ot.emphasis,class:"tok-emphasis"},{tag:Ot.strong,class:"tok-strong"},{tag:Ot.keyword,class:"tok-keyword"},{tag:Ot.atom,class:"tok-atom"},{tag:Ot.bool,class:"tok-bool"},{tag:Ot.url,class:"tok-url"},{tag:Ot.labelName,class:"tok-labelName"},{tag:Ot.inserted,class:"tok-inserted"},{tag:Ot.deleted,class:"tok-deleted"},{tag:Ot.literal,class:"tok-literal"},{tag:Ot.string,class:"tok-string"},{tag:Ot.number,class:"tok-number"},{tag:[Ot.regexp,Ot.escape,Ot.special(Ot.string)],class:"tok-string2"},{tag:Ot.variableName,class:"tok-variableName"},{tag:Ot.local(Ot.variableName),class:"tok-variableName tok-local"},{tag:Ot.definition(Ot.variableName),class:"tok-variableName tok-definition"},{tag:Ot.special(Ot.variableName),class:"tok-variableName2"},{tag:Ot.definition(Ot.propertyName),class:"tok-propertyName tok-definition"},{tag:Ot.typeName,class:"tok-typeName"},{tag:Ot.namespace,class:"tok-namespace"},{tag:Ot.className,class:"tok-className"},{tag:Ot.macroName,class:"tok-macroName"},{tag:Ot.propertyName,class:"tok-propertyName"},{tag:Ot.operator,class:"tok-operator"},{tag:Ot.comment,class:"tok-comment"},{tag:Ot.meta,class:"tok-meta"},{tag:Ot.invalid,class:"tok-invalid"},{tag:Ot.punctuation,class:"tok-punctuation"}]);var Oc;const Fo=new de;function Cg(o){return Ft.define({combine:o?t=>t.concat(o):void 0})}const A0=new de;class zi{constructor(t,e,i=[],n=""){this.data=t,this.name=n,ve.prototype.hasOwnProperty("tree")||Object.defineProperty(ve.prototype,"tree",{get(){return Wi(this)}}),this.parser=e,this.extension=[So.of(this),ve.languageData.of((s,a,l)=>{let c=Fp(s,a,l),u=c.type.prop(Fo);if(!u)return[];let p=s.facet(u),v=c.type.prop(A0);if(v){let x=c.resolve(a-c.from,l);for(let T of v)if(T.test(x,s)){let M=s.facet(T.facet);return T.type=="replace"?M:M.concat(p)}}return p})].concat(i)}isActiveAt(t,e,i=-1){return Fp(t,e,i).type.prop(Fo)==this.data}findRegions(t){let e=t.facet(So);if(e?.data==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(s,a)=>{if(s.prop(Fo)==this.data){i.push({from:a,to:a+s.length});return}let l=s.prop(de.mounted);if(l){if(l.tree.prop(Fo)==this.data){if(l.overlay)for(let c of l.overlay)i.push({from:c.from+a,to:c.to+a});else i.push({from:a,to:a+s.length});return}else if(l.overlay){let c=i.length;if(n(l.tree,l.overlay[0].from+a),i.length>c)return}}for(let c=0;c<s.children.length;c++){let u=s.children[c];u instanceof Le&&n(u,s.positions[c]+a)}};return n(Wi(t),0),i}get allowsNesting(){return!0}}zi.setState=me.define();function Fp(o,t,e){let i=o.facet(So),n=Wi(o).topNode;if(!i||i.allowsNesting)for(let s=n;s;s=s.enter(t,e,ze.ExcludeBuffers))s.type.isTop&&(n=s);return n}class Nd extends zi{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=Cg(t.languageData);return new Nd(e,t.parser.configure({props:[Fo.add(i=>i.isTop?e:void 0)]}),t.name)}configure(t,e){return new Nd(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Wi(o){let t=o.field(zi.state,!1);return t?t.tree:Le.empty}function $g(o,t,e=50){var i;let n=(i=o.field(zi.state,!1))===null||i===void 0?void 0:i.context;if(!n)return null;let s=n.viewport;n.updateViewport({from:0,to:t});let a=n.isDone(t)||n.work(e,t)?n.tree:null;return n.updateViewport(s),a}class L0{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let lr=null;class $s{constructor(t,e,i=[],n,s,a,l,c){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=a,this.skipped=l,this.scheduleOn=c,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new $s(t,e,[],Le.empty,0,i,[],null)}startParse(){return this.parser.startParse(new L0(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=Le.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof t=="number"){let n=Date.now()+t;t=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(io.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(e??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(io.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=lr;lr=this;try{return t()}finally{lr=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Wp(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:a,skipped:l}=this;if(this.takeTree(),!t.empty){let c=[];if(t.iterChangedRanges((u,p,v,x)=>c.push({fromA:u,toA:p,fromB:v,toB:x})),i=io.applyChanges(i,c),n=Le.empty,s=0,a={from:t.mapPos(a.from,-1),to:t.mapPos(a.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let p=t.mapPos(u.from,1),v=t.mapPos(u.to,-1);p<v&&l.push({from:p,to:v})}}}return new $s(this.parser,e,i,n,s,a,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:n,to:s}=this.skipped[i];n<t.to&&s>t.from&&(this.fragments=Wp(this.fragments,n,s),this.skipped.splice(i--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends _g{createParse(e,i,n){let s=n[0].from,a=n[n.length-1].to;return{parsedPos:s,advance(){let l=lr;if(l){for(let c of n)l.tempSkipped.push(c);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=a,new Le(Ci.none,[],[],a-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return lr}}function Wp(o,t,e){return io.applyChanges(o,[{fromA:t,toA:e,fromB:t,toB:e}])}class Ss{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new Ss(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=$s.create(t.facet(So).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Ss(i)}}zi.state=$i.define({create:Ss.init,update(o,t){for(let e of t.effects)if(e.is(zi.setState))return e.value;return t.startState.facet(So)!=t.state.facet(So)?Ss.init(t.state):o.apply(t)}});let Sg=o=>{let t=setTimeout(()=>o(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Sg=o=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(o,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const Dc=typeof navigator<"u"&&!((Oc=navigator.scheduling)===null||Oc===void 0)&&Oc.isInputPending?()=>navigator.scheduling.isInputPending():null,N0=ti.fromClass(class{constructor(o){this.view=o,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(o){let t=this.view.state.field(zi.state).context;(t.updateViewport(o.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(o.docChanged||o.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:o}=this.view,t=o.field(zi.state);(t.tree!=t.context.tree||!t.context.isDone(o.doc.length))&&(this.working=Sg(this.work))}work(o){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:e,viewport:{to:i}}=this.view,n=e.field(zi.state);if(n.tree==n.context.tree&&n.context.isDone(i+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,o&&!Dc?Math.max(25,o.timeRemaining()-5):1e9),a=n.context.treeLen<i&&e.doc.length>i+1e3,l=n.context.work(()=>Dc&&Dc()||Date.now()>s,i+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:zi.setState.of(new Ss(n.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(o){o.scheduleOn&&(this.workScheduled++,o.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ji(this.view.state,t)).then(()=>this.workScheduled--),o.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),So=Ft.define({combine(o){return o.length?o[0]:null},enables:o=>[zi.state,N0,Wt.contentAttributes.compute([o],t=>{let e=t.facet(o);return e&&e.name?{"data-language":e.name}:{}})]});class MA{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class Tg{constructor(t,e,i,n,s,a=void 0){this.name=t,this.alias=e,this.extensions=i,this.filename=n,this.loadFunc=s,this.support=a,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:e,support:i}=t;if(!e){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(i)}return new Tg(t.name,(t.alias||[]).concat(t.name).map(n=>n.toLowerCase()),t.extensions||[],t.filename,e,i)}static matchFilename(t,e){for(let n of t)if(n.filename&&n.filename.test(e))return n;let i=/\.([^.]+)$/.exec(e);if(i){for(let n of t)if(n.extensions.indexOf(i[1])>-1)return n}return null}static matchLanguageName(t,e,i=!0){e=e.toLowerCase();for(let n of t)if(n.alias.some(s=>s==e))return n;if(i)for(let n of t)for(let s of n.alias){let a=e.indexOf(s);if(a>-1&&(s.length>2||!/\w/.test(e[a-1])&&!/\w/.test(e[a+s.length])))return n}return null}}const M0=Ft.define(),Ts=Ft.define({combine:o=>{if(!o.length)return" ";let t=o[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(o[0]));return t}});function so(o){let t=o.facet(Ts);return t.charCodeAt(0)==9?o.tabSize*t.length:t.length}function xl(o,t){let e="",i=o.tabSize,n=o.facet(Ts)[0];if(n==" "){for(;t>=i;)e+=" ",t-=i;n=" "}for(let s=0;s<t;s++)e+=n;return e}function Eg(o,t){o instanceof ve&&(o=new zl(o));for(let i of o.state.facet(M0)){let n=i(o,t);if(n!==void 0)return n}let e=Wi(o.state);return e.length>=t?P0(o,e,t):null}class zl{constructor(t,e={}){this.state=t,this.options=e,this.unit=so(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:s}=this.options;return n!=null&&n>=i.from&&n<=i.to?s&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.countColumn(i,t-n),a=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return a>-1&&(s+=a-this.countColumn(i,i.search(/\S|$/))),s}countColumn(t,e=t.length){return Ol(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.options.overrideIndentation;if(s){let a=s(n);if(a>-1)return a}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Ig=new de;function P0(o,t,e){let i=t.resolveStack(e),n=t.resolveInner(e,-1).resolve(e,0).enterUnfinishedNodesBefore(e);if(n!=i.node){let s=[];for(let a=n;a&&!(a.from==i.node.from&&a.type==i.node.type);a=a.parent)s.push(a);for(let a=s.length-1;a>=0;a--)i={node:s[a],next:i}}return Ag(i,o,e)}function Ag(o,t,e){for(let i=o;i;i=i.next){let n=D0(i.node);if(n)return n(bh.create(t,e,i))}return 0}function O0(o){return o.pos==o.options.simulateBreak&&o.options.simulateDoubleBreak}function D0(o){let t=o.type.prop(Ig);if(t)return t;let e=o.firstChild,i;if(e&&(i=e.type.prop(de.closedBy))){let n=o.lastChild,s=n&&i.indexOf(n.name)>-1;return a=>Lg(a,!0,1,void 0,s&&!O0(a)?n.from:void 0)}return o.parent==null?R0:null}function R0(){return 0}class bh extends zl{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new bh(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(B0(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return Ag(this.context.next,this.base,this.pos)}}function B0(o,t){for(let e=t;e;e=e.parent)if(o==e)return!0;return!1}function z0(o){let t=o.node,e=t.childAfter(t.from),i=t.lastChild;if(!e)return null;let n=o.options.simulateBreak,s=o.state.doc.lineAt(e.from),a=n==null||n<=s.from?s.to:Math.min(s.to,n);for(let l=e.to;;){let c=t.childAfter(l);if(!c||c==i)return null;if(!c.type.isSkipped){if(c.from>=a)return null;let u=/^ */.exec(s.text.slice(e.to-s.from))[0].length;return{from:e.from,to:e.to+u}}l=c.to}}function PA({closing:o,align:t=!0,units:e=1}){return i=>Lg(i,t,e,o)}function Lg(o,t,e,i,n){let s=o.textAfter,a=s.match(/^\s*/)[0].length,l=i&&s.slice(a,a+i.length)==i||n==o.pos+a,c=t?z0(o):null;return c?l?o.column(c.from):o.column(c.to):o.baseIndent+(l?0:o.unit*e)}const OA=o=>o.baseIndent;function DA({except:o,units:t=1}={}){return e=>{let i=o&&o.test(e.textAfter);return e.baseIndent+(i?0:t*e.unit)}}const F0=Ft.define(),W0=new de;function RA(o){let t=o.firstChild,e=o.lastChild;return t&&t.to<e.from?{from:t.to,to:e.type.isError?o.to:e.from}:null}function H0(o,t,e){let i=Wi(o);if(i.length<e)return null;let n=i.resolveStack(e,1),s=null;for(let a=n;a;a=a.next){let l=a.node;if(l.to<=e||l.from>e)continue;if(s&&l.from<t)break;let c=l.type.prop(W0);if(c&&(l.to<i.length-50||i.length==o.doc.length||!V0(l))){let u=c(l,o);u&&u.from<=e&&u.from>=t&&u.to>e&&(s=u)}}return s}function V0(o){let t=o.lastChild;return t&&t.to==o.to&&t.type.isError}function Md(o,t,e){for(let i of o.facet(F0)){let n=i(o,t,e);if(n)return n}return H0(o,t,e)}function Ng(o,t){let e=t.mapPos(o.from,1),i=t.mapPos(o.to,-1);return e>=i?void 0:{from:e,to:i}}const wh=me.define({map:Ng}),Fl=me.define({map:Ng});function U0(o){let t=[];for(let{head:e}of o.state.selection.ranges)t.some(i=>i.from<=e&&i.to>=e)||t.push(o.lineBlockAt(e));return t}const Es=$i.define({create(){return Yt.none},update(o,t){o=o.map(t.changes);for(let e of t.effects)if(e.is(wh)&&!j0(o,e.value.from,e.value.to)){let{preparePlaceholder:i}=t.state.facet(Mg),n=i?Yt.replace({widget:new Y0(i(t.state,e.value))}):Hp;o=o.update({add:[n.range(e.value.from,e.value.to)]})}else e.is(Fl)&&(o=o.update({filter:(i,n)=>e.value.from!=i||e.value.to!=n,filterFrom:e.value.from,filterTo:e.value.to}));if(t.selection){let e=!1,{head:i}=t.selection.main;o.between(i,i,(n,s)=>{n<i&&s>i&&(e=!0)}),e&&(o=o.update({filterFrom:i,filterTo:i,filter:(n,s)=>s<=i||n>=i}))}return o},provide:o=>Wt.decorations.from(o),toJSON(o,t){let e=[];return o.between(0,t.doc.length,(i,n)=>{e.push(i,n)}),e},fromJSON(o){if(!Array.isArray(o)||o.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let e=0;e<o.length;){let i=o[e++],n=o[e++];if(typeof i!="number"||typeof n!="number")throw new RangeError("Invalid JSON for fold state");t.push(Hp.range(i,n))}return Yt.set(t,!0)}});function Pd(o,t,e){var i;let n=null;return(i=o.field(Es,!1))===null||i===void 0||i.between(t,e,(s,a)=>{(!n||n.from>s)&&(n={from:s,to:a})}),n}function j0(o,t,e){let i=!1;return o.between(t,t,(n,s)=>{n==t&&s==e&&(i=!0)}),i}function q0(o,t){return o.field(Es,!1)?t:t.concat(me.appendConfig.of(_h()))}const K0=o=>{for(let t of U0(o)){let e=Md(o.state,t.from,t.to);if(e)return o.dispatch({effects:q0(o.state,[wh.of(e),Z0(o,e)])}),!0}return!1};function Z0(o,t,e=!0){let i=o.state.doc.lineAt(t.from).number,n=o.state.doc.lineAt(t.to).number;return Wt.announce.of(`${o.state.phrase(e?"Folded lines":"Unfolded lines")} ${i} ${o.state.phrase("to")} ${n}.`)}const G0={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Mg=Ft.define({combine(o){return ro(o,G0)}});function _h(o){return[Es,X0]}function Pg(o,t){let{state:e}=o,i=e.facet(Mg),n=a=>{let l=o.lineBlockAt(o.posAtDOM(a.target)),c=Pd(o.state,l.from,l.to);c&&o.dispatch({effects:Fl.of(c)}),a.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(o,n,t);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",e.phrase("folded code")),s.title=e.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=n,s}const Hp=Yt.replace({widget:new class extends Zo{toDOM(o){return Pg(o,null)}}});class Y0 extends Zo{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Pg(t,this.value)}}const J0={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Rc extends oo{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function Q0(o={}){let t=Object.assign(Object.assign({},J0),o),e=new Rc(t,!0),i=new Rc(t,!1),n=ti.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(So)!=a.state.facet(So)||a.startState.field(Es,!1)!=a.state.field(Es,!1)||Wi(a.startState)!=Wi(a.state)||t.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let l=new On;for(let c of a.viewportLineBlocks){let u=Pd(a.state,c.from,c.to)?i:Md(a.state,c.from,c.to)?e:null;u&&l.add(c.from,c.from,u)}return l.finish()}}),{domEventHandlers:s}=t;return[n,mg({class:"cm-foldGutter",markers(a){var l;return((l=a.plugin(n))===null||l===void 0?void 0:l.markers)||ue.empty},initialSpacer(){return new Rc(t,!1)},domEventHandlers:Object.assign(Object.assign({},s),{click:(a,l,c)=>{if(s.click&&s.click(a,l,c))return!0;let u=Pd(a.state,l.from,l.to);if(u)return a.dispatch({effects:Fl.of(u)}),!0;let p=Md(a.state,l.from,l.to);return p?(a.dispatch({effects:wh.of(p)}),!0):!1}})}),_h()]}const X0=Wt.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Wl{constructor(t,e){this.specs=t;let i;function n(l){let c=xo.newName();return(i||(i=Object.create(null)))["."+c]=l,c}const s=typeof e.all=="string"?e.all:e.all?n(e.all):void 0,a=e.scope;this.scope=a instanceof zi?l=>l.prop(Fo)==a.data:a?l=>l==a:void 0,this.style=kg(t.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new xo(i):null,this.themeType=e.themeType}static define(t,e){return new Wl(t,e||{})}}const Od=Ft.define(),Og=Ft.define({combine(o){return o.length?[o[0]]:null}});function Bc(o){let t=o.facet(Od);return t.length?t:o.facet(Og)}function tk(o,t){let e=[ik],i;return o instanceof Wl&&(o.module&&e.push(Wt.styleModule.of(o.module)),i=o.themeType),t!=null&&t.fallback?e.push(Og.of(o)):i?e.push(Od.computeN([Wt.darkTheme],n=>n.facet(Wt.darkTheme)==(i=="dark")?[o]:[])):e.push(Od.of(o)),e}class ek{constructor(t){this.markCache=Object.create(null),this.tree=Wi(t.state),this.decorations=this.buildDeco(t,Bc(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=Wi(t.state),i=Bc(t.state),n=i!=Bc(t.startState),{viewport:s}=t.view,a=t.changes.mapPos(this.decoratedTo,1);e.length<s.to&&!n&&e.type==this.tree.type&&a>=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=a):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=s.to)}buildDeco(t,e){if(!e||!this.tree.length)return Yt.none;let i=new On;for(let{from:n,to:s}of t.visibleRanges)T0(this.tree,e,(a,l,c)=>{i.add(a,l,this.markCache[c]||(this.markCache[c]=Yt.mark({class:c})))},n,s);return i.finish()}}const ik=Pl.high(ti.fromClass(ek,{decorations:o=>o.decorations})),nk=Wl.define([{tag:Ot.meta,color:"#404740"},{tag:Ot.link,textDecoration:"underline"},{tag:Ot.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Ot.emphasis,fontStyle:"italic"},{tag:Ot.strong,fontWeight:"bold"},{tag:Ot.strikethrough,textDecoration:"line-through"},{tag:Ot.keyword,color:"#708"},{tag:[Ot.atom,Ot.bool,Ot.url,Ot.contentSeparator,Ot.labelName],color:"#219"},{tag:[Ot.literal,Ot.inserted],color:"#164"},{tag:[Ot.string,Ot.deleted],color:"#a11"},{tag:[Ot.regexp,Ot.escape,Ot.special(Ot.string)],color:"#e40"},{tag:Ot.definition(Ot.variableName),color:"#00f"},{tag:Ot.local(Ot.variableName),color:"#30a"},{tag:[Ot.typeName,Ot.namespace],color:"#085"},{tag:Ot.className,color:"#167"},{tag:[Ot.special(Ot.variableName),Ot.macroName],color:"#256"},{tag:Ot.definition(Ot.propertyName),color:"#00c"},{tag:Ot.comment,color:"#940"},{tag:Ot.invalid,color:"#f00"}]),ok=Wt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Dg=1e4,Rg="()[]{}",Bg=Ft.define({combine(o){return ro(o,{afterCursor:!0,brackets:Rg,maxScanDistance:Dg,renderMatch:ak})}}),sk=Yt.mark({class:"cm-matchingBracket"}),rk=Yt.mark({class:"cm-nonmatchingBracket"});function ak(o){let t=[],e=o.matched?sk:rk;return t.push(e.range(o.start.from,o.start.to)),o.end&&t.push(e.range(o.end.from,o.end.to)),t}const lk=$i.define({create(){return Yt.none},update(o,t){if(!t.docChanged&&!t.selection)return o;let e=[],i=t.state.facet(Bg);for(let n of t.state.selection.ranges){if(!n.empty)continue;let s=Xi(t.state,n.head,-1,i)||n.head>0&&Xi(t.state,n.head-1,1,i)||i.afterCursor&&(Xi(t.state,n.head,1,i)||n.head<t.state.doc.length&&Xi(t.state,n.head+1,-1,i));s&&(e=e.concat(i.renderMatch(s,t.state)))}return Yt.set(e,!0)},provide:o=>Wt.decorations.from(o)}),ck=[lk,ok];function dk(o={}){return[Bg.of(o),ck]}const hk=new de;function Dd(o,t,e){let i=o.prop(t<0?de.openedBy:de.closedBy);if(i)return i;if(o.name.length==1){let n=e.indexOf(o.name);if(n>-1&&n%2==(t<0?1:0))return[e[n+t]]}return null}function Rd(o){let t=o.type.prop(hk);return t?t(o.node):o}function Xi(o,t,e,i={}){let n=i.maxScanDistance||Dg,s=i.brackets||Rg,a=Wi(o),l=a.resolveInner(t,e);for(let c=l;c;c=c.parent){let u=Dd(c.type,e,s);if(u&&c.from<c.to){let p=Rd(c);if(p&&(e>0?t>=p.from&&t<p.to:t>p.from&&t<=p.to))return uk(o,t,e,c,p,u,s)}}return pk(o,t,e,a,l.type,n,s)}function uk(o,t,e,i,n,s,a){let l=i.parent,c={from:n.from,to:n.to},u=0,p=l?.cursor();if(p&&(e<0?p.childBefore(i.from):p.childAfter(i.to)))do if(e<0?p.to<=i.from:p.from>=i.to){if(u==0&&s.indexOf(p.type.name)>-1&&p.from<p.to){let v=Rd(p);return{start:c,end:v?{from:v.from,to:v.to}:void 0,matched:!0}}else if(Dd(p.type,e,a))u++;else if(Dd(p.type,-e,a)){if(u==0){let v=Rd(p);return{start:c,end:v&&v.from<v.to?{from:v.from,to:v.to}:void 0,matched:!1}}u--}}while(e<0?p.prevSibling():p.nextSibling());return{start:c,matched:!1}}function pk(o,t,e,i,n,s,a){let l=e<0?o.sliceDoc(t-1,t):o.sliceDoc(t,t+1),c=a.indexOf(l);if(c<0||c%2==0!=e>0)return null;let u={from:e<0?t-1:t,to:e>0?t+1:t},p=o.doc.iterRange(t,e>0?o.doc.length:0),v=0;for(let x=0;!p.next().done&&x<=s;){let T=p.value;e<0&&(x+=T.length);let M=t+x*e;for(let P=e>0?0:T.length-1,F=e>0?T.length:-1;P!=F;P+=e){let R=a.indexOf(T[P]);if(!(R<0||i.resolveInner(M+P,1).type!=n))if(R%2==0==e>0)v++;else{if(v==1)return{start:u,end:{from:M+P,to:M+P+1},matched:R>>1==c>>1};v--}}e>0&&(x+=T.length)}return p.done?{start:u,matched:!1}:null}function Vp(o,t,e,i=0,n=0){t==null&&(t=o.search(/[^\s\u00a0]/),t==-1&&(t=o.length));let s=n;for(let a=i;a<t;a++)o.charCodeAt(a)==9?s+=e-s%e:s++;return s}class xh{constructor(t,e,i,n){this.string=t,this.tabSize=e,this.indentUnit=i,this.overrideIndent=n,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e=this.string.charAt(this.pos),i;if(typeof t=="string"?i=e==t:i=e&&(t instanceof RegExp?t.test(e):t(e)),i)return++this.pos,e}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Vp(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:Vp(this.string,null,this.tabSize)}match(t,e,i){if(typeof t=="string"){let n=a=>i?a.toLowerCase():a,s=this.string.substr(this.pos,t.length);return n(s)==n(t)?(e!==!1&&(this.pos+=t.length),!0):null}else{let n=this.string.slice(this.pos).match(t);return n&&n.index>0?null:(n&&e!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}}function fk(o){return{name:o.name||"",token:o.token,blankLine:o.blankLine||(()=>{}),startState:o.startState||(()=>!0),copyState:o.copyState||mk,indent:o.indent||(()=>null),languageData:o.languageData||{},tokenTable:o.tokenTable||$h,mergeTokens:o.mergeTokens!==!1}}function mk(o){if(typeof o!="object")return o;let t={};for(let e in o){let i=o[e];t[e]=i instanceof Array?i.slice():i}return t}const Up=new WeakMap;class kh extends zi{constructor(t){let e=Cg(t.languageData),i=fk(t),n,s=new class extends _g{createParse(a,l,c){return new vk(n,a,l,c)}};super(e,s,[],t.name),this.topNode=wk(e,this),n=this,this.streamParser=i,this.stateAfter=new de({perNode:!0}),this.tokenTable=t.tokenTable?new Hg(i.tokenTable):bk}static define(t){return new kh(t)}getIndent(t){let e,{overrideIndentation:i}=t.options;i&&(e=Up.get(t.state),e!=null&&e<t.pos-1e4&&(e=void 0));let n=Ch(this,t.node.tree,t.node.from,t.node.from,e??t.pos),s,a;if(n?(a=n.state,s=n.pos+1):(a=this.streamParser.startState(t.unit),s=t.node.from),t.pos-s>1e4)return null;for(;s<t.pos;){let c=t.state.doc.lineAt(s),u=Math.min(t.pos,c.to);if(c.length){let p=i?i(c.from):-1,v=new xh(c.text,t.state.tabSize,t.unit,p<0?void 0:p);for(;v.pos<u-c.from;)Fg(this.streamParser.token,v,a)}else this.streamParser.blankLine(a,t.unit);if(u==t.pos)break;s=c.to+1}let l=t.lineAt(t.pos);return i&&e==null&&Up.set(t.state,l.from),this.streamParser.indent(a,/^\s*(.*)/.exec(l.text)[1],t)}get allowsNesting(){return!1}}function Ch(o,t,e,i,n){let s=e>=i&&e+t.length<=n&&t.prop(o.stateAfter);if(s)return{state:o.streamParser.copyState(s),pos:e+t.length};for(let a=t.children.length-1;a>=0;a--){let l=t.children[a],c=e+t.positions[a],u=l instanceof Le&&c<n&&Ch(o,l,c,i,n);if(u)return u}return null}function zg(o,t,e,i,n){if(n&&e<=0&&i>=t.length)return t;!n&&e==0&&t.type==o.topNode&&(n=!0);for(let s=t.children.length-1;s>=0;s--){let a=t.positions[s],l=t.children[s],c;if(a<i&&l instanceof Le){if(!(c=zg(o,l,e-a,i-a,n)))break;return n?new Le(t.type,t.children.slice(0,s).concat(c),t.positions.slice(0,s+1),a+c.length):c}}return null}function gk(o,t,e,i,n){for(let s of t){let a=s.from+(s.openStart?25:0),l=s.to-(s.openEnd?25:0),c=a<=e&&l>e&&Ch(o,s.tree,0-s.offset,e,l),u;if(c&&c.pos<=i&&(u=zg(o,s.tree,e+s.offset,c.pos+s.offset,!1)))return{state:c.state,tree:u}}return{state:o.streamParser.startState(n?so(n):4),tree:Le.empty}}class vk{constructor(t,e,i,n){this.lang=t,this.input=e,this.fragments=i,this.ranges=n,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=n[n.length-1].to;let s=$s.get(),a=n[0].from,{state:l,tree:c}=gk(t,i,a,this.to,s?.state);this.state=l,this.parsedPos=this.chunkStart=a+c.length;for(let u=0;u<c.children.length;u++)this.chunks.push(c.children[u]),this.chunkPos.push(c.positions[u]);s&&this.parsedPos<s.viewport.from-1e5&&n.some(u=>u.from<=s.viewport.from&&u.to>=s.viewport.from)&&(this.state=this.lang.streamParser.startState(so(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let t=$s.get(),e=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(e,this.chunkStart+2048);for(t&&(i=Math.min(i,t.viewport.to));this.parsedPos<i;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)e==`
|
||
`&&(e="");else{let i=e.indexOf(`
|
||
`);i>-1&&(e=e.slice(0,i))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),i=t+e.length;for(let n=this.rangeIndex;;){let s=this.ranges[n].to;if(s>=i||(e=e.slice(0,s-(i-e.length)),n++,n==this.ranges.length))break;let a=this.ranges[n].from,l=this.lineAfter(a);e+=l,i=a+l.length}return{line:e,end:i}}skipGapsTo(t,e,i){for(;;){let n=this.ranges[this.rangeIndex].to,s=t+e;if(i>0?n>s:n>=s)break;let a=this.ranges[++this.rangeIndex].from;e+=a-n}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,i,n){let s=4;if(this.ranges.length>1){n=this.skipGapsTo(e,n,1),e+=n;let l=this.chunk.length;n=this.skipGapsTo(i,n,-1),i+=n,s+=this.chunk.length-l}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&s==4&&a>=0&&this.chunk[a]==t&&this.chunk[a+2]==e?this.chunk[a+2]=i:this.chunk.push(t,e,i,s),n}parseLine(t){let{line:e,end:i}=this.nextLine(),n=0,{streamParser:s}=this.lang,a=new xh(e,t?t.state.tabSize:4,t?so(t.state):2);if(a.eol())s.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let l=Fg(s.token,a,this.state);if(l&&(n=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+a.start,this.parsedPos+a.pos,n)),a.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=Le.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:yk,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new Le(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new Le(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function Fg(o,t,e){t.start=t.pos;for(let i=0;i<10;i++){let n=o(t,e);if(t.pos>t.start)return n}throw new Error("Stream parser failed to advance stream.")}const $h=Object.create(null),Or=[Ci.none],yk=new mh(Or),jp=[],qp=Object.create(null),Wg=Object.create(null);for(let[o,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Wg[o]=Vg($h,t);class Hg{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Wg)}resolve(t){return t?this.table[t]||(this.table[t]=Vg(this.extra,t)):0}}const bk=new Hg($h);function zc(o,t){jp.indexOf(o)>-1||(jp.push(o),console.warn(t))}function Vg(o,t){let e=[];for(let l of t.split(" ")){let c=[];for(let u of l.split(".")){let p=o[u]||Ot[u];p?typeof p=="function"?c.length?c=c.map(p):zc(u,`Modifier ${u} used at start of tag`):c.length?zc(u,`Tag ${u} used as modifier`):c=Array.isArray(p)?p:[p]:zc(u,`Unknown highlighting tag ${u}`)}for(let u of c)e.push(u)}if(!e.length)return 0;let i=t.replace(/ /g,"_"),n=i+" "+e.map(l=>l.id),s=qp[n];if(s)return s.id;let a=qp[n]=Ci.define({id:Or.length,name:i,props:[$0({[i]:e})]});return Or.push(a),a.id}function wk(o,t){let e=Ci.define({id:Or.length,name:"Document",props:[Fo.add(()=>o),Ig.add(()=>i=>t.getIndent(i))],top:!0});return Or.push(e),e}Fe.RTL,Fe.LTR;const _k=o=>{let{state:t}=o,e=t.doc.lineAt(t.selection.main.from),i=Th(o.state,e.from);return i.line?xk(o):i.block?Ck(o):!1};function Sh(o,t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=o(t,e);return n?(i(e.update(n)),!0):!1}}const xk=Sh(Tk,0),kk=Sh(Ug,0),Ck=Sh((o,t)=>Ug(o,t,Sk(t)),0);function Th(o,t){let e=o.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}const cr=50;function $k(o,{open:t,close:e},i,n){let s=o.sliceDoc(i-cr,i),a=o.sliceDoc(n,n+cr),l=/\s*$/.exec(s)[0].length,c=/^\s*/.exec(a)[0].length,u=s.length-l;if(s.slice(u-t.length,u)==t&&a.slice(c,c+e.length)==e)return{open:{pos:i-l,margin:l&&1},close:{pos:n+c,margin:c&&1}};let p,v;n-i<=2*cr?p=v=o.sliceDoc(i,n):(p=o.sliceDoc(i,i+cr),v=o.sliceDoc(n-cr,n));let x=/^\s*/.exec(p)[0].length,T=/\s*$/.exec(v)[0].length,M=v.length-T-e.length;return p.slice(x,x+t.length)==t&&v.slice(M,M+e.length)==e?{open:{pos:i+x+t.length,margin:/\s/.test(p.charAt(x+t.length))?1:0},close:{pos:n-T-e.length,margin:/\s/.test(v.charAt(M-1))?1:0}}:null}function Sk(o){let t=[];for(let e of o.selection.ranges){let i=o.doc.lineAt(e.from),n=e.to<=i.to?i:o.doc.lineAt(e.to);n.from>i.from&&n.from==e.to&&(n=e.to==i.to+1?i:o.doc.lineAt(e.to-1));let s=t.length-1;s>=0&&t[s].to>i.from?t[s].to=n.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:n.to})}return t}function Ug(o,t,e=t.selection.ranges){let i=e.map(s=>Th(t,s.from).block);if(!i.every(s=>s))return null;let n=e.map((s,a)=>$k(t,i[a],s.from,s.to));if(o!=2&&!n.every(s=>s))return{changes:t.changes(e.map((s,a)=>n[a]?[]:[{from:s.from,insert:i[a].open+" "},{from:s.to,insert:" "+i[a].close}]))};if(o!=1&&n.some(s=>s)){let s=[];for(let a=0,l;a<n.length;a++)if(l=n[a]){let c=i[a],{open:u,close:p}=l;s.push({from:u.pos-c.open.length,to:u.pos+u.margin},{from:p.pos-p.margin,to:p.pos+c.close.length})}return{changes:s}}return null}function Tk(o,t,e=t.selection.ranges){let i=[],n=-1;for(let{from:s,to:a}of e){let l=i.length,c=1e9,u=Th(t,s).line;if(u){for(let p=s;p<=a;){let v=t.doc.lineAt(p);if(v.from>n&&(s==a||a>v.from)){n=v.from;let x=/^\s*/.exec(v.text)[0].length,T=x==v.length,M=v.text.slice(x,x+u.length)==u?x:-1;x<v.text.length&&x<c&&(c=x),i.push({line:v,comment:M,token:u,indent:x,empty:T,single:!1})}p=v.to+1}if(c<1e9)for(let p=l;p<i.length;p++)i[p].indent<i[p].line.text.length&&(i[p].indent=c);i.length==l+1&&(i[l].single=!0)}}if(o!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:c,indent:u,empty:p,single:v}of i)(v||!p)&&s.push({from:l.from+u,insert:c+" "});let a=t.changes(s);return{changes:a,selection:t.selection.map(a,1)}}else if(o!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:a,comment:l,token:c}of i)if(l>=0){let u=a.from+l,p=u+c.length;a.text[p-a.from]==" "&&p++,s.push({from:u,to:p})}return{changes:s}}return null}const Bd=To.define(),Ek=To.define(),Ik=Ft.define(),jg=Ft.define({combine(o){return ro(o,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})}}),qg=$i.define({create(){return Nn.empty},update(o,t){let e=t.state.facet(jg),i=t.annotation(Bd);if(i){let c=Ni.fromTransaction(t,i.selection),u=i.side,p=u==0?o.undone:o.done;return c?p=Cl(p,p.length,e.minDepth,c):p=Zg(p,t.startState.selection),new Nn(u==0?i.rest:p,u==0?p:i.rest)}let n=t.annotation(Ek);if((n=="full"||n=="before")&&(o=o.isolate()),t.annotation(Qe.addToHistory)===!1)return t.changes.empty?o:o.addMapping(t.changes.desc);let s=Ni.fromTransaction(t),a=t.annotation(Qe.time),l=t.annotation(Qe.userEvent);return s?o=o.addChanges(s,a,l,e,t):t.selection&&(o=o.addSelection(t.startState.selection,a,l,e.newGroupDelay)),(n=="full"||n=="after")&&(o=o.isolate()),o},toJSON(o){return{done:o.done.map(t=>t.toJSON()),undone:o.undone.map(t=>t.toJSON())}},fromJSON(o){return new Nn(o.done.map(Ni.fromJSON),o.undone.map(Ni.fromJSON))}});function Kp(o={}){return[qg,jg.of(o),Wt.domEventHandlers({beforeinput(t,e){let i=t.inputType=="historyUndo"?Eh:t.inputType=="historyRedo"?kl:null;return i?(t.preventDefault(),i(e)):!1}})]}function Hl(o,t){return function({state:e,dispatch:i}){if(!t&&e.readOnly)return!1;let n=e.field(qg,!1);if(!n)return!1;let s=n.pop(o,e,t);return s?(i(s),!0):!1}}const Eh=Hl(0,!1),kl=Hl(1,!1),Ak=Hl(0,!0),Lk=Hl(1,!0);class Ni{constructor(t,e,i,n,s){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=s}setSelAfter(t){return new Ni(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(e=this.mapped)===null||e===void 0?void 0:e.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(t){return new Ni(t.changes&&Je.fromJSON(t.changes),[],t.mapped&&Pn.fromJSON(t.mapped),t.startSelection&&xt.fromJSON(t.startSelection),t.selectionsAfter.map(xt.fromJSON))}static fromTransaction(t,e){let i=tn;for(let n of t.startState.facet(Ik)){let s=n(t);s.length&&(i=i.concat(s))}return!i.length&&t.changes.empty?null:new Ni(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,tn)}static selection(t){return new Ni(void 0,tn,void 0,void 0,t)}}function Cl(o,t,e,i){let n=t+1>e+20?t-e-1:0,s=o.slice(n,t);return s.push(i),s}function Nk(o,t){let e=[],i=!1;return o.iterChangedRanges((n,s)=>e.push(n,s)),t.iterChangedRanges((n,s,a,l)=>{for(let c=0;c<e.length;){let u=e[c++],p=e[c++];l>=u&&a<=p&&(i=!0)}}),i}function Mk(o,t){return o.ranges.length==t.ranges.length&&o.ranges.filter((e,i)=>e.empty!=t.ranges[i].empty).length===0}function Kg(o,t){return o.length?t.length?o.concat(t):o:t}const tn=[],Pk=200;function Zg(o,t){if(o.length){let e=o[o.length-1],i=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-Pk));return i.length&&i[i.length-1].eq(t)?o:(i.push(t),Cl(o,o.length-1,1e9,e.setSelAfter(i)))}else return[Ni.selection([t])]}function Ok(o){let t=o[o.length-1],e=o.slice();return e[o.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),e}function Fc(o,t){if(!o.length)return o;let e=o.length,i=tn;for(;e;){let n=Dk(o[e-1],t,i);if(n.changes&&!n.changes.empty||n.effects.length){let s=o.slice(0,e);return s[e-1]=n,s}else t=n.mapped,e--,i=n.selectionsAfter}return i.length?[Ni.selection(i)]:tn}function Dk(o,t,e){let i=Kg(o.selectionsAfter.length?o.selectionsAfter.map(l=>l.map(t)):tn,e);if(!o.changes)return Ni.selection(i);let n=o.changes.map(t),s=t.mapDesc(o.changes,!0),a=o.mapped?o.mapped.composeDesc(s):s;return new Ni(n,me.mapEffects(o.effects,t),a,o.startSelection.map(s),i)}const Rk=/^(input\.type|delete)($|\.)/;class Nn{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new Nn(this.done,this.undone):this}addChanges(t,e,i,n,s){let a=this.done,l=a[a.length-1];return l&&l.changes&&!l.changes.empty&&t.changes&&(!i||Rk.test(i))&&(!l.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(s,Nk(l.changes,t.changes))||i=="input.type.compose")?a=Cl(a,a.length-1,n.minDepth,new Ni(t.changes.compose(l.changes),Kg(me.mapEffects(t.effects,l.changes),l.effects),l.mapped,l.startSelection,tn)):a=Cl(a,a.length,n.minDepth,t),new Nn(a,tn,e,i)}addSelection(t,e,i,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:tn;return s.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&Mk(s[s.length-1],t)?this:new Nn(Zg(this.done,t),this.undone,e,i)}addMapping(t){return new Nn(Fc(this.done,t),Fc(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=t==0?this.done:this.undone;if(n.length==0)return null;let s=n[n.length-1],a=s.selectionsAfter[0]||e.selection;if(i&&s.selectionsAfter.length)return e.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Bd.of({side:t,rest:Ok(n),selection:a}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=n.length==1?tn:n.slice(0,n.length-1);return s.mapped&&(l=Fc(l,s.mapped)),e.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Bd.of({side:t,rest:l,selection:a}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}Nn.empty=new Nn(tn,tn);const Bk=[{key:"Mod-z",run:Eh,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:kl,preventDefault:!0},{linux:"Ctrl-Shift-z",run:kl,preventDefault:!0},{key:"Mod-u",run:Ak,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Lk,preventDefault:!0}];function Ls(o,t){return xt.create(o.ranges.map(t),o.mainIndex)}function Rn(o,t){return o.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function yn({state:o,dispatch:t},e){let i=Ls(o.selection,e);return i.eq(o.selection,!0)?!1:(t(Rn(o,i)),!0)}function Vl(o,t){return xt.cursor(t?o.to:o.from)}function Ih(o,t){return yn(o,e=>e.empty?o.moveByChar(e,t):Vl(e,t))}function bi(o){return o.textDirectionAt(o.state.selection.main.head)==Fe.LTR}const Ah=o=>Ih(o,!bi(o)),Gg=o=>Ih(o,bi(o)),zk=o=>Ih(o,!1);function Yg(o,t){return yn(o,e=>e.empty?o.moveByGroup(e,t):Vl(e,t))}const Fk=o=>Yg(o,!bi(o)),Wk=o=>Yg(o,bi(o));function Hk(o,t,e){if(t.type.prop(e))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(o.sliceDoc(t.from,t.to)))||t.firstChild}function Ul(o,t,e){let i=Wi(o).resolveInner(t.head),n=e?de.closedBy:de.openedBy;for(let c=t.head;;){let u=e?i.childAfter(c):i.childBefore(c);if(!u)break;Hk(o,u,n)?i=u:c=e?u.to:u.from}let s=i.type.prop(n),a,l;return s&&(a=e?Xi(o,i.from,1):Xi(o,i.to,-1))&&a.matched?l=e?a.end.to:a.end.from:l=e?i.to:i.from,xt.cursor(l,e?-1:1)}const Vk=o=>yn(o,t=>Ul(o.state,t,!bi(o))),Uk=o=>yn(o,t=>Ul(o.state,t,bi(o)));function Jg(o,t){return yn(o,e=>{if(!e.empty)return Vl(e,t);let i=o.moveVertically(e,t);return i.head!=e.head?i:o.moveToLineBoundary(e,t)})}const Qg=o=>Jg(o,!1),Xg=o=>Jg(o,!0);function tv(o){let t=o.scrollDOM.clientHeight<o.scrollDOM.scrollHeight-2,e=0,i=0,n;if(t){for(let s of o.state.facet(Wt.scrollMargins)){let a=s(o);a!=null&&a.top&&(e=Math.max(a?.top,e)),a!=null&&a.bottom&&(i=Math.max(a?.bottom,i))}n=o.scrollDOM.clientHeight-e-i}else n=(o.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:e,marginBottom:i,selfScroll:t,height:Math.max(o.defaultLineHeight,n-5)}}function ev(o,t){let e=tv(o),{state:i}=o,n=Ls(i.selection,a=>a.empty?o.moveVertically(a,t,e.height):Vl(a,t));if(n.eq(i.selection))return!1;let s;if(e.selfScroll){let a=o.coordsAtPos(i.selection.main.head),l=o.scrollDOM.getBoundingClientRect(),c=l.top+e.marginTop,u=l.bottom-e.marginBottom;a&&a.top>c&&a.bottom<u&&(s=Wt.scrollIntoView(n.main.head,{y:"start",yMargin:a.top-c}))}return o.dispatch(Rn(i,n),{effects:s}),!0}const Zp=o=>ev(o,!1),zd=o=>ev(o,!0);function Eo(o,t,e){let i=o.lineBlockAt(t.head),n=o.moveToLineBoundary(t,e);if(n.head==t.head&&n.head!=(e?i.to:i.from)&&(n=o.moveToLineBoundary(t,e,!1)),!e&&n.head==i.from&&i.length){let s=/^\s*/.exec(o.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&t.head!=i.from+s&&(n=xt.cursor(i.from+s))}return n}const iv=o=>yn(o,t=>Eo(o,t,!0)),nv=o=>yn(o,t=>Eo(o,t,!1)),jk=o=>yn(o,t=>Eo(o,t,!bi(o))),qk=o=>yn(o,t=>Eo(o,t,bi(o))),Kk=o=>yn(o,t=>xt.cursor(o.lineBlockAt(t.head).from,1)),Zk=o=>yn(o,t=>xt.cursor(o.lineBlockAt(t.head).to,-1));function Gk(o,t,e){let i=!1,n=Ls(o.selection,s=>{let a=Xi(o,s.head,-1)||Xi(o,s.head,1)||s.head>0&&Xi(o,s.head-1,1)||s.head<o.doc.length&&Xi(o,s.head+1,-1);if(!a||!a.end)return s;i=!0;let l=a.start.from==s.head?a.end.to:a.end.from;return xt.cursor(l)});return i?(t(Rn(o,n)),!0):!1}const Yk=({state:o,dispatch:t})=>Gk(o,t);function rn(o,t){let e=Ls(o.state.selection,i=>{let n=t(i);return xt.range(i.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return e.eq(o.state.selection)?!1:(o.dispatch(Rn(o.state,e)),!0)}function ov(o,t){return rn(o,e=>o.moveByChar(e,t))}const sv=o=>ov(o,!bi(o)),rv=o=>ov(o,bi(o));function av(o,t){return rn(o,e=>o.moveByGroup(e,t))}const Jk=o=>av(o,!bi(o)),Qk=o=>av(o,bi(o)),Xk=o=>rn(o,t=>Ul(o.state,t,!bi(o))),tC=o=>rn(o,t=>Ul(o.state,t,bi(o)));function lv(o,t){return rn(o,e=>o.moveVertically(e,t))}const cv=o=>lv(o,!1),dv=o=>lv(o,!0);function hv(o,t){return rn(o,e=>o.moveVertically(e,t,tv(o).height))}const Gp=o=>hv(o,!1),Yp=o=>hv(o,!0),eC=o=>rn(o,t=>Eo(o,t,!0)),iC=o=>rn(o,t=>Eo(o,t,!1)),nC=o=>rn(o,t=>Eo(o,t,!bi(o))),oC=o=>rn(o,t=>Eo(o,t,bi(o))),sC=o=>rn(o,t=>xt.cursor(o.lineBlockAt(t.head).from)),rC=o=>rn(o,t=>xt.cursor(o.lineBlockAt(t.head).to)),Jp=({state:o,dispatch:t})=>(t(Rn(o,{anchor:0})),!0),Qp=({state:o,dispatch:t})=>(t(Rn(o,{anchor:o.doc.length})),!0),Xp=({state:o,dispatch:t})=>(t(Rn(o,{anchor:o.selection.main.anchor,head:0})),!0),tf=({state:o,dispatch:t})=>(t(Rn(o,{anchor:o.selection.main.anchor,head:o.doc.length})),!0),aC=({state:o,dispatch:t})=>(t(o.update({selection:{anchor:0,head:o.doc.length},userEvent:"select"})),!0),lC=({state:o,dispatch:t})=>{let e=jl(o).map(({from:i,to:n})=>xt.range(i,Math.min(n+1,o.doc.length)));return t(o.update({selection:xt.create(e),userEvent:"select"})),!0},cC=({state:o,dispatch:t})=>{let e=Ls(o.selection,i=>{let n=Wi(o),s=n.resolveStack(i.from,1);if(i.empty){let a=n.resolveStack(i.from,-1);a.node.from>=s.node.from&&a.node.to<=s.node.to&&(s=a)}for(let a=s;a;a=a.next){let{node:l}=a;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&a.next)return xt.range(l.to,l.from)}return i});return e.eq(o.selection)?!1:(t(Rn(o,e)),!0)},dC=({state:o,dispatch:t})=>{let e=o.selection,i=null;return e.ranges.length>1?i=xt.create([e.main]):e.main.empty||(i=xt.create([xt.cursor(e.main.head)])),i?(t(Rn(o,i)),!0):!1};function Hr(o,t){if(o.state.readOnly)return!1;let e="delete.selection",{state:i}=o,n=i.changeByRange(s=>{let{from:a,to:l}=s;if(a==l){let c=t(s);c<a?(e="delete.backward",c=Ra(o,c,!1)):c>a&&(e="delete.forward",c=Ra(o,c,!0)),a=Math.min(a,c),l=Math.max(l,c)}else a=Ra(o,a,!1),l=Ra(o,l,!0);return a==l?{range:s}:{changes:{from:a,to:l},range:xt.cursor(a,a<s.head?-1:1)}});return n.changes.empty?!1:(o.dispatch(i.update(n,{scrollIntoView:!0,userEvent:e,effects:e=="delete.selection"?Wt.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Ra(o,t,e){if(o instanceof Wt)for(let i of o.state.facet(Wt.atomicRanges).map(n=>n(o)))i.between(t,t,(n,s)=>{n<t&&s>t&&(t=e?s:n)});return t}const uv=(o,t,e)=>Hr(o,i=>{let n=i.from,{state:s}=o,a=s.doc.lineAt(n),l,c;if(e&&!t&&n>a.from&&n<a.from+200&&!/[^ \t]/.test(l=a.text.slice(0,n-a.from))){if(l[l.length-1]==" ")return n-1;let u=Ol(l,s.tabSize),p=u%so(s)||so(s);for(let v=0;v<p&&l[l.length-1-v]==" ";v++)n--;c=n}else c=di(a.text,n-a.from,t,t)+a.from,c==n&&a.number!=(t?s.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(a.text.slice(c-a.from,n-a.from))&&(c=di(a.text,c-a.from,!1,!1)+a.from);return c}),Fd=o=>uv(o,!1,!0),pv=o=>uv(o,!0,!1),fv=(o,t)=>Hr(o,e=>{let i=e.head,{state:n}=o,s=n.doc.lineAt(i),a=n.charCategorizer(i);for(let l=null;;){if(i==(t?s.to:s.from)){i==e.head&&s.number!=(t?n.doc.lines:1)&&(i+=t?1:-1);break}let c=di(s.text,i-s.from,t)+s.from,u=s.text.slice(Math.min(i,c)-s.from,Math.max(i,c)-s.from),p=a(u);if(l!=null&&p!=l)break;(u!=" "||i!=e.head)&&(l=p),i=c}return i}),mv=o=>fv(o,!1),hC=o=>fv(o,!0),uC=o=>Hr(o,t=>{let e=o.lineBlockAt(t.head).to;return t.head<e?e:Math.min(o.state.doc.length,t.head+1)}),pC=o=>Hr(o,t=>{let e=o.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),fC=o=>Hr(o,t=>{let e=o.moveToLineBoundary(t,!0).head;return t.head<e?e:Math.min(o.state.doc.length,t.head+1)}),mC=({state:o,dispatch:t})=>{if(o.readOnly)return!1;let e=o.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:ye.of(["",""])},range:xt.cursor(i.from)}));return t(o.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},gC=({state:o,dispatch:t})=>{if(o.readOnly)return!1;let e=o.changeByRange(i=>{if(!i.empty||i.from==0||i.from==o.doc.length)return{range:i};let n=i.from,s=o.doc.lineAt(n),a=n==s.from?n-1:di(s.text,n-s.from,!1)+s.from,l=n==s.to?n+1:di(s.text,n-s.from,!0)+s.from;return{changes:{from:a,to:l,insert:o.doc.slice(n,l).append(o.doc.slice(a,n))},range:xt.cursor(l)}});return e.changes.empty?!1:(t(o.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function jl(o){let t=[],e=-1;for(let i of o.selection.ranges){let n=o.doc.lineAt(i.from),s=o.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=o.doc.lineAt(i.to-1)),e>=n.number){let a=t[t.length-1];a.to=s.to,a.ranges.push(i)}else t.push({from:n.from,to:s.to,ranges:[i]});e=s.number+1}return t}function gv(o,t,e){if(o.readOnly)return!1;let i=[],n=[];for(let s of jl(o)){if(e?s.to==o.doc.length:s.from==0)continue;let a=o.doc.lineAt(e?s.to+1:s.from-1),l=a.length+1;if(e){i.push({from:s.to,to:a.to},{from:s.from,insert:a.text+o.lineBreak});for(let c of s.ranges)n.push(xt.range(Math.min(o.doc.length,c.anchor+l),Math.min(o.doc.length,c.head+l)))}else{i.push({from:a.from,to:s.from},{from:s.to,insert:o.lineBreak+a.text});for(let c of s.ranges)n.push(xt.range(c.anchor-l,c.head-l))}}return i.length?(t(o.update({changes:i,scrollIntoView:!0,selection:xt.create(n,o.selection.mainIndex),userEvent:"move.line"})),!0):!1}const vC=({state:o,dispatch:t})=>gv(o,t,!1),yC=({state:o,dispatch:t})=>gv(o,t,!0);function vv(o,t,e){if(o.readOnly)return!1;let i=[];for(let n of jl(o))e?i.push({from:n.from,insert:o.doc.slice(n.from,n.to)+o.lineBreak}):i.push({from:n.to,insert:o.lineBreak+o.doc.slice(n.from,n.to)});return t(o.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const bC=({state:o,dispatch:t})=>vv(o,t,!1),wC=({state:o,dispatch:t})=>vv(o,t,!0),_C=o=>{if(o.state.readOnly)return!1;let{state:t}=o,e=t.changes(jl(t).map(({from:n,to:s})=>(n>0?n--:s<t.doc.length&&s++,{from:n,to:s}))),i=Ls(t.selection,n=>{let s;if(o.lineWrapping){let a=o.lineBlockAt(n.head),l=o.coordsAtPos(n.head,n.assoc||1);l&&(s=a.bottom+o.documentTop-l.bottom+o.defaultLineHeight/2)}return o.moveVertically(n,!0,s)}).map(e);return o.dispatch({changes:e,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function xC(o,t){if(/\(\)|\[\]|\{\}/.test(o.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=Wi(o).resolveInner(t),i=e.childBefore(t),n=e.childAfter(t),s;return i&&n&&i.to<=t&&n.from>=t&&(s=i.type.prop(de.closedBy))&&s.indexOf(n.name)>-1&&o.doc.lineAt(i.to).from==o.doc.lineAt(n.from).from&&!/\S/.test(o.sliceDoc(i.to,n.from))?{from:i.to,to:n.from}:null}const Wd=yv(!1),kC=yv(!0);function yv(o){return({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(n=>{let{from:s,to:a}=n,l=t.doc.lineAt(s),c=!o&&s==a&&xC(t,s);o&&(s=a=(a<=l.to?l:t.doc.lineAt(a)).to);let u=new zl(t,{simulateBreak:s,simulateDoubleBreak:!!c}),p=Eg(u,s);for(p==null&&(p=Ol(/^\s*/.exec(t.doc.lineAt(s).text)[0],t.tabSize));a<l.to&&/\s/.test(l.text[a-l.from]);)a++;c?{from:s,to:a}=c:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let v=["",xl(t,p)];return c&&v.push(xl(t,u.lineIndent(l.from,-1))),{changes:{from:s,to:a,insert:ye.of(v)},range:xt.cursor(s+1+v[1].length)}});return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Lh(o,t){let e=-1;return o.changeByRange(i=>{let n=[];for(let a=i.from;a<=i.to;){let l=o.doc.lineAt(a);l.number>e&&(i.empty||i.to>l.from)&&(t(l,n,i),e=l.number),a=l.to+1}let s=o.changes(n);return{changes:n,range:xt.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const bv=({state:o,dispatch:t})=>{if(o.readOnly)return!1;let e=Object.create(null),i=new zl(o,{overrideIndentation:s=>e[s]??-1}),n=Lh(o,(s,a,l)=>{let c=Eg(i,s.from);if(c==null)return;/\S/.test(s.text)||(c=0);let u=/^\s*/.exec(s.text)[0],p=xl(o,c);(u!=p||l.from<s.from+u.length)&&(e[s.from]=c,a.push({from:s.from,to:s.from+u.length,insert:p}))});return n.changes.empty||t(o.update(n,{userEvent:"indent"})),!0},ql=({state:o,dispatch:t})=>o.readOnly?!1:(t(o.update(Lh(o,(e,i)=>{i.push({from:e.from,insert:o.facet(Ts)})}),{userEvent:"input.indent"})),!0),Nh=({state:o,dispatch:t})=>o.readOnly?!1:(t(o.update(Lh(o,(e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let s=Ol(n,o.tabSize),a=0,l=xl(o,Math.max(0,s-so(o)));for(;a<n.length&&a<l.length&&n.charCodeAt(a)==l.charCodeAt(a);)a++;i.push({from:e.from+a,to:e.from+n.length,insert:l.slice(a)})}),{userEvent:"delete.dedent"})),!0),CC=o=>(o.setTabFocusMode(),!0),$C=[{key:"Ctrl-b",run:Ah,shift:sv,preventDefault:!0},{key:"Ctrl-f",run:Gg,shift:rv},{key:"Ctrl-p",run:Qg,shift:cv},{key:"Ctrl-n",run:Xg,shift:dv},{key:"Ctrl-a",run:Kk,shift:sC},{key:"Ctrl-e",run:Zk,shift:rC},{key:"Ctrl-d",run:pv},{key:"Ctrl-h",run:Fd},{key:"Ctrl-k",run:uC},{key:"Ctrl-Alt-h",run:mv},{key:"Ctrl-o",run:mC},{key:"Ctrl-t",run:gC},{key:"Ctrl-v",run:zd}],SC=[{key:"ArrowLeft",run:Ah,shift:sv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Fk,shift:Jk,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:jk,shift:nC,preventDefault:!0},{key:"ArrowRight",run:Gg,shift:rv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Wk,shift:Qk,preventDefault:!0},{mac:"Cmd-ArrowRight",run:qk,shift:oC,preventDefault:!0},{key:"ArrowUp",run:Qg,shift:cv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Jp,shift:Xp},{mac:"Ctrl-ArrowUp",run:Zp,shift:Gp},{key:"ArrowDown",run:Xg,shift:dv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Qp,shift:tf},{mac:"Ctrl-ArrowDown",run:zd,shift:Yp},{key:"PageUp",run:Zp,shift:Gp},{key:"PageDown",run:zd,shift:Yp},{key:"Home",run:nv,shift:iC,preventDefault:!0},{key:"Mod-Home",run:Jp,shift:Xp},{key:"End",run:iv,shift:eC,preventDefault:!0},{key:"Mod-End",run:Qp,shift:tf},{key:"Enter",run:Wd,shift:Wd},{key:"Mod-a",run:aC},{key:"Backspace",run:Fd,shift:Fd},{key:"Delete",run:pv},{key:"Mod-Backspace",mac:"Alt-Backspace",run:mv},{key:"Mod-Delete",mac:"Alt-Delete",run:hC},{mac:"Mod-Backspace",run:pC},{mac:"Mod-Delete",run:fC}].concat($C.map(o=>({mac:o.key,run:o.run,shift:o.shift}))),TC=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Vk,shift:Xk},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Uk,shift:tC},{key:"Alt-ArrowUp",run:vC},{key:"Shift-Alt-ArrowUp",run:bC},{key:"Alt-ArrowDown",run:yC},{key:"Shift-Alt-ArrowDown",run:wC},{key:"Escape",run:dC},{key:"Mod-Enter",run:kC},{key:"Alt-l",mac:"Ctrl-l",run:lC},{key:"Mod-i",run:cC,preventDefault:!0},{key:"Mod-[",run:Nh},{key:"Mod-]",run:ql},{key:"Mod-Alt-\\",run:bv},{key:"Shift-Mod-k",run:_C},{key:"Shift-Mod-\\",run:Yk},{key:"Mod-/",run:_k},{key:"Alt-A",run:kk},{key:"Ctrl-m",mac:"Shift-Alt-m",run:CC}].concat(SC),ef=typeof String.prototype.normalize=="function"?o=>o.normalize("NFKD"):o=>o;class Mh{constructor(t,e,i=0,n=t.length,s,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,n),this.bufferStart=i,this.normalize=s?l=>s(ef(l)):ef,this.query=this.normalize(e)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return tm(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=Dw(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=em(t);let n=this.normalize(e);if(n.length)for(let s=0,a=i;;s++){let l=n.charCodeAt(s),c=this.match(l,a,this.bufferPos+this.bufferStart);if(s==n.length-1){if(c)return this.value=c,this;break}a==i&&s<e.length&&e.charCodeAt(s)==l&&a++}}}match(t,e,i){let n=null;for(let s=0;s<this.matches.length;s+=2){let a=this.matches[s],l=!1;this.query.charCodeAt(a)==t&&(a==this.query.length-1?n={from:this.matches[s+1],to:i}:(this.matches[s]++,l=!0)),l||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==t&&(this.query.length==1?n={from:e,to:i}:this.matches.push(1,e)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferStart)&&(n=null),n}}typeof Symbol<"u"&&(Mh.prototype[Symbol.iterator]=function(){return this});const wv={from:-1,to:-1,match:/.*/.exec("")},Ph="gm"+(/x/.unicode==null?"":"u");class Oh{constructor(t,e,i,n=0,s=t.length){if(this.text=t,this.to=s,this.curLine="",this.done=!1,this.value=wv,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new _v(t,e,i,n,s);this.re=new RegExp(e,Ph+(i!=null&&i.ignoreCase?"i":"")),this.test=i?.test,this.iter=t.iter();let a=t.lineAt(n);this.curLineStart=a.from,this.matchPos=$l(t,n),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let i=this.curLineStart+e.index,n=i+e[0].length;if(this.matchPos=$l(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,e)))return this.value={from:i,to:n,match:e},this;t=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),t=0;else return this.done=!0,this}}}const Wc=new WeakMap;class ys{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,i){let n=Wc.get(t);if(!n||n.from>=i||n.to<=e){let l=new ys(e,t.sliceString(e,i));return Wc.set(t,l),l}if(n.from==e&&n.to==i)return n;let{text:s,from:a}=n;return a>e&&(s=t.sliceString(e,a)+s,a=e),n.to<i&&(s+=t.sliceString(n.to,i)),Wc.set(t,new ys(a,s)),new ys(e,s.slice(e-a,i-a))}}class _v{constructor(t,e,i,n,s){this.text=t,this.to=s,this.done=!1,this.value=wv,this.matchPos=$l(t,n),this.re=new RegExp(e,Ph+(i!=null&&i.ignoreCase?"i":"")),this.test=i?.test,this.flat=ys.get(t,n,this.chunkEnd(n+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let i=this.flat.from+e.index,n=i+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,n,e)))return this.value={from:i,to:n,match:e},this.matchPos=$l(this.text,n+(i==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ys.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Oh.prototype[Symbol.iterator]=_v.prototype[Symbol.iterator]=function(){return this});function EC(o){try{return new RegExp(o,Ph),!0}catch{return!1}}function $l(o,t){if(t>=o.length)return t;let e=o.lineAt(t),i;for(;t<e.to&&(i=e.text.charCodeAt(t-e.from))>=56320&&i<57344;)t++;return t}const IC={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},AC=Ft.define({combine(o){return ro(o,IC,{highlightWordAroundCursor:(t,e)=>t||e,minSelectionLength:Math.min,maxMatches:Math.min})}});function LC(o){return[DC,OC]}const NC=Yt.mark({class:"cm-selectionMatch"}),MC=Yt.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function nf(o,t,e,i){return(e==0||o(t.sliceDoc(e-1,e))!=Ve.Word)&&(i==t.doc.length||o(t.sliceDoc(i,i+1))!=Ve.Word)}function PC(o,t,e,i){return o(t.sliceDoc(e,e+1))==Ve.Word&&o(t.sliceDoc(i-1,i))==Ve.Word}const OC=ti.fromClass(class{constructor(o){this.decorations=this.getDeco(o)}update(o){(o.selectionSet||o.docChanged||o.viewportChanged)&&(this.decorations=this.getDeco(o.view))}getDeco(o){let t=o.state.facet(AC),{state:e}=o,i=e.selection;if(i.ranges.length>1)return Yt.none;let n=i.main,s,a=null;if(n.empty){if(!t.highlightWordAroundCursor)return Yt.none;let c=e.wordAt(n.head);if(!c)return Yt.none;a=e.charCategorizer(n.head),s=e.sliceDoc(c.from,c.to)}else{let c=n.to-n.from;if(c<t.minSelectionLength||c>200)return Yt.none;if(t.wholeWords){if(s=e.sliceDoc(n.from,n.to),a=e.charCategorizer(n.head),!(nf(a,e,n.from,n.to)&&PC(a,e,n.from,n.to)))return Yt.none}else if(s=e.sliceDoc(n.from,n.to),!s)return Yt.none}let l=[];for(let c of o.visibleRanges){let u=new Mh(e.doc,s,c.from,c.to);for(;!u.next().done;){let{from:p,to:v}=u.value;if((!a||nf(a,e,p,v))&&(n.empty&&p<=n.from&&v>=n.to?l.push(MC.range(p,v)):(p>=n.to||v<=n.from)&&l.push(NC.range(p,v)),l.length>t.maxMatches))return Yt.none}}return Yt.set(l)}},{decorations:o=>o.decorations}),DC=Wt.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});class RC{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||EC(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(e,i)=>i=="n"?`
|
||
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new WC(this):new zC(this)}getCursor(t,e=0,i){let n=t.doc?t:ve.create({doc:t});return i==null&&(i=n.doc.length),this.regexp?hs(this,n,e,i):ds(this,n,e,i)}}class xv{constructor(t){this.spec=t}}function ds(o,t,e,i){return new Mh(t.doc,o.unquoted,e,i,o.caseSensitive?void 0:n=>n.toLowerCase(),o.wholeWord?BC(t.doc,t.charCategorizer(t.selection.main.head)):void 0)}function BC(o,t){return(e,i,n,s)=>((s>e||s+n.length<i)&&(s=Math.max(0,e-2),n=o.sliceString(s,Math.min(o.length,i+2))),(t(Sl(n,e-s))!=Ve.Word||t(Tl(n,e-s))!=Ve.Word)&&(t(Tl(n,i-s))!=Ve.Word||t(Sl(n,i-s))!=Ve.Word))}class zC extends xv{constructor(t){super(t)}nextMatch(t,e,i){let n=ds(this.spec,t,i,t.doc.length).nextOverlapping();if(n.done){let s=Math.min(t.doc.length,e+this.spec.unquoted.length);n=ds(this.spec,t,0,s).nextOverlapping()}return n.done||n.value.from==e&&n.value.to==i?null:n.value}prevMatchInRange(t,e,i){for(let n=i;;){let s=Math.max(e,n-1e4-this.spec.unquoted.length),a=ds(this.spec,t,s,n),l=null;for(;!a.nextOverlapping().done;)l=a.value;if(l)return l;if(s==e)return null;n-=1e4}}prevMatch(t,e,i){let n=this.prevMatchInRange(t,0,e);return n||(n=this.prevMatchInRange(t,Math.max(0,i-this.spec.unquoted.length),t.doc.length)),n&&(n.from!=e||n.to!=i)?n:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let i=ds(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=ds(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}function hs(o,t,e,i){return new Oh(t.doc,o.search,{ignoreCase:!o.caseSensitive,test:o.wholeWord?FC(t.charCategorizer(t.selection.main.head)):void 0},e,i)}function Sl(o,t){return o.slice(di(o,t,!1),t)}function Tl(o,t){return o.slice(t,di(o,t))}function FC(o){return(t,e,i)=>!i[0].length||(o(Sl(i.input,i.index))!=Ve.Word||o(Tl(i.input,i.index))!=Ve.Word)&&(o(Tl(i.input,i.index+i[0].length))!=Ve.Word||o(Sl(i.input,i.index+i[0].length))!=Ve.Word)}class WC extends xv{nextMatch(t,e,i){let n=hs(this.spec,t,i,t.doc.length).next();return n.done&&(n=hs(this.spec,t,0,e).next()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=1;;n++){let s=Math.max(e,i-n*1e4),a=hs(this.spec,t,s,i),l=null;for(;!a.next().done;)l=a.value;if(l&&(s==e||l.from>s+10))return l;if(s==e)return null}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(e,i)=>{if(i=="&")return t.match[0];if(i=="$")return"$";for(let n=i.length;n>0;n--){let s=+i.slice(0,n);if(s>0&&s<t.match.length)return t.match[s]+i.slice(n)}return e})}matchAll(t,e){let i=hs(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=hs(this.spec,t,Math.max(0,e-250),Math.min(i+250,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}const Hd=me.define();function HC(o){var t=o.Pos;function e(h,g,y){if(g.line===y.line&&g.ch>=y.ch-1){var w=h.getLine(g.line),C=w.charCodeAt(g.ch);55296<=C&&C<=55551&&(y.ch+=1)}return{start:g,end:y}}var i=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"g<Up>",type:"keyToKey",toKeys:"gk"},{keys:"g<Down>",type:"keyToKey",toKeys:"gj"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h"},{keys:"<Del>",type:"keyToKey",toKeys:"x"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:"=",type:"operator",operator:"indentAuto"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"gn",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!0}},{keys:"gN",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!1}},{keys:"gq",type:"operator",operator:"hardWrap"},{keys:"gw",type:"operator",operator:"hardWrap",operatorArgs:{keepCursor:!0}},{keys:"g?",type:"operator",operator:"rot13"},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-u>",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-w>",type:"idle",context:"normal"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"gi",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"lastEdit"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"gI",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"bol"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"gJ",type:"action",action:"joinLines",actionArgs:{keepSpaces:!0},isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<register>",type:"action",action:"replayMacro"},{keys:"q<register>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0},context:"normal"},{keys:"R",type:"operator",operator:"change",operatorArgs:{linewise:!0,fullLine:!0},context:"visual",exitVisualBlock:!0},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<register>",type:"action",action:"setMark"},{keys:'"<register>',type:"action",action:"setRegister"},{keys:"<C-r><register>",type:"action",action:"insertRegister",context:"insert",isEdit:!0},{keys:"<C-o>",type:"action",action:"oneNormalCommand",context:"insert"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<register>",type:"motion",motion:"textObjectManipulation"},{keys:"i<register>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],n=Object.create(null),s=i.length,a=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"omap",shortName:"om"},{name:"noremap",shortName:"no"},{name:"nnoremap",shortName:"nn"},{name:"vnoremap",shortName:"vn"},{name:"inoremap",shortName:"ino"},{name:"onoremap",shortName:"ono"},{name:"unmap"},{name:"mapclear",shortName:"mapc"},{name:"nmapclear",shortName:"nmapc"},{name:"vmapclear",shortName:"vmapc"},{name:"imapclear",shortName:"imapc"},{name:"omapclear",shortName:"omapc"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"startinsert",shortName:"start"},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"delmarks",shortName:"delm"},{name:"marks",excludeFromCommandHistory:!0},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"vglobal",shortName:"v"},{name:"delete",shortName:"d"},{name:"join",shortName:"j"},{name:"normal",shortName:"norm"},{name:"global",shortName:"g"}],l=G("");function c(h){h.setOption("disableInput",!0),h.setOption("showCursorWhenSelecting",!1),o.signal(h,"vim-mode-change",{mode:"normal"}),h.on("cursorActivity",qe),te(h),o.on(h.getInputField(),"paste",p(h))}function u(h){h.setOption("disableInput",!1),h.off("cursorActivity",qe),o.off(h.getInputField(),"paste",p(h)),h.state.vim=null,cn&&clearTimeout(cn)}function p(h){var g=h.state.vim;return g.onPasteFn||(g.onPasteFn=function(){g.insertMode||(h.setCursor(De(h.getCursor(),0,1)),Si.enterInsertMode(h,{},g))}),g.onPasteFn}var v=/[\d]/,x=[o.isWordChar,function(h){return h&&!o.isWordChar(h)&&!/\s/.test(h)}],T=[function(h){return/\S/.test(h)}],M=["<",">"],P=["-",'"',".",":","_","/","+"],F=/^\w$/,R=/^[A-Z]$/;try{R=new RegExp("^[\\p{Lu}]$","u")}catch{}function q(h,g){return g>=h.firstLine()&&g<=h.lastLine()}function H(h){return/^[a-z]$/.test(h)}function Q(h){return"()[]{}".indexOf(h)!=-1}function tt(h){return v.test(h)}function it(h){return R.test(h)}function rt(h){return/^\s*$/.test(h)}function vt(h){return".?!".indexOf(h)!=-1}function Dt(h,g){for(var y=0;y<g.length;y++)if(g[y]==h)return!0;return!1}var jt={};function gt(h,g,y,w,C){if(g===void 0&&!C)throw Error("defaultValue is required unless callback is provided");if(y||(y="string"),jt[h]={type:y,defaultValue:g,callback:C},w)for(var A=0;A<w.length;A++)jt[w[A]]=jt[h];g&&Ct(h,g)}function Ct(h,g,y,w){var C=jt[h];w=w||{};var A=w.scope;if(!C)return new Error("Unknown option: "+h);if(C.type=="boolean"){if(g&&g!==!0)return new Error("Invalid argument: "+h+"="+g);g!==!1&&(g=!0)}C.callback?(A!=="local"&&C.callback(g,void 0),A!=="global"&&y&&C.callback(g,y)):(A!=="local"&&(C.value=C.type=="boolean"?!!g:g),A!=="global"&&y&&(y.state.vim.options[h]={value:g}))}function St(h,g,y){var w=jt[h];y=y||{};var C=y.scope;if(!w)return new Error("Unknown option: "+h);if(w.callback){let A=g&&w.callback(void 0,g);return C!=="global"&&A!==void 0?A:C!=="local"?w.callback():void 0}else return(C!=="global"&&g&&g.state.vim.options[h]||C!=="local"&&w||{}).value}gt("filetype",void 0,"string",["ft"],function(h,g){if(g!==void 0)if(h===void 0){let y=g.getOption("mode");return y=="null"?"":y}else{let y=h==""?"null":h;g.setOption("mode",y)}}),gt("textwidth",80,"number",["tw"],function(h,g){if(g!==void 0)if(h===void 0){var y=g.getOption("textwidth");return y}else{var w=Math.round(h);w>1&&g.setOption("textwidth",w)}});var Nt=function(){var h=100,g=-1,y=0,w=0,C=new Array(h);function A(W,j,U){var nt=g%h,ot=C[nt];function st(yt){var kt=++g%h,Ut=C[kt];Ut&&Ut.clear(),C[kt]=W.setBookmark(yt)}if(ot){var Y=ot.find();Y&&!ei(Y,j)&&st(j)}else st(j);st(U),y=g,w=g-h+1,w<0&&(w=0)}function D(W,j){g+=j,g>y?g=y:g<w&&(g=w);var U=C[(h+g)%h];if(U&&!U.find()){var nt=j>0?1:-1,ot,st=W.getCursor();do if(g+=nt,U=C[(h+g)%h],U&&(ot=U.find())&&!ei(st,ot))break;while(g<y&&g>w)}return U}function z(W,j){var U=g,nt=D(W,j);return g=U,nt&&nt.find()}return{cachedCursor:void 0,add:A,find:z,move:D}},Zt=function(h){return h?{changes:h.changes,expectCursorActivityForChange:h.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class re{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=Zt()}exitMacroRecordMode(){var g=ut.macroModeState;g.onRecordingDone&&g.onRecordingDone(),g.onRecordingDone=void 0,g.isRecording=!1}enterMacroRecordMode(g,y){var w=ut.registerController.getRegister(y);if(w){if(w.clear(),this.latestRegister=y,g.openDialog){var C=ui("span",{class:"cm-vim-message"},"recording @"+y);this.onRecordingDone=g.openDialog(C,function(){},{bottom:!0})}this.isRecording=!0}}}function te(h){return h.state.vim||(h.state.vim={inputState:new J,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:void 0,sel:{anchor:new t(0,0),head:new t(0,0)},options:{},expectLiteralNext:!1,status:""}),h.state.vim}var ut;function bt(){ut={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:Nt(),macroModeState:new re,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new Ht({}),searchHistoryController:new Kt,exCommandHistoryController:new Kt};for(var h in jt){var g=jt[h];g.value=g.defaultValue}}class ht{constructor(g,y){this.keyName=g,this.key=y.key,this.ctrlKey=y.ctrlKey,this.altKey=y.altKey,this.metaKey=y.metaKey,this.shiftKey=y.shiftKey}}var Tt,mt={enterVimMode:c,leaveVimMode:u,buildKeyMap:function(){},getRegisterController:function(){return ut.registerController},resetVimGlobalState_:bt,getVimGlobalState_:function(){return ut},maybeInitVimState_:te,suppressErrorLogging:!1,InsertModeKey:ht,map:function(h,g,y){ii.map(h,g,y)},unmap:function(h,g){return ii.unmap(h,g)},noremap:function(h,g,y){ii.map(h,g,y,!0)},mapclear:function(h){var g=i.length,y=s,w=i.slice(0,g-y);if(i=i.slice(g-y),h)for(var C=w.length-1;C>=0;C--){var A=w[C];if(h!==A.context)if(A.context)this._mapCommand(A);else{var D=["normal","insert","visual"];for(var z in D)if(D[z]!==h){var W=Object.assign({},A);W.context=D[z],this._mapCommand(W)}}}},langmap:V,vimKeyFromEvent:B,setOption:Ct,getOption:St,defineOption:gt,defineEx:function(h,g,y){if(!g)g=h;else if(h.indexOf(g)!==0)throw new Error('(Vim.defineEx) "'+g+'" is not a prefix of "'+h+'", command not registered');Us[h]=y,ii.commandMap_[g]={name:h,shortName:g,type:"api"}},handleKey:function(h,g,y){var w=this.findKey(h,g,y);if(typeof w=="function")return w()},multiSelectHandleKey:lc,findKey:function(h,g,y){var w=te(h),C=h;function A(){var U=ut.macroModeState;if(U.isRecording){if(g=="q")return U.exitMacroRecordMode(),X(C),!0;y!="mapping"&&Ks(U,g)}}function D(){if(g=="<Esc>"){if(w.visualMode)zt(C);else if(w.insertMode)Gt(C);else return;return X(C),!0}}function z(){if(D())return!0;w.inputState.keyBuffer.push(g);var U=w.inputState.keyBuffer.join(""),nt=g.length==1,ot=qt.matchCommand(U,i,w.inputState,"insert"),st=w.inputState.changeQueue;if(ot.type=="none")return X(C),!1;if(ot.type=="partial"){if(ot.expectLiteralNext&&(w.expectLiteralNext=!0),Tt&&window.clearTimeout(Tt),Tt=nt&&window.setTimeout(function(){w.insertMode&&w.inputState.keyBuffer.length&&X(C)},St("insertModeEscKeysTimeout")),nt){var Y=C.listSelections();(!st||st.removed.length!=Y.length)&&(st=w.inputState.changeQueue=new wt),st.inserted+=g;for(var yt=0;yt<Y.length;yt++){var kt=si(Y[yt].anchor,Y[yt].head),Ut=an(Y[yt].anchor,Y[yt].head),Lt=C.getRange(kt,C.state.overwrite?De(Ut,0,1):Ut);st.removed[yt]=(st.removed[yt]||"")+Lt}}return!nt}else ot.type=="full"&&(w.inputState.keyBuffer.length=0);if(w.expectLiteralNext=!1,Tt&&window.clearTimeout(Tt),ot.command&&st){for(var Y=C.listSelections(),yt=0;yt<Y.length;yt++){var ee=Y[yt].head;C.replaceRange(st.removed[yt]||"",De(ee,0,-st.inserted.length),ee,"+input")}ut.macroModeState.lastInsertModeChanges.changes.pop()}return ot.command||X(C),ot.command}function W(){if(A()||D())return!0;w.inputState.keyBuffer.push(g);var U=w.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(U))return!0;var nt=/^(\d*)(.*)$/.exec(U);if(!nt)return X(C),!1;var ot=w.visualMode?"visual":"normal",st=nt[2]||nt[1];w.inputState.operatorShortcut&&w.inputState.operatorShortcut.slice(-1)==st&&(st=w.inputState.operatorShortcut);var Y=qt.matchCommand(st,i,w.inputState,ot);return Y.type=="none"?(X(C),!1):Y.type=="partial"?(Y.expectLiteralNext&&(w.expectLiteralNext=!0),!0):Y.type=="clear"?(X(C),!0):(w.expectLiteralNext=!1,w.inputState.keyBuffer.length=0,nt=/^(\d*)(.*)$/.exec(U),nt&&nt[1]&&nt[1]!="0"&&w.inputState.pushRepeatDigit(nt[1]),Y.command)}var j=w.insertMode?z():W();if(j===!1)return!w.insertMode&&(g.length===1||o.isMac&&/<A-.>/.test(g))?function(){return!0}:void 0;if(j===!0)return function(){return!0};if(j)return function(){return C.operation(function(){C.curOp.isVimOp=!0;try{if(typeof j!="object")return;j.type=="keyToKey"?k(C,j.toKeys,j):qt.processCommand(C,w,j)}catch(U){throw C.state.vim=void 0,te(C),mt.suppressErrorLogging||console.log(U),U}return!0})}},handleEx:function(h,g){ii.processCommand(h,g)},defineMotion:be,defineAction:Vr,defineOperator:je,mapCommand:js,_mapCommand:Ei,defineRegister:lt,exitVisualMode:zt,exitInsertMode:Gt},At=[],Et=!1,dt;function b(h){if(!dt)throw new Error("No prompt to send key to");if(h[0]=="<"){var g=h.toLowerCase().slice(1,-1),y=g.split("-");if(g=y.pop()||"",g=="lt")h="<";else if(g=="space")h=" ";else if(g=="cr")h=`
|
||
`;else if(N[g]){var w=dt.value||"",C={key:N[g],target:{value:w,selectionEnd:w.length,selectionStart:w.length}};dt.onKeyDown&&dt.onKeyDown(C,dt.value,D),dt&&dt.onKeyUp&&dt.onKeyUp(C,dt.value,D);return}}if(h==`
|
||
`){var A=dt;dt=null,A.onClose&&A.onClose(A.value)}else dt.value=(dt.value||"")+h;function D(z){dt&&(typeof z=="string"?dt.value=z:dt=null)}}function k(h,g,y){var w=Et;if(y){if(At.indexOf(y)!=-1)return;At.push(y),Et=y.noremap!=!1}try{for(var C=te(h),A=/<(?:[CSMA]-)*\w+>|./gi,D;D=A.exec(g);){var z=D[0],W=C.insertMode;if(dt){b(z);continue}var j=mt.handleKey(h,z,"mapping");if(!j&&W&&C.insertMode){if(z[0]=="<"){var U=z.toLowerCase().slice(1,-1),nt=U.split("-");if(U=nt.pop()||"",U=="lt")z="<";else if(U=="space")z=" ";else if(U=="cr")z=`
|
||
`;else if(N.hasOwnProperty(U)){z=N[U],na(h,z);continue}else z=z[0],A.lastIndex=D.index+1}h.replaceSelection(z)}}}finally{if(At.pop(),Et=At.length?w:!1,!At.length&&dt){var ot=dt;dt=null,Fn(h,ot)}}}var S={Return:"CR",Backspace:"BS",Delete:"Del",Escape:"Esc",Insert:"Ins",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down",Enter:"CR"," ":"Space"},I={Shift:1,Alt:1,Command:1,Control:1,CapsLock:1,AltGraph:1,Dead:1,Unidentified:1},N={};"Left|Right|Up|Down|End|Home".split("|").concat(Object.keys(S)).forEach(function(h){N[(S[h]||"").toLowerCase()]=N[h.toLowerCase()]=h});function B(h,g){var y,w=h.key;if(!I[w]){w.length>1&&w[0]=="n"&&(w=w.replace("Numpad","")),w=S[w]||w;var C="";if(h.ctrlKey&&(C+="C-"),h.altKey&&(C+="A-"),h.metaKey&&(C+="M-"),o.isMac&&C=="A-"&&w.length==1&&(C=C.slice(2)),(C||w.length>1)&&h.shiftKey&&(C+="S-"),g&&!g.expectLiteralNext&&w.length==1){if(l.keymap&&w in l.keymap)(l.remapCtrl!=!1||!C)&&(w=l.keymap[w]);else if(w.charCodeAt(0)>128&&!n[w]){var A=((y=h.code)==null?void 0:y.slice(-1))||"";h.shiftKey||(A=A.toLowerCase()),A&&(w=A,!C&&h.altKey&&(C="A-"))}}return C+=w,C.length>1&&(C="<"+C+">"),C}}function V(h,g){l.string!==h&&(l=G(h)),l.remapCtrl=g}function G(h){let g={};if(!h)return{keymap:g,string:""};function y(w){return w.split(/\\?(.)/).filter(Boolean)}return h.split(/((?:[^\\,]|\\.)+),/).map(w=>{if(!w)return;const C=w.split(/((?:[^\\;]|\\.)+);/);if(C.length==3){const A=y(C[1]),D=y(C[2]);if(A.length!==D.length)return;for(let z=0;z<A.length;++z)g[A[z]]=D[z]}else if(C.length==1){const A=y(w);if(A.length%2!==0)return;for(let D=0;D<A.length;D+=2)g[A[D]]=A[D+1]}}),{keymap:g,string:h}}gt("langmap",void 0,"string",["lmap"],function(h,g){if(h===void 0)return l.string;V(h)});class J{constructor(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=void 0,this.changeQueue=null}pushRepeatDigit(g){this.operator?this.motionRepeat=this.motionRepeat.concat(g):this.prefixRepeat=this.prefixRepeat.concat(g)}getRepeat(){var g=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(g=1,this.prefixRepeat.length>0&&(g*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(g*=parseInt(this.motionRepeat.join(""),10))),g}}function X(h,g){h.state.vim.inputState=new J,h.state.vim.expectLiteralNext=!1,o.signal(h,"vim-command-done",g)}function wt(){this.removed=[],this.inserted=""}class $t{constructor(g,y,w){this.clear(),this.keyBuffer=[g||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!y,this.blockwise=!!w}setText(g,y,w){this.keyBuffer=[g||""],this.linewise=!!y,this.blockwise=!!w}pushText(g,y){y&&(this.linewise||this.keyBuffer.push(`
|
||
`),this.linewise=!0),this.keyBuffer.push(g)}pushInsertModeChanges(g){this.insertModeChanges.push(Zt(g))}pushSearchQuery(g){this.searchQueries.push(g)}clear(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1}toString(){return this.keyBuffer.join("")}}function lt(h,g){var y=ut.registerController.registers;if(!h||h.length!=1)throw Error("Register name must be 1 character");if(y[h])throw Error("Register already defined "+h);y[h]=g,P.push(h)}class Ht{constructor(g){this.registers=g,this.unnamedRegister=g['"']=new $t,g["."]=new $t,g[":"]=new $t,g["/"]=new $t,g["+"]=new $t}pushText(g,y,w,C,A){if(g!=="_"){C&&w.charAt(w.length-1)!==`
|
||
`&&(w+=`
|
||
`);var D=this.isValidRegister(g)?this.getRegister(g):null;if(!D||!g){switch(y){case"yank":this.registers[0]=new $t(w,C,A);break;case"delete":case"change":w.indexOf(`
|
||
`)==-1?this.registers["-"]=new $t(w,C):(this.shiftNumericRegisters_(),this.registers[1]=new $t(w,C));break}this.unnamedRegister.setText(w,C,A);return}var z=it(g);z?D.pushText(w,C):D.setText(w,C,A),g==="+"&&navigator.clipboard.writeText(w),this.unnamedRegister.setText(D.toString(),C)}}getRegister(g){return this.isValidRegister(g)?(g=g.toLowerCase(),this.registers[g]||(this.registers[g]=new $t),this.registers[g]):this.unnamedRegister}isValidRegister(g){return g&&(Dt(g,P)||F.test(g))}shiftNumericRegisters_(){for(var g=9;g>=2;g--)this.registers[g]=this.getRegister(""+(g-1))}}class Kt{constructor(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}nextMatch(g,y){var w=this.historyBuffer,C=y?-1:1;this.initialPrefix===null&&(this.initialPrefix=g);for(var A=this.iterator+C;y?A>=0:A<w.length;A+=C)for(var D=w[A],z=0;z<=D.length;z++)if(this.initialPrefix==D.substring(0,z))return this.iterator=A,D;if(A>=w.length)return this.iterator=w.length,this.initialPrefix;if(A<0)return g}pushInput(g){var y=this.historyBuffer.indexOf(g);y>-1&&this.historyBuffer.splice(y,1),g.length&&this.historyBuffer.push(g)}reset(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}}var qt={matchCommand:function(h,g,y,w){var C=Jl(h,g,w,y),A=C.full[0];if(!A)return C.partial.length?{type:"partial",expectLiteralNext:C.partial.length==1&&C.partial[0].keys.slice(-11)=="<character>"}:{type:"none"};if(A.keys.slice(-11)=="<character>"||A.keys.slice(-10)=="<register>"){var D=Ns(h);if(!D||D.length>1)return{type:"clear"};y.selectedCharacter=D}return{type:"full",command:A}},processCommand:function(h,g,y){switch(g.inputState.repeatOverride=y.repeatOverride,y.type){case"motion":this.processMotion(h,g,y);break;case"operator":this.processOperator(h,g,y);break;case"operatorMotion":this.processOperatorMotion(h,g,y);break;case"action":this.processAction(h,g,y);break;case"search":this.processSearch(h,g,y);break;case"ex":case"keyToEx":this.processEx(h,g,y);break}},processMotion:function(h,g,y){g.inputState.motion=y.motion,g.inputState.motionArgs=Io(y.motionArgs),this.evalInput(h,g)},processOperator:function(h,g,y){var w=g.inputState;if(w.operator)if(w.operator==y.operator){w.motion="expandToLine",w.motionArgs={linewise:!0,repeat:1},this.evalInput(h,g);return}else X(h);w.operator=y.operator,w.operatorArgs=Io(y.operatorArgs),y.keys.length>1&&(w.operatorShortcut=y.keys),y.exitVisualBlock&&(g.visualBlock=!1,ao(h)),g.visualMode&&this.evalInput(h,g)},processOperatorMotion:function(h,g,y){var w=g.visualMode,C=Io(y.operatorMotionArgs);C&&w&&C.visualLine&&(g.visualLine=!0),this.processOperator(h,g,y),w||this.processMotion(h,g,y)},processAction:function(h,g,y){var w=g.inputState,C=w.getRepeat(),A=!!C,D=Io(y.actionArgs)||{repeat:1};w.selectedCharacter&&(D.selectedCharacter=w.selectedCharacter),y.operator&&this.processOperator(h,g,y),y.motion&&this.processMotion(h,g,y),(y.motion||y.operator)&&this.evalInput(h,g),D.repeat=C||1,D.repeatIsExplicit=A,D.registerName=w.registerName,X(h),g.lastMotion=null,y.isEdit&&this.recordLastEdit(g,w,y),Si[y.action](h,D,g)},processSearch:function(h,g,y){if(!h.getSearchCursor)return;var w=y.searchArgs.forward,C=y.searchArgs.wholeWordOnly;Ti(h).setReversed(!w);var A=w?"/":"?",D=Ti(h).getQuery(),z=h.getScrollInfo(),W="";function j(Lt,ee,oe){ut.searchHistoryController.pushInput(Lt),ut.searchHistoryController.reset();try{Ie(h,Lt,ee,oe)}catch{ie(h,"Invalid regex: "+Lt),X(h);return}qt.processMotion(h,g,{keys:"",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:y.searchArgs.toJumplist}})}function U(Lt){h.scrollTo(z.left,z.top),j(Lt,!0,!0);var ee=ut.macroModeState;ee.isRecording&&Zs(ee,Lt)}function nt(){return St("pcre")?"(JavaScript regexp: set pcre)":"(Vim regexp: set nopcre)"}function ot(Lt,ee,oe){var se=B(Lt),$e,Ae;se=="<Up>"||se=="<Down>"?($e=se=="<Up>",Ae=Lt.target?Lt.target.selectionEnd:0,ee=ut.searchHistoryController.nextMatch(ee,$e)||"",oe(ee),Ae&&Lt.target&&(Lt.target.selectionEnd=Lt.target.selectionStart=Math.min(Ae,Lt.target.value.length))):se&&se!="<Left>"&&se!="<Right>"&&ut.searchHistoryController.reset(),W=ee,st()}function st(){var Lt;try{Lt=Ie(h,W,!0,!0)}catch{}Lt?h.scrollIntoView(Xo(h,!w,Lt),30):(bn(h),h.scrollTo(z.left,z.top))}function Y(Lt,ee,oe){var se=B(Lt);se=="<Esc>"||se=="<C-c>"||se=="<C-[>"||se=="<BS>"&&ee==""?(ut.searchHistoryController.pushInput(ee),ut.searchHistoryController.reset(),Ie(h,D?.source||""),bn(h),h.scrollTo(z.left,z.top),o.e_stop(Lt),X(h),oe(),h.focus()):se=="<Up>"||se=="<Down>"?o.e_stop(Lt):se=="<C-u>"&&(o.e_stop(Lt),oe(""))}switch(y.searchArgs.querySrc){case"prompt":var yt=ut.macroModeState;if(yt.isPlaying){let ee=yt.replaySearchQueries.shift();j(ee||"",!0,!1)}else Fn(h,{onClose:U,prefix:A,desc:ui("span",{$cursor:"pointer",onmousedown:function(ee){ee.preventDefault(),Ct("pcre",!St("pcre")),this.textContent=nt(),st()}},nt()),onKeyUp:ot,onKeyDown:Y});break;case"wordUnderCursor":var kt=Go(h,{noSymbol:!0}),Ut=!0;if(kt||(kt=Go(h,{noSymbol:!1}),Ut=!1),!kt){ie(h,"No word under cursor"),X(h);return}let Lt=h.getLine(kt.start.line).substring(kt.start.ch,kt.end.ch);Ut&&C?Lt="\\b"+Lt+"\\b":Lt=Ql(Lt),ut.jumpList.cachedCursor=h.getCursor(),h.setCursor(kt.start),j(Lt,!0,!1);break}},processEx:function(h,g,y){function w(z){ut.exCommandHistoryController.pushInput(z),ut.exCommandHistoryController.reset(),ii.processCommand(h,z),h.state.vim&&X(h),bn(h)}function C(z,W,j){var U=B(z),nt,ot;(U=="<Esc>"||U=="<C-c>"||U=="<C-[>"||U=="<BS>"&&W=="")&&(ut.exCommandHistoryController.pushInput(W),ut.exCommandHistoryController.reset(),o.e_stop(z),X(h),bn(h),j(),h.focus()),U=="<Up>"||U=="<Down>"?(o.e_stop(z),nt=U=="<Up>",ot=z.target?z.target.selectionEnd:0,W=ut.exCommandHistoryController.nextMatch(W,nt)||"",j(W),ot&&z.target&&(z.target.selectionEnd=z.target.selectionStart=Math.min(ot,z.target.value.length))):U=="<C-u>"?(o.e_stop(z),j("")):U&&U!="<Left>"&&U!="<Right>"&&ut.exCommandHistoryController.reset()}function A(z,W){var j=new o.StringStream(W),U={};try{if(ii.parseInput_(h,j,U),U.commandName!="s"){bn(h);return}var nt=ii.matchCommand_(U.commandName);if(!nt||(ii.parseCommandArgs_(j,U,nt),!U.argString))return;var ot=Qo(U.argString.slice(1),!0,!0);ot&&Vn(h,ot)}catch{}}if(y.type=="keyToEx")ii.processCommand(h,y.exArgs.input);else{var D={onClose:w,onKeyDown:C,onKeyUp:A,prefix:":"};g.visualMode&&(D.value="'<,'>",D.selectValueOnOpen=!1),Fn(h,D)}},evalInput:function(h,g){var y=g.inputState,w=y.motion,C=y.motionArgs||{repeat:1},A=y.operator,D=y.operatorArgs||{},z=y.registerName,W=g.sel,j=xe(g.visualMode?oi(h,W.head):h.getCursor("head")),U=xe(g.visualMode?oi(h,W.anchor):h.getCursor("anchor")),nt=xe(j),ot=xe(U),st,Y,yt;if(A&&this.recordLastEdit(g,y),y.repeatOverride!==void 0?yt=y.repeatOverride:yt=y.getRepeat(),yt>0&&C.explicitRepeat?C.repeatIsExplicit=!0:(C.noRepeat||!C.explicitRepeat&&yt===0)&&(yt=1,C.repeatIsExplicit=!1),y.selectedCharacter&&(C.selectedCharacter=D.selectedCharacter=y.selectedCharacter),C.repeat=yt,X(h),w){var kt=Vt[w](h,j,C,g,y);if(g.lastMotion=Vt[w],!kt)return;if(C.toJumplist){var Ut=ut.jumpList,Lt=Ut.cachedCursor;Lt?(zs(h,Lt,kt),delete Ut.cachedCursor):zs(h,j,kt)}kt instanceof Array?(Y=kt[0],st=kt[1]):st=kt,st||(st=xe(j)),g.visualMode?(g.visualBlock&&st.ch===1/0||(st=oi(h,st,nt)),Y&&(Y=oi(h,Y)),Y=Y||ot,W.anchor=Y,W.head=st,ao(h),ln(h,g,"<",Oe(Y,st)?Y:st),ln(h,g,">",Oe(Y,st)?st:Y)):A||(st=oi(h,st,nt),h.setCursor(st.line,st.ch))}if(A){if(D.lastSel){Y=ot;var ee=D.lastSel,oe=Math.abs(ee.head.line-ee.anchor.line),se=Math.abs(ee.head.ch-ee.anchor.ch);ee.visualLine?st=new t(ot.line+oe,ot.ch):ee.visualBlock?st=new t(ot.line+oe,ot.ch+se):ee.head.line==ee.anchor.line?st=new t(ot.line,ot.ch+se):st=new t(ot.line+oe,ot.ch),g.visualMode=!0,g.visualLine=ee.visualLine,g.visualBlock=ee.visualBlock,W=g.sel={anchor:Y,head:st},ao(h)}else g.visualMode&&(D.lastSel={anchor:xe(W.anchor),head:xe(W.head),visualBlock:g.visualBlock,visualLine:g.visualLine});var $e,Ae,he,Xt,we;if(g.visualMode){$e=si(W.head,W.anchor),Ae=an(W.head,W.anchor),he=g.visualLine||D.linewise,Xt=g.visualBlock?"block":he?"line":"char";var Ii=e(h,$e,Ae);if(we=Rs(h,{anchor:Ii.start,head:Ii.end},Xt),he){var Ke=we.ranges;if(Xt=="block")for(var wi=0;wi<Ke.length;wi++)Ke[wi].head.ch=Ye(h,Ke[wi].head.line);else Xt=="line"&&(Ke[0].head=new t(Ke[0].head.line+1,0))}}else{if($e=xe(Y||ot),Ae=xe(st||nt),Oe(Ae,$e)){var ji=$e;$e=Ae,Ae=ji}he=C.linewise||D.linewise,he?Gr(h,$e,Ae):C.forward&&Zr(h,$e,Ae),Xt="char";var jn=!C.inclusive||he,Ii=e(h,$e,Ae);we=Rs(h,{anchor:Ii.start,head:Ii.end},Xt,jn)}h.setSelections(we.ranges,we.primary),g.lastMotion=null,D.repeat=yt,D.registerName=z,D.linewise=he;var Qs=_e[A](h,D,we.ranges,ot,st);g.visualMode&&zt(h,Qs!=null),Qs&&h.setCursor(Qs)}},recordLastEdit:function(h,g,y){var w=ut.macroModeState;w.isPlaying||(h.lastEditInputState=g,h.lastEditActionCommand=y,w.lastInsertModeChanges.changes=[],w.lastInsertModeChanges.expectCursorActivityForChange=!1,w.lastInsertModeChanges.visualBlock=h.visualBlock?h.sel.head.line-h.sel.anchor.line:0)}},Vt={moveToTopLine:function(h,g,y){var w=co(h).top+y.repeat-1;return new t(w,Oi(h.getLine(w)))},moveToMiddleLine:function(h){var g=co(h),y=Math.floor((g.top+g.bottom)*.5);return new t(y,Oi(h.getLine(y)))},moveToBottomLine:function(h,g,y){var w=co(h).bottom-y.repeat+1;return new t(w,Oi(h.getLine(w)))},expandToLine:function(h,g,y){var w=g;return new t(w.line+y.repeat-1,1/0)},findNext:function(h,g,y){var w=Ti(h),C=w.getQuery();if(C){var A=!y.forward;A=w.isReversed()?!A:A,Vn(h,C);var D=Xo(h,A,C,y.repeat);return D||ie(h,"No match found "+C+(St("pcre")?" (set nopcre to use Vim regexps)":"")),D}},findAndSelectNextInclusive:function(h,g,y,w,C){var A=Ti(h),D=A.getQuery();if(D){var z=!y.forward;z=A.isReversed()?!z:z;var W=Mo(h,z,D,y.repeat,w);if(W){if(C.operator)return W;var j=W[0],U=new t(W[1].line,W[1].ch-1);if(w.visualMode){(w.visualLine||w.visualBlock)&&(w.visualLine=!1,w.visualBlock=!1,o.signal(h,"vim-mode-change",{mode:"visual",subMode:""}));var nt=w.sel.anchor;if(nt)return A.isReversed()?y.forward?[nt,j]:[nt,U]:y.forward?[nt,U]:[nt,j]}else w.visualMode=!0,w.visualLine=!1,w.visualBlock=!1,o.signal(h,"vim-mode-change",{mode:"visual",subMode:""});return z?[U,j]:[j,U]}}},goToMark:function(h,g,y,w){var C=ho(h,w,y.selectedCharacter||"");return C?y.linewise?{line:C.line,ch:Oi(h.getLine(C.line))}:C:null},moveToOtherHighlightedEnd:function(h,g,y,w){var C=w.sel;return w.visualBlock&&y.sameLine?[oi(h,new t(C.anchor.line,C.head.ch)),oi(h,new t(C.head.line,C.anchor.ch))]:[C.head,C.anchor]},jumpToMark:function(h,g,y,w){for(var C=g,A=0;A<y.repeat;A++){var D=C;for(var z in w.marks)if(H(z)){var W=w.marks[z].find(),j=y.forward?Oe(W,D):Oe(D,W);if(!j&&!(y.linewise&&W.line==D.line)){var U=ei(D,C),nt=y.forward?Ps(D,W,C):Ps(C,W,D);(U||nt)&&(C=W)}}}return y.linewise&&(C=new t(C.line,Oi(h.getLine(C.line)))),C},moveByCharacters:function(h,g,y){var w=g,C=y.repeat,A=y.forward?w.ch+C:w.ch-C;return new t(w.line,A)},moveByLines:function(h,g,y,w){var C=g,A=C.ch;switch(w.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:A=w.lastHPos;break;default:w.lastHPos=A}var D=y.repeat+(y.repeatOffset||0),z=y.forward?C.line+D:C.line-D,W=h.firstLine(),j=h.lastLine(),U=h.findPosV(C,y.forward?D:-D,"line",w.lastHSPos),nt=y.forward?U.line>z:U.line<z;return nt&&(z=U.line,A=U.ch),z<W&&C.line==W?this.moveToStartOfLine(h,g,y,w):z>j&&C.line==j?Fs(h,g,y,w,!0):(y.toFirstChar&&(A=Oi(h.getLine(z)),w.lastHPos=A),w.lastHSPos=h.charCoords(new t(z,A),"div").left,new t(z,A))},moveByDisplayLines:function(h,g,y,w){var C=g;switch(w.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:w.lastHSPos=h.charCoords(C,"div").left}var A=y.repeat,D=h.findPosV(C,y.forward?A:-A,"line",w.lastHSPos);if(D.hitSide)if(y.forward){var z=h.charCoords(D,"div"),W={top:z.top+8,left:w.lastHSPos};D=h.coordsChar(W,"div")}else{var j=h.charCoords(new t(h.firstLine(),0),"div");j.left=w.lastHSPos,D=h.coordsChar(j,"div")}return w.lastHPos=D.ch,D},moveByPage:function(h,g,y){var w=g,C=y.repeat;return h.findPosV(w,y.forward?C:-C,"page")},moveByParagraph:function(h,g,y){var w=y.forward?1:-1;return Xr(h,g,y.repeat,w).start},moveBySentence:function(h,g,y){var w=y.forward?1:-1;return sc(h,g,y.repeat,w)},moveByScroll:function(h,g,y,w){var C=h.getScrollInfo(),A=null,D=y.repeat;D||(D=C.clientHeight/(2*h.defaultTextHeight()));var z=h.charCoords(g,"local");if(y.repeat=D,A=Vt.moveByDisplayLines(h,g,y,w),!A)return null;var W=h.charCoords(A,"local");return h.scrollTo(null,C.top+W.top-z.top),A},moveByWords:function(h,g,y){return nc(h,g,y.repeat,!!y.forward,!!y.wordEnd,!!y.bigWord)},moveTillCharacter:function(h,g,y){var w=y.repeat,C=Ws(h,w,y.forward,y.selectedCharacter,g),A=y.forward?-1:1;return Bn(A,y),C?(C.ch+=A,C):null},moveToCharacter:function(h,g,y){var w=y.repeat;return Bn(0,y),Ws(h,w,y.forward,y.selectedCharacter,g)||g},moveToSymbol:function(h,g,y){var w=y.repeat;return y.selectedCharacter&&ic(h,w,y.forward,y.selectedCharacter)||g},moveToColumn:function(h,g,y,w){var C=y.repeat;return w.lastHPos=C-1,w.lastHSPos=h.charCoords(g,"div").left,Yo(h,C)},moveToEol:function(h,g,y,w){return Fs(h,g,y,w,!1)},moveToFirstNonWhiteSpaceCharacter:function(h,g){var y=g;return new t(y.line,Oi(h.getLine(y.line)))},moveToMatchedSymbol:function(h,g){for(var y=g,w=y.line,C=y.ch,A=h.getLine(w),D;C<A.length;C++)if(D=A.charAt(C),D&&Q(D)){var z=h.getTokenTypeAt(new t(w,C+1));if(z!=="string"&&z!=="comment")break}if(C<A.length){var W=D==="<"||D===">"?/[(){}[\]<>]/:/[(){}[\]]/,j=h.findMatchingBracket(new t(w,C),{bracketRegex:W});return j.to}else return y},moveToStartOfLine:function(h,g){return new t(g.line,0)},moveToLineOrEdgeOfDocument:function(h,g,y){var w=y.forward?h.lastLine():h.firstLine();return y.repeatIsExplicit&&(w=y.repeat-h.getOption("firstLineNumber")),new t(w,Oi(h.getLine(w)))},moveToStartOfDisplayLine:function(h){return h.execCommand("goLineLeft"),h.getCursor()},moveToEndOfDisplayLine:function(h){h.execCommand("goLineRight");var g=h.getCursor();return g.sticky=="before"&&g.ch--,g},textObjectManipulation:function(h,g,y,w){var C={"(":")",")":"(","{":"}","}":"{","[":"]","]":"[","<":">",">":"<"},A={"'":!0,'"':!0,"`":!0},D=y.selectedCharacter||"";D=="b"?D="(":D=="B"&&(D="{");var z=!y.textObjectInner,W,j;if(C[D]){if(j=!0,W=Jo(h,g,D,z),!W){var U=h.getSearchCursor(new RegExp("\\"+D,"g"),g);U.find()&&(W=Jo(h,U.from(),D,z))}}else if(A[D])j=!0,W=Ao(h,g,D,z);else if(D==="W"||D==="w")for(var nt=y.repeat||1;nt-- >0;){var ot=Go(h,{inclusive:z,innerWord:!z,bigWord:D==="W",noSymbol:D==="W",multiline:!0},W&&W.end);ot&&(W||(W=ot),W.end=ot.end)}else if(D==="p")if(W=Xr(h,g,y.repeat,0,z),y.linewise=!0,w.visualMode)w.visualLine||(w.visualLine=!0);else{var st=w.inputState.operatorArgs;st&&(st.linewise=!0),W.end.line--}else if(D==="t")W=Bs(h,g,z);else if(D==="s"){var Y=h.getLine(g.line);g.ch>0&&vt(Y[g.ch])&&(g.ch-=1);var yt=ta(h,g,y.repeat,1,z),kt=ta(h,g,y.repeat,-1,z);rt(h.getLine(kt.line)[kt.ch])&&rt(h.getLine(yt.line)[yt.ch-1])&&(kt={line:kt.line,ch:kt.ch+1}),W={start:kt,end:yt}}return W?h.state.vim.visualMode?ec(h,W.start,W.end,j):[W.start,W.end]:null},repeatLastCharacterSearch:function(h,g,y){var w=ut.lastCharacterSearch,C=y.repeat,A=y.forward===w.forward,D=(w.increment?1:0)*(A?-1:1);h.moveH(-D,"char"),y.inclusive=!!A;var z=Ws(h,C,A,w.selectedCharacter);return z?(z.ch+=D,z):(h.moveH(D,"char"),g)}};function be(h,g){Vt[h]=g}function Ce(h,g){for(var y=[],w=0;w<g;w++)y.push(h);return y}var _e={change:function(h,g,y){var w,C,A=h.state.vim,D=y[0].anchor,z=y[0].head;if(A.visualMode)if(g.fullLine)z.ch=Number.MAX_VALUE,z.line--,h.setSelection(D,z),C=h.getSelection(),h.replaceSelection(""),w=D;else{C=h.getSelection();var W=Ce("",y.length);h.replaceSelections(W),w=si(y[0].head,y[0].anchor)}else{C=h.getRange(D,z);var j=A.lastEditInputState;if(j?.motion=="moveByWords"&&!rt(C)){var U=/\s+$/.exec(C);U&&j.motionArgs&&j.motionArgs.forward&&(z=De(z,0,-U[0].length),C=C.slice(0,-U[0].length))}g.linewise&&(D=new t(D.line,Oi(h.getLine(D.line))),z.line>D.line&&(z=new t(z.line-1,Number.MAX_VALUE))),h.replaceRange("",D,z),w=D}ut.registerController.pushText(g.registerName,"change",C,g.linewise,y.length>1),Si.enterInsertMode(h,{head:w},h.state.vim)},delete:function(h,g,y){var w,C,A=h.state.vim;if(A.visualBlock){C=h.getSelection();var D=Ce("",y.length);h.replaceSelections(D),w=si(y[0].head,y[0].anchor)}else{var z=y[0].anchor,W=y[0].head;g.linewise&&W.line!=h.firstLine()&&z.line==h.lastLine()&&z.line==W.line-1&&(z.line==h.firstLine()?z.ch=0:z=new t(z.line-1,Ye(h,z.line-1))),C=h.getRange(z,W),h.replaceRange("",z,W),w=z,g.linewise&&(w=Vt.moveToFirstNonWhiteSpaceCharacter(h,z))}return ut.registerController.pushText(g.registerName,"delete",C,g.linewise,A.visualBlock),oi(h,w)},indent:function(h,g,y){var w=h.state.vim,C=w.visualMode&&g.repeat||1;if(w.visualBlock){for(var A=h.getOption("tabSize"),D=h.getOption("indentWithTabs")?" ":" ".repeat(A),z,W=y.length-1;W>=0;W--)if(z=si(y[W].anchor,y[W].head),g.indentRight)h.replaceRange(D.repeat(C),z,z);else{for(var j=h.getLine(z.line),U=0,nt=0;nt<C;nt++){var ot=j[z.ch+U];if(ot==" ")U++;else if(ot==" "){U++;for(var st=1;st<D.length&&(ot=j[z.ch+U],ot===" ");st++)U++}else break}h.replaceRange("",z,De(z,0,U))}return z}else if(h.indentMore)for(var nt=0;nt<C;nt++)g.indentRight?h.indentMore():h.indentLess();else{var Y=y[0].anchor.line,yt=w.visualBlock?y[y.length-1].anchor.line:y[0].head.line;g.linewise&&yt--;for(var W=Y;W<=yt;W++)for(var nt=0;nt<C;nt++)h.indentLine(W,g.indentRight)}return Vt.moveToFirstNonWhiteSpaceCharacter(h,y[0].anchor)},indentAuto:function(h,g,y){return h.execCommand("indentAuto"),Vt.moveToFirstNonWhiteSpaceCharacter(h,y[0].anchor)},hardWrap:function(h,g,y,w){if(h.hardWrap){var C=y[0].anchor.line,A=y[0].head.line;g.linewise&&A--;var D=h.hardWrap({from:C,to:A});return D>C&&g.linewise&&D--,g.keepCursor?w:new t(D,0)}},changeCase:function(h,g,y,w,C){for(var A=h.getSelections(),D=[],z=g.toLower,W=0;W<A.length;W++){var j=A[W],U="";if(z===!0)U=j.toLowerCase();else if(z===!1)U=j.toUpperCase();else for(var nt=0;nt<j.length;nt++){var ot=j.charAt(nt);U+=it(ot)?ot.toLowerCase():ot.toUpperCase()}D.push(U)}return h.replaceSelections(D),g.shouldMoveCursor?C:!h.state.vim.visualMode&&g.linewise&&y[0].anchor.line+1==y[0].head.line?Vt.moveToFirstNonWhiteSpaceCharacter(h,w):g.linewise?w:si(y[0].anchor,y[0].head)},yank:function(h,g,y,w){var C=h.state.vim,A=h.getSelection(),D=C.visualMode?si(C.sel.anchor,C.sel.head,y[0].head,y[0].anchor):w;return ut.registerController.pushText(g.registerName,"yank",A,g.linewise,C.visualBlock),D},rot13:function(h,g,y,w,C){for(var A=h.getSelections(),D=[],z=0;z<A.length;z++){const W=A[z].split("").map(j=>{const U=j.charCodeAt(0);return U>=65&&U<=90?String.fromCharCode(65+(U-65+13)%26):U>=97&&U<=122?String.fromCharCode(97+(U-97+13)%26):j}).join("");D.push(W)}return h.replaceSelections(D),g.shouldMoveCursor?C:!h.state.vim.visualMode&&g.linewise&&y[0].anchor.line+1==y[0].head.line?Vt.moveToFirstNonWhiteSpaceCharacter(h,w):g.linewise?w:si(y[0].anchor,y[0].head)}};function je(h,g){_e[h]=g}var Si={jumpListWalk:function(h,g,y){if(!y.visualMode){var w=g.repeat||1,C=g.forward,A=ut.jumpList,D=A.move(h,C?w:-w),z=D?D.find():void 0;z=z||h.getCursor(),h.setCursor(z)}},scroll:function(h,g,y){if(!y.visualMode){var w=g.repeat||1,C=h.defaultTextHeight(),A=h.getScrollInfo().top,D=C*w,z=g.forward?A+D:A-D,W=xe(h.getCursor()),j=h.charCoords(W,"local");if(g.forward)z>j.top?(W.line+=(z-j.top)/C,W.line=Math.ceil(W.line),h.setCursor(W),j=h.charCoords(W,"local"),h.scrollTo(null,j.top)):h.scrollTo(null,z);else{var U=z+h.getScrollInfo().clientHeight;U<j.bottom?(W.line-=(j.bottom-U)/C,W.line=Math.floor(W.line),h.setCursor(W),j=h.charCoords(W,"local"),h.scrollTo(null,j.bottom-h.getScrollInfo().clientHeight)):h.scrollTo(null,z)}}},scrollToCursor:function(h,g){var y=h.getCursor().line,w=h.charCoords(new t(y,0),"local"),C=h.getScrollInfo().clientHeight,A=w.top;switch(g.position){case"center":A=w.bottom-C/2;break;case"bottom":var D=new t(y,h.getLine(y).length-1),z=h.charCoords(D,"local"),W=z.bottom-A;A=A-C+W;break}h.scrollTo(null,A)},replayMacro:function(h,g,y){var w=g.selectedCharacter||"",C=g.repeat||1,A=ut.macroModeState;for(w=="@"?w=A.latestRegister||"":A.latestRegister=w;C--;)qs(h,y,A,w)},enterMacroRecordMode:function(h,g){var y=ut.macroModeState,w=g.selectedCharacter;ut.registerController.isValidRegister(w)&&y.enterMacroRecordMode(h,w)},toggleOverwrite:function(h){h.state.overwrite?(h.toggleOverwrite(!1),h.setOption("keyMap","vim-insert"),o.signal(h,"vim-mode-change",{mode:"insert"})):(h.toggleOverwrite(!0),h.setOption("keyMap","vim-replace"),o.signal(h,"vim-mode-change",{mode:"replace"}))},enterInsertMode:function(h,g,y){if(!h.getOption("readOnly")){y.insertMode=!0,y.insertModeRepeat=g&&g.repeat||1;var w=g?g.insertAt:null,C=y.sel,A=g.head||h.getCursor("head"),D=h.listSelections().length;if(w=="eol")A=new t(A.line,Ye(h,A.line));else if(w=="bol")A=new t(A.line,0);else if(w=="charAfter"){var z=e(h,A,De(A,0,1));A=z.end}else if(w=="firstNonBlank"){var z=e(h,A,Vt.moveToFirstNonWhiteSpaceCharacter(h,A));A=z.end}else if(w=="startOfSelectedArea"){if(!y.visualMode)return;y.visualBlock?(A=new t(Math.min(C.head.line,C.anchor.line),Math.min(C.head.ch,C.anchor.ch)),D=Math.abs(C.head.line-C.anchor.line)+1):C.head.line<C.anchor.line?A=C.head:A=new t(C.anchor.line,0)}else if(w=="endOfSelectedArea"){if(!y.visualMode)return;y.visualBlock?(A=new t(Math.min(C.head.line,C.anchor.line),Math.max(C.head.ch,C.anchor.ch)+1),D=Math.abs(C.head.line-C.anchor.line)+1):C.head.line>=C.anchor.line?A=De(C.head,0,1):A=new t(C.anchor.line,0)}else if(w=="inplace"){if(y.visualMode)return}else w=="lastEdit"&&(A=ts(h)||A);h.setOption("disableInput",!1),g&&g.replace?(h.toggleOverwrite(!0),h.setOption("keyMap","vim-replace"),o.signal(h,"vim-mode-change",{mode:"replace"})):(h.toggleOverwrite(!1),h.setOption("keyMap","vim-insert"),o.signal(h,"vim-mode-change",{mode:"insert"})),ut.macroModeState.isPlaying||(h.on("change",uo),y.insertEnd&&y.insertEnd.clear(),y.insertEnd=h.setBookmark(A,{insertLeft:!0}),o.on(h.getInputField(),"keydown",Gs)),y.visualMode&&zt(h),qr(h,A,D)}},toggleVisualMode:function(h,g,y){var w=g.repeat,C=h.getCursor(),A;if(y.visualMode)y.visualLine!=!!g.linewise||y.visualBlock!=!!g.blockwise?(y.visualLine=!!g.linewise,y.visualBlock=!!g.blockwise,o.signal(h,"vim-mode-change",{mode:"visual",subMode:y.visualLine?"linewise":y.visualBlock?"blockwise":""}),ao(h)):zt(h);else{y.visualMode=!0,y.visualLine=!!g.linewise,y.visualBlock=!!g.blockwise,A=oi(h,new t(C.line,C.ch+w-1));var D=e(h,C,A);y.sel={anchor:D.start,head:D.end},o.signal(h,"vim-mode-change",{mode:"visual",subMode:y.visualLine?"linewise":y.visualBlock?"blockwise":""}),ao(h),ln(h,y,"<",si(C,A)),ln(h,y,">",an(C,A))}},reselectLastSelection:function(h,g,y){var w=y.lastSelection;if(y.visualMode&&Kr(h,y),w){var C=w.anchorMark.find(),A=w.headMark.find();if(!C||!A)return;y.sel={anchor:C,head:A},y.visualMode=!0,y.visualLine=w.visualLine,y.visualBlock=w.visualBlock,ao(h),ln(h,y,"<",si(C,A)),ln(h,y,">",an(C,A)),o.signal(h,"vim-mode-change",{mode:"visual",subMode:y.visualLine?"linewise":y.visualBlock?"blockwise":""})}},joinLines:function(h,g,y){var w,C;if(y.visualMode){if(w=h.getCursor("anchor"),C=h.getCursor("head"),Oe(C,w)){var A=C;C=w,w=A}C.ch=Ye(h,C.line)-1}else{var D=Math.max(g.repeat,2);w=h.getCursor(),C=oi(h,new t(w.line+D-1,1/0))}for(var z=0,W=w.line;W<C.line;W++){z=Ye(h,w.line);var j="",U=0;if(!g.keepSpaces){var nt=h.getLine(w.line+1);U=nt.search(/\S/),U==-1?U=nt.length:j=" "}h.replaceRange(j,new t(w.line,z),new t(w.line+1,U))}var ot=oi(h,new t(w.line,z));y.visualMode&&zt(h,!1),h.setCursor(ot)},newLineAndEnterInsertMode:function(h,g,y){y.insertMode=!0;var w=xe(h.getCursor());if(w.line===h.firstLine()&&!g.after)h.replaceRange(`
|
||
`,new t(h.firstLine(),0)),h.setCursor(h.firstLine(),0);else{w.line=g.after?w.line:w.line-1,w.ch=Ye(h,w.line),h.setCursor(w);var C=o.commands.newlineAndIndentContinueComment||o.commands.newlineAndIndent;C(h)}this.enterInsertMode(h,{repeat:g.repeat},y)},paste:function(h,g,y){var w=ut.registerController.getRegister(g.registerName);if(g.registerName==="+")navigator.clipboard.readText().then(A=>{this.continuePaste(h,g,y,A,w)});else{var C=w.toString();this.continuePaste(h,g,y,C,w)}},continuePaste:function(h,g,y,w,C){var A=xe(h.getCursor());if(w){if(g.matchIndent){var D=h.getOption("tabSize"),z=function(Ke){var wi=Ke.split(" ").length-1,ji=Ke.split(" ").length-1;return wi*D+ji*1},W=h.getLine(h.getCursor().line),j=z(W.match(/^\s*/)[0]),U=w.replace(/\n$/,""),nt=w!==U,ot=z(w.match(/^\s*/)[0]),w=U.replace(/^\s*/gm,function(Ke){var wi=j+(z(Ke)-ot);if(wi<0)return"";if(h.getOption("indentWithTabs")){var ji=Math.floor(wi/D);return Array(ji+1).join(" ")}else return Array(wi+1).join(" ")});w+=nt?`
|
||
`:""}g.repeat>1&&(w=Array(g.repeat+1).join(w));var st=C.linewise,Y=C.blockwise,yt=Y?w.split(`
|
||
`):void 0;if(yt){st&&yt.pop();for(var kt=0;kt<yt.length;kt++)yt[kt]=yt[kt]==""?" ":yt[kt];A.ch+=g.after?1:0,A.ch=Math.min(Ye(h,A.line),A.ch)}else st?y.visualMode?w=y.visualLine?w.slice(0,-1):`
|
||
`+w.slice(0,w.length-1)+`
|
||
`:g.after?(w=`
|
||
`+w.slice(0,w.length-1),A.ch=Ye(h,A.line)):A.ch=0:A.ch+=g.after?1:0;var Ut;if(y.visualMode){y.lastPastedText=w;var Lt,ee=Ds(h),oe=ee[0],se=ee[1],$e=h.getSelection(),Ae=h.listSelections(),he=new Array(Ae.length).join("1").split("1");y.lastSelection&&(Lt=y.lastSelection.headMark.find()),ut.registerController.unnamedRegister.setText($e),Y?(h.replaceSelections(he),se=new t(oe.line+w.length-1,oe.ch),h.setCursor(oe),jr(h,se),h.replaceSelections(w),Ut=oe):y.visualBlock?(h.replaceSelections(he),h.setCursor(oe),h.replaceRange(w,oe,oe),Ut=oe):(h.replaceRange(w,oe,se),Ut=h.posFromIndex(h.indexFromPos(oe)+w.length-1)),Lt&&(y.lastSelection.headMark=h.setBookmark(Lt)),st&&(Ut.ch=0)}else if(Y&&yt){h.setCursor(A);for(var kt=0;kt<yt.length;kt++){var Xt=A.line+kt;Xt>h.lastLine()&&h.replaceRange(`
|
||
`,new t(Xt,0));var we=Ye(h,Xt);we<A.ch&&Xl(h,Xt,A.ch)}h.setCursor(A),jr(h,new t(A.line+yt.length-1,A.ch)),h.replaceSelections(yt),Ut=A}else if(h.replaceRange(w,A),st){var Xt=g.after?A.line+1:A.line;Ut=new t(Xt,Oi(h.getLine(Xt)))}else Ut=xe(A),/\n/.test(w)||(Ut.ch+=w.length-(g.after?1:0));y.visualMode&&zt(h,!1),h.setCursor(Ut)}},undo:function(h,g){h.operation(function(){Ms(h,o.commands.undo,g.repeat)(),h.setCursor(oi(h,h.getCursor("start")))})},redo:function(h,g){Ms(h,o.commands.redo,g.repeat)()},setRegister:function(h,g,y){y.inputState.registerName=g.selectedCharacter},insertRegister:function(h,g,y){var w=g.selectedCharacter,C=ut.registerController.getRegister(w),A=C&&C.toString();A&&h.replaceSelection(A)},oneNormalCommand:function(h,g,y){Gt(h,!0),y.insertModeReturn=!0,o.on(h,"vim-command-done",function w(){y.visualMode||(y.insertModeReturn&&(y.insertModeReturn=!1,y.insertMode||Si.enterInsertMode(h,{},y)),o.off(h,"vim-command-done",w))})},setMark:function(h,g,y){var w=g.selectedCharacter;w&&ln(h,y,w,h.getCursor())},replace:function(h,g,y){var w=g.selectedCharacter||"",C=h.getCursor(),A,D,z=h.listSelections();if(y.visualMode)C=h.getCursor("start"),D=h.getCursor("end");else{var W=h.getLine(C.line);A=C.ch+g.repeat,A>W.length&&(A=W.length),D=new t(C.line,A)}var j=e(h,C,D);if(C=j.start,D=j.end,w==`
|
||
`)y.visualMode||h.replaceRange("",C,D),(o.commands.newlineAndIndentContinueComment||o.commands.newlineAndIndent)(h);else{var U=h.getRange(C,D);if(U=U.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,w),U=U.replace(/[^\n]/g,w),y.visualBlock){var nt=new Array(h.getOption("tabSize")+1).join(" ");U=h.getSelection(),U=U.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,w);var ot=U.replace(/\t/g,nt).replace(/[^\n]/g,w).split(`
|
||
`);h.replaceSelections(ot)}else h.replaceRange(U,C,D);y.visualMode?(C=Oe(z[0].anchor,z[0].head)?z[0].anchor:z[0].head,h.setCursor(C),zt(h,!1)):h.setCursor(De(D,0,-1))}},incrementNumberToken:function(h,g){for(var y=h.getCursor(),w=h.getLine(y.line),C=/(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi,A,D,z,W;(A=C.exec(w))!==null&&(D=A.index,z=D+A[0].length,!(y.ch<z)););if(!(!g.backtrack&&z<=y.ch)){if(A){var j=A[2]||A[4],U=A[3]||A[5],nt=g.increase?1:-1,ot={"0b":2,0:8,"":10,"0x":16}[j.toLowerCase()],st=parseInt(A[1]+U,ot)+nt*g.repeat;W=st.toString(ot);var Y=j?new Array(U.length-W.length+1+A[1].length).join("0"):"";W.charAt(0)==="-"?W="-"+j+Y+W.substr(1):W=j+Y+W;var yt=new t(y.line,D),kt=new t(y.line,z);h.replaceRange(W,yt,kt)}else return;h.setCursor(new t(y.line,D+W.length-1))}},repeatLastEdit:function(h,g,y){var w=y.lastEditInputState;if(w){var C=g.repeat;C&&g.repeatIsExplicit?w.repeatOverride=C:C=w.repeatOverride||C,Ys(h,y,C,!1)}},indent:function(h,g){h.indentLine(h.getCursor().line,g.indentRight)},exitInsertMode:function(h,g){Gt(h)}};function Vr(h,g){Si[h]=g}function oi(h,g,y){var w=h.state.vim,C=w.insertMode||w.visualMode,A=Math.min(Math.max(h.firstLine(),g.line),h.lastLine()),D=h.getLine(A),z=D.length-1+ +!!C,W=Math.min(Math.max(0,g.ch),z),j=D.charCodeAt(W);if(56320<=j&&j<=57343){var U=1;y&&y.line==A&&y.ch>W&&(U=-1),W+=U,W>z&&(W-=2)}return new t(A,W)}function Io(h){var g={};for(var y in h)Object.prototype.hasOwnProperty.call(h,y)&&(g[y]=h[y]);return g}function De(h,g,y){return typeof g=="object"&&(y=g.ch,g=g.line),new t(h.line+g,h.ch+y)}function Jl(h,g,y,w){w.operator&&(y="operatorPending");for(var C,A=[],D=[],z=Et?g.length-s:0,W=z;W<g.length;W++){var j=g[W];y=="insert"&&j.context!="insert"||j.context&&j.context!=y||w.operator&&j.type=="action"||!(C=Ur(h,j.keys))||(C=="partial"&&A.push(j),C=="full"&&D.push(j))}return{partial:A,full:D}}function Ur(h,g){const y=g.slice(-11)=="<character>",w=g.slice(-10)=="<register>";if(y||w){var C=g.length-(y?11:10),A=h.slice(0,C),D=g.slice(0,C);return A==D&&h.length>C?"full":D.indexOf(A)==0?"partial":!1}else return h==g?"full":g.indexOf(h)==0?"partial":!1}function Ns(h){var g=/^.*(<[^>]+>)$/.exec(h),y=g?g[1]:h.slice(-1);if(y.length>1)switch(y){case"<CR>":case"<S-CR>":y=`
|
||
`;break;case"<Space>":case"<S-Space>":y=" ";break;default:y="";break}return y}function Ms(h,g,y){return function(){for(var w=0;w<y;w++)g(h)}}function xe(h){return new t(h.line,h.ch)}function ei(h,g){return h.ch==g.ch&&h.line==g.line}function Oe(h,g){return h.line<g.line||h.line==g.line&&h.ch<g.ch}function si(h,g){return arguments.length>2&&(g=si.apply(void 0,Array.prototype.slice.call(arguments,1))),Oe(h,g)?h:g}function an(h,g){return arguments.length>2&&(g=an.apply(void 0,Array.prototype.slice.call(arguments,1))),Oe(h,g)?g:h}function Ps(h,g,y){var w=Oe(h,g),C=Oe(g,y);return w&&C}function Ye(h,g){return h.getLine(g).length}function Os(h){return h.trim?h.trim():h.replace(/^\s+|\s+$/g,"")}function Ql(h){return h.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function Xl(h,g,y){var w=Ye(h,g),C=new Array(y-w+1).join(" ");h.setCursor(new t(g,w)),h.replaceRange(C,h.getCursor())}function jr(h,g){var y=[],w=h.listSelections(),C=xe(h.clipPos(g)),A=!ei(g,C),D=h.getCursor("head"),z=tc(w,D),W=ei(w[z].head,w[z].anchor),j=w.length-1,U=j-z>z?j:0,nt=w[U].anchor,ot=Math.min(nt.line,C.line),st=Math.max(nt.line,C.line),Y=nt.ch,yt=C.ch,kt=w[U].head.ch-Y,Ut=yt-Y;kt>0&&Ut<=0?(Y++,A||yt--):kt<0&&Ut>=0?(Y--,W||yt++):kt<0&&Ut==-1&&(Y--,yt++);for(var Lt=ot;Lt<=st;Lt++){var ee={anchor:new t(Lt,Y),head:new t(Lt,yt)};y.push(ee)}return h.setSelections(y),g.ch=yt,nt.ch=Y,nt}function qr(h,g,y){for(var w=[],C=0;C<y;C++){var A=De(g,C,0);w.push({anchor:A,head:A})}h.setSelections(w,0)}function tc(h,g,y){for(var w=0;w<h.length;w++){var C=ei(h[w].anchor,g),A=ei(h[w].head,g);if(C||A)return w}return-1}function Ds(h,g){var y=h.listSelections(),w=y[0],C=y[y.length-1],A=Oe(w.anchor,w.head)?w.anchor:w.head,D=Oe(C.anchor,C.head)?C.head:C.anchor;return[A,D]}function Kr(h,g){var y=g.sel.anchor,w=g.sel.head;g.lastPastedText&&(w=h.posFromIndex(h.indexFromPos(y)+g.lastPastedText.length),g.lastPastedText=void 0),g.lastSelection={anchorMark:h.setBookmark(y),headMark:h.setBookmark(w),anchor:xe(y),head:xe(w),visualMode:g.visualMode,visualLine:g.visualLine,visualBlock:g.visualBlock}}function ec(h,g,y,w){var C=h.state.vim.sel,A=w?g:C.head,D=w?g:C.anchor,z;return Oe(y,g)&&(z=y,y=g,g=z),Oe(A,D)?(A=si(g,A),D=an(D,y)):(D=si(g,D),A=an(A,y),A=De(A,0,-1),A.ch==-1&&A.line!=h.firstLine()&&(A=new t(A.line-1,Ye(h,A.line-1)))),[D,A]}function ao(h,g,y){var w=h.state.vim;g=g||w.sel,y||(y=w.visualLine?"line":w.visualBlock?"block":"char");var C=Rs(h,g,y);h.setSelections(C.ranges,C.primary)}function Rs(h,g,y,w){var C=xe(g.head),A=xe(g.anchor);if(y=="char"){var D=!w&&!Oe(g.head,g.anchor)?1:0,z=Oe(g.head,g.anchor)?1:0;return C=De(g.head,0,D),A=De(g.anchor,0,z),{ranges:[{anchor:A,head:C}],primary:0}}else if(y=="line"){if(Oe(g.head,g.anchor))C.ch=0,A.ch=Ye(h,A.line);else{A.ch=0;var W=h.lastLine();C.line>W&&(C.line=W),C.ch=Ye(h,C.line)}return{ranges:[{anchor:A,head:C}],primary:0}}else if(y=="block"){var j=Math.min(A.line,C.line),U=A.ch,nt=Math.max(A.line,C.line),ot=C.ch;U<ot?ot+=1:U+=1;for(var st=nt-j+1,Y=C.line==j?0:st-1,yt=[],kt=0;kt<st;kt++)yt.push({anchor:new t(j+kt,U),head:new t(j+kt,ot)});return{ranges:yt,primary:Y}}throw"never happens"}function Ui(h){var g=h.getCursor("head");return h.getSelection().length==1&&(g=si(g,h.getCursor("anchor"))),g}function zt(h,g){var y=h.state.vim;g!==!1&&h.setCursor(oi(h,y.sel.head)),Kr(h,y),y.visualMode=!1,y.visualLine=!1,y.visualBlock=!1,y.insertMode||o.signal(h,"vim-mode-change",{mode:"normal"})}function Zr(h,g,y){var w=h.getRange(g,y);if(/\n\s*$/.test(w)){var C=w.split(`
|
||
`);C.pop();for(var A=C.pop();C.length>0&&A&&rt(A);A=C.pop())y.line--,y.ch=0;A?(y.line--,y.ch=Ye(h,y.line)):y.ch=0}}function Gr(h,g,y){g.ch=0,y.ch=0,y.line++}function Oi(h){if(!h)return 0;var g=h.search(/\S/);return g==-1?h.length:g}function Go(h,{inclusive:g,innerWord:y,bigWord:w,noSymbol:C,multiline:A},D){var z=D||Ui(h),W=h.getLine(z.line),j=W,U=z.line,nt=U,ot=z.ch,st,Y=C?x[0]:T[0];if(y&&/\s/.test(W.charAt(ot)))Y=function(oe){return/\s/.test(oe)};else{for(;!Y(W.charAt(ot));)if(ot++,ot>=W.length){if(!A)return null;ot--,st=Qr(h,z,!0,w,!0);break}w?Y=T[0]:(Y=x[0],Y(W.charAt(ot))||(Y=x[1]))}for(var yt=ot,kt=ot;Y(W.charAt(kt))&&kt>=0;)kt--;if(kt++,st)yt=st.to,nt=st.line,j=h.getLine(nt),!j&&yt==0&&yt++;else for(;Y(W.charAt(yt))&&yt<W.length;)yt++;if(g){var Ut=yt,Lt=z.ch<=kt&&/\s/.test(W.charAt(z.ch));if(!Lt)for(;/\s/.test(j.charAt(yt))&&yt<j.length;)yt++;if(Ut==yt||Lt){for(var ee=kt;/\s/.test(W.charAt(kt-1))&&kt>0;)kt--;!kt&&!Lt&&(kt=ee)}}return{start:new t(U,kt),end:new t(nt,yt)}}function Bs(h,g,y){var w=g;if(!o.findMatchingTag||!o.findEnclosingTag)return{start:w,end:w};var C=o.findMatchingTag(h,g)||o.findEnclosingTag(h,g);return!C||!C.open||!C.close?{start:w,end:w}:y?{start:C.open.from,end:C.close.to}:{start:C.open.to,end:C.close.from}}function zs(h,g,y){ei(g,y)||ut.jumpList.add(h,g,y)}function Bn(h,g){ut.lastCharacterSearch.increment=h,ut.lastCharacterSearch.forward=g.forward,ut.lastCharacterSearch.selectedCharacter=g.selectedCharacter}var Yr={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},Jr={bracket:{isComplete:function(h){if(h.nextCh===h.symb){if(h.depth++,h.depth>=1)return!0}else h.nextCh===h.reverseSymb&&h.depth--;return!1}},section:{init:function(h){h.curMoveThrough=!0,h.symb=(h.forward?"]":"[")===h.symb?"{":"}"},isComplete:function(h){return h.index===0&&h.nextCh===h.symb}},comment:{isComplete:function(h){var g=h.lastCh==="*"&&h.nextCh==="/";return h.lastCh=h.nextCh,g}},method:{init:function(h){h.symb=h.symb==="m"?"{":"}",h.reverseSymb=h.symb==="{"?"}":"{"},isComplete:function(h){return h.nextCh===h.symb}},preprocess:{init:function(h){h.index=0},isComplete:function(h){var g;if(h.nextCh==="#"){var y=(g=h.lineText.match(/^#(\w+)/))==null?void 0:g[1];if(y==="endif"){if(h.forward&&h.depth===0)return!0;h.depth++}else if(y==="if"){if(!h.forward&&h.depth===0)return!0;h.depth--}if(y==="else"&&h.depth===0)return!0}return!1}}};function ic(h,g,y,w){var C=xe(h.getCursor()),A=y?1:-1,D=y?h.lineCount():-1,z=C.ch,W=C.line,j=h.getLine(W),U={lineText:j,nextCh:j.charAt(z),lastCh:null,index:z,symb:w,reverseSymb:(y?{")":"(","}":"{"}:{"(":")","{":"}"})[w],forward:y,depth:0,curMoveThrough:!1},nt=Yr[w];if(!nt)return C;var ot=Jr[nt].init,st=Jr[nt].isComplete;for(ot&&ot(U);W!==D&&g;){if(U.index+=A,U.nextCh=U.lineText.charAt(U.index),!U.nextCh){if(W+=A,U.lineText=h.getLine(W)||"",A>0)U.index=0;else{var Y=U.lineText.length;U.index=Y>0?Y-1:0}U.nextCh=U.lineText.charAt(U.index)}st(U)&&(C.line=W,C.ch=U.index,g--)}return U.nextCh||U.curMoveThrough?new t(W,U.index):C}function Qr(h,g,y,w,C){var A=g.line,D=g.ch,z=h.getLine(A),W=y?1:-1,j=w?T:x;if(C&&z==""){if(A+=W,z=h.getLine(A),!q(h,A))return null;D=y?0:z.length}for(;;){if(C&&z=="")return{from:0,to:0,line:A};for(var U=W>0?z.length:-1,nt=U,ot=U;D!=U;){for(var st=!1,Y=0;Y<j.length&&!st;++Y)if(j[Y](z.charAt(D))){for(nt=D;D!=U&&j[Y](z.charAt(D));)D+=W;if(ot=D,st=nt!=ot,nt==g.ch&&A==g.line&&ot==nt+W)continue;return{from:Math.min(nt,ot+1),to:Math.max(nt,ot),line:A}}st||(D+=W)}if(A+=W,!q(h,A))return null;z=h.getLine(A),D=W>0?0:z.length}}function nc(h,g,y,w,C,A){var D=xe(g),z=[];(w&&!C||!w&&C)&&y++;for(var W=!(w&&C),j=0;j<y;j++){var U=Qr(h,g,w,A,W);if(!U){var nt=Ye(h,h.lastLine());z.push(w?{line:h.lastLine(),from:nt,to:nt}:{line:0,from:0,to:0});break}z.push(U),g=new t(U.line,w?U.to-1:U.from)}var ot=z.length!=y,st=z[0],Y=z.pop();return w&&!C?(!ot&&(st.from!=D.ch||st.line!=D.line)&&(Y=z.pop()),Y&&new t(Y.line,Y.from)):w&&C?Y&&new t(Y.line,Y.to-1):!w&&C?(!ot&&(st.to!=D.ch||st.line!=D.line)&&(Y=z.pop()),Y&&new t(Y.line,Y.to)):Y&&new t(Y.line,Y.from)}function Fs(h,g,y,w,C){var A=g,D=new t(A.line+y.repeat-1,1/0),z=h.clipPos(D);return z.ch--,C||(w.lastHPos=1/0,w.lastHSPos=h.charCoords(z,"div").left),D}function Ws(h,g,y,w,C){if(w){for(var A=C||h.getCursor(),D=A.ch,z,W=0;W<g;W++){var j=h.getLine(A.line);if(z=oc(D,j,w,y),z==-1)return;D=z}if(z!=null)return new t(h.getCursor().line,z)}}function Yo(h,g){var y=h.getCursor().line;return oi(h,new t(y,g-1))}function ln(h,g,y,w){!Dt(y,M)&&!F.test(y)||(g.marks[y]&&g.marks[y].clear(),g.marks[y]=h.setBookmark(w))}function oc(h,g,y,w,C){var A;return w?A=g.indexOf(y,h+1):A=g.lastIndexOf(y,h-1),A}function Xr(h,g,y,w,C){var A=g.line,D=h.firstLine(),z=h.lastLine(),W,j,U=A;function nt(kt){return!h.getLine(kt)}function ot(kt,Ut,Lt){return Lt?nt(kt)!=nt(kt+Ut):!nt(kt)&&nt(kt+Ut)}if(w){for(;D<=U&&U<=z&&y>0;)ot(U,w)&&y--,U+=w;return{start:new t(U,0),end:g}}var st=h.state.vim;if(st.visualLine&&ot(A,1,!0)){var Y=st.sel.anchor;ot(Y.line,-1,!0)&&(!C||Y.line!=A)&&(A+=1)}var yt=nt(A);for(U=A;U<=z&&y;U++)ot(U,1,!0)&&(!C||nt(U)!=yt)&&y--;for(j=new t(U,0),U>z&&!yt?yt=!0:C=!1,U=A;U>D&&!((!C||nt(U)==yt||U==A)&&ot(U,-1,!0));U--);return W=new t(U,0),{start:W,end:j}}function ta(h,g,y,w,C){function A(j){j.line!==null&&(j.pos+j.dir<0||j.pos+j.dir>=j.line.length?j.line=null:j.pos+=j.dir)}function D(j,U,nt,ot){var st=j.getLine(U),Y={line:st,ln:U,pos:nt,dir:ot};if(Y.line==="")return{ln:Y.ln,pos:Y.pos};var yt=Y.pos;for(A(Y);Y.line!==null;){if(yt=Y.pos,vt(Y.line[Y.pos]))if(C){for(A(Y);Y.line!==null&&rt(Y.line[Y.pos]);)yt=Y.pos,A(Y);return{ln:Y.ln,pos:yt+1}}else return{ln:Y.ln,pos:Y.pos+1};A(Y)}return{ln:Y.ln,pos:yt+1}}function z(j,U,nt,ot){var st=j.getLine(U),Y={line:st,ln:U,pos:nt,dir:ot};if(Y.line==="")return{ln:Y.ln,pos:Y.pos};var yt=Y.pos;for(A(Y);Y.line!==null;){if(!rt(Y.line[Y.pos])&&!vt(Y.line[Y.pos]))yt=Y.pos;else if(vt(Y.line[Y.pos]))return C?rt(Y.line[Y.pos+1])?{ln:Y.ln,pos:Y.pos+1}:{ln:Y.ln,pos:yt}:{ln:Y.ln,pos:yt};A(Y)}return Y.line=st,C&&rt(Y.line[Y.pos])?{ln:Y.ln,pos:Y.pos}:{ln:Y.ln,pos:yt}}for(var W={ln:g.line,pos:g.ch};y>0;)w<0?W=z(h,W.ln,W.pos,w):W=D(h,W.ln,W.pos,w),y--;return new t(W.ln,W.pos)}function sc(h,g,y,w){function C(W,j){if(j.line!==null)if(j.pos+j.dir<0||j.pos+j.dir>=j.line.length){if(j.ln+=j.dir,!q(W,j.ln)){j.line=null;return}j.line=W.getLine(j.ln),j.pos=j.dir>0?0:j.line.length-1}else j.pos+=j.dir}function A(W,j,U,nt){var kt=W.getLine(j),ot=kt==="",st={line:kt,ln:j,pos:U,dir:nt},Y={ln:st.ln,pos:st.pos},yt=st.line==="";for(C(W,st);st.line!==null;){if(Y.ln=st.ln,Y.pos=st.pos,st.line===""&&!yt)return{ln:st.ln,pos:st.pos};if(ot&&st.line!==""&&!rt(st.line[st.pos]))return{ln:st.ln,pos:st.pos};vt(st.line[st.pos])&&!ot&&(st.pos===st.line.length-1||rt(st.line[st.pos+1]))&&(ot=!0),C(W,st)}var kt=W.getLine(Y.ln);Y.pos=0;for(var Ut=kt.length-1;Ut>=0;--Ut)if(!rt(kt[Ut])){Y.pos=Ut;break}return Y}function D(W,j,U,nt){var kt=W.getLine(j),ot={line:kt,ln:j,pos:U,dir:nt},st=ot.ln,Y=null,yt=ot.line==="";for(C(W,ot);ot.line!==null;){if(ot.line===""&&!yt)return Y!==null?{ln:st,pos:Y}:{ln:ot.ln,pos:ot.pos};if(vt(ot.line[ot.pos])&&Y!==null&&!(ot.ln===st&&ot.pos+1===Y))return{ln:st,pos:Y};ot.line!==""&&!rt(ot.line[ot.pos])&&(yt=!1,st=ot.ln,Y=ot.pos),C(W,ot)}var kt=W.getLine(st);Y=0;for(var Ut=0;Ut<kt.length;++Ut)if(!rt(kt[Ut])){Y=Ut;break}return{ln:st,pos:Y}}for(var z={ln:g.line,pos:g.ch};y>0;)w<0?z=D(h,z.ln,z.pos,w):z=A(h,z.ln,z.pos,w),y--;return new t(z.ln,z.pos)}function Jo(h,g,y,w){var C=g,A={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/,"<":/[<>]/,">":/[<>]/}[y],D={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{","<":"<",">":"<"}[y],z=h.getLine(C.line).charAt(C.ch),W=z===D?1:0,j=h.scanForBracket(new t(C.line,C.ch+W),-1,void 0,{bracketRegex:A}),U=h.scanForBracket(new t(C.line,C.ch+W),1,void 0,{bracketRegex:A});if(!j||!U)return null;var nt=j.pos,ot=U.pos;if(nt.line==ot.line&&nt.ch>ot.ch||nt.line>ot.line){var st=nt;nt=ot,ot=st}return w?ot.ch+=1:nt.ch+=1,{start:nt,end:ot}}function Ao(h,g,y,w){var C=xe(g),A=h.getLine(C.line),D=A.split(""),z,W,j,U,nt=D.indexOf(y);if(C.ch<nt)C.ch=nt;else if(nt<C.ch&&D[C.ch]==y){var ot=/string/.test(h.getTokenTypeAt(De(g,0,1))),st=/string/.test(h.getTokenTypeAt(g)),Y=ot&&!st;Y||(W=C.ch,--C.ch)}if(D[C.ch]==y&&!W)z=C.ch+1;else for(j=C.ch;j>-1&&!z;j--)D[j]==y&&(z=j+1);if(z&&!W)for(j=z,U=D.length;j<U&&!W;j++)D[j]==y&&(W=j);return!z||!W?{start:C,end:C}:(w&&(--z,++W),{start:new t(C.line,z),end:new t(C.line,W)})}gt("pcre",!0,"boolean");class ea{constructor(){this.highlightTimeout}getQuery(){return ut.query}setQuery(g){ut.query=g}getOverlay(){return this.searchOverlay}setOverlay(g){this.searchOverlay=g}isReversed(){return ut.isReversed}setReversed(g){ut.isReversed=g}getScrollbarAnnotate(){return this.annotate}setScrollbarAnnotate(g){this.annotate=g}}function Ti(h){var g=h.state.vim;return g.searchState_||(g.searchState_=new ea)}function Lo(h){return Ee(h,"/")}function pe(h){return No(h,"/")}function Ee(h,g){var y=No(h,g)||[];if(!y.length)return[];var w=[];if(y[0]===0){for(var C=0;C<y.length;C++)typeof y[C]=="number"&&w.push(h.substring(y[C]+1,y[C+1]));return w}}function No(h,g){g||(g="/");for(var y=!1,w=[],C=0;C<h.length;C++){var A=h.charAt(C);!y&&A==g&&w.push(C),y=!y&&A=="\\"}return w}function lo(h){var g={V:"|(){+?*.[$^",M:"|(){+?*.[",m:"|(){+?",v:"<>"},y={">":"(?<=[\\w])(?=[^\\w]|$)","<":"(?<=[^\\w]|^)(?=[\\w])"},w=g.m,C=h.replace(/\\.|[\[|(){+*?.$^<>]/g,function(D){if(D[0]==="\\"){var z=D[1];return z==="}"||w.indexOf(z)!=-1?z:z in g?(w=g[z],""):z in y?y[z]:D}else return w.indexOf(D)!=-1?y[D]||"\\"+D:D}),A=C.indexOf("\\zs");return A!=-1&&(C="(?<="+C.slice(0,A)+")"+C.slice(A+3)),A=C.indexOf("\\ze"),A!=-1&&(C=C.slice(0,A)+"(?="+C.slice(A+3)+")"),C}var zn={"\\n":`
|
||
`,"\\r":"\r","\\t":" "};function Hs(h){for(var g=!1,y=[],w=-1;w<h.length;w++){var C=h.charAt(w)||"",A=h.charAt(w+1)||"";zn[C+A]?(y.push(zn[C+A]),w++):g?(y.push(C),g=!1):C==="\\"?(g=!0,tt(A)||A==="$"?y.push("$"):A!=="/"&&A!=="\\"&&y.push("\\")):(C==="$"&&y.push("$"),y.push(C),A==="/"&&y.push("\\"))}return y.join("")}var ne={"\\/":"/","\\\\":"\\","\\n":`
|
||
`,"\\r":"\r","\\t":" ","\\&":"&"};function Re(h){for(var g=new o.StringStream(h),y=[];!g.eol();){for(;g.peek()&&g.peek()!="\\";)y.push(g.next());var w=!1;for(var C in ne)if(g.match(C,!0)){w=!0,y.push(ne[C]);break}w||y.push(g.next())}return y.join("")}function Qo(h,g,y){var w=ut.registerController.getRegister("/");w.setText(h);var C=pe(h),A,D;if(!C.length)A=h;else{A=h.substring(0,C[0]);var z=h.substring(C[0]);D=z.indexOf("i")!=-1}if(!A)return null;St("pcre")||(A=lo(A)),y&&(g=/^[^A-Z]*$/.test(A));var W=new RegExp(A,g||D?"im":"m");return W}function ui(h){typeof h=="string"&&(h=document.createElement(h));for(var g=1;g<arguments.length;g++){var y=arguments[g];if(y)if(typeof y!="object"&&(y=document.createTextNode(y)),y.nodeType)h.appendChild(y);else for(var w in y)Object.prototype.hasOwnProperty.call(y,w)&&(w[0]==="$"?h.style[w.slice(1)]=y[w]:typeof y[w]=="function"?h[w]=y[w]:h.setAttribute(w,y[w]))}return h}function ie(h,g,y){var w=ui("div",{$color:"red",$whiteSpace:"pre",class:"cm-vim-message"},g);h.openNotification?y?(w=ui("div",{},w,ui("div",{},"Press ENTER or type command to continue")),h.state.closeVimNotification&&h.state.closeVimNotification(),h.state.closeVimNotification=h.openNotification(w,{bottom:!0,duration:0})):h.openNotification(w,{bottom:!0,duration:15e3}):alert(w.innerText)}function rc(h,g){return ui("div",{$display:"flex",$flex:1},ui("span",{$fontFamily:"monospace",$whiteSpace:"pre",$flex:1,$display:"flex"},h,ui("input",{type:"text",autocorrect:"off",autocapitalize:"off",spellcheck:"false",$flex:1})),g&&ui("span",{$color:"#888"},g))}function Fn(h,g){var y;if(At.length){g.value||(g.value=""),dt=g;return}var w=rc(g.prefix,g.desc);if(h.openDialog)h.openDialog(w,g.onClose,{onKeyDown:g.onKeyDown,onKeyUp:g.onKeyUp,bottom:!0,selectValueOnOpen:!1,value:g.value});else{var C="";typeof g.prefix!="string"&&g.prefix&&(C+=g.prefix.textContent),g.desc&&(C+=" "+g.desc),(y=g.onClose)==null||y.call(g,prompt(C,""))}}function Wn(h,g){return h instanceof RegExp&&g instanceof RegExp?h.flags==g.flags&&h.source==g.source:!1}function Ie(h,g,y,w){if(g){var C=Ti(h),A=Qo(g,!!y,!!w);if(A)return Vn(h,A),Wn(A,C.getQuery())||C.setQuery(A),A}}function Hn(h){if(h.source.charAt(0)=="^")var g=!0;return{token:function(y){if(g&&!y.sol()){y.skipToEnd();return}var w=y.match(h,!1);if(w)return w[0].length==0?(y.next(),"searching"):!y.sol()&&(y.backUp(1),!h.exec(y.next()+w[0]))?(y.next(),null):(y.match(h),"searching");for(;!y.eol()&&(y.next(),!y.match(h,!1)););},query:h}}var cn=0;function Vn(h,g){clearTimeout(cn);var y=Ti(h);y.highlightTimeout=cn,cn=setTimeout(function(){if(h.state.vim){var w=Ti(h);w.highlightTimeout=void 0;var C=w.getOverlay();(!C||g!=C.query)&&(C&&h.removeOverlay(C),C=Hn(g),h.addOverlay(C),h.showMatchesOnScrollbar&&(w.getScrollbarAnnotate()&&w.getScrollbarAnnotate().clear(),w.setScrollbarAnnotate(h.showMatchesOnScrollbar(g))),w.setOverlay(C))}},50)}function Xo(h,g,y,w){return h.operation(function(){w===void 0&&(w=1);for(var C=h.getCursor(),A=h.getSearchCursor(y,C),D=0;D<w;D++){var z=A.find(g);if(D==0&&z&&ei(A.from(),C)){var W=g?A.from():A.to();z=A.find(g),z&&!z[0]&&ei(A.from(),W)&&h.getLine(W.line).length==W.ch&&(z=A.find(g))}if(!z&&(A=h.getSearchCursor(y,g?new t(h.lastLine()):new t(h.firstLine(),0)),!A.find(g)))return}return A.from()})}function Mo(h,g,y,w,C){return h.operation(function(){w===void 0&&(w=1);var A=h.getCursor(),D=h.getSearchCursor(y,A),z=D.find(!g);!C.visualMode&&z&&ei(D.from(),A)&&D.find(!g);for(var W=0;W<w;W++)if(z=D.find(g),!z&&(D=h.getSearchCursor(y,g?new t(h.lastLine()):new t(h.firstLine(),0)),!D.find(g)))return;var j=D.from(),U=D.to();return j&&U&&[j,U]})}function bn(h){var g=Ti(h);g.highlightTimeout&&(clearTimeout(g.highlightTimeout),g.highlightTimeout=void 0),h.removeOverlay(Ti(h).getOverlay()),g.setOverlay(null),g.getScrollbarAnnotate()&&(g.getScrollbarAnnotate().clear(),g.setScrollbarAnnotate(null))}function Vs(h,g,y){return typeof h!="number"&&(h=h.line),g instanceof Array?Dt(h,g):typeof y=="number"?h>=g&&h<=y:h==g}function co(h){var g=h.getScrollInfo(),y=6,w=10,C=h.coordsChar({left:0,top:y+g.top},"local"),A=g.clientHeight-w+g.top,D=h.coordsChar({left:0,top:A},"local");return{top:C.line,bottom:D.line}}function ho(h,g,y){if(y=="'"||y=="`")return ut.jumpList.find(h,-1)||new t(0,0);if(y==".")return ts(h);var w=g.marks[y];return w&&w.find()}function ts(h){if(h.getLastEditEnd)return h.getLastEditEnd();for(var g=h.doc.history.done,y=g.length;y--;)if(g[y].changes)return xe(g[y].changes[0].to)}class es{constructor(){this.commandMap_,this.buildCommandMap_()}processCommand(g,y,w){var C=this;g.operation(function(){g.curOp&&(g.curOp.isVimOp=!0),C._processCommand(g,y,w)})}_processCommand(g,y,w){var C=g.state.vim,A=ut.registerController.getRegister(":"),D=A.toString(),z=new o.StringStream(y);A.setText(y);var W=w||{};W.input=y;try{this.parseInput_(g,z,W)}catch(nt){throw ie(g,nt+""),nt}C.visualMode&&zt(g);var j,U;if(!W.commandName)W.line!==void 0&&(U="move");else if(j=this.matchCommand_(W.commandName),j){if(U=j.name,j.excludeFromCommandHistory&&A.setText(D),this.parseCommandArgs_(z,W,j),j.type=="exToKey"){k(g,j.toKeys||"",j);return}else if(j.type=="exToEx"){this.processCommand(g,j.toInput||"");return}}if(!U){ie(g,'Not an editor command ":'+y+'"');return}try{Us[U](g,W),(!j||!j.possiblyAsync)&&W.callback&&W.callback()}catch(nt){throw ie(g,nt+""),nt}}parseInput_(g,y,w){var C,A;y.eatWhile(":"),y.eat("%")?(w.line=g.firstLine(),w.lineEnd=g.lastLine()):(w.line=this.parseLineSpec_(g,y),w.line!==void 0&&y.eat(",")&&(w.lineEnd=this.parseLineSpec_(g,y))),w.line==null?g.state.vim.visualMode?(w.selectionLine=(C=ho(g,g.state.vim,"<"))==null?void 0:C.line,w.selectionLineEnd=(A=ho(g,g.state.vim,">"))==null?void 0:A.line):w.selectionLine=g.getCursor().line:(w.selectionLine=w.line,w.selectionLineEnd=w.lineEnd);var D=y.match(/^(\w+|!!|@@|[!#&*<=>@~])/);return D?w.commandName=D[1]:w.commandName=(y.match(/.*/)||[""])[0],w}parseLineSpec_(g,y){var w=y.match(/^(\d+)/);if(w)return parseInt(w[1],10)-1;switch(y.next()){case".":return this.parseLineSpecOffset_(y,g.getCursor().line);case"$":return this.parseLineSpecOffset_(y,g.lastLine());case"'":var C=y.next()||"",A=ho(g,g.state.vim,C);if(!A)throw new Error("Mark not set");return this.parseLineSpecOffset_(y,A.line);case"-":case"+":return y.backUp(1),this.parseLineSpecOffset_(y,g.getCursor().line);default:y.backUp(1);return}}parseLineSpecOffset_(g,y){var w=g.match(/^([+-])?(\d+)/);if(w){var C=parseInt(w[2],10);w[1]=="-"?y-=C:y+=C}return y}parseCommandArgs_(g,y,w){var C;if(!g.eol()){y.argString=(C=g.match(/.*/))==null?void 0:C[0];var A=w.argDelimiter||/\s+/,D=Os(y.argString||"").split(A);D.length&&D[0]&&(y.args=D)}}matchCommand_(g){for(var y=g.length;y>0;y--){var w=g.substring(0,y);if(this.commandMap_[w]){var C=this.commandMap_[w];if(C.name.indexOf(g)===0)return C}}}buildCommandMap_(){this.commandMap_={};for(var g=0;g<a.length;g++){var y=a[g],w=y.shortName||y.name;this.commandMap_[w]=y}}map(g,y,w,C){if(g!=":"&&g.charAt(0)==":"){if(w)throw Error("Mode not supported for ex mappings");var A=g.substring(1);y!=":"&&y.charAt(0)==":"?this.commandMap_[A]={name:A,type:"exToEx",toInput:y.substring(1),user:!0}:this.commandMap_[A]={name:A,type:"exToKey",toKeys:y,user:!0}}else{var D={keys:g,type:"keyToKey",toKeys:y,noremap:!!C};w&&(D.context=w),Ei(D)}}unmap(g,y){if(g!=":"&&g.charAt(0)==":"){if(y)throw Error("Mode not supported for ex mappings");var w=g.substring(1);if(this.commandMap_[w]&&this.commandMap_[w].user)return delete this.commandMap_[w],!0}else for(var C=g,A=0;A<i.length;A++)if(C==i[A].keys&&i[A].context===y)return i.splice(A,1),ia(C),!0}}var Us={colorscheme:function(h,g){if(!g.args||g.args.length<1){ie(h,h.getOption("theme"));return}h.setOption("theme",g.args[0])},map:function(h,g,y,w){var C=g.args;if(!C||C.length<2){h&&ie(h,"Invalid mapping: "+g.input);return}ii.map(C[0],C[1],y,w)},imap:function(h,g){this.map(h,g,"insert")},nmap:function(h,g){this.map(h,g,"normal")},vmap:function(h,g){this.map(h,g,"visual")},omap:function(h,g){this.map(h,g,"operatorPending")},noremap:function(h,g){this.map(h,g,void 0,!0)},inoremap:function(h,g){this.map(h,g,"insert",!0)},nnoremap:function(h,g){this.map(h,g,"normal",!0)},vnoremap:function(h,g){this.map(h,g,"visual",!0)},onoremap:function(h,g){this.map(h,g,"operatorPending",!0)},unmap:function(h,g,y){var w=g.args;(!w||w.length<1||!ii.unmap(w[0],y))&&h&&ie(h,"No such mapping: "+g.input)},mapclear:function(h,g){mt.mapclear()},imapclear:function(h,g){mt.mapclear("insert")},nmapclear:function(h,g){mt.mapclear("normal")},vmapclear:function(h,g){mt.mapclear("visual")},omapclear:function(h,g){mt.mapclear("operatorPending")},move:function(h,g){qt.processCommand(h,h.state.vim,{keys:"",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:g.line+1})},set:function(h,g){var y=g.args,w=g.setCfg||{};if(!y||y.length<1){h&&ie(h,"Invalid mapping: "+g.input);return}var C=y[0].split("="),A=C.shift()||"",D=C.length>0?C.join("="):void 0,z=!1,W=!1;if(A.charAt(A.length-1)=="?"){if(D)throw Error("Trailing characters: "+g.argString);A=A.substring(0,A.length-1),z=!0}else A.charAt(A.length-1)=="!"&&(A=A.substring(0,A.length-1),W=!0);D===void 0&&A.substring(0,2)=="no"&&(A=A.substring(2),D=!1);var j=jt[A]&&jt[A].type=="boolean";if(j&&(W?D=!St(A,h,w):D==null&&(D=!0)),!j&&D===void 0||z){var U=St(A,h,w);U instanceof Error?ie(h,U.message):U===!0||U===!1?ie(h," "+(U?"":"no")+A):ie(h," "+A+"="+U)}else{var nt=Ct(A,D,h,w);nt instanceof Error&&ie(h,nt.message)}},setlocal:function(h,g){g.setCfg={scope:"local"},this.set(h,g)},setglobal:function(h,g){g.setCfg={scope:"global"},this.set(h,g)},registers:function(h,g){var y=g.args,w=ut.registerController.registers,C=`----------Registers----------
|
||
|
||
`;if(y)for(var A=y.join(""),D=0;D<A.length;D++){var z=A.charAt(D);if(ut.registerController.isValidRegister(z)){var W=w[z]||new $t;C+='"'+z+" "+W.toString()+`
|
||
`}}else for(var z in w){var j=w[z].toString();j.length&&(C+='"'+z+" "+j+`
|
||
`)}ie(h,C,!0)},marks:function(h,g){var y=g.args,w=h.state.vim.marks,C=`-----------Marks-----------
|
||
mark line col
|
||
|
||
`;if(y)for(var A=y.join(""),D=0;D<A.length;D++){var z=A.charAt(D),W=w[z]&&w[z].find();W&&(C+=z+" "+W.line+" "+W.ch+`
|
||
`)}else for(var z in w){var W=w[z]&&w[z].find();W&&(C+=z+" "+W.line+" "+W.ch+`
|
||
`)}ie(h,C,!0)},sort:function(h,g){var y,w,C,A,D;function z(){if(g.argString){var he=new o.StringStream(g.argString);if(he.eat("!")&&(y=!0),he.eol())return;if(!he.eatSpace())return"Invalid arguments";var Xt=he.match(/([dinuox]+)?\s*(\/.+\/)?\s*/);if(!Xt||!he.eol())return"Invalid arguments";if(Xt[1]){w=Xt[1].indexOf("i")!=-1,C=Xt[1].indexOf("u")!=-1;var we=Xt[1].indexOf("d")!=-1||Xt[1].indexOf("n")!=-1,Ii=Xt[1].indexOf("x")!=-1,Ke=Xt[1].indexOf("o")!=-1;if(Number(we)+Number(Ii)+Number(Ke)>1)return"Invalid arguments";A=we&&"decimal"||Ii&&"hex"||Ke&&"octal"}Xt[2]&&(D=new RegExp(Xt[2].substr(1,Xt[2].length-2),w?"i":""))}}var W=z();if(W){ie(h,W+": "+g.argString);return}var j=g.line||h.firstLine(),U=g.lineEnd||g.line||h.lastLine();if(j==U)return;var nt=new t(j,0),ot=new t(U,Ye(h,U)),st=h.getRange(nt,ot).split(`
|
||
`),Y=A=="decimal"?/(-?)([\d]+)/:A=="hex"?/(-?)(?:0x)?([0-9a-f]+)/i:A=="octal"?/([0-7]+)/:null,yt=A=="decimal"?10:A=="hex"?16:A=="octal"?8:void 0,kt=[],Ut=[];if(A||D)for(var Lt=0;Lt<st.length;Lt++){var ee=D?st[Lt].match(D):null;ee&&ee[0]!=""?kt.push(ee):Y&&Y.exec(st[Lt])?kt.push(st[Lt]):Ut.push(st[Lt])}else Ut=st;function oe(he,Xt){if(y){var we;we=he,he=Xt,Xt=we}w&&(he=he.toLowerCase(),Xt=Xt.toLowerCase());var Ii=Y&&Y.exec(he),Ke=Y&&Y.exec(Xt);if(!Ii||!Ke)return he<Xt?-1:1;var wi=parseInt((Ii[1]+Ii[2]).toLowerCase(),yt),ji=parseInt((Ke[1]+Ke[2]).toLowerCase(),yt);return wi-ji}function se(he,Xt){if(y){var we;we=he,he=Xt,Xt=we}return w&&(he[0]=he[0].toLowerCase(),Xt[0]=Xt[0].toLowerCase()),he[0]<Xt[0]?-1:1}if(kt.sort(D?se:oe),D)for(var Lt=0;Lt<kt.length;Lt++)kt[Lt]=kt[Lt].input;else A||Ut.sort(oe);if(st=y?kt.concat(Ut):Ut.concat(kt),C){var $e=st,Ae;st=[];for(var Lt=0;Lt<$e.length;Lt++)$e[Lt]!=Ae&&st.push($e[Lt]),Ae=$e[Lt]}h.replaceRange(st.join(`
|
||
`),nt,ot)},vglobal:function(h,g){this.global(h,g)},normal:function(h,g){var y=!1,w=g.argString;if(w&&w[0]=="!"&&(w=w.slice(1),y=!0),w=w.trimStart(),!w){ie(h,"Argument is required.");return}var C=g.line;if(typeof C=="number")for(var A=isNaN(g.lineEnd)?C:g.lineEnd,D=C;D<=A;D++)h.setCursor(D,0),k(h,g.argString.trimStart(),{noremap:y}),h.state.vim.insertMode&&Gt(h,!0);else k(h,g.argString.trimStart(),{noremap:y}),h.state.vim.insertMode&&Gt(h,!0)},global:function(h,g){var y=g.argString;if(!y){ie(h,"Regular Expression missing from global");return}var w=g.commandName[0]==="v";y[0]==="!"&&g.commandName[0]==="g"&&(w=!0,y=y.slice(1));var C=g.line!==void 0?g.line:h.firstLine(),A=g.lineEnd||g.line||h.lastLine(),D=Lo(y),z=y,W="";if(D&&D.length&&(z=D[0],W=D.slice(1,D.length).join("/")),z)try{Ie(h,z,!0,!0)}catch{ie(h,"Invalid regex: "+z);return}for(var j=Ti(h).getQuery(),U=[],nt=C;nt<=A;nt++){var ot=h.getLine(nt),st=j.test(ot);st!==w&&U.push(W?h.getLineHandle(nt):ot)}if(!W){ie(h,U.join(`
|
||
`));return}var Y=0,yt=function(){if(Y<U.length){var kt=U[Y++],Ut=h.getLineNumber(kt);if(Ut==null){yt();return}var Lt=Ut+1+W;ii.processCommand(h,Lt,{callback:yt})}else h.releaseLineHandles&&h.releaseLineHandles()};yt()},substitute:function(h,g){if(!h.getSearchCursor)throw new Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var y=g.argString,w=y?Ee(y,y[0]):[],C="",A="",D,z,W,j=!1,U=!1;if(w&&w.length)C=w[0],St("pcre")&&C!==""&&(C=new RegExp(C).source),A=w[1],A!==void 0&&(St("pcre")?A=Re(A.replace(/([^\\])&/g,"$1$$&")):A=Hs(A),ut.lastSubstituteReplacePart=A),D=w[2]?w[2].split(" "):[];else if(y&&y.length){ie(h,"Substitutions should be of the form :s/pattern/replace/");return}if(D&&(z=D[0],W=parseInt(D[1]),z&&(z.indexOf("c")!=-1&&(j=!0),z.indexOf("g")!=-1&&(U=!0),St("pcre")?C=C+"/"+z:C=C.replace(/\//g,"\\/")+"/"+z)),C)try{Ie(h,C,!0,!0)}catch{ie(h,"Invalid regex: "+C);return}if(A=A||ut.lastSubstituteReplacePart,A===void 0){ie(h,"No previous substitute regular expression");return}var nt=Ti(h),ot=nt.getQuery(),st=g.line!==void 0?g.line:h.getCursor().line,Y=g.lineEnd||st;st==h.firstLine()&&Y==h.lastLine()&&(Y=1/0),W&&(st=Y,Y=st+W-1);var yt=oi(h,new t(st,0)),kt=h.getSearchCursor(ot,yt);ac(h,j,U,st,Y,kt,ot,A,g.callback)},startinsert:function(h,g){k(h,g.argString=="!"?"A":"i",{})},redo:o.commands.redo,undo:o.commands.undo,write:function(h){o.commands.save?o.commands.save(h):h.save&&h.save()},nohlsearch:function(h){bn(h)},yank:function(h){var g=xe(h.getCursor()),y=g.line,w=h.getLine(y);ut.registerController.pushText("0","yank",w,!0,!0)},delete:function(h,g){var y=g.selectionLine,w=isNaN(g.selectionLineEnd)?y:g.selectionLineEnd;_e.delete(h,{linewise:!0},[{anchor:new t(y,0),head:new t(w+1,0)}])},join:function(h,g){var y=g.selectionLine,w=isNaN(g.selectionLineEnd)?y:g.selectionLineEnd;h.setCursor(new t(y,0)),Si.joinLines(h,{repeat:w-y},h.state.vim)},delmarks:function(h,g){if(!g.argString||!Os(g.argString)){ie(h,"Argument required");return}for(var y=h.state.vim,w=new o.StringStream(Os(g.argString));!w.eol();){w.eatSpace();var C=w.pos;if(!w.match(/[a-zA-Z]/,!1)){ie(h,"Invalid argument: "+g.argString.substring(C));return}var A=w.next();if(w.match("-",!0)){if(!w.match(/[a-zA-Z]/,!1)){ie(h,"Invalid argument: "+g.argString.substring(C));return}var D=A,z=w.next();if(D&&z&&H(D)==H(z)){var W=D.charCodeAt(0),j=z.charCodeAt(0);if(W>=j){ie(h,"Invalid argument: "+g.argString.substring(C));return}for(var U=0;U<=j-W;U++){var nt=String.fromCharCode(W+U);delete y.marks[nt]}}else{ie(h,"Invalid argument: "+D+"-");return}}else A&&delete y.marks[A]}}},ii=new es;mt.defineEx("version","ve",h=>{ie(h,"Codemirror-vim version: 6.3.0")});function ac(h,g,y,w,C,A,D,z,W){h.state.vim.exMode=!0;var j=!1,U=0,nt,ot,st;function Y(){h.operation(function(){for(;!j;)yt(),Ut();Lt()})}function yt(){var oe="",se=A.match||A.pos&&A.pos.match;if(se)oe=z.replace(/\$(\d{1,3}|[$&])/g,function(he,Xt){if(Xt=="$")return"$";if(Xt=="&")return se[0];for(var we=Xt;parseInt(we)>=se.length&&we.length>0;)we=we.slice(0,we.length-1);return we?se[we]+Xt.slice(we.length,Xt.length):he});else{var $e=h.getRange(A.from(),A.to());oe=$e.replace(D,z)}var Ae=A.to().line;A.replace(oe),ot=A.to().line,C+=ot-Ae,st=ot<Ae}function kt(){var oe=nt&&xe(A.to()),se=A.findNext();return se&&!se[0]&&oe&&ei(A.from(),oe)&&(se=A.findNext()),se&&U++,se}function Ut(){for(;kt()&&Vs(A.from(),w,C);)if(!(!y&&A.from().line==ot&&!st)){h.scrollIntoView(A.from(),30),h.setSelection(A.from(),A.to()),nt=A.from(),j=!1;return}j=!0}function Lt(oe){if(oe&&oe(),h.focus(),nt){h.setCursor(nt);var se=h.state.vim;se.exMode=!1,se.lastHPos=se.lastHSPos=nt.ch}W?W():j&&ie(h,(U?"Found "+U+" matches":"No matches found")+" for pattern: "+D+(St("pcre")?" (set nopcre to use Vim regexps)":""))}function ee(oe,se,$e){o.e_stop(oe);var Ae=B(oe);switch(Ae){case"y":yt(),Ut();break;case"n":Ut();break;case"a":var he=W;W=void 0,h.operation(Y),W=he;break;case"l":yt();case"q":case"<Esc>":case"<C-c>":case"<C-[>":Lt($e);break}return j&&Lt($e),!0}if(Ut(),j){ie(h,"No matches for "+D+(St("pcre")?" (set nopcre to use vim regexps)":""));return}if(!g){Y(),W&&W();return}Fn(h,{prefix:ui("span","replace with ",ui("strong",z)," (y/n/a/q/l)"),onKeyDown:ee})}function Gt(h,g){var y=h.state.vim,w=ut.macroModeState,C=ut.registerController.getRegister("."),A=w.isPlaying,D=w.lastInsertModeChanges;A||(h.off("change",uo),y.insertEnd&&y.insertEnd.clear(),y.insertEnd=void 0,o.off(h.getInputField(),"keydown",Gs)),!A&&y.insertModeRepeat&&y.insertModeRepeat>1&&(Ys(h,y,y.insertModeRepeat-1,!0),y.lastEditInputState.repeatOverride=y.insertModeRepeat),delete y.insertModeRepeat,y.insertMode=!1,g||h.setCursor(h.getCursor().line,h.getCursor().ch-1),h.setOption("keyMap","vim"),h.setOption("disableInput",!0),h.toggleOverwrite(!1),C.setText(D.changes.join("")),o.signal(h,"vim-mode-change",{mode:"normal"}),w.isRecording&&Un(w)}function Ei(h){i.unshift(h),h.keys&&ke(h.keys)}function ke(h){h.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(g){g&&(n[g]||(n[g]=0),n[g]++)})}function ia(h){h.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(g){n[g]&&n[g]--})}function js(h,g,y,w,C){var A={keys:h,type:g};A[g]=y,A[g+"Args"]=w;for(var D in C)A[D]=C[D];Ei(A)}gt("insertModeEscKeysTimeout",200,"number");function qs(h,g,y,w){var C=ut.registerController.getRegister(w);if(w==":"){C.keyBuffer[0]&&ii.processCommand(h,C.keyBuffer[0]),y.isPlaying=!1;return}var A=C.keyBuffer,D=0;y.isPlaying=!0,y.replaySearchQueries=C.searchQueries.slice(0);for(var z=0;z<A.length;z++)for(var W=A[z],j,U,nt=/<(?:[CSMA]-)*\w+>|./gi;j=nt.exec(W);)if(U=j[0],mt.handleKey(h,U,"macro"),g.insertMode){var ot=C.insertModeChanges[D++].changes;ut.macroModeState.lastInsertModeChanges.changes=ot,Js(h,ot,1),Gt(h)}y.isPlaying=!1}function Ks(h,g){if(!h.isPlaying){var y=h.latestRegister,w=ut.registerController.getRegister(y);w&&w.pushText(g)}}function Un(h){if(!h.isPlaying){var g=h.latestRegister,y=ut.registerController.getRegister(g);y&&y.pushInsertModeChanges&&y.pushInsertModeChanges(h.lastInsertModeChanges)}}function Zs(h,g){if(!h.isPlaying){var y=h.latestRegister,w=ut.registerController.getRegister(y);w&&w.pushSearchQuery&&w.pushSearchQuery(g)}}function uo(h,g){var y=ut.macroModeState,w=y.lastInsertModeChanges;if(!y.isPlaying)for(var C=h.state.vim;g;){if(w.expectCursorActivityForChange=!0,w.ignoreCount>1)w.ignoreCount--;else if(g.origin=="+input"||g.origin=="paste"||g.origin===void 0){var A=h.listSelections().length;A>1&&(w.ignoreCount=A);var D=g.text.join(`
|
||
`);if(w.maybeReset&&(w.changes=[],w.maybeReset=!1),D)if(h.state.overwrite&&!/\n/.test(D))w.changes.push([D]);else{if(D.length>1){var z=C&&C.insertEnd&&C.insertEnd.find(),W=h.getCursor();if(z&&z.line==W.line){var j=z.ch-W.ch;j>0&&j<D.length&&(w.changes.push([D,j]),D="")}}D&&w.changes.push(D)}}g=g.next}}function qe(h){var g,y=h.state.vim;if(y.insertMode){var w=ut.macroModeState;if(w.isPlaying)return;var C=w.lastInsertModeChanges;C.expectCursorActivityForChange?C.expectCursorActivityForChange=!1:(C.maybeReset=!0,y.insertEnd&&y.insertEnd.clear(),y.insertEnd=h.setBookmark(h.getCursor(),{insertLeft:!0}))}else(g=h.curOp)!=null&&g.isVimOp||wn(h,y)}function wn(h,g){var y=h.getCursor("anchor"),w=h.getCursor("head");if(g.visualMode&&!h.somethingSelected()?zt(h,!1):!g.visualMode&&!g.insertMode&&h.somethingSelected()&&(g.visualMode=!0,g.visualLine=!1,o.signal(h,"vim-mode-change",{mode:"visual"})),g.visualMode){var C=Oe(w,y)?0:-1,A=Oe(w,y)?-1:0;w=De(w,0,C),y=De(y,0,A),g.sel={anchor:y,head:w},ln(h,g,"<",si(w,y)),ln(h,g,">",an(w,y))}else g.insertMode||(g.lastHPos=h.getCursor().ch)}function Gs(h){var g=ut.macroModeState,y=g.lastInsertModeChanges,w=o.keyName?o.keyName(h):h.key;w&&(w.indexOf("Delete")!=-1||w.indexOf("Backspace")!=-1)&&(y.maybeReset&&(y.changes=[],y.maybeReset=!1),y.changes.push(new ht(w,h)))}function Ys(h,g,y,w){var C=ut.macroModeState;C.isPlaying=!0;var A=g.lastEditActionCommand,D=g.inputState;function z(){A?qt.processAction(h,g,A):qt.evalInput(h,g)}function W(U){if(C.lastInsertModeChanges.changes.length>0){U=g.lastEditActionCommand?U:1;var nt=C.lastInsertModeChanges;Js(h,nt.changes,U)}}if(g.inputState=g.lastEditInputState,A&&A.interlaceInsertRepeat)for(var j=0;j<y;j++)z(),W(1);else w||z(),W(y);g.inputState=D,g.insertMode&&!w&&Gt(h),C.isPlaying=!1}function na(h,g){o.lookupKey(g,"vim-insert",function(y){return typeof y=="string"?o.commands[y](h):y(h),!0})}function Js(h,g,y){var w=h.getCursor("head"),C=ut.macroModeState.lastInsertModeChanges.visualBlock;C&&(qr(h,w,C+1),y=h.listSelections().length,h.setCursor(w));for(var A=0;A<y;A++){C&&h.setCursor(De(w,A,0));for(var D=0;D<g.length;D++){var z=g[D];if(z instanceof ht)na(h,z.keyName);else if(typeof z=="string")h.replaceSelection(z);else{var W=h.getCursor(),j=De(W,0,z[0].length-(z[1]||0));h.replaceRange(z[0],W,z[1]?W:j),h.setCursor(j)}}}C&&h.setCursor(De(w,0,1))}function Po(h){var g=new h.constructor;return Object.keys(h).forEach(function(y){if(y!="insertEnd"){var w=h[y];Array.isArray(w)?w=w.slice():w&&typeof w=="object"&&w.constructor!=Object&&(w=Po(w)),g[y]=w}}),h.sel&&(g.sel={head:h.sel.head&&xe(h.sel.head),anchor:h.sel.anchor&&xe(h.sel.anchor)}),g}function lc(h,g,y){var A=te(h),w=h,C=!1,A=mt.maybeInitVimState_(w),D=A.visualBlock||A.wasInVisualBlock;if(w.state.closeVimNotification){var z=w.state.closeVimNotification;if(w.state.closeVimNotification=null,z(),g=="<CR>")return X(w),!0}var W=w.isInMultiSelectMode();if(A.wasInVisualBlock&&!W?A.wasInVisualBlock=!1:W&&A.visualBlock&&(A.wasInVisualBlock=!0),g=="<Esc>"&&!A.insertMode&&!A.visualMode&&W&&A.status=="<Esc>")X(w);else if(D||!W||w.inVirtualSelectionMode)C=mt.handleKey(w,g,y);else{var j=Po(A),U=A.inputState.changeQueueList||[];w.operation(function(){var nt;w.curOp&&(w.curOp.isVimOp=!0);var ot=0;w.forEachSelection(function(){w.state.vim.inputState.changeQueue=U[ot];var st=w.getCursor("head"),Y=w.getCursor("anchor"),yt=Oe(st,Y)?0:-1,kt=Oe(st,Y)?-1:0;st=De(st,0,yt),Y=De(Y,0,kt),w.state.vim.sel.head=st,w.state.vim.sel.anchor=Y,C=mt.handleKey(w,g,y),w.virtualSelection&&(U[ot]=w.state.vim.inputState.changeQueue,w.state.vim=Po(j)),ot++}),(nt=w.curOp)!=null&&nt.cursorActivity&&!C&&(w.curOp.cursorActivity=!1),w.state.vim=A,A.inputState.changeQueueList=U,A.inputState.changeQueue=null},!0)}return C&&!A.visualMode&&!A.insertMode&&A.visualMode!=w.somethingSelected()&&wn(w,A),C}return bt(),mt}function Di(o,t){var e=t.ch,i=t.line+1;i<1&&(i=1,e=0),i>o.lines&&(i=o.lines,e=Number.MAX_VALUE);var n=o.line(i);return Math.min(n.from+Math.max(0,e),n.to)}function Zi(o,t){let e=o.lineAt(t);return{line:e.number-1,ch:t-e.from}}class Sn{constructor(t,e){this.line=t,this.ch=e}}function kv(o,t,e){if(o.addEventListener)o.addEventListener(t,e,!1);else{var i=o._handlers||(o._handlers={});i[t]=(i[t]||[]).concat(e)}}function Cv(o,t,e){if(o.removeEventListener)o.removeEventListener(t,e,!1);else{var i=o._handlers,n=i&&i[t];if(n){var s=n.indexOf(e);s>-1&&(i[t]=n.slice(0,s).concat(n.slice(s+1)))}}}function $v(o,t,...e){var i,n=(i=o._handlers)===null||i===void 0?void 0:i[t];if(n)for(var s=0;s<n.length;++s)n[s](...e)}function of(o,...t){if(o)for(var e=0;e<o.length;++e)o[e](...t)}let Vd;try{Vd=new RegExp("[\\w\\p{Alphabetic}\\p{Number}_]","u")}catch{Vd=/[\w]/}function mr(o,t){var e=o.cm6;if(!e.state.readOnly){var i="input.type.compose";if(o.curOp&&(o.curOp.lastChange||(i="input.type.compose.start")),t.annotations)try{t.annotations.some(function(n){n.value=="input"&&(n.value=i)})}catch(n){console.error(n)}else t.userEvent=i;return e.dispatch(t)}}function sf(o,t){var e;o.curOp&&(o.curOp.$changeStart=void 0),(t?Eh:kl)(o.cm6);let i=(e=o.curOp)===null||e===void 0?void 0:e.$changeStart;i!=null&&o.cm6.dispatch({selection:{anchor:i}})}var VC={Left:o=>cs(o.cm6,{key:"Left"},"editor"),Right:o=>cs(o.cm6,{key:"Right"},"editor"),Up:o=>cs(o.cm6,{key:"Up"},"editor"),Down:o=>cs(o.cm6,{key:"Down"},"editor"),Backspace:o=>cs(o.cm6,{key:"Backspace"},"editor"),Delete:o=>cs(o.cm6,{key:"Delete"},"editor")};let ce=class Sv{openDialog(t,e,i){return jC(this,t,e,i)}openNotification(t,e){return UC(this,t,e)}constructor(t){this.state={},this.marks=Object.create(null),this.$mid=0,this.options={},this._handlers={},this.$lastChangeEndOffset=0,this.virtualSelection=null,this.cm6=t,this.onChange=this.onChange.bind(this),this.onSelectionChange=this.onSelectionChange.bind(this)}on(t,e){kv(this,t,e)}off(t,e){Cv(this,t,e)}signal(t,e,i){$v(this,t,e,i)}indexFromPos(t){return Di(this.cm6.state.doc,t)}posFromIndex(t){return Zi(this.cm6.state.doc,t)}foldCode(t){let e=this.cm6,i=e.state.selection.ranges,n=this.cm6.state.doc,s=Di(n,t),a=xt.create([xt.range(s,s)],0).ranges;e.state.selection.ranges=a,K0(e),e.state.selection.ranges=i}firstLine(){return 0}lastLine(){return this.cm6.state.doc.lines-1}lineCount(){return this.cm6.state.doc.lines}setCursor(t,e){typeof t=="object"&&(e=t.ch,t=t.line);var i=Di(this.cm6.state.doc,{line:t,ch:e||0});this.cm6.dispatch({selection:{anchor:i}},{scrollIntoView:!this.curOp}),this.curOp&&!this.curOp.isVimOp&&this.onBeforeEndOperation()}getCursor(t){var e=this.cm6.state.selection.main,i=t=="head"||!t?e.head:t=="anchor"?e.anchor:t=="start"?e.from:t=="end"?e.to:null;if(i==null)throw new Error("Invalid cursor type");return this.posFromIndex(i)}listSelections(){var t=this.cm6.state.doc;return this.cm6.state.selection.ranges.map(e=>({anchor:Zi(t,e.anchor),head:Zi(t,e.head)}))}setSelections(t,e){var i=this.cm6.state.doc,n=t.map(s=>{var a=Di(i,s.head),l=Di(i,s.anchor);return a==l?xt.cursor(a,1):xt.range(l,a)});this.cm6.dispatch({selection:xt.create(n,e)})}setSelection(t,e,i){this.setSelections([{anchor:t,head:e}],0),i&&i.origin=="*mouse"&&this.onBeforeEndOperation()}getLine(t){var e=this.cm6.state.doc;return t<0||t>=e.lines?"":this.cm6.state.doc.line(t+1).text}getLineHandle(t){return this.$lineHandleChanges||(this.$lineHandleChanges=[]),{row:t,index:this.indexFromPos(new Sn(t,0))}}getLineNumber(t){var e=this.$lineHandleChanges;if(!e)return null;for(var i=t.index,n=0;n<e.length;n++)if(i=e[n].changes.mapPos(i,1,mi.TrackAfter),i==null)return null;var s=this.posFromIndex(i);return s.ch==0?s.line:null}releaseLineHandles(){this.$lineHandleChanges=void 0}getRange(t,e){var i=this.cm6.state.doc;return this.cm6.state.sliceDoc(Di(i,t),Di(i,e))}replaceRange(t,e,i,n){i||(i=e);var s=this.cm6.state.doc,a=Di(s,e),l=Di(s,i);mr(this,{changes:{from:a,to:l,insert:t}})}replaceSelection(t){mr(this,this.cm6.state.replaceSelection(t))}replaceSelections(t){var e=this.cm6.state.selection.ranges,i=e.map((n,s)=>({from:n.from,to:n.to,insert:t[s]||""}));mr(this,{changes:i})}getSelection(){return this.getSelections().join(`
|
||
`)}getSelections(){var t=this.cm6;return t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to))}somethingSelected(){return this.cm6.state.selection.ranges.some(t=>!t.empty)}getInputField(){return this.cm6.contentDOM}clipPos(t){var e=this.cm6.state.doc,i=t.ch,n=t.line+1;n<1&&(n=1,i=0),n>e.lines&&(n=e.lines,i=Number.MAX_VALUE);var s=e.line(n);return i=Math.min(Math.max(0,i),s.to-s.from),new Sn(n-1,i)}getValue(){return this.cm6.state.doc.toString()}setValue(t){var e=this.cm6;return e.dispatch({changes:{from:0,to:e.state.doc.length,insert:t},selection:xt.range(0,0)})}focus(){return this.cm6.focus()}blur(){return this.cm6.contentDOM.blur()}defaultTextHeight(){return this.cm6.defaultLineHeight}findMatchingBracket(t,e){var i=this.cm6.state,n=Di(i.doc,t),s=Xi(i,n+1,-1);return s&&s.end?{to:Zi(i.doc,s.end.from)}:(s=Xi(i,n,1),s&&s.end?{to:Zi(i.doc,s.end.from)}:{to:void 0})}scanForBracket(t,e,i,n){return ZC(this,t,e,i,n)}indentLine(t,e){e?this.indentMore():this.indentLess()}indentMore(){ql(this.cm6)}indentLess(){Nh(this.cm6)}execCommand(t){if(t=="indentAuto")Sv.commands.indentAuto(this);else if(t=="goLineLeft")nv(this.cm6);else if(t=="goLineRight"){iv(this.cm6);let e=this.cm6.state,i=e.selection.main.head;i<e.doc.length&&e.sliceDoc(i,i+1)!==`
|
||
`&&zk(this.cm6)}else console.log(t+" is not implemented")}setBookmark(t,e){var i=e!=null&&e.insertLeft?1:-1,n=this.indexFromPos(t),s=new JC(this,n,i);return s}addOverlay({query:t}){let e=new RC({regexp:!0,search:t.source,caseSensitive:!/i/.test(t.flags)});if(e.valid){e.forVim=!0,this.cm6Query=e;let i=Hd.of(e);return this.cm6.dispatch({effects:i}),e}}removeOverlay(t){if(!this.cm6Query)return;this.cm6Query.forVim=!1;let e=Hd.of(this.cm6Query);this.cm6.dispatch({effects:e})}getSearchCursor(t,e){var i=this,n=null,s=null,a=!1;e.ch==null&&(e.ch=Number.MAX_VALUE);var l=Di(i.cm6.state.doc,e),c=t.source.replace(/(\\.|{(?:\d+(?:,\d*)?|,\d+)})|[{}]/g,function(T,M){return M||"\\"+T});function u(T,M=0,P=T.length){return new Oh(T,c,{ignoreCase:t.ignoreCase},M,P)}function p(T){var M=i.cm6.state.doc;if(T>M.length)return null;let P=u(M,T).next();return P.done?null:P.value}var v=1e4;function x(T,M){var P=i.cm6.state.doc;for(let F=1;;F++){let R=Math.max(T,M-F*v),q=u(P,R,M),H=null;for(;!q.next().done;)H=q.value;if(H&&(R==T||H.from>R+10))return H;if(R==T)return null}}return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(T){var M=i.cm6.state.doc;if(T){let P=n?a?n.to-1:n.from:l;n=x(0,P)}else{let P=n?a?n.to+1:n.to:l;n=p(P)}return s=n&&{from:Zi(M,n.from),to:Zi(M,n.to),match:n.match},a=n?n.from==n.to:!1,n&&n.match},from:function(){return s?.from},to:function(){return s?.to},replace:function(T){n&&(mr(i,{changes:{from:n.from,to:n.to,insert:T}}),n.to=n.from+T.length,s&&(s.to=Zi(i.cm6.state.doc,n.to)))},get match(){return s&&s.match}}}findPosV(t,e,i,n){let{cm6:s}=this;const a=s.state.doc;let l=i=="page"?s.dom.clientHeight:0;const c=Di(a,t);let u=xt.cursor(c,1,void 0,n),p=Math.round(Math.abs(e));for(let x=0;x<p;x++)i=="page"?u=s.moveVertically(u,e>0,l):i=="line"&&(u=s.moveVertically(u,e>0));let v=Zi(a,u.head);return(e<0&&u.head==0&&n!=0&&t.line==0&&t.ch!=0||e>0&&u.head==a.length&&v.ch!=n&&t.line==v.line)&&(v.hitSide=!0),v}charCoords(t,e){var i=this.cm6.contentDOM.getBoundingClientRect(),n=Di(this.cm6.state.doc,t),s=this.cm6.coordsAtPos(n),a=-i.top;return{left:(s?.left||0)-i.left,top:(s?.top||0)+a,bottom:(s?.bottom||0)+a}}coordsChar(t,e){var i=this.cm6.contentDOM.getBoundingClientRect(),n=this.cm6.posAtCoords({x:t.left+i.left,y:t.top+i.top})||0;return Zi(this.cm6.state.doc,n)}getScrollInfo(){var t=this.cm6.scrollDOM;return{left:t.scrollLeft,top:t.scrollTop,height:t.scrollHeight,width:t.scrollWidth,clientHeight:t.clientHeight,clientWidth:t.clientWidth}}scrollTo(t,e){t!=null&&(this.cm6.scrollDOM.scrollLeft=t),e!=null&&(this.cm6.scrollDOM.scrollTop=e)}scrollIntoView(t,e){if(t){var i=this.indexFromPos(t);this.cm6.dispatch({effects:Wt.scrollIntoView(i)})}else this.cm6.dispatch({scrollIntoView:!0,userEvent:"scroll"})}getWrapperElement(){return this.cm6.dom}getMode(){return{name:this.getOption("mode")}}setSize(t,e){this.cm6.dom.style.width=t+4+"px",this.cm6.dom.style.height=e+"px",this.refresh()}refresh(){this.cm6.measure()}destroy(){this.removeOverlay()}getLastEditEnd(){return this.posFromIndex(this.$lastChangeEndOffset)}onChange(t){this.$lineHandleChanges&&this.$lineHandleChanges.push(t);for(let i in this.marks)this.marks[i].update(t.changes);this.virtualSelection&&(this.virtualSelection.ranges=this.virtualSelection.ranges.map(i=>i.map(t.changes)));var e=this.curOp=this.curOp||{};t.changes.iterChanges((i,n,s,a,l)=>{(e.$changeStart==null||e.$changeStart>s)&&(e.$changeStart=s),this.$lastChangeEndOffset=a;var c={text:l.toJSON()};e.lastChange?e.lastChange.next=e.lastChange=c:e.lastChange=e.change=c},!0),e.changeHandlers||(e.changeHandlers=this._handlers.change&&this._handlers.change.slice())}onSelectionChange(){var t=this.curOp=this.curOp||{};t.cursorActivityHandlers||(t.cursorActivityHandlers=this._handlers.cursorActivity&&this._handlers.cursorActivity.slice()),this.curOp.cursorActivity=!0}operation(t,e){this.curOp||(this.curOp={$d:0}),this.curOp.$d++;try{var i=t()}finally{this.curOp&&(this.curOp.$d--,this.curOp.$d||this.onBeforeEndOperation())}return i}onBeforeEndOperation(){var t=this.curOp,e=!1;t&&(t.change&&of(t.changeHandlers,this,t.change),t&&t.cursorActivity&&(of(t.cursorActivityHandlers,this,null),t.isVimOp&&(e=!0)),this.curOp=null),e&&this.scrollIntoView()}moveH(t,e){if(e=="char"){var i=this.getCursor();this.setCursor(i.line,i.ch+t)}}setOption(t,e){switch(t){case"keyMap":this.state.keyMap=e;break;case"textwidth":this.state.textwidth=e;break}}getOption(t){switch(t){case"firstLineNumber":return 1;case"tabSize":return this.cm6.state.tabSize||4;case"readOnly":return this.cm6.state.readOnly;case"indentWithTabs":return this.cm6.state.facet(Ts)==" ";case"indentUnit":return this.cm6.state.facet(Ts).length||2;case"textwidth":return this.state.textwidth;case"keyMap":return this.state.keyMap||"vim"}}toggleOverwrite(t){this.state.overwrite=t}getTokenTypeAt(t){var e,i=this.indexFromPos(t),n=$g(this.cm6.state,i),s=n?.resolve(i),a=((e=s?.type)===null||e===void 0?void 0:e.name)||"";return/comment/i.test(a)?"comment":/string/i.test(a)?"string":""}overWriteSelection(t){var e=this.cm6.state.doc,i=this.cm6.state.selection,n=i.ranges.map(s=>{if(s.empty){var a=s.to<e.length?e.sliceString(s.from,s.to+1):"";if(a&&!/\n/.test(a))return xt.range(s.from,s.to+1)}return s});this.cm6.dispatch({selection:xt.create(n,i.mainIndex)}),this.replaceSelection(t)}isInMultiSelectMode(){return this.cm6.state.selection.ranges.length>1}virtualSelectionMode(){return!!this.virtualSelection}forEachSelection(t){var e=this.cm6.state.selection;this.virtualSelection=xt.create(e.ranges,e.mainIndex);for(var i=0;i<this.virtualSelection.ranges.length;i++){var n=this.virtualSelection.ranges[i];n&&(this.cm6.dispatch({selection:xt.create([n])}),t(),this.virtualSelection.ranges[i]=this.cm6.state.selection.ranges[0])}this.cm6.dispatch({selection:this.virtualSelection}),this.virtualSelection=null}hardWrap(t){return QC(this,t)}};ce.isMac=typeof navigator<"u"&&/Mac/.test(navigator.platform);ce.Pos=Sn;ce.StringStream=xh;ce.commands={cursorCharLeft:function(o){Ah(o.cm6)},redo:function(o){sf(o,!1)},undo:function(o){sf(o,!0)},newlineAndIndent:function(o){Wd({state:o.cm6.state,dispatch:t=>mr(o,t)})},indentAuto:function(o){bv(o.cm6)},newlineAndIndentContinueComment:void 0,save:void 0};ce.isWordChar=function(o){return Vd.test(o)};ce.keys=VC;ce.addClass=function(o,t){};ce.rmClass=function(o,t){};ce.e_preventDefault=function(o){o.preventDefault()};ce.e_stop=function(o){var t,e;(t=o?.stopPropagation)===null||t===void 0||t.call(o),(e=o?.preventDefault)===null||e===void 0||e.call(o)};ce.lookupKey=function(o,t,e){var i=ce.keys[o];!i&&/^Arrow/.test(o)&&(i=ce.keys[o.slice(5)]),i&&e(i)};ce.on=kv;ce.off=Cv;ce.signal=$v;ce.findMatchingTag=GC;ce.findEnclosingTag=YC;ce.keyName=void 0;function Tv(o,t,e){var i=document.createElement("div");return i.appendChild(t),i}function Ev(o,t){o.state.currentNotificationClose&&o.state.currentNotificationClose(),o.state.currentNotificationClose=t}function UC(o,t,e){Ev(o,l);var i=Tv(o,t,e&&e.bottom),n=!1,s,a=e&&typeof e.duration<"u"?e.duration:5e3;function l(){n||(n=!0,clearTimeout(s),i.remove(),Av(o,i))}return i.onclick=function(c){c.preventDefault(),l()},Iv(o,i),a&&(s=setTimeout(l,a)),l}function Iv(o,t){var e=o.state.dialog;o.state.dialog=t,t.style.flex="1",t&&e!==t&&(e&&e.contains(document.activeElement)&&o.focus(),e&&e.parentElement?e.parentElement.replaceChild(t,e):e&&e.remove(),ce.signal(o,"dialog"))}function Av(o,t){o.state.dialog==t&&(o.state.dialog=null,ce.signal(o,"dialog"))}function jC(o,t,e,i){i||(i={}),Ev(o,void 0);var n=Tv(o,t,i.bottom),s=!1;Iv(o,n);function a(c){if(typeof c=="string")l.value=c;else{if(s)return;s=!0,Av(o,n),o.state.dialog||o.focus(),i.onClose&&i.onClose(n)}}var l=n.getElementsByTagName("input")[0];return l&&(i.value&&(l.value=i.value,i.selectValueOnOpen!==!1&&l.select()),i.onInput&&ce.on(l,"input",function(c){i.onInput(c,l.value,a)}),i.onKeyUp&&ce.on(l,"keyup",function(c){i.onKeyUp(c,l.value,a)}),ce.on(l,"keydown",function(c){i&&i.onKeyDown&&i.onKeyDown(c,l.value,a)||(c.keyCode==13&&e&&e(l.value),(c.keyCode==27||i.closeOnEnter!==!1&&c.keyCode==13)&&(l.blur(),ce.e_stop(c),a()))}),i.closeOnBlur!==!1&&ce.on(l,"blur",function(){setTimeout(function(){document.activeElement!==l&&a()})}),l.focus()),a}var qC={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function KC(o){return o&&o.bracketRegex||/[(){}[\]]/}function ZC(o,t,e,i,n){for(var s=n&&n.maxScanLineLength||1e4,a=n&&n.maxScanLines||1e3,l=[],c=KC(n),u=e>0?Math.min(t.line+a,o.lastLine()+1):Math.max(o.firstLine()-1,t.line-a),p=t.line;p!=u;p+=e){var v=o.getLine(p);if(v){var x=e>0?0:v.length-1,T=e>0?v.length:-1;if(!(v.length>s))for(p==t.line&&(x=t.ch-(e<0?1:0));x!=T;x+=e){var M=v.charAt(x);if(c.test(M)){var P=qC[M];if(P&&P.charAt(1)==">"==e>0)l.push(M);else if(l.length)l.pop();else return{pos:new Sn(p,x),ch:M}}}}}return p-e==(e>0?o.lastLine():o.firstLine())?!1:null}function GC(o,t){return null}function YC(o,t){var e,i,n=o.cm6.state,s=o.indexFromPos(t);if(s<n.doc.length){var a=n.sliceDoc(s,s+1);a=="<"&&s++}for(var l=$g(n,s),c=l?.resolve(s)||null;c;){if(((e=c.firstChild)===null||e===void 0?void 0:e.type.name)=="OpenTag"&&((i=c.lastChild)===null||i===void 0?void 0:i.type.name)=="CloseTag")return{open:rf(n.doc,c.firstChild),close:rf(n.doc,c.lastChild)};c=c.parent}}function rf(o,t){return{from:Zi(o,t.from),to:Zi(o,t.to)}}class JC{constructor(t,e,i){this.cm=t,this.id=t.$mid++,this.offset=e,this.assoc=i,t.marks[this.id]=this}clear(){delete this.cm.marks[this.id]}find(){return this.offset==null?null:this.cm.posFromIndex(this.offset)}update(t){this.offset!=null&&(this.offset=t.mapPos(this.offset,this.assoc,mi.TrackDel))}}function QC(o,t){for(var e,i=t.column||o.getOption("textwidth")||80,n=t.allowMerge!=!1,s=Math.min(t.from,t.to),a=Math.max(t.from,t.to);s<=a;){var l=o.getLine(s);if(l.length>i){var c=M(l,i,5);if(c){var u=(e=/^\s*/.exec(l))===null||e===void 0?void 0:e[0];o.replaceRange(`
|
||
`+u,new Sn(s,c.start),new Sn(s,c.end))}a++}else if(n&&/\S/.test(l)&&s!=a){var p=o.getLine(s+1);if(p&&/\S/.test(p)){var v=l.replace(/\s+$/,""),x=p.replace(/^\s+/,""),T=v+" "+x,c=M(T,i,5);c&&c.start>v.length||T.length<i?(o.replaceRange(" ",new Sn(s,v.length),new Sn(s+1,p.length-x.length)),s--,a--):v.length<l.length&&o.replaceRange("",new Sn(s,v.length),new Sn(s,l.length))}}s++}return s;function M(P,F,R){if(!(P.length<F)){var q=P.slice(0,F),H=P.slice(F),Q=/^(?:(\s+)|(\S+)(\s+))/.exec(H),tt=/(?:(\s+)|(\s+)(\S+))$/.exec(q),it=0,rt=0;if(tt&&!tt[2]&&(it=F-tt[1].length,rt=F),Q&&!Q[2]&&(it||(it=F),rt=F+Q[1].length),it)return{start:it,end:rt};if(tt&&tt[2]&&tt.index>R)return{start:tt.index,end:tt.index+tt[2].length};if(Q&&Q[2])return it=F+Q[2].length,{start:it,end:it+Q[3].length}}}}let Ud=Px||function(){let o={cursorBlinkRate:1200};return function(){return o}}();class XC{constructor(t,e,i,n,s,a,l,c,u,p){this.left=t,this.top=e,this.height=i,this.fontFamily=n,this.fontSize=s,this.fontWeight=a,this.color=l,this.className=c,this.letter=u,this.partial=p}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",t.style.height=this.height+"px",t.style.lineHeight=this.height+"px",t.style.fontFamily=this.fontFamily,t.style.fontSize=this.fontSize,t.style.fontWeight=this.fontWeight,t.style.color=this.partial?"transparent":this.color,t.className=this.className,t.textContent=this.letter}eq(t){return this.left==t.left&&this.top==t.top&&this.height==t.height&&this.fontFamily==t.fontFamily&&this.fontSize==t.fontSize&&this.fontWeight==t.fontWeight&&this.color==t.color&&this.className==t.className&&this.letter==t.letter}}class t${constructor(t,e){this.view=t,this.rangePieces=[],this.cursors=[],this.cm=e,this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.cursorLayer=t.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer cm-vimCursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),t.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){let t=Ud(this.cm.cm6.state).cursorBlinkRate;this.cursorLayer.style.animationDuration=t+"ms"}update(t){(t.selectionSet||t.geometryChanged||t.viewportChanged)&&(this.view.requestMeasure(this.measureReq),this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink"),e$(t)&&this.setBlinkRate()}scheduleRedraw(){this.view.requestMeasure(this.measureReq)}readPos(){let{state:t}=this.view,e=[];for(let i of t.selection.ranges){let n=i==t.selection.main,s=s$(this.cm,this.view,i,n);s&&e.push(s)}return{cursors:e}}drawSel({cursors:t}){if(t.length!=this.cursors.length||t.some((e,i)=>!e.eq(this.cursors[i]))){let e=this.cursorLayer.children;if(e.length!==t.length){this.cursorLayer.textContent="";for(const i of t)this.cursorLayer.appendChild(i.draw())}else t.forEach((i,n)=>i.adjust(e[n]));this.cursors=t}}destroy(){this.cursorLayer.remove()}}function e$(o){return Ud(o.startState)!=Ud(o.state)}const i$={".cm-vimMode .cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-fat-cursor":{position:"absolute",background:"#ff9696",border:"none",whiteSpace:"pre"},"&:not(.cm-focused) .cm-fat-cursor":{background:"none",outline:"solid 1px #ff9696",color:"transparent !important"}},n$=Pl.highest(Wt.theme(i$));function o$(o){let t=o.scrollDOM.getBoundingClientRect();return{left:(o.textDirection==Fe.LTR?t.left:t.right-o.scrollDOM.clientWidth)-o.scrollDOM.scrollLeft*o.scaleX,top:t.top-o.scrollDOM.scrollTop*o.scaleY}}function s$(o,t,e,i){var n,s,a,l;let c=e.head,u=!1,p=1,v=o.state.vim;if(v&&(!v.insertMode||o.state.overwrite)){if(u=!0,v.visualBlock&&!i)return null;e.anchor<e.head&&(c<t.state.doc.length&&t.state.sliceDoc(c,c+1))!=`
|
||
`&&c--,o.state.overwrite?p=.2:v.status&&(p=.5)}if(u){let T=c<t.state.doc.length&&t.state.sliceDoc(c,c+1);T&&/[\uDC00-\uDFFF]/.test(T)&&c>1&&(c--,T=t.state.sliceDoc(c,c+1));let M=t.coordsAtPos(c,1);if(!M)return null;let P=o$(t),F=t.domAtPos(c),R=F?F.node:t.contentDOM;for(R instanceof Text&&F.offset>=R.data.length&&!((n=R.parentElement)===null||n===void 0)&&n.nextSibling&&(R=(s=R.parentElement)===null||s===void 0?void 0:s.nextSibling,F={node:R,offset:0});F&&F.node instanceof HTMLElement;)R=F.node,F={node:F.node.childNodes[F.offset],offset:0};if(!(R instanceof HTMLElement)){if(!R.parentNode)return null;R=R.parentNode}let q=getComputedStyle(R),H=M.left,Q=(l=(a=t).coordsForChar)===null||l===void 0?void 0:l.call(a,c);if(Q&&(H=Q.left),!T||T==`
|
||
`||T=="\r")T=" ";else if(T==" "){T=" ";var x=t.coordsAtPos(c+1,-1);x&&(H=x.left-(x.left-M.left)/parseInt(q.tabSize))}else/[\uD800-\uDBFF]/.test(T)&&c<t.state.doc.length-1&&(T+=t.state.sliceDoc(c+1,c+2));let tt=M.bottom-M.top;return new XC((H-P.left)/t.scaleX,(M.top-P.top+tt*(1-p))/t.scaleY,tt*p/t.scaleY,q.fontFamily,q.fontSize,q.fontWeight,q.color,i?"cm-fat-cursor cm-cursor-primary":"cm-fat-cursor cm-cursor-secondary",T,p!=1)}else return null}var r$=typeof navigator<"u"&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent);const Do=HC(ce),a$=250,l$=Wt.baseTheme({".cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer)":{display:"none"},".cm-vim-panel":{padding:"0px 10px",fontFamily:"monospace",minHeight:"1.3em",display:"flex"},".cm-vim-panel input":{border:"none",outline:"none",backgroundColor:"inherit"},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"}}),c$=ti.fromClass(class{constructor(o){this.status="",this.query=null,this.decorations=Yt.none,this.waitForCopy=!1,this.lastKeydown="",this.useNextTextInput=!1,this.compositionText="",this.view=o;const t=this.cm=new ce(o);Do.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new t$(o,t),this.updateClass(),this.cm.on("vim-command-done",()=>{t.state.vim&&(t.state.vim.status=""),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on("vim-mode-change",e=>{t.state.vim&&(t.state.vim.mode=e.mode,e.subMode&&(t.state.vim.mode+=" block"),t.state.vim.status="",this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on("dialog",()=>{this.cm.state.statusbar?this.updateStatus():o.dispatch({effects:Lv.of(!!this.cm.state.dialog)})}),this.dom=document.createElement("span"),this.spacer=document.createElement("span"),this.spacer.style.flex="1",this.statusButton=document.createElement("span"),this.statusButton.onclick=e=>{Do.handleKey(this.cm,"<Esc>","user"),this.cm.focus()},this.statusButton.style.cssText="cursor: pointer"}update(o){var t;if((o.viewportChanged||o.docChanged)&&this.query&&this.highlight(this.query),o.docChanged&&this.cm.onChange(o),o.selectionSet&&this.cm.onSelectionChange(),o.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),o.transactions){for(let e of o.transactions)for(let i of e.effects)if(i.is(Hd))if(!(!((t=i.value)===null||t===void 0)&&t.forVim))this.highlight(null);else{let n=i.value.create();this.highlight(n)}}this.blockCursor.update(o)}updateClass(){const o=this.cm.state;!o.vim||o.vim.insertMode&&!o.overwrite?this.view.scrollDOM.classList.remove("cm-vimMode"):this.view.scrollDOM.classList.add("cm-vimMode")}updateStatus(){let o=this.cm.state.statusbar,t=this.cm.state.vim;if(!o||!t)return;let e=this.cm.state.dialog;if(e)e.parentElement!=o&&(o.textContent="",o.appendChild(e));else{o.textContent="";var i=(t.mode||"normal").toUpperCase();t.insertModeReturn&&(i+="(C-O)"),this.statusButton.textContent=`--${i}--`,o.appendChild(this.statusButton),o.appendChild(this.spacer)}this.dom.textContent=t.status,o.appendChild(this.dom)}destroy(){Do.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(o){if(this.query=o,!o)return this.decorations=Yt.none;let{view:t}=this,e=new On;for(let i=0,n=t.visibleRanges,s=n.length;i<s;i++){let{from:a,to:l}=n[i];for(;i<s-1&&l>n[i+1].from-2*a$;)l=n[++i].to;o.highlight(t.state,a,l,(c,u)=>{e.add(c,u,h$)})}return this.decorations=e.finish()}handleKey(o,t){const e=this.cm;let i=e.state.vim;if(!i)return;const n=Do.vimKeyFromEvent(o,i);if(ce.signal(this.cm,"inputEvent",{type:"handleKey",key:n}),!n)return;if(n=="<Esc>"&&!i.insertMode&&!i.visualMode&&this.query){const a=i.searchState_;a&&(e.removeOverlay(a.getOverlay()),a.setOverlay(null))}if(n==="<C-c>"&&!ce.isMac&&e.somethingSelected())return this.waitForCopy=!0,!0;i.status=(i.status||"")+n;let s=Do.multiSelectHandleKey(e,n,"user");return i=Do.maybeInitVimState_(e),!s&&i.insertMode&&e.state.overwrite&&(o.key&&o.key.length==1&&!/\n/.test(o.key)?(s=!0,e.overWriteSelection(o.key)):o.key=="Backspace"&&(s=!0,ce.commands.cursorCharLeft(e))),s&&(ce.signal(this.cm,"vim-keypress",n),o.preventDefault(),o.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!s}},{eventHandlers:{copy:function(o,t){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var e=this.cm,i=e.state.vim;i&&(i.insertMode?e.setSelection(e.getCursor(),e.getCursor()):e.operation(()=>{e.curOp&&(e.curOp.isVimOp=!0),Do.handleKey(e,"<Esc>","user")}))}))},compositionstart:function(o,t){this.useNextTextInput=!0,ce.signal(this.cm,"inputEvent",o)},compositionupdate:function(o,t){ce.signal(this.cm,"inputEvent",o)},compositionend:function(o,t){ce.signal(this.cm,"inputEvent",o)},keypress:function(o,t){ce.signal(this.cm,"inputEvent",o),this.lastKeydown=="Dead"&&this.handleKey(o,t)},keydown:function(o,t){ce.signal(this.cm,"inputEvent",o),this.lastKeydown=o.key,this.lastKeydown=="Unidentified"||this.lastKeydown=="Process"||this.lastKeydown=="Dead"?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(o,t))}},provide:()=>[Wt.inputHandler.of((o,t,e,i)=>{var n,s,a=g$(o);if(!a)return!1;var l=(n=a.state)===null||n===void 0?void 0:n.vim,c=a.state.vimPlugin;if(l&&!l.insertMode&&!(!((s=a.curOp)===null||s===void 0)&&s.isVimOp)){if(i==="\0\0")return!0;if(ce.signal(a,"inputEvent",{type:"text",text:i,from:t,to:e}),i.length==1&&c.useNextTextInput){if(l.expectLiteralNext&&o.composing)return c.compositionText=i,!1;if(c.compositionText){var u=c.compositionText;c.compositionText="";var p=o.state.selection.main.head,v=o.state.sliceDoc(p-u.length,p);if(u===v){var x=a.getCursor();a.replaceRange("",a.posFromIndex(p-u.length),x)}}return c.handleKey({key:i,preventDefault:()=>{},stopPropagation:()=>{}}),d$(o),!0}}return!1})],decorations:o=>o.decorations});function d$(o){var t=o.scrollDOM.parentElement;if(t){if(r$){o.contentDOM.textContent="\0\0",o.contentDOM.dispatchEvent(new CustomEvent("compositionend"));return}var e=o.scrollDOM.nextSibling,i=window.getSelection(),n=i&&{anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset};o.scrollDOM.remove(),t.insertBefore(o.scrollDOM,e);try{n&&i&&(i.setPosition(n.anchorNode,n.anchorOffset),n.focusNode&&i.extend(n.focusNode,n.focusOffset))}catch(s){console.error(s)}o.focus(),o.contentDOM.dispatchEvent(new CustomEvent("compositionend"))}}const h$=Yt.mark({class:"cm-searchMatch"}),Lv=me.define(),u$=$i.define({create:()=>!1,update(o,t){for(let e of t.effects)e.is(Lv)&&(o=e.value);return o},provide:o=>Nr.from(o,t=>t?p$:null)});function p$(o){let t=document.createElement("div");t.className="cm-vim-panel";let e=o.cm;return e.state.dialog&&t.appendChild(e.state.dialog),{top:!1,dom:t}}function f$(o){let t=document.createElement("div");t.className="cm-vim-panel";let e=o.cm;return e.state.statusbar=t,e.state.vimPlugin.updateStatus(),{dom:t}}function m$(o={}){return[l$,c$,n$,o.status?Nr.of(f$):u$]}function g$(o){return o.cm||null}function v$(o,t=o.state){const e=new Set;for(const{from:i,to:n}of o.visibleRanges){let s=i;for(;s<=n;){const a=t.doc.lineAt(s);e.has(a)||e.add(a),s=a.to+1}}return e}function jd(o){const t=o.selection.main.head;return o.doc.lineAt(t)}function af(o,t){let e=0;t:for(let i=0;i<o.length;i++)switch(o[i]){case" ":case" ":{e+=1;continue t}case" ":{e+=t-e%t;continue t}case"\r":continue t;default:break t}return e}const El=Ft.define({combine(o){return ro(o,{highlightActiveBlock:!0,hideFirstIndent:!1,markerType:"fullScope",thickness:1})}});class y${constructor(t,e,i,n){this.lines=t,this.state=e,this.map=new Map,this.unitWidth=i,this.markerType=n;for(const s of this.lines)this.add(s);this.state.facet(El).highlightActiveBlock&&this.findAndSetActiveLines()}has(t){return this.map.has(typeof t=="number"?t:t.number)}get(t){const e=this.map.get(typeof t=="number"?t:t.number);if(!e)throw new Error("Line not found in indentation map");return e}set(t,e,i){const n=!t.text.trim().length,s={line:t,col:e,level:i,empty:n};return this.map.set(s.line.number,s),s}add(t){if(this.has(t))return this.get(t);if(!t.length||!t.text.trim().length){if(t.number===1)return this.set(t,0,0);if(t.number===this.state.doc.lines){const a=this.closestNonEmpty(t,-1);return this.set(t,0,a.level)}const n=this.closestNonEmpty(t,-1),s=this.closestNonEmpty(t,1);return n.level>=s.level&&this.markerType!=="codeOnly"?this.set(t,0,n.level):n.empty&&n.level===0&&s.level!==0?this.set(t,0,0):s.level>n.level?this.set(t,0,n.level+1):this.set(t,0,s.level)}const e=af(t.text,this.state.tabSize),i=Math.floor(e/this.unitWidth);return this.set(t,e,i)}closestNonEmpty(t,e){let i=t.number+e;for(;e===-1?i>=1:i<=this.state.doc.lines;){if(this.has(i)){const a=this.get(i);if(!a.empty)return a}const s=this.state.doc.line(i);if(s.text.trim().length){const a=af(s.text,this.state.tabSize),l=Math.floor(a/this.unitWidth);return this.set(s,a,l)}i+=e}const n=this.state.doc.line(e===-1?1:this.state.doc.lines);return this.set(n,0,0)}findAndSetActiveLines(){const t=jd(this.state);if(!this.has(t))return;let e=this.get(t);if(this.has(e.line.number+1)){const s=this.get(e.line.number+1);s.level>e.level&&(e=s)}if(this.has(e.line.number-1)){const s=this.get(e.line.number-1);s.level>e.level&&(e=s)}if(e.level===0)return;e.active=e.level;let i,n;for(i=e.line.number;i>1;i--){if(!this.has(i-1))continue;const s=this.get(i-1);if(s.level<e.level)break;s.active=e.level}for(n=e.line.number;n<this.state.doc.lines;n++){if(!this.has(n+1))continue;const s=this.get(n+1);if(s.level<e.level)break;s.active=e.level}}}function b$(o){const t={light:"#F0F1F2",dark:"#2B3245",activeLight:"#E4E5E6",activeDark:"#3C445C"};let e=t;return o&&(e=Object.assign(Object.assign({},t),o)),Wt.baseTheme({"&light":{"--indent-marker-bg-color":e.light,"--indent-marker-active-bg-color":e.activeLight},"&dark":{"--indent-marker-bg-color":e.dark,"--indent-marker-active-bg-color":e.activeDark},".cm-line":{position:"relative"},".cm-indent-markers::before":{content:'""',position:"absolute",top:0,left:"2px",right:0,bottom:0,background:"var(--indent-markers)",pointerEvents:"none",zIndex:"-1"}})}function Ba(o,t,e,i,n){return`${`repeating-linear-gradient(to right, var(${o}) 0 ${t}px, transparent ${t}px ${e}ch)`} ${i*e}.5ch/calc(${e*n}ch - 1px) no-repeat`}function w$(o,t,e,i,n){const{level:s,active:a}=o;if(n=n??i,e&&s===0)return[];const l=e?1:0,c=[];if(a!==void 0){const u=a-l-1;u>0&&c.push(Ba("--indent-marker-bg-color",i,t,l,u)),c.push(Ba("--indent-marker-active-bg-color",n,t,a-1,1)),a!==s&&c.push(Ba("--indent-marker-bg-color",i,t,a,s-a))}else c.push(Ba("--indent-marker-bg-color",i,t,l,s-l));return c.join(",")}class _${constructor(t){this.view=t,this.unitWidth=so(t.state),this.currentLineNumber=jd(t.state).number,this.generate(t.state)}update(t){const e=so(t.state),i=e!==this.unitWidth;i&&(this.unitWidth=e);const n=jd(t.state).number,s=n!==this.currentLineNumber;this.currentLineNumber=n;const a=t.state.facet(El).highlightActiveBlock&&s;(t.docChanged||t.viewportChanged||i||a)&&this.generate(t.state)}generate(t){const e=new On,i=v$(this.view,t),{hideFirstIndent:n,markerType:s,thickness:a,activeThickness:l}=t.facet(El),c=new y$(i,t,this.unitWidth,s);for(const u of i){const p=c.get(u.number);if(!(p!=null&&p.level))continue;const v=w$(p,this.unitWidth,n,a,l);e.add(u.from,u.from,Yt.line({class:"cm-indent-markers",attributes:{style:`--indent-markers: ${v}`}}))}this.decorations=e.finish()}}function x$(o={}){return[El.of(o),b$(o.colors),ti.fromClass(_$,{decorations:t=>t.decorations})]}class lf{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}}class Bo{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let n=i.facet(Mn).markerFilter;n&&(t=n(t,i));let s=t.slice().sort((p,v)=>p.from-v.from||p.to-v.to),a=new On,l=[],c=0;for(let p=0;;){let v=p==s.length?null:s[p];if(!v&&!l.length)break;let x,T;for(l.length?(x=c,T=l.reduce((P,F)=>Math.min(P,F.to),v&&v.from>x?v.from:1e8)):(x=v.from,T=v.to,l.push(v),p++);p<s.length;){let P=s[p];if(P.from==x&&(P.to>P.from||P.to==x))l.push(P),p++,T=Math.min(P.to,T);else{T=Math.min(P.from,T);break}}let M=Bv(l);if(l.some(P=>P.from==P.to||P.from==P.to-1&&i.doc.lineAt(P.from).to==P.from))a.add(x,x,Yt.widget({widget:new A$(M),diagnostics:l.slice()}));else{let P=l.reduce((F,R)=>R.markClass?F+" "+R.markClass:F,"");a.add(x,T,Yt.mark({class:"cm-lintRange cm-lintRange-"+M+P,diagnostics:l.slice(),inclusiveEnd:l.some(F=>F.to>T)}))}c=T;for(let P=0;P<l.length;P++)l[P].to<=c&&l.splice(P--,1)}let u=a.finish();return new Bo(u,e,Is(u))}}function Is(o,t=null,e=0){let i=null;return o.between(e,1e9,(n,s,{spec:a})=>{if(!(t&&a.diagnostics.indexOf(t)<0))if(!i)i=new lf(n,s,t||a.diagnostics[0]);else{if(a.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new lf(i.from,s,i.diagnostic)}}),i}function Nv(o,t){let e=t.pos,i=t.end||e,n=o.state.facet(Mn).hideOn(o,e,i);if(n!=null)return n;let s=o.startState.doc.lineAt(t.pos);return!!(o.effects.some(a=>a.is(Kl))||o.changes.touchesRange(s.from,Math.max(s.to,i)))}function k$(o,t){return o.field(mn,!1)?t:t.concat(me.appendConfig.of(Wv))}function C$(o,t){return{effects:k$(o,[Kl.of(t)])}}const Kl=me.define(),Mv=me.define(),Pv=me.define(),mn=$i.define({create(){return new Bo(Yt.none,null,null)},update(o,t){if(t.docChanged&&o.diagnostics.size){let e=o.diagnostics.map(t.changes),i=null,n=o.panel;if(o.selected){let s=t.changes.mapPos(o.selected.from,1);i=Is(e,o.selected.diagnostic,s)||Is(e,null,s)}!e.size&&n&&t.state.facet(Mn).autoPanel&&(n=null),o=new Bo(e,n,i)}for(let e of t.effects)if(e.is(Kl)){let i=t.state.facet(Mn).autoPanel?e.value.length?Il.open:null:o.panel;o=Bo.init(e.value,i,t.state)}else e.is(Mv)?o=new Bo(o.diagnostics,e.value?Il.open:null,o.selected):e.is(Pv)&&(o=new Bo(o.diagnostics,o.panel,e.value));return o},provide:o=>[Nr.from(o,t=>t.panel),Wt.decorations.from(o,t=>t.diagnostics)]}),$$=Yt.mark({class:"cm-lintRange cm-lintRange-active"});function S$(o,t,e){let{diagnostics:i}=o.state.field(mn),n,s=-1,a=-1;i.between(t-(e<0?1:0),t+(e>0?1:0),(c,u,{spec:p})=>{if(t>=c&&t<=u&&(c==u||(t>c||e>0)&&(t<u||e<0)))return n=p.diagnostics,s=c,a=u,!1});let l=o.state.facet(Mn).tooltipFilter;return n&&l&&(n=l(n,o.state)),n?{pos:s,end:a,above:o.state.doc.lineAt(s).to<a,create(){return{dom:Ov(o,n)}}}:null}function Ov(o,t){return En("ul",{class:"cm-tooltip-lint"},t.map(e=>Rv(o,e,!1)))}const cf=o=>{let t=o.state.field(mn,!1);return!t||!t.panel?!1:(o.dispatch({effects:Mv.of(!1)}),!0)},T$=ti.fromClass(class{constructor(o){this.view=o,this.timeout=-1,this.set=!0;let{delay:t}=o.state.facet(Mn);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let o=Date.now();if(o<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-o);else{this.set=!1;let{state:t}=this.view,{sources:e}=t.facet(Mn);e.length&&E$(e.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==t.doc&&this.view.dispatch(C$(this.view.state,i.reduce((n,s)=>n.concat(s))))},i=>{Ji(this.view.state,i)})}}update(o){let t=o.state.facet(Mn);(o.docChanged||t!=o.startState.facet(Mn)||t.needsRefresh&&t.needsRefresh(o))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function E$(o,t,e){let i=[],n=-1;for(let s of o)s.then(a=>{i.push(a),clearTimeout(n),i.length==o.length?t(i):n=setTimeout(()=>t(i),200)},e)}const Mn=Ft.define({combine(o){return Object.assign({sources:o.map(t=>t.source).filter(t=>t!=null)},ro(o.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(t,e)=>t?e?i=>t(i)||e(i):t:e}))}});function I$(o,t={}){return[Mn.of({source:o,config:t}),T$,Wv]}function Dv(o){let t=[];if(o)t:for(let{name:e}of o){for(let i=0;i<e.length;i++){let n=e[i];if(/[a-zA-Z]/.test(n)&&!t.some(s=>s.toLowerCase()==n.toLowerCase())){t.push(n);continue t}}t.push("")}return t}function Rv(o,t,e){var i;let n=e?Dv(t.actions):[];return En("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},En("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(o):t.message),(i=t.actions)===null||i===void 0?void 0:i.map((s,a)=>{let l=!1,c=x=>{if(x.preventDefault(),l)return;l=!0;let T=Is(o.state.field(mn).diagnostics,t);T&&s.apply(o,T.from,T.to)},{name:u}=s,p=n[a]?u.indexOf(n[a]):-1,v=p<0?u:[u.slice(0,p),En("u",u.slice(p,p+1)),u.slice(p+1)];return En("button",{type:"button",class:"cm-diagnosticAction",onclick:c,onmousedown:c,"aria-label":` Action: ${u}${p<0?"":` (access key "${n[a]})"`}.`},v)}),t.source&&En("div",{class:"cm-diagnosticSource"},t.source))}class A$ extends Zo{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return En("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class df{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Rv(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Il{constructor(t){this.view=t,this.items=[];let e=n=>{if(n.keyCode==27)cf(this.view),this.view.focus();else if(n.keyCode==38||n.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(n.keyCode==40||n.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(n.keyCode==36)this.moveSelection(0);else if(n.keyCode==35)this.moveSelection(this.items.length-1);else if(n.keyCode==13)this.view.focus();else if(n.keyCode>=65&&n.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],a=Dv(s.actions);for(let l=0;l<a.length;l++)if(a[l].toUpperCase().charCodeAt(0)==n.keyCode){let c=Is(this.view.state.field(mn).diagnostics,s);c&&s.actions[l].apply(t,c.from,c.to)}}else return;n.preventDefault()},i=n=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(n.target)&&this.moveSelection(s)};this.list=En("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e,onclick:i}),this.dom=En("div",{class:"cm-panel-lint"},this.list,En("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>cf(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(mn).selected;if(!t)return-1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}update(){let{diagnostics:t,selected:e}=this.view.state.field(mn),i=0,n=!1,s=null,a=new Set;for(t.between(0,this.view.state.doc.length,(l,c,{spec:u})=>{for(let p of u.diagnostics){if(a.has(p))continue;a.add(p);let v=-1,x;for(let T=i;T<this.items.length;T++)if(this.items[T].diagnostic==p){v=T;break}v<0?(x=new df(this.view,p),this.items.splice(i,0,x),n=!0):(x=this.items[v],v>i&&(this.items.splice(i,v-i),n=!0)),e&&x.diagnostic==e.diagnostic?x.dom.hasAttribute("aria-selected")||(x.dom.setAttribute("aria-selected","true"),s=x):x.dom.hasAttribute("aria-selected")&&x.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();this.items.length==0&&(this.items.push(new df(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:c})=>{let u=c.height/this.list.offsetHeight;l.top<c.top?this.list.scrollTop-=(c.top-l.top)/u:l.bottom>c.bottom&&(this.list.scrollTop+=(l.bottom-c.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let t=this.list.firstChild;function e(){let i=t;t=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;t!=i.dom;)e();t=i.dom.nextSibling}else this.list.insertBefore(i.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=this.view.state.field(mn),i=Is(e.diagnostics,this.items[t].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Pv.of(i)})}static open(t){return new Il(t)}}function ol(o,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(o)}</svg>')`}function za(o){return ol(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${o}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const L$=Wt.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:za("#d11")},".cm-lintRange-warning":{backgroundImage:za("orange")},".cm-lintRange-info":{backgroundImage:za("#999")},".cm-lintRange-hint":{backgroundImage:za("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function N$(o){return o=="error"?4:o=="warning"?3:o=="info"?2:1}function Bv(o){let t="hint",e=1;for(let i of o){let n=N$(i.severity);n>e&&(e=n,t=i.severity)}return t}class zv extends oo{constructor(t){super(),this.diagnostics=t,this.severity=Bv(t)}toDOM(t){let e=document.createElement("div");e.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,n=t.state.facet(Zl).tooltipFilter;return n&&(i=n(i,t.state)),i.length&&(e.onmouseover=()=>P$(t,e,i)),e}}function M$(o,t){let e=i=>{let n=t.getBoundingClientRect();if(!(i.clientX>n.left-10&&i.clientX<n.right+10&&i.clientY>n.top-10&&i.clientY<n.bottom+10)){for(let s=i.target;s;s=s.parentNode)if(s.nodeType==1&&s.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",e),o.state.field(Fv)&&o.dispatch({effects:Dh.of(null)})}};window.addEventListener("mousemove",e)}function P$(o,t,e){function i(){let a=o.elementAtHeight(t.getBoundingClientRect().top+5-o.documentTop);o.coordsAtPos(a.from)&&o.dispatch({effects:Dh.of({pos:a.from,above:!1,clip:!1,create(){return{dom:Ov(o,e),getCoords:()=>t.getBoundingClientRect()}}})}),t.onmouseout=t.onmousemove=null,M$(o,t)}let{hoverTime:n}=o.state.facet(Zl),s=setTimeout(i,n);t.onmouseout=()=>{clearTimeout(s),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(s),s=setTimeout(i,n)}}function O$(o,t){let e=Object.create(null);for(let n of t){let s=o.lineAt(n.from);(e[s.from]||(e[s.from]=[])).push(n)}let i=[];for(let n in e)i.push(new zv(e[n]).range(+n));return ue.of(i,!0)}const D$=mg({class:"cm-gutter-lint",markers:o=>o.state.field(qd),widgetMarker:(o,t,e)=>{let i=[];return o.state.field(qd).between(e.from,e.to,(n,s,a)=>{n>e.from&&n<e.to&&i.push(...a.diagnostics)}),i.length?new zv(i):null}}),qd=$i.define({create(){return ue.empty},update(o,t){o=o.map(t.changes);let e=t.state.facet(Zl).markerFilter;for(let i of t.effects)if(i.is(Kl)){let n=i.value;e&&(n=e(n||[],t.state)),o=O$(t.state.doc,n.slice(0))}return o}}),Dh=me.define(),Fv=$i.define({create(){return null},update(o,t){return o&&t.docChanged&&(o=Nv(t,o)?null:Object.assign(Object.assign({},o),{pos:t.changes.mapPos(o.pos)})),t.effects.reduce((e,i)=>i.is(Dh)?i.value:e,o)},provide:o=>fh.from(o)}),R$=Wt.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:ol('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:ol('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:ol('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),Wv=[mn,Wt.decorations.compute([mn],o=>{let{selected:t,panel:e}=o.field(mn);return!t||!e||t.from==t.to?Yt.none:Yt.set([$$.range(t.from,t.to)])}),Gx(S$,{hideOn:Nv}),L$],Zl=Ft.define({combine(o){return ro(o,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function B$(o={}){return[Zl.of(o),qd,D$,R$,Fv]}async function hf(o){const{javascript:t,esLint:e}=await Z(async()=>{const{javascript:a,esLint:l}=await import("./index-DMWsby55.js");return{javascript:a,esLint:l}},__vite__mapDeps([18,19,20,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url),i=(await Z(async()=>{const{lint:a}=await import("./eslint-BLaL04kV.js");return{lint:a}},__vite__mapDeps([21,2]),import.meta.url)).lint,n=[t()],s=await i(o);if("linter"in s){const{linter:a,config:l}=s;n.push(I$(e(a,l))),n.push(B$())}return n}async function uf(){const{mermaid:o,foldByIndent:t}=await Z(async()=>{const{mermaid:e,foldByIndent:i}=await import("./index-ChAH7PmL.js");return{mermaid:e,foldByIndent:i}},__vite__mapDeps([22,19,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url);return[o(),t()]}const z$={"text/plain":null,"application/dart":async()=>(await Z(async()=>{const{dart:o}=await import("./clike-C67HaMJ3.js");return{dart:o}},[],import.meta.url)).dart,"application/edn":async()=>(await Z(async()=>{const{clojure:o}=await import("./clojure-CCKyeQKf.js");return{clojure:o}},[],import.meta.url)).clojure,"application/javascript;env=backend":async()=>hf("application/javascript;env=backend"),"application/javascript;env=frontend":async()=>hf("application/javascript;env=frontend"),"application/json":async()=>(await Z(async()=>{const{json:o}=await import("./index-C-bx8VHj.js");return{json:o}},__vite__mapDeps([23,19,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).json(),"application/ld+json":async()=>(await Z(async()=>{const{jsonld:o}=await import("./javascript-C2yteZeJ.js");return{jsonld:o}},[],import.meta.url)).jsonld,"application/mbox":async()=>(await Z(async()=>{const{mbox:o}=await import("./mbox-BctzC1hL.js");return{mbox:o}},[],import.meta.url)).mbox,"application/n-triples":async()=>(await Z(async()=>{const{ntriples:o}=await import("./ntriples-CsNjv2QF.js");return{ntriples:o}},[],import.meta.url)).ntriples,"application/pgp":async()=>(await Z(async()=>{const{asciiArmor:o}=await import("./asciiarmor-2LVJmxlE.js");return{asciiArmor:o}},[],import.meta.url)).asciiArmor,"application/sieve":async()=>(await Z(async()=>{const{sieve:o}=await import("./sieve-Bwz7vjP5.js");return{sieve:o}},[],import.meta.url)).sieve,"application/sparql-query":async()=>(await Z(async()=>{const{sparql:o}=await import("./sparql-FarWu_Gb.js");return{sparql:o}},[],import.meta.url)).sparql,"application/typescript":async()=>(await Z(async()=>{const{javascript:o}=await import("./index-DMWsby55.js");return{javascript:o}},__vite__mapDeps([18,19,20,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).javascript({typescript:!0}),"application/x-aspx":null,"application/x-bat":async()=>(await Z(async()=>{const{batch:o}=await import("./batch-X8TaNpXx.js");return{batch:o}},__vite__mapDeps([24,25]),import.meta.url)).batch,"application/x-cypher-query":async()=>(await Z(async()=>{const{cypher:o}=await import("./cypher-BMq4Fwjl.js");return{cypher:o}},[],import.meta.url)).cypher,"application/x-ejs":null,"application/x-erb":null,"application/x-jsp":null,"application/x-powershell":async()=>(await Z(async()=>{const{powerShell:o}=await import("./powershell-DkYVfTzP.js");return{powerShell:o}},[],import.meta.url)).powerShell,"application/xml-dtd":async()=>(await Z(async()=>{const{xml:o}=await import("./xml-Dw5x8Is8.js");return{xml:o}},[],import.meta.url)).xml,"application/xquery":async()=>(await Z(async()=>{const{xQuery:o}=await import("./xquery-BUQdORAS.js");return{xQuery:o}},[],import.meta.url)).xQuery,"message/http":async()=>(await Z(async()=>{const{http:o}=await import("./http-D9LttvKF.js");return{http:o}},[],import.meta.url)).http,"text/apl":async()=>(await Z(async()=>{const{apl:o}=await import("./apl-B2DGVGxc.js");return{apl:o}},[],import.meta.url)).apl,"text/coffeescript":async()=>(await Z(async()=>{const{coffeeScript:o}=await import("./coffeescript-BVCvwO8I.js");return{coffeeScript:o}},[],import.meta.url)).coffeeScript,"text/css":async()=>(await Z(async()=>{const{css:o}=await import("./index-Dzlwgv2b.js");return{css:o}},__vite__mapDeps([26,19,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).css(),"text/html":async()=>(await Z(async()=>{const{html:o}=await import("./index-DVtO9wPE.js");return{html:o}},__vite__mapDeps([27,19,26,3,2,4,5,1,6,7,9,10,11,12,18,20]),import.meta.url)).html(),"text/jinja2":async()=>(await Z(async()=>{const{jinja2:o}=await import("./jinja2-DnB6dQmV.js");return{jinja2:o}},[],import.meta.url)).jinja2,"text/jsx":async()=>(await Z(async()=>{const{javascript:o}=await import("./index-DMWsby55.js");return{javascript:o}},__vite__mapDeps([18,19,20,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).javascript({jsx:!0}),"text/mirc":async()=>(await Z(async()=>{const{mirc:o}=await import("./mirc-CFBPAOaF.js");return{mirc:o}},[],import.meta.url)).mirc,"text/tiki":async()=>(await Z(async()=>{const{tiki:o}=await import("./tiki-__Kn3CeS.js");return{tiki:o}},[],import.meta.url)).tiki,"text/troff":async()=>(await Z(async()=>{const{troff:o}=await import("./troff-D2UO-fKf.js");return{troff:o}},[],import.meta.url)).troff,"text/turtle":async()=>(await Z(async()=>{const{turtle:o}=await import("./turtle-xwJUxoPV.js");return{turtle:o}},[],import.meta.url)).turtle,"text/typescript-jsx":async()=>(await Z(async()=>{const{javascript:o}=await import("./index-DMWsby55.js");return{javascript:o}},__vite__mapDeps([18,19,20,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).javascript({typescript:!0,jsx:!0}),"text/vbscript":async()=>(await Z(async()=>{const{vbScript:o}=await import("./vbscript-1f_Dhg5H.js");return{vbScript:o}},[],import.meta.url)).vbScript,"text/velocity":async()=>(await Z(async()=>{const{velocity:o}=await import("./velocity-DJd0pTTC.js");return{velocity:o}},[],import.meta.url)).velocity,"text/vnd.mermaid":async()=>uf(),"text/mermaid":async()=>uf(),"text/x-asm-mips":null,"text/x-asterisk":async()=>(await Z(async()=>{const{asterisk:o}=await import("./asterisk-DS281yxp.js");return{asterisk:o}},[],import.meta.url)).asterisk,"text/x-brainfuck":async()=>(await Z(async()=>{const{brainfuck:o}=await import("./brainfuck-C_p9pTT8.js");return{brainfuck:o}},[],import.meta.url)).brainfuck,"text/x-c++src":async()=>(await Z(async()=>{const{cpp:o}=await import("./clike-C67HaMJ3.js");return{cpp:o}},[],import.meta.url)).cpp,"text/x-cassandra":async()=>(await Z(async()=>{const{cassandra:o}=await import("./sql-D0fBjQXA.js");return{cassandra:o}},[],import.meta.url)).cassandra,"text/x-clojure":async()=>(await Z(async()=>{const{clojure:o}=await import("./clojure-CCKyeQKf.js");return{clojure:o}},[],import.meta.url)).clojure,"text/x-clojurescript":async()=>(await Z(async()=>{const{clojure:o}=await import("./clojure-CCKyeQKf.js");return{clojure:o}},[],import.meta.url)).clojure,"text/x-cmake":async()=>(await Z(async()=>{const{cmake:o}=await import("./cmake-CuaCgAKt.js");return{cmake:o}},[],import.meta.url)).cmake,"text/x-cobol":async()=>(await Z(async()=>{const{cobol:o}=await import("./cobol-BlTKFDRj.js");return{cobol:o}},[],import.meta.url)).cobol,"text/x-common-lisp":async()=>(await Z(async()=>{const{commonLisp:o}=await import("./commonlisp-D_kxz07b.js");return{commonLisp:o}},[],import.meta.url)).commonLisp,"text/x-crystal":async()=>(await Z(async()=>{const{crystal:o}=await import("./crystal-D309uH6_.js");return{crystal:o}},[],import.meta.url)).crystal,"text/x-csharp":async()=>(await Z(async()=>{const{csharp:o}=await import("./clike-C67HaMJ3.js");return{csharp:o}},[],import.meta.url)).csharp,"text/x-csrc":async()=>(await Z(async()=>{const{c:o}=await import("./clike-C67HaMJ3.js");return{c:o}},[],import.meta.url)).c,"text/x-cython":async()=>(await Z(async()=>{const{cython:o}=await import("./python-B5QdSKoL.js");return{cython:o}},[],import.meta.url)).cython,"text/x-d":async()=>(await Z(async()=>{const{d:o}=await import("./d-BZcgY6La.js");return{d:o}},[],import.meta.url)).d,"text/x-diff":async()=>(await Z(async()=>{const{diff:o}=await import("./diff-Cg9d_RX2.js");return{diff:o}},[],import.meta.url)).diff,"text/x-django":null,"text/x-dockerfile":async()=>(await Z(async()=>{const{dockerFile:o}=await import("./dockerfile-DIy8NleC.js");return{dockerFile:o}},__vite__mapDeps([28,25]),import.meta.url)).dockerFile,"text/x-dylan":async()=>(await Z(async()=>{const{dylan:o}=await import("./dylan-QYeExnWK.js");return{dylan:o}},[],import.meta.url)).dylan,"text/x-ebnf":async()=>(await Z(async()=>{const{ebnf:o}=await import("./ebnf-DUPDuY4r.js");return{ebnf:o}},[],import.meta.url)).ebnf,"text/x-ecl":async()=>(await Z(async()=>{const{ecl:o}=await import("./ecl-CiXN-g_D.js");return{ecl:o}},[],import.meta.url)).ecl,"text/x-eiffel":async()=>(await Z(async()=>{const{eiffel:o}=await import("./eiffel-yQhjl4T1.js");return{eiffel:o}},[],import.meta.url)).eiffel,"text/x-elm":async()=>(await Z(async()=>{const{elm:o}=await import("./elm-CNT9vbN0.js");return{elm:o}},[],import.meta.url)).elm,"text/x-erlang":async()=>(await Z(async()=>{const{erlang:o}=await import("./erlang-CFOYdy9e.js");return{erlang:o}},[],import.meta.url)).erlang,"text/x-esper":async()=>(await Z(async()=>{const{esper:o}=await import("./sql-D0fBjQXA.js");return{esper:o}},[],import.meta.url)).esper,"text/x-factor":async()=>(await Z(async()=>{const{factor:o}=await import("./factor-DDOC7X6P.js");return{factor:o}},__vite__mapDeps([29,25]),import.meta.url)).factor,"text/x-fcl":async()=>(await Z(async()=>{const{fcl:o}=await import("./fcl-CPC2WYrI.js");return{fcl:o}},[],import.meta.url)).fcl,"text/x-feature":async()=>(await Z(async()=>{const{gherkin:o}=await import("./gherkin-CJuwpceU.js");return{gherkin:o}},[],import.meta.url)).gherkin,"text/x-forth":async()=>(await Z(async()=>{const{forth:o}=await import("./forth-BmxRyE9S.js");return{forth:o}},[],import.meta.url)).forth,"text/x-fortran":async()=>(await Z(async()=>{const{fortran:o}=await import("./fortran-9bvPyrOW.js");return{fortran:o}},[],import.meta.url)).fortran,"text/x-fsharp":async()=>(await Z(async()=>{const{fSharp:o}=await import("./mllike-BSnXJBGA.js");return{fSharp:o}},[],import.meta.url)).fSharp,"text/x-gas":async()=>(await Z(async()=>{const{gas:o}=await import("./gas-cpmYfFX2.js");return{gas:o}},[],import.meta.url)).gas,"text/x-gdscript":async()=>(await Z(async()=>{const{gdscript:o}=await import("./gdscript-fVwPZpIE.js");return{gdscript:o}},__vite__mapDeps([30,25]),import.meta.url)).gdscript,"text/x-gfm":async()=>{const{markdown:o,markdownLanguage:t}=await Z(async()=>{const{markdown:e,markdownLanguage:i}=await import("./index-DfHtIUQk.js");return{markdown:e,markdownLanguage:i}},__vite__mapDeps([31,20,27,19,26,3,2,4,5,1,6,7,9,10,11,12,18]),import.meta.url);return o({base:t})},"text/x-go":async()=>(await Z(async()=>{const{go:o}=await import("./go-BHVhI2MG.js");return{go:o}},[],import.meta.url)).go,"text/x-groovy":async()=>(await Z(async()=>{const{groovy:o}=await import("./groovy-DZeT_VM-.js");return{groovy:o}},[],import.meta.url)).groovy,"text/x-gss":async()=>(await Z(async()=>{const{gss:o}=await import("./css-D7hGgwrb.js");return{gss:o}},[],import.meta.url)).gss,"text/x-haml":null,"text/x-haskell":async()=>(await Z(async()=>{const{haskell:o}=await import("./haskell-Bvt3Qq1t.js");return{haskell:o}},[],import.meta.url)).haskell,"text/x-haxe":async()=>(await Z(async()=>{const{haxe:o}=await import("./haxe-70NVW1pR.js");return{haxe:o}},[],import.meta.url)).haxe,"text/x-hcl":async()=>(await Z(async()=>{const{hcl:o}=await import("./index-DGP8gWJD.js");return{hcl:o}},__vite__mapDeps([32,19,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).hcl(),"text/x-hxml":async()=>(await Z(async()=>{const{hxml:o}=await import("./haxe-70NVW1pR.js");return{hxml:o}},[],import.meta.url)).hxml,"text/x-idl":async()=>(await Z(async()=>{const{idl:o}=await import("./idl-B6TRFYjl.js");return{idl:o}},[],import.meta.url)).idl,"text/x-java":async()=>(await Z(async()=>{const{java:o}=await import("./clike-C67HaMJ3.js");return{java:o}},[],import.meta.url)).java,"text/x-julia":async()=>(await Z(async()=>{const{julia:o}=await import("./julia-DpvXAuO6.js");return{julia:o}},[],import.meta.url)).julia,"text/x-kotlin":async()=>(await Z(async()=>{const{kotlin:o}=await import("./clike-C67HaMJ3.js");return{kotlin:o}},[],import.meta.url)).kotlin,"text/x-latex":async()=>(await Z(async()=>{const{stex:o}=await import("./stex-Du4h4KAU.js");return{stex:o}},[],import.meta.url)).stex,"text/x-less":async()=>(await Z(async()=>{const{less:o}=await import("./css-D7hGgwrb.js");return{less:o}},[],import.meta.url)).less,"text/x-literate-haskell":null,"text/x-livescript":async()=>(await Z(async()=>{const{liveScript:o}=await import("./livescript-CanGTf8u.js");return{liveScript:o}},[],import.meta.url)).liveScript,"text/x-lua":async()=>(await Z(async()=>{const{lua:o}=await import("./lua-XplVlWi_.js");return{lua:o}},[],import.meta.url)).lua,"text/x-mariadb":async()=>(await Z(async()=>{const{sqlite:o}=await import("./sql-D0fBjQXA.js");return{sqlite:o}},[],import.meta.url)).sqlite,"text/x-markdown":async()=>(await Z(async()=>{const{markdown:o}=await import("./index-DfHtIUQk.js");return{markdown:o}},__vite__mapDeps([31,20,27,19,26,3,2,4,5,1,6,7,9,10,11,12,18]),import.meta.url)).markdown(),"text/x-mathematica":async()=>(await Z(async()=>{const{mathematica:o}=await import("./mathematica-jaRHnSxC.js");return{mathematica:o}},[],import.meta.url)).mathematica,"text/x-modelica":async()=>(await Z(async()=>{const{modelica:o}=await import("./modelica-vUgVs--1.js");return{modelica:o}},[],import.meta.url)).modelica,"text/x-mscgen":async()=>(await Z(async()=>{const{mscgen:o}=await import("./mscgen-Cpl0NYLN.js");return{mscgen:o}},[],import.meta.url)).mscgen,"text/x-msgenny":async()=>(await Z(async()=>{const{msgenny:o}=await import("./mscgen-Cpl0NYLN.js");return{msgenny:o}},[],import.meta.url)).msgenny,"text/x-mssql":async()=>(await Z(async()=>{const{msSQL:o}=await import("./sql-D0fBjQXA.js");return{msSQL:o}},[],import.meta.url)).msSQL,"text/x-mumps":async()=>(await Z(async()=>{const{mumps:o}=await import("./mumps-CQoS1kWX.js");return{mumps:o}},[],import.meta.url)).mumps,"text/x-mysql":async()=>(await Z(async()=>{const{mySQL:o}=await import("./sql-D0fBjQXA.js");return{mySQL:o}},[],import.meta.url)).mySQL,"text/x-nix":async()=>(await Z(async()=>{const{nix:o}=await import("./index-BOZ6ZR_8.js");return{nix:o}},__vite__mapDeps([33,19,20,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).nix(),"text/x-nginx-conf":async()=>(await Z(async()=>{const{nginx:o}=await import("./nginx-zDPm3Z74.js");return{nginx:o}},[],import.meta.url)).nginx,"text/x-nsis":async()=>(await Z(async()=>{const{nsis:o}=await import("./nsis-fePjrhq7.js");return{nsis:o}},__vite__mapDeps([34,25]),import.meta.url)).nsis,"text/x-objectivec":async()=>(await Z(async()=>{const{objectiveC:o}=await import("./clike-C67HaMJ3.js");return{objectiveC:o}},[],import.meta.url)).objectiveC,"text/x-ocaml":async()=>(await Z(async()=>{const{oCaml:o}=await import("./mllike-BSnXJBGA.js");return{oCaml:o}},[],import.meta.url)).oCaml,"text/x-octave":async()=>(await Z(async()=>{const{octave:o}=await import("./octave-C8PmmSRH.js");return{octave:o}},[],import.meta.url)).octave,"text/x-oz":async()=>(await Z(async()=>{const{oz:o}=await import("./oz-Ce8aN8oE.js");return{oz:o}},[],import.meta.url)).oz,"text/x-pascal":async()=>(await Z(async()=>{const{pascal:o}=await import("./pascal-De0D6mP7.js");return{pascal:o}},[],import.meta.url)).pascal,"text/x-perl":async()=>(await Z(async()=>{const{perl:o}=await import("./perl-B4bSCe1C.js");return{perl:o}},[],import.meta.url)).perl,"text/x-pgsql":async()=>(await Z(async()=>{const{pgSQL:o}=await import("./sql-D0fBjQXA.js");return{pgSQL:o}},[],import.meta.url)).pgSQL,"text/x-php":async()=>(await Z(async()=>{const{php:o}=await import("./index-iV4hneWX.js");return{php:o}},__vite__mapDeps([35,19,27,26,3,2,4,5,1,6,7,9,10,11,12,18,20]),import.meta.url)).php(),"text/x-pig":async()=>(await Z(async()=>{const{pig:o}=await import("./pig-D24Z8EXi.js");return{pig:o}},[],import.meta.url)).pig,"text/x-plsql":async()=>(await Z(async()=>{const{plSQL:o}=await import("./sql-D0fBjQXA.js");return{plSQL:o}},[],import.meta.url)).plSQL,"text/x-properties":async()=>(await Z(async()=>{const{properties:o}=await import("./properties-Dn9wna3M.js");return{properties:o}},[],import.meta.url)).properties,"text/x-protobuf":async()=>(await Z(async()=>{const{protobuf:o}=await import("./protobuf-BPIjwpzm.js");return{protobuf:o}},[],import.meta.url)).protobuf,"text/x-pug":async()=>(await Z(async()=>{const{pug:o}=await import("./pug-CwAQJzGR.js");return{pug:o}},__vite__mapDeps([36,37]),import.meta.url)).pug,"text/x-puppet":async()=>(await Z(async()=>{const{puppet:o}=await import("./puppet-nyd4dhjf.js");return{puppet:o}},[],import.meta.url)).puppet,"text/x-python":async()=>(await Z(async()=>{const{python:o}=await import("./python-B5QdSKoL.js");return{python:o}},[],import.meta.url)).python,"text/x-q":async()=>(await Z(async()=>{const{q:o}=await import("./q-DXjKs-tC.js");return{q:o}},[],import.meta.url)).q,"text/x-rpm-changes":async()=>(await Z(async()=>{const{rpmChanges:o}=await import("./rpm-IznJm2Xc.js");return{rpmChanges:o}},[],import.meta.url)).rpmChanges,"text/x-rpm-spec":async()=>(await Z(async()=>{const{rpmSpec:o}=await import("./rpm-IznJm2Xc.js");return{rpmSpec:o}},[],import.meta.url)).rpmSpec,"text/x-rsrc":async()=>(await Z(async()=>{const{r:o}=await import("./r-LKEuhEGI.js");return{r:o}},[],import.meta.url)).r,"text/x-rst":null,"text/x-ruby":async()=>(await Z(async()=>{const{ruby:o}=await import("./ruby-CcYfvIk6.js");return{ruby:o}},[],import.meta.url)).ruby,"text/x-rustsrc":async()=>(await Z(async()=>{const{rust:o}=await import("./rust-DZOEz86s.js");return{rust:o}},__vite__mapDeps([38,25]),import.meta.url)).rust,"text/x-sas":async()=>(await Z(async()=>{const{sas:o}=await import("./sas-7E8yHoCW.js");return{sas:o}},[],import.meta.url)).sas,"text/x-sass":async()=>(await Z(async()=>{const{sass:o}=await import("./sass-DXRO2mSp.js");return{sass:o}},__vite__mapDeps([39,40]),import.meta.url)).sass,"text/x-scala":async()=>(await Z(async()=>{const{scala:o}=await import("./clike-C67HaMJ3.js");return{scala:o}},[],import.meta.url)).scala,"text/x-scheme":async()=>(await Z(async()=>{const{scheme:o}=await import("./scheme-DjibxsNh.js");return{scheme:o}},[],import.meta.url)).scheme,"text/x-scss":async()=>(await Z(async()=>{const{sCSS:o}=await import("./css-D7hGgwrb.js");return{sCSS:o}},[],import.meta.url)).sCSS,"text/x-sh":async()=>(await Z(async()=>{const{shell:o}=await import("./shell-C0C2sNA_.js");return{shell:o}},[],import.meta.url)).shell,"text/x-slim":null,"text/x-smarty":async()=>(await Z(async()=>{const{smarty:o}=await import("./index-Dk9oRf-I.js");return{smarty:o}},[],import.meta.url)).smarty,"text/x-sml":async()=>(await Z(async()=>{const{sml:o}=await import("./mllike-BSnXJBGA.js");return{sml:o}},[],import.meta.url)).sml,"text/x-solr":async()=>(await Z(async()=>{const{solr:o}=await import("./solr-BNlsLglM.js");return{solr:o}},[],import.meta.url)).solr,"text/x-soy":null,"text/x-spreadsheet":async()=>(await Z(async()=>{const{spreadsheet:o}=await import("./spreadsheet-C-cy4P5N.js");return{spreadsheet:o}},[],import.meta.url)).spreadsheet,"text/x-sql":async()=>(await Z(async()=>{const{mySQL:o}=await import("./sql-D0fBjQXA.js");return{mySQL:o}},[],import.meta.url)).mySQL,"text/x-sqlite;schema=trilium":async()=>(await Z(async()=>{const{sqlite:o}=await import("./sql-D0fBjQXA.js");return{sqlite:o}},[],import.meta.url)).sqlite,"text/x-sqlite":async()=>(await Z(async()=>{const{sqlite:o}=await import("./sql-D0fBjQXA.js");return{sqlite:o}},[],import.meta.url)).sqlite,"text/x-squirrel":async()=>(await Z(async()=>{const{squirrel:o}=await import("./clike-C67HaMJ3.js");return{squirrel:o}},[],import.meta.url)).squirrel,"text/x-stex":async()=>(await Z(async()=>{const{stex:o}=await import("./stex-Du4h4KAU.js");return{stex:o}},[],import.meta.url)).stex,"text/x-stsrc":async()=>(await Z(async()=>{const{smalltalk:o}=await import("./smalltalk-Bhddl2pB.js");return{smalltalk:o}},[],import.meta.url)).smalltalk,"text/x-styl":async()=>(await Z(async()=>{const{stylus:o}=await import("./stylus-CAdqWld3.js");return{stylus:o}},[],import.meta.url)).stylus,"text/x-swift":async()=>(await Z(async()=>{const{swift:o}=await import("./swift-DSxqR9R6.js");return{swift:o}},[],import.meta.url)).swift,"text/x-systemverilog":async()=>(await Z(async()=>{const{verilog:o}=await import("./verilog-CiS1jyi5.js");return{verilog:o}},[],import.meta.url)).verilog,"text/x-tcl":async()=>(await Z(async()=>{const{tcl:o}=await import("./tcl-xfoLljhY.js");return{tcl:o}},[],import.meta.url)).tcl,"text/x-textile":async()=>(await Z(async()=>{const{textile:o}=await import("./textile-D1AWE-pc.js");return{textile:o}},[],import.meta.url)).textile,"text/x-tiddlywiki":async()=>(await Z(async()=>{const{tiddlyWiki:o}=await import("./tiddlywiki-5wqsXtSk.js");return{tiddlyWiki:o}},[],import.meta.url)).tiddlyWiki,"text/x-toml":async()=>(await Z(async()=>{const{toml:o}=await import("./toml-BHiuTcfn.js");return{toml:o}},[],import.meta.url)).toml,"text/x-tornado":null,"text/x-ttcn-asn":async()=>(await Z(async()=>{const{ttcn:o}=await import("./ttcn-Bsa4sfRm.js");return{ttcn:o}},[],import.meta.url)).ttcn,"text/x-ttcn-cfg":async()=>(await Z(async()=>{const{ttcnCfg:o}=await import("./ttcn-cfg-Bac_acMi.js");return{ttcnCfg:o}},[],import.meta.url)).ttcnCfg,"text/x-ttcn":async()=>(await Z(async()=>{const{ttcn:o}=await import("./ttcn-Bsa4sfRm.js");return{ttcn:o}},[],import.meta.url)).ttcn,"text/x-twig":async()=>(await Z(async()=>{const{twig:o}=await import("./index-BVDyGn0z.js");return{twig:o}},__vite__mapDeps([41,19,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).twig(),"text/x-vb":async()=>(await Z(async()=>{const{vb:o}=await import("./vb-c2kQGd6-.js");return{vb:o}},[],import.meta.url)).vb,"text/x-verilog":async()=>(await Z(async()=>{const{verilog:o}=await import("./verilog-CiS1jyi5.js");return{verilog:o}},[],import.meta.url)).verilog,"text/x-vhdl":async()=>(await Z(async()=>{const{vhdl:o}=await import("./vhdl-T9HkrbI2.js");return{vhdl:o}},[],import.meta.url)).vhdl,"text/x-vue":async()=>(await Z(async()=>{const{vue:o}=await import("./index-Byvc7VQm.js");return{vue:o}},__vite__mapDeps([42,27,19,26,3,2,4,5,1,6,7,9,10,11,12,18,20]),import.meta.url)).vue(),"text/x-webidl":async()=>(await Z(async()=>{const{webIDL:o}=await import("./webidl-CjfDENEo.js");return{webIDL:o}},[],import.meta.url)).webIDL,"text/x-xu":async()=>(await Z(async()=>{const{xu:o}=await import("./mscgen-Cpl0NYLN.js");return{xu:o}},[],import.meta.url)).xu,"text/x-yacas":async()=>(await Z(async()=>{const{yacas:o}=await import("./yacas-C0absKBh.js");return{yacas:o}},[],import.meta.url)).yacas,"text/x-yaml":async()=>(await Z(async()=>{const{yaml:o}=await import("./yaml-Dt6Tp2eU.js");return{yaml:o}},[],import.meta.url)).yaml,"text/x-z80":async()=>(await Z(async()=>{const{z80:o}=await import("./z80-Pki2zAjW.js");return{z80:o}},[],import.meta.url)).z80,"text/xml":async()=>(await Z(async()=>{const{xml:o}=await import("./index-Dqpe0q7-.js");return{xml:o}},__vite__mapDeps([43,19,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).xml()},F$=[{key:"Tab",run({state:o,dispatch:t}){if(o.facet(ve.readOnly))return!1;const{selection:e}=o;if(e.ranges.some(i=>!i.empty)){const i=new Set;for(const n of e.ranges){const s=o.doc.lineAt(n.from),a=o.doc.lineAt(n.to);for(let l=s.number;l<=a.number;l++)i.add(l)}return i.size>1?ql({state:o,dispatch:t}):W$(o,t)}return H$(o,t)},shift:Nh}];function W$(o,t){const e=[],i=[];for(let n of o.selection.ranges)e.push({from:n.from,to:n.to,insert:" "}),i.push(xt.cursor(n.from+1));return t(o.update({changes:e,selection:xt.create(i),scrollIntoView:!0,userEvent:"input"})),!0}function H$(o,t){const e=[],i=[];for(let n of o.selection.ranges){const s=o.doc.lineAt(n.head),a=o.doc.sliceString(s.from,n.head);if(/^\s*$/.test(a))return ql({state:o,dispatch:t});e.push({from:n.head,to:n.head,insert:" "}),i.push(xt.cursor(n.head+1))}return e.length?(t(o.update({changes:e,selection:xt.create(i),scrollIntoView:!0,userEvent:"input"})),!0):!1}const V$=Yt.mark({class:"cm-searchMatch"}),U$=Yt.mark({class:"cm-activeMatch"});var gr,Kd,Hv;class Vv{constructor(t){qf(this,gr),xi(this,"matches"),xi(this,"activeMatch"),xi(this,"currentFound"),xi(this,"totalFound"),xi(this,"matcher"),xi(this,"searchRegexp"),xi(this,"parsedMatches"),this.view=t,this.parsedMatches=[],this.currentFound=0,this.totalFound=0,this.matches=ue.empty}searchFor(t,e,i){if(!t){this.matches=ue.empty;return}const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=i?"\\b":"",a=e?"g":"gi",l=new RegExp(`${s}${n}${s}`,a);this.matcher=new Dx({regexp:l,decoration:V$}),this.searchRegexp=l,Ya(this,gr,Kd).call(this,this.view),Ya(this,gr,Hv).call(this)}replaceActiveMatch(t){if(!this.parsedMatches.length||this.currentFound===0)return;const e=this.currentFound-1,i=this.parsedMatches[e];this.view.dispatch({changes:{from:i.from,to:i.to,insert:t}})}replaceAll(t){this.parsedMatches.length&&this.view.dispatch({changes:this.parsedMatches.map(e=>({from:e.from,to:e.to,insert:t}))})}scrollToMatch(t){if(this.parsedMatches.length<=t)return;const e=this.parsedMatches[t];this.currentFound=t+1,this.activeMatch=U$.range(e.from,e.to);const i=[],n=this.view.state.field(Es).iter();for(;n.value;)e.from>=n.from&&e.to<=n.to&&i.push(Fl.of({from:n.from,to:n.to})),n.next();this.view.dispatch({effects:[...i,Wt.scrollIntoView(e.from,{y:"center"})],scrollIntoView:!0})}update(t){(t.docChanged||t.viewportChanged)&&Ya(this,gr,Kd).call(this,t.view)}destroy(){}}gr=new WeakSet,Kd=function(o){var t;if(!this.matcher)return;this.matches=this.matcher.createDeco(o);const e=[],i=o.state.doc.toString();let n;for(;n=(t=this.searchRegexp)==null?void 0:t.exec(i);){const s=n.index??0,a=s+n[0].length;e.push({from:s,to:a})}this.parsedMatches=e,this.totalFound=this.parsedMatches.length},Hv=function(){const o=this.view.state.selection.main.head;let t=0;for(const e of this.parsedMatches){if(e.from>=o){this.scrollToMatch(t);return}t++}},xi(Vv,"deco",o=>o.matches);function j$(){return ti.fromClass(Vv,{decorations:o=>o.activeMatch?o.matches.update({add:[o.activeMatch]}):o.matches})}const q$=Wt.baseTheme({".cm-searchMatch":{backgroundColor:"rgba(255, 255, 0, 0.4)",borderRadius:"2px"},".cm-activeMatch":{backgroundColor:"rgba(255, 165, 0, 0.6)",borderRadius:"2px",outline:"2px solid orange"}}),Uv=[{id:"abyss",name:"Abyss",load:async()=>(await Z(async()=>{const{abyss:o}=await import("./index-BDUNLGjv.js");return{abyss:o}},__vite__mapDeps([44,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).abyss},{id:"abcdef",name:"ABCDEF",load:async()=>(await Z(async()=>{const{abcdef:o}=await import("./index-xqhK_p3_.js");return{abcdef:o}},__vite__mapDeps([45,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).abcdef},{id:"android-studio",name:"Android Studio",load:async()=>(await Z(async()=>{const{androidStudio:o}=await import("./index-Co2ZowoL.js");return{androidStudio:o}},__vite__mapDeps([46,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).androidStudio},{id:"andromeda",name:"Andromeda",load:async()=>(await Z(async()=>{const{andromeda:o}=await import("./index-m6eB99Pt.js");return{andromeda:o}},__vite__mapDeps([47,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).andromeda},{id:"basic-dark",name:"Basic Dark",load:async()=>(await Z(async()=>{const{basicDark:o}=await import("./index-CtyT9BpA.js");return{basicDark:o}},__vite__mapDeps([48,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).basicDark},{id:"basic-light",name:"Basic Light",load:async()=>(await Z(async()=>{const{basicLight:o}=await import("./index-DzzK8sxM.js");return{basicLight:o}},__vite__mapDeps([49,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).basicLight},{id:"forest",name:"Forest",load:async()=>(await Z(async()=>{const{forest:o}=await import("./index-BsQdGQZO.js");return{forest:o}},__vite__mapDeps([50,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).forest},{id:"github-dark",name:"GitHub Dark",load:async()=>(await Z(async()=>{const{githubDark:o}=await import("./index-BNHmbid4.js");return{githubDark:o}},__vite__mapDeps([51,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).githubDark},{id:"github-light",name:"GitHub Light",load:async()=>(await Z(async()=>{const{githubLight:o}=await import("./index-B-_mzY9b.js");return{githubLight:o}},__vite__mapDeps([52,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).githubLight},{id:"gruvbox-dark",name:"Gruvbox Dark",load:async()=>(await Z(async()=>{const{gruvboxDark:o}=await import("./index-BQbQdyQd.js");return{gruvboxDark:o}},__vite__mapDeps([53,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).gruvboxDark},{id:"gruvbox-light",name:"Gruvbox Light",load:async()=>(await Z(async()=>{const{gruvboxLight:o}=await import("./index-CkgmqLZz.js");return{gruvboxLight:o}},__vite__mapDeps([54,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).gruvboxLight},{id:"material-mark",name:"Material Dark",load:async()=>(await Z(async()=>{const{materialDark:o}=await import("./index-B7IbnQNR.js");return{materialDark:o}},__vite__mapDeps([55,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).materialDark},{id:"material-light",name:"Material Light",load:async()=>(await Z(async()=>{const{materialLight:o}=await import("./index-F9F1O8fB.js");return{materialLight:o}},__vite__mapDeps([56,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).materialLight},{id:"monokai",name:"Monokai",load:async()=>(await Z(async()=>{const{monokai:o}=await import("./index-C-bZr3zn.js");return{monokai:o}},__vite__mapDeps([57,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).monokai},{id:"nord",name:"Nord",load:async()=>(await Z(async()=>{const{nord:o}=await import("./index-CGkKWkW-.js");return{nord:o}},__vite__mapDeps([58,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).nord},{id:"palenight",name:"Palenight",load:async()=>(await Z(async()=>{const{palenight:o}=await import("./index-C83-juky.js");return{palenight:o}},__vite__mapDeps([59,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).palenight},{id:"solarized-dark",name:"Solarized Dark",load:async()=>(await Z(async()=>{const{solarizedDark:o}=await import("./index-BLvbl8ks.js");return{solarizedDark:o}},__vite__mapDeps([60,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).solarizedDark},{id:"solarized-light",name:"Solarized Light",load:async()=>(await Z(async()=>{const{solarizedLight:o}=await import("./index-Bm2pFVA9.js");return{solarizedLight:o}},__vite__mapDeps([61,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).solarizedLight},{id:"tokyo-night-day",name:"Tokyo Night Day",load:async()=>(await Z(async()=>{const{tokyoNightDay:o}=await import("./index-gs0O0rSY.js");return{tokyoNightDay:o}},__vite__mapDeps([62,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).tokyoNightDay},{id:"tokyo-night-storm",name:"Tokyo Night Storm",load:async()=>(await Z(async()=>{const{tokyoNightStorm:o}=await import("./index-BEqJy_lh.js");return{tokyoNightStorm:o}},__vite__mapDeps([63,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).tokyoNightStorm},{id:"volcano",name:"Volcano",load:async()=>(await Z(async()=>{const{volcano:o}=await import("./index-Dw3iqOwU.js");return{volcano:o}},__vite__mapDeps([64,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).volcano},{id:"vs-code-dark",name:"VS Code Dark",load:async()=>(await Z(async()=>{const{vsCodeDark:o}=await import("./index-CWDzYz2u.js");return{vsCodeDark:o}},__vite__mapDeps([65,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).vsCodeDark},{id:"vs-code-light",name:"VS Code Light",load:async()=>(await Z(async()=>{const{vsCodeLight:o}=await import("./index-CSTtsAHM.js");return{vsCodeLight:o}},__vite__mapDeps([66,3,2,4,5,1,6,7,9,10,11,12]),import.meta.url)).vsCodeLight}];function Zd(o){for(const t of Uv)if(t.id===o)return t;return null}var Gd,jv;class qv extends Wt{constructor(t){const e=new Xn,i=new Xn,n=new Xn,s=new Xn,a=new Xn;let l=[];t.vimKeybindings&&l.push(m$()),l=[...l,e.of([]),s.of(t.lineWrapping?Wt.lineWrapping:[]),q$,a.of([]),Rx(),r0(),Ts.of(" ".repeat(4)),dg.of([...TC,...Bk,...F$])],t.preferPerformance||(l=[...l,n.of([tk(nk,{fallback:!0})]),LC(),dk(),_h(),Q0(),x$()]),t.readOnly?l.push(ve.readOnly.of(!0)):(t.placeholder&&l.push(Wx(t.placeholder)),t.onContentChanged&&l.push(Wt.updateListener.of(c=>Ya(this,Gd,jv).call(this,c))),l.push(i.of(Kp()))),super({parent:t.parent,extensions:l}),qf(this,Gd),xi(this,"config"),xi(this,"languageCompartment"),xi(this,"historyCompartment"),xi(this,"themeCompartment"),xi(this,"lineWrappingCompartment"),xi(this,"searchHighlightCompartment"),xi(this,"searchPlugin"),t.tabIndex&&(this.dom.tabIndex=t.tabIndex),this.config=t,this.languageCompartment=e,this.historyCompartment=i,this.themeCompartment=n,this.lineWrappingCompartment=s,this.searchHighlightCompartment=a}getText(){return this.state.doc.toString()}getSelectedText(){return this.state.selection.ranges.map(t=>this.state.sliceDoc(t.from,t.to)).join("")}setText(t){this.dispatch({changes:{from:0,to:this.state.doc.length,insert:t||""}})}async setTheme(t){const e=await t.load();this.dispatch({effects:[this.themeCompartment.reconfigure([e])]})}setLineWrapping(t){this.dispatch({effects:[this.lineWrappingCompartment.reconfigure(t?Wt.lineWrapping:[])]})}clearHistory(){this.config.readOnly||(this.dispatch({effects:[this.historyCompartment.reconfigure([])]}),this.dispatch({effects:[this.historyCompartment.reconfigure(Kp())]}))}scrollToEnd(){const t=this.state.doc.length;this.dispatch({selection:xt.cursor(t),effects:Wt.scrollIntoView(t,{y:"end"}),scrollIntoView:!0})}async performFind(t,e,i){const n=j$();this.dispatch({effects:this.searchHighlightCompartment.reconfigure(n)}),await new Promise(requestAnimationFrame);const s=this.plugin(n);return s?.searchFor(t,e,i),this.searchPlugin=s,{totalFound:s?.totalFound??0,currentFound:s?.currentFound??0}}async findNext(t,e,i){var n;(n=this.searchPlugin)==null||n.scrollToMatch(i)}async replace(t){var e;(e=this.searchPlugin)==null||e.replaceActiveMatch(t)}async replaceAll(t){var e;(e=this.searchPlugin)==null||e.replaceAll(t)}cleanSearch(){this.searchPlugin&&(this.dispatch({effects:this.searchHighlightCompartment.reconfigure([])}),this.searchPlugin=null)}async setMimeType(t){let e=[];const i=z$[t];if(i){const n=await i();if("token"in n){const s=kh.define(n);e.push(s)}else Array.isArray(n)?e=[...e,...n]:e.push(n)}this.dispatch({effects:this.languageCompartment.reconfigure(e)})}}Gd=new WeakSet,jv=function(o){var t,e;o.docChanged&&((e=(t=this.config).onContentChanged)==null||e.call(t))};const fs="default:";class Rh extends Ue{$editor;codeEditor;doRender(){this.initialized=this.#t()}async#t(){this.codeEditor=new qv({parent:this.$editor[0],lineWrapping:Qt.is("codeLineWrapEnabled"),...this.getExtraOpts()});const t=Qt.get("codeNoteTheme");if(t?.startsWith(fs)){const e=Zd(t.substring(fs.length));e&&await this.codeEditor.setTheme(e)}}getExtraOpts(){return{}}onEditorInitialized(){}_update(t,e){this.codeEditor.setText(e),this.codeEditor.setMimeType(t.mime),this.codeEditor.clearHistory()}show(){this.$widget.show(),this.updateBackgroundColor()}focus(){this.codeEditor.focus()}scrollToEnd(){this.codeEditor.scrollToEnd(),this.codeEditor.focus()}cleanup(){this.codeEditor&&this.spacedUpdate.allowUpdateWithoutChange(()=>{this.codeEditor.setText("")}),this.updateBackgroundColor("unset")}async executeWithCodeEditorEvent({resolve:t,ntxId:e}){this.isNoteContext(e)&&(await this.initialized,t(this.codeEditor))}async entitiesReloadedEvent({loadResults:t}){if(t.isOptionReloaded("codeNoteTheme")){const e=Qt.get("codeNoteTheme");if(e?.startsWith(fs)){const i=Zd(e.substring(fs.length));i&&await this.codeEditor.setTheme(i),this.updateBackgroundColor()}}t.isOptionReloaded("codeLineWrapEnabled")&&this.codeEditor.setLineWrapping(Qt.is("codeLineWrapEnabled"))}updateBackgroundColor(t){if(this.note?.mime==="text/x-sqlite;schema=trilium")return;const e=$(this.codeEditor.dom);this.$widget.closest(".scrolling-container").css("background-color",t??e.css("background-color"))}}const K$=`
|
||
<div class="note-detail-code note-detail-printable">
|
||
<style>
|
||
.note-detail-code {
|
||
position: relative;
|
||
height: 100%;
|
||
}
|
||
|
||
.note-detail-code-editor {
|
||
min-height: 50px;
|
||
height: 100%;
|
||
}
|
||
</style>
|
||
|
||
<div class="note-detail-code-editor"></div>
|
||
</div>`;class Kv extends Rh{static getType(){return"editableCode"}doRender(){this.$widget=$(K$),this.contentSized(),this.$editor=this.$widget.find(".note-detail-code-editor"),qo.setupActionsForElement("code-detail",this.$widget,this),super.doRender()}getExtraOpts(){return{placeholder:m("editable_code.placeholder"),vimKeybindings:Qt.is("vimKeymapEnabled"),onContentChanged:()=>this.spacedUpdate.scheduleUpdate(),tabIndex:300}}async doRefresh(t){const e=await this.note?.getBlob();await this.spacedUpdate.allowUpdateWithoutChange(()=>{this._update(t,e?.content??"")}),this.show(),this.parent&&Sr&&this.triggerCommand("refreshTouchBar")}getData(){return{content:this.codeEditor.getText()}}buildTouchBarCommand({TouchBar:t,buildIcon:e}){const i=[],n=this.note;return(n?.mime.startsWith("application/javascript")||n?.mime==="text/x-sqlite;schema=trilium")&&i.push(new t.TouchBarButton({icon:e("NSImageNameTouchBarPlayTemplate"),click:()=>Pt.triggerCommand("runActiveNote")})),i}}const Zv=5e3,Z$=`
|
||
<div class="note-detail-file note-detail-printable">
|
||
<style>
|
||
.type-file .note-detail {
|
||
height: 100%;
|
||
}
|
||
|
||
.note-detail-file {
|
||
padding: 10px;
|
||
height: 100%;
|
||
}
|
||
|
||
.note-split.full-content-width .note-detail-file {
|
||
padding: 0;
|
||
}
|
||
|
||
.note-split.full-content-width .note-detail-file[data-preview-type="video"] {
|
||
overflow: hidden;
|
||
}
|
||
|
||
.file-preview-content {
|
||
background-color: var(--accented-background-color);
|
||
padding: 15px;
|
||
height: 100%;
|
||
overflow: auto;
|
||
margin: 10px;
|
||
}
|
||
|
||
.note-detail-file > .video-preview {
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
</style>
|
||
|
||
<div class="file-preview-too-big alert alert-info hidden-ext">
|
||
${m("file.too_big",{maxNumChars:Zv})}
|
||
</div>
|
||
|
||
<pre class="file-preview-content"></pre>
|
||
|
||
<div class="file-preview-not-available alert alert-info">
|
||
${m("file.file_preview_not_available")}
|
||
</div>
|
||
|
||
<iframe class="pdf-preview" style="width: 100%; height: 100%; flex-grow: 100;"></iframe>
|
||
|
||
<video class="video-preview" controls></video>
|
||
|
||
<audio class="audio-preview" controls></audio>
|
||
</div>`;class G$ extends Ue{$previewContent;$previewNotAvailable;$previewTooBig;$pdfPreview;$videoPreview;$audioPreview;static getType(){return"file"}doRender(){this.$widget=$(Z$),this.$previewContent=this.$widget.find(".file-preview-content"),this.$previewNotAvailable=this.$widget.find(".file-preview-not-available"),this.$previewTooBig=this.$widget.find(".file-preview-too-big"),this.$pdfPreview=this.$widget.find(".pdf-preview"),this.$videoPreview=this.$widget.find(".video-preview"),this.$audioPreview=this.$widget.find(".audio-preview"),super.doRender()}async doRefresh(t){this.$widget.show();const e=await this.note?.getBlob();this.$previewContent.empty().hide(),this.$pdfPreview.attr("src","").empty().hide(),this.$previewNotAvailable.hide(),this.$previewTooBig.addClass("hidden-ext"),this.$videoPreview.hide(),this.$audioPreview.hide();let i;if(e?.content){this.$previewContent.show().scrollTop(0);const n=e.content.substring(0,Zv);n.length!==e.content.length&&this.$previewTooBig.removeClass("hidden-ext"),this.$previewContent.text(n),i="text"}else t.mime==="application/pdf"?(this.$pdfPreview.show().attr("src",en.getUrlForDownload(`api/notes/${this.noteId}/open`)),i="pdf"):t.mime.startsWith("video/")?(this.$videoPreview.show().attr("src",en.getUrlForDownload(`api/notes/${this.noteId}/open-partial`)).attr("type",this.note?.mime??"").css("width",this.$widget.width()??0),i="video"):t.mime.startsWith("audio/")?(this.$audioPreview.show().attr("src",en.getUrlForDownload(`api/notes/${this.noteId}/open-partial`)).attr("type",this.note?.mime??"").css("width",this.$widget.width()??0),i="audio"):(this.$previewNotAvailable.show(),i="not-available");this.$widget.attr("data-preview-type",i??"")}async entitiesReloadedEvent({loadResults:t}){t.isNoteReloaded(this.noteId)&&this.refresh()}}const Y$=`
|
||
<div class="note-detail-image note-detail-printable">
|
||
<style>
|
||
.type-image .note-detail {
|
||
height: 100%;
|
||
}
|
||
|
||
.note-detail-image {
|
||
height: 100%;
|
||
}
|
||
|
||
.note-detail-image-wrapper {
|
||
position: relative;
|
||
display: flex;
|
||
align-items: center;
|
||
overflow: hidden;
|
||
justify-content: center;
|
||
height: 100%;
|
||
}
|
||
|
||
.note-detail-image-view {
|
||
display: block;
|
||
width: auto;
|
||
height: auto;
|
||
align-self: center;
|
||
flex-shrink: 0;
|
||
}
|
||
</style>
|
||
|
||
<div class="note-detail-image-wrapper">
|
||
<img class="note-detail-image-view" />
|
||
</div>
|
||
</div>`;class J$ extends Ue{$imageWrapper;$imageView;static getType(){return"image"}doRender(){this.$widget=$(Y$),this.$imageWrapper=this.$widget.find(".note-detail-image-wrapper"),this.$imageView=this.$widget.find(".note-detail-image-view").attr("id",`image-view-${ct.randomString(10)}`);const t=async()=>{document.querySelector(`#${this.$imageView.attr("id")}`)?pb.create(`#${this.$imageView.attr("id")}`,{maxScale:50,speed:1.3,zoomOnClick:!1}):requestAnimationFrame(t)};t(),ub.setupContextMenu(this.$imageView),super.doRender()}async doRefresh(t){this.$imageView.prop("src",ct.createImageSrcUrl(t))}copyImageReferenceToClipboardEvent({ntxId:t}){this.isNoteContext(t)&&Df.copyImageReferenceToClipboard(this.$imageWrapper)}async entitiesReloadedEvent({loadResults:t}){t.isNoteReloaded(this.noteId)&&this.refresh()}}const Q$=`
|
||
<div class="note-detail-render note-detail-printable">
|
||
<style>
|
||
.note-detail-render {
|
||
position: relative;
|
||
}
|
||
</style>
|
||
|
||
<div class="note-detail-render-help alert alert-warning" style="margin: 50px; padding: 20px;">
|
||
<p><strong>${m("render.note_detail_render_help_1")}</strong></p>
|
||
|
||
<p>${m("render.note_detail_render_help_2")}</p>
|
||
</div>
|
||
|
||
<div class="note-detail-render-content"></div>
|
||
</div>`;class X$ extends Ue{$noteDetailRenderHelp;$noteDetailRenderContent;static getType(){return"render"}doRender(){this.$widget=$(Q$),this.$noteDetailRenderHelp=this.$widget.find(".note-detail-render-help"),this.$noteDetailRenderContent=this.$widget.find(".note-detail-render-content"),super.doRender()}async doRefresh(t){this.$widget.show(),this.$noteDetailRenderHelp.hide(),await fb.render(t,this.$noteDetailRenderContent)||this.$noteDetailRenderHelp.show()}cleanup(){this.$noteDetailRenderContent.empty()}renderActiveNoteEvent(){this.noteContext?.isActive()&&this.refresh()}async executeWithContentElementEvent({resolve:t,ntxId:e}){this.isNoteContext(e)&&(await this.initialized,t(this.$noteDetailRenderContent))}}const pf=[["Arrow",{location:1,id:"arrow",length:14,foldback:.8}],["Label",{label:"",id:"label",cssClass:"connection-label"}]],t1=[["Arrow",{location:1,id:"arrow",length:14,foldback:.8}],["Label",{label:"",id:"label",cssClass:"connection-label"}],["Arrow",{location:0,id:"arrow2",length:14,direction:-1,foldback:.8}]],e1=[["Arrow",{location:1,id:"arrow",length:14,foldback:.8}],["Label",{label:"",location:.2,id:"label-source",cssClass:"connection-label"}],["Label",{label:"",location:.8,id:"label-target",cssClass:"connection-label"}],["Arrow",{location:0,id:"arrow2",length:14,direction:-1,foldback:.8}]],i1=[["Arrow",{location:1,id:"arrow",length:14,foldback:.8}]],n1=`
|
||
<div class="note-detail-relation-map note-detail-printable">
|
||
<div class="relation-map-wrapper">
|
||
<div class="relation-map-container"></div>
|
||
</div>
|
||
</div>`;let o1=1;class s1 extends Ue{clipboard;jsPlumbInstance;pzInstance;mapData;relations;$relationMapContainer;$relationMapWrapper;static getType(){return"relationMap"}doRender(){this.$widget=$(n1),this.$relationMapContainer=this.$widget.find(".relation-map-container"),this.mapData=null,this.jsPlumbInstance=null,this.relations=null,this.pzInstance=null,this.$relationMapWrapper=this.$widget.find(".relation-map-wrapper"),this.$relationMapWrapper.on("click",t=>{if(this.clipboard&&this.mapData){let{x:e,y:i}=this.getMousePosition(t);e-=80,i-=15,this.createNoteBox(this.clipboard.noteId,this.clipboard.title,e,i),this.mapData.notes.push({noteId:this.clipboard.noteId,x:e,y:i}),this.saveData(),this.clipboard=null}return!0}),this.$relationMapContainer.attr("id","relation-map-container-"+o1++),this.$relationMapContainer.on("contextmenu",".note-box",t=>(Ho.show({x:t.pageX,y:t.pageY,items:[{title:m("relation_map.open_in_new_tab"),command:"openInNewTab",uiIcon:"bx bx-empty"},{title:m("relation_map.remove_note"),command:"remove",uiIcon:"bx bx-trash"},{title:m("relation_map.edit_title"),command:"editTitle",uiIcon:"bx bx-pencil"}],selectMenuItemHandler:({command:e})=>this.contextMenuHandler(e,t.target)}),!1)),this.clipboard=null,this.$widget.on("drop",t=>this.dropNoteOntoRelationMapHandler(t)),this.$widget.on("dragover",t=>t.preventDefault()),this.initialized=new Promise(async t=>{(await Z(async()=>{const{default:i}=await import("./jsplumb.js").then(n=>n.j);return{default:i}},__vite__mapDeps([67,5]),import.meta.url)).default.jsPlumb.ready(t)}),super.doRender()}async contextMenuHandler(t,e){const i=$(e).closest(".note-box"),n=i.find(".title a"),s=this.idToNoteId(i.prop("id"));if(t==="openInNewTab")Pt.tabManager.openTabWithNoteWithHoisting(s);else if(t==="remove"){const a=await Me.confirmDeleteNoteBoxWithNote(n.text());if(typeof a!="object"||!a.confirmed)return;if(this.jsPlumbInstance?.remove(this.noteIdToId(s)),a.isDeleteNoteChecked){const l=ct.randomString(10);await pt.remove(`notes/${s}?taskId=${l}&last=true`)}this.mapData&&(this.mapData.notes=this.mapData.notes.filter(l=>l.noteId!==s)),this.relations&&(this.relations=this.relations.filter(l=>l.sourceNoteId!==s&&l.targetNoteId!==s)),this.saveData()}else if(t==="editTitle"){const a=await Me.prompt({title:m("relation_map.rename_note"),message:m("relation_map.enter_new_title"),defaultValue:n.text()});if(!a)return;await pt.put(`notes/${s}/title`,{title:a}),n.text(a)}}async loadMapData(){this.mapData={notes:[],transform:{x:0,y:0,scale:1}};const t=await this.note?.getBlob();if(t?.content)try{this.mapData=JSON.parse(t.content)}catch(e){console.log("Could not parse content: ",e)}}noteIdToId(t){return`rel-map-note-${t}`}idToNoteId(t){return t.substr(13)}async doRefresh(t){await this.loadMapData(),await this.initJsPlumbInstance(),await this.initPanZoom(),this.loadNotesAndRelations()}clearMap(){this.jsPlumbInstance?.deleteEveryEndpoint(),this.$relationMapContainer.empty()}async loadNotesAndRelations(){if(!this.mapData||!this.jsPlumbInstance)return;const t=this.mapData.notes.map(i=>i.noteId),e=await pt.post("relation-map",{noteIds:t,relationMapNoteId:this.noteId});this.relations=[];for(const i of e.relations){const n=this.relations.find(s=>s.name===e.inverseRelations[i.name]&&(s.sourceNoteId===i.sourceNoteId&&s.targetNoteId===i.targetNoteId||s.sourceNoteId===i.targetNoteId&&s.targetNoteId===i.sourceNoteId));n?(n.type=i.type=i.name===e.inverseRelations[i.name]?"biDirectional":"inverse",i.render=!1):(i.type="uniDirectional",i.render=!0),this.relations.push(i)}this.mapData.notes=this.mapData.notes.filter(i=>i.noteId in e.noteTitles),this.jsPlumbInstance.batch(async()=>{if(!(!this.jsPlumbInstance||!this.mapData||!this.relations)){this.clearMap();for(const i of this.mapData.notes){const n=e.noteTitles[i.noteId];await this.createNoteBox(i.noteId,n,i.x,i.y)}for(const i of this.relations){if(!i.render)continue;const n=this.jsPlumbInstance.connect({source:this.noteIdToId(i.sourceNoteId),target:this.noteIdToId(i.targetNoteId),type:i.type});n.id=i.attributeId,i.type==="inverse"?(n.getOverlay("label-source").setLabel(i.name),n.getOverlay("label-target").setLabel(e.inverseRelations[i.name])):n.getOverlay("label").setLabel(i.name),n.canvas.setAttribute("data-connection-id",n.id)}}})}async initPanZoom(){if(this.pzInstance)return;const t=(await Z(async()=>{const{default:e}=await import("./index7.js").then(i=>i.i);return{default:e}},__vite__mapDeps([68,5]),import.meta.url)).default;this.pzInstance=t(this.$relationMapContainer[0],{maxZoom:2,minZoom:.3,smoothScroll:!1,filterKey:function(e){return e.altKey}}),this.pzInstance&&(this.pzInstance.on("transform",()=>{this.jsPlumbInstance?.setZoom(this.getZoom()),this.saveCurrentTransform()}),this.mapData?.transform?(this.pzInstance.zoomTo(0,0,this.mapData.transform.scale),this.pzInstance.moveTo(this.mapData.transform.x,this.mapData.transform.y)):this.pzInstance.moveTo(0,0))}saveCurrentTransform(){if(!this.pzInstance)return;const t=this.pzInstance.getTransform();this.mapData&&JSON.stringify(t)!==JSON.stringify(this.mapData.transform)&&(this.mapData.transform=JSON.parse(JSON.stringify(t)),this.saveData())}cleanup(){this.jsPlumbInstance&&this.clearMap(),this.pzInstance&&(this.pzInstance.dispose(),this.pzInstance=null)}async initJsPlumbInstance(){if(this.jsPlumbInstance){this.cleanup();return}const t=(await Z(async()=>{const{default:e}=await import("./jsplumb.js").then(i=>i.j);return{default:e}},__vite__mapDeps([67,5]),import.meta.url)).default.jsPlumb;this.jsPlumbInstance=t.getInstance({Endpoint:["Dot",{radius:2}],Connector:"StateMachine",ConnectionOverlays:pf,HoverPaintStyle:{stroke:"#777",strokeWidth:1},Container:this.$relationMapContainer.attr("id")}),this.jsPlumbInstance&&(this.jsPlumbInstance.registerConnectionType("uniDirectional",{anchor:"Continuous",connector:"StateMachine",overlays:pf}),this.jsPlumbInstance.registerConnectionType("biDirectional",{anchor:"Continuous",connector:"StateMachine",overlays:t1}),this.jsPlumbInstance.registerConnectionType("inverse",{anchor:"Continuous",connector:"StateMachine",overlays:e1}),this.jsPlumbInstance.registerConnectionType("link",{anchor:"Continuous",connector:"StateMachine",overlays:i1}),this.jsPlumbInstance.bind("connection",(e,i)=>this.connectionCreatedHandler(e,i)))}async connectionCreatedHandler(t,e){const i=t.connection;if(i.bind("contextmenu",(c,u)=>{i.getType().includes("link")?u.preventDefault():(u.preventDefault(),u.stopPropagation(),Ho.show({x:u.pageX,y:u.pageY,items:[{title:m("relation_map.remove_relation"),command:"remove",uiIcon:"bx bx-trash"}],selectMenuItemHandler:async({command:p})=>{if(p==="remove"){if(!await Me.confirm(m("relation_map.confirm_remove_relation"))||!this.relations)return;const v=this.relations.find(x=>x.attributeId===i.id);v&&await pt.remove(`notes/${v.sourceNoteId}/relations/${v.name}/to/${v.targetNoteId}`),this.jsPlumbInstance?.deleteConnection(i),this.relations=this.relations.filter(x=>x.attributeId!==i.id)}}}))}),!e||!this.jsPlumbInstance)return;let n=await Me.prompt({message:m("relation_map.specify_new_relation_name"),shown:({$answer:c})=>{c&&(c.on("keyup",()=>{const u=ct.filterAttributeName(c.val());c.val(u)}),fw.initAttributeNameAutocomplete({$el:c,attributeType:"relation",open:!0}))}});if(!n||!n.trim()){this.jsPlumbInstance.deleteConnection(i);return}n=ct.filterAttributeName(n);const s=this.idToNoteId(i.target.id),a=this.idToNoteId(i.source.id);if(this.relations?.some(c=>c.targetNoteId===s&&c.sourceNoteId===a&&c.name===n)){await Me.info(m("relation_map.connection_exists",{name:n})),this.jsPlumbInstance.deleteConnection(i);return}await pt.put(`notes/${a}/relations/${n}/to/${s}`),this.loadNotesAndRelations()}saveData(){this.spacedUpdate.scheduleUpdate()}async createNoteBox(t,e,i,n){if(!this.jsPlumbInstance)return;const s=await Pe.createLink(t,{title:e});s.mousedown(c=>Pe.goToLink(c));const a=await Mt.getNote(t);if(!a)return;const l=$("<div>").addClass("note-box").addClass(a.getCssClass()).prop("id",this.noteIdToId(t)).append($("<span>").addClass("title").append(s)).append($("<div>").addClass("endpoint").attr("title",m("relation_map.start_dragging_relations"))).css("left",`${i}px`).css("top",`${n}px`);this.jsPlumbInstance.getContainer().appendChild(l[0]),this.jsPlumbInstance.draggable(l[0],{start:c=>{},drag:c=>{},stop:c=>{const u=this.idToNoteId(c.el.id),p=this.mapData?.notes.find(v=>v.noteId===u);if(!p){logError(m("relation_map.note_not_found",{noteId:u}));return}[p.x,p.y]=c.finalPos,this.saveData()}}),this.jsPlumbInstance.makeSource(l[0],{filter:".endpoint",anchor:"Continuous",connectorStyle:{stroke:"#000",strokeWidth:1},connectionType:"basic",extract:{action:"the-action"}}),this.jsPlumbInstance.makeTarget(l[0],{dropOptions:{hoverClass:"dragHover"},anchor:"Continuous",allowLoopback:!0})}getZoom(){const t=/matrix\((-?\d*\.?\d+),\s*0,\s*0,\s*-?\d*\.?\d+,\s*-?\d*\.?\d+,\s*-?\d*\.?\d+\)/,e=this.$relationMapContainer.css("transform");if(e==="none")return 1;const i=e.match(t);if(!i)throw new Error(m("relation_map.cannot_match_transform",{transform:e}));return parseFloat(i[1])}async dropNoteOntoRelationMapHandler(t){t.preventDefault();const e=t.originalEvent?.dataTransfer?.getData("text");if(!e)return;const i=JSON.parse(e);let{x:n,y:s}=this.getMousePosition(t);for(const a of i){if(this.mapData?.notes.some(c=>c.noteId===a.noteId)){ft.showError(m("relation_map.note_already_in_diagram",{title:a.title}));continue}this.mapData?.notes.push({noteId:a.noteId,x:n,y:s}),n>1e3?(s+=100,n=0):n+=200}this.saveData(),this.loadNotesAndRelations()}getMousePosition(t){const e=this.$relationMapContainer[0].getBoundingClientRect(),i=this.getZoom();return{x:((t.clientX??0)-e.left)/i,y:((t.clientY??0)-e.top)/i}}getData(){return{content:JSON.stringify(this.mapData)}}async relationMapCreateChildNoteEvent({ntxId:t}){if(!this.isNoteContext(t))return;const e=await Me.prompt({message:m("relation_map.enter_title_of_new_note"),defaultValue:m("relation_map.default_new_note_title")});if(!e?.trim())return;const{note:i}=await pt.post(`notes/${this.noteId}/children?target=into`,{title:e,content:"",type:"text"});ft.showMessage(m("relation_map.click_on_canvas_to_place_new_note")),this.clipboard={noteId:i.noteId,title:e}}relationMapResetPanZoomEvent({ntxId:t}){this.isNoteContext(t)&&(this.pzInstance?.zoomTo(0,0,1/this.getZoom()),this.pzInstance?.moveTo(0,0))}relationMapResetZoomInEvent({ntxId:t}){this.isNoteContext(t)&&this.pzInstance?.zoomTo(0,0,1.2)}relationMapResetZoomOutEvent({ntxId:t}){this.isNoteContext(t)&&this.pzInstance?.zoomTo(0,0,.8)}}const r1=`
|
||
<div class="canvas-widget note-detail-canvas note-detail-printable note-detail">
|
||
<style>
|
||
.excalidraw .App-menu_top .buttonList {
|
||
display: flex;
|
||
}
|
||
|
||
/* Conflict between excalidraw and bootstrap classes keeps the menu hidden */
|
||
/* https://github.com/zadam/trilium/issues/3780 */
|
||
/* https://github.com/excalidraw/excalidraw/issues/6567 */
|
||
.excalidraw .dropdown-menu {
|
||
display: block;
|
||
}
|
||
|
||
.excalidraw-wrapper {
|
||
height: 100%;
|
||
}
|
||
|
||
:root[dir="ltr"]
|
||
.excalidraw
|
||
.layer-ui__wrapper
|
||
.zen-mode-transition.App-menu_bottom--transition-left {
|
||
transform: none;
|
||
}
|
||
|
||
/* collaboration not possible so hide the button */
|
||
.CollabButton {
|
||
display: none !important;
|
||
}
|
||
|
||
.library-button {
|
||
display: none !important; /* library won't work without extra support which isn't currently implemented */
|
||
}
|
||
|
||
</style>
|
||
<!-- height here necessary. otherwise excalidraw not shown -->
|
||
<div class="canvas-render" style="height: 100%"></div>
|
||
</div>
|
||
`;class a1 extends Ue{currentNoteId;libraryChanged;librarycache;attachmentMetadata;themeStyle;$render;reactHandlers;canvasInstance;constructor(){super(),this.currentNoteId="",this.$render,this.$widget,this.reactHandlers,this.libraryChanged=!1,this.librarycache=[],this.attachmentMetadata=[]}static getType(){return"canvas"}doRender(){this.$widget=$(r1),this.$widget.bind("mousewheel DOMMouseScroll",e=>{if(e.ctrlKey)return e.preventDefault(),e.stopPropagation(),!1}),this.$widget.toggleClass("full-height",!0),this.$render=this.$widget.find(".canvas-render");const t=window.getComputedStyle(document.documentElement);return this.themeStyle=t.getPropertyValue("--theme-style")?.trim(),this.#t(),this.$widget}async#t(){const t=this.$render.get(0);if(!t)throw new Error("Unable to find element to render.");const e=(await Z(async()=>{const{default:i}=await import("./percentages-BXMCSKIN.js").then(n=>n.c);return{default:i}},__vite__mapDeps([69,2,70,71,5,72]),import.meta.url)).default;this.canvasInstance=new e({langCode:"ko-KR",theme:this.themeStyle,onChange:()=>this.onChangeHandler(),viewModeEnabled:Qt.is("databaseReadonly"),zenModeEnabled:!1,gridModeEnabled:!1,isCollaborating:!1,detectScroll:!1,handleKeyboardGlobally:!1,autoFocus:!1,UIOptions:{canvasActions:{saveToActiveFile:!1,export:!1}},onLibraryChange:()=>{this.libraryChanged=!0,this.saveData()}}),await l1(),this.canvasInstance.renderCanvas(t)}async doRefresh(t){this.canvasInstance||await this.#t(),this.currentNoteId!==t.noteId&&this.canvasInstance.resetSceneVersion(),this.currentNoteId=t.noteId;const i=await t.getBlob();if(await this.canvasInstance.waitForApiToBecomeAvailable(),!i?.content?.trim())this.canvasInstance.resetScene(this.themeStyle);else if(i.content){let n;try{n=i.getJsonContent()}catch(s){console.error("Error parsing content. Probably note.type changed. Starting with empty canvas",t,i,s),n={elements:[],files:[],appState:{}}}this.canvasInstance.loadData(n,this.themeStyle),Promise.all((await t.getAttachmentsByRole("canvasLibraryItem")).map(async s=>({blob:await s.getBlob(),metadata:{attachmentId:s.attachmentId,title:s.title}}))).then(s=>{if(t.noteId!==this.currentNoteId)return;const a=s.map(c=>c?.blob?.getJsonContentSafely()).filter(c=>!!c),l=s.map(c=>c.metadata);this.canvasInstance.updateLibrary(a),this.librarycache=a,this.attachmentMetadata=l})}this.canvasInstance.isInitialScene()&&this.canvasInstance.updateSceneVersion()}async getData(){const{content:t,svg:e}=await this.canvasInstance.getData(),i=[{role:"image",title:"canvas-export.svg",mime:"image/svg+xml",content:e,position:0}];if(this.libraryChanged){const n=await this.canvasInstance.getLibraryItems(),s=this.librarycache.filter(u=>!n.some(p=>u.id===p.id)),l=this.attachmentMetadata.filter(u=>s.some(p=>{const v=`${p.id}${p.name}`;return u.title===v})).map(u=>u.attachmentId);for(const u of l)await pt.remove(`attachments/${u}`);let c=10;for(const u of n)i.push({role:"canvasLibraryItem",title:u.id+u.name,mime:"application/json",content:JSON.stringify(u),position:c}),c+=10}return{content:JSON.stringify(t),attachments:i}}saveData(){this.spacedUpdate.resetUpdateTimer(),this.spacedUpdate.scheduleUpdate()}dataSaved(){this.libraryChanged=!1}onChangeHandler(){if(Qt.is("databaseReadonly"))return;const t=this.canvasInstance.isNewSceneVersion(),e=!this.canvasInstance.isInitialScene();t&&e&&(this.canvasInstance.updateSceneVersion(),this.saveData())}}async function l1(){if(window.EXCALIDRAW_ASSET_PATH)return;let o;if(!glob.isDev)o=`${window.location.pathname}/node_modules/@excalidraw/excalidraw/dist/prod`;else{o=(await Z(async()=>{const{default:e}=await import("./Excalifont-Regular-a88b72a24fb54c9f94e3b5fdaa7481c9.js");return{default:e}},[],import.meta.url)).default;let t=o.split("/");o=t.slice(0,t.length-2).join("/")}window.EXCALIDRAW_ASSET_PATH=o}const c1=`
|
||
<div class="protected-session-password-component note-detail-printable">
|
||
<style>
|
||
.protected-session-password-component {
|
||
width: 300px;
|
||
margin: 30px auto auto;
|
||
}
|
||
|
||
.protected-session-password-component input,
|
||
.protected-session-password-component button {
|
||
margin-top: 12px;
|
||
}
|
||
|
||
</style>
|
||
|
||
<form class="protected-session-password-form">
|
||
<div class="form-group">
|
||
<label for="protected-session-password-in-detail">${m("protected_session.enter_password_instruction")}</label>
|
||
<input id="protected-session-password-in-detail" class="form-control protected-session-password" type="password" autofocus autocomplete="current-password">
|
||
</div>
|
||
|
||
<button class="btn btn-primary">${m("protected_session.start_session_button")}</button>
|
||
</form>
|
||
</div>`;class d1 extends Ue{$passwordForm;$passwordInput;static getType(){return"protectedSession"}doRender(){this.$widget=$(c1),this.$passwordForm=this.$widget.find(".protected-session-password-form"),this.$passwordInput=this.$widget.find(".protected-session-password"),this.$passwordForm.on("submit",()=>{const t=String(this.$passwordInput.val());return this.$passwordInput.val(""),ll.setupProtectedSession(t),!1}),super.doRender()}}const h1=`
|
||
<div class="note-detail-book note-detail-printable">
|
||
<style>
|
||
.note-detail-book-auto-help {
|
||
background-color: var(--accented-background-color);
|
||
text-align: center;
|
||
border-radius: 10px;
|
||
padding: 5px;
|
||
margin: 0 10px 10px 10px;
|
||
}
|
||
</style>
|
||
|
||
<div class="note-detail-book-empty-help alert alert-warning" style="margin: 50px; padding: 20px;">
|
||
${m("book.no_children_help")}
|
||
</div>
|
||
</div>`;class u1 extends Ue{$helpNoChildren;static getType(){return"book"}doRender(){this.$widget=$(h1),this.$helpNoChildren=this.$widget.find(".note-detail-book-empty-help"),super.doRender()}async doRefresh(t){this.$helpNoChildren.toggle(!this.note?.hasChildren()&&this.note?.getAttributeValue("label","viewType")!=="calendar")}entitiesReloadedEvent({loadResults:t}){t.getAttributeRows().find(e=>e.noteId===this.noteId&&e.name==="viewType")&&this.refresh()}}const p1=`
|
||
<div class="note-detail-readonly-text note-detail-printable" tabindex="100">
|
||
<style>
|
||
/* h1 should not be used at all since semantically that's a note title */
|
||
.note-detail-readonly-text h1 { font-size: 1.8em; }
|
||
.note-detail-readonly-text h2 { font-size: 1.6em; }
|
||
.note-detail-readonly-text h3 { font-size: 1.4em; }
|
||
.note-detail-readonly-text h4 { font-size: 1.2em; }
|
||
.note-detail-readonly-text h5 { font-size: 1.1em; }
|
||
.note-detail-readonly-text h6 { font-size: 1.0em; }
|
||
|
||
body.heading-style-markdown .note-detail-readonly-text h1::before { content: "#\\2004"; color: var(--muted-text-color); }
|
||
body.heading-style-markdown .note-detail-readonly-text h2::before { content: "##\\2004"; color: var(--muted-text-color); }
|
||
body.heading-style-markdown .note-detail-readonly-text h3::before { content: "###\\2004"; color: var(--muted-text-color); }
|
||
body.heading-style-markdown .note-detail-readonly-text h4:not(.include-note-title)::before { content: "####\\2004"; color: var(--muted-text-color); }
|
||
body.heading-style-markdown .note-detail-readonly-text h5::before { content: "#####\\2004"; color: var(--muted-text-color); }
|
||
body.heading-style-markdown .note-detail-readonly-text h6::before { content: "######\\2004"; color: var(--muted-text-color); }
|
||
|
||
body.heading-style-underline .note-detail-readonly-text h1 { border-bottom: 1px solid var(--main-border-color); }
|
||
body.heading-style-underline .note-detail-readonly-text h2 { border-bottom: 1px solid var(--main-border-color); }
|
||
body.heading-style-underline .note-detail-readonly-text h3 { border-bottom: 1px solid var(--main-border-color); }
|
||
body.heading-style-underline .note-detail-readonly-text h4:not(.include-note-title) { border-bottom: 1px solid var(--main-border-color); }
|
||
body.heading-style-underline .note-detail-readonly-text h5 { border-bottom: 1px solid var(--main-border-color); }
|
||
body.heading-style-underline .note-detail-readonly-text h6 { border-bottom: 1px solid var(--main-border-color); }
|
||
|
||
.note-detail-readonly-text {
|
||
padding-inline-start: 24px;
|
||
padding-top: 10px;
|
||
font-family: var(--detail-font-family);
|
||
min-height: 50px;
|
||
position: relative;
|
||
}
|
||
|
||
body.mobile .note-detail-readonly-text {
|
||
padding-left: 10px;
|
||
}
|
||
|
||
.note-detail-readonly-text p:first-child, .note-detail-readonly-text::before {
|
||
margin-top: 0;
|
||
}
|
||
|
||
.note-detail-readonly-text img {
|
||
max-width: 100%;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.edit-text-note-button {
|
||
position: absolute;
|
||
top: 5px;
|
||
right: 10px;
|
||
font-size: 150%;
|
||
padding: 5px;
|
||
cursor: pointer;
|
||
border: 1px solid transparent;
|
||
border-radius: var(--button-border-radius);
|
||
color: var(--button-text-color);
|
||
}
|
||
|
||
.edit-text-note-button:hover {
|
||
border-color: var(--button-border-color);
|
||
}
|
||
</style>
|
||
|
||
<div class="note-detail-readonly-text-content ck-content use-tn-links"></div>
|
||
</div>
|
||
`;class f1 extends Hf{$content;static getType(){return"readOnlyText"}doRender(){this.$widget=$(p1),this.$content=this.$widget.find(".note-detail-readonly-text-content"),this.setupImageOpening(!0),super.doRender()}cleanup(){this.$content.html("")}async doRefresh(t){await Z(()=>import("./ckeditor5.js"),[],import.meta.url),this.onLanguageChanged();const e=await t.getBlob();this.$content.html(e?.content??""),this.$content.find("a.reference-link").each((i,n)=>{this.loadReferenceLinkTitle($(n))}),this.$content.find("section").each((i,n)=>{const s=$(n).attr("data-note-id");s&&this.loadIncludedNote(s,$(n))}),this.$content.find("span.math-tex").length>0&&Rf(this.$content[0],{trust:!0}),await this.#t(),await Yd(this.$content)}async#t(){const t=this.$content.find('code[class="language-mermaid"]').closest("pre");if(!t.length)return;t.replaceWith((i,n)=>$('<div class="mermaid-diagram">').text($(n).text()));const e=(await Z(async()=>{const{default:i}=await import("./mermaid.core.js").then(n=>n.bh);return{default:i}},__vite__mapDeps([14,2,4,5,15,16,17,12,3]),import.meta.url)).default;e.initialize(Qd()),e.run({nodes:this.$content.find(".mermaid-diagram")})}async refreshIncludedNoteEvent({noteId:t}){this.refreshIncludedNote(this.$content,t)}async executeWithContentElementEvent({resolve:t,ntxId:e}){this.isNoteContext(e)&&(await this.initialized,t(this.$content))}async onLanguageChanged(){const t=this.note?.getLabelValue("language"),i=rb(t)?.rtl;this.$widget.attr("dir",i?"rtl":"ltr")}buildTouchBarCommand({TouchBar:t,buildIcon:e}){return[new t.TouchBarSpacer({size:"flexible"}),new t.TouchBarButton({icon:e("NSLockUnlockedTemplate"),click:()=>{this.noteContext?.viewScope&&(this.noteContext.viewScope.readOnlyTemporarilyDisabled=!0,Pt.triggerEvent("readOnlyTemporarilyDisabled",{noteContext:this.noteContext})),this.refresh()}})]}}const m1=`
|
||
<div class="note-detail-readonly-code note-detail-printable">
|
||
<style>
|
||
.note-detail-readonly-code {
|
||
min-height: 50px;
|
||
position: relative;
|
||
}
|
||
</style>
|
||
|
||
<pre class="note-detail-readonly-code-content"></pre>
|
||
</div>`;class g1 extends Rh{static getType(){return"readOnlyCode"}doRender(){this.$widget=$(m1),this.contentSized(),this.$editor=this.$widget.find(".note-detail-readonly-code-content"),super.doRender()}async doRefresh(t){const e=await this.note?.getBlob();if(!e)return;const n=t.type==="text"&&this.noteContext?.viewScope?.viewMode==="source"?this.format(e.content):e.content;this._update(t,n),this.show()}getExtraOpts(){return{readOnly:!0}}async executeWithContentElementEvent({resolve:t,ntxId:e}){this.isNoteContext(e)&&(await this.initialized,t(this.$editor))}format(t){let e=`
|
||
`;const i=" ";let n=0,s=[];for(t=t.replace(new RegExp("<pre>((.|\\t|\\n|\\r)+)?</pre>"),function(a){return s.push({indent:"",tag:a}),"<--TEMPPRE"+n+++"/-->"}).replace(new RegExp("<[^<>]+>[^<]?","g"),function(a){let l;const c=/<\/?([^\s/>]+)/.exec(a);let u=c?c[1]:"",p=new RegExp("<--TEMPPRE(\\d+)/-->").exec(a);if(p){const v=parseInt(p[1]);s[v].indent=e}return["area","base","br","col","command","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"].indexOf(u)>=0?l=e+a:a.indexOf("</")<0?(a.charAt(a.length-1)!==">"?l=e+a.substr(0,a.length-1)+e+i+a.substr(a.length-1,a.length):l=e+a,!p&&(e+=i)):(e=e.substr(0,e.length-1),a.charAt(a.length-1)!==">"?l=e+a.substr(0,a.length-1)+e+a.substr(a.length-1,a.length):l=e+a),l}),n=s.length;n--;)t=t.replace("<--TEMPPRE"+n+"/-->",s[n].tag.replace("<pre>",`<pre>
|
||
`).replace("</pre>",s[n].indent+"</pre>"));return t.charAt(0)===`
|
||
`?t.substr(1,t.length-1):t}}const v1='<div class="note-detail-none note-detail-printable"></div>';class y1 extends Ue{static getType(){return"none"}doRender(){this.$widget=$(v1),super.doRender()}}const Fa=ct.escapeHtml,b1=`<div class="note-map-widget">
|
||
<style>
|
||
.note-detail-note-map {
|
||
height: 100%;
|
||
overflow: hidden;
|
||
}
|
||
|
||
/* Style Ui Element to Drag Nodes */
|
||
.fixnodes-type-switcher {
|
||
display: flex;
|
||
align-items: center;
|
||
z-index: 10; /* should be below dropdown (note actions) */
|
||
border-radius: .2rem;
|
||
}
|
||
|
||
.fixnodes-type-switcher button.toggled {
|
||
background: var(--active-item-background-color);
|
||
color: var(--active-item-text-color);
|
||
}
|
||
|
||
/* Start of styling the slider */
|
||
.fixnodes-type-switcher input[type="range"] {
|
||
|
||
/* removing default appearance */
|
||
-webkit-appearance: none;
|
||
appearance: none;
|
||
margin-left: 15px;
|
||
width: 150px;
|
||
}
|
||
|
||
/* Changing slider tracker */
|
||
.fixnodes-type-switcher input[type="range"]::-webkit-slider-runnable-track {
|
||
height: 4px;
|
||
background-color: var(--main-border-color);
|
||
border-radius: 4px;
|
||
}
|
||
|
||
/* Changing Slider Thumb */
|
||
.fixnodes-type-switcher input[type="range"]::-webkit-slider-thumb {
|
||
/* removing default appearance */
|
||
-webkit-appearance: none;
|
||
appearance: none;
|
||
/* creating a custom design */
|
||
height: 15px;
|
||
width: 15px;
|
||
margin-top:-5px;
|
||
background-color: var(--accented-background-color);
|
||
border: 1px solid var(--main-text-color);
|
||
border-radius: 50%;
|
||
}
|
||
|
||
.fixnodes-type-switcher input[type="range"]::-moz-range-track {
|
||
background-color: var(--main-border-color);
|
||
border-radius: 4px;
|
||
}
|
||
|
||
.fixnodes-type-switcher input[type="range"]::-moz-range-thumb {
|
||
background-color: var(--accented-background-color);
|
||
border-color: var(--main-text-color);
|
||
height: 10px;
|
||
width: 10px;
|
||
}
|
||
|
||
/* End of styling the slider */
|
||
|
||
</style>
|
||
|
||
<div class="btn-group btn-group-sm map-type-switcher content-floating-buttons top-left" role="group">
|
||
<button type="button" class="btn bx bx-network-chart tn-tool-button" title="${m("note-map.button-link-map")}" data-type="link"></button>
|
||
<button type="button" class="btn bx bx-sitemap tn-tool-button" title="${m("note-map.button-tree-map")}" data-type="tree"></button>
|
||
</div>
|
||
|
||
<! UI for dragging Notes and link force >
|
||
|
||
<div class="btn-group-sm fixnodes-type-switcher content-floating-buttons bottom-left" role="group">
|
||
<button type="button" data-toggle="button" class="btn bx bx-lock-alt tn-tool-button" title="${m("note_map.fix-nodes")}" data-type="moveable"></button>
|
||
<input type="range" class="slider" min="1" title="${m("note_map.link-distance")}" max="100" value="40" >
|
||
</div>
|
||
|
||
<div class="style-resolver"></div>
|
||
|
||
<div class="note-map-container"></div>
|
||
</div>`;class w1 extends hi{fixNodes;widgetMode;mapType;cssData;themeStyle;$container;$styleResolver;$fixNodesButton;graph;noteIdToSizeMap;zoomLevel;nodes;constructor(t){super(),this.fixNodes=!1,this.widgetMode=t}doRender(){this.$widget=$(b1);const t=window.getComputedStyle(document.documentElement);this.themeStyle=t.getPropertyValue("--theme-style")?.trim(),this.$container=this.$widget.find(".note-map-container"),this.$styleResolver=this.$widget.find(".style-resolver"),this.$fixNodesButton=this.$widget.find(".fixnodes-type-switcher > button"),new ResizeObserver(()=>this.setDimensions()).observe(this.$container[0]),this.$widget.find(".map-type-switcher button").on("click",async e=>{const i=$(e.target).closest("button").attr("data-type");await Be.setLabel(this.noteId??"","mapType",i)}),this.$fixNodesButton.on("click",async e=>{this.fixNodes=!this.fixNodes,this.$fixNodesButton.toggleClass("toggled",this.fixNodes)}),super.doRender()}setDimensions(){if(!this.graph)return;const t=this.$widget.parent();this.graph.height(t.height()||0).width(t.width()||0)}async refreshWithNote(t){this.$widget.show(),this.cssData={fontFamily:this.$container.css("font-family"),textColor:this.rgb2hex(this.$container.css("color")),mutedTextColor:this.rgb2hex(this.$styleResolver.css("color"))},this.mapType=t.getLabelValue("mapType")==="tree"?"tree":"link";let e=null;const i=new Set,n=new Set,s=(await Z(async()=>{const{default:T}=await import("./force-graph.js");return{default:T}},__vite__mapDeps([73,15,16,74,75,71,76,77,78,79]),import.meta.url)).default;this.graph=new s(this.$container[0]).width(this.$container.width()||0).height(this.$container.height()||0).onZoom(T=>this.setZoomLevel(T.k)).d3AlphaDecay(.01).d3VelocityDecay(.08).onNodeDragEnd(T=>{this.fixNodes?(T.fx=T.x,T.fy=T.y):(T.fx=void 0,T.fy=void 0)}).onNodeHover(T=>{e=T||null,i.clear()}).linkWidth(T=>i.has(T)?3:.4).linkColor(T=>i.has(T)?"white":this.cssData.mutedTextColor).linkDirectionalArrowLength(4).linkDirectionalArrowRelPos(.95).nodeCanvasObject((T,M)=>{const P=T;if(e==P){this.paintNode(P,"#661822",M),n.clear();for(const F of l.links){const R=F;(R.source.id==P.id||R.target.id==P.id)&&(n.add(R.source),n.add(R.target),i.add(R),n.delete(P))}}else n.has(P)&&e!=null?this.paintNode(P,"#9d6363",M):this.paintNode(P,this.getColorForNode(P),M)}).nodePointerAreaPaint((T,M,P)=>this.paintNode(T,this.getColorForNode(T),P)).nodePointerAreaPaint((T,M,P)=>{T.id&&(P.fillStyle=M,P.beginPath(),T.x&&T.y&&P.arc(T.x,T.y,this.noteIdToSizeMap[T.id],0,2*Math.PI,!1),P.fill())}).nodeLabel(T=>Fa(T.name)).maxZoom(7).warmupTicks(30).onNodeClick(T=>{T.id&&Pt.tabManager.getActiveContext()?.setNote(T.id)}).onNodeRightClick((T,M)=>{T.id&&$r.openContextMenu(T.id,M)}),this.mapType==="link"&&this.graph.linkLabel(T=>`${Fa(T.source.name)} - <strong>${Fa(T.name)}</strong> - ${Fa(T.target.name)}`).linkCanvasObject((T,M)=>this.paintLink(T,M)).linkCanvasObjectMode(()=>"after");const a=this.getMapRootNoteId(),l=await this.loadNotesAndRelations(a),c=l.nodes.length/l.links.length,p=-20/Math.pow(c,1.5),v=Math.min(-3,p);let x=40;this.$widget.find(".fixnodes-type-switcher input").on("change",async T=>{x=parseInt(T.target.closest("input")?.value??"0"),this.graph.d3Force("link")?.distance(x),this.renderData(l)}),this.graph.d3Force("center")?.strength(.2),this.graph.d3Force("charge")?.strength(v),this.graph.d3Force("charge")?.distanceMax(1e3),this.renderData(l)}getMapRootNoteId(){if(this.noteId&&this.widgetMode==="ribbon")return this.noteId;let t=this.note?.getLabelValue("mapRootNoteId");return t==="hoisted"?t=li.getHoistedNoteId():t||(t=Pt.tabManager.getActiveContext()?.parentNoteId),t??""}getColorForNode(t){return t.color?t.color:this.widgetMode==="ribbon"&&t.id===this.noteId?"red":this.generateColorFromString(t.type)}generateColorFromString(t){this.themeStyle==="dark"&&(t=`0${t}`);let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e);let i="#";for(let n=0;n<3;n++){const s=e>>n*8&255;i+=`00${s.toString(16)}`.substr(-2)}return i}rgb2hex(t){return`#${(t.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/)||[]).slice(1).map(e=>parseInt(e,10).toString(16).padStart(2,"0")).join("")}`}setZoomLevel(t){this.zoomLevel=t}paintNode(t,e,i){const{x:n,y:s}=t;if(!n||!s)return;const a=this.noteIdToSizeMap[t.id];if(i.fillStyle=e,i.beginPath(),i.arc(n,s,a*.8,0,2*Math.PI,!1),i.fill(),!(this.zoomLevel>2||this.zoomLevel>1&&a>6||this.zoomLevel>.3&&a>10))return;i.fillStyle=this.cssData.textColor,i.font=`${a}px ${this.cssData.fontFamily}`,i.textAlign="center",i.textBaseline="middle";let c=t.name;c.length>15&&(c=`${c.substr(0,15)}...`),i.fillText(c,n,s+Math.round(a*1.5))}paintLink(t,e){if(this.zoomLevel<5)return;e.font=`3px ${this.cssData.fontFamily}`,e.textAlign="center",e.textBaseline="middle",e.fillStyle=this.cssData.mutedTextColor;const{source:i,target:n}=t;if(!(typeof i!="object"||typeof n!="object")){if(i.x&&i.y&&n.x&&n.y){const s=(i.x+n.x)/2,a=(i.y+n.y)/2;e.save(),e.translate(s,a);const l=i.y-n.y,c=i.x-n.x;let u=Math.atan2(l,c),p=2;(u<-Math.PI/2||u>Math.PI/2)&&(u+=Math.PI,p=-2),e.rotate(u),e.fillText(t.name,0,p)}e.restore()}}async loadNotesAndRelations(t){const e=await pt.post(`note-map/${t}/${this.mapType}`);this.calculateNodeSizes(e);const i=this.getGroupedLinks(e.links);return this.nodes=e.notes.map(([n,s,a,l])=>({id:n,name:s,type:a,color:l})),{nodes:this.nodes,links:i.map(n=>({id:`${n.sourceNoteId}-${n.targetNoteId}`,source:n.sourceNoteId,target:n.targetNoteId,name:n.names.join(", ")}))}}getGroupedLinks(t){const e={};for(const i of t){const n=`${i.sourceNoteId}-${i.targetNoteId}`;n in e?e[n].names.includes(i.name)||e[n].names.push(i.name):e[n]={id:n,sourceNoteId:i.sourceNoteId,targetNoteId:i.targetNoteId,names:[i.name]}}return Object.values(e)}calculateNodeSizes(t){if(this.noteIdToSizeMap={},this.mapType==="tree"){const{noteIdToDescendantCountMap:e}=t;for(const i in e){this.noteIdToSizeMap[i]=4;const n=e[i];n>0&&(this.noteIdToSizeMap[i]+=1+Math.round(Math.log(n)/Math.log(1.5)))}}else if(this.mapType==="link"){const e={};for(const i of t.links)e[i.targetNoteId]=1+(e[i.targetNoteId]||0);for(const[i]of t.notes)this.noteIdToSizeMap[i]=4,i in e&&(this.noteIdToSizeMap[i]+=Math.min(Math.pow(e[i],.5),15))}}renderData(t){this.graph.graphData(t),this.widgetMode==="ribbon"&&this.note?.type!=="search"?setTimeout(()=>{this.setDimensions();const e=this.getSubGraphConnectedToCurrentNote(t);this.graph.zoomToFit(400,50,i=>e.has(i.id)),e.size<30&&this.graph.d3VelocityDecay(.4)},1e3):t.nodes.length>1&&setTimeout(()=>{this.setDimensions();const e=this.getNoteIdsWithLinks(t);e.size>0&&this.graph.zoomToFit(400,30,i=>e.has(i.id??"")),e.size<30&&this.graph.d3VelocityDecay(.4)},1e3)}getNoteIdsWithLinks(t){const e=new Set;for(const i of t.links)typeof i.source=="object"&&i.source.id&&e.add(i.source.id),typeof i.target=="object"&&i.target.id&&e.add(i.target.id);return e}getSubGraphConnectedToCurrentNote(t){function e(l,c){const u={};for(const p of l){if(typeof p[c]!="object")continue;const v=p[c].id;v&&(u[v]=u[v]||[],u[v].push(p))}return u}const i=e(t.links,"source"),n=e(t.links,"target"),s=new Set;function a(l){if(!(!l||s.has(l))){s.add(l);for(const c of i[l]||[])typeof c.target=="object"&&a(c.target?.id);for(const c of n[l]||[])typeof c.source=="object"&&a(c.source?.id)}}return a(this.noteId),s}cleanup(){this.$container.html("")}entitiesReloadedEvent({loadResults:t}){t.getAttributeRows(this.componentId).find(e=>e.type==="label"&&["mapType","mapRootNoteId"].includes(e.name||"")&&Be.isAffecting(e,this.note))&&this.refresh()}}const _1='<div class="note-detail-note-map note-detail-printable"></div>';class x1 extends Ue{noteMapWidget;static getType(){return"noteMap"}constructor(){super(),this.noteMapWidget=new w1("type"),this.child(this.noteMapWidget)}doRender(){this.$widget=$(_1),this.$widget.append(this.noteMapWidget.render()),super.doRender()}async doRefresh(t){await this.noteMapWidget.refresh()}}const k1=`
|
||
<div class="note-detail-web-view note-detail-printable" style="height: 100%">
|
||
<div class="note-detail-web-view-help alert alert-warning" style="margin: 50px; padding: 20px 20px 0px 20px;">
|
||
<h4>${m("web_view.web_view")}</h4>
|
||
|
||
<p>${m("web_view.embed_websites")}</p>
|
||
|
||
<p>${m("web_view.create_label")}</p>
|
||
</div>
|
||
|
||
${C1()}
|
||
</div>`;function C1(){return ct.isElectron()?'<webview class="note-detail-web-view-content"></webview>':'<iframe class="note-detail-web-view-content" sandbox="allow-same-origin allow-scripts"></iframe>'}class $1 extends Ue{$noteDetailWebViewHelp;$noteDetailWebViewContent;static getType(){return"webView"}doRender(){this.$widget=$(k1),this.$noteDetailWebViewHelp=this.$widget.find(".note-detail-web-view-help"),this.$noteDetailWebViewContent=this.$widget.find(".note-detail-web-view-content"),window.addEventListener("resize",()=>this.setDimensions(),!1),super.doRender()}async doRefresh(t){if(this.$widget.show(),this.$noteDetailWebViewHelp.hide(),this.$noteDetailWebViewContent.hide(),!this.note)return;const e=this.note.getLabelValue("webViewSrc");e?this.$noteDetailWebViewContent.show().attr("src",e):(this.$noteDetailWebViewContent.hide(),this.$noteDetailWebViewHelp.show()),this.setDimensions(),setTimeout(()=>this.setDimensions(),1e3)}cleanup(){this.$noteDetailWebViewContent.removeAttr("src")}setDimensions(){const t=this.$widget;this.$noteDetailWebViewContent.height(t.height()??0).width(t.width()??0)}entitiesReloadedEvent({loadResults:t}){t.getAttributeRows().find(e=>e.name==="webViewSrc"&&Be.isAffecting(e,this.noteContext?.note))&&this.refresh()}}const S1=`<div class="note-detail-doc note-detail-printable">
|
||
<style>
|
||
.note-detail-doc-content {
|
||
padding: 15px;
|
||
}
|
||
|
||
.note-detail-doc-content pre {
|
||
border: 0;
|
||
box-shadow: var(--code-block-box-shadow);
|
||
padding: 15px;
|
||
border-radius: 5px;
|
||
}
|
||
|
||
.note-detail-doc-content pre:not(.hljs) {
|
||
background-color: var(--accented-background-color);
|
||
border: 1px solid var(--main-border-color);
|
||
}
|
||
|
||
.note-detail-doc.contextual-help {
|
||
padding-bottom: 0;
|
||
}
|
||
|
||
.note-detail-doc.contextual-help h2,
|
||
.note-detail-doc.contextual-help h3,
|
||
.note-detail-doc.contextual-help h4,
|
||
.note-detail-doc.contextual-help h5,
|
||
.note-detail-doc.contextual-help h6 {
|
||
font-size: 1.25rem;
|
||
background-color: var(--main-background-color);
|
||
position: sticky;
|
||
top: 0;
|
||
z-index: 50;
|
||
margin: 0;
|
||
padding-bottom: 0.25em;
|
||
}
|
||
|
||
img {
|
||
max-width: 100%;
|
||
height: auto;
|
||
}
|
||
|
||
td img {
|
||
max-width: 40vw;
|
||
}
|
||
|
||
figure.table {
|
||
overflow: auto !important;
|
||
}
|
||
</style>
|
||
|
||
<div class="note-detail-doc-content ck-content"></div>
|
||
</div>`;class T1 extends Ue{$content;static getType(){return"doc"}doRender(){this.$widget=$(S1),this.$content=this.$widget.find(".note-detail-doc-content"),super.doRender()}async doRefresh(t){this.initialized=mb(t).then(e=>{this.$content.html(e.html())}),this.$widget.toggleClass("contextual-help",this.noteContext?.viewScope?.viewMode==="contextual-help")}async executeWithContentElementEvent({resolve:t,ntxId:e}){this.isNoteContext(e)&&(await this.initialized,t(this.$content))}}class ae extends hi{constructor(){super(),this.contentSized()}async updateOption(t,e){const i={[t]:e};await this.updateMultipleOptions(i)}async updateMultipleOptions(t){await pt.put("options",t),this.showUpdateNotification()}showUpdateNotification(){ft.showPersistent({id:"options-change-saved",title:m("options_widget.options_status"),message:m("options_widget.options_change_saved"),icon:"slider",closeAfter:2e3})}async updateCheckboxOption(t,e){const i=e.prop("checked");return await this.updateOption(t,i?"true":"false")}setCheckboxState(t,e){t.prop("checked",e==="true")}optionsLoaded(t){}async refresh(){this.toggleInt(this.isEnabled());try{await this.refreshWithNote(this.note)}catch(t){if(t==="rejected by browser")return;throw t}}async refreshWithNote(t){const e=await pt.get("options");e&&this.optionsLoaded(e)}async entitiesReloadedEvent({loadResults:t}){t.getOptionNames().length>0&&this.refresh()}}const E1=`
|
||
<div class="options-section">
|
||
<h4>${m("electron_integration.desktop-application")}</h4>
|
||
|
||
<div class="form-group row">
|
||
<div class="col-12">
|
||
<label for="zoom-factor-select">${m("electron_integration.zoom-factor")}</label>
|
||
<input id="zoom-factor-select" type="number" class="zoom-factor-select form-control options-number-input" min="0.3" max="2.0" step="0.1"/>
|
||
<p class="form-text">${m("zoom_factor.description")}</p>
|
||
</div>
|
||
</div>
|
||
<hr />
|
||
|
||
<div>
|
||
<label class="form-check tn-checkbox">
|
||
<input type="checkbox" class="native-title-bar form-check-input" />
|
||
${m("electron_integration.native-title-bar")}
|
||
</label>
|
||
<p class="form-text">
|
||
${m("electron_integration.native-title-bar-description")}
|
||
</p>
|
||
</div>
|
||
|
||
<div>
|
||
<label class="form-check tn-checkbox">
|
||
<input type="checkbox" class="background-effects form-check-input" />
|
||
${m("electron_integration.background-effects")}
|
||
</label>
|
||
<p class="form-text">
|
||
${m("electron_integration.background-effects-description")}
|
||
</p>
|
||
</div>
|
||
|
||
<button class="btn btn-secondary btn-micro restart-app-button">${m("electron_integration.restart-app-button")}</button>
|
||
</div>
|
||
`;class I1 extends ae{$zoomFactorSelect;$nativeTitleBar;$backgroundEffects;doRender(){this.$widget=$(E1),this.$zoomFactorSelect=this.$widget.find(".zoom-factor-select"),this.$zoomFactorSelect.on("change",()=>{this.triggerCommand("setZoomFactorAndSave",{zoomFactor:String(this.$zoomFactorSelect.val())})}),this.$nativeTitleBar=this.$widget.find("input.native-title-bar"),this.$nativeTitleBar.on("change",()=>this.updateCheckboxOption("nativeTitleBarVisible",this.$nativeTitleBar)),this.$backgroundEffects=this.$widget.find("input.background-effects"),this.$backgroundEffects.on("change",()=>this.updateCheckboxOption("backgroundEffects",this.$backgroundEffects)),this.$widget.find(".restart-app-button").on("click",ct.restartDesktopApp)}isEnabled(){return ct.isElectron()}async optionsLoaded(t){this.$zoomFactorSelect.val(t.zoomFactor),this.setCheckboxState(this.$nativeTitleBar,t.nativeTitleBarVisible),this.setCheckboxState(this.$backgroundEffects,t.backgroundEffects)}}const A1=`
|
||
<div class="options-section">
|
||
<h4>${m("theme.layout")}</h4>
|
||
|
||
<div class="form-group row">
|
||
<div>
|
||
<label class="tn-radio">
|
||
<input type="radio" name="layout-orientation" value="vertical" />
|
||
<strong>${m("theme.layout-vertical-title")}</strong>
|
||
- ${m("theme.layout-vertical-description")}
|
||
</label>
|
||
</div>
|
||
|
||
<div>
|
||
<label class="tn-radio">
|
||
<input type="radio" name="layout-orientation" value="horizontal" />
|
||
<strong>${m("theme.layout-horizontal-title")}</strong>
|
||
- ${m("theme.layout-horizontal-description")}
|
||
</label>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="options-section">
|
||
<h4>${m("theme.title")}</h4>
|
||
|
||
<div class="form-group row">
|
||
<div class="col-md-6">
|
||
<label for="theme-select">${m("theme.theme_label")}</label>
|
||
<select id="theme-select" class="theme-select form-select"></select>
|
||
</div>
|
||
|
||
<div class="col-md-6 side-checkbox">
|
||
<label class="form-check tn-checkbox">
|
||
<input type="checkbox" class="override-theme-fonts form-check-input">
|
||
${m("theme.override_theme_fonts_label")}
|
||
</label>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`;class L1 extends ae{$themeSelect;$overrideThemeFonts;$layoutOrientation;doRender(){this.$widget=$(A1),this.$themeSelect=this.$widget.find(".theme-select"),this.$overrideThemeFonts=this.$widget.find(".override-theme-fonts"),this.$layoutOrientation=this.$widget.find('input[name="layout-orientation"]').on("change",async()=>{const e=String(this.$widget.find('input[name="layout-orientation"]:checked').val());await this.updateOption("layoutOrientation",e),ct.reloadFrontendApp("layout orientation change")}),$(this.$widget[0]).toggleClass("hidden-ext",ct.isMobile()),this.$themeSelect.on("change",async()=>{const e=this.$themeSelect.val();await pt.put(`options/theme/${e}`),ct.reloadFrontendApp("theme change")}),this.$overrideThemeFonts.on("change",()=>this.updateCheckboxOption("overrideThemeFonts",this.$overrideThemeFonts))}async optionsLoaded(t){const e=[{val:"next",title:m("theme.triliumnext")},{val:"next-light",title:m("theme.triliumnext-light")},{val:"next-dark",title:m("theme.triliumnext-dark")},{val:"auto",title:m("theme.auto_theme")},{val:"light",title:m("theme.light_theme")},{val:"dark",title:m("theme.dark_theme")}].concat(await pt.get("options/user-themes"));this.$themeSelect.empty();for(const i of e)this.$themeSelect.append($("<option>").attr("value",i.val).attr("data-note-id",i.noteId||"").text(i.title));this.$themeSelect.val(t.theme),this.setCheckboxState(this.$overrideThemeFonts,t.overrideThemeFonts),this.$widget.find(`input[name="layout-orientation"][value="${t.layoutOrientation}"]`).prop("checked","true")}}const N1=[{title:m("fonts.generic-fonts"),items:[{value:"theme",label:m("fonts.theme_defined")},{value:"system",label:m("fonts.system-default")},{value:"serif",label:m("fonts.serif")},{value:"sans-serif",label:m("fonts.sans-serif")},{value:"monospace",label:m("fonts.monospace")}]},{title:m("fonts.sans-serif-system-fonts"),items:[{value:"Arial"},{value:"Verdana"},{value:"Helvetica"},{value:"Tahoma"},{value:"Trebuchet MS"},{value:"Microsoft YaHei"}]},{title:m("fonts.serif-system-fonts"),items:[{value:"Times New Roman"},{value:"Georgia"},{value:"Garamond"}]},{title:m("fonts.monospace-system-fonts"),items:[{value:"Courier New"},{value:"Brush Script MT"},{value:"Impact"},{value:"American Typewriter"},{value:"Andalé Mono"},{value:"Lucida Console"},{value:"Monaco"}]},{title:m("fonts.handwriting-system-fonts"),items:[{value:"Bradley Hand"},{value:"Luminari"},{value:"Comic Sans MS"}]}],M1=`
|
||
<div class="options-section">
|
||
<h4>${m("fonts.fonts")}</h4>
|
||
|
||
<h5>${m("fonts.main_font")}</h5>
|
||
|
||
<div class="form-group row">
|
||
<div class="col-4">
|
||
<label for="main-font-family">${m("fonts.font_family")}</label>
|
||
<select id="main-font-family" class="main-font-family form-select"></select>
|
||
</div>
|
||
|
||
<div class="col-6">
|
||
<label for="main-font-size">${m("fonts.size")}</label>
|
||
|
||
<label class="input-group tn-number-unit-pair main-font-size-input-group">
|
||
<input id="main-font-size" type="number" class="main-font-size form-control options-number-input" min="50" max="200" step="10"/>
|
||
<span class="input-group-text">%</span>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
|
||
<h5>${m("fonts.note_tree_font")}</h5>
|
||
|
||
<div class="form-group row">
|
||
<div class="col-4">
|
||
<label for="tree-font-family">${m("fonts.font_family")}</label>
|
||
<select id="tree-font-family" class="tree-font-family form-select"></select>
|
||
</div>
|
||
|
||
<div class="col-6">
|
||
<label for="tree-font-size">${m("fonts.size")}</label>
|
||
|
||
<label class="input-group tn-number-unit-pair tree-font-size-input-group">
|
||
<input id="tree-font-size" type="number" class="tree-font-size form-control options-number-input" min="50" max="200" step="10"/>
|
||
<span class="input-group-text">%</span>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
|
||
<h5>${m("fonts.note_detail_font")}</h5>
|
||
|
||
<div class="form-group row">
|
||
<div class="col-4">
|
||
<label for="detail-font-family">${m("fonts.font_family")}</label>
|
||
<select id="detail-font-family" class="detail-font-family form-select"></select>
|
||
</div>
|
||
|
||
<div class="col-6">
|
||
<label for="detail-font-size">${m("fonts.size")}</label>
|
||
|
||
<label class="input-group tn-number-unit-pair detail-font-size-input-group">
|
||
<input id="detail-font-size" type="number" class="detail-font-size form-control options-number-input" min="50" max="200" step="10"/>
|
||
<span class="input-group-text">%</span>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
|
||
<h5>${m("fonts.monospace_font")}</h5>
|
||
|
||
<div class="form-group row">
|
||
<div class="col-4">
|
||
<label for="monospace-font-family">${m("fonts.font_family")}</label>
|
||
<select id="monospace-font-family" class="monospace-font-family form-select"></select>
|
||
</div>
|
||
|
||
<div class="col-6">
|
||
<label for="monospace-font-size">${m("fonts.size")}</label>
|
||
|
||
<label class="input-group tn-number-unit-pair monospace-font-size-input-group">
|
||
<input id="monospace-font-size" type="number" class="monospace-font-size form-control options-number-input" min="50" max="200" step="10"/>
|
||
<span class="input-group-text">%</span>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
|
||
<p class="form-text">${m("fonts.note_tree_and_detail_font_sizing")}</p>
|
||
|
||
<p class="form-text">${m("fonts.not_all_fonts_available")}</p>
|
||
|
||
<p>
|
||
${m("fonts.apply_font_changes")}
|
||
<button class="btn btn-secondary btn-micro reload-frontend-button">${m("fonts.reload_frontend")}</button>
|
||
</p>
|
||
</div>`;class P1 extends ae{$mainFontSize;$mainFontFamily;$treeFontSize;$treeFontFamily;$detailFontSize;$detailFontFamily;$monospaceFontSize;$monospaceFontFamily;_isEnabled;doRender(){this.$widget=$(M1),this.$mainFontSize=this.$widget.find(".main-font-size"),this.$mainFontFamily=this.$widget.find(".main-font-family"),this.$treeFontSize=this.$widget.find(".tree-font-size"),this.$treeFontFamily=this.$widget.find(".tree-font-family"),this.$detailFontSize=this.$widget.find(".detail-font-size"),this.$detailFontFamily=this.$widget.find(".detail-font-family"),this.$monospaceFontSize=this.$widget.find(".monospace-font-size"),this.$monospaceFontFamily=this.$widget.find(".monospace-font-family"),this.$widget.find(".reload-frontend-button").on("click",()=>ct.reloadFrontendApp("changes from appearance options"))}isEnabled(){return!!this._isEnabled}async optionsLoaded(t){if(this._isEnabled=t.overrideThemeFonts==="true",this.toggleInt(this._isEnabled),!this._isEnabled)return;this.$mainFontSize.val(t.mainFontSize),this.fillFontFamilyOptions(this.$mainFontFamily,t.mainFontFamily),this.$treeFontSize.val(t.treeFontSize),this.fillFontFamilyOptions(this.$treeFontFamily,t.treeFontFamily),this.$detailFontSize.val(t.detailFontSize),this.fillFontFamilyOptions(this.$detailFontFamily,t.detailFontFamily),this.$monospaceFontSize.val(t.monospaceFontSize),this.fillFontFamilyOptions(this.$monospaceFontFamily,t.monospaceFontFamily);const e=["mainFontFamily","mainFontSize","treeFontFamily","treeFontSize","detailFontFamily","detailFontSize","monospaceFontFamily","monospaceFontSize"];for(const i of e){const n=this[`$${i}`];n.on("change",()=>this.updateOption(i,n.val()))}}fillFontFamilyOptions(t,e){t.empty();for(const{title:i,items:n}of Object.values(N1)){const s=$("<optgroup>").attr("label",i);for(const{value:a,label:l}of n)s.append($("<option>").attr("value",a).prop("selected",a===e).text(l??a));t.append(s)}}}const Gv=640,O1=`
|
||
<div class="options-section">
|
||
<h4>${m("max_content_width.title")}</h4>
|
||
|
||
<p class="form-text">${m("max_content_width.default_description")}</p>
|
||
|
||
<div class="form-group row">
|
||
<div class="col-md-6">
|
||
<label for="max-content-width">${m("max_content_width.max_width_label")}</label>
|
||
<label class="input-group tn-number-unit-pair">
|
||
<input id="max-content-width" type="number" min="${Gv}" step="10" class="max-content-width form-control options-number-input">
|
||
<span class="input-group-text">${m("max_content_width.max_width_unit")}</span>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
|
||
<p>
|
||
${m("max_content_width.apply_changes_description")}
|
||
<button class="btn btn-secondary btn-micro reload-frontend-button">${m("max_content_width.reload_button")}</button>
|
||
</p>
|
||
</div>`;class D1 extends ae{$maxContentWidth;doRender(){this.$widget=$(O1),this.$maxContentWidth=this.$widget.find(".max-content-width"),this.$maxContentWidth.on("change",async()=>this.updateOption("maxContentWidth",String(this.$maxContentWidth.val()))),this.$widget.find(".reload-frontend-button").on("click",()=>ct.reloadFrontendApp(m("max_content_width.reload_description")))}async optionsLoaded(t){this.$maxContentWidth.val(Math.max(Gv,parseInt(t.maxContentWidth,10)))}}const R1=`
|
||
<div class="options-section shortcuts-options-section tn-no-card">
|
||
<style>
|
||
.shortcuts-options-section {
|
||
display: flex;
|
||
flex-direction: column;
|
||
height: 100%;
|
||
}
|
||
|
||
.shortcuts-table-container {
|
||
overflow: auto;
|
||
flex-grow: 1;
|
||
flex-shrink: 1;
|
||
}
|
||
|
||
.shortcuts-options-buttons {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
margin: 15px 15px 0 15px;
|
||
}
|
||
</style>
|
||
|
||
<h4>${m("shortcuts.keyboard_shortcuts")}</h4>
|
||
|
||
<p class="form-text use-tn-links">
|
||
${m("shortcuts.multiple_shortcuts")}
|
||
${m("shortcuts.electron_documentation")}
|
||
</p>
|
||
|
||
<div class="form-group">
|
||
<input type="text" class="keyboard-shortcut-filter form-control" placeholder="${m("shortcuts.type_text_to_filter")}">
|
||
</div>
|
||
|
||
<div class="shortcuts-table-container">
|
||
<table class="keyboard-shortcut-table" cellpadding="10">
|
||
<thead>
|
||
<tr class="text-nowrap">
|
||
<th>${m("shortcuts.action_name")}</th>
|
||
<th>${m("shortcuts.shortcuts")}</th>
|
||
<th>${m("shortcuts.default_shortcuts")}</th>
|
||
<th>${m("shortcuts.description")}</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody></tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="shortcuts-options-buttons">
|
||
<button class="options-keyboard-shortcuts-reload-app btn btn-primary">${m("shortcuts.reload_app")}</button>
|
||
|
||
<button class="options-keyboard-shortcuts-set-all-to-default btn btn-secondary">${m("shortcuts.set_all_to_default")}</button>
|
||
</div>
|
||
</div>`;let ff;class B1 extends ae{doRender(){this.$widget=$(R1),this.$widget.find(".options-keyboard-shortcuts-reload-app").on("click",()=>ct.reloadFrontendApp());const t=this.$widget.find(".keyboard-shortcut-table tbody");pt.get("keyboard-actions").then(i=>{ff=i;for(const n of i){const s=$("<tr>");n.separator?s.append($('<td class="separator" colspan="4">').attr("style","background-color: var(--accented-background-color); font-weight: bold;").text(n.separator)):n.defaultShortcuts&&n.actionName&&s.append($("<td>").text(n.actionName)).append($("<td>").append($('<input type="text" class="form-control">').val((n.effectiveShortcuts??[]).join(", ")).attr("data-keyboard-action-name",n.actionName).attr("data-default-keyboard-shortcuts",n.defaultShortcuts.join(", ")))).append($("<td>").text(n.defaultShortcuts.join(", "))).append($("<td>").text(n.description??"")),t.append(s)}}),t.on("change","input.form-control",i=>{const n=this.$widget.find(i.target),s=n.attr("data-keyboard-action-name");if(!s)return;const a=n.val().replace("+,","+Comma").split(",").map(c=>c.replace("+Comma","+,")).filter(c=>!!c),l=`keyboardShortcuts${s.substr(0,1).toUpperCase()}${s.substr(1)}`;this.updateOption(l,JSON.stringify(a))}),this.$widget.find(".options-keyboard-shortcuts-set-all-to-default").on("click",async()=>{await Me.confirm(m("shortcuts.confirm_reset"))&&t.find("input.form-control").each((i,n)=>{const s=this.$widget.find(n).attr("data-default-keyboard-shortcuts");s&&this.$widget.find(n).val()!==s&&this.$widget.find(n).val(s).trigger("change")})});const e=this.$widget.find(".keyboard-shortcut-filter");e.on("keyup",()=>{const i=String(e.val()).trim().toLowerCase();t.find("tr").each((n,s)=>{if(!i){this.$widget.find(s).show();return}const a=this.$widget.find(s).find("input").attr("data-keyboard-action-name");if(!a){this.$widget.find(s).hide();return}const l=ff.find(c=>c.actionName===a);if(!l||!l.actionName){this.$widget.find(s).hide();return}this.$widget.find(s).toggle(!!(l.actionName.toLowerCase().includes(i)||(l.defaultShortcuts??[]).some(c=>c.toLowerCase().includes(i))||(l.effectiveShortcuts??[]).some(c=>c.toLowerCase().includes(i))||l.description&&l.description.toLowerCase().includes(i)))})})}}const z1=`
|
||
<div class="options-section">
|
||
<h4>${m("heading_style.title")}</h4>
|
||
|
||
<div role="group">
|
||
<label class="tn-radio">
|
||
<input name="heading-style" type="radio" value="plain" />
|
||
${m("heading_style.plain")}
|
||
</label>
|
||
|
||
<label class="tn-radio">
|
||
<input name="heading-style" type="radio" value="underline" />
|
||
${m("heading_style.underline")}
|
||
</label>
|
||
|
||
<label class="tn-radio">
|
||
<input name="heading-style" type="radio" value="markdown" />
|
||
${m("heading_style.markdown")}
|
||
</label>
|
||
</div>
|
||
</div>`;class F1 extends ae{$body;doRender(){this.$widget=$(z1),this.$body=$("body"),this.$widget.find('input[name="heading-style"]').on("change",()=>{const t=String(this.$widget.find('input[name="heading-style"]:checked').val());this.toggleBodyClass("heading-style-",t),this.updateOption("headingStyle",t)})}async optionsLoaded(t){this.$widget.find(`input[name="heading-style"][value="${t.headingStyle}"]`).prop("checked","true")}toggleBodyClass(t,e){for(const i of Array.from(this.$body[0].classList))i.startsWith(t)&&this.$body.removeClass(i);this.$body.addClass(t+e)}}const W1=`
|
||
<div class="options-section">
|
||
<h4>${m("table_of_contents.title")}</h4>
|
||
|
||
${m("table_of_contents.description")}
|
||
|
||
<div class="form-group">
|
||
<label class="input-group tn-number-unit-pair">
|
||
<input type="number" class="min-toc-headings form-control options-number-input options-number-input" min="0" max="9999999999999999" step="1" />
|
||
<span class="input-group-text">${m("table_of_contents.unit")}</span>
|
||
</label>
|
||
</div>
|
||
|
||
<p class="form-text">${m("table_of_contents.disable_info")}</p>
|
||
|
||
<p class="form-text">${m("table_of_contents.shortcut_info")}</p>
|
||
</div>`;class H1 extends ae{$minTocHeadings;doRender(){this.$widget=$(W1),this.$minTocHeadings=this.$widget.find(".min-toc-headings"),this.$minTocHeadings.on("change",()=>this.updateOption("minTocHeadings",this.$minTocHeadings.val()))}async optionsLoaded(t){this.$minTocHeadings.val(t.minTocHeadings)}}const V1=`
|
||
<div class="options-section">
|
||
<h4>${m("highlights_list.title")}</h4>
|
||
|
||
<p>${m("highlights_list.description")}</p>
|
||
|
||
<div>
|
||
<label class="tn-checkbox"><input type="checkbox" class="highlights-list-check form-check-input" value="bold"> ${m("highlights_list.bold")}</label>
|
||
<label class="tn-checkbox"><input type="checkbox" class="highlights-list-check form-check-input" value="italic"> ${m("highlights_list.italic")}</label>
|
||
<label class="tn-checkbox"><input type="checkbox" class="highlights-list-check form-check-input" value="underline"> ${m("highlights_list.underline")}</label>
|
||
<label class="tn-checkbox"><input type="checkbox" class="highlights-list-check form-check-input" value="color"> ${m("highlights_list.color")}</label>
|
||
<label class="tn-checkbox"><input type="checkbox" class="highlights-list-check form-check-input" value="bgColor"> ${m("highlights_list.bg_color")}</label>
|
||
</div>
|
||
|
||
<hr />
|
||
|
||
<h5>${m("highlights_list.visibility_title")}</h5>
|
||
|
||
<p class="form-text">${m("highlights_list.visibility_description")}</p>
|
||
|
||
<p class="form-text">${m("highlights_list.shortcut_info")}</p>
|
||
</div>`;class U1 extends ae{$hlt;doRender(){this.$widget=$(V1),this.$hlt=this.$widget.find("input.highlights-list-check"),this.$hlt.on("change",()=>{const t=this.$widget.find('input.highlights-list-check[type="checkbox"]:checked').map(function(){return this.value}).get();this.updateOption("highlightsList",JSON.stringify(t))})}async optionsLoaded(t){const e=JSON.parse(t.highlightsList);this.$widget.find('input.highlights-list-check[type="checkbox"]').each(function(){$.inArray($(this).val(),e)!==-1?$(this).prop("checked",!0):$(this).prop("checked",!1)})}}const j1=`
|
||
<div class="options-section">
|
||
<h4>${m("text_auto_read_only_size.title")}</h4>
|
||
|
||
<p class="form-text">${m("text_auto_read_only_size.description")}</p>
|
||
|
||
<div class="form-group">
|
||
<label for="auto-readonly-size-text">${m("text_auto_read_only_size.label")}</label>
|
||
<label class="input-group tn-number-unit-pair">
|
||
<input id="auto-readonly-size-text" class="auto-readonly-size-text form-control options-number-input" type="number" min="0">
|
||
<span class="input-group-text">${m("text_auto_read_only_size.unit")}</span>
|
||
</label>
|
||
</div>
|
||
</div>`;class q1 extends ae{$autoReadonlySizeText;doRender(){this.$widget=$(j1),this.$autoReadonlySizeText=this.$widget.find(".auto-readonly-size-text"),this.$autoReadonlySizeText.on("change",()=>this.updateOption("autoReadonlySizeText",this.$autoReadonlySizeText.val()))}async optionsLoaded(t){this.$autoReadonlySizeText.val(t.autoReadonlySizeText)}}const K1=`
|
||
<div class="options-section">
|
||
<h4>${m("custom_date_time_format.title")}</h4>
|
||
|
||
<p class="description">
|
||
${m("custom_date_time_format.description")}
|
||
</p>
|
||
|
||
<div class="form-group row align-items-center">
|
||
<div class="col-6">
|
||
<label for="custom-date-time-format">${m("custom_date_time_format.format_string")}</label>
|
||
<input type="text" id="custom-date-time-format" class="form-control custom-date-time-format" placeholder="YYYY-MM-DD HH:mm">
|
||
</div>
|
||
<div class="col-6">
|
||
<label>${m("custom_date_time_format.formatted_time")}</label>
|
||
<div class="formatted-date"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`;class Z1 extends ae{$formatInput;$formattedDate;doRender(){return this.$widget=$(K1),this.$formatInput=this.$widget.find("input.custom-date-time-format"),this.$formattedDate=this.$widget.find(".formatted-date"),this.$formatInput.on("input",()=>{const t=ct.formatDateTime(new Date,this.$formatInput.val());this.$formattedDate.text(t)}),this.$formatInput.on("blur keydown",t=>{(t.type==="blur"||t.type==="keydown"&&t.key==="Enter")&&this.updateOption("customDateTimeFormat",this.$formatInput.val())}),this.$widget}async optionsLoaded(t){const e=(await qo.getAction("insertDateTimeToText")).effectiveShortcuts.join(", "),i=await Pe.createLink("_hidden/_options/_optionsShortcuts",{title:e,showTooltip:!1});this.$widget.find(".description").find("kbd").replaceWith(i);const n=t.customDateTimeFormat||"YYYY-MM-DD HH:mm";this.$formatInput.val(n);const s=ct.formatDateTime(new Date,n);this.$formattedDate.text(s)}}const G1=`
|
||
<div class="options-section">
|
||
<h4>${m("code-editor-options.title")}</h4>
|
||
<label class="tn-checkbox">
|
||
<input type="checkbox" class="vim-keymap-enabled form-check-input">
|
||
${m("vim_key_bindings.use_vim_keybindings_in_code_notes")}
|
||
</label>
|
||
<p class="form-text">${m("vim_key_bindings.enable_vim_keybindings")}</p>
|
||
</div>`;class Y1 extends ae{$vimKeymapEnabled;doRender(){this.$widget=$(G1),this.$vimKeymapEnabled=this.$widget.find(".vim-keymap-enabled"),this.$vimKeymapEnabled.on("change",()=>this.updateCheckboxOption("vimKeymapEnabled",this.$vimKeymapEnabled))}async optionsLoaded(t){this.setCheckboxState(this.$vimKeymapEnabled,t.vimKeymapEnabled)}}const J1=`
|
||
<div class="options-section">
|
||
<h4>${m("code_auto_read_only_size.title")}</h4>
|
||
|
||
<p class="form-text">${m("code_auto_read_only_size.description")}</p>
|
||
|
||
<div class="form-group">
|
||
<label for="auto-readonly-size-code">${m("code_auto_read_only_size.label")}</label>
|
||
<label class="input-group tn-number-unit-pair">
|
||
<input id="auto-readonly-size-code" class="auto-readonly-size-code form-control options-number-input" type="number" min="0">
|
||
<span class="input-group-text">${m("code_auto_read_only_size.unit")}</span>
|
||
</label>
|
||
</div>
|
||
</div>`;class Q1 extends ae{$autoReadonlySizeCode;doRender(){this.$widget=$(J1),this.$autoReadonlySizeCode=this.$widget.find(".auto-readonly-size-code"),this.$autoReadonlySizeCode.on("change",()=>this.updateOption("autoReadonlySizeCode",this.$autoReadonlySizeCode.val()))}async optionsLoaded(t){this.$autoReadonlySizeCode.val(t.autoReadonlySizeCode)}}const X1=`
|
||
<div class="options-section">
|
||
<h4>${m("code_mime_types.title")}</h4>
|
||
|
||
<ul class="options-mime-types" style="list-style-type: none;"></ul>
|
||
</div>
|
||
|
||
<style>
|
||
.options-mime-types section,
|
||
.options-mime-types > li:first-of-type {
|
||
margin-bottom: 1em;
|
||
}
|
||
</style>
|
||
`;let tS=1;function eS(o){const t={};o=o.toSorted((e,i)=>e.title.localeCompare(i.title));for(const e of o){const i=e.title.charAt(0).toUpperCase();t[i]||(t[i]=[]),t[i].push(e)}return t}class iS extends ae{$mimeTypes;doRender(){this.$widget=$(X1),this.$mimeTypes=this.$widget.find(".options-mime-types")}async optionsLoaded(t){this.$mimeTypes.empty(),al.loadMimeTypes();const e=Array.from(al.getMimeTypes()),i=e.shift(),n=eS(e);if(i){const s=this.#t(i);s.find("input").attr("disabled",""),this.$mimeTypes.append(s)}for(const[s,a]of Object.entries(n)){const l=$("<section>");l.append($("<h5>").text(s));for(const c of a)l.append(this.#t(c));this.$mimeTypes.append(l)}}async save(){const t=[];this.$mimeTypes.find("input:checked").each((e,i)=>{const n=this.$widget.find(i).attr("data-mime-type");n&&t.push(n)}),await this.updateOption("codeNotesMimeTypes",JSON.stringify(t))}#t(t){const e="code-mime-type-"+tS++,i=$('<label class="tn-checkbox">').append($('<input type="checkbox" class="form-check-input">').attr("id",e).attr("data-mime-type",t.mime).prop("checked",t.enabled)).on("change",()=>this.save()).append(t.title);return $("<li>").append(i)}}const nS=`
|
||
<div class="options-section">
|
||
<style>
|
||
.options-section .disabled-field {
|
||
opacity: 0.5;
|
||
pointer-events: none;
|
||
}
|
||
</style>
|
||
|
||
<h4>${m("images.images_section_title")}</h4>
|
||
|
||
<label class="tn-checkbox">
|
||
<input class="download-images-automatically" type="checkbox" name="download-images-automatically">
|
||
${m("images.download_images_automatically")}
|
||
</label>
|
||
|
||
<p class="form-text">${m("images.download_images_description")}</p>
|
||
|
||
<hr />
|
||
|
||
<label class="tn-checkbox">
|
||
<input class="image-compresion-enabled" type="checkbox" name="image-compression-enabled">
|
||
${m("images.enable_image_compression")}
|
||
</label>
|
||
|
||
<div class="image-compression-enabled-wraper">
|
||
<div class="form-group">
|
||
<label>${m("images.max_image_dimensions")}</label>
|
||
<label class="input-group tn-number-unit-pair">
|
||
<input class="image-max-width-height form-control options-number-input" type="number" min="1">
|
||
<span class="input-group-text">${m("images.max_image_dimensions_unit")}</span>
|
||
</label>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label>${m("images.jpeg_quality_description")}</label>
|
||
<label class="input-group tn-number-unit-pair">
|
||
<input class="image-jpeg-quality form-control options-number-input" min="10" max="100" type="number">
|
||
<span class="input-group-text">%</span>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`;class oS extends ae{$imageMaxWidthHeight;$imageJpegQuality;$downloadImagesAutomatically;$enableImageCompression;$imageCompressionWrapper;doRender(){this.$widget=$(nS),this.$imageMaxWidthHeight=this.$widget.find(".image-max-width-height"),this.$imageJpegQuality=this.$widget.find(".image-jpeg-quality"),this.$imageMaxWidthHeight.on("change",()=>this.updateOption("imageMaxWidthHeight",this.$imageMaxWidthHeight.val())),this.$imageJpegQuality.on("change",()=>this.updateOption("imageJpegQuality",String(this.$imageJpegQuality.val()).trim()||"75")),this.$downloadImagesAutomatically=this.$widget.find(".download-images-automatically"),this.$downloadImagesAutomatically.on("change",()=>this.updateCheckboxOption("downloadImagesAutomatically",this.$downloadImagesAutomatically)),this.$enableImageCompression=this.$widget.find(".image-compresion-enabled"),this.$imageCompressionWrapper=this.$widget.find(".image-compression-enabled-wraper"),this.$enableImageCompression.on("change",()=>{this.updateCheckboxOption("compressImages",this.$enableImageCompression),this.setImageCompression()})}optionsLoaded(t){this.$imageMaxWidthHeight.val(t.imageMaxWidthHeight),this.$imageJpegQuality.val(t.imageJpegQuality),this.setCheckboxState(this.$downloadImagesAutomatically,t.downloadImagesAutomatically),this.setCheckboxState(this.$enableImageCompression,t.compressImages),this.setImageCompression()}setImageCompression(){this.$enableImageCompression.prop("checked")?this.$imageCompressionWrapper.removeClass("disabled-field"):this.$imageCompressionWrapper.addClass("disabled-field")}}const sS=`
|
||
<div class="options-section">
|
||
<h4>${m("spellcheck.title")}</h4>
|
||
|
||
<p>${m("spellcheck.description")}</p>
|
||
</div>
|
||
`,rS=`
|
||
<div class="options-section">
|
||
<h4>${m("spellcheck.title")}</h4>
|
||
|
||
<p class="form-text">${m("spellcheck.restart-required")}</p>
|
||
|
||
<label class="tn-checkbox">
|
||
<input type="checkbox" class="spell-check-enabled">
|
||
${m("spellcheck.enable")}
|
||
</label>
|
||
|
||
<br/>
|
||
|
||
<div class="form-group">
|
||
<label for="spell-check-language-code">${m("spellcheck.language_code_label")}</label>
|
||
<input id="spell-check-language-code" type="text" class="spell-check-language-code form-control" placeholder="${m("spellcheck.language_code_placeholder")}">
|
||
</div>
|
||
|
||
<p class="form-text">${m("spellcheck.multiple_languages_info")}</p>
|
||
|
||
<p class="form-text"><strong>${m("spellcheck.available_language_codes_label")} </strong> <span class="available-language-codes"></span></p>
|
||
</div>`;class aS extends ae{$spellCheckEnabled;$spellCheckLanguageCode;$availableLanguageCodes;doRender(){const t=ct.isElectron()?rS:sS;if(this.$widget=$(t),this.$spellCheckEnabled=this.$widget.find(".spell-check-enabled"),this.$spellCheckLanguageCode=this.$widget.find(".spell-check-language-code"),this.$spellCheckEnabled.on("change",()=>this.updateCheckboxOption("spellCheckEnabled",this.$spellCheckEnabled)),this.$spellCheckLanguageCode.on("change",()=>this.updateOption("spellCheckLanguageCode",this.$spellCheckLanguageCode.val())),this.$availableLanguageCodes=this.$widget.find(".available-language-codes"),ct.isElectron()){const{webContents:e}=ct.dynamicRequire("@electron/remote").getCurrentWindow();this.$availableLanguageCodes.text(e.session.availableSpellCheckerLanguages.join(", "))}}optionsLoaded(t){this.setCheckboxState(this.$spellCheckEnabled,t.spellCheckEnabled),this.$spellCheckLanguageCode.val(t.spellCheckLanguageCode)}}const lS=`
|
||
<div class="options-section">
|
||
<h4 class="password-heading">${m("password.heading")}</h4>
|
||
|
||
<div class="alert alert-warning" role="alert">
|
||
${m("password.alert_message")} <a class="reset-password-button tn-link" href="javascript:">${m("password.reset_link")}</a>
|
||
</div>
|
||
|
||
<form class="change-password-form">
|
||
<div class="old-password-form-group form-group">
|
||
<label for="old-password">${m("password.old_password")}</label>
|
||
<input id="old-password" class="old-password form-control" type="password">
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="new-password1">${m("password.new_password")}</label>
|
||
<input id="new-password1" class="new-password1 form-control" type="password">
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="new-password2">${m("password.new_password_confirmation")}</label>
|
||
<input id="new-password2" class="new-password2 form-control" type="password">
|
||
</div>
|
||
|
||
<button class="save-password-button btn btn-primary">${m("password.change_password")}</button>
|
||
</form>
|
||
</div>
|
||
`;class cS extends ae{$passwordHeading;$changePasswordForm;$oldPassword;$newPassword1;$newPassword2;$savePasswordButton;$resetPasswordButton;$protectedSessionTimeout;doRender(){this.$widget=$(lS),this.$passwordHeading=this.$widget.find(".password-heading"),this.$changePasswordForm=this.$widget.find(".change-password-form"),this.$oldPassword=this.$widget.find(".old-password"),this.$newPassword1=this.$widget.find(".new-password1"),this.$newPassword2=this.$widget.find(".new-password2"),this.$savePasswordButton=this.$widget.find(".save-password-button"),this.$resetPasswordButton=this.$widget.find(".reset-password-button"),this.$resetPasswordButton.on("click",async()=>{if(confirm(m("password.reset_confirmation"))){await pt.post("password/reset?really=yesIReallyWantToResetPasswordAndLoseAccessToMyProtectedNotes");const t=await pt.get("options");this.optionsLoaded(t),ft.showError(m("password.reset_success_message"))}}),this.$changePasswordForm.on("submit",()=>this.save()),this.$protectedSessionTimeout=this.$widget.find(".protected-session-timeout-in-seconds"),this.$protectedSessionTimeout.on("change",()=>this.updateOption("protectedSessionTimeout",this.$protectedSessionTimeout.val()))}optionsLoaded(t){const e=t.isPasswordSet==="true";this.$widget.find(".old-password-form-group").toggle(e),this.$passwordHeading.text(e?m("password.change_password_heading"):m("password.set_password_heading")),this.$savePasswordButton.text(e?m("password.change_password"):m("password.set_password")),this.$protectedSessionTimeout.val(t.protectedSessionTimeout)}save(){const t=this.$oldPassword.val(),e=this.$newPassword1.val(),i=this.$newPassword2.val();return this.$oldPassword.val(""),this.$newPassword1.val(""),this.$newPassword2.val(""),e!==i?(ft.showError(m("password.password_mismatch")),!1):(pt.post("password/change",{current_password:t,new_password:e}).then(n=>{n.success?(ft.showError(m("password.password_changed_success")),Mi.resetProtectedSession()):n.message&&ft.showError(n.message)}),!1)}}const dS=o=>`
|
||
<div class="form-group">
|
||
<label for="${o.widgetId}">${m(o.widgetLabelId)}</label>
|
||
<div class="d-flex gap-2">
|
||
<input id="${o.widgetId}" class="form-control options-number-input" type="number" min="0" steps="1" required>
|
||
<select id="${o.widgetId}-time-scale" class="form-select duration-selector" required>
|
||
${o.includedTimeScales?.has("seconds")?`<option value="1">${m("duration.seconds")}</option>`:""}
|
||
${o.includedTimeScales?.has("minutes")?`<option value="60">${m("duration.minutes")}</option>`:""}
|
||
${o.includedTimeScales?.has("hours")?`<option value="3600">${m("duration.hours")}</option>`:""}
|
||
${o.includedTimeScales?.has("days")?`<option value="86400">${m("duration.days")}</option>`:""}
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
<style>
|
||
.duration-selector {
|
||
width: auto;
|
||
}
|
||
</style>`;class Gl extends ae{$timeValueInput;$timeScaleSelect;internalTimeInSeconds;widgetId;widgetLabelId;optionValueId;optionTimeScaleId;includedTimeScales;minimumSeconds;constructor(t){super(),this.widgetId=t.widgetId,this.widgetLabelId=t.widgetLabelId,this.optionValueId=t.optionValueId,this.optionTimeScaleId=t.optionTimeScaleId,this.includedTimeScales=t.includedTimeScales||new Set(["seconds","minutes","hours","days"]),this.minimumSeconds=t.minimumSeconds||0}doRender(){this.$widget=$(dS({widgetId:this.widgetId,widgetLabelId:this.widgetLabelId,includedTimeScales:this.includedTimeScales})),this.$timeValueInput=this.$widget.find(`#${this.widgetId}`),this.$timeScaleSelect=this.$widget.find(`#${this.widgetId}-time-scale`),this.$timeValueInput.on("change",()=>{const t=this.$timeValueInput.val(),e=this.$timeScaleSelect.val();!this.handleTimeValidation()||typeof e!="string"||!t||(this.setInternalTimeInSeconds(this.convertTime(t,e).toOption()),this.updateOption(this.optionValueId,this.internalTimeInSeconds))}),this.$timeScaleSelect.on("change",()=>{const t=this.$timeScaleSelect.val();if(!this.handleTimeValidation()||typeof t!="string")return;const e=this.convertTime(this.internalTimeInSeconds,t).toDisplay();this.updateOption(this.optionTimeScaleId,t),this.$timeValueInput.val(e).trigger("change")})}async optionsLoaded(t){const e=Qt.getInt(this.optionValueId)||0,i=Qt.getInt(this.optionTimeScaleId)||1;this.setInternalTimeInSeconds(e);const n=this.convertTime(e,i).toDisplay();this.$timeValueInput.val(n),this.$timeScaleSelect.val(i)}convertTime(t,e){const i=typeof t=="number"?t:parseInt(t);if(Number.isNaN(i))throw new Error(`Time needs to be a valid integer, but received: ${t}`);const n=typeof e=="number"?e:parseInt(e);if(Number.isNaN(n)||n<1)throw new Error(`TimeScale needs to be a valid integer >= 1, but received: ${e}`);return{toOption:()=>Math.ceil(i*n),toDisplay:()=>Math.ceil(i/n)}}handleTimeValidation(){return this.$timeValueInput.is(":invalid")?(ft.showError(m("time_selector.invalid_input")),!1):!0}setInternalTimeInSeconds(t){return t<this.minimumSeconds?(ft.showError(m("time_selector.minimum_input",{minimumSeconds:this.minimumSeconds})),this.internalTimeInSeconds=this.minimumSeconds):this.internalTimeInSeconds=t}}const hS=`
|
||
<div class="options-section">
|
||
<h4>${m("password.protected_session_timeout")}</h4>
|
||
|
||
<p class="form-text">
|
||
${m("password.protected_session_timeout_description")} <a class="tn-link" href="https://triliumnext.github.io/Docs/Wiki/protected-notes.html" class="external">${m("password.wiki")}</a> ${m("password.for_more_info")}
|
||
</p>
|
||
<div id="time-selector-placeholder"></div>
|
||
</div>`;class uS extends Gl{constructor(){super({widgetId:"protected-session-timeout",widgetLabelId:"password.protected_session_timeout_label",optionValueId:"protectedSessionTimeout",optionTimeScaleId:"protectedSessionTimeoutTimeScale",minimumSeconds:60}),super.doRender()}doRender(){const t=this.$widget;this.$widget=$(hS),this.$widget.find("#time-selector-placeholder").replaceWith(t)}}function Dr(o,t="medium",e="medium"){const i=navigator.language;let n;if(typeof o=="string"||typeof o=="number")n=new Date(o);else if(o instanceof Date)n=o;else throw new TypeError('Invalid type for the "date" argument.');if(e!=="none"&&t!=="none")return new Intl.DateTimeFormat(navigator.language,{dateStyle:t,timeStyle:e}).format(n);if(e==="none"&&t!=="none")return n.toLocaleDateString(i,{dateStyle:t});if(t==="none"&&e!=="none")return n.toLocaleTimeString(i,{timeStyle:e});throw new Error("Incorrect state.")}const pS=`
|
||
<div class="etapi-options-section options-section">
|
||
<h4>${m("etapi.title")}</h4>
|
||
|
||
<p class="form-text">${m("etapi.description")} <br/>
|
||
${m("etapi.see_more",{link_to_wiki:`<a class="tn-link" href="https://triliumnext.github.io/Docs/Wiki/etapi.html">${m("etapi.wiki")}</a>`,link_to_openapi_spec:`<a class="tn-link" onclick="window.open('etapi/etapi.openapi.yaml')" href="etapi/etapi.openapi.yaml">${m("etapi.openapi_spec")}</a>`,link_to_swagger_ui:`<a class="tn-link" href="#_help_f3xpgx6H01PW">${m("etapi.swagger_ui")}</a>`})}
|
||
</p>
|
||
|
||
<button type="button" class="create-etapi-token btn btn-sm">
|
||
<span class="bx bx-plus"></span>
|
||
${m("etapi.create_token")}
|
||
</button>
|
||
|
||
<hr />
|
||
|
||
<h5>${m("etapi.existing_tokens")}</h5>
|
||
|
||
<div class="no-tokens-yet">${m("etapi.no_tokens_yet")}</div>
|
||
|
||
<div style="overflow: auto; height: 500px;">
|
||
<table class="tokens-table table table-stripped">
|
||
<thead>
|
||
<tr>
|
||
<th>${m("etapi.token_name")}</th>
|
||
<th>${m("etapi.created")}</th>
|
||
<th>${m("etapi.actions")}</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody></tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<style>
|
||
.token-table-button {
|
||
display: inline-block;
|
||
cursor: pointer;
|
||
padding: 3px;
|
||
margin-right: 20px;
|
||
font-size: large;
|
||
border: 1px solid transparent;
|
||
border-radius: var(--button-border-radius);
|
||
}
|
||
|
||
.token-table-button:hover {
|
||
border: 1px solid var(--button-border-color);
|
||
}
|
||
</style>`;class fS extends ae{doRender(){this.$widget=$(pS),this.$widget.find(".create-etapi-token").on("click",async()=>{const t=await Me.prompt({title:m("etapi.new_token_title"),message:m("etapi.new_token_message"),defaultValue:m("etapi.default_token_name")});if(!t?.trim()){ft.showError(m("etapi.error_empty_name"));return}const{authToken:e}=await pt.post("etapi-tokens",{tokenName:t});await Me.prompt({title:m("etapi.token_created_title"),message:m("etapi.token_created_message"),defaultValue:e}),this.refreshTokens()}),this.refreshTokens()}async refreshTokens(){const t=this.$widget.find(".no-tokens-yet"),e=this.$widget.find(".tokens-table"),i=await pt.get("etapi-tokens");t.toggle(i.length===0),e.toggle(i.length>0);const n=e.find("tbody");n.empty();for(const s of i)n.append($("<tr>").append($("<td>").text(s.name)).append($("<td>").text(Dr(s.utcDateCreated))).append($("<td>").append($(`<span class="bx bx-edit-alt token-table-button icon-action" title="${m("etapi.rename_token")}"></span>`).on("click",()=>this.renameToken(s.etapiTokenId,s.name)),$(`<span class="bx bx-trash token-table-button icon-action" title="${m("etapi.delete_token")}"></span>`).on("click",()=>this.deleteToken(s.etapiTokenId,s.name)))))}async renameToken(t,e){const i=await Me.prompt({title:m("etapi.rename_token_title"),message:m("etapi.rename_token_message"),defaultValue:e});i?.trim()&&(await pt.patch(`etapi-tokens/${t}`,{name:i}),this.refreshTokens())}async deleteToken(t,e){await Me.confirm(m("etapi.delete_token_confirmation",{name:e}))&&(await pt.remove(`etapi-tokens/${t}`),this.refreshTokens())}}const mS=`
|
||
<div class="options-section">
|
||
<h4>${m("backup.automatic_backup")}</h4>
|
||
|
||
<p>${m("backup.automatic_backup_description")}</p>
|
||
|
||
<ul style="list-style: none">
|
||
<li>
|
||
<label class="tn-checkbox">
|
||
<input type="checkbox" class="daily-backup-enabled form-check-input">
|
||
${m("backup.enable_daily_backup")}
|
||
</label>
|
||
</li>
|
||
<li>
|
||
<label class="tn-checkbox">
|
||
<input type="checkbox" class="weekly-backup-enabled form-check-input">
|
||
${m("backup.enable_weekly_backup")}
|
||
</label>
|
||
</li>
|
||
<li>
|
||
<label class="tn-checkbox">
|
||
<input type="checkbox" class="monthly-backup-enabled form-check-input">
|
||
${m("backup.enable_monthly_backup")}
|
||
</label>
|
||
</li>
|
||
</ul>
|
||
|
||
<p class="form-text">${m("backup.backup_recommendation")}</p>
|
||
</div>
|
||
|
||
<div class="options-section">
|
||
<h4>${m("backup.backup_now")}</h4>
|
||
|
||
<button class="backup-database-button btn btn-secondary">${m("backup.backup_database_now")}</button>
|
||
</div>
|
||
|
||
<div class="options-section">
|
||
<h4>${m("backup.existing_backups")}</h4>
|
||
|
||
<table class="table table-stripped">
|
||
<colgroup>
|
||
<col width="33%" />
|
||
<col />
|
||
</colgroup>
|
||
<thead>
|
||
<tr>
|
||
<th>${m("backup.date-and-time")}</th>
|
||
<th>${m("backup.path")}</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="existing-backup-list-items">
|
||
</tbody>
|
||
</table>
|
||
|
||
</div>
|
||
`;class gS extends ae{$backupDatabaseButton;$dailyBackupEnabled;$weeklyBackupEnabled;$monthlyBackupEnabled;$existingBackupList;doRender(){this.$widget=$(mS),this.$backupDatabaseButton=this.$widget.find(".backup-database-button"),this.$backupDatabaseButton.on("click",async()=>{const{backupFile:t}=await pt.post("database/backup-database");ft.showMessage(m("backup.database_backed_up_to",{backupFilePath:t}),1e4),this.refresh()}),this.$dailyBackupEnabled=this.$widget.find(".daily-backup-enabled"),this.$weeklyBackupEnabled=this.$widget.find(".weekly-backup-enabled"),this.$monthlyBackupEnabled=this.$widget.find(".monthly-backup-enabled"),this.$dailyBackupEnabled.on("change",()=>this.updateCheckboxOption("dailyBackupEnabled",this.$dailyBackupEnabled)),this.$weeklyBackupEnabled.on("change",()=>this.updateCheckboxOption("weeklyBackupEnabled",this.$weeklyBackupEnabled)),this.$monthlyBackupEnabled.on("change",()=>this.updateCheckboxOption("monthlyBackupEnabled",this.$monthlyBackupEnabled)),this.$existingBackupList=this.$widget.find(".existing-backup-list-items")}optionsLoaded(t){this.setCheckboxState(this.$dailyBackupEnabled,t.dailyBackupEnabled),this.setCheckboxState(this.$weeklyBackupEnabled,t.weeklyBackupEnabled),this.setCheckboxState(this.$monthlyBackupEnabled,t.monthlyBackupEnabled),pt.get("database/backups").then(e=>{if(this.$existingBackupList.empty(),!e.length){this.$existingBackupList.append($(`
|
||
<tr>
|
||
<td class="empty-table-placeholder" colspan="2">${m("backup.no_backup_yet")}</td>
|
||
</tr>
|
||
`));return}e.sort((i,n)=>i.mtime<n.mtime?1:i.mtime>n.mtime?-1:0);for(const{filePath:i,mtime:n}of e)this.$existingBackupList.append($(`
|
||
<tr>
|
||
<td>${n?Dr(n):"-"}</td>
|
||
<td>${i}</td>
|
||
</tr>
|
||
`))})}}const vS=`
|
||
<div class="options-section">
|
||
<h4 style="margin-top: 0px;">${m("sync_2.config_title")}</h4>
|
||
|
||
<form class="sync-setup-form">
|
||
<div class="form-group">
|
||
<label for="sync-server-host" >${m("sync_2.server_address")}</label>
|
||
<input id="sync-server-host" class="sync-server-host form-control" placeholder="https://<host>:<port>">
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="sync-proxy form-control" >${m("sync_2.proxy_label")}</label>
|
||
<input id="sync-proxy form-control" class="sync-proxy form-control" placeholder="https://<host>:<port>">
|
||
|
||
<p class="form-text"><strong>${m("sync_2.note")}:</strong> ${m("sync_2.note_description")}</p>
|
||
<p class="form-text">${m("sync_2.special_value_description")}</p>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="sync-server-timeout">${m("sync_2.timeout")}</label>
|
||
<label class="input-group tn-number-unit-pair">
|
||
<input id="sync-server-timeout" class="sync-server-timeout form-control" min="1" max="10000000" type="number" style="text-align: left;">
|
||
<span class="input-group-text">${m("sync_2.timeout_unit")}</span>
|
||
</label>
|
||
</div>
|
||
|
||
<div style="display: flex; justify-content: space-between;">
|
||
<button class="btn btn-primary">${m("sync_2.save")}</button>
|
||
|
||
<button class="btn btn-secondary" type="button" data-help-page="synchronization.html">${m("sync_2.help")}</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
|
||
<div class="options-section">
|
||
<h4>${m("sync_2.test_title")}</h4>
|
||
|
||
<p>${m("sync_2.test_description")}</p>
|
||
|
||
<button class="test-sync-button btn btn-secondary">${m("sync_2.test_button")}</button>
|
||
</div>`;class yS extends ae{$form;$syncServerHost;$syncServerTimeout;$syncProxy;$testSyncButton;doRender(){this.$widget=$(vS),this.$form=this.$widget.find(".sync-setup-form"),this.$syncServerHost=this.$widget.find(".sync-server-host"),this.$syncServerTimeout=this.$widget.find(".sync-server-timeout"),this.$syncProxy=this.$widget.find(".sync-proxy"),this.$testSyncButton=this.$widget.find(".test-sync-button"),this.$form.on("submit",()=>this.save()),this.$testSyncButton.on("click",async()=>{const t=await pt.post("sync/test");t.success?ft.showMessage(t.message):ft.showError(m("sync_2.handshake_failed",{message:t.message}))})}optionsLoaded(t){this.$syncServerHost.val(t.syncServerHost),this.$syncServerTimeout.val(t.syncServerTimeout),this.$syncProxy.val(t.syncProxy)}save(){return this.updateMultipleOptions({syncServerHost:String(this.$syncServerHost.val()),syncServerTimeout:String(this.$syncServerTimeout.val()),syncProxy:String(this.$syncProxy.val())}),!1}}const bS=`
|
||
<div class="options-section">
|
||
<h4>${m("search_engine.title")}</h4>
|
||
|
||
<p class="form-text">${m("search_engine.custom_search_engine_info")}</p>
|
||
|
||
<form class="sync-setup-form">
|
||
<div class="form-group">
|
||
<label for="predefined-search-engine-select">${m("search_engine.predefined_templates_label")}</label>
|
||
<select id="predefined-search-engine-select" class="predefined-search-engine-select form-control">
|
||
<option value="Bing">${m("search_engine.bing")}</option>
|
||
<option value="Baidu">${m("search_engine.baidu")}</option>
|
||
<option value="DuckDuckGo">${m("search_engine.duckduckgo")}</option>
|
||
<option value="Google">${m("search_engine.google")}</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label>${m("search_engine.custom_name_label")}</label>
|
||
<input type="text" class="custom-search-engine-name form-control" placeholder="${m("search_engine.custom_name_placeholder")}">
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label>${m("search_engine.custom_url_label")}</label>
|
||
<input type="text" class="custom-search-engine-url form-control" placeholder="${m("search_engine.custom_url_placeholder")}">
|
||
</div>
|
||
|
||
<div style="display: flex; justify-content: space-between;">
|
||
<button class="btn btn-primary">${m("search_engine.save_button")}</button>
|
||
</div>
|
||
</form>
|
||
</div>`,wS={Bing:"https://www.bing.com/search?q={keyword}",Baidu:"https://www.baidu.com/s?wd={keyword}",DuckDuckGo:"https://duckduckgo.com/?q={keyword}",Google:"https://www.google.com/search?q={keyword}"};class _S extends ae{$form;$predefinedSearchEngineSelect;$customSearchEngineName;$customSearchEngineUrl;isEnabled(){return super.isEnabled()&&ct.isElectron()}doRender(){this.$widget=$(bS),this.$form=this.$widget.find(".sync-setup-form"),this.$predefinedSearchEngineSelect=this.$widget.find(".predefined-search-engine-select"),this.$customSearchEngineName=this.$widget.find(".custom-search-engine-name"),this.$customSearchEngineUrl=this.$widget.find(".custom-search-engine-url"),this.$predefinedSearchEngineSelect.on("change",()=>{const t=String(this.$predefinedSearchEngineSelect.val());this.$customSearchEngineName[0].value=t,this.$customSearchEngineUrl[0].value=wS[t]}),this.$form.on("submit",()=>{this.updateMultipleOptions({customSearchEngineName:this.$customSearchEngineName.val(),customSearchEngineUrl:this.$customSearchEngineUrl.val()})})}async optionsLoaded(t){this.$predefinedSearchEngineSelect.val(""),this.$customSearchEngineName[0].value=t.customSearchEngineName,this.$customSearchEngineUrl[0].value=t.customSearchEngineUrl}}const xS=`
|
||
<div class="options-section">
|
||
<h4>${m("tray.title")}</h4>
|
||
|
||
<label class="tn-checkbox">
|
||
<input type="checkbox" class="tray-enabled">
|
||
${m("tray.enable_tray")}
|
||
</label>
|
||
</div>`;class kS extends ae{$trayEnabled;doRender(){this.$widget=$(xS),this.$trayEnabled=this.$widget.find(".tray-enabled"),this.$trayEnabled.on("change",()=>this.updateOption("disableTray",this.$trayEnabled.is(":checked")?"false":"true"))}isEnabled(){return ct.isElectron()}async optionsLoaded(t){this.$trayEnabled.prop("checked",t.disableTray!=="true")}}const CS=`
|
||
<div class="options-section">
|
||
<h4>${m("note_erasure_timeout.note_erasure_timeout_title")}</h4>
|
||
<p class="form-text">${m("note_erasure_timeout.note_erasure_description")}</p>
|
||
<div id="time-selector-placeholder"></div>
|
||
<p class="form-text">${m("note_erasure_timeout.manual_erasing_description")}</p>
|
||
<button id="erase-deleted-notes-now-button" class="btn btn-secondary">${m("note_erasure_timeout.erase_deleted_notes_now")}</button>
|
||
</div>`;class $S extends Gl{$eraseDeletedNotesButton;constructor(){super({widgetId:"erase-entities-after",widgetLabelId:"note_erasure_timeout.erase_notes_after",optionValueId:"eraseEntitiesAfterTimeInSeconds",optionTimeScaleId:"eraseEntitiesAfterTimeScale"}),super.doRender()}doRender(){const t=this.$widget;this.$widget=$(CS),this.$widget.find("#time-selector-placeholder").replaceWith(t),this.$eraseDeletedNotesButton=this.$widget.find("#erase-deleted-notes-now-button"),this.$eraseDeletedNotesButton.on("click",()=>{pt.post("notes/erase-deleted-notes-now").then(()=>{ft.showMessage(m("note_erasure_timeout.deleted_notes_erased"))})})}}const SS=`
|
||
<div class="options-section">
|
||
<h4>${m("revisions_snapshot_interval.note_revisions_snapshot_interval_title")}</h4>
|
||
|
||
<p class="form-text use-tn-links">${m("revisions_snapshot_interval.note_revisions_snapshot_description")}</p>
|
||
<div id="time-selector-placeholder"></div>
|
||
</div>`;class TS extends Gl{constructor(){super({widgetId:"revision-snapshot-time-interval",widgetLabelId:"revisions_snapshot_interval.snapshot_time_interval_label",optionValueId:"revisionSnapshotTimeInterval",optionTimeScaleId:"revisionSnapshotTimeIntervalTimeScale",minimumSeconds:10}),super.doRender()}doRender(){const t=this.$widget;this.$widget=$(SS),this.$widget.find("#time-selector-placeholder").replaceWith(t)}}const ES=`
|
||
<div class="options-section">
|
||
<h4>${m("revisions_snapshot_limit.note_revisions_snapshot_limit_title")}</h4>
|
||
|
||
<p class="form-text">${m("revisions_snapshot_limit.note_revisions_snapshot_limit_description")}</p>
|
||
|
||
<div class="form-group">
|
||
<label>${m("revisions_snapshot_limit.snapshot_number_limit_label")}</label>
|
||
<label class="input-group tn-number-unit-pair">
|
||
<input class="revision-snapshot-number-limit form-control options-number-input" type="number" min="-1">
|
||
<span class="input-group-text">${m("revisions_snapshot_limit.snapshot_number_limit_unit")}</span>
|
||
</label>
|
||
</div>
|
||
|
||
<button class="erase-excess-revision-snapshots-now-button btn btn-sm">
|
||
${m("revisions_snapshot_limit.erase_excess_revision_snapshots")}</button>
|
||
</div>`;class IS extends ae{$revisionSnapshotsNumberLimit;$eraseExcessRevisionSnapshotsButton;doRender(){this.$widget=$(ES),this.$revisionSnapshotsNumberLimit=this.$widget.find(".revision-snapshot-number-limit"),this.$revisionSnapshotsNumberLimit.on("change",()=>{let t=parseInt(String(this.$revisionSnapshotsNumberLimit.val()),10);!isNaN(t)&&t>=-1&&this.updateOption("revisionSnapshotNumberLimit",t)}),this.$eraseExcessRevisionSnapshotsButton=this.$widget.find(".erase-excess-revision-snapshots-now-button"),this.$eraseExcessRevisionSnapshotsButton.on("click",()=>{pt.post("revisions/erase-all-excess-revisions").then(()=>{ft.showMessage(m("revisions_snapshot_limit.erase_excess_revision_snapshots_prompt"))})})}async optionsLoaded(t){this.$revisionSnapshotsNumberLimit.val(t.revisionSnapshotNumberLimit)}}const AS=`
|
||
<div class="options-section">
|
||
<h4>${m("network_connections.network_connections_title")}</h4>
|
||
|
||
<label class="tn-checkbox">
|
||
<input class="check-for-updates form-check-input" type="checkbox" name="check-for-updates">
|
||
${m("network_connections.check_for_updates")}
|
||
</label>
|
||
</div>`;class LS extends ae{$checkForUpdates;doRender(){this.$widget=$(AS),this.$checkForUpdates=this.$widget.find(".check-for-updates"),this.$checkForUpdates.on("change",()=>this.updateCheckboxOption("checkForUpdates",this.$checkForUpdates))}async optionsLoaded(t){this.setCheckboxState(this.$checkForUpdates,t.checkForUpdates)}}const Hc=["h1","h2","h3","h4","h5","h6","blockquote","p","a","ul","ol","li","b","i","strong","em","strike","s","del","abbr","code","hr","br","div","table","thead","caption","tbody","tfoot","tr","th","td","pre","section","img","figure","figcaption","span","label","input","details","summary","address","aside","footer","header","hgroup","main","nav","dl","dt","menu","bdi","bdo","dfn","kbd","mark","q","time","var","wbr","area","map","track","video","audio","picture","del","ins","en-media","acronym","article","big","button","cite","col","colgroup","data","dd","fieldset","form","legend","meter","noscript","option","progress","rp","samp","small","sub","sup","template","textarea","tt"],NS=`
|
||
<div class="html-import-tags-settings options-section">
|
||
<style>
|
||
.html-import-tags-settings .allowed-html-tags {
|
||
height: 150px;
|
||
margin-bottom: 12px;
|
||
font-family: monospace;
|
||
}
|
||
</style>
|
||
<h4>${m("import.html_import_tags.title")}</h4>
|
||
|
||
<p class="form-text">${m("import.html_import_tags.description")}</p>
|
||
|
||
<textarea class="allowed-html-tags form-control" spellcheck="false"
|
||
placeholder="${m("import.html_import_tags.placeholder")}"></textarea>
|
||
|
||
<div>
|
||
<button class="btn btn-sm btn-secondary reset-to-default">
|
||
${m("import.html_import_tags.reset_button")}
|
||
</button>
|
||
</div>
|
||
</div>`;class MS extends ae{$allowedTags;$resetButton;doRender(){this.$widget=$(NS),this.contentSized(),this.$allowedTags=this.$widget.find(".allowed-html-tags"),this.$resetButton=this.$widget.find(".reset-to-default"),this.$allowedTags.on("change",()=>this.saveTags()),this.$resetButton.on("click",()=>this.resetToDefault()),this.refresh()}async optionsLoaded(t){try{if(t.allowedHtmlTags){const e=JSON.parse(t.allowedHtmlTags);this.$allowedTags.val(e.join(" "))}else this.$allowedTags.val(Hc.join(" "))}catch(e){console.error("Could not load HTML tags:",e),this.$allowedTags.val(Hc.join(" "))}}async saveTags(){const e=(String(this.$allowedTags.val())||"").split(/[\n,\s]+/).map(i=>i.trim()).filter(i=>i.length>0);await this.updateOption("allowedHtmlTags",JSON.stringify(e))}async resetToDefault(){this.$allowedTags.val(Hc.join(`
|
||
`)),await this.saveTags()}}const PS=`
|
||
<div class="options-section">
|
||
<h4>${m("sync.title")}</h4>
|
||
<button class="force-full-sync-button btn btn-secondary">${m("sync.force_full_sync_button")}</button>
|
||
|
||
<button class="fill-entity-changes-button btn btn-secondary">${m("sync.fill_entity_changes_button")}</button>
|
||
</div>`;class OS extends ae{$forceFullSyncButton;$fillEntityChangesButton;doRender(){this.$widget=$(PS),this.$forceFullSyncButton=this.$widget.find(".force-full-sync-button"),this.$fillEntityChangesButton=this.$widget.find(".fill-entity-changes-button"),this.$forceFullSyncButton.on("click",async()=>{await pt.post("sync/force-full-sync"),ft.showMessage(m("sync.full_sync_triggered"))}),this.$fillEntityChangesButton.on("click",async()=>{ft.showMessage(m("sync.filling_entity_changes")),await pt.post("sync/fill-entity-changes"),ft.showMessage(m("sync.sync_rows_filled_successfully"))})}async optionsLoaded(t){}}const DS=`
|
||
<div class="options-section">
|
||
<h4>${m("database_integrity_check.title")}</h4>
|
||
|
||
<p class="form-text">${m("database_integrity_check.description")}</p>
|
||
|
||
<button class="check-integrity-button btn btn-secondary">${m("database_integrity_check.check_button")}</button>
|
||
<button class="find-and-fix-consistency-issues-button btn btn-secondary">${m("consistency_checks.find_and_fix_button")}</button>
|
||
</div>
|
||
`;class RS extends ae{$checkIntegrityButton;$findAndFixConsistencyIssuesButton;doRender(){this.$widget=$(DS),this.$checkIntegrityButton=this.$widget.find(".check-integrity-button"),this.$checkIntegrityButton.on("click",async()=>{ft.showMessage(m("database_integrity_check.checking_integrity"));const{results:t}=await pt.get("database/check-integrity");t.length===1&&t[0].integrity_check==="ok"?ft.showMessage(m("database_integrity_check.integrity_check_succeeded")):ft.showMessage(m("database_integrity_check.integrity_check_failed",{results:JSON.stringify(t,null,2)}),15e3)}),this.$findAndFixConsistencyIssuesButton=this.$widget.find(".find-and-fix-consistency-issues-button"),this.$findAndFixConsistencyIssuesButton.on("click",async()=>{ft.showMessage(m("consistency_checks.finding_and_fixing_message")),await pt.post("database/find-and-fix-consistency-issues"),ft.showMessage(m("consistency_checks.issues_fixed_message"))})}}const BS=`
|
||
<div class="options-section">
|
||
<h4>${m("vacuum_database.title")}</h4>
|
||
|
||
<p class="form-text">${m("vacuum_database.description")}</p>
|
||
|
||
<button class="vacuum-database-button btn btn-secondary">${m("vacuum_database.button_text")}</button>
|
||
</div>`;class zS extends ae{$vacuumDatabaseButton;doRender(){this.$widget=$(BS),this.$vacuumDatabaseButton=this.$widget.find(".vacuum-database-button"),this.$vacuumDatabaseButton.on("click",async()=>{ft.showMessage(m("vacuum_database.vacuuming_database")),await pt.post("database/vacuum-database"),ft.showMessage(m("vacuum_database.database_vacuumed"))})}}const FS=`
|
||
<div class="options-section">
|
||
<style>
|
||
.database-database-anonymization-option {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: flex-start;
|
||
margin-top: 1em;
|
||
}
|
||
|
||
.database-database-anonymization-option p {
|
||
margin-top: .75em;
|
||
flex-grow: 1;
|
||
}
|
||
</style>
|
||
|
||
<h4>${m("database_anonymization.title")}</h4>
|
||
|
||
<div class="row">
|
||
<p class="form-text">${m("database_anonymization.choose_anonymization")}</p>
|
||
|
||
<div class="col-md-6 database-database-anonymization-option">
|
||
<h5>${m("database_anonymization.full_anonymization")}</h5>
|
||
|
||
<p class="form-text">${m("database_anonymization.full_anonymization_description")}</p>
|
||
<button class="anonymize-full-button btn btn-secondary">${m("database_anonymization.save_fully_anonymized_database")}</button>
|
||
</div>
|
||
|
||
<div class="col-md-6 database-database-anonymization-option">
|
||
<h5>${m("database_anonymization.light_anonymization")}</h5>
|
||
|
||
<p class="form-text">${m("database_anonymization.light_anonymization_description")}</p>
|
||
|
||
<button class="anonymize-light-button btn btn-secondary">${m("database_anonymization.save_lightly_anonymized_database")}</button>
|
||
</div>
|
||
</div>
|
||
|
||
<hr />
|
||
|
||
<table class="existing-anonymized-databases-table table table-stripped">
|
||
<thead>
|
||
<th>${m("database_anonymization.existing_anonymized_databases")}</th>
|
||
</thead>
|
||
<tbody class="existing-anonymized-databases">
|
||
</tbody>
|
||
</table>
|
||
</div>`;class WS extends ae{$anonymizeFullButton;$anonymizeLightButton;$existingAnonymizedDatabases;doRender(){this.$widget=$(FS),this.$anonymizeFullButton=this.$widget.find(".anonymize-full-button"),this.$anonymizeLightButton=this.$widget.find(".anonymize-light-button"),this.$anonymizeFullButton.on("click",async()=>{ft.showMessage(m("database_anonymization.creating_fully_anonymized_database"));const t=await pt.post("database/anonymize/full");t.success?ft.showMessage(m("database_anonymization.successfully_created_fully_anonymized_database",{anonymizedFilePath:t.anonymizedFilePath}),1e4):ft.showError(m("database_anonymization.error_creating_anonymized_database")),this.refresh()}),this.$anonymizeLightButton.on("click",async()=>{ft.showMessage(m("database_anonymization.creating_lightly_anonymized_database"));const t=await pt.post("database/anonymize/light");t.success?ft.showMessage(m("database_anonymization.successfully_created_lightly_anonymized_database",{anonymizedFilePath:t.anonymizedFilePath}),1e4):ft.showError(m("database_anonymization.error_creating_anonymized_database")),this.refresh()}),this.$existingAnonymizedDatabases=this.$widget.find(".existing-anonymized-databases")}optionsLoaded(t){pt.get("database/anonymized-databases").then(e=>{this.$existingAnonymizedDatabases.empty(),e.length||(e=[{filePath:m("database_anonymization.no_anonymized_database_yet")}]);for(const{filePath:i}of e)this.$existingAnonymizedDatabases.append($("<tr>").append($("<td>").text(i)))})}}const HS=`<div style="height: 100%; display: flex; flex-direction: column;">
|
||
<style>
|
||
.backend-log-editor {
|
||
flex-grow: 1;
|
||
width: 100%;
|
||
border: none;
|
||
resize: none;
|
||
margin-bottom: 0;
|
||
}
|
||
</style>
|
||
|
||
<pre class="backend-log-editor"></pre
|
||
</div>`;class VS extends Rh{$refreshBackendLog;doRender(){this.$widget=$(HS),this.$editor=this.$widget.find(".backend-log-editor"),super.doRender()}async refresh(){await this.load()}async refreshDataEvent({ntxId:t}){t===this.noteContext?.ntxId&&this.refresh()}getExtraOpts(){return{readOnly:!0,preferPerformance:!0}}async load(){const t=await pt.get("backend-log");await this.initialized,this._update({mime:"text/plain"},t),this.show(),this.scrollToEnd()}}const US=`
|
||
<div class="options-section">
|
||
<h4>${m("attachment_erasure_timeout.attachment_erasure_timeout")}</h4>
|
||
|
||
<p class="form-text">${m("attachment_erasure_timeout.attachment_auto_deletion_description")}</p>
|
||
<div id="time-selector-placeholder"></div>
|
||
|
||
<p class="form-text">${m("attachment_erasure_timeout.manual_erasing_description")}</p>
|
||
<button class="erase-unused-attachments-now-button btn btn-secondary">${m("attachment_erasure_timeout.erase_unused_attachments_now")}</button>
|
||
</div>`;class jS extends Gl{$eraseUnusedAttachmentsNowButton;constructor(){super({widgetId:"erase-unused-attachments-after",widgetLabelId:"attachment_erasure_timeout.erase_attachments_after",optionValueId:"eraseUnusedAttachmentsAfterSeconds",optionTimeScaleId:"eraseUnusedAttachmentsAfterTimeScale"}),super.doRender()}doRender(){const t=this.$widget;this.$widget=$(US),this.$widget.find("#time-selector-placeholder").replaceWith(t),this.$eraseUnusedAttachmentsNowButton=this.$widget.find(".erase-unused-attachments-now-button"),this.$eraseUnusedAttachmentsNowButton.on("click",()=>{pt.post("notes/erase-unused-attachments-now").then(()=>{ft.showMessage(m("attachment_erasure_timeout.unused_attachments_erased"))})})}}const qS=`
|
||
<div class="options-section">
|
||
<h4>${m("ribbon.widgets")}</h4>
|
||
<div>
|
||
<label class="tn-checkbox">
|
||
<input type="checkbox" class="promoted-attributes-open-in-ribbon form-check-input">
|
||
${m("ribbon.promoted_attributes_message")}
|
||
</label>
|
||
</div>
|
||
|
||
<div>
|
||
<label class="tn-checkbox">
|
||
<input type="checkbox" class="edited-notes-open-in-ribbon form-check-input">
|
||
${m("ribbon.edited_notes_message")}
|
||
</label>
|
||
</div>
|
||
</div>`;class KS extends ae{$promotedAttributesOpenInRibbon;$editedNotesOpenInRibbon;doRender(){this.$widget=$(qS),this.$promotedAttributesOpenInRibbon=this.$widget.find(".promoted-attributes-open-in-ribbon"),this.$promotedAttributesOpenInRibbon.on("change",()=>this.updateCheckboxOption("promotedAttributesOpenInRibbon",this.$promotedAttributesOpenInRibbon)),this.$editedNotesOpenInRibbon=this.$widget.find(".edited-notes-open-in-ribbon"),this.$editedNotesOpenInRibbon.on("change",()=>this.updateCheckboxOption("editedNotesOpenInRibbon",this.$editedNotesOpenInRibbon))}async optionsLoaded(t){this.setCheckboxState(this.$promotedAttributesOpenInRibbon,t.promotedAttributesOpenInRibbon),this.setCheckboxState(this.$editedNotesOpenInRibbon,t.editedNotesOpenInRibbon)}}const ZS=`
|
||
<div class="options-section">
|
||
<h4>${m("multi_factor_authentication.title")}</h4>
|
||
<p class="form-text">${m("multi_factor_authentication.description")}</p>
|
||
|
||
<div class="col-md-6 side-checkbox">
|
||
<label class="form-check tn-checkbox">
|
||
<input type="checkbox" class="mfa-enabled-checkbox form-check-input" />
|
||
${m("multi_factor_authentication.mfa_enabled")}
|
||
</label>
|
||
</div>
|
||
|
||
<hr />
|
||
|
||
<div class="mfa-options" style="display: none;">
|
||
<label class="form-label"><b>${m("multi_factor_authentication.mfa_method")}</b></label>
|
||
<div role="group">
|
||
<label class="tn-radio">
|
||
<input class="mfa-method-radio" type="radio" name="mfaMethod" value="totp" />
|
||
<b>${m("multi_factor_authentication.totp_title")}</b>
|
||
</label>
|
||
<label class="tn-radio">
|
||
<input class="mfa-method-radio" type="radio" name="mfaMethod" value="oauth" />
|
||
<b>${m("multi_factor_authentication.oauth_title")}</b>
|
||
</label>
|
||
</div>
|
||
|
||
<div class="totp-options" style="display: none;">
|
||
<p class="form-text">${m("multi_factor_authentication.totp_description")}</p>
|
||
|
||
<hr />
|
||
|
||
<h5>${m("multi_factor_authentication.totp_secret_title")}</h5>
|
||
<div class="admonition note no-totp-secret" role="alert">
|
||
${m("multi_factor_authentication.no_totp_secret_warning")}
|
||
</div>
|
||
|
||
<div class="admonition warning" role="alert">
|
||
${m("multi_factor_authentication.totp_secret_description_warning")}
|
||
</div>
|
||
|
||
<button class="generate-totp btn btn-primary">
|
||
${m("multi_factor_authentication.totp_secret_generate")}
|
||
</button>
|
||
|
||
<hr />
|
||
|
||
<h5>${m("multi_factor_authentication.recovery_keys_title")}</h5>
|
||
<p class="form-text">${m("multi_factor_authentication.recovery_keys_description")}</p>
|
||
<div class="admonition caution">
|
||
${m("multi_factor_authentication.recovery_keys_description_warning")}
|
||
</div>
|
||
|
||
<table style="border: 0px solid white">
|
||
<tbody>
|
||
<tr>
|
||
<td class="key_0"></td>
|
||
<td style="width: 20px" />
|
||
<td class="key_1"></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="key_2"></td>
|
||
<td />
|
||
<td class="key_3"></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="key_4"></td>
|
||
<td />
|
||
<td class="key_5"></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="key_6"></td>
|
||
<td />
|
||
<td class="key_7"></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<br>
|
||
|
||
<button class="generate-recovery-code btn btn-primary"> ${m("multi_factor_authentication.recovery_keys_generate")} </button>
|
||
</div>
|
||
|
||
<div class="oauth-options" style="display: none;">
|
||
<p class="form-text">${m("multi_factor_authentication.oauth_description")}</p>
|
||
<div class="admonition note oauth-warning" role="alert">
|
||
${m("multi_factor_authentication.oauth_description_warning")}
|
||
</div>
|
||
<div class="admonition caution missing-vars" role="alert" style="display: none;"></div>
|
||
<hr />
|
||
<div class="col-md-6">
|
||
<span><b>${m("multi_factor_authentication.oauth_user_account")}</b></span><span class="user-account-name">${m("multi_factor_authentication.oauth_user_not_logged_in")}</span>
|
||
<br>
|
||
<span><b>${m("multi_factor_authentication.oauth_user_email")}</b></span><span class="user-account-email">${m("multi_factor_authentication.oauth_user_not_logged_in")}</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`,GS=`
|
||
<div class="options-section">
|
||
<h4>${m("multi_factor_authentication.title")}</h4>
|
||
<p class="form-text">${m("multi_factor_authentication.electron_disabled")}</p>
|
||
</div>
|
||
`;class YS extends ae{$mfaEnabledCheckbox;$mfaOptions;$mfaMethodRadios;$totpOptions;$noTotpSecretWarning;$generateTotpButton;$generateRecoveryCodeButton;$recoveryKeys=[];$oauthOptions;$UserAccountName;$UserAccountEmail;$oauthWarning;$missingVars;doRender(){const t=ct.isElectron()?GS:ZS;if(this.$widget=$(t),!ct.isElectron()){this.$mfaEnabledCheckbox=this.$widget.find(".mfa-enabled-checkbox"),this.$mfaOptions=this.$widget.find(".mfa-options"),this.$mfaMethodRadios=this.$widget.find(".mfa-method-radio"),this.$totpOptions=this.$widget.find(".totp-options"),this.$noTotpSecretWarning=this.$widget.find(".no-totp-secret"),this.$generateTotpButton=this.$widget.find(".generate-totp"),this.$generateRecoveryCodeButton=this.$widget.find(".generate-recovery-code"),this.$oauthOptions=this.$widget.find(".oauth-options"),this.$UserAccountName=this.$widget.find(".user-account-name"),this.$UserAccountEmail=this.$widget.find(".user-account-email"),this.$oauthWarning=this.$widget.find(".oauth-warning"),this.$missingVars=this.$widget.find(".missing-vars"),this.$recoveryKeys=[];for(let e=0;e<8;e++)this.$recoveryKeys.push(this.$widget.find(".key_"+e));this.$generateRecoveryCodeButton.on("click",async()=>{await this.setRecoveryKeys()}),this.$generateTotpButton.on("click",async()=>{await this.generateKey()}),this.displayRecoveryKeys(),this.$mfaEnabledCheckbox.on("change",()=>{const e=this.$mfaEnabledCheckbox.is(":checked");this.$mfaOptions.toggle(e),e?(this.$mfaMethodRadios.filter('[value="totp"]').prop("checked",!0),this.$totpOptions.show(),this.$oauthOptions.hide()):(this.$totpOptions.hide(),this.$oauthOptions.hide()),this.updateCheckboxOption("mfaEnabled",this.$mfaEnabledCheckbox)}),this.$mfaMethodRadios.on("change",()=>{const e=this.$mfaMethodRadios.filter(":checked").val();this.$totpOptions.toggle(e==="totp"),this.$oauthOptions.toggle(e==="oauth"),this.updateOption("mfaMethod",e)})}}async setRecoveryKeys(){const t=await pt.get("totp_recovery/generate");if(!t.success){ft.showError(m("multi_factor_authentication.recovery_keys_error"));return}t.recoveryCodes&&(this.keyFiller(t.recoveryCodes),await pt.post("totp_recovery/set",{recoveryCodes:t.recoveryCodes}))}async displayRecoveryKeys(){const t=await pt.get("totp_recovery/enabled");if(!t.success){this.fillKeys(m("multi_factor_authentication.recovery_keys_error"));return}if(!t.keysExist){this.fillKeys(m("multi_factor_authentication.recovery_keys_no_key_set")),this.$generateRecoveryCodeButton.text(m("multi_factor_authentication.recovery_keys_generate"));return}const e=await pt.get("totp_recovery/used");e.usedRecoveryCodes?(this.keyFiller(e.usedRecoveryCodes),this.$generateRecoveryCodeButton.text(m("multi_factor_authentication.recovery_keys_regenerate"))):this.fillKeys(m("multi_factor_authentication.recovery_keys_no_key_set"))}keyFiller(t){this.fillKeys(""),t.forEach((e,i)=>{if(typeof e=="string"){const n=new Date(e.replace(/\//g,"-"));isNaN(n.getTime())?this.$recoveryKeys[i].text(e):this.$recoveryKeys[i].text(m("multi_factor_authentication.recovery_keys_used",{date:e.replace(/\//g,"-")}))}else this.$recoveryKeys[i].text(m("multi_factor_authentication.recovery_keys_unused",{index:e}))})}fillKeys(t){for(let e=0;e<8;e++)this.$recoveryKeys[e].text(t)}async generateKey(){if((await pt.get("totp/status")).set&&!await Me.confirm(m("multi_factor_authentication.totp_secret_regenerate_confirm")))return;const e=await pt.get("totp/generate");e.success?(await Me.prompt({title:m("multi_factor_authentication.totp_secret_generated"),message:m("multi_factor_authentication.totp_secret_warning"),defaultValue:e.message,shown:({$answer:i})=>{i&&i.prop("readonly",!0)}}),this.$generateTotpButton.text(m("multi_factor_authentication.totp_secret_regenerate")),await this.setRecoveryKeys()):ft.showError(e.message)}optionsLoaded(t){if(!ct.isElectron()){if(this.$mfaEnabledCheckbox.prop("checked",t.mfaEnabled==="true"),this.$mfaOptions.toggle(t.mfaEnabled==="true"),t.mfaEnabled==="true"){const e=t.mfaMethod||"totp";this.$mfaMethodRadios.filter(`[value="${e}"]`).prop("checked",!0),this.$totpOptions.toggle(e==="totp"),this.$oauthOptions.toggle(e==="oauth")}else this.$totpOptions.hide(),this.$oauthOptions.hide();pt.get("oauth/status").then(e=>{if(e.enabled)e.name&&this.$UserAccountName.text(e.name),e.email&&this.$UserAccountEmail.text(e.email),this.$oauthWarning.hide(),this.$missingVars.hide();else if(this.$UserAccountName.text(m("multi_factor_authentication.oauth_user_not_logged_in")),this.$UserAccountEmail.text(m("multi_factor_authentication.oauth_user_not_logged_in")),this.$oauthWarning.show(),e.missingVars&&e.missingVars.length>0){this.$missingVars.show();const i=e.missingVars.map(n=>`"${n}"`);this.$missingVars.html(m("multi_factor_authentication.oauth_missing_vars",{variables:i.join(", ")}))}}),pt.get("totp/status").then(e=>{e.set?(this.$generateTotpButton.text(m("multi_factor_authentication.totp_secret_regenerate")),this.$noTotpSecretWarning.hide()):this.$noTotpSecretWarning.show()})}}}const JS=`
|
||
<div class="options-section">
|
||
<h4>${m("i18n.title")}</h4>
|
||
|
||
<div class="locale-options-container">
|
||
<div class="option-row">
|
||
<label for="locale-select">${m("i18n.language")}</label>
|
||
<select id="locale-select" class="locale-select form-select"></select>
|
||
</div>
|
||
|
||
<div class="option-row electron-only">
|
||
<label for="formatting-locale-select">${m("i18n.formatting-locale")}</label>
|
||
<select id="formatting-locale-select" class="formatting-locale-select form-select"></select>
|
||
</div>
|
||
|
||
<div class="option-row">
|
||
<label id="first-day-of-week-label">${m("i18n.first-day-of-the-week")}</label>
|
||
<div role="group" aria-labelledby="first-day-of-week-label">
|
||
<label class="tn-radio">
|
||
<input name="first-day-of-week" type="radio" value="0" />
|
||
${m("i18n.sunday")}
|
||
</label>
|
||
|
||
<label class="tn-radio">
|
||
<input name="first-day-of-week" type="radio" value="1" />
|
||
${m("i18n.monday")}
|
||
</label>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="option-row">
|
||
<label id="first-week-of-year-label">${m("i18n.first-week-of-the-year")}</label>
|
||
<div role="group" aria-labelledby="first-week-of-year-label">
|
||
<label class="tn-radio">
|
||
<input name="first-week-of-year" type="radio" value="0" />
|
||
${m("i18n.first-week-contains-first-day")}
|
||
</label>
|
||
|
||
<label class="tn-radio">
|
||
<input name="first-week-of-year" type="radio" value="1" />
|
||
${m("i18n.first-week-contains-first-thursday")}
|
||
</label>
|
||
|
||
<label class="tn-radio">
|
||
<input name="first-week-of-year" type="radio" value="2" />
|
||
${m("i18n.first-week-has-minimum-days")}
|
||
</label>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="option-row min-days-row" style="display: none;">
|
||
<label for="min-days-in-first-week">${m("i18n.min-days-in-first-week")}</label>
|
||
<select id="min-days-in-first-week" class="form-select">
|
||
${Array.from({length:7},(o,t)=>t+1).map(o=>`<option value="${o}">${o}</option>`).join("")}
|
||
</select>
|
||
</div>
|
||
|
||
<p class="form-text">${m("i18n.first-week-info")}</p>
|
||
|
||
<div class="admonition warning" role="alert">
|
||
${m("i18n.first-week-warning")}
|
||
</div>
|
||
|
||
<div class="option-row centered">
|
||
<button class="btn btn-secondary btn-micro restart-app-button">${m("electron_integration.restart-app-button")}</button>
|
||
</div>
|
||
</div>
|
||
|
||
<style>
|
||
.locale-options-container .option-row {
|
||
border-bottom: 1px solid var(--main-border-color);
|
||
display: flex;
|
||
align-items: center;
|
||
padding: 0.5em 0;
|
||
}
|
||
|
||
.locale-options-container .option-row > label {
|
||
width: 40%;
|
||
margin-bottom: 0 !important;
|
||
}
|
||
|
||
.locale-options-container .option-row > select {
|
||
width: 60%;
|
||
}
|
||
|
||
.locale-options-container .option-row:last-of-type {
|
||
border-bottom: unset;
|
||
}
|
||
|
||
.locale-options-container .option-row.centered {
|
||
justify-content: center;
|
||
}
|
||
|
||
.locale-options-container .option-row [aria-labelledby="first-week-of-year-label"] {
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.locale-options-container .option-row [aria-labelledby="first-week-of-year-label"] .tn-radio {
|
||
margin-left: 0;
|
||
white-space: nowrap;
|
||
}
|
||
</style>
|
||
</div>
|
||
`;class QS extends ae{$localeSelect;$formattingLocaleSelect;$minDaysRow;doRender(){this.$widget=$(JS),this.$minDaysRow=this.$widget.find(".min-days-row"),this.$localeSelect=this.$widget.find(".locale-select"),this.$localeSelect.on("change",async()=>{const e=this.$localeSelect.val();await pt.put(`options/locale/${e}`)}),this.$formattingLocaleSelect=this.$widget.find(".formatting-locale-select"),this.$formattingLocaleSelect.on("change",async()=>{const e=this.$formattingLocaleSelect.val();await pt.put(`options/formattingLocale/${e}`)}),this.$widget.find('input[name="first-day-of-week"]').on("change",()=>{const e=String(this.$widget.find('input[name="first-day-of-week"]:checked').val());this.updateOption("firstDayOfWeek",e)}),this.$widget.find('input[name="first-week-of-year"]').on("change",e=>{const i=e.target,n=parseInt(i.value);n===2?this.$minDaysRow.show():this.$minDaysRow.hide(),this.updateOption("firstWeekOfYear",n)}),this.$widget.find('input[name="first-week-of-year"]:checked').val()===2&&this.$minDaysRow.show(),this.$widget.find("#min-days-in-first-week").on("change",()=>{const e=this.$widget.find("#min-days-in-first-week").val();this.updateOption("minDaysInFirstWeek",e)}),this.$widget.find(".restart-app-button").on("click",ct.restartDesktopApp)}async optionsLoaded(t){const e=Pf();function i(n,s){return $("<option>").attr("value",s).text(n.name)}this.$localeSelect.empty();for(const n of e.filter(s=>!s.contentOnly))this.$localeSelect.append(i(n,n.id));this.$localeSelect.val(t.locale),this.$formattingLocaleSelect.empty();for(const n of e.filter(s=>s.electronLocale))this.$formattingLocaleSelect.append(i(n,n.electronLocale));this.$formattingLocaleSelect.val(t.formattingLocale),this.$widget.find(`input[name="first-day-of-week"][value="${t.firstDayOfWeek}"]`).prop("checked","true"),this.$widget.find(`input[name="first-week-of-year"][value="${t.firstWeekOfYear}"]`).prop("checked","true"),parseInt(t.firstWeekOfYear)===2&&this.$minDaysRow.show(),this.$widget.find("#min-days-in-first-week").val(t.minDaysInFirstWeek)}}const XS=Mf("application/javascript;env=frontend"),Yv=`const n = 10;
|
||
greet(n); // Print "Hello World" for n times
|
||
|
||
/**
|
||
* Displays a "Hello World!" message for a given amount of times, on the standard console. The "Hello World!" text will be displayed once per line.
|
||
*
|
||
* @param {number} times The number of times to print the \`Hello World!\` message.
|
||
*/
|
||
function greet(times) {
|
||
for (let i = 0; i++; i < times) {
|
||
console.log("Hello World!");
|
||
}
|
||
}
|
||
`,tT=`
|
||
<div class="options-section">
|
||
<h4>${m("highlighting.title")}</h4>
|
||
|
||
<div class="form-group row">
|
||
<div class="col-md-6">
|
||
<label for="highlighting-color-scheme-select">${m("highlighting.color-scheme")}</label>
|
||
<select id="highlighting-color-scheme-select" class="theme-select form-select"></select>
|
||
</div>
|
||
|
||
<div class="col-md-6 side-checkbox">
|
||
<label class="form-check tn-checkbox">
|
||
<input type="checkbox" class="word-wrap form-check-input" />
|
||
${m("code_block.word_wrapping")}
|
||
</label>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="note-detail-readonly-text-content ck-content code-sample-wrapper">
|
||
<pre class="hljs"><code class="code-sample">${Yv}</code></pre>
|
||
</div>
|
||
|
||
<style>
|
||
.code-sample-wrapper {
|
||
margin-top: 1em;
|
||
}
|
||
|
||
.code-sample-wrapper pre {
|
||
margin-bottom: 0;
|
||
}
|
||
</style>
|
||
</div>
|
||
`;class eT extends ae{$themeSelect;$wordWrap;$sampleEl;doRender(){this.$widget=$(tT),this.$themeSelect=this.$widget.find(".theme-select");const t=iT();for(const[e,i]of Object.entries(t)){const n=e?$("<optgroup>").attr("label",e):null;for(const s of i){const a=$("<option>").attr("value",s.val).text(s.title);n?n.append(a):this.$themeSelect.append(a)}n&&this.$themeSelect.append(n)}this.$themeSelect.on("change",async()=>{const e=String(this.$themeSelect.val());ab(e),await pt.put(`options/codeBlockTheme/${e}`)}),this.$wordWrap=this.$widget.find("input.word-wrap"),this.$wordWrap.on("change",()=>this.updateCheckboxOption("codeBlockWordWrap",this.$wordWrap)),this.$sampleEl=this.$widget.find(".code-sample")}#t(t){const e=Yv;t?Z(()=>import("./marked.esm.js").then(i=>i.i),__vite__mapDeps([12,3,2,4,5]),import.meta.url).then(async i=>{await Nf();const n=i.highlight(e,{language:XS});n&&this.$sampleEl.html(n.value)}):this.$sampleEl.text(e)}async optionsLoaded(t){this.$themeSelect.val(t.codeBlockTheme),this.setCheckboxState(this.$wordWrap,t.codeBlockWordWrap),this.$widget.closest(".note-detail-printable").toggleClass("word-wrap",t.codeBlockWordWrap==="true"),this.#t(t.codeBlockTheme!=="none")}}function iT(){const o=[],t=[];for(const[i,n]of Object.entries(lb)){const s={val:"default:"+i,title:n.name};n.name.includes("Dark")?o.push(s):t.push(s)}const e={"":[{val:"none",title:m("code_block.theme_none")}]};return e[m("code_block.theme_group_light")]=t,e[m("code_block.theme_group_dark")]=o,e}const nT=`
|
||
<div class="options-section formatting-toolbar">
|
||
<h4>${m("editing.editor_type.label")}</h4>
|
||
|
||
<div>
|
||
<label class="tn-radio">
|
||
<input type="radio" name="editor-type" value="ckeditor-balloon" />
|
||
<strong>${m("editing.editor_type.floating.title")}</strong>
|
||
- ${m("editing.editor_type.floating.description")}
|
||
</label>
|
||
</div>
|
||
|
||
<div>
|
||
<label class="tn-radio">
|
||
<input type="radio" name="editor-type" value="ckeditor-classic" />
|
||
<strong>${m("editing.editor_type.fixed.title")}</strong>
|
||
- ${m("editing.editor_type.fixed.description")}
|
||
</label>
|
||
|
||
<div>
|
||
<label class="tn-checkbox">
|
||
<input type="checkbox" name="multiline-toolbar" />
|
||
${m("editing.editor_type.multiline-toolbar")}
|
||
</label>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<style>
|
||
.formatting-toolbar div > div {
|
||
margin-left: 1em;
|
||
}
|
||
</style>
|
||
`;class oT extends ae{$body;$multilineToolbarCheckbox;doRender(){this.$widget=$(nT),this.$body=$("body"),this.$widget.find('input[name="editor-type"]').on("change",async()=>{const t=this.$widget.find('input[name="editor-type"]:checked').val();await this.updateOption("textNoteEditorType",t),ct.reloadFrontendApp("editor type change")}),this.$multilineToolbarCheckbox=this.$widget.find('input[name="multiline-toolbar"]'),this.$multilineToolbarCheckbox.on("change",()=>this.updateCheckboxOption("textNoteEditorMultilineToolbar",this.$multilineToolbarCheckbox))}async optionsLoaded(t){this.$widget.find(`input[name="editor-type"][value="${t.textNoteEditorType}"]`).prop("checked","true"),this.setCheckboxState(this.$multilineToolbarCheckbox,t.textNoteEditorMultilineToolbar)}}const sT=`
|
||
<div class="options-section">
|
||
<h4>${m("share.title")}</h4>
|
||
|
||
<label class="tn-checkbox">
|
||
<input class="form-check-input" type="checkbox" name="redirectBareDomain" value="true">
|
||
${m("share.redirect_bare_domain")}
|
||
</label>
|
||
<p class="form-text">${m("share.redirect_bare_domain_description")}</p>
|
||
|
||
<label class="tn-checkbox">
|
||
<input class="form-check-input" type="checkbox" name="showLoginInShareTheme" value="true">
|
||
${m("share.show_login_link")}
|
||
</label>
|
||
<p class="form-text">${m("share.show_login_link_description")}</p>
|
||
</div>`;class rT extends ae{$shareRootCheck;$shareRootStatus;doRender(){this.$widget=$(sT),this.contentSized(),this.$shareRootCheck=this.$widget.find(".share-root-check"),this.$shareRootStatus=this.$widget.find(".share-root-status"),this.$widget.find('input[type="checkbox"]').on("change",t=>{this.save();const e=t.target;e.name==="redirectBareDomain"&&(this.$shareRootCheck.toggle(e.checked),e.checked&&this.checkShareRoot())}),this.$widget.find(".check-share-root").on("click",()=>this.checkShareRoot())}async optionsLoaded(t){const e=t.redirectBareDomain==="true";this.$widget.find('input[name="redirectBareDomain"]').prop("checked",e),this.$shareRootCheck.toggle(e),e&&await this.checkShareRoot(),this.$widget.find('input[name="showLoginInShareTheme"]').prop("checked",t.showLoginInShareTheme==="true")}async checkShareRoot(){const t=this.$widget.find(".check-share-root");t.prop("disabled",!0);try{const e=await Of.searchForNotes("#shareRoot"),i=e.find(n=>n.isShared());i?this.$shareRootStatus.removeClass("text-danger").addClass("text-success").text(m("share.share_root_found",{noteTitle:i.title})):this.$shareRootStatus.removeClass("text-success").addClass("text-danger").text(e.length>0?m("share.share_root_not_shared",{noteTitle:e[0].title}):m("share.share_root_not_found"))}finally{t.prop("disabled",!1)}}async save(){const t=this.$widget.find('input[name="redirectBareDomain"]').prop("checked");await this.updateOption("redirectBareDomain",t.toString());const e=this.$widget.find('input[name="showLoginInShareTheme"]').prop("checked");await this.updateOption("showLoginInShareTheme",e.toString())}}const aT=`
|
||
<div class="options-section">
|
||
<h4>${m("ai_llm.title")}</h4>
|
||
|
||
<!-- Add warning alert div -->
|
||
<div class="provider-validation-warning alert alert-warning" style="display: none;"></div>
|
||
|
||
<div class="form-group">
|
||
<label class="tn-checkbox">
|
||
<input class="ai-enabled form-check-input" type="checkbox">
|
||
${m("ai_llm.enable_ai_features")}
|
||
</label>
|
||
<div class="form-text">${m("ai_llm.enable_ai_description")}</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- AI settings template -->
|
||
|
||
<div class="ai-providers-section options-section">
|
||
<h4>${m("ai_llm.provider_configuration")}</h4>
|
||
|
||
<div class="form-group">
|
||
<label>${m("ai_llm.selected_provider")}</label>
|
||
<select class="ai-selected-provider form-control">
|
||
<option value="">${m("ai_llm.select_provider")}</option>
|
||
<option value="openai">OpenAI</option>
|
||
<option value="anthropic">Anthropic</option>
|
||
<option value="ollama">Ollama</option>
|
||
</select>
|
||
<div class="form-text">${m("ai_llm.selected_provider_description")}</div>
|
||
</div>
|
||
|
||
<!-- OpenAI Provider Settings -->
|
||
<div class="provider-settings openai-provider-settings" style="display: none;">
|
||
<div class="card mt-3">
|
||
<div class="card-header">
|
||
<h5>${m("ai_llm.openai_settings")}</h5>
|
||
</div>
|
||
<div class="card-body">
|
||
<div class="form-group">
|
||
<label>${m("ai_llm.api_key")}</label>
|
||
<input type="password" class="openai-api-key form-control" autocomplete="off" />
|
||
<div class="form-text">${m("ai_llm.openai_api_key_description")}</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label>${m("ai_llm.url")}</label>
|
||
<input type="text" class="openai-base-url form-control" />
|
||
<div class="form-text">${m("ai_llm.openai_url_description")}</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label>${m("ai_llm.model")}</label>
|
||
<select class="openai-default-model form-control">
|
||
<option value="">${m("ai_llm.select_model")}</option>
|
||
</select>
|
||
<div class="form-text">${m("ai_llm.openai_model_description")}</div>
|
||
<button class="btn btn-sm btn-outline-secondary refresh-openai-models">${m("ai_llm.refresh_models")}</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Anthropic Provider Settings -->
|
||
<div class="provider-settings anthropic-provider-settings" style="display: none;">
|
||
<div class="card mt-3">
|
||
<div class="card-header">
|
||
<h5>${m("ai_llm.anthropic_settings")}</h5>
|
||
</div>
|
||
<div class="card-body">
|
||
<div class="form-group">
|
||
<label>${m("ai_llm.api_key")}</label>
|
||
<input type="password" class="anthropic-api-key form-control" autocomplete="off" />
|
||
<div class="form-text">${m("ai_llm.anthropic_api_key_description")}</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label>${m("ai_llm.url")}</label>
|
||
<input type="text" class="anthropic-base-url form-control" />
|
||
<div class="form-text">${m("ai_llm.anthropic_url_description")}</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label>${m("ai_llm.model")}</label>
|
||
<select class="anthropic-default-model form-control">
|
||
<option value="">${m("ai_llm.select_model")}</option>
|
||
</select>
|
||
<div class="form-text">${m("ai_llm.anthropic_model_description")}</div>
|
||
<button class="btn btn-sm btn-outline-secondary refresh-anthropic-models">${m("ai_llm.refresh_models")}</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Ollama Provider Settings -->
|
||
<div class="provider-settings ollama-provider-settings" style="display: none;">
|
||
<div class="card mt-3">
|
||
<div class="card-header">
|
||
<h5>${m("ai_llm.ollama_settings")}</h5>
|
||
</div>
|
||
<div class="card-body">
|
||
<div class="form-group">
|
||
<label>${m("ai_llm.url")}</label>
|
||
<input type="text" class="ollama-base-url form-control" />
|
||
<div class="form-text">${m("ai_llm.ollama_url_description")}</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label>${m("ai_llm.model")}</label>
|
||
<select class="ollama-default-model form-control">
|
||
<option value="">${m("ai_llm.select_model")}</option>
|
||
</select>
|
||
<div class="form-text">${m("ai_llm.ollama_model_description")}</div>
|
||
<button class="btn btn-sm btn-outline-secondary refresh-models"><span class="bx bx-refresh"></span></button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label>${m("ai_llm.temperature")}</label>
|
||
<input class="ai-temperature form-control" type="number" min="0" max="2" step="0.1">
|
||
<div class="form-text">${m("ai_llm.temperature_description")}</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label>${m("ai_llm.system_prompt")}</label>
|
||
<textarea class="ai-system-prompt form-control" rows="3"></textarea>
|
||
<div class="form-text">${m("ai_llm.system_prompt_description")}</div>
|
||
</div>
|
||
</div>
|
||
|
||
`;class lT{constructor(t){this.$widget=t}ensureSelectedValue(t,e,i){if(e)t.val(e),t.val()||t.prop("selectedIndex",0);else{const n=Qt.get(i);n&&(t.val(n),t.val()||t.prop("selectedIndex",0))}}async refreshOpenAIModels(t,e){if(!this.$widget)return!1;const i=this.$widget.find(".refresh-openai-models");if(e&&!t)return e;t&&(i.prop("disabled",!0),i.html('<i class="spinner-border spinner-border-sm"></i>'));try{const n=this.$widget.find(".openai-base-url").val(),s=await pt.get(`llm/providers/openai/models?baseUrl=${encodeURIComponent(n)}`);if(s&&s.success){if(s.chatModels?.length>0){const a=this.$widget.find(".openai-default-model"),l=a.val();a.empty(),[...s.chatModels].sort((u,p)=>u.name.localeCompare(p.name)).forEach(u=>{a.append(`<option value="${u.id}">${u.name}</option>`)}),this.ensureSelectedValue(a,l,"openaiDefaultModel")}if(t){const a=s.chatModels?.length||0;ft.showMessage(`${a} OpenAI models found.`)}return!0}else t&&ft.showError("No OpenAI models found. Please check your API key and settings.");return e}catch(n){return console.error("Error fetching OpenAI models:",n),t&&ft.showError(`Error fetching OpenAI models: ${n}`),e}finally{t&&(i.prop("disabled",!1),i.html('<span class="bx bx-refresh"></span>'))}}async refreshAnthropicModels(t,e){if(!this.$widget)return!1;const i=this.$widget.find(".refresh-anthropic-models");if(e&&!t)return e;t&&(i.prop("disabled",!0),i.html('<i class="spinner-border spinner-border-sm"></i>'));try{const n=this.$widget.find(".anthropic-base-url").val(),s=await pt.get(`llm/providers/anthropic/models?baseUrl=${encodeURIComponent(n)}`);if(s&&s.success){if(s.chatModels?.length>0){const a=this.$widget.find(".anthropic-default-model"),l=a.val();a.empty(),[...s.chatModels].sort((u,p)=>u.name.localeCompare(p.name)).forEach(u=>{a.append(`<option value="${u.id}">${u.name}</option>`)}),this.ensureSelectedValue(a,l,"anthropicDefaultModel")}if(t){const a=s.chatModels?.length||0;ft.showMessage(`${a} Anthropic models found.`)}return!0}else t&&ft.showError("No Anthropic models found. Please check your API key and settings.");return e}catch(n){return console.error("Error fetching Anthropic models:",n),t&&ft.showError(`Error fetching Anthropic models: ${n}`),e}finally{t&&(i.prop("disabled",!1),i.html('<span class="bx bx-refresh"></span>'))}}async refreshOllamaModels(t,e){if(!this.$widget)return!1;const i=this.$widget.find(".refresh-models");if(e&&!t)return e;t&&(i.prop("disabled",!0),i.text(m("ai_llm.refreshing_models")));try{const n=this.$widget.find(".ollama-base-url").val(),s=await pt.get(`llm/providers/ollama/models?baseUrl=${encodeURIComponent(n)}`);if(s&&s.success&&s.models&&s.models.length>0){const a=this.$widget.find(".ollama-default-model"),l=a.val();return a.empty(),[...s.models].sort((u,p)=>u.name.localeCompare(p.name)).forEach(u=>{a.append(`<option value="${u.name}">${u.name}</option>`)}),this.ensureSelectedValue(a,l,"ollamaDefaultModel"),t&&ft.showMessage(`${s.models.length} Ollama models found.`),!0}else t&&ft.showError("No Ollama models found. Please check if Ollama is running.");return e}catch(n){return console.error("Error fetching Ollama models:",n),t&&ft.showError(`Error fetching Ollama models: ${n}`),e}finally{t&&(i.prop("disabled",!1),i.html('<span class="bx bx-refresh"></span>'))}}}class cT extends ae{ollamaModelsRefreshed=!1;openaiModelsRefreshed=!1;anthropicModelsRefreshed=!1;providerService=null;doRender(){return this.$widget=$(aT),this.providerService=new lT(this.$widget),this.setupEventHandlers(),this.$widget}setupChangeHandler(t,e,i=!1,n=!1){if(!this.$widget)return;const s=this.$widget.find(t);s.on("change",async()=>{let a;if(n?a=s.prop("checked")?"true":"false":a=s.val(),await this.updateOption(e,a),e==="aiEnabled")try{a==="true"?ft.showMessage(m("ai_llm.ai_enabled")||"AI features enabled"):ft.showMessage(m("ai_llm.ai_disabled")||"AI features disabled")}catch(l){console.error("Error toggling AI:",l),ft.showError(m("ai_llm.ai_toggle_error")||"Error toggling AI features")}i&&await this.displayValidationWarnings()})}setupEventHandlers(){if(!this.$widget)return;this.setupChangeHandler(".ai-enabled","aiEnabled",!0,!0),this.setupChangeHandler(".ai-selected-provider","aiSelectedProvider",!0),this.setupChangeHandler(".ai-temperature","aiTemperature"),this.setupChangeHandler(".ai-system-prompt","aiSystemPrompt"),this.setupChangeHandler(".openai-api-key","openaiApiKey",!0),this.setupChangeHandler(".openai-base-url","openaiBaseUrl",!0),this.setupChangeHandler(".openai-default-model","openaiDefaultModel"),this.setupChangeHandler(".anthropic-api-key","anthropicApiKey",!0),this.setupChangeHandler(".anthropic-default-model","anthropicDefaultModel"),this.setupChangeHandler(".anthropic-base-url","anthropicBaseUrl"),this.setupChangeHandler(".voyage-api-key","voyageApiKey"),this.setupChangeHandler(".ollama-base-url","ollamaBaseUrl"),this.setupChangeHandler(".ollama-default-model","ollamaDefaultModel"),this.$widget.find(".refresh-models").on("click",async()=>{this.ollamaModelsRefreshed=await this.providerService?.refreshOllamaModels(!0,this.ollamaModelsRefreshed)||!1}),this.$widget.find("#nav-ollama-tab").on("shown.bs.tab",async()=>{this.ollamaModelsRefreshed=await this.providerService?.refreshOllamaModels(!1,this.ollamaModelsRefreshed)||!1}),this.$widget.find(".refresh-openai-models").on("click",async()=>{this.openaiModelsRefreshed=await this.providerService?.refreshOpenAIModels(!0,this.openaiModelsRefreshed)||!1}),this.$widget.find("#nav-openai-tab").on("shown.bs.tab",async()=>{this.openaiModelsRefreshed=await this.providerService?.refreshOpenAIModels(!1,this.openaiModelsRefreshed)||!1}),this.$widget.find(".refresh-anthropic-models").on("click",async()=>{this.anthropicModelsRefreshed=await this.providerService?.refreshAnthropicModels(!0,this.anthropicModelsRefreshed)||!1}),this.$widget.find("#nav-anthropic-tab").on("shown.bs.tab",async()=>{this.anthropicModelsRefreshed=await this.providerService?.refreshAnthropicModels(!1,this.anthropicModelsRefreshed)||!1}),this.$widget.find(".ai-selected-provider").on("change",async()=>{const l=this.$widget.find(".ai-selected-provider").val();this.$widget.find(".provider-settings").hide(),l&&(this.$widget.find(`.${l}-provider-settings`).show(),await this.fetchModelsForProvider(l,"chat"))}),this.$widget.find(".openai-base-url").on("change",async()=>{this.$widget.find(".ai-selected-provider").val()==="openai"&&await this.fetchModelsForProvider("openai","chat")}),this.$widget.find(".anthropic-base-url").on("change",async()=>{this.$widget.find(".ai-selected-provider").val()==="anthropic"&&await this.fetchModelsForProvider("anthropic","chat")}),this.$widget.find(".ollama-base-url").on("change",async()=>{this.$widget.find(".ai-selected-provider").val()==="ollama"&&await this.fetchModelsForProvider("ollama","chat")}),this.$widget.find(".openai-api-key").on("change",async()=>{this.$widget.find(".ai-selected-provider").val()==="openai"&&await this.fetchModelsForProvider("openai","chat")}),this.$widget.find(".anthropic-api-key").on("change",async()=>{this.$widget.find(".ai-selected-provider").val()==="anthropic"&&await this.fetchModelsForProvider("anthropic","chat")})}async displayValidationWarnings(){if(!this.$widget)return;const t=this.$widget.find(".provider-validation-warning");if(!this.$widget.find(".ai-enabled").prop("checked")){t.hide();return}const i=this.$widget.find(".ai-selected-provider").val(),n=[m("ai_llm.experimental_warning")],s=[];if(i==="openai"?this.$widget.find(".openai-api-key").val()||s.push(m("ai_llm.empty_key_warning.openai")):i==="anthropic"?this.$widget.find(".anthropic-api-key").val()||s.push(m("ai_llm.empty_key_warning.anthropic")):i==="ollama"&&(this.$widget.find(".ollama-base-url").val()||s.push(m("ai_llm.ollama_no_url"))),n.push(...s),n.length>0){const a="<strong>"+m("ai_llm.configuration_warnings")+"</strong><ul>"+n.map(l=>`<li>${l}</li>`).join("")+"</ul>";t.html(a).show()}else t.hide()}getProviderDisplayName(t){switch(t){case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"ollama":return"Ollama";case"voyage":return"Voyage";case"local":return"Local";default:return t.charAt(0).toUpperCase()+t.slice(1)}}setModelDropdownValue(t,e){if(!this.$widget||!e)return;const i=this.$widget.find(t);i.find(`option[value="${e}"]`).length===0&&i.append(`<option value="${e}">${e} (current)</option>`),i.val(e)}async fetchModelsForProvider(t,e){if(this.providerService)try{switch(t){case"openai":this.openaiModelsRefreshed=await this.providerService.refreshOpenAIModels(!1,this.openaiModelsRefreshed);break;case"anthropic":this.anthropicModelsRefreshed=await this.providerService.refreshAnthropicModels(!1,this.anthropicModelsRefreshed);break;case"ollama":this.ollamaModelsRefreshed=await this.providerService.refreshOllamaModels(!1,this.ollamaModelsRefreshed);break;default:console.log(`Model fetching not implemented for provider: ${t}`)}}catch(i){console.error(`Error fetching models for ${t}:`,i)}}updateProviderSettingsVisibility(){if(!this.$widget)return;const t=this.$widget.find(".ai-selected-provider").val();this.$widget.find(".provider-settings").hide(),t&&this.$widget.find(`.${t}-provider-settings`).show()}async optionsLoaded(t){if(!this.$widget)return;this.$widget.find(".ai-enabled").prop("checked",t.aiEnabled!=="false"),this.$widget.find(".ai-temperature").val(t.aiTemperature||"0.7"),this.$widget.find(".ai-system-prompt").val(t.aiSystemPrompt||""),this.$widget.find(".ai-selected-provider").val(t.aiSelectedProvider||"openai"),this.$widget.find(".openai-api-key").val(t.openaiApiKey||""),this.$widget.find(".openai-base-url").val(t.openaiBaseUrl||"https://api.openai.com/v1"),this.setModelDropdownValue(".openai-default-model",t.openaiDefaultModel),this.$widget.find(".anthropic-api-key").val(t.anthropicApiKey||""),this.$widget.find(".anthropic-base-url").val(t.anthropicBaseUrl||"https://api.anthropic.com"),this.setModelDropdownValue(".anthropic-default-model",t.anthropicDefaultModel),this.$widget.find(".voyage-api-key").val(t.voyageApiKey||""),this.$widget.find(".ollama-base-url").val(t.ollamaBaseUrl||"http://localhost:11434"),this.setModelDropdownValue(".ollama-default-model",t.ollamaDefaultModel),this.updateProviderSettingsVisibility();const e=this.$widget.find(".ai-selected-provider").val();e&&await this.fetchModelsForProvider(e,"chat"),this.displayValidationWarnings()}cleanup(){}}const dT=`
|
||
<div class="options-section">
|
||
<h4>${m("content_language.title")}</h4>
|
||
<p class="form-text">${m("content_language.description")}</p>
|
||
|
||
<ul class="options-languages">
|
||
</ul>
|
||
|
||
<style>
|
||
ul.options-languages {
|
||
list-style-type: none;
|
||
margin-bottom: 0;
|
||
column-width: 400px;
|
||
}
|
||
</style>
|
||
</div>
|
||
`;class hT extends ae{$languagesContainer;doRender(){this.$widget=$(dT),this.$languagesContainer=this.$widget.find(".options-languages")}async save(){const t=[];this.$languagesContainer.find("input:checked").each((e,i)=>{const n=$(i).attr("data-language-id");n&&t.push(n)}),await this.updateOption("languages",JSON.stringify(t))}async optionsLoaded(t){const e=Pf(),i=JSON.parse(t.languages);this.$languagesContainer.empty();for(const n of e){const s=$('<input type="checkbox" class="form-check-input">').attr("data-language-id",n.id).prop("checked",i.includes(n.id)),a=$('<label class="tn-checkbox">').append(s).on("change",()=>this.save()).append(n.name);this.$languagesContainer.append($("<li>").append(a))}}}const uT="application/typescript",pT=`import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
|
||
import { EditorView, highlightActiveLine, keymap, lineNumbers, placeholder, ViewUpdate, type EditorViewConfig } from "@codemirror/view";
|
||
import { defaultHighlightStyle, StreamLanguage, syntaxHighlighting, indentUnit, bracketMatching, foldGutter } from "@codemirror/language";
|
||
import { Compartment, EditorState, type Extension } from "@codemirror/state";
|
||
import { highlightSelectionMatches } from "@codemirror/search";
|
||
import { vim } from "@replit/codemirror-vim";
|
||
import byMimeType from "./syntax_highlighting.js";
|
||
import smartIndentWithTab from "./extensions/custom_tab.js";
|
||
import type { ThemeDefinition } from "./color_themes.js";
|
||
|
||
export { default as ColorThemes, type ThemeDefinition, getThemeById } from "./color_themes.js";
|
||
|
||
type ContentChangedListener = () => void;
|
||
|
||
export interface EditorConfig {
|
||
parent: HTMLElement;
|
||
placeholder?: string;
|
||
lineWrapping?: boolean;
|
||
vimKeybindings?: boolean;
|
||
readOnly?: boolean;
|
||
onContentChanged?: ContentChangedListener;
|
||
}
|
||
|
||
export default class CodeMirror extends EditorView {
|
||
|
||
private config: EditorConfig;
|
||
private languageCompartment: Compartment;
|
||
private historyCompartment: Compartment;
|
||
private themeCompartment: Compartment;
|
||
|
||
constructor(config: EditorConfig) {
|
||
const languageCompartment = new Compartment();
|
||
const historyCompartment = new Compartment();
|
||
const themeCompartment = new Compartment();
|
||
|
||
let extensions: Extension[] = [];
|
||
|
||
if (config.vimKeybindings) {
|
||
extensions.push(vim());
|
||
}
|
||
|
||
extensions = [
|
||
...extensions,
|
||
languageCompartment.of([]),
|
||
themeCompartment.of([
|
||
syntaxHighlighting(defaultHighlightStyle, { fallback: true })
|
||
]),
|
||
highlightActiveLine(),
|
||
highlightSelectionMatches(),
|
||
bracketMatching(),
|
||
lineNumbers(),
|
||
foldGutter(),
|
||
indentUnit.of(" ".repeat(4)),
|
||
keymap.of([
|
||
...defaultKeymap,
|
||
...historyKeymap,
|
||
...smartIndentWithTab
|
||
])
|
||
]
|
||
|
||
super({
|
||
parent: config.parent,
|
||
extensions
|
||
});
|
||
}
|
||
}`,fT=`<div class="options-section">
|
||
<h4>${m("code_theme.title")}</h4>
|
||
|
||
<div class="form-group row">
|
||
<div class="col-md-6">
|
||
<label for="color-theme">${m("code_theme.color-scheme")}</label>
|
||
<select id="color-theme" class="theme-select form-select"></select>
|
||
</div>
|
||
|
||
<div class="col-md-6 side-checkbox">
|
||
<label class="form-check tn-checkbox">
|
||
<input type="checkbox" class="word-wrap form-check-input" />
|
||
${m("code_theme.word_wrapping")}
|
||
</label>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="note-detail-readonly-code-content">
|
||
</div>
|
||
|
||
<style>
|
||
.options-section .note-detail-readonly-code-content {
|
||
margin: 0;
|
||
}
|
||
|
||
.options-section .note-detail-readonly-code-content .cm-editor {
|
||
height: 200px;
|
||
}
|
||
</style>
|
||
</div>
|
||
`;class mT extends ae{$themeSelect;$sampleEl;$lineWrapEnabled;editor;doRender(){this.$widget=$(fT),this.$themeSelect=this.$widget.find(".theme-select"),this.$themeSelect.on("change",async()=>{const t=String(this.$themeSelect.val());await pt.put(`options/codeNoteTheme/${t}`)});for(const t of Uv){const e=$("<option>").attr("value",`default:${t.id}`).text(t.name);this.$themeSelect.append(e)}this.$sampleEl=this.$widget.find(".note-detail-readonly-code-content"),this.$lineWrapEnabled=this.$widget.find(".word-wrap"),this.$lineWrapEnabled.on("change",()=>this.updateCheckboxOption("codeLineWrapEnabled",this.$lineWrapEnabled))}async#t(t){this.editor||(this.editor=new qv({parent:this.$sampleEl[0]})),this.editor.setText(pT),this.editor.setMimeType(uT),this.editor.setLineWrapping(t.codeLineWrapEnabled==="true");const e=t.codeNoteTheme;if(e?.startsWith(fs)){const i=Zd(e.substring(fs.length));i&&await this.editor.setTheme(i)}}async optionsLoaded(t){this.$themeSelect.val(t.codeNoteTheme),this.#t(t),this.setCheckboxState(this.$lineWrapEnabled,t.codeLineWrapEnabled)}}const gT=`<div class="options-section">
|
||
<h4>Related settings</h4>
|
||
|
||
<nav class="related-settings">
|
||
<li>Color scheme for code blocks in text notes</li>
|
||
<li>Color scheme for code notes</li>
|
||
</nav>
|
||
|
||
<style>
|
||
.related-settings {
|
||
padding: 0;
|
||
margin: 0;
|
||
list-style-type: none;
|
||
}
|
||
</style>
|
||
</div>
|
||
`,mf={_optionsAppearance:{items:[{title:"Color scheme for code blocks in text notes",targetPage:"_optionsTextNotes"},{title:"Color scheme for code notes",targetPage:"_optionsCodeNotes"}]}};class vT extends ae{doRender(){this.$widget=$(gT);const t=this.noteId&&mf[this.noteId];if(!t)return;const e=this.$widget.find(".related-settings");e.empty();for(const i of t.items){const n=$("<li>"),s=$("<a>").text(i.title);n.append(s),s.attr("href",`#root/_hidden/_options/${i.targetPage}`),e.append(n)}}isEnabled(){return!!this.noteId&&this.noteId in mf}}const yT=`<div class="note-detail-content-widget note-detail-printable">
|
||
<style>
|
||
.type-contentWidget .note-detail {
|
||
height: 100%;
|
||
}
|
||
|
||
.note-detail-content-widget {
|
||
height: 100%;
|
||
}
|
||
|
||
.note-detail-content-widget-content {
|
||
padding: 15px;
|
||
height: 100%;
|
||
}
|
||
|
||
.note-detail.full-height .note-detail-content-widget-content {
|
||
padding: 0;
|
||
}
|
||
</style>
|
||
|
||
<div class="note-detail-content-widget-content"></div>
|
||
</div>`,bT={_optionsAppearance:[L1,P1,I1,D1,KS],_optionsShortcuts:[B1],_optionsTextNotes:[oT,F1,eT,H1,U1,q1,Z1],_optionsCodeNotes:[Y1,mT,iS,Q1],_optionsImages:[oS],_optionsSpellcheck:[aS],_optionsPassword:[cS,uS],_optionsMFA:[YS],_optionsEtapi:[fS],_optionsBackup:[gS],_optionsSync:[yS],_optionsAi:[cT],_optionsOther:[_S,kS,$S,jS,TS,IS,MS,rT,LS],_optionsLocalization:[QS,hT],_optionsAdvanced:[OS,RS,WS,zS],_backendLog:[VS]};class wT extends Ue{$content;widget;static getType(){return"contentWidget"}doRender(){this.$widget=$(yT),this.$content=this.$widget.find(".note-detail-content-widget-content"),super.doRender()}async doRefresh(t){this.$content.empty(),this.children=[];const e=[...bT[t.noteId],vT];if(this.$content.toggleClass("options",t.noteId.startsWith("_options")),e)for(const i of e){const n=new i;this.noteContext&&await n.handleEvent("setNoteContext",{noteContext:this.noteContext}),this.child(n),this.$content.append(n.render()),this.widget=n,await n.refresh()}else this.$content.append(m("content_widget.unknown_widget",{id:t.noteId}))}}const _T=`
|
||
<div class="dropdown attachment-actions">
|
||
<style>
|
||
.attachment-actions {
|
||
width: 35px;
|
||
height: 35px;
|
||
}
|
||
|
||
.attachment-actions .dropdown-menu {
|
||
width: 20em;
|
||
}
|
||
|
||
.attachment-actions .dropdown-item .bx {
|
||
position: relative;
|
||
top: 3px;
|
||
font-size: 120%;
|
||
margin-right: 5px;
|
||
}
|
||
|
||
.attachment-actions .dropdown-item[disabled], .attachment-actions .dropdown-item[disabled]:hover {
|
||
color: var(--muted-text-color) !important;
|
||
background-color: transparent !important;
|
||
pointer-events: none; /* makes it unclickable */
|
||
}
|
||
</style>
|
||
|
||
<button type="button" data-bs-toggle="dropdown" aria-haspopup="true"
|
||
aria-expanded="false" class="icon-action icon-action-always-border bx bx-dots-vertical-rounded"
|
||
style="position: relative; top: 3px;"></button>
|
||
|
||
<div class="dropdown-menu dropdown-menu-right">
|
||
|
||
<li data-trigger-command="openAttachment" class="dropdown-item"
|
||
title="${m("attachments_actions.open_externally_title")}"><span class="bx bx-file-find"></span> ${m("attachments_actions.open_externally")}</li>
|
||
|
||
<li data-trigger-command="openAttachmentCustom" class="dropdown-item"
|
||
title="${m("attachments_actions.open_custom_title")}"><span class="bx bx-customize"></span> ${m("attachments_actions.open_custom")}</li>
|
||
|
||
<li data-trigger-command="downloadAttachment" class="dropdown-item">
|
||
<span class="bx bx-download"></span> ${m("attachments_actions.download")}</li>
|
||
|
||
<li data-trigger-command="copyAttachmentLinkToClipboard" class="dropdown-item"><span class="bx bx-link">
|
||
</span> ${m("attachments_actions.copy_link_to_clipboard")}</li>
|
||
|
||
|
||
<div class="dropdown-divider"></div>
|
||
|
||
|
||
<li data-trigger-command="uploadNewAttachmentRevision" class="dropdown-item"><span class="bx bx-upload">
|
||
</span> ${m("attachments_actions.upload_new_revision")}</li>
|
||
|
||
<li data-trigger-command="renameAttachment" class="dropdown-item">
|
||
<span class="bx bx-rename"></span> ${m("attachments_actions.rename_attachment")}</li>
|
||
|
||
<li data-trigger-command="deleteAttachment" class="dropdown-item">
|
||
<span class="bx bx-trash destructive-action-icon"></span> ${m("attachments_actions.delete_attachment")}</li>
|
||
|
||
|
||
<div class="dropdown-divider"></div>
|
||
|
||
|
||
<li data-trigger-command="convertAttachmentIntoNote" class="dropdown-item"><span class="bx bx-note">
|
||
</span> ${m("attachments_actions.convert_attachment_into_note")}</li>
|
||
|
||
</div>
|
||
|
||
<input type="file" class="attachment-upload-new-revision-input" style="display: none">
|
||
</div>`;class xT extends ge{$uploadNewRevisionInput;attachment;isFullDetail;dropdown;constructor(t,e){super(),this.attachment=t,this.isFullDetail=e}get attachmentId(){return this.attachment.attachmentId}doRender(){this.$widget=$(_T),this.dropdown=Ko.getOrCreateInstance(this.$widget.find("[data-bs-toggle='dropdown']")[0]),this.$widget.on("click",".dropdown-item",()=>this.dropdown.toggle()),this.$uploadNewRevisionInput=this.$widget.find(".attachment-upload-new-revision-input"),this.$uploadNewRevisionInput.on("change",async()=>{const e=this.$uploadNewRevisionInput[0].files?.item(0);this.$uploadNewRevisionInput.val(""),e&&((await pt.upload(`attachments/${this.attachmentId}/file`,e)).uploaded?ft.showMessage(m("attachments_actions.upload_success")):ft.showError(m("attachments_actions.upload_failed")))});const t=ct.isElectron();this.isFullDetail||(this.$widget.find("[data-trigger-command='openAttachment']").addClass("disabled").append($('<span class="bx bx-info-circle disabled-tooltip" />').attr("title",m("attachments_actions.open_externally_detail_page"))),t&&this.$widget.find("[data-trigger-command='openAttachmentCustom']").addClass("disabled").append($('<span class="bx bx-info-circle disabled-tooltip" />').attr("title",m("attachments_actions.open_externally_detail_page")))),t||this.$widget.find("[data-trigger-command='openAttachmentCustom']").addClass("disabled").append($('<span class="bx bx-info-circle disabled-tooltip" />').attr("title",m("attachments_actions.open_custom_client_only")))}async openAttachmentCommand(){await en.openAttachmentExternally(this.attachmentId,this.attachment.mime)}async openAttachmentCustomCommand(){await en.openAttachmentCustom(this.attachmentId,this.attachment.mime)}async downloadAttachmentCommand(){await en.downloadAttachment(this.attachmentId)}async uploadNewAttachmentRevisionCommand(){this.$uploadNewRevisionInput.trigger("click")}async copyAttachmentLinkToClipboardCommand(){this.parent&&"copyAttachmentLinkToClipboard"in this.parent&&this.parent.copyAttachmentLinkToClipboard()}async deleteAttachmentCommand(){await Me.confirm(m("attachments_actions.delete_confirm",{title:this.attachment.title}))&&(await pt.remove(`attachments/${this.attachmentId}`),ft.showMessage(m("attachments_actions.delete_success",{title:this.attachment.title})))}async convertAttachmentIntoNoteCommand(){if(!await Me.confirm(m("attachments_actions.convert_confirm",{title:this.attachment.title})))return;const{note:t}=await pt.post(`attachments/${this.attachmentId}/convert-to-note`);ft.showMessage(m("attachments_actions.convert_success",{title:this.attachment.title})),await yi.waitForMaxKnownEntityChangeId(),await Pt.tabManager.getActiveContext()?.setNote(t.noteId)}async renameAttachmentCommand(){const t=await Me.prompt({title:m("attachments_actions.rename_attachment"),message:m("attachments_actions.enter_new_name"),defaultValue:this.attachment.title});t?.trim()&&await pt.put(`attachments/${this.attachmentId}/rename`,{title:t})}}const gf=`
|
||
<div class="attachment-detail-widget">
|
||
<style>
|
||
.attachment-detail-widget {
|
||
height: 100%;
|
||
}
|
||
|
||
.attachment-detail-wrapper {
|
||
margin-bottom: 20px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.attachment-title-line {
|
||
display: flex;
|
||
align-items: baseline;
|
||
gap: 1em;
|
||
}
|
||
|
||
.attachment-details {
|
||
margin-left: 10px;
|
||
}
|
||
|
||
.attachment-content-wrapper {
|
||
flex-grow: 1;
|
||
}
|
||
|
||
.attachment-content-wrapper .rendered-content {
|
||
height: 100%;
|
||
}
|
||
|
||
.attachment-content-wrapper pre {
|
||
padding: 10px;
|
||
margin-top: 10px;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.attachment-detail-wrapper.list-view .attachment-content-wrapper {
|
||
max-height: 300px;
|
||
}
|
||
|
||
.attachment-detail-wrapper.full-detail {
|
||
height: 100%;
|
||
}
|
||
|
||
.attachment-detail-wrapper.full-detail .attachment-content-wrapper {
|
||
height: 100%;
|
||
}
|
||
|
||
.attachment-detail-wrapper.list-view .attachment-content-wrapper pre {
|
||
max-height: 400px;
|
||
}
|
||
|
||
.attachment-content-wrapper img {
|
||
margin: 10px;
|
||
}
|
||
|
||
.attachment-detail-wrapper.list-view .attachment-content-wrapper img, .attachment-detail-wrapper.list-view .attachment-content-wrapper video {
|
||
max-height: 300px;
|
||
max-width: 90%;
|
||
object-fit: contain;
|
||
}
|
||
|
||
.attachment-detail-wrapper.full-detail .attachment-content-wrapper img {
|
||
max-width: 90%;
|
||
object-fit: contain;
|
||
}
|
||
|
||
.attachment-detail-wrapper.scheduled-for-deletion .attachment-content-wrapper img {
|
||
filter: contrast(10%);
|
||
}
|
||
</style>
|
||
|
||
<div class="attachment-detail-wrapper">
|
||
<div class="attachment-title-line">
|
||
<div class="attachment-actions-container"></div>
|
||
<h4 class="attachment-title"></h4>
|
||
<div class="attachment-details"></div>
|
||
<div style="flex: 1 1;"></div>
|
||
</div>
|
||
|
||
<div class="attachment-deletion-warning alert alert-info" style="margin-top: 15px;"></div>
|
||
|
||
<div class="attachment-content-wrapper"></div>
|
||
</div>
|
||
</div>`;class Jv extends ge{attachment;attachmentActionsWidget;isFullDetail;$wrapper;constructor(t,e){super(),this.contentSized(),this.attachment=t,this.attachmentActionsWidget=new xT(t,e),this.isFullDetail=e,this.child(this.attachmentActionsWidget)}doRender(){this.$widget=$(gf),this.refresh(),super.doRender()}async refresh(){if(this.$widget.find(".attachment-detail-wrapper").empty().append($(gf).find(".attachment-detail-wrapper").html()),this.$wrapper=this.$widget.find(".attachment-detail-wrapper"),this.$wrapper.addClass(this.isFullDetail?"full-detail":"list-view"),this.isFullDetail)this.$wrapper.find(".attachment-title").text(this.attachment.title);else{const n=await Pe.createLink(this.attachment.ownerId,{title:this.attachment.title,viewScope:{viewMode:"attachments",attachmentId:this.attachment.attachmentId}});n.addClass("use-tn-links"),this.$wrapper.find(".attachment-title").append(n)}const t=this.$wrapper.find(".attachment-deletion-warning"),{utcDateScheduledForErasureSince:e}=this.attachment;if(e){this.$wrapper.addClass("scheduled-for-deletion");const n=ct.parseDate(e)?.getTime(),s=Qt.getInt("eraseUnusedAttachmentsAfterSeconds")||2592e3*1e3,l=n+s-Date.now();t.show(),l>=6e4?t.text(m("attachment_detail_2.will_be_deleted_in",{time:ct.formatTimeInterval(l)})):t.text(m("attachment_detail_2.will_be_deleted_soon")),t.append(m("attachment_detail_2.deletion_reason"))}else this.$wrapper.removeClass("scheduled-for-deletion"),t.hide();this.$wrapper.find(".attachment-details").text(m("attachment_detail_2.role_and_size",{role:this.attachment.role,size:ct.formatSize(this.attachment.contentLength)})),this.$wrapper.find(".attachment-actions-container").append(this.attachmentActionsWidget.render());const{$renderedContent:i}=await Jd.getRenderedContent(this.attachment,{imageHasZoom:this.isFullDetail});this.$wrapper.find(".attachment-content-wrapper").append(i)}async copyAttachmentLinkToClipboard(){if(this.attachment.role==="image")Df.copyImageReferenceToClipboard(this.$wrapper.find(".attachment-content-wrapper"));else if(this.attachment.role==="file"){const t=await Pe.createLink(this.attachment.ownerId,{referenceLink:!0,viewScope:{viewMode:"attachments",attachmentId:this.attachment.attachmentId}});ct.copyHtmlToClipboard(t[0].outerHTML),ft.showMessage(m("attachment_detail_2.link_copied"))}else throw new Error(m("attachment_detail_2.unrecognized_role",{role:this.attachment.role}))}async entitiesReloadedEvent({loadResults:t}){const e=t.getAttachmentRows().find(i=>i.attachmentId===this.attachment.attachmentId);e&&(e.isDeleted?this.toggleInt(!1):this.refresh())}}const kT=`
|
||
<div class="attachment-list note-detail-printable">
|
||
<style>
|
||
.attachment-list {
|
||
padding-left: 15px;
|
||
padding-right: 15px;
|
||
}
|
||
|
||
.attachment-list .links-wrapper {
|
||
font-size: larger;
|
||
margin-bottom: 15px;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: baseline;
|
||
}
|
||
</style>
|
||
|
||
<div class="links-wrapper"></div>
|
||
|
||
<div class="attachment-list-wrapper"></div>
|
||
</div>`;class CT extends Ue{$list;$linksWrapper;renderedAttachmentIds;static getType(){return"attachmentList"}doRender(){this.$widget=$(kT),this.$list=this.$widget.find(".attachment-list-wrapper"),this.$linksWrapper=this.$widget.find(".links-wrapper"),super.doRender()}async doRefresh(t){const e=$(`
|
||
<button class="attachment-help-button icon-action bx bx-help-circle"
|
||
type="button" data-help-page="attachments.html"
|
||
title="${m("attachment_list.open_help_page")}">
|
||
</button>
|
||
`);ct.initHelpButtons(e);const i=await Pe.createLink(this.noteId);i.addClass("use-tn-links");const n=$(`
|
||
<button class="btn btn-sm">
|
||
<span class="bx bx-folder-open"></span>
|
||
${m("attachment_list.upload_attachments")}
|
||
</button>
|
||
`);n.on("click",()=>{this.noteId&&this.triggerCommand("showUploadAttachmentsDialog",{noteId:this.noteId})}),this.$linksWrapper.empty().append($("<div>").append(m("attachment_list.owning_note"),i),$('<div class="attachment-actions-toolbar">').append(n,e)),this.$list.empty(),this.children=[],this.renderedAttachmentIds=new Set;const s=await t.getAttachments();if(s.length===0){this.$list.html('<div class="alert alert-info">'+m("attachment_list.no_attachments")+"</div>");return}for(const a of s){const l=new Jv(a,!1);this.child(l),this.renderedAttachmentIds.add(a.attachmentId),this.$list.append(l.render())}}async entitiesReloadedEvent({loadResults:t}){t.getAttachmentRows().some(i=>i.attachmentId&&!this.renderedAttachmentIds.has(i.attachmentId))&&this.refresh()}}const $T=`
|
||
<div class="attachment-detail note-detail-printable">
|
||
<style>
|
||
.attachment-detail {
|
||
padding-left: 15px;
|
||
padding-right: 15px;
|
||
height: 100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.attachment-detail .links-wrapper {
|
||
font-size: larger;
|
||
padding: 0 0 16px 0;
|
||
}
|
||
|
||
.attachment-detail .attachment-wrapper {
|
||
flex-grow: 1;
|
||
}
|
||
</style>
|
||
|
||
<div class="links-wrapper use-tn-links"></div>
|
||
|
||
<div class="attachment-wrapper"></div>
|
||
</div>`;class ST extends Ue{$wrapper;$linksWrapper;static getType(){return"attachmentDetail"}doRender(){this.$widget=$($T),this.$wrapper=this.$widget.find(".attachment-wrapper"),this.$linksWrapper=this.$widget.find(".links-wrapper"),super.doRender()}async doRefresh(t){this.$wrapper.empty(),this.children=[];const e=$(`
|
||
<button class="attachment-help-button icon-action bx bx-help-circle"
|
||
type="button" data-help-page="attachments.html"
|
||
title="${m("attachment_detail.open_help_page")}"
|
||
</button>
|
||
`);ct.initHelpButtons(e),this.$linksWrapper.empty().append(m("attachment_detail.owning_note"),await Pe.createLink(this.noteId),m("attachment_detail.you_can_also_open"),await Pe.createLink(this.noteId,{title:m("attachment_detail.list_of_all_attachments"),viewScope:{viewMode:"attachments"}}),e);const i=this.attachmentId?await Mt.getAttachment(this.attachmentId,!0):null;if(!i){this.$wrapper.html("<strong>"+m("attachment_detail.attachment_deleted")+"</strong>");return}const n=new Jv(i,!0);this.child(n),this.$wrapper.append(n.render())}async entitiesReloadedEvent({loadResults:t}){t.getAttachmentRows().find(i=>i.attachmentId===this.attachmentId)?.isDeleted&&this.refresh()}get attachmentId(){return this?.noteContext?.viewScope?.attachmentId}}window._iconfont_svg_string_4003484='<svg><symbol id="icon-a" viewBox="0 0 1024 1024"><path d="M757.76 665.6q0 20.48 1.536 34.304t7.68 22.016 18.944 12.288 34.304 4.096q-3.072 25.6-15.36 44.032-11.264 16.384-33.28 29.696t-62.976 13.312q-11.264 0-20.48-0.512t-17.408-2.56l-6.144-2.048-1.024 0q-4.096-1.024-10.24-4.096-2.048-2.048-4.096-2.048-1.024-1.024-2.048-1.024-14.336-8.192-23.552-17.408t-14.336-17.408q-6.144-10.24-9.216-20.48-63.488 75.776-178.176 75.776-48.128 0-88.064-15.36t-69.12-44.032-45.056-68.096-15.872-88.576 16.896-89.088 47.616-67.584 74.24-42.496 96.768-14.848q48.128 0 88.576 17.408t66.048 49.152q0-8.192 0.512-16.384t0.512-15.36q0-71.68-39.936-104.448t-128-32.768q-43.008 0-84.992 6.656t-84.992 17.92q14.336-28.672 25.088-47.616t24.064-29.184q30.72-24.576 158.72-24.576 79.872 0 135.168 13.824t90.624 43.52 51.2 75.264 15.872 108.032l0 200.704zM487.424 743.424q50.176 0 79.872-33.28t29.696-95.744q0-61.44-28.672-93.696t-76.8-32.256q-52.224 0-82.944 33.28t-30.72 94.72q0 58.368 31.744 92.672t77.824 34.304z" ></path></symbol><symbol id="icon-close" viewBox="0 0 1024 1024"><path d="M557.312 513.248l265.28-263.904c12.544-12.48 12.608-32.704 0.128-45.248-12.512-12.576-32.704-12.608-45.248-0.128L512.128 467.904l-263.04-263.84c-12.448-12.48-32.704-12.544-45.248-0.064-12.512 12.48-12.544 32.736-0.064 45.28l262.976 263.776L201.6 776.8c-12.544 12.48-12.608 32.704-0.128 45.248a31.937 31.937 0 0 0 22.688 9.44c8.16 0 16.32-3.104 22.56-9.312l265.216-263.808 265.44 266.24c6.24 6.272 14.432 9.408 22.656 9.408a31.94 31.94 0 0 0 22.592-9.344c12.512-12.48 12.544-32.704 0.064-45.248L557.312 513.248z" fill="" ></path></symbol><symbol id="icon-menu" viewBox="0 0 1024 1024"><path d="M109.714 292.571h804.572c21.943 0 36.571-21.942 36.571-43.885 0-14.629-14.628-29.257-36.571-29.257H109.714c-21.943 0-36.571 14.628-36.571 36.571 0 14.629 14.628 36.571 36.571 36.571zM914.286 512H109.714c-21.943 0-36.571 14.629-36.571 36.571 0 14.629 14.628 36.572 36.571 36.572h804.572c21.943 0 36.571-21.943 36.571-43.886 0-14.628-14.628-29.257-36.571-29.257z m0 292.571H109.714c-21.943 0-36.571 14.629-36.571 36.572s14.628 36.571 36.571 36.571h804.572c21.943 0 36.571-21.943 36.571-36.571 0-21.943-14.628-36.572-36.571-36.572z" ></path></symbol><symbol id="icon-B" viewBox="0 0 1024 1024"><path d="M98.067692 65.457231H481.28c75.854769 0 132.411077 3.150769 169.668923 9.452307 37.336615 6.301538 70.656 19.534769 100.036923 39.620924 29.459692 20.007385 53.956923 46.710154 73.570462 80.029538 19.692308 33.398154 29.459692 70.734769 29.459692 112.167385 0 44.898462-12.130462 86.094769-36.233846 123.588923a224.886154 224.886154 0 0 1-98.461539 84.283077c58.368 17.092923 103.266462 46.08 134.695385 87.04 31.350154 40.96 47.025231 89.088 47.025231 144.462769 0 43.638154-10.082462 86.016-30.404923 127.212308-20.243692 41.196308-47.891692 74.043077-83.02277 98.697846-35.052308 24.654769-78.296615 39.778462-129.732923 45.449846-32.295385 3.465846-110.119385 5.671385-233.472 6.537846H98.067692V65.457231z m193.536 159.507692V446.621538h126.818462c75.460923 0 122.328615-1.024 140.603077-3.229538 33.083077-3.938462 59.155692-15.36 78.139077-34.343385 18.904615-18.904615 28.435692-43.874462 28.435692-74.830769 0-29.696-8.192-53.720615-24.497231-72.310154-16.384-18.510769-40.644923-29.696-72.940307-33.634461-19.140923-2.205538-74.279385-3.308308-165.415385-3.308308h-111.064615z m0 381.243077v256.315077h179.2c69.710769 0 113.979077-1.969231 132.726154-5.907692 28.750769-5.198769 52.145231-17.959385 70.262154-38.281847 18.116923-20.243692 27.096615-47.340308 27.096615-81.368615 0-28.750769-6.931692-53.169231-20.873846-73.255385a118.232615 118.232615 0 0 0-60.494769-43.795692c-26.387692-9.137231-83.574154-13.705846-171.638154-13.705846H291.603692z" ></path></symbol></svg>',function(o){var e=(e=document.getElementsByTagName("script"))[e.length-1],t=e.getAttribute("data-injectcss"),e=e.getAttribute("data-disable-injectsvg");if(!e){var i,n,s,a,l,c=function(v,x){x.parentNode.insertBefore(v,x)};if(t&&!o.__iconfont__svg__cssinject__){o.__iconfont__svg__cssinject__=!0;try{document.write("<style>.svgfont {display: inline-block;width: 1em;height: 1em;fill: currentColor;vertical-align: -0.1em;font-size:16px;}</style>")}catch(v){console&&console.log(v)}}i=function(){var v,x=document.createElement("div");x.innerHTML=o._iconfont_svg_string_4003484,(x=x.getElementsByTagName("svg")[0])&&(x.setAttribute("aria-hidden","true"),x.style.position="absolute",x.style.width=0,x.style.height=0,x.style.overflow="hidden",x=x,(v=document.body).firstChild?c(x,v.firstChild):v.appendChild(x))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(i,0):(n=function(){document.removeEventListener("DOMContentLoaded",n,!1),i()},document.addEventListener("DOMContentLoaded",n,!1)):document.attachEvent&&(s=i,a=o.document,l=!1,p(),a.onreadystatechange=function(){a.readyState=="complete"&&(a.onreadystatechange=null,u())})}function u(){l||(l=!0,s())}function p(){try{a.documentElement.doScroll("left")}catch{return void setTimeout(p,50)}u()}}(window);const vf={addChild:"插入子节点",addParent:"插入父节点",addSibling:"插入同级节点",removeNode:"删除节点",focus:"专注",cancelFocus:"取消专注",moveUp:"上移",moveDown:"下移",link:"连接",clickTips:"请点击目标节点",font:"文字",background:"背景",tag:"标签",icon:"图标",tagsSeparate:"多个标签半角逗号分隔",iconsSeparate:"多个图标半角逗号分隔",url:"URL"},Yn={ko:{"addChild":"하위 항목 추가","addParent":"상위 항목 추가","addSibling":"같은 단계의 항목 추가","removeNode":"항목 삭제","focus":"집중 모드","cancelFocus":"집중 모드 해제","moveUp":"위로 이동","moveDown":"아래로 이동","link":"연결","clickTips":"연결할 항목을 클릭하세요","font":"글자 색상","background":"배경색","tag":"태그","icon":"아이콘","tagsSeparate":"태그를 쉼표로 구분하세요","iconsSeparate":"아이콘을 쉼표로 구분하세요","url":"웹페이지 주소","memo":"메모","summary":"요약"},cn:vf,zh_CN:vf,zh_TW:{addChild:"插入子節點",addParent:"插入父節點",addSibling:"插入同級節點",removeNode:"刪除節點",focus:"專注",cancelFocus:"取消專注",moveUp:"上移",moveDown:"下移",link:"連接",clickTips:"請點擊目標節點",font:"文字",background:"背景",tag:"標簽",icon:"圖標",tagsSeparate:"多個標簽半角逗號分隔",iconsSeparate:"多個圖標半角逗號分隔",url:"URL"},de:{addChild:"Kindknoten hinzufügen",addParent:"Elternknoten hinzufügen",addSibling:"Geschwisterknoten hinzufügen",removeNode:"Knoten entfernen",focus:"Fokus-Modus",cancelFocus:"Fokus-Modus abbrechen",moveUp:"Nach oben bewegen",moveDown:"Nach unten bewegen",link:"Verbinden",clickTips:"Bitte den Zielknoten anklicken",font:"Schriftart",background:"Hintergrund",tag:"Tag",icon:"Icon",tagsSeparate:"Durch Komma getrennte Tags",iconsSeparate:"Durch Komma getrennte Icons",url:"URL"},en:{addChild:"Add child",addParent:"Add parent",addSibling:"Add sibling",removeNode:"Remove node",focus:"Focus Mode",cancelFocus:"Cancel Focus Mode",moveUp:"Move up",moveDown:"Move down",link:"Link",clickTips:"Please click the target node",font:"Font",background:"Background",tag:"Tag",icon:"Icon",tagsSeparate:"Separate tags by comma",iconsSeparate:"Separate icons by comma",url:"URL"},ru:{addChild:"Добавить дочерний элемент",addParent:"Добавить родительский элемент",addSibling:"Добавить на этом уровне",removeNode:"Удалить узел",focus:"Режим фокусировки",cancelFocus:"Отменить режим фокусировки",moveUp:"Поднять выше",moveDown:"Опустить ниже",link:"Ссылка",clickTips:"Пожалуйста, нажмите на целевой узел",font:"Цвет шрифта",background:"Цвет фона",tag:"Тег",icon:"Иконка",tagsSeparate:"Разделяйте теги запятой",iconsSeparate:"Разделяйте иконки запятой"},ja:{addChild:"子ノードを追加する",addParent:"親ノードを追加します",addSibling:"兄弟ノードを追加する",removeNode:"ノードを削除",focus:"集中",cancelFocus:"集中解除",moveUp:"上へ移動",moveDown:"下へ移動",link:"コネクト",clickTips:"ターゲットノードをクリックしてください",font:"フォント",background:"バックグラウンド",tag:"タグ",icon:"アイコン",tagsSeparate:"複数タグはカンマ区切り",iconsSeparate:"複数アイコンはカンマ区切り",url:"URL"},pt:{addChild:"Adicionar item filho",addParent:"Adicionar item pai",addSibling:"Adicionar item irmao",removeNode:"Remover item",focus:"Modo Foco",cancelFocus:"Cancelar Modo Foco",moveUp:"Mover para cima",moveDown:"Mover para baixo",link:"Link",clickTips:"Favor clicar no item alvo",font:"Fonte",background:"Cor de fundo",tag:"Tag",icon:"Icone",tagsSeparate:"Separe tags por virgula",iconsSeparate:"Separe icones por virgula",url:"URL"}},dr=(o,t)=>{const e=document.createElement("div");return e.id=o,e.innerHTML=t,e},TT=["#2c3e50","#34495e","#7f8c8d","#94a5a6","#bdc3c7","#ecf0f1","#8e44ad","#9b59b6","#2980b9","#3298db","#c0392c","#e74c3c","#d35400","#f39c11","#f1c40e","#17a085","#27ae61","#2ecc71"];function ET(o){console.log("install node menu");function t(H,Q){const tt=o.container.querySelectorAll(H);[].forEach.call(tt,function(it){it.classList.remove(Q)})}const e=Yn[o.locale]?o.locale:"en",i=dr("nm-style",`
|
||
<div class="nm-fontsize-container">
|
||
${["15","24","32"].map(H=>`<div class="size" data-size="${H}">
|
||
<svg class="icon" style="width: ${H}px;height: ${H}px" aria-hidden="true">
|
||
<use xlink:href="#icon-a"></use>
|
||
</svg></div>`).join("")}<div class="bold"><svg class="icon" aria-hidden="true">
|
||
<use xlink:href="#icon-B"></use>
|
||
</svg></div>
|
||
</div>
|
||
<div class="nm-fontcolor-container">
|
||
${TT.map(H=>`<div class="split6"><div class="palette" data-color="${H}" style="background-color: ${H};"></div></div>`).join("")}
|
||
</div>
|
||
<div class="bof">
|
||
<span class="font">${Yn[e].font}</span>
|
||
<span class="background">${Yn[e].background}</span>
|
||
</div>`),n=dr("nm-tag",`${Yn[e].tag}<input class="nm-tag" tabindex="-1" placeholder="${Yn[e].tagsSeparate}" />`),s=dr("nm-icon",`${Yn[e].icon}<input class="nm-icon" tabindex="-1" placeholder="${Yn[e].iconsSeparate}" />`),a=dr("nm-url",`${Yn[e].url}<input class="nm-url" tabindex="-1" />`),l=dr("nm-memo",`${Yn[e].memo||"Memo"}<textarea class="nm-memo" rows="5" tabindex="-1" />`),c=document.createElement("div");c.className="node-menu",c.innerHTML=`
|
||
<div class="button-container"><svg class="icon" aria-hidden="true">
|
||
<use xlink:href="#icon-close"></use>
|
||
</svg></div>
|
||
`,c.appendChild(i),c.appendChild(n),c.appendChild(s),c.appendChild(a),c.appendChild(l),c.hidden=!0,o.container.append(c);const u=c.querySelectorAll(".size"),p=c.querySelector(".bold"),v=c.querySelector(".button-container"),x=c.querySelector(".font"),T=o.container.querySelector(".nm-tag"),M=o.container.querySelector(".nm-icon"),P=o.container.querySelector(".nm-url"),F=o.container.querySelector(".nm-memo");let R;o.findEle,c.onclick=H=>{if(!o.currentNode)return;const Q=o.currentNode.nodeObj,tt=H.target;if(tt.className==="palette"){t(".palette","nmenu-selected"),tt.className="palette nmenu-selected";const it=tt.dataset.color,rt={style:{}};R==="font"?rt.style.color=it:R==="background"&&(rt.style.background=it),console.log(rt),o.reshapeNode(o.currentNode,rt)}else tt.className==="background"?(t(".palette","nmenu-selected"),R="background",tt.className="background selected",tt.previousElementSibling.className="font",Q.style&&Q.style.background&&(c.querySelector('.palette[data-color="'+Q.style.background+'"]').className="palette nmenu-selected")):tt.className==="font"&&(t(".palette","nmenu-selected"),R="font",tt.className="font selected",tt.nextElementSibling.className="background",Q.style&&Q.style.color&&(c.querySelector('.palette[data-color="'+Q.style.color+'"]').className="palette nmenu-selected"))},Array.from(u).map(H=>{H.onclick=Q=>{t(".size","size-selected");const tt=Q.currentTarget;tt.className="size size-selected",o.reshapeNode(o.currentNode,{style:{fontSize:tt.dataset.size}})}}),p.onclick=H=>{var Q,tt;let it="";((tt=(Q=o.currentNode.nodeObj)==null?void 0:Q.style)==null?void 0:tt.fontWeight)==="bold"?H.currentTarget.className="bold":(it="bold",H.currentTarget.className="bold size-selected"),o.reshapeNode(o.currentNode,{style:{fontWeight:it}})},T.onchange=H=>{if(o.currentNode&&typeof H.target.value=="string"){const Q=H.target.value.split(",");o.reshapeNode(o.currentNode,{tags:Q.filter(tt=>tt)})}},M.onchange=H=>{if(o.currentNode&&typeof H.target.value=="string"){const Q=H.target.value.split(",");o.reshapeNode(o.currentNode,{icons:Q.filter(tt=>tt)})}},P.onchange=H=>{!o.currentNode||o.reshapeNode(o.currentNode,{hyperLink:H.target.value})},F.onchange=H=>{!o.currentNode||(o.currentNode.nodeObj.memo=H.target.value,o.bus.fire("operation",{name:"updateMemo",obj:o.currentNode.nodeObj}))};let q="open";v.onclick=H=>{c.classList.toggle("close"),q==="open"?(q="close",v.innerHTML='<svg class="icon" aria-hidden="true"><use xlink:href="#icon-menu"></use></svg>'):(q="open",v.innerHTML='<svg class="icon" aria-hidden="true"><use xlink:href="#icon-close"></use></svg>')},o.bus.addListener("unselectNode",function(){c.hidden=!0}),o.bus.addListener("selectNode",function(H,Q){!Q||(c.hidden=!1,t(".palette","nmenu-selected"),t(".size","size-selected"),t(".bold","size-selected"),R="font",x.className="font selected",x.nextElementSibling.className="background",H.style&&(H.style.fontSize&&(c.querySelector('.size[data-size="'+H.style.fontSize+'"]').className="size size-selected"),H.style.fontWeight&&(c.querySelector(".bold").className="bold size-selected"),H.style.color&&(c.querySelector('.palette[data-color="'+H.style.color+'"]').className="palette nmenu-selected")),H.tags?T.value=H.tags.join(","):T.value="",H.icons?M.value=H.icons.join(","):M.value="",P.value=H.hyperLink||"",F.value=H.memo||"")})}const yf="",IT=`
|
||
<div class="note-detail-mind-map note-detail-printable">
|
||
<div class="mind-map-container">
|
||
</div>
|
||
|
||
<style>
|
||
.note-detail-mind-map {
|
||
height: 100%;
|
||
overflow: hidden !important;
|
||
}
|
||
|
||
.note-detail-mind-map .mind-map-container {
|
||
height: 100%;
|
||
}
|
||
|
||
.map-container .node-menu {
|
||
position: absolute;
|
||
top: 60px;
|
||
right: 20px;
|
||
bottom: 80px;
|
||
overflow: auto;
|
||
background: var(--panel-bgcolor);
|
||
color: var(--main-color);
|
||
border-radius: 5px;
|
||
box-shadow: 0 1px 2px #0003;
|
||
width: 240px;
|
||
box-sizing: border-box;
|
||
padding: 0 15px 15px;
|
||
transition: .3s all
|
||
}
|
||
|
||
.map-container .node-menu.close {
|
||
height: 29px;
|
||
width: 46px;
|
||
overflow: hidden
|
||
}
|
||
|
||
.map-container .node-menu .button-container {
|
||
padding: 3px 0;
|
||
direction: rtl
|
||
}
|
||
|
||
.map-container .node-menu #nm-tag {
|
||
margin-top: 20px
|
||
}
|
||
|
||
.map-container .node-menu .nm-fontsize-container {
|
||
display: flex;
|
||
justify-content: space-around;
|
||
margin-bottom: 20px
|
||
}
|
||
|
||
.map-container .node-menu .nm-fontsize-container div {
|
||
height: 36px;
|
||
width: 36px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-shadow: 0 1px 2px #0003;
|
||
background-color: #fff;
|
||
color: tomato;
|
||
border-radius: 100%
|
||
}
|
||
|
||
.map-container .node-menu .nm-fontcolor-container {
|
||
margin-bottom: 10px
|
||
}
|
||
|
||
.map-container .node-menu input,
|
||
.map-container .node-menu textarea {
|
||
background: var(--input-background-color);
|
||
border: 1px solid var(--panel-border-color);
|
||
border-radius: var(--bs-border-radius);
|
||
color: var(--main-color);
|
||
padding: 5px;
|
||
margin: 10px 0;
|
||
width: 100%;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.map-container .node-menu textarea {
|
||
resize: none
|
||
}
|
||
|
||
.map-container .node-menu .split6 {
|
||
display: inline-block;
|
||
width: 16.66%;
|
||
margin-bottom: 5px
|
||
}
|
||
|
||
.map-container .node-menu .palette {
|
||
border-radius: 100%;
|
||
width: 21px;
|
||
height: 21px;
|
||
border: 1px solid #edf1f2;
|
||
margin: auto
|
||
}
|
||
|
||
.map-container .node-menu .nmenu-selected,
|
||
.map-container .node-menu .palette:hover {
|
||
box-shadow: tomato 0 0 0 2px;
|
||
background-color: #c7e9fa
|
||
}
|
||
|
||
.map-container .node-menu .size-selected {
|
||
background-color: tomato !important;
|
||
border-color: tomato;
|
||
fill: #fff;
|
||
color: #fff
|
||
}
|
||
|
||
.map-container .node-menu .size-selected svg {
|
||
color: #fff
|
||
}
|
||
|
||
.map-container .node-menu .bof {
|
||
text-align: center
|
||
}
|
||
|
||
.map-container .node-menu .bof span {
|
||
display: inline-block;
|
||
font-size: 14px;
|
||
border-radius: 4px;
|
||
padding: 2px 5px
|
||
}
|
||
|
||
.map-container .node-menu .bof .selected {
|
||
background-color: tomato;
|
||
color: #fff
|
||
}
|
||
</style>
|
||
</div>
|
||
`;class AT extends Ue{$content;triggeredByUserOperation;mind;MindElixir;static getType(){return"mindMap"}doRender(){this.$widget=$(IT),this.$content=this.$widget.find(".mind-map-container"),this.$content.on("keydown",t=>{t.key==="F1"&&t.stopPropagation(),t.ctrlKey&&!t.altKey&&!t.metaKey&&(t.key=="-"||t.key=="="||t.key=="0")&&t.stopPropagation()}),this.$content.on("click",".mind-elixir-toolbar.lt",()=>{this.spacedUpdate.scheduleUpdate()}),super.doRender()}async doRefresh(t){if(this.triggeredByUserOperation){this.triggeredByUserOperation=!1;return}await this.#t(t)}cleanup(){this.triggeredByUserOperation=!1}async#t(t){const i=(await t.getBlob())?.getJsonContent();this.mind||await this.#i(i?.direction),this.mind.refresh(i??this.MindElixir.new(yf)),this.mind.toCenter()}async#i(t){this.MindElixir=(await Z(async()=>{const{default:i}=await import("./MindElixir.js");return{default:i}},[],import.meta.url)).default;const e=new this.MindElixir({locale:"ko",el:this.$content[0],direction:t??this.MindElixir.LEFT});e.install(ET),this.mind=e,e.init(this.MindElixir.new(yf)),e.bus.addListener("operation",i=>{this.triggeredByUserOperation=!0,i.name!=="beginEdit"&&this.spacedUpdate.scheduleUpdate()}),setTimeout(()=>{e.toCenter()},200)}async getData(){const t=this.mind;if(!t)return;const e=await this.renderSvg();return{content:t.getDataString(),attachments:[{role:"image",title:"mindmap-export.svg",mime:"image/svg+xml",content:e,position:0}]}}async renderSvg(){return await this.mind.exportSvg().text()}async entitiesReloadedEvent({loadResults:t}){this.noteId&&t.isNoteReloaded(this.noteId)&&this.refresh()}async exportSvgEvent({ntxId:t}){if(!this.isNoteContext(t)||this.note?.type!=="mindMap")return;const e=await this.renderSvg();ct.downloadSvg(this.note.title,e)}async exportPngEvent({ntxId:t}){if(!this.isNoteContext(t)||this.note?.type!=="mindMap")return;const e=await this.renderSvg();ct.downloadSvgAsPng(this.note.title,e)}async executeWithContentElementEvent({resolve:t,ntxId:e}){this.isNoteContext(e)&&(await this.initialized,t(this.$content.find(".main-node-container")))}}var vr={exports:{}};/* @preserve
|
||
* Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com
|
||
* (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
|
||
*/var LT=vr.exports,bf;function NT(){return bf||(bf=1,function(o,t){(function(e,i){i(t)})(LT,function(e){var i="1.9.4";function n(r){var d,f,_,E;for(f=1,_=arguments.length;f<_;f++){E=arguments[f];for(d in E)r[d]=E[d]}return r}var s=Object.create||function(){function r(){}return function(d){return r.prototype=d,new r}}();function a(r,d){var f=Array.prototype.slice;if(r.bind)return r.bind.apply(r,f.call(arguments,1));var _=f.call(arguments,2);return function(){return r.apply(d,_.length?_.concat(f.call(arguments)):arguments)}}var l=0;function c(r){return"_leaflet_id"in r||(r._leaflet_id=++l),r._leaflet_id}function u(r,d,f){var _,E,O,K;return K=function(){_=!1,E&&(O.apply(f,E),E=!1)},O=function(){_?E=arguments:(r.apply(f,arguments),setTimeout(K,d),_=!0)},O}function p(r,d,f){var _=d[1],E=d[0],O=_-E;return r===_&&f?r:((r-E)%O+O)%O+E}function v(){return!1}function x(r,d){if(d===!1)return r;var f=Math.pow(10,d===void 0?6:d);return Math.round(r*f)/f}function T(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function M(r){return T(r).split(/\s+/)}function P(r,d){Object.prototype.hasOwnProperty.call(r,"options")||(r.options=r.options?s(r.options):{});for(var f in d)r.options[f]=d[f];return r.options}function F(r,d,f){var _=[];for(var E in r)_.push(encodeURIComponent(f?E.toUpperCase():E)+"="+encodeURIComponent(r[E]));return(!d||d.indexOf("?")===-1?"?":"&")+_.join("&")}var R=/\{ *([\w_ -]+) *\}/g;function q(r,d){return r.replace(R,function(f,_){var E=d[_];if(E===void 0)throw new Error("No value provided for variable "+f);return typeof E=="function"&&(E=E(d)),E})}var H=Array.isArray||function(r){return Object.prototype.toString.call(r)==="[object Array]"};function Q(r,d){for(var f=0;f<r.length;f++)if(r[f]===d)return f;return-1}var tt="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function it(r){return window["webkit"+r]||window["moz"+r]||window["ms"+r]}var rt=0;function vt(r){var d=+new Date,f=Math.max(0,16-(d-rt));return rt=d+f,window.setTimeout(r,f)}var Dt=window.requestAnimationFrame||it("RequestAnimationFrame")||vt,jt=window.cancelAnimationFrame||it("CancelAnimationFrame")||it("CancelRequestAnimationFrame")||function(r){window.clearTimeout(r)};function gt(r,d,f){if(f&&Dt===vt)r.call(d);else return Dt.call(window,a(r,d))}function Ct(r){r&&jt.call(window,r)}var St={__proto__:null,extend:n,create:s,bind:a,get lastId(){return l},stamp:c,throttle:u,wrapNum:p,falseFn:v,formatNum:x,trim:T,splitWords:M,setOptions:P,getParamString:F,template:q,isArray:H,indexOf:Q,emptyImageUrl:tt,requestFn:Dt,cancelFn:jt,requestAnimFrame:gt,cancelAnimFrame:Ct};function Nt(){}Nt.extend=function(r){var d=function(){P(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},f=d.__super__=this.prototype,_=s(f);_.constructor=d,d.prototype=_;for(var E in this)Object.prototype.hasOwnProperty.call(this,E)&&E!=="prototype"&&E!=="__super__"&&(d[E]=this[E]);return r.statics&&n(d,r.statics),r.includes&&(Zt(r.includes),n.apply(null,[_].concat(r.includes))),n(_,r),delete _.statics,delete _.includes,_.options&&(_.options=f.options?s(f.options):{},n(_.options,r.options)),_._initHooks=[],_.callInitHooks=function(){if(!this._initHooksCalled){f.callInitHooks&&f.callInitHooks.call(this),this._initHooksCalled=!0;for(var O=0,K=_._initHooks.length;O<K;O++)_._initHooks[O].call(this)}},d},Nt.include=function(r){var d=this.prototype.options;return n(this.prototype,r),r.options&&(this.prototype.options=d,this.mergeOptions(r.options)),this},Nt.mergeOptions=function(r){return n(this.prototype.options,r),this},Nt.addInitHook=function(r){var d=Array.prototype.slice.call(arguments,1),f=typeof r=="function"?r:function(){this[r].apply(this,d)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(f),this};function Zt(r){if(!(typeof L>"u"||!L||!L.Mixin)){r=H(r)?r:[r];for(var d=0;d<r.length;d++)r[d]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",new Error().stack)}}var re={on:function(r,d,f){if(typeof r=="object")for(var _ in r)this._on(_,r[_],d);else{r=M(r);for(var E=0,O=r.length;E<O;E++)this._on(r[E],d,f)}return this},off:function(r,d,f){if(!arguments.length)delete this._events;else if(typeof r=="object")for(var _ in r)this._off(_,r[_],d);else{r=M(r);for(var E=arguments.length===1,O=0,K=r.length;O<K;O++)E?this._off(r[O]):this._off(r[O],d,f)}return this},_on:function(r,d,f,_){if(typeof d!="function"){console.warn("wrong listener type: "+typeof d);return}if(this._listens(r,d,f)===!1){f===this&&(f=void 0);var E={fn:d,ctx:f};_&&(E.once=!0),this._events=this._events||{},this._events[r]=this._events[r]||[],this._events[r].push(E)}},_off:function(r,d,f){var _,E,O;if(this._events&&(_=this._events[r],!!_)){if(arguments.length===1){if(this._firingCount)for(E=0,O=_.length;E<O;E++)_[E].fn=v;delete this._events[r];return}if(typeof d!="function"){console.warn("wrong listener type: "+typeof d);return}var K=this._listens(r,d,f);if(K!==!1){var et=_[K];this._firingCount&&(et.fn=v,this._events[r]=_=_.slice()),_.splice(K,1)}}},fire:function(r,d,f){if(!this.listens(r,f))return this;var _=n({},d,{type:r,target:this,sourceTarget:d&&d.sourceTarget||this});if(this._events){var E=this._events[r];if(E){this._firingCount=this._firingCount+1||1;for(var O=0,K=E.length;O<K;O++){var et=E[O],at=et.fn;et.once&&this.off(r,at,et.ctx),at.call(et.ctx||this,_)}this._firingCount--}}return f&&this._propagateEvent(_),this},listens:function(r,d,f,_){typeof r!="string"&&console.warn('"string" type argument expected');var E=d;typeof d!="function"&&(_=!!d,E=void 0,f=void 0);var O=this._events&&this._events[r];if(O&&O.length&&this._listens(r,E,f)!==!1)return!0;if(_){for(var K in this._eventParents)if(this._eventParents[K].listens(r,d,f,_))return!0}return!1},_listens:function(r,d,f){if(!this._events)return!1;var _=this._events[r]||[];if(!d)return!!_.length;f===this&&(f=void 0);for(var E=0,O=_.length;E<O;E++)if(_[E].fn===d&&_[E].ctx===f)return E;return!1},once:function(r,d,f){if(typeof r=="object")for(var _ in r)this._on(_,r[_],d,!0);else{r=M(r);for(var E=0,O=r.length;E<O;E++)this._on(r[E],d,f,!0)}return this},addEventParent:function(r){return this._eventParents=this._eventParents||{},this._eventParents[c(r)]=r,this},removeEventParent:function(r){return this._eventParents&&delete this._eventParents[c(r)],this},_propagateEvent:function(r){for(var d in this._eventParents)this._eventParents[d].fire(r.type,n({layer:r.target,propagatedFrom:r.target},r),!0)}};re.addEventListener=re.on,re.removeEventListener=re.clearAllEventListeners=re.off,re.addOneTimeEventListener=re.once,re.fireEvent=re.fire,re.hasEventListeners=re.listens;var te=Nt.extend(re);function ut(r,d,f){this.x=f?Math.round(r):r,this.y=f?Math.round(d):d}var bt=Math.trunc||function(r){return r>0?Math.floor(r):Math.ceil(r)};ut.prototype={clone:function(){return new ut(this.x,this.y)},add:function(r){return this.clone()._add(ht(r))},_add:function(r){return this.x+=r.x,this.y+=r.y,this},subtract:function(r){return this.clone()._subtract(ht(r))},_subtract:function(r){return this.x-=r.x,this.y-=r.y,this},divideBy:function(r){return this.clone()._divideBy(r)},_divideBy:function(r){return this.x/=r,this.y/=r,this},multiplyBy:function(r){return this.clone()._multiplyBy(r)},_multiplyBy:function(r){return this.x*=r,this.y*=r,this},scaleBy:function(r){return new ut(this.x*r.x,this.y*r.y)},unscaleBy:function(r){return new ut(this.x/r.x,this.y/r.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=bt(this.x),this.y=bt(this.y),this},distanceTo:function(r){r=ht(r);var d=r.x-this.x,f=r.y-this.y;return Math.sqrt(d*d+f*f)},equals:function(r){return r=ht(r),r.x===this.x&&r.y===this.y},contains:function(r){return r=ht(r),Math.abs(r.x)<=Math.abs(this.x)&&Math.abs(r.y)<=Math.abs(this.y)},toString:function(){return"Point("+x(this.x)+", "+x(this.y)+")"}};function ht(r,d,f){return r instanceof ut?r:H(r)?new ut(r[0],r[1]):r==null?r:typeof r=="object"&&"x"in r&&"y"in r?new ut(r.x,r.y):new ut(r,d,f)}function Tt(r,d){if(r)for(var f=d?[r,d]:r,_=0,E=f.length;_<E;_++)this.extend(f[_])}Tt.prototype={extend:function(r){var d,f;if(!r)return this;if(r instanceof ut||typeof r[0]=="number"||"x"in r)d=f=ht(r);else if(r=mt(r),d=r.min,f=r.max,!d||!f)return this;return!this.min&&!this.max?(this.min=d.clone(),this.max=f.clone()):(this.min.x=Math.min(d.x,this.min.x),this.max.x=Math.max(f.x,this.max.x),this.min.y=Math.min(d.y,this.min.y),this.max.y=Math.max(f.y,this.max.y)),this},getCenter:function(r){return ht((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,r)},getBottomLeft:function(){return ht(this.min.x,this.max.y)},getTopRight:function(){return ht(this.max.x,this.min.y)},getTopLeft:function(){return this.min},getBottomRight:function(){return this.max},getSize:function(){return this.max.subtract(this.min)},contains:function(r){var d,f;return typeof r[0]=="number"||r instanceof ut?r=ht(r):r=mt(r),r instanceof Tt?(d=r.min,f=r.max):d=f=r,d.x>=this.min.x&&f.x<=this.max.x&&d.y>=this.min.y&&f.y<=this.max.y},intersects:function(r){r=mt(r);var d=this.min,f=this.max,_=r.min,E=r.max,O=E.x>=d.x&&_.x<=f.x,K=E.y>=d.y&&_.y<=f.y;return O&&K},overlaps:function(r){r=mt(r);var d=this.min,f=this.max,_=r.min,E=r.max,O=E.x>d.x&&_.x<f.x,K=E.y>d.y&&_.y<f.y;return O&&K},isValid:function(){return!!(this.min&&this.max)},pad:function(r){var d=this.min,f=this.max,_=Math.abs(d.x-f.x)*r,E=Math.abs(d.y-f.y)*r;return mt(ht(d.x-_,d.y-E),ht(f.x+_,f.y+E))},equals:function(r){return r?(r=mt(r),this.min.equals(r.getTopLeft())&&this.max.equals(r.getBottomRight())):!1}};function mt(r,d){return!r||r instanceof Tt?r:new Tt(r,d)}function At(r,d){if(r)for(var f=d?[r,d]:r,_=0,E=f.length;_<E;_++)this.extend(f[_])}At.prototype={extend:function(r){var d=this._southWest,f=this._northEast,_,E;if(r instanceof dt)_=r,E=r;else if(r instanceof At){if(_=r._southWest,E=r._northEast,!_||!E)return this}else return r?this.extend(b(r)||Et(r)):this;return!d&&!f?(this._southWest=new dt(_.lat,_.lng),this._northEast=new dt(E.lat,E.lng)):(d.lat=Math.min(_.lat,d.lat),d.lng=Math.min(_.lng,d.lng),f.lat=Math.max(E.lat,f.lat),f.lng=Math.max(E.lng,f.lng)),this},pad:function(r){var d=this._southWest,f=this._northEast,_=Math.abs(d.lat-f.lat)*r,E=Math.abs(d.lng-f.lng)*r;return new At(new dt(d.lat-_,d.lng-E),new dt(f.lat+_,f.lng+E))},getCenter:function(){return new dt((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new dt(this.getNorth(),this.getWest())},getSouthEast:function(){return new dt(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(r){typeof r[0]=="number"||r instanceof dt||"lat"in r?r=b(r):r=Et(r);var d=this._southWest,f=this._northEast,_,E;return r instanceof At?(_=r.getSouthWest(),E=r.getNorthEast()):_=E=r,_.lat>=d.lat&&E.lat<=f.lat&&_.lng>=d.lng&&E.lng<=f.lng},intersects:function(r){r=Et(r);var d=this._southWest,f=this._northEast,_=r.getSouthWest(),E=r.getNorthEast(),O=E.lat>=d.lat&&_.lat<=f.lat,K=E.lng>=d.lng&&_.lng<=f.lng;return O&&K},overlaps:function(r){r=Et(r);var d=this._southWest,f=this._northEast,_=r.getSouthWest(),E=r.getNorthEast(),O=E.lat>d.lat&&_.lat<f.lat,K=E.lng>d.lng&&_.lng<f.lng;return O&&K},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(r,d){return r?(r=Et(r),this._southWest.equals(r.getSouthWest(),d)&&this._northEast.equals(r.getNorthEast(),d)):!1},isValid:function(){return!!(this._southWest&&this._northEast)}};function Et(r,d){return r instanceof At?r:new At(r,d)}function dt(r,d,f){if(isNaN(r)||isNaN(d))throw new Error("Invalid LatLng object: ("+r+", "+d+")");this.lat=+r,this.lng=+d,f!==void 0&&(this.alt=+f)}dt.prototype={equals:function(r,d){if(!r)return!1;r=b(r);var f=Math.max(Math.abs(this.lat-r.lat),Math.abs(this.lng-r.lng));return f<=(d===void 0?1e-9:d)},toString:function(r){return"LatLng("+x(this.lat,r)+", "+x(this.lng,r)+")"},distanceTo:function(r){return S.distance(this,b(r))},wrap:function(){return S.wrapLatLng(this)},toBounds:function(r){var d=180*r/40075017,f=d/Math.cos(Math.PI/180*this.lat);return Et([this.lat-d,this.lng-f],[this.lat+d,this.lng+f])},clone:function(){return new dt(this.lat,this.lng,this.alt)}};function b(r,d,f){return r instanceof dt?r:H(r)&&typeof r[0]!="object"?r.length===3?new dt(r[0],r[1],r[2]):r.length===2?new dt(r[0],r[1]):null:r==null?r:typeof r=="object"&&"lat"in r?new dt(r.lat,"lng"in r?r.lng:r.lon,r.alt):d===void 0?null:new dt(r,d,f)}var k={latLngToPoint:function(r,d){var f=this.projection.project(r),_=this.scale(d);return this.transformation._transform(f,_)},pointToLatLng:function(r,d){var f=this.scale(d),_=this.transformation.untransform(r,f);return this.projection.unproject(_)},project:function(r){return this.projection.project(r)},unproject:function(r){return this.projection.unproject(r)},scale:function(r){return 256*Math.pow(2,r)},zoom:function(r){return Math.log(r/256)/Math.LN2},getProjectedBounds:function(r){if(this.infinite)return null;var d=this.projection.bounds,f=this.scale(r),_=this.transformation.transform(d.min,f),E=this.transformation.transform(d.max,f);return new Tt(_,E)},infinite:!1,wrapLatLng:function(r){var d=this.wrapLng?p(r.lng,this.wrapLng,!0):r.lng,f=this.wrapLat?p(r.lat,this.wrapLat,!0):r.lat,_=r.alt;return new dt(f,d,_)},wrapLatLngBounds:function(r){var d=r.getCenter(),f=this.wrapLatLng(d),_=d.lat-f.lat,E=d.lng-f.lng;if(_===0&&E===0)return r;var O=r.getSouthWest(),K=r.getNorthEast(),et=new dt(O.lat-_,O.lng-E),at=new dt(K.lat-_,K.lng-E);return new At(et,at)}},S=n({},k,{wrapLng:[-180,180],R:6371e3,distance:function(r,d){var f=Math.PI/180,_=r.lat*f,E=d.lat*f,O=Math.sin((d.lat-r.lat)*f/2),K=Math.sin((d.lng-r.lng)*f/2),et=O*O+Math.cos(_)*Math.cos(E)*K*K,at=2*Math.atan2(Math.sqrt(et),Math.sqrt(1-et));return this.R*at}}),I=6378137,N={R:I,MAX_LATITUDE:85.0511287798,project:function(r){var d=Math.PI/180,f=this.MAX_LATITUDE,_=Math.max(Math.min(f,r.lat),-f),E=Math.sin(_*d);return new ut(this.R*r.lng*d,this.R*Math.log((1+E)/(1-E))/2)},unproject:function(r){var d=180/Math.PI;return new dt((2*Math.atan(Math.exp(r.y/this.R))-Math.PI/2)*d,r.x*d/this.R)},bounds:function(){var r=I*Math.PI;return new Tt([-r,-r],[r,r])}()};function B(r,d,f,_){if(H(r)){this._a=r[0],this._b=r[1],this._c=r[2],this._d=r[3];return}this._a=r,this._b=d,this._c=f,this._d=_}B.prototype={transform:function(r,d){return this._transform(r.clone(),d)},_transform:function(r,d){return d=d||1,r.x=d*(this._a*r.x+this._b),r.y=d*(this._c*r.y+this._d),r},untransform:function(r,d){return d=d||1,new ut((r.x/d-this._b)/this._a,(r.y/d-this._d)/this._c)}};function V(r,d,f,_){return new B(r,d,f,_)}var G=n({},S,{code:"EPSG:3857",projection:N,transformation:function(){var r=.5/(Math.PI*N.R);return V(r,.5,-r,.5)}()}),J=n({},G,{code:"EPSG:900913"});function X(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function wt(r,d){var f="",_,E,O,K,et,at;for(_=0,O=r.length;_<O;_++){for(et=r[_],E=0,K=et.length;E<K;E++)at=et[E],f+=(E?"L":"M")+at.x+" "+at.y;f+=d?zt.svg?"z":"x":""}return f||"M0 0"}var $t=document.documentElement.style,lt="ActiveXObject"in window,Ht=lt&&!document.addEventListener,Kt="msLaunchUri"in navigator&&!("documentMode"in document),qt=Ui("webkit"),Vt=Ui("android"),be=Ui("android 2")||Ui("android 3"),Ce=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),_e=Vt&&Ui("Google")&&Ce<537&&!("AudioNode"in window),je=!!window.opera,Si=!Kt&&Ui("chrome"),Vr=Ui("gecko")&&!qt&&!je&&!lt,oi=!Si&&Ui("safari"),Io=Ui("phantom"),De="OTransition"in $t,Jl=navigator.platform.indexOf("Win")===0,Ur=lt&&"transition"in $t,Ns="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!be,Ms="MozPerspective"in $t,xe=!window.L_DISABLE_3D&&(Ur||Ns||Ms)&&!De&&!Io,ei=typeof orientation<"u"||Ui("mobile"),Oe=ei&&qt,si=ei&&Ns,an=!window.PointerEvent&&window.MSPointerEvent,Ps=!!(window.PointerEvent||an),Ye="ontouchstart"in window||!!window.TouchEvent,Os=!window.L_NO_TOUCH&&(Ye||Ps),Ql=ei&&je,Xl=ei&&Vr,jr=(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI)>1,qr=function(){var r=!1;try{var d=Object.defineProperty({},"passive",{get:function(){r=!0}});window.addEventListener("testPassiveEventSupport",v,d),window.removeEventListener("testPassiveEventSupport",v,d)}catch{}return r}(),tc=function(){return!!document.createElement("canvas").getContext}(),Ds=!!(document.createElementNS&&X("svg").createSVGRect),Kr=!!Ds&&function(){var r=document.createElement("div");return r.innerHTML="<svg/>",(r.firstChild&&r.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"}(),ec=!Ds&&function(){try{var r=document.createElement("div");r.innerHTML='<v:shape adj="1"/>';var d=r.firstChild;return d.style.behavior="url(#default#VML)",d&&typeof d.adj=="object"}catch{return!1}}(),ao=navigator.platform.indexOf("Mac")===0,Rs=navigator.platform.indexOf("Linux")===0;function Ui(r){return navigator.userAgent.toLowerCase().indexOf(r)>=0}var zt={ie:lt,ielt9:Ht,edge:Kt,webkit:qt,android:Vt,android23:be,androidStock:_e,opera:je,chrome:Si,gecko:Vr,safari:oi,phantom:Io,opera12:De,win:Jl,ie3d:Ur,webkit3d:Ns,gecko3d:Ms,any3d:xe,mobile:ei,mobileWebkit:Oe,mobileWebkit3d:si,msPointer:an,pointer:Ps,touch:Os,touchNative:Ye,mobileOpera:Ql,mobileGecko:Xl,retina:jr,passiveEvents:qr,canvas:tc,svg:Ds,vml:ec,inlineSvg:Kr,mac:ao,linux:Rs},Zr=zt.msPointer?"MSPointerDown":"pointerdown",Gr=zt.msPointer?"MSPointerMove":"pointermove",Oi=zt.msPointer?"MSPointerUp":"pointerup",Go=zt.msPointer?"MSPointerCancel":"pointercancel",Bs={touchstart:Zr,touchmove:Gr,touchend:Oi,touchcancel:Go},zs={touchstart:ln,touchmove:Yo,touchend:Yo,touchcancel:Yo},Bn={},Yr=!1;function Jr(r,d,f){return d==="touchstart"&&Ws(),zs[d]?(f=zs[d].bind(this,f),r.addEventListener(Bs[d],f,!1),f):(console.warn("wrong event specified:",d),v)}function ic(r,d,f){if(!Bs[d]){console.warn("wrong event specified:",d);return}r.removeEventListener(Bs[d],f,!1)}function Qr(r){Bn[r.pointerId]=r}function nc(r){Bn[r.pointerId]&&(Bn[r.pointerId]=r)}function Fs(r){delete Bn[r.pointerId]}function Ws(){Yr||(document.addEventListener(Zr,Qr,!0),document.addEventListener(Gr,nc,!0),document.addEventListener(Oi,Fs,!0),document.addEventListener(Go,Fs,!0),Yr=!0)}function Yo(r,d){if(d.pointerType!==(d.MSPOINTER_TYPE_MOUSE||"mouse")){d.touches=[];for(var f in Bn)d.touches.push(Bn[f]);d.changedTouches=[d],r(d)}}function ln(r,d){d.MSPOINTER_TYPE_TOUCH&&d.pointerType===d.MSPOINTER_TYPE_TOUCH&&qe(d),Yo(r,d)}function oc(r){var d={},f,_;for(_ in r)f=r[_],d[_]=f&&f.bind?f.bind(r):f;return r=d,d.type="dblclick",d.detail=2,d.isTrusted=!1,d._simulated=!0,d}var Xr=200;function ta(r,d){r.addEventListener("dblclick",d);var f=0,_;function E(O){if(O.detail!==1){_=O.detail;return}if(!(O.pointerType==="mouse"||O.sourceCapabilities&&!O.sourceCapabilities.firesTouchEvents)){var K=Gs(O);if(!(K.some(function(at){return at instanceof HTMLLabelElement&&at.attributes.for})&&!K.some(function(at){return at instanceof HTMLInputElement||at instanceof HTMLSelectElement}))){var et=Date.now();et-f<=Xr?(_++,_===2&&d(oc(O))):_=1,f=et}}}return r.addEventListener("click",E),{dblclick:d,simDblclick:E}}function sc(r,d){r.removeEventListener("dblclick",d.dblclick),r.removeEventListener("click",d.simDblclick)}var Jo=Fn(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),Ao=Fn(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),ea=Ao==="webkitTransition"||Ao==="OTransition"?Ao+"End":"transitionend";function Ti(r){return typeof r=="string"?document.getElementById(r):r}function Lo(r,d){var f=r.style[d]||r.currentStyle&&r.currentStyle[d];if((!f||f==="auto")&&document.defaultView){var _=document.defaultView.getComputedStyle(r,null);f=_?_[d]:null}return f==="auto"?null:f}function pe(r,d,f){var _=document.createElement(r);return _.className=d||"",f&&f.appendChild(_),_}function Ee(r){var d=r.parentNode;d&&d.removeChild(r)}function No(r){for(;r.firstChild;)r.removeChild(r.firstChild)}function lo(r){var d=r.parentNode;d&&d.lastChild!==r&&d.appendChild(r)}function zn(r){var d=r.parentNode;d&&d.firstChild!==r&&d.insertBefore(r,d.firstChild)}function Hs(r,d){if(r.classList!==void 0)return r.classList.contains(d);var f=ui(r);return f.length>0&&new RegExp("(^|\\s)"+d+"(\\s|$)").test(f)}function ne(r,d){if(r.classList!==void 0)for(var f=M(d),_=0,E=f.length;_<E;_++)r.classList.add(f[_]);else if(!Hs(r,d)){var O=ui(r);Qo(r,(O?O+" ":"")+d)}}function Re(r,d){r.classList!==void 0?r.classList.remove(d):Qo(r,T((" "+ui(r)+" ").replace(" "+d+" "," ")))}function Qo(r,d){r.className.baseVal===void 0?r.className=d:r.className.baseVal=d}function ui(r){return r.correspondingElement&&(r=r.correspondingElement),r.className.baseVal===void 0?r.className:r.className.baseVal}function ie(r,d){"opacity"in r.style?r.style.opacity=d:"filter"in r.style&&rc(r,d)}function rc(r,d){var f=!1,_="DXImageTransform.Microsoft.Alpha";try{f=r.filters.item(_)}catch{if(d===1)return}d=Math.round(d*100),f?(f.Enabled=d!==100,f.Opacity=d):r.style.filter+=" progid:"+_+"(opacity="+d+")"}function Fn(r){for(var d=document.documentElement.style,f=0;f<r.length;f++)if(r[f]in d)return r[f];return!1}function Wn(r,d,f){var _=d||new ut(0,0);r.style[Jo]=(zt.ie3d?"translate("+_.x+"px,"+_.y+"px)":"translate3d("+_.x+"px,"+_.y+"px,0)")+(f?" scale("+f+")":"")}function Ie(r,d){r._leaflet_pos=d,zt.any3d?Wn(r,d):(r.style.left=d.x+"px",r.style.top=d.y+"px")}function Hn(r){return r._leaflet_pos||new ut(0,0)}var cn,Vn,Xo;if("onselectstart"in document)cn=function(){Gt(window,"selectstart",qe)},Vn=function(){ke(window,"selectstart",qe)};else{var Mo=Fn(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);cn=function(){if(Mo){var r=document.documentElement.style;Xo=r[Mo],r[Mo]="none"}},Vn=function(){Mo&&(document.documentElement.style[Mo]=Xo,Xo=void 0)}}function bn(){Gt(window,"dragstart",qe)}function Vs(){ke(window,"dragstart",qe)}var co,ho;function ts(r){for(;r.tabIndex===-1;)r=r.parentNode;r.style&&(es(),co=r,ho=r.style.outlineStyle,r.style.outlineStyle="none",Gt(window,"keydown",es))}function es(){co&&(co.style.outlineStyle=ho,co=void 0,ho=void 0,ke(window,"keydown",es))}function Us(r){do r=r.parentNode;while((!r.offsetWidth||!r.offsetHeight)&&r!==document.body);return r}function ii(r){var d=r.getBoundingClientRect();return{x:d.width/r.offsetWidth||1,y:d.height/r.offsetHeight||1,boundingClientRect:d}}var ac={__proto__:null,TRANSFORM:Jo,TRANSITION:Ao,TRANSITION_END:ea,get:Ti,getStyle:Lo,create:pe,remove:Ee,empty:No,toFront:lo,toBack:zn,hasClass:Hs,addClass:ne,removeClass:Re,setClass:Qo,getClass:ui,setOpacity:ie,testProp:Fn,setTransform:Wn,setPosition:Ie,getPosition:Hn,get disableTextSelection(){return cn},get enableTextSelection(){return Vn},disableImageDrag:bn,enableImageDrag:Vs,preventOutline:ts,restoreOutline:es,getSizedParentNode:Us,getScale:ii};function Gt(r,d,f,_){if(d&&typeof d=="object")for(var E in d)qs(r,E,d[E],f);else{d=M(d);for(var O=0,K=d.length;O<K;O++)qs(r,d[O],f,_)}return this}var Ei="_leaflet_events";function ke(r,d,f,_){if(arguments.length===1)ia(r),delete r[Ei];else if(d&&typeof d=="object")for(var E in d)Ks(r,E,d[E],f);else if(d=M(d),arguments.length===2)ia(r,function(et){return Q(d,et)!==-1});else for(var O=0,K=d.length;O<K;O++)Ks(r,d[O],f,_);return this}function ia(r,d){for(var f in r[Ei]){var _=f.split(/\d/)[0];(!d||d(_))&&Ks(r,_,null,null,f)}}var js={mouseenter:"mouseover",mouseleave:"mouseout",wheel:!("onwheel"in window)&&"mousewheel"};function qs(r,d,f,_){var E=d+c(f)+(_?"_"+c(_):"");if(r[Ei]&&r[Ei][E])return this;var O=function(et){return f.call(_||r,et||window.event)},K=O;!zt.touchNative&&zt.pointer&&d.indexOf("touch")===0?O=Jr(r,d,O):zt.touch&&d==="dblclick"?O=ta(r,O):"addEventListener"in r?d==="touchstart"||d==="touchmove"||d==="wheel"||d==="mousewheel"?r.addEventListener(js[d]||d,O,zt.passiveEvents?{passive:!1}:!1):d==="mouseenter"||d==="mouseleave"?(O=function(et){et=et||window.event,Po(r,et)&&K(et)},r.addEventListener(js[d],O,!1)):r.addEventListener(d,K,!1):r.attachEvent("on"+d,O),r[Ei]=r[Ei]||{},r[Ei][E]=O}function Ks(r,d,f,_,E){E=E||d+c(f)+(_?"_"+c(_):"");var O=r[Ei]&&r[Ei][E];if(!O)return this;!zt.touchNative&&zt.pointer&&d.indexOf("touch")===0?ic(r,d,O):zt.touch&&d==="dblclick"?sc(r,O):"removeEventListener"in r?r.removeEventListener(js[d]||d,O,!1):r.detachEvent("on"+d,O),r[Ei][E]=null}function Un(r){return r.stopPropagation?r.stopPropagation():r.originalEvent?r.originalEvent._stopped=!0:r.cancelBubble=!0,this}function Zs(r){return qs(r,"wheel",Un),this}function uo(r){return Gt(r,"mousedown touchstart dblclick contextmenu",Un),r._leaflet_disable_click=!0,this}function qe(r){return r.preventDefault?r.preventDefault():r.returnValue=!1,this}function wn(r){return qe(r),Un(r),this}function Gs(r){if(r.composedPath)return r.composedPath();for(var d=[],f=r.target;f;)d.push(f),f=f.parentNode;return d}function Ys(r,d){if(!d)return new ut(r.clientX,r.clientY);var f=ii(d),_=f.boundingClientRect;return new ut((r.clientX-_.left)/f.x-d.clientLeft,(r.clientY-_.top)/f.y-d.clientTop)}var na=zt.linux&&zt.chrome?window.devicePixelRatio:zt.mac?window.devicePixelRatio*3:window.devicePixelRatio>0?2*window.devicePixelRatio:1;function Js(r){return zt.edge?r.wheelDeltaY/2:r.deltaY&&r.deltaMode===0?-r.deltaY/na:r.deltaY&&r.deltaMode===1?-r.deltaY*20:r.deltaY&&r.deltaMode===2?-r.deltaY*60:r.deltaX||r.deltaZ?0:r.wheelDelta?(r.wheelDeltaY||r.wheelDelta)/2:r.detail&&Math.abs(r.detail)<32765?-r.detail*20:r.detail?r.detail/-32765*60:0}function Po(r,d){var f=d.relatedTarget;if(!f)return!0;try{for(;f&&f!==r;)f=f.parentNode}catch{return!1}return f!==r}var lc={__proto__:null,on:Gt,off:ke,stopPropagation:Un,disableScrollPropagation:Zs,disableClickPropagation:uo,preventDefault:qe,stop:wn,getPropagationPath:Gs,getMousePosition:Ys,getWheelDelta:Js,isExternalTarget:Po,addListener:Gt,removeListener:ke},h=te.extend({run:function(r,d,f,_){this.stop(),this._el=r,this._inProgress=!0,this._duration=f||.25,this._easeOutPower=1/Math.max(_||.5,.2),this._startPos=Hn(r),this._offset=d.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=gt(this._animate,this),this._step()},_step:function(r){var d=+new Date-this._startTime,f=this._duration*1e3;d<f?this._runFrame(this._easeOut(d/f),r):(this._runFrame(1),this._complete())},_runFrame:function(r,d){var f=this._startPos.add(this._offset.multiplyBy(r));d&&f._round(),Ie(this._el,f),this.fire("step")},_complete:function(){Ct(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(r){return 1-Math.pow(1-r,this._easeOutPower)}}),g=te.extend({options:{crs:G,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(r,d){d=P(this,d),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(r),this._initLayout(),this._onResize=a(this._onResize,this),this._initEvents(),d.maxBounds&&this.setMaxBounds(d.maxBounds),d.zoom!==void 0&&(this._zoom=this._limitZoom(d.zoom)),d.center&&d.zoom!==void 0&&this.setView(b(d.center),d.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=Ao&&zt.any3d&&!zt.mobileOpera&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),Gt(this._proxy,ea,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(r,d,f){if(d=d===void 0?this._zoom:this._limitZoom(d),r=this._limitCenter(b(r),d,this.options.maxBounds),f=f||{},this._stop(),this._loaded&&!f.reset&&f!==!0){f.animate!==void 0&&(f.zoom=n({animate:f.animate},f.zoom),f.pan=n({animate:f.animate,duration:f.duration},f.pan));var _=this._zoom!==d?this._tryAnimatedZoom&&this._tryAnimatedZoom(r,d,f.zoom):this._tryAnimatedPan(r,f.pan);if(_)return clearTimeout(this._sizeTimer),this}return this._resetView(r,d,f.pan&&f.pan.noMoveStart),this},setZoom:function(r,d){return this._loaded?this.setView(this.getCenter(),r,{zoom:d}):(this._zoom=r,this)},zoomIn:function(r,d){return r=r||(zt.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom+r,d)},zoomOut:function(r,d){return r=r||(zt.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom-r,d)},setZoomAround:function(r,d,f){var _=this.getZoomScale(d),E=this.getSize().divideBy(2),O=r instanceof ut?r:this.latLngToContainerPoint(r),K=O.subtract(E).multiplyBy(1-1/_),et=this.containerPointToLatLng(E.add(K));return this.setView(et,d,{zoom:f})},_getBoundsCenterZoom:function(r,d){d=d||{},r=r.getBounds?r.getBounds():Et(r);var f=ht(d.paddingTopLeft||d.padding||[0,0]),_=ht(d.paddingBottomRight||d.padding||[0,0]),E=this.getBoundsZoom(r,!1,f.add(_));if(E=typeof d.maxZoom=="number"?Math.min(d.maxZoom,E):E,E===1/0)return{center:r.getCenter(),zoom:E};var O=_.subtract(f).divideBy(2),K=this.project(r.getSouthWest(),E),et=this.project(r.getNorthEast(),E),at=this.unproject(K.add(et).divideBy(2).add(O),E);return{center:at,zoom:E}},fitBounds:function(r,d){if(r=Et(r),!r.isValid())throw new Error("Bounds are not valid.");var f=this._getBoundsCenterZoom(r,d);return this.setView(f.center,f.zoom,d)},fitWorld:function(r){return this.fitBounds([[-90,-180],[90,180]],r)},panTo:function(r,d){return this.setView(r,this._zoom,{pan:d})},panBy:function(r,d){if(r=ht(r).round(),d=d||{},!r.x&&!r.y)return this.fire("moveend");if(d.animate!==!0&&!this.getSize().contains(r))return this._resetView(this.unproject(this.project(this.getCenter()).add(r)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new h,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),d.noMoveStart||this.fire("movestart"),d.animate!==!1){ne(this._mapPane,"leaflet-pan-anim");var f=this._getMapPanePos().subtract(r).round();this._panAnim.run(this._mapPane,f,d.duration||.25,d.easeLinearity)}else this._rawPanBy(r),this.fire("move").fire("moveend");return this},flyTo:function(r,d,f){if(f=f||{},f.animate===!1||!zt.any3d)return this.setView(r,d,f);this._stop();var _=this.project(this.getCenter()),E=this.project(r),O=this.getSize(),K=this._zoom;r=b(r),d=d===void 0?K:d;var et=Math.max(O.x,O.y),at=et*this.getZoomScale(K,d),_t=E.distanceTo(_)||1,Rt=1.42,Jt=Rt*Rt;function le(Ze){var fa=Ze?-1:1,Qy=Ze?at:et,Xy=at*at-et*et+fa*Jt*Jt*_t*_t,tb=2*Qy*Jt*_t,mc=Xy/tb,hu=Math.sqrt(mc*mc+1)-mc,eb=hu<1e-9?-18:Math.log(hu);return eb}function _i(Ze){return(Math.exp(Ze)-Math.exp(-Ze))/2}function ni(Ze){return(Math.exp(Ze)+Math.exp(-Ze))/2}function Ki(Ze){return _i(Ze)/ni(Ze)}var Ai=le(0);function as(Ze){return et*(ni(Ai)/ni(Ai+Rt*Ze))}function Zy(Ze){return et*(ni(Ai)*Ki(Ai+Rt*Ze)-_i(Ai))/Jt}function Gy(Ze){return 1-Math.pow(1-Ze,1.5)}var Yy=Date.now(),cu=(le(1)-Ai)/Rt,Jy=f.duration?1e3*f.duration:1e3*cu*.8;function du(){var Ze=(Date.now()-Yy)/Jy,fa=Gy(Ze)*cu;Ze<=1?(this._flyToFrame=gt(du,this),this._move(this.unproject(_.add(E.subtract(_).multiplyBy(Zy(fa)/_t)),K),this.getScaleZoom(et/as(fa),K),{flyTo:!0})):this._move(r,d)._moveEnd(!0)}return this._moveStart(!0,f.noMoveStart),du.call(this),this},flyToBounds:function(r,d){var f=this._getBoundsCenterZoom(r,d);return this.flyTo(f.center,f.zoom,d)},setMaxBounds:function(r){return r=Et(r),this.listens("moveend",this._panInsideMaxBounds)&&this.off("moveend",this._panInsideMaxBounds),r.isValid()?(this.options.maxBounds=r,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this)},setMinZoom:function(r){var d=this.options.minZoom;return this.options.minZoom=r,this._loaded&&d!==r&&(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)?this.setZoom(r):this},setMaxZoom:function(r){var d=this.options.maxZoom;return this.options.maxZoom=r,this._loaded&&d!==r&&(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)?this.setZoom(r):this},panInsideBounds:function(r,d){this._enforcingBounds=!0;var f=this.getCenter(),_=this._limitCenter(f,this._zoom,Et(r));return f.equals(_)||this.panTo(_,d),this._enforcingBounds=!1,this},panInside:function(r,d){d=d||{};var f=ht(d.paddingTopLeft||d.padding||[0,0]),_=ht(d.paddingBottomRight||d.padding||[0,0]),E=this.project(this.getCenter()),O=this.project(r),K=this.getPixelBounds(),et=mt([K.min.add(f),K.max.subtract(_)]),at=et.getSize();if(!et.contains(O)){this._enforcingBounds=!0;var _t=O.subtract(et.getCenter()),Rt=et.extend(O).getSize().subtract(at);E.x+=_t.x<0?-Rt.x:Rt.x,E.y+=_t.y<0?-Rt.y:Rt.y,this.panTo(this.unproject(E),d),this._enforcingBounds=!1}return this},invalidateSize:function(r){if(!this._loaded)return this;r=n({animate:!1,pan:!0},r===!0?{animate:!0}:r);var d=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var f=this.getSize(),_=d.divideBy(2).round(),E=f.divideBy(2).round(),O=_.subtract(E);return!O.x&&!O.y?this:(r.animate&&r.pan?this.panBy(O):(r.pan&&this._rawPanBy(O),this.fire("move"),r.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(a(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:d,newSize:f}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(r){if(r=this._locateOptions=n({timeout:1e4,watch:!1},r),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var d=a(this._handleGeolocationResponse,this),f=a(this._handleGeolocationError,this);return r.watch?this._locationWatchId=navigator.geolocation.watchPosition(d,f,r):navigator.geolocation.getCurrentPosition(d,f,r),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(r){if(this._container._leaflet_id){var d=r.code,f=r.message||(d===1?"permission denied":d===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:d,message:"Geolocation error: "+f+"."})}},_handleGeolocationResponse:function(r){if(this._container._leaflet_id){var d=r.coords.latitude,f=r.coords.longitude,_=new dt(d,f),E=_.toBounds(r.coords.accuracy*2),O=this._locateOptions;if(O.setView){var K=this.getBoundsZoom(E);this.setView(_,O.maxZoom?Math.min(K,O.maxZoom):K)}var et={latlng:_,bounds:E,timestamp:r.timestamp};for(var at in r.coords)typeof r.coords[at]=="number"&&(et[at]=r.coords[at]);this.fire("locationfound",et)}},addHandler:function(r,d){if(!d)return this;var f=this[r]=new d(this);return this._handlers.push(f),this.options[r]&&f.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),Ee(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(Ct(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var r;for(r in this._layers)this._layers[r].remove();for(r in this._panes)Ee(this._panes[r]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(r,d){var f="leaflet-pane"+(r?" leaflet-"+r.replace("Pane","")+"-pane":""),_=pe("div",f,d||this._mapPane);return r&&(this._panes[r]=_),_},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var r=this.getPixelBounds(),d=this.unproject(r.getBottomLeft()),f=this.unproject(r.getTopRight());return new At(d,f)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(r,d,f){r=Et(r),f=ht(f||[0,0]);var _=this.getZoom()||0,E=this.getMinZoom(),O=this.getMaxZoom(),K=r.getNorthWest(),et=r.getSouthEast(),at=this.getSize().subtract(f),_t=mt(this.project(et,_),this.project(K,_)).getSize(),Rt=zt.any3d?this.options.zoomSnap:1,Jt=at.x/_t.x,le=at.y/_t.y,_i=d?Math.max(Jt,le):Math.min(Jt,le);return _=this.getScaleZoom(_i,_),Rt&&(_=Math.round(_/(Rt/100))*(Rt/100),_=d?Math.ceil(_/Rt)*Rt:Math.floor(_/Rt)*Rt),Math.max(E,Math.min(O,_))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new ut(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(r,d){var f=this._getTopLeftPoint(r,d);return new Tt(f,f.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(r){return this.options.crs.getProjectedBounds(r===void 0?this.getZoom():r)},getPane:function(r){return typeof r=="string"?this._panes[r]:r},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(r,d){var f=this.options.crs;return d=d===void 0?this._zoom:d,f.scale(r)/f.scale(d)},getScaleZoom:function(r,d){var f=this.options.crs;d=d===void 0?this._zoom:d;var _=f.zoom(r*f.scale(d));return isNaN(_)?1/0:_},project:function(r,d){return d=d===void 0?this._zoom:d,this.options.crs.latLngToPoint(b(r),d)},unproject:function(r,d){return d=d===void 0?this._zoom:d,this.options.crs.pointToLatLng(ht(r),d)},layerPointToLatLng:function(r){var d=ht(r).add(this.getPixelOrigin());return this.unproject(d)},latLngToLayerPoint:function(r){var d=this.project(b(r))._round();return d._subtract(this.getPixelOrigin())},wrapLatLng:function(r){return this.options.crs.wrapLatLng(b(r))},wrapLatLngBounds:function(r){return this.options.crs.wrapLatLngBounds(Et(r))},distance:function(r,d){return this.options.crs.distance(b(r),b(d))},containerPointToLayerPoint:function(r){return ht(r).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(r){return ht(r).add(this._getMapPanePos())},containerPointToLatLng:function(r){var d=this.containerPointToLayerPoint(ht(r));return this.layerPointToLatLng(d)},latLngToContainerPoint:function(r){return this.layerPointToContainerPoint(this.latLngToLayerPoint(b(r)))},mouseEventToContainerPoint:function(r){return Ys(r,this._container)},mouseEventToLayerPoint:function(r){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(r))},mouseEventToLatLng:function(r){return this.layerPointToLatLng(this.mouseEventToLayerPoint(r))},_initContainer:function(r){var d=this._container=Ti(r);if(d){if(d._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");Gt(d,"scroll",this._onScroll,this),this._containerId=c(d)},_initLayout:function(){var r=this._container;this._fadeAnimated=this.options.fadeAnimation&&zt.any3d,ne(r,"leaflet-container"+(zt.touch?" leaflet-touch":"")+(zt.retina?" leaflet-retina":"")+(zt.ielt9?" leaflet-oldie":"")+(zt.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var d=Lo(r,"position");d!=="absolute"&&d!=="relative"&&d!=="fixed"&&d!=="sticky"&&(r.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var r=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Ie(this._mapPane,new ut(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(ne(r.markerPane,"leaflet-zoom-hide"),ne(r.shadowPane,"leaflet-zoom-hide"))},_resetView:function(r,d,f){Ie(this._mapPane,new ut(0,0));var _=!this._loaded;this._loaded=!0,d=this._limitZoom(d),this.fire("viewprereset");var E=this._zoom!==d;this._moveStart(E,f)._move(r,d)._moveEnd(E),this.fire("viewreset"),_&&this.fire("load")},_moveStart:function(r,d){return r&&this.fire("zoomstart"),d||this.fire("movestart"),this},_move:function(r,d,f,_){d===void 0&&(d=this._zoom);var E=this._zoom!==d;return this._zoom=d,this._lastCenter=r,this._pixelOrigin=this._getNewPixelOrigin(r),_?f&&f.pinch&&this.fire("zoom",f):((E||f&&f.pinch)&&this.fire("zoom",f),this.fire("move",f)),this},_moveEnd:function(r){return r&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return Ct(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(r){Ie(this._mapPane,this._getMapPanePos().subtract(r))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(r){this._targets={},this._targets[c(this._container)]=this;var d=r?ke:Gt;d(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&d(window,"resize",this._onResize,this),zt.any3d&&this.options.transform3DLimit&&(r?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){Ct(this._resizeRequest),this._resizeRequest=gt(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var r=this._getMapPanePos();Math.max(Math.abs(r.x),Math.abs(r.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(r,d){for(var f=[],_,E=d==="mouseout"||d==="mouseover",O=r.target||r.srcElement,K=!1;O;){if(_=this._targets[c(O)],_&&(d==="click"||d==="preclick")&&this._draggableMoved(_)){K=!0;break}if(_&&_.listens(d,!0)&&(E&&!Po(O,r)||(f.push(_),E))||O===this._container)break;O=O.parentNode}return!f.length&&!K&&!E&&this.listens(d,!0)&&(f=[this]),f},_isClickDisabled:function(r){for(;r&&r!==this._container;){if(r._leaflet_disable_click)return!0;r=r.parentNode}},_handleDOMEvent:function(r){var d=r.target||r.srcElement;if(!(!this._loaded||d._leaflet_disable_events||r.type==="click"&&this._isClickDisabled(d))){var f=r.type;f==="mousedown"&&ts(d),this._fireDOMEvent(r,f)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(r,d,f){if(r.type==="click"){var _=n({},r);_.type="preclick",this._fireDOMEvent(_,_.type,f)}var E=this._findEventTargets(r,d);if(f){for(var O=[],K=0;K<f.length;K++)f[K].listens(d,!0)&&O.push(f[K]);E=O.concat(E)}if(E.length){d==="contextmenu"&&qe(r);var et=E[0],at={originalEvent:r};if(r.type!=="keypress"&&r.type!=="keydown"&&r.type!=="keyup"){var _t=et.getLatLng&&(!et._radius||et._radius<=10);at.containerPoint=_t?this.latLngToContainerPoint(et.getLatLng()):this.mouseEventToContainerPoint(r),at.layerPoint=this.containerPointToLayerPoint(at.containerPoint),at.latlng=_t?et.getLatLng():this.layerPointToLatLng(at.layerPoint)}for(K=0;K<E.length;K++)if(E[K].fire(d,at,!0),at.originalEvent._stopped||E[K].options.bubblingMouseEvents===!1&&Q(this._mouseEvents,d)!==-1)return}},_draggableMoved:function(r){return r=r.dragging&&r.dragging.enabled()?r:this,r.dragging&&r.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var r=0,d=this._handlers.length;r<d;r++)this._handlers[r].disable()},whenReady:function(r,d){return this._loaded?r.call(d||this,{target:this}):this.on("load",r,d),this},_getMapPanePos:function(){return Hn(this._mapPane)||new ut(0,0)},_moved:function(){var r=this._getMapPanePos();return r&&!r.equals([0,0])},_getTopLeftPoint:function(r,d){var f=r&&d!==void 0?this._getNewPixelOrigin(r,d):this.getPixelOrigin();return f.subtract(this._getMapPanePos())},_getNewPixelOrigin:function(r,d){var f=this.getSize()._divideBy(2);return this.project(r,d)._subtract(f)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(r,d,f){var _=this._getNewPixelOrigin(f,d);return this.project(r,d)._subtract(_)},_latLngBoundsToNewLayerBounds:function(r,d,f){var _=this._getNewPixelOrigin(f,d);return mt([this.project(r.getSouthWest(),d)._subtract(_),this.project(r.getNorthWest(),d)._subtract(_),this.project(r.getSouthEast(),d)._subtract(_),this.project(r.getNorthEast(),d)._subtract(_)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(r){return this.latLngToLayerPoint(r).subtract(this._getCenterLayerPoint())},_limitCenter:function(r,d,f){if(!f)return r;var _=this.project(r,d),E=this.getSize().divideBy(2),O=new Tt(_.subtract(E),_.add(E)),K=this._getBoundsOffset(O,f,d);return Math.abs(K.x)<=1&&Math.abs(K.y)<=1?r:this.unproject(_.add(K),d)},_limitOffset:function(r,d){if(!d)return r;var f=this.getPixelBounds(),_=new Tt(f.min.add(r),f.max.add(r));return r.add(this._getBoundsOffset(_,d))},_getBoundsOffset:function(r,d,f){var _=mt(this.project(d.getNorthEast(),f),this.project(d.getSouthWest(),f)),E=_.min.subtract(r.min),O=_.max.subtract(r.max),K=this._rebound(E.x,-O.x),et=this._rebound(E.y,-O.y);return new ut(K,et)},_rebound:function(r,d){return r+d>0?Math.round(r-d)/2:Math.max(0,Math.ceil(r))-Math.max(0,Math.floor(d))},_limitZoom:function(r){var d=this.getMinZoom(),f=this.getMaxZoom(),_=zt.any3d?this.options.zoomSnap:1;return _&&(r=Math.round(r/_)*_),Math.max(d,Math.min(f,r))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){Re(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(r,d){var f=this._getCenterOffset(r)._trunc();return(d&&d.animate)!==!0&&!this.getSize().contains(f)?!1:(this.panBy(f,d),!0)},_createAnimProxy:function(){var r=this._proxy=pe("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(r),this.on("zoomanim",function(d){var f=Jo,_=this._proxy.style[f];Wn(this._proxy,this.project(d.center,d.zoom),this.getZoomScale(d.zoom,1)),_===this._proxy.style[f]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){Ee(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var r=this.getCenter(),d=this.getZoom();Wn(this._proxy,this.project(r,d),this.getZoomScale(d,1))},_catchTransitionEnd:function(r){this._animatingZoom&&r.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(r,d,f){if(this._animatingZoom)return!0;if(f=f||{},!this._zoomAnimated||f.animate===!1||this._nothingToAnimate()||Math.abs(d-this._zoom)>this.options.zoomAnimationThreshold)return!1;var _=this.getZoomScale(d),E=this._getCenterOffset(r)._divideBy(1-1/_);return f.animate!==!0&&!this.getSize().contains(E)?!1:(gt(function(){this._moveStart(!0,f.noMoveStart||!1)._animateZoom(r,d,!0)},this),!0)},_animateZoom:function(r,d,f,_){this._mapPane&&(f&&(this._animatingZoom=!0,this._animateToCenter=r,this._animateToZoom=d,ne(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:r,zoom:d,noUpdate:_}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(a(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&Re(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function y(r,d){return new g(r,d)}var w=Nt.extend({options:{position:"topright"},initialize:function(r){P(this,r)},getPosition:function(){return this.options.position},setPosition:function(r){var d=this._map;return d&&d.removeControl(this),this.options.position=r,d&&d.addControl(this),this},getContainer:function(){return this._container},addTo:function(r){this.remove(),this._map=r;var d=this._container=this.onAdd(r),f=this.getPosition(),_=r._controlCorners[f];return ne(d,"leaflet-control"),f.indexOf("bottom")!==-1?_.insertBefore(d,_.firstChild):_.appendChild(d),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(Ee(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(r){this._map&&r&&r.screenX>0&&r.screenY>0&&this._map.getContainer().focus()}}),C=function(r){return new w(r)};g.include({addControl:function(r){return r.addTo(this),this},removeControl:function(r){return r.remove(),this},_initControlPos:function(){var r=this._controlCorners={},d="leaflet-",f=this._controlContainer=pe("div",d+"control-container",this._container);function _(E,O){var K=d+E+" "+d+O;r[E+O]=pe("div",K,f)}_("top","left"),_("top","right"),_("bottom","left"),_("bottom","right")},_clearControlPos:function(){for(var r in this._controlCorners)Ee(this._controlCorners[r]);Ee(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var A=w.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(r,d,f,_){return f<_?-1:_<f?1:0}},initialize:function(r,d,f){P(this,f),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(var _ in r)this._addLayer(r[_],_);for(_ in d)this._addLayer(d[_],_,!0)},onAdd:function(r){this._initLayout(),this._update(),this._map=r,r.on("zoomend",this._checkDisabledLayers,this);for(var d=0;d<this._layers.length;d++)this._layers[d].layer.on("add remove",this._onLayerChange,this);return this._container},addTo:function(r){return w.prototype.addTo.call(this,r),this._expandIfNotCollapsed()},onRemove:function(){this._map.off("zoomend",this._checkDisabledLayers,this);for(var r=0;r<this._layers.length;r++)this._layers[r].layer.off("add remove",this._onLayerChange,this)},addBaseLayer:function(r,d){return this._addLayer(r,d),this._map?this._update():this},addOverlay:function(r,d){return this._addLayer(r,d,!0),this._map?this._update():this},removeLayer:function(r){r.off("add remove",this._onLayerChange,this);var d=this._getLayer(c(r));return d&&this._layers.splice(this._layers.indexOf(d),1),this._map?this._update():this},expand:function(){ne(this._container,"leaflet-control-layers-expanded"),this._section.style.height=null;var r=this._map.getSize().y-(this._container.offsetTop+50);return r<this._section.clientHeight?(ne(this._section,"leaflet-control-layers-scrollbar"),this._section.style.height=r+"px"):Re(this._section,"leaflet-control-layers-scrollbar"),this._checkDisabledLayers(),this},collapse:function(){return Re(this._container,"leaflet-control-layers-expanded"),this},_initLayout:function(){var r="leaflet-control-layers",d=this._container=pe("div",r),f=this.options.collapsed;d.setAttribute("aria-haspopup",!0),uo(d),Zs(d);var _=this._section=pe("section",r+"-list");f&&(this._map.on("click",this.collapse,this),Gt(d,{mouseenter:this._expandSafely,mouseleave:this.collapse},this));var E=this._layersLink=pe("a",r+"-toggle",d);E.href="#",E.title="Layers",E.setAttribute("role","button"),Gt(E,{keydown:function(O){O.keyCode===13&&this._expandSafely()},click:function(O){qe(O),this._expandSafely()}},this),f||this.expand(),this._baseLayersList=pe("div",r+"-base",_),this._separator=pe("div",r+"-separator",_),this._overlaysList=pe("div",r+"-overlays",_),d.appendChild(_)},_getLayer:function(r){for(var d=0;d<this._layers.length;d++)if(this._layers[d]&&c(this._layers[d].layer)===r)return this._layers[d]},_addLayer:function(r,d,f){this._map&&r.on("add remove",this._onLayerChange,this),this._layers.push({layer:r,name:d,overlay:f}),this.options.sortLayers&&this._layers.sort(a(function(_,E){return this.options.sortFunction(_.layer,E.layer,_.name,E.name)},this)),this.options.autoZIndex&&r.setZIndex&&(this._lastZIndex++,r.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;No(this._baseLayersList),No(this._overlaysList),this._layerControlInputs=[];var r,d,f,_,E=0;for(f=0;f<this._layers.length;f++)_=this._layers[f],this._addItem(_),d=d||_.overlay,r=r||!_.overlay,E+=_.overlay?0:1;return this.options.hideSingleBase&&(r=r&&E>1,this._baseLayersList.style.display=r?"":"none"),this._separator.style.display=d&&r?"":"none",this},_onLayerChange:function(r){this._handlingClick||this._update();var d=this._getLayer(c(r.target)),f=d.overlay?r.type==="add"?"overlayadd":"overlayremove":r.type==="add"?"baselayerchange":null;f&&this._map.fire(f,d)},_createRadioElement:function(r,d){var f='<input type="radio" class="leaflet-control-layers-selector" name="'+r+'"'+(d?' checked="checked"':"")+"/>",_=document.createElement("div");return _.innerHTML=f,_.firstChild},_addItem:function(r){var d=document.createElement("label"),f=this._map.hasLayer(r.layer),_;r.overlay?(_=document.createElement("input"),_.type="checkbox",_.className="leaflet-control-layers-selector",_.defaultChecked=f):_=this._createRadioElement("leaflet-base-layers_"+c(this),f),this._layerControlInputs.push(_),_.layerId=c(r.layer),Gt(_,"click",this._onInputClick,this);var E=document.createElement("span");E.innerHTML=" "+r.name;var O=document.createElement("span");d.appendChild(O),O.appendChild(_),O.appendChild(E);var K=r.overlay?this._overlaysList:this._baseLayersList;return K.appendChild(d),this._checkDisabledLayers(),d},_onInputClick:function(){if(!this._preventClick){var r=this._layerControlInputs,d,f,_=[],E=[];this._handlingClick=!0;for(var O=r.length-1;O>=0;O--)d=r[O],f=this._getLayer(d.layerId).layer,d.checked?_.push(f):d.checked||E.push(f);for(O=0;O<E.length;O++)this._map.hasLayer(E[O])&&this._map.removeLayer(E[O]);for(O=0;O<_.length;O++)this._map.hasLayer(_[O])||this._map.addLayer(_[O]);this._handlingClick=!1,this._refocusOnMap()}},_checkDisabledLayers:function(){for(var r=this._layerControlInputs,d,f,_=this._map.getZoom(),E=r.length-1;E>=0;E--)d=r[E],f=this._getLayer(d.layerId).layer,d.disabled=f.options.minZoom!==void 0&&_<f.options.minZoom||f.options.maxZoom!==void 0&&_>f.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var r=this._section;this._preventClick=!0,Gt(r,"click",qe),this.expand();var d=this;setTimeout(function(){ke(r,"click",qe),d._preventClick=!1})}}),D=function(r,d,f){return new A(r,d,f)},z=w.extend({options:{position:"topleft",zoomInText:'<span aria-hidden="true">+</span>',zoomInTitle:"Zoom in",zoomOutText:'<span aria-hidden="true">−</span>',zoomOutTitle:"Zoom out"},onAdd:function(r){var d="leaflet-control-zoom",f=pe("div",d+" leaflet-bar"),_=this.options;return this._zoomInButton=this._createButton(_.zoomInText,_.zoomInTitle,d+"-in",f,this._zoomIn),this._zoomOutButton=this._createButton(_.zoomOutText,_.zoomOutTitle,d+"-out",f,this._zoomOut),this._updateDisabled(),r.on("zoomend zoomlevelschange",this._updateDisabled,this),f},onRemove:function(r){r.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(r){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(r.shiftKey?3:1))},_zoomOut:function(r){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(r.shiftKey?3:1))},_createButton:function(r,d,f,_,E){var O=pe("a",f,_);return O.innerHTML=r,O.href="#",O.title=d,O.setAttribute("role","button"),O.setAttribute("aria-label",d),uo(O),Gt(O,"click",wn),Gt(O,"click",E,this),Gt(O,"click",this._refocusOnMap,this),O},_updateDisabled:function(){var r=this._map,d="leaflet-disabled";Re(this._zoomInButton,d),Re(this._zoomOutButton,d),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||r._zoom===r.getMinZoom())&&(ne(this._zoomOutButton,d),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||r._zoom===r.getMaxZoom())&&(ne(this._zoomInButton,d),this._zoomInButton.setAttribute("aria-disabled","true"))}});g.mergeOptions({zoomControl:!0}),g.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new z,this.addControl(this.zoomControl))});var W=function(r){return new z(r)},j=w.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(r){var d="leaflet-control-scale",f=pe("div",d),_=this.options;return this._addScales(_,d+"-line",f),r.on(_.updateWhenIdle?"moveend":"move",this._update,this),r.whenReady(this._update,this),f},onRemove:function(r){r.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(r,d,f){r.metric&&(this._mScale=pe("div",d,f)),r.imperial&&(this._iScale=pe("div",d,f))},_update:function(){var r=this._map,d=r.getSize().y/2,f=r.distance(r.containerPointToLatLng([0,d]),r.containerPointToLatLng([this.options.maxWidth,d]));this._updateScales(f)},_updateScales:function(r){this.options.metric&&r&&this._updateMetric(r),this.options.imperial&&r&&this._updateImperial(r)},_updateMetric:function(r){var d=this._getRoundNum(r),f=d<1e3?d+" m":d/1e3+" km";this._updateScale(this._mScale,f,d/r)},_updateImperial:function(r){var d=r*3.2808399,f,_,E;d>5280?(f=d/5280,_=this._getRoundNum(f),this._updateScale(this._iScale,_+" mi",_/f)):(E=this._getRoundNum(d),this._updateScale(this._iScale,E+" ft",E/d))},_updateScale:function(r,d,f){r.style.width=Math.round(this.options.maxWidth*f)+"px",r.innerHTML=d},_getRoundNum:function(r){var d=Math.pow(10,(Math.floor(r)+"").length-1),f=r/d;return f=f>=10?10:f>=5?5:f>=3?3:f>=2?2:1,d*f}}),U=function(r){return new j(r)},nt='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" class="leaflet-attribution-flag"><path fill="#4C7BE1" d="M0 0h12v4H0z"/><path fill="#FFD500" d="M0 4h12v3H0z"/><path fill="#E0BC00" d="M0 7h12v1H0z"/></svg>',ot=w.extend({options:{position:"bottomright",prefix:'<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">'+(zt.inlineSvg?nt+" ":"")+"Leaflet</a>"},initialize:function(r){P(this,r),this._attributions={}},onAdd:function(r){r.attributionControl=this,this._container=pe("div","leaflet-control-attribution"),uo(this._container);for(var d in r._layers)r._layers[d].getAttribution&&this.addAttribution(r._layers[d].getAttribution());return this._update(),r.on("layeradd",this._addAttribution,this),this._container},onRemove:function(r){r.off("layeradd",this._addAttribution,this)},_addAttribution:function(r){r.layer.getAttribution&&(this.addAttribution(r.layer.getAttribution()),r.layer.once("remove",function(){this.removeAttribution(r.layer.getAttribution())},this))},setPrefix:function(r){return this.options.prefix=r,this._update(),this},addAttribution:function(r){return r?(this._attributions[r]||(this._attributions[r]=0),this._attributions[r]++,this._update(),this):this},removeAttribution:function(r){return r?(this._attributions[r]&&(this._attributions[r]--,this._update()),this):this},_update:function(){if(this._map){var r=[];for(var d in this._attributions)this._attributions[d]&&r.push(d);var f=[];this.options.prefix&&f.push(this.options.prefix),r.length&&f.push(r.join(", ")),this._container.innerHTML=f.join(' <span aria-hidden="true">|</span> ')}}});g.mergeOptions({attributionControl:!0}),g.addInitHook(function(){this.options.attributionControl&&new ot().addTo(this)});var st=function(r){return new ot(r)};w.Layers=A,w.Zoom=z,w.Scale=j,w.Attribution=ot,C.layers=D,C.zoom=W,C.scale=U,C.attribution=st;var Y=Nt.extend({initialize:function(r){this._map=r},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});Y.addTo=function(r,d){return r.addHandler(d,this),this};var yt={Events:re},kt=zt.touch?"touchstart mousedown":"mousedown",Ut=te.extend({options:{clickTolerance:3},initialize:function(r,d,f,_){P(this,_),this._element=r,this._dragStartTarget=d||r,this._preventOutline=f},enable:function(){this._enabled||(Gt(this._dragStartTarget,kt,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(Ut._dragging===this&&this.finishDrag(!0),ke(this._dragStartTarget,kt,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(r){if(this._enabled&&(this._moved=!1,!Hs(this._element,"leaflet-zoom-anim"))){if(r.touches&&r.touches.length!==1){Ut._dragging===this&&this.finishDrag();return}if(!(Ut._dragging||r.shiftKey||r.which!==1&&r.button!==1&&!r.touches)&&(Ut._dragging=this,this._preventOutline&&ts(this._element),bn(),cn(),!this._moving)){this.fire("down");var d=r.touches?r.touches[0]:r,f=Us(this._element);this._startPoint=new ut(d.clientX,d.clientY),this._startPos=Hn(this._element),this._parentScale=ii(f);var _=r.type==="mousedown";Gt(document,_?"mousemove":"touchmove",this._onMove,this),Gt(document,_?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(r){if(this._enabled){if(r.touches&&r.touches.length>1){this._moved=!0;return}var d=r.touches&&r.touches.length===1?r.touches[0]:r,f=new ut(d.clientX,d.clientY)._subtract(this._startPoint);!f.x&&!f.y||Math.abs(f.x)+Math.abs(f.y)<this.options.clickTolerance||(f.x/=this._parentScale.x,f.y/=this._parentScale.y,qe(r),this._moved||(this.fire("dragstart"),this._moved=!0,ne(document.body,"leaflet-dragging"),this._lastTarget=r.target||r.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),ne(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(f),this._moving=!0,this._lastEvent=r,this._updatePosition())}},_updatePosition:function(){var r={originalEvent:this._lastEvent};this.fire("predrag",r),Ie(this._element,this._newPos),this.fire("drag",r)},_onUp:function(){this._enabled&&this.finishDrag()},finishDrag:function(r){Re(document.body,"leaflet-dragging"),this._lastTarget&&(Re(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null),ke(document,"mousemove touchmove",this._onMove,this),ke(document,"mouseup touchend touchcancel",this._onUp,this),Vs(),Vn();var d=this._moved&&this._moving;this._moving=!1,Ut._dragging=!1,d&&this.fire("dragend",{noInertia:r,distance:this._newPos.distanceTo(this._startPos)})}});function Lt(r,d,f){var _,E=[1,4,2,8],O,K,et,at,_t,Rt,Jt,le;for(O=0,Rt=r.length;O<Rt;O++)r[O]._code=jn(r[O],d);for(et=0;et<4;et++){for(Jt=E[et],_=[],O=0,Rt=r.length,K=Rt-1;O<Rt;K=O++)at=r[O],_t=r[K],at._code&Jt?_t._code&Jt||(le=ji(_t,at,Jt,d,f),le._code=jn(le,d),_.push(le)):(_t._code&Jt&&(le=ji(_t,at,Jt,d,f),le._code=jn(le,d),_.push(le)),_.push(at));r=_}return r}function ee(r,d){var f,_,E,O,K,et,at,_t,Rt;if(!r||r.length===0)throw new Error("latlngs not passed");qi(r)||(console.warn("latlngs are not flat! Only the first ring will be used"),r=r[0]);var Jt=b([0,0]),le=Et(r),_i=le.getNorthWest().distanceTo(le.getSouthWest())*le.getNorthEast().distanceTo(le.getNorthWest());_i<1700&&(Jt=oe(r));var ni=r.length,Ki=[];for(f=0;f<ni;f++){var Ai=b(r[f]);Ki.push(d.project(b([Ai.lat-Jt.lat,Ai.lng-Jt.lng])))}for(et=at=_t=0,f=0,_=ni-1;f<ni;_=f++)E=Ki[f],O=Ki[_],K=E.y*O.x-O.y*E.x,at+=(E.x+O.x)*K,_t+=(E.y+O.y)*K,et+=K*3;et===0?Rt=Ki[0]:Rt=[at/et,_t/et];var as=d.unproject(ht(Rt));return b([as.lat+Jt.lat,as.lng+Jt.lng])}function oe(r){for(var d=0,f=0,_=0,E=0;E<r.length;E++){var O=b(r[E]);d+=O.lat,f+=O.lng,_++}return b([d/_,f/_])}var se={__proto__:null,clipPolygon:Lt,polygonCenter:ee,centroid:oe};function $e(r,d){if(!d||!r.length)return r.slice();var f=d*d;return r=Ii(r,f),r=Xt(r,f),r}function Ae(r,d,f){return Math.sqrt(Xs(r,d,f,!0))}function he(r,d,f){return Xs(r,d,f)}function Xt(r,d){var f=r.length,_=typeof Uint8Array<"u"?Uint8Array:Array,E=new _(f);E[0]=E[f-1]=1,we(r,E,d,0,f-1);var O,K=[];for(O=0;O<f;O++)E[O]&&K.push(r[O]);return K}function we(r,d,f,_,E){var O=0,K,et,at;for(et=_+1;et<=E-1;et++)at=Xs(r[et],r[_],r[E],!0),at>O&&(K=et,O=at);O>f&&(d[K]=1,we(r,d,f,_,K),we(r,d,f,K,E))}function Ii(r,d){for(var f=[r[0]],_=1,E=0,O=r.length;_<O;_++)Qs(r[_],r[E])>d&&(f.push(r[_]),E=_);return E<O-1&&f.push(r[O-1]),f}var Ke;function wi(r,d,f,_,E){var O=_?Ke:jn(r,f),K=jn(d,f),et,at,_t;for(Ke=K;;){if(!(O|K))return[r,d];if(O&K)return!1;et=O||K,at=ji(r,d,et,f,E),_t=jn(at,f),et===O?(r=at,O=_t):(d=at,K=_t)}}function ji(r,d,f,_,E){var O=d.x-r.x,K=d.y-r.y,et=_.min,at=_.max,_t,Rt;return f&8?(_t=r.x+O*(at.y-r.y)/K,Rt=at.y):f&4?(_t=r.x+O*(et.y-r.y)/K,Rt=et.y):f&2?(_t=at.x,Rt=r.y+K*(at.x-r.x)/O):f&1&&(_t=et.x,Rt=r.y+K*(et.x-r.x)/O),new ut(_t,Rt,E)}function jn(r,d){var f=0;return r.x<d.min.x?f|=1:r.x>d.max.x&&(f|=2),r.y<d.min.y?f|=4:r.y>d.max.y&&(f|=8),f}function Qs(r,d){var f=d.x-r.x,_=d.y-r.y;return f*f+_*_}function Xs(r,d,f,_){var E=d.x,O=d.y,K=f.x-E,et=f.y-O,at=K*K+et*et,_t;return at>0&&(_t=((r.x-E)*K+(r.y-O)*et)/at,_t>1?(E=f.x,O=f.y):_t>0&&(E+=K*_t,O+=et*_t)),K=r.x-E,et=r.y-O,_?K*K+et*et:new ut(E,O)}function qi(r){return!H(r[0])||typeof r[0][0]!="object"&&typeof r[0][0]<"u"}function Wh(r){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),qi(r)}function Hh(r,d){var f,_,E,O,K,et,at,_t;if(!r||r.length===0)throw new Error("latlngs not passed");qi(r)||(console.warn("latlngs are not flat! Only the first ring will be used"),r=r[0]);var Rt=b([0,0]),Jt=Et(r),le=Jt.getNorthWest().distanceTo(Jt.getSouthWest())*Jt.getNorthEast().distanceTo(Jt.getNorthWest());le<1700&&(Rt=oe(r));var _i=r.length,ni=[];for(f=0;f<_i;f++){var Ki=b(r[f]);ni.push(d.project(b([Ki.lat-Rt.lat,Ki.lng-Rt.lng])))}for(f=0,_=0;f<_i-1;f++)_+=ni[f].distanceTo(ni[f+1])/2;if(_===0)_t=ni[0];else for(f=0,O=0;f<_i-1;f++)if(K=ni[f],et=ni[f+1],E=K.distanceTo(et),O+=E,O>_){at=(O-_)/E,_t=[et.x-at*(et.x-K.x),et.y-at*(et.y-K.y)];break}var Ai=d.unproject(ht(_t));return b([Ai.lat+Rt.lat,Ai.lng+Rt.lng])}var ky={__proto__:null,simplify:$e,pointToSegmentDistance:Ae,closestPointOnSegment:he,clipSegment:wi,_getEdgeIntersection:ji,_getBitCode:jn,_sqClosestPointOnSegment:Xs,isFlat:qi,_flat:Wh,polylineCenter:Hh},cc={project:function(r){return new ut(r.lng,r.lat)},unproject:function(r){return new dt(r.y,r.x)},bounds:new Tt([-180,-90],[180,90])},dc={R:6378137,R_MINOR:6356752314245179e-9,bounds:new Tt([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(r){var d=Math.PI/180,f=this.R,_=r.lat*d,E=this.R_MINOR/f,O=Math.sqrt(1-E*E),K=O*Math.sin(_),et=Math.tan(Math.PI/4-_/2)/Math.pow((1-K)/(1+K),O/2);return _=-f*Math.log(Math.max(et,1e-10)),new ut(r.lng*d*f,_)},unproject:function(r){for(var d=180/Math.PI,f=this.R,_=this.R_MINOR/f,E=Math.sqrt(1-_*_),O=Math.exp(-r.y/f),K=Math.PI/2-2*Math.atan(O),et=0,at=.1,_t;et<15&&Math.abs(at)>1e-7;et++)_t=E*Math.sin(K),_t=Math.pow((1-_t)/(1+_t),E/2),at=Math.PI/2-2*Math.atan(O*_t)-K,K+=at;return new dt(K*d,r.x*d/f)}},Cy={__proto__:null,LonLat:cc,Mercator:dc,SphericalMercator:N},$y=n({},S,{code:"EPSG:3395",projection:dc,transformation:function(){var r=.5/(Math.PI*dc.R);return V(r,.5,-r,.5)}()}),Vh=n({},S,{code:"EPSG:4326",projection:cc,transformation:V(1/180,1,-1/180,.5)}),Sy=n({},k,{projection:cc,transformation:V(1,0,-1,0),scale:function(r){return Math.pow(2,r)},zoom:function(r){return Math.log(r)/Math.LN2},distance:function(r,d){var f=d.lng-r.lng,_=d.lat-r.lat;return Math.sqrt(f*f+_*_)},infinite:!0});k.Earth=S,k.EPSG3395=$y,k.EPSG3857=G,k.EPSG900913=J,k.EPSG4326=Vh,k.Simple=Sy;var dn=te.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(r){return r.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(r){return r&&r.removeLayer(this),this},getPane:function(r){return this._map.getPane(r?this.options[r]||r:this.options.pane)},addInteractiveTarget:function(r){return this._map._targets[c(r)]=this,this},removeInteractiveTarget:function(r){return delete this._map._targets[c(r)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(r){var d=r.target;if(d.hasLayer(this)){if(this._map=d,this._zoomAnimated=d._zoomAnimated,this.getEvents){var f=this.getEvents();d.on(f,this),this.once("remove",function(){d.off(f,this)},this)}this.onAdd(d),this.fire("add"),d.fire("layeradd",{layer:this})}}});g.include({addLayer:function(r){if(!r._layerAdd)throw new Error("The provided object is not a Layer.");var d=c(r);return this._layers[d]?this:(this._layers[d]=r,r._mapToAdd=this,r.beforeAdd&&r.beforeAdd(this),this.whenReady(r._layerAdd,r),this)},removeLayer:function(r){var d=c(r);return this._layers[d]?(this._loaded&&r.onRemove(this),delete this._layers[d],this._loaded&&(this.fire("layerremove",{layer:r}),r.fire("remove")),r._map=r._mapToAdd=null,this):this},hasLayer:function(r){return c(r)in this._layers},eachLayer:function(r,d){for(var f in this._layers)r.call(d,this._layers[f]);return this},_addLayers:function(r){r=r?H(r)?r:[r]:[];for(var d=0,f=r.length;d<f;d++)this.addLayer(r[d])},_addZoomLimit:function(r){(!isNaN(r.options.maxZoom)||!isNaN(r.options.minZoom))&&(this._zoomBoundLayers[c(r)]=r,this._updateZoomLevels())},_removeZoomLimit:function(r){var d=c(r);this._zoomBoundLayers[d]&&(delete this._zoomBoundLayers[d],this._updateZoomLevels())},_updateZoomLevels:function(){var r=1/0,d=-1/0,f=this._getZoomSpan();for(var _ in this._zoomBoundLayers){var E=this._zoomBoundLayers[_].options;r=E.minZoom===void 0?r:Math.min(r,E.minZoom),d=E.maxZoom===void 0?d:Math.max(d,E.maxZoom)}this._layersMaxZoom=d===-1/0?void 0:d,this._layersMinZoom=r===1/0?void 0:r,f!==this._getZoomSpan()&&this.fire("zoomlevelschange"),this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var is=dn.extend({initialize:function(r,d){P(this,d),this._layers={};var f,_;if(r)for(f=0,_=r.length;f<_;f++)this.addLayer(r[f])},addLayer:function(r){var d=this.getLayerId(r);return this._layers[d]=r,this._map&&this._map.addLayer(r),this},removeLayer:function(r){var d=r in this._layers?r:this.getLayerId(r);return this._map&&this._layers[d]&&this._map.removeLayer(this._layers[d]),delete this._layers[d],this},hasLayer:function(r){var d=typeof r=="number"?r:this.getLayerId(r);return d in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(r){var d=Array.prototype.slice.call(arguments,1),f,_;for(f in this._layers)_=this._layers[f],_[r]&&_[r].apply(_,d);return this},onAdd:function(r){this.eachLayer(r.addLayer,r)},onRemove:function(r){this.eachLayer(r.removeLayer,r)},eachLayer:function(r,d){for(var f in this._layers)r.call(d,this._layers[f]);return this},getLayer:function(r){return this._layers[r]},getLayers:function(){var r=[];return this.eachLayer(r.push,r),r},setZIndex:function(r){return this.invoke("setZIndex",r)},getLayerId:function(r){return c(r)}}),Ty=function(r,d){return new is(r,d)},qn=is.extend({addLayer:function(r){return this.hasLayer(r)?this:(r.addEventParent(this),is.prototype.addLayer.call(this,r),this.fire("layeradd",{layer:r}))},removeLayer:function(r){return this.hasLayer(r)?(r in this._layers&&(r=this._layers[r]),r.removeEventParent(this),is.prototype.removeLayer.call(this,r),this.fire("layerremove",{layer:r})):this},setStyle:function(r){return this.invoke("setStyle",r)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var r=new At;for(var d in this._layers){var f=this._layers[d];r.extend(f.getBounds?f.getBounds():f.getLatLng())}return r}}),Ey=function(r,d){return new qn(r,d)},ns=Nt.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1},initialize:function(r){P(this,r)},createIcon:function(r){return this._createIcon("icon",r)},createShadow:function(r){return this._createIcon("shadow",r)},_createIcon:function(r,d){var f=this._getIconUrl(r);if(!f){if(r==="icon")throw new Error("iconUrl not set in Icon options (see the docs).");return null}var _=this._createImg(f,d&&d.tagName==="IMG"?d:null);return this._setIconStyles(_,r),(this.options.crossOrigin||this.options.crossOrigin==="")&&(_.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),_},_setIconStyles:function(r,d){var f=this.options,_=f[d+"Size"];typeof _=="number"&&(_=[_,_]);var E=ht(_),O=ht(d==="shadow"&&f.shadowAnchor||f.iconAnchor||E&&E.divideBy(2,!0));r.className="leaflet-marker-"+d+" "+(f.className||""),O&&(r.style.marginLeft=-O.x+"px",r.style.marginTop=-O.y+"px"),E&&(r.style.width=E.x+"px",r.style.height=E.y+"px")},_createImg:function(r,d){return d=d||document.createElement("img"),d.src=r,d},_getIconUrl:function(r){return zt.retina&&this.options[r+"RetinaUrl"]||this.options[r+"Url"]}});function Iy(r){return new ns(r)}var tr=ns.extend({options:{iconUrl:"marker-icon.png",iconRetinaUrl:"marker-icon-2x.png",shadowUrl:"marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(r){return typeof tr.imagePath!="string"&&(tr.imagePath=this._detectIconPath()),(this.options.imagePath||tr.imagePath)+ns.prototype._getIconUrl.call(this,r)},_stripUrl:function(r){var d=function(f,_,E){var O=_.exec(f);return O&&O[E]};return r=d(r,/^url\((['"])?(.+)\1\)$/,2),r&&d(r,/^(.*)marker-icon\.png$/,1)},_detectIconPath:function(){var r=pe("div","leaflet-default-icon-path",document.body),d=Lo(r,"background-image")||Lo(r,"backgroundImage");if(document.body.removeChild(r),d=this._stripUrl(d),d)return d;var f=document.querySelector('link[href$="leaflet.css"]');return f?f.href.substring(0,f.href.length-11-1):""}}),Uh=Y.extend({initialize:function(r){this._marker=r},addHooks:function(){var r=this._marker._icon;this._draggable||(this._draggable=new Ut(r,r,!0)),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),ne(r,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&Re(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(r){var d=this._marker,f=d._map,_=this._marker.options.autoPanSpeed,E=this._marker.options.autoPanPadding,O=Hn(d._icon),K=f.getPixelBounds(),et=f.getPixelOrigin(),at=mt(K.min._subtract(et).add(E),K.max._subtract(et).subtract(E));if(!at.contains(O)){var _t=ht((Math.max(at.max.x,O.x)-at.max.x)/(K.max.x-at.max.x)-(Math.min(at.min.x,O.x)-at.min.x)/(K.min.x-at.min.x),(Math.max(at.max.y,O.y)-at.max.y)/(K.max.y-at.max.y)-(Math.min(at.min.y,O.y)-at.min.y)/(K.min.y-at.min.y)).multiplyBy(_);f.panBy(_t,{animate:!1}),this._draggable._newPos._add(_t),this._draggable._startPos._add(_t),Ie(d._icon,this._draggable._newPos),this._onDrag(r),this._panRequest=gt(this._adjustPan.bind(this,r))}},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire("movestart").fire("dragstart")},_onPreDrag:function(r){this._marker.options.autoPan&&(Ct(this._panRequest),this._panRequest=gt(this._adjustPan.bind(this,r)))},_onDrag:function(r){var d=this._marker,f=d._shadow,_=Hn(d._icon),E=d._map.layerPointToLatLng(_);f&&Ie(f,_),d._latlng=E,r.latlng=E,r.oldLatLng=this._oldLatLng,d.fire("move",r).fire("drag",r)},_onDragEnd:function(r){Ct(this._panRequest),delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",r)}}),oa=dn.extend({options:{icon:new tr,interactive:!0,keyboard:!0,title:"",alt:"Marker",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",shadowPane:"shadowPane",bubblingMouseEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10},initialize:function(r,d){P(this,d),this._latlng=b(r)},onAdd:function(r){this._zoomAnimated=this._zoomAnimated&&r.options.markerZoomAnimation,this._zoomAnimated&&r.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(r){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&r.off("zoomanim",this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(r){var d=this._latlng;return this._latlng=b(r),this.update(),this.fire("move",{oldLatLng:d,latlng:this._latlng})},setZIndexOffset:function(r){return this.options.zIndexOffset=r,this.update()},getIcon:function(){return this.options.icon},setIcon:function(r){return this.options.icon=r,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){if(this._icon&&this._map){var r=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(r)}return this},_initIcon:function(){var r=this.options,d="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),f=r.icon.createIcon(this._icon),_=!1;f!==this._icon&&(this._icon&&this._removeIcon(),_=!0,r.title&&(f.title=r.title),f.tagName==="IMG"&&(f.alt=r.alt||"")),ne(f,d),r.keyboard&&(f.tabIndex="0",f.setAttribute("role","button")),this._icon=f,r.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&Gt(f,"focus",this._panOnFocus,this);var E=r.icon.createShadow(this._shadow),O=!1;E!==this._shadow&&(this._removeShadow(),O=!0),E&&(ne(E,d),E.alt=""),this._shadow=E,r.opacity<1&&this._updateOpacity(),_&&this.getPane().appendChild(this._icon),this._initInteraction(),E&&O&&this.getPane(r.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&ke(this._icon,"focus",this._panOnFocus,this),Ee(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&Ee(this._shadow),this._shadow=null},_setPos:function(r){this._icon&&Ie(this._icon,r),this._shadow&&Ie(this._shadow,r),this._zIndex=r.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(r){this._icon&&(this._icon.style.zIndex=this._zIndex+r)},_animateZoom:function(r){var d=this._map._latLngToNewLayerPoint(this._latlng,r.zoom,r.center).round();this._setPos(d)},_initInteraction:function(){if(this.options.interactive&&(ne(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),Uh)){var r=this.options.draggable;this.dragging&&(r=this.dragging.enabled(),this.dragging.disable()),this.dragging=new Uh(this),r&&this.dragging.enable()}},setOpacity:function(r){return this.options.opacity=r,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var r=this.options.opacity;this._icon&&ie(this._icon,r),this._shadow&&ie(this._shadow,r)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_panOnFocus:function(){var r=this._map;if(r){var d=this.options.icon.options,f=d.iconSize?ht(d.iconSize):ht(0,0),_=d.iconAnchor?ht(d.iconAnchor):ht(0,0);r.panInside(this._latlng,{paddingTopLeft:_,paddingBottomRight:f.subtract(_)})}},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});function Ay(r,d){return new oa(r,d)}var po=dn.extend({options:{stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:"evenodd",interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(r){this._renderer=r.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(r){return P(this,r),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&r&&Object.prototype.hasOwnProperty.call(r,"weight")&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}}),sa=po.extend({options:{fill:!0,radius:10},initialize:function(r,d){P(this,d),this._latlng=b(r),this._radius=this.options.radius},setLatLng:function(r){var d=this._latlng;return this._latlng=b(r),this.redraw(),this.fire("move",{oldLatLng:d,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(r){return this.options.radius=this._radius=r,this.redraw()},getRadius:function(){return this._radius},setStyle:function(r){var d=r&&r.radius||this._radius;return po.prototype.setStyle.call(this,r),this.setRadius(d),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var r=this._radius,d=this._radiusY||r,f=this._clickTolerance(),_=[r+f,d+f];this._pxBounds=new Tt(this._point.subtract(_),this._point.add(_))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(r){return r.distanceTo(this._point)<=this._radius+this._clickTolerance()}});function Ly(r,d){return new sa(r,d)}var hc=sa.extend({initialize:function(r,d,f){if(typeof d=="number"&&(d=n({},f,{radius:d})),P(this,d),this._latlng=b(r),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(r){return this._mRadius=r,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var r=[this._radius,this._radiusY||this._radius];return new At(this._map.layerPointToLatLng(this._point.subtract(r)),this._map.layerPointToLatLng(this._point.add(r)))},setStyle:po.prototype.setStyle,_project:function(){var r=this._latlng.lng,d=this._latlng.lat,f=this._map,_=f.options.crs;if(_.distance===S.distance){var E=Math.PI/180,O=this._mRadius/S.R/E,K=f.project([d+O,r]),et=f.project([d-O,r]),at=K.add(et).divideBy(2),_t=f.unproject(at).lat,Rt=Math.acos((Math.cos(O*E)-Math.sin(d*E)*Math.sin(_t*E))/(Math.cos(d*E)*Math.cos(_t*E)))/E;(isNaN(Rt)||Rt===0)&&(Rt=O/Math.cos(Math.PI/180*d)),this._point=at.subtract(f.getPixelOrigin()),this._radius=isNaN(Rt)?0:at.x-f.project([_t,r-Rt]).x,this._radiusY=at.y-K.y}else{var Jt=_.unproject(_.project(this._latlng).subtract([this._mRadius,0]));this._point=f.latLngToLayerPoint(this._latlng),this._radius=this._point.x-f.latLngToLayerPoint(Jt).x}this._updateBounds()}});function Ny(r,d,f){return new hc(r,d,f)}var Kn=po.extend({options:{smoothFactor:1,noClip:!1},initialize:function(r,d){P(this,d),this._setLatLngs(r)},getLatLngs:function(){return this._latlngs},setLatLngs:function(r){return this._setLatLngs(r),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(r){for(var d=1/0,f=null,_=Xs,E,O,K=0,et=this._parts.length;K<et;K++)for(var at=this._parts[K],_t=1,Rt=at.length;_t<Rt;_t++){E=at[_t-1],O=at[_t];var Jt=_(r,E,O,!0);Jt<d&&(d=Jt,f=_(r,E,O))}return f&&(f.distance=Math.sqrt(d)),f},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return Hh(this._defaultShape(),this._map.options.crs)},getBounds:function(){return this._bounds},addLatLng:function(r,d){return d=d||this._defaultShape(),r=b(r),d.push(r),this._bounds.extend(r),this.redraw()},_setLatLngs:function(r){this._bounds=new At,this._latlngs=this._convertLatLngs(r)},_defaultShape:function(){return qi(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(r){for(var d=[],f=qi(r),_=0,E=r.length;_<E;_++)f?(d[_]=b(r[_]),this._bounds.extend(d[_])):d[_]=this._convertLatLngs(r[_]);return d},_project:function(){var r=new Tt;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,r),this._bounds.isValid()&&r.isValid()&&(this._rawPxBounds=r,this._updateBounds())},_updateBounds:function(){var r=this._clickTolerance(),d=new ut(r,r);this._rawPxBounds&&(this._pxBounds=new Tt([this._rawPxBounds.min.subtract(d),this._rawPxBounds.max.add(d)]))},_projectLatlngs:function(r,d,f){var _=r[0]instanceof dt,E=r.length,O,K;if(_){for(K=[],O=0;O<E;O++)K[O]=this._map.latLngToLayerPoint(r[O]),f.extend(K[O]);d.push(K)}else for(O=0;O<E;O++)this._projectLatlngs(r[O],d,f)},_clipPoints:function(){var r=this._renderer._bounds;if(this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(r))){if(this.options.noClip){this._parts=this._rings;return}var d=this._parts,f,_,E,O,K,et,at;for(f=0,E=0,O=this._rings.length;f<O;f++)for(at=this._rings[f],_=0,K=at.length;_<K-1;_++)et=wi(at[_],at[_+1],r,_,!0),et&&(d[E]=d[E]||[],d[E].push(et[0]),(et[1]!==at[_+1]||_===K-2)&&(d[E].push(et[1]),E++))}},_simplifyPoints:function(){for(var r=this._parts,d=this.options.smoothFactor,f=0,_=r.length;f<_;f++)r[f]=$e(r[f],d)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(r,d){var f,_,E,O,K,et,at=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(r))return!1;for(f=0,O=this._parts.length;f<O;f++)for(et=this._parts[f],_=0,K=et.length,E=K-1;_<K;E=_++)if(!(!d&&_===0)&&Ae(r,et[E],et[_])<=at)return!0;return!1}});function My(r,d){return new Kn(r,d)}Kn._flat=Wh;var os=Kn.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return ee(this._defaultShape(),this._map.options.crs)},_convertLatLngs:function(r){var d=Kn.prototype._convertLatLngs.call(this,r),f=d.length;return f>=2&&d[0]instanceof dt&&d[0].equals(d[f-1])&&d.pop(),d},_setLatLngs:function(r){Kn.prototype._setLatLngs.call(this,r),qi(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return qi(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var r=this._renderer._bounds,d=this.options.weight,f=new ut(d,d);if(r=new Tt(r.min.subtract(f),r.max.add(f)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(r))){if(this.options.noClip){this._parts=this._rings;return}for(var _=0,E=this._rings.length,O;_<E;_++)O=Lt(this._rings[_],r,!0),O.length&&this._parts.push(O)}},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(r){var d=!1,f,_,E,O,K,et,at,_t;if(!this._pxBounds||!this._pxBounds.contains(r))return!1;for(O=0,at=this._parts.length;O<at;O++)for(f=this._parts[O],K=0,_t=f.length,et=_t-1;K<_t;et=K++)_=f[K],E=f[et],_.y>r.y!=E.y>r.y&&r.x<(E.x-_.x)*(r.y-_.y)/(E.y-_.y)+_.x&&(d=!d);return d||Kn.prototype._containsPoint.call(this,r,!0)}});function Py(r,d){return new os(r,d)}var Zn=qn.extend({initialize:function(r,d){P(this,d),this._layers={},r&&this.addData(r)},addData:function(r){var d=H(r)?r:r.features,f,_,E;if(d){for(f=0,_=d.length;f<_;f++)E=d[f],(E.geometries||E.geometry||E.features||E.coordinates)&&this.addData(E);return this}var O=this.options;if(O.filter&&!O.filter(r))return this;var K=ra(r,O);return K?(K.feature=ca(r),K.defaultOptions=K.options,this.resetStyle(K),O.onEachFeature&&O.onEachFeature(r,K),this.addLayer(K)):this},resetStyle:function(r){return r===void 0?this.eachLayer(this.resetStyle,this):(r.options=n({},r.defaultOptions),this._setLayerStyle(r,this.options.style),this)},setStyle:function(r){return this.eachLayer(function(d){this._setLayerStyle(d,r)},this)},_setLayerStyle:function(r,d){r.setStyle&&(typeof d=="function"&&(d=d(r.feature)),r.setStyle(d))}});function ra(r,d){var f=r.type==="Feature"?r.geometry:r,_=f?f.coordinates:null,E=[],O=d&&d.pointToLayer,K=d&&d.coordsToLatLng||uc,et,at,_t,Rt;if(!_&&!f)return null;switch(f.type){case"Point":return et=K(_),jh(O,r,et,d);case"MultiPoint":for(_t=0,Rt=_.length;_t<Rt;_t++)et=K(_[_t]),E.push(jh(O,r,et,d));return new qn(E);case"LineString":case"MultiLineString":return at=aa(_,f.type==="LineString"?0:1,K),new Kn(at,d);case"Polygon":case"MultiPolygon":return at=aa(_,f.type==="Polygon"?1:2,K),new os(at,d);case"GeometryCollection":for(_t=0,Rt=f.geometries.length;_t<Rt;_t++){var Jt=ra({geometry:f.geometries[_t],type:"Feature",properties:r.properties},d);Jt&&E.push(Jt)}return new qn(E);case"FeatureCollection":for(_t=0,Rt=f.features.length;_t<Rt;_t++){var le=ra(f.features[_t],d);le&&E.push(le)}return new qn(E);default:throw new Error("Invalid GeoJSON object.")}}function jh(r,d,f,_){return r?r(d,f):new oa(f,_&&_.markersInheritOptions&&_)}function uc(r){return new dt(r[1],r[0],r[2])}function aa(r,d,f){for(var _=[],E=0,O=r.length,K;E<O;E++)K=d?aa(r[E],d-1,f):(f||uc)(r[E]),_.push(K);return _}function pc(r,d){return r=b(r),r.alt!==void 0?[x(r.lng,d),x(r.lat,d),x(r.alt,d)]:[x(r.lng,d),x(r.lat,d)]}function la(r,d,f,_){for(var E=[],O=0,K=r.length;O<K;O++)E.push(d?la(r[O],qi(r[O])?0:d-1,f,_):pc(r[O],_));return!d&&f&&E.length>0&&E.push(E[0].slice()),E}function ss(r,d){return r.feature?n({},r.feature,{geometry:d}):ca(d)}function ca(r){return r.type==="Feature"||r.type==="FeatureCollection"?r:{type:"Feature",properties:{},geometry:r}}var fc={toGeoJSON:function(r){return ss(this,{type:"Point",coordinates:pc(this.getLatLng(),r)})}};oa.include(fc),hc.include(fc),sa.include(fc),Kn.include({toGeoJSON:function(r){var d=!qi(this._latlngs),f=la(this._latlngs,d?1:0,!1,r);return ss(this,{type:(d?"Multi":"")+"LineString",coordinates:f})}}),os.include({toGeoJSON:function(r){var d=!qi(this._latlngs),f=d&&!qi(this._latlngs[0]),_=la(this._latlngs,f?2:d?1:0,!0,r);return d||(_=[_]),ss(this,{type:(f?"Multi":"")+"Polygon",coordinates:_})}}),is.include({toMultiPoint:function(r){var d=[];return this.eachLayer(function(f){d.push(f.toGeoJSON(r).geometry.coordinates)}),ss(this,{type:"MultiPoint",coordinates:d})},toGeoJSON:function(r){var d=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(d==="MultiPoint")return this.toMultiPoint(r);var f=d==="GeometryCollection",_=[];return this.eachLayer(function(E){if(E.toGeoJSON){var O=E.toGeoJSON(r);if(f)_.push(O.geometry);else{var K=ca(O);K.type==="FeatureCollection"?_.push.apply(_,K.features):_.push(K)}}}),f?ss(this,{geometries:_,type:"GeometryCollection"}):{type:"FeatureCollection",features:_}}});function qh(r,d){return new Zn(r,d)}var Oy=qh,da=dn.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(r,d,f){this._url=r,this._bounds=Et(d),P(this,f)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(ne(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){Ee(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(r){return this.options.opacity=r,this._image&&this._updateOpacity(),this},setStyle:function(r){return r.opacity&&this.setOpacity(r.opacity),this},bringToFront:function(){return this._map&&lo(this._image),this},bringToBack:function(){return this._map&&zn(this._image),this},setUrl:function(r){return this._url=r,this._image&&(this._image.src=r),this},setBounds:function(r){return this._bounds=Et(r),this._map&&this._reset(),this},getEvents:function(){var r={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(r.zoomanim=this._animateZoom),r},setZIndex:function(r){return this.options.zIndex=r,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var r=this._url.tagName==="IMG",d=this._image=r?this._url:pe("img");if(ne(d,"leaflet-image-layer"),this._zoomAnimated&&ne(d,"leaflet-zoom-animated"),this.options.className&&ne(d,this.options.className),d.onselectstart=v,d.onmousemove=v,d.onload=a(this.fire,this,"load"),d.onerror=a(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(d.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),r){this._url=d.src;return}d.src=this._url,d.alt=this.options.alt},_animateZoom:function(r){var d=this._map.getZoomScale(r.zoom),f=this._map._latLngBoundsToNewLayerBounds(this._bounds,r.zoom,r.center).min;Wn(this._image,f,d)},_reset:function(){var r=this._image,d=new Tt(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),f=d.getSize();Ie(r,d.min),r.style.width=f.x+"px",r.style.height=f.y+"px"},_updateOpacity:function(){ie(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var r=this.options.errorOverlayUrl;r&&this._url!==r&&(this._url=r,this._image.src=r)},getCenter:function(){return this._bounds.getCenter()}}),Dy=function(r,d,f){return new da(r,d,f)},Kh=da.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var r=this._url.tagName==="VIDEO",d=this._image=r?this._url:pe("video");if(ne(d,"leaflet-image-layer"),this._zoomAnimated&&ne(d,"leaflet-zoom-animated"),this.options.className&&ne(d,this.options.className),d.onselectstart=v,d.onmousemove=v,d.onloadeddata=a(this.fire,this,"load"),r){for(var f=d.getElementsByTagName("source"),_=[],E=0;E<f.length;E++)_.push(f[E].src);this._url=f.length>0?_:[d.src];return}H(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(d.style,"objectFit")&&(d.style.objectFit="fill"),d.autoplay=!!this.options.autoplay,d.loop=!!this.options.loop,d.muted=!!this.options.muted,d.playsInline=!!this.options.playsInline;for(var O=0;O<this._url.length;O++){var K=pe("source");K.src=this._url[O],d.appendChild(K)}}});function Ry(r,d,f){return new Kh(r,d,f)}var Zh=da.extend({_initImage:function(){var r=this._image=this._url;ne(r,"leaflet-image-layer"),this._zoomAnimated&&ne(r,"leaflet-zoom-animated"),this.options.className&&ne(r,this.options.className),r.onselectstart=v,r.onmousemove=v}});function By(r,d,f){return new Zh(r,d,f)}var _n=dn.extend({options:{interactive:!1,offset:[0,0],className:"",pane:void 0,content:""},initialize:function(r,d){r&&(r instanceof dt||H(r))?(this._latlng=b(r),P(this,d)):(P(this,r),this._source=d),this.options.content&&(this._content=this.options.content)},openOn:function(r){return r=arguments.length?r:this._source._map,r.hasLayer(this)||r.addLayer(this),this},close:function(){return this._map&&this._map.removeLayer(this),this},toggle:function(r){return this._map?this.close():(arguments.length?this._source=r:r=this._source,this._prepareOpen(),this.openOn(r._map)),this},onAdd:function(r){this._zoomAnimated=r._zoomAnimated,this._container||this._initLayout(),r._fadeAnimated&&ie(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),r._fadeAnimated&&ie(this._container,1),this.bringToFront(),this.options.interactive&&(ne(this._container,"leaflet-interactive"),this.addInteractiveTarget(this._container))},onRemove:function(r){r._fadeAnimated?(ie(this._container,0),this._removeTimeout=setTimeout(a(Ee,void 0,this._container),200)):Ee(this._container),this.options.interactive&&(Re(this._container,"leaflet-interactive"),this.removeInteractiveTarget(this._container))},getLatLng:function(){return this._latlng},setLatLng:function(r){return this._latlng=b(r),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(r){return this._content=r,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan())},getEvents:function(){var r={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(r.zoomanim=this._animateZoom),r},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&lo(this._container),this},bringToBack:function(){return this._map&&zn(this._container),this},_prepareOpen:function(r){var d=this._source;if(!d._map)return!1;if(d instanceof qn){d=null;var f=this._source._layers;for(var _ in f)if(f[_]._map){d=f[_];break}if(!d)return!1;this._source=d}if(!r)if(d.getCenter)r=d.getCenter();else if(d.getLatLng)r=d.getLatLng();else if(d.getBounds)r=d.getBounds().getCenter();else throw new Error("Unable to get source layer LatLng.");return this.setLatLng(r),this._map&&this.update(),!0},_updateContent:function(){if(this._content){var r=this._contentNode,d=typeof this._content=="function"?this._content(this._source||this):this._content;if(typeof d=="string")r.innerHTML=d;else{for(;r.hasChildNodes();)r.removeChild(r.firstChild);r.appendChild(d)}this.fire("contentupdate")}},_updatePosition:function(){if(this._map){var r=this._map.latLngToLayerPoint(this._latlng),d=ht(this.options.offset),f=this._getAnchor();this._zoomAnimated?Ie(this._container,r.add(f)):d=d.add(r).add(f);var _=this._containerBottom=-d.y,E=this._containerLeft=-Math.round(this._containerWidth/2)+d.x;this._container.style.bottom=_+"px",this._container.style.left=E+"px"}},_getAnchor:function(){return[0,0]}});g.include({_initOverlay:function(r,d,f,_){var E=d;return E instanceof r||(E=new r(_).setContent(d)),f&&E.setLatLng(f),E}}),dn.include({_initOverlay:function(r,d,f,_){var E=f;return E instanceof r?(P(E,_),E._source=this):(E=d&&!_?d:new r(_,this),E.setContent(f)),E}});var ha=_n.extend({options:{pane:"popupPane",offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:""},openOn:function(r){return r=arguments.length?r:this._source._map,!r.hasLayer(this)&&r._popup&&r._popup.options.autoClose&&r.removeLayer(r._popup),r._popup=this,_n.prototype.openOn.call(this,r)},onAdd:function(r){_n.prototype.onAdd.call(this,r),r.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof po||this._source.on("preclick",Un))},onRemove:function(r){_n.prototype.onRemove.call(this,r),r.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof po||this._source.off("preclick",Un))},getEvents:function(){var r=_n.prototype.getEvents.call(this);return(this.options.closeOnClick!==void 0?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(r.preclick=this.close),this.options.keepInView&&(r.moveend=this._adjustPan),r},_initLayout:function(){var r="leaflet-popup",d=this._container=pe("div",r+" "+(this.options.className||"")+" leaflet-zoom-animated"),f=this._wrapper=pe("div",r+"-content-wrapper",d);if(this._contentNode=pe("div",r+"-content",f),uo(d),Zs(this._contentNode),Gt(d,"contextmenu",Un),this._tipContainer=pe("div",r+"-tip-container",d),this._tip=pe("div",r+"-tip",this._tipContainer),this.options.closeButton){var _=this._closeButton=pe("a",r+"-close-button",d);_.setAttribute("role","button"),_.setAttribute("aria-label","Close popup"),_.href="#close",_.innerHTML='<span aria-hidden="true">×</span>',Gt(_,"click",function(E){qe(E),this.close()},this)}},_updateLayout:function(){var r=this._contentNode,d=r.style;d.width="",d.whiteSpace="nowrap";var f=r.offsetWidth;f=Math.min(f,this.options.maxWidth),f=Math.max(f,this.options.minWidth),d.width=f+1+"px",d.whiteSpace="",d.height="";var _=r.offsetHeight,E=this.options.maxHeight,O="leaflet-popup-scrolled";E&&_>E?(d.height=E+"px",ne(r,O)):Re(r,O),this._containerWidth=this._container.offsetWidth},_animateZoom:function(r){var d=this._map._latLngToNewLayerPoint(this._latlng,r.zoom,r.center),f=this._getAnchor();Ie(this._container,d.add(f))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var r=this._map,d=parseInt(Lo(this._container,"marginBottom"),10)||0,f=this._container.offsetHeight+d,_=this._containerWidth,E=new ut(this._containerLeft,-f-this._containerBottom);E._add(Hn(this._container));var O=r.layerPointToContainerPoint(E),K=ht(this.options.autoPanPadding),et=ht(this.options.autoPanPaddingTopLeft||K),at=ht(this.options.autoPanPaddingBottomRight||K),_t=r.getSize(),Rt=0,Jt=0;O.x+_+at.x>_t.x&&(Rt=O.x+_-_t.x+at.x),O.x-Rt-et.x<0&&(Rt=O.x-et.x),O.y+f+at.y>_t.y&&(Jt=O.y+f-_t.y+at.y),O.y-Jt-et.y<0&&(Jt=O.y-et.y),(Rt||Jt)&&(this.options.keepInView&&(this._autopanning=!0),r.fire("autopanstart").panBy([Rt,Jt]))}},_getAnchor:function(){return ht(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),zy=function(r,d){return new ha(r,d)};g.mergeOptions({closePopupOnClick:!0}),g.include({openPopup:function(r,d,f){return this._initOverlay(ha,r,d,f).openOn(this),this},closePopup:function(r){return r=arguments.length?r:this._popup,r&&r.close(),this}}),dn.include({bindPopup:function(r,d){return this._popup=this._initOverlay(ha,this._popup,r,d),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(r){return this._popup&&(this instanceof qn||(this._popup._source=this),this._popup._prepareOpen(r||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(r){return this._popup&&this._popup.setContent(r),this},getPopup:function(){return this._popup},_openPopup:function(r){if(!(!this._popup||!this._map)){wn(r);var d=r.layer||r.target;if(this._popup._source===d&&!(d instanceof po)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(r.latlng);return}this._popup._source=d,this.openPopup(r.latlng)}},_movePopup:function(r){this._popup.setLatLng(r.latlng)},_onKeyPress:function(r){r.originalEvent.keyCode===13&&this._openPopup(r)}});var ua=_n.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(r){_n.prototype.onAdd.call(this,r),this.setOpacity(this.options.opacity),r.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(r){_n.prototype.onRemove.call(this,r),r.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var r=_n.prototype.getEvents.call(this);return this.options.permanent||(r.preclick=this.close),r},_initLayout:function(){var r="leaflet-tooltip",d=r+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=pe("div",d),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+c(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(r){var d,f,_=this._map,E=this._container,O=_.latLngToContainerPoint(_.getCenter()),K=_.layerPointToContainerPoint(r),et=this.options.direction,at=E.offsetWidth,_t=E.offsetHeight,Rt=ht(this.options.offset),Jt=this._getAnchor();et==="top"?(d=at/2,f=_t):et==="bottom"?(d=at/2,f=0):et==="center"?(d=at/2,f=_t/2):et==="right"?(d=0,f=_t/2):et==="left"?(d=at,f=_t/2):K.x<O.x?(et="right",d=0,f=_t/2):(et="left",d=at+(Rt.x+Jt.x)*2,f=_t/2),r=r.subtract(ht(d,f,!0)).add(Rt).add(Jt),Re(E,"leaflet-tooltip-right"),Re(E,"leaflet-tooltip-left"),Re(E,"leaflet-tooltip-top"),Re(E,"leaflet-tooltip-bottom"),ne(E,"leaflet-tooltip-"+et),Ie(E,r)},_updatePosition:function(){var r=this._map.latLngToLayerPoint(this._latlng);this._setPosition(r)},setOpacity:function(r){this.options.opacity=r,this._container&&ie(this._container,r)},_animateZoom:function(r){var d=this._map._latLngToNewLayerPoint(this._latlng,r.zoom,r.center);this._setPosition(d)},_getAnchor:function(){return ht(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}),Fy=function(r,d){return new ua(r,d)};g.include({openTooltip:function(r,d,f){return this._initOverlay(ua,r,d,f).openOn(this),this},closeTooltip:function(r){return r.close(),this}}),dn.include({bindTooltip:function(r,d){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(ua,this._tooltip,r,d),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&(this._initTooltipInteractions(!0),this.closeTooltip(),this._tooltip=null),this},_initTooltipInteractions:function(r){if(!(!r&&this._tooltipHandlersAdded)){var d=r?"off":"on",f={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?f.add=this._openTooltip:(f.mouseover=this._openTooltip,f.mouseout=this.closeTooltip,f.click=this._openTooltip,this._map?this._addFocusListeners():f.add=this._addFocusListeners),this._tooltip.options.sticky&&(f.mousemove=this._moveTooltip),this[d](f),this._tooltipHandlersAdded=!r}},openTooltip:function(r){return this._tooltip&&(this instanceof qn||(this._tooltip._source=this),this._tooltip._prepareOpen(r)&&(this._tooltip.openOn(this._map),this.getElement?this._setAriaDescribedByOnLayer(this):this.eachLayer&&this.eachLayer(this._setAriaDescribedByOnLayer,this))),this},closeTooltip:function(){if(this._tooltip)return this._tooltip.close()},toggleTooltip:function(){return this._tooltip&&this._tooltip.toggle(this),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(r){return this._tooltip&&this._tooltip.setContent(r),this},getTooltip:function(){return this._tooltip},_addFocusListeners:function(){this.getElement?this._addFocusListenersOnLayer(this):this.eachLayer&&this.eachLayer(this._addFocusListenersOnLayer,this)},_addFocusListenersOnLayer:function(r){var d=typeof r.getElement=="function"&&r.getElement();d&&(Gt(d,"focus",function(){this._tooltip._source=r,this.openTooltip()},this),Gt(d,"blur",this.closeTooltip,this))},_setAriaDescribedByOnLayer:function(r){var d=typeof r.getElement=="function"&&r.getElement();d&&d.setAttribute("aria-describedby",this._tooltip._container.id)},_openTooltip:function(r){if(!(!this._tooltip||!this._map)){if(this._map.dragging&&this._map.dragging.moving()&&!this._openOnceFlag){this._openOnceFlag=!0;var d=this;this._map.once("moveend",function(){d._openOnceFlag=!1,d._openTooltip(r)});return}this._tooltip._source=r.layer||r.target,this.openTooltip(this._tooltip.options.sticky?r.latlng:void 0)}},_moveTooltip:function(r){var d=r.latlng,f,_;this._tooltip.options.sticky&&r.originalEvent&&(f=this._map.mouseEventToContainerPoint(r.originalEvent),_=this._map.containerPointToLayerPoint(f),d=this._map.layerPointToLatLng(_)),this._tooltip.setLatLng(d)}});var Gh=ns.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(r){var d=r&&r.tagName==="DIV"?r:document.createElement("div"),f=this.options;if(f.html instanceof Element?(No(d),d.appendChild(f.html)):d.innerHTML=f.html!==!1?f.html:"",f.bgPos){var _=ht(f.bgPos);d.style.backgroundPosition=-_.x+"px "+-_.y+"px"}return this._setIconStyles(d,"icon"),d},createShadow:function(){return null}});function Wy(r){return new Gh(r)}ns.Default=tr;var er=dn.extend({options:{tileSize:256,opacity:1,updateWhenIdle:zt.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2},initialize:function(r){P(this,r)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView()},beforeAdd:function(r){r._addZoomLimit(this)},onRemove:function(r){this._removeAllTiles(),Ee(this._container),r._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(lo(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(zn(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(r){return this.options.opacity=r,this._updateOpacity(),this},setZIndex:function(r){return this.options.zIndex=r,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){if(this._map){this._removeAllTiles();var r=this._clampZoom(this._map.getZoom());r!==this._tileZoom&&(this._tileZoom=r,this._updateLevels()),this._update()}return this},getEvents:function(){var r={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=u(this._onMoveEnd,this.options.updateInterval,this)),r.move=this._onMove),this._zoomAnimated&&(r.zoomanim=this._animateZoom),r},createTile:function(){return document.createElement("div")},getTileSize:function(){var r=this.options.tileSize;return r instanceof ut?r:new ut(r,r)},_updateZIndex:function(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(r){for(var d=this.getPane().children,f=-r(-1/0,1/0),_=0,E=d.length,O;_<E;_++)O=d[_].style.zIndex,d[_]!==this._container&&O&&(f=r(f,+O));isFinite(f)&&(this.options.zIndex=f+r(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!zt.ielt9){ie(this._container,this.options.opacity);var r=+new Date,d=!1,f=!1;for(var _ in this._tiles){var E=this._tiles[_];if(!(!E.current||!E.loaded)){var O=Math.min(1,(r-E.loaded)/200);ie(E.el,O),O<1?d=!0:(E.active?f=!0:this._onOpaqueTile(E),E.active=!0)}}f&&!this._noPrune&&this._pruneTiles(),d&&(Ct(this._fadeFrame),this._fadeFrame=gt(this._updateOpacity,this))}},_onOpaqueTile:v,_initContainer:function(){this._container||(this._container=pe("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var r=this._tileZoom,d=this.options.maxZoom;if(r!==void 0){for(var f in this._levels)f=Number(f),this._levels[f].el.children.length||f===r?(this._levels[f].el.style.zIndex=d-Math.abs(r-f),this._onUpdateLevel(f)):(Ee(this._levels[f].el),this._removeTilesAtZoom(f),this._onRemoveLevel(f),delete this._levels[f]);var _=this._levels[r],E=this._map;return _||(_=this._levels[r]={},_.el=pe("div","leaflet-tile-container leaflet-zoom-animated",this._container),_.el.style.zIndex=d,_.origin=E.project(E.unproject(E.getPixelOrigin()),r).round(),_.zoom=r,this._setZoomTransform(_,E.getCenter(),E.getZoom()),v(_.el.offsetWidth),this._onCreateLevel(_)),this._level=_,_}},_onUpdateLevel:v,_onRemoveLevel:v,_onCreateLevel:v,_pruneTiles:function(){if(this._map){var r,d,f=this._map.getZoom();if(f>this.options.maxZoom||f<this.options.minZoom){this._removeAllTiles();return}for(r in this._tiles)d=this._tiles[r],d.retain=d.current;for(r in this._tiles)if(d=this._tiles[r],d.current&&!d.active){var _=d.coords;this._retainParent(_.x,_.y,_.z,_.z-5)||this._retainChildren(_.x,_.y,_.z,_.z+2)}for(r in this._tiles)this._tiles[r].retain||this._removeTile(r)}},_removeTilesAtZoom:function(r){for(var d in this._tiles)this._tiles[d].coords.z===r&&this._removeTile(d)},_removeAllTiles:function(){for(var r in this._tiles)this._removeTile(r)},_invalidateAll:function(){for(var r in this._levels)Ee(this._levels[r].el),this._onRemoveLevel(Number(r)),delete this._levels[r];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(r,d,f,_){var E=Math.floor(r/2),O=Math.floor(d/2),K=f-1,et=new ut(+E,+O);et.z=+K;var at=this._tileCoordsToKey(et),_t=this._tiles[at];return _t&&_t.active?(_t.retain=!0,!0):(_t&&_t.loaded&&(_t.retain=!0),K>_?this._retainParent(E,O,K,_):!1)},_retainChildren:function(r,d,f,_){for(var E=2*r;E<2*r+2;E++)for(var O=2*d;O<2*d+2;O++){var K=new ut(E,O);K.z=f+1;var et=this._tileCoordsToKey(K),at=this._tiles[et];if(at&&at.active){at.retain=!0;continue}else at&&at.loaded&&(at.retain=!0);f+1<_&&this._retainChildren(E,O,f+1,_)}},_resetView:function(r){var d=r&&(r.pinch||r.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),d,d)},_animateZoom:function(r){this._setView(r.center,r.zoom,!0,r.noUpdate)},_clampZoom:function(r){var d=this.options;return d.minNativeZoom!==void 0&&r<d.minNativeZoom?d.minNativeZoom:d.maxNativeZoom!==void 0&&d.maxNativeZoom<r?d.maxNativeZoom:r},_setView:function(r,d,f,_){var E=Math.round(d);this.options.maxZoom!==void 0&&E>this.options.maxZoom||this.options.minZoom!==void 0&&E<this.options.minZoom?E=void 0:E=this._clampZoom(E);var O=this.options.updateWhenZooming&&E!==this._tileZoom;(!_||O)&&(this._tileZoom=E,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),E!==void 0&&this._update(r),f||this._pruneTiles(),this._noPrune=!!f),this._setZoomTransforms(r,d)},_setZoomTransforms:function(r,d){for(var f in this._levels)this._setZoomTransform(this._levels[f],r,d)},_setZoomTransform:function(r,d,f){var _=this._map.getZoomScale(f,r.zoom),E=r.origin.multiplyBy(_).subtract(this._map._getNewPixelOrigin(d,f)).round();zt.any3d?Wn(r.el,E,_):Ie(r.el,E)},_resetGrid:function(){var r=this._map,d=r.options.crs,f=this._tileSize=this.getTileSize(),_=this._tileZoom,E=this._map.getPixelWorldBounds(this._tileZoom);E&&(this._globalTileRange=this._pxBoundsToTileRange(E)),this._wrapX=d.wrapLng&&!this.options.noWrap&&[Math.floor(r.project([0,d.wrapLng[0]],_).x/f.x),Math.ceil(r.project([0,d.wrapLng[1]],_).x/f.y)],this._wrapY=d.wrapLat&&!this.options.noWrap&&[Math.floor(r.project([d.wrapLat[0],0],_).y/f.x),Math.ceil(r.project([d.wrapLat[1],0],_).y/f.y)]},_onMoveEnd:function(){!this._map||this._map._animatingZoom||this._update()},_getTiledPixelBounds:function(r){var d=this._map,f=d._animatingZoom?Math.max(d._animateToZoom,d.getZoom()):d.getZoom(),_=d.getZoomScale(f,this._tileZoom),E=d.project(r,this._tileZoom).floor(),O=d.getSize().divideBy(_*2);return new Tt(E.subtract(O),E.add(O))},_update:function(r){var d=this._map;if(d){var f=this._clampZoom(d.getZoom());if(r===void 0&&(r=d.getCenter()),this._tileZoom!==void 0){var _=this._getTiledPixelBounds(r),E=this._pxBoundsToTileRange(_),O=E.getCenter(),K=[],et=this.options.keepBuffer,at=new Tt(E.getBottomLeft().subtract([et,-et]),E.getTopRight().add([et,-et]));if(!(isFinite(E.min.x)&&isFinite(E.min.y)&&isFinite(E.max.x)&&isFinite(E.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var _t in this._tiles){var Rt=this._tiles[_t].coords;(Rt.z!==this._tileZoom||!at.contains(new ut(Rt.x,Rt.y)))&&(this._tiles[_t].current=!1)}if(Math.abs(f-this._tileZoom)>1){this._setView(r,f);return}for(var Jt=E.min.y;Jt<=E.max.y;Jt++)for(var le=E.min.x;le<=E.max.x;le++){var _i=new ut(le,Jt);if(_i.z=this._tileZoom,!!this._isValidTile(_i)){var ni=this._tiles[this._tileCoordsToKey(_i)];ni?ni.current=!0:K.push(_i)}}if(K.sort(function(Ai,as){return Ai.distanceTo(O)-as.distanceTo(O)}),K.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var Ki=document.createDocumentFragment();for(le=0;le<K.length;le++)this._addTile(K[le],Ki);this._level.el.appendChild(Ki)}}}},_isValidTile:function(r){var d=this._map.options.crs;if(!d.infinite){var f=this._globalTileRange;if(!d.wrapLng&&(r.x<f.min.x||r.x>f.max.x)||!d.wrapLat&&(r.y<f.min.y||r.y>f.max.y))return!1}if(!this.options.bounds)return!0;var _=this._tileCoordsToBounds(r);return Et(this.options.bounds).overlaps(_)},_keyToBounds:function(r){return this._tileCoordsToBounds(this._keyToTileCoords(r))},_tileCoordsToNwSe:function(r){var d=this._map,f=this.getTileSize(),_=r.scaleBy(f),E=_.add(f),O=d.unproject(_,r.z),K=d.unproject(E,r.z);return[O,K]},_tileCoordsToBounds:function(r){var d=this._tileCoordsToNwSe(r),f=new At(d[0],d[1]);return this.options.noWrap||(f=this._map.wrapLatLngBounds(f)),f},_tileCoordsToKey:function(r){return r.x+":"+r.y+":"+r.z},_keyToTileCoords:function(r){var d=r.split(":"),f=new ut(+d[0],+d[1]);return f.z=+d[2],f},_removeTile:function(r){var d=this._tiles[r];d&&(Ee(d.el),delete this._tiles[r],this.fire("tileunload",{tile:d.el,coords:this._keyToTileCoords(r)}))},_initTile:function(r){ne(r,"leaflet-tile");var d=this.getTileSize();r.style.width=d.x+"px",r.style.height=d.y+"px",r.onselectstart=v,r.onmousemove=v,zt.ielt9&&this.options.opacity<1&&ie(r,this.options.opacity)},_addTile:function(r,d){var f=this._getTilePos(r),_=this._tileCoordsToKey(r),E=this.createTile(this._wrapCoords(r),a(this._tileReady,this,r));this._initTile(E),this.createTile.length<2&>(a(this._tileReady,this,r,null,E)),Ie(E,f),this._tiles[_]={el:E,coords:r,current:!0},d.appendChild(E),this.fire("tileloadstart",{tile:E,coords:r})},_tileReady:function(r,d,f){d&&this.fire("tileerror",{error:d,tile:f,coords:r});var _=this._tileCoordsToKey(r);f=this._tiles[_],f&&(f.loaded=+new Date,this._map._fadeAnimated?(ie(f.el,0),Ct(this._fadeFrame),this._fadeFrame=gt(this._updateOpacity,this)):(f.active=!0,this._pruneTiles()),d||(ne(f.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:f.el,coords:r})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),zt.ielt9||!this._map._fadeAnimated?gt(this._pruneTiles,this):setTimeout(a(this._pruneTiles,this),250)))},_getTilePos:function(r){return r.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(r){var d=new ut(this._wrapX?p(r.x,this._wrapX):r.x,this._wrapY?p(r.y,this._wrapY):r.y);return d.z=r.z,d},_pxBoundsToTileRange:function(r){var d=this.getTileSize();return new Tt(r.min.unscaleBy(d).floor(),r.max.unscaleBy(d).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var r in this._tiles)if(!this._tiles[r].loaded)return!1;return!0}});function Hy(r){return new er(r)}var rs=er.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(r,d){this._url=r,d=P(this,d),d.detectRetina&&zt.retina&&d.maxZoom>0?(d.tileSize=Math.floor(d.tileSize/2),d.zoomReverse?(d.zoomOffset--,d.minZoom=Math.min(d.maxZoom,d.minZoom+1)):(d.zoomOffset++,d.maxZoom=Math.max(d.minZoom,d.maxZoom-1)),d.minZoom=Math.max(0,d.minZoom)):d.zoomReverse?d.minZoom=Math.min(d.maxZoom,d.minZoom):d.maxZoom=Math.max(d.minZoom,d.maxZoom),typeof d.subdomains=="string"&&(d.subdomains=d.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(r,d){return this._url===r&&d===void 0&&(d=!0),this._url=r,d||this.redraw(),this},createTile:function(r,d){var f=document.createElement("img");return Gt(f,"load",a(this._tileOnLoad,this,d,f)),Gt(f,"error",a(this._tileOnError,this,d,f)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(f.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(f.referrerPolicy=this.options.referrerPolicy),f.alt="",f.src=this.getTileUrl(r),f},getTileUrl:function(r){var d={r:zt.retina?"@2x":"",s:this._getSubdomain(r),x:r.x,y:r.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var f=this._globalTileRange.max.y-r.y;this.options.tms&&(d.y=f),d["-y"]=f}return q(this._url,n(d,this.options))},_tileOnLoad:function(r,d){zt.ielt9?setTimeout(a(r,this,null,d),0):r(null,d)},_tileOnError:function(r,d,f){var _=this.options.errorTileUrl;_&&d.getAttribute("src")!==_&&(d.src=_),r(f,d)},_onTileRemove:function(r){r.tile.onload=null},_getZoomForUrl:function(){var r=this._tileZoom,d=this.options.maxZoom,f=this.options.zoomReverse,_=this.options.zoomOffset;return f&&(r=d-r),r+_},_getSubdomain:function(r){var d=Math.abs(r.x+r.y)%this.options.subdomains.length;return this.options.subdomains[d]},_abortLoading:function(){var r,d;for(r in this._tiles)if(this._tiles[r].coords.z!==this._tileZoom&&(d=this._tiles[r].el,d.onload=v,d.onerror=v,!d.complete)){d.src=tt;var f=this._tiles[r].coords;Ee(d),delete this._tiles[r],this.fire("tileabort",{tile:d,coords:f})}},_removeTile:function(r){var d=this._tiles[r];if(d)return d.el.setAttribute("src",tt),er.prototype._removeTile.call(this,r)},_tileReady:function(r,d,f){if(!(!this._map||f&&f.getAttribute("src")===tt))return er.prototype._tileReady.call(this,r,d,f)}});function Yh(r,d){return new rs(r,d)}var Jh=rs.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(r,d){this._url=r;var f=n({},this.defaultWmsParams);for(var _ in d)_ in this.options||(f[_]=d[_]);d=P(this,d);var E=d.detectRetina&&zt.retina?2:1,O=this.getTileSize();f.width=O.x*E,f.height=O.y*E,this.wmsParams=f},onAdd:function(r){this._crs=this.options.crs||r.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var d=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[d]=this._crs.code,rs.prototype.onAdd.call(this,r)},getTileUrl:function(r){var d=this._tileCoordsToNwSe(r),f=this._crs,_=mt(f.project(d[0]),f.project(d[1])),E=_.min,O=_.max,K=(this._wmsVersion>=1.3&&this._crs===Vh?[E.y,E.x,O.y,O.x]:[E.x,E.y,O.x,O.y]).join(","),et=rs.prototype.getTileUrl.call(this,r);return et+F(this.wmsParams,et,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+K},setParams:function(r,d){return n(this.wmsParams,r),d||this.redraw(),this}});function Vy(r,d){return new Jh(r,d)}rs.WMS=Jh,Yh.wms=Vy;var Gn=dn.extend({options:{padding:.1},initialize:function(r){P(this,r),c(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),ne(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var r={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(r.zoomanim=this._onAnimZoom),r},_onAnimZoom:function(r){this._updateTransform(r.center,r.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(r,d){var f=this._map.getZoomScale(d,this._zoom),_=this._map.getSize().multiplyBy(.5+this.options.padding),E=this._map.project(this._center,d),O=_.multiplyBy(-f).add(E).subtract(this._map._getNewPixelOrigin(r,d));zt.any3d?Wn(this._container,O,f):Ie(this._container,O)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var r in this._layers)this._layers[r]._reset()},_onZoomEnd:function(){for(var r in this._layers)this._layers[r]._project()},_updatePaths:function(){for(var r in this._layers)this._layers[r]._update()},_update:function(){var r=this.options.padding,d=this._map.getSize(),f=this._map.containerPointToLayerPoint(d.multiplyBy(-r)).round();this._bounds=new Tt(f,f.add(d.multiplyBy(1+r*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),Qh=Gn.extend({options:{tolerance:0},getEvents:function(){var r=Gn.prototype.getEvents.call(this);return r.viewprereset=this._onViewPreReset,r},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Gn.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var r=this._container=document.createElement("canvas");Gt(r,"mousemove",this._onMouseMove,this),Gt(r,"click dblclick mousedown mouseup contextmenu",this._onClick,this),Gt(r,"mouseout",this._handleMouseOut,this),r._leaflet_disable_events=!0,this._ctx=r.getContext("2d")},_destroyContainer:function(){Ct(this._redrawRequest),delete this._ctx,Ee(this._container),ke(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var r;this._redrawBounds=null;for(var d in this._layers)r=this._layers[d],r._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Gn.prototype._update.call(this);var r=this._bounds,d=this._container,f=r.getSize(),_=zt.retina?2:1;Ie(d,r.min),d.width=_*f.x,d.height=_*f.y,d.style.width=f.x+"px",d.style.height=f.y+"px",zt.retina&&this._ctx.scale(2,2),this._ctx.translate(-r.min.x,-r.min.y),this.fire("update")}},_reset:function(){Gn.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(r){this._updateDashArray(r),this._layers[c(r)]=r;var d=r._order={layer:r,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=d),this._drawLast=d,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(r){this._requestRedraw(r)},_removePath:function(r){var d=r._order,f=d.next,_=d.prev;f?f.prev=_:this._drawLast=_,_?_.next=f:this._drawFirst=f,delete r._order,delete this._layers[c(r)],this._requestRedraw(r)},_updatePath:function(r){this._extendRedrawBounds(r),r._project(),r._update(),this._requestRedraw(r)},_updateStyle:function(r){this._updateDashArray(r),this._requestRedraw(r)},_updateDashArray:function(r){if(typeof r.options.dashArray=="string"){var d=r.options.dashArray.split(/[, ]+/),f=[],_,E;for(E=0;E<d.length;E++){if(_=Number(d[E]),isNaN(_))return;f.push(_)}r.options._dashArray=f}else r.options._dashArray=r.options.dashArray},_requestRedraw:function(r){this._map&&(this._extendRedrawBounds(r),this._redrawRequest=this._redrawRequest||gt(this._redraw,this))},_extendRedrawBounds:function(r){if(r._pxBounds){var d=(r.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new Tt,this._redrawBounds.extend(r._pxBounds.min.subtract([d,d])),this._redrawBounds.extend(r._pxBounds.max.add([d,d]))}},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var r=this._redrawBounds;if(r){var d=r.getSize();this._ctx.clearRect(r.min.x,r.min.y,d.x,d.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()},_draw:function(){var r,d=this._redrawBounds;if(this._ctx.save(),d){var f=d.getSize();this._ctx.beginPath(),this._ctx.rect(d.min.x,d.min.y,f.x,f.y),this._ctx.clip()}this._drawing=!0;for(var _=this._drawFirst;_;_=_.next)r=_.layer,(!d||r._pxBounds&&r._pxBounds.intersects(d))&&r._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(r,d){if(this._drawing){var f,_,E,O,K=r._parts,et=K.length,at=this._ctx;if(et){for(at.beginPath(),f=0;f<et;f++){for(_=0,E=K[f].length;_<E;_++)O=K[f][_],at[_?"lineTo":"moveTo"](O.x,O.y);d&&at.closePath()}this._fillStroke(at,r)}}},_updateCircle:function(r){if(!(!this._drawing||r._empty())){var d=r._point,f=this._ctx,_=Math.max(Math.round(r._radius),1),E=(Math.max(Math.round(r._radiusY),1)||_)/_;E!==1&&(f.save(),f.scale(1,E)),f.beginPath(),f.arc(d.x,d.y/E,_,0,Math.PI*2,!1),E!==1&&f.restore(),this._fillStroke(f,r)}},_fillStroke:function(r,d){var f=d.options;f.fill&&(r.globalAlpha=f.fillOpacity,r.fillStyle=f.fillColor||f.color,r.fill(f.fillRule||"evenodd")),f.stroke&&f.weight!==0&&(r.setLineDash&&r.setLineDash(d.options&&d.options._dashArray||[]),r.globalAlpha=f.opacity,r.lineWidth=f.weight,r.strokeStyle=f.color,r.lineCap=f.lineCap,r.lineJoin=f.lineJoin,r.stroke())},_onClick:function(r){for(var d=this._map.mouseEventToLayerPoint(r),f,_,E=this._drawFirst;E;E=E.next)f=E.layer,f.options.interactive&&f._containsPoint(d)&&(!(r.type==="click"||r.type==="preclick")||!this._map._draggableMoved(f))&&(_=f);this._fireEvent(_?[_]:!1,r)},_onMouseMove:function(r){if(!(!this._map||this._map.dragging.moving()||this._map._animatingZoom)){var d=this._map.mouseEventToLayerPoint(r);this._handleMouseHover(r,d)}},_handleMouseOut:function(r){var d=this._hoveredLayer;d&&(Re(this._container,"leaflet-interactive"),this._fireEvent([d],r,"mouseout"),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(r,d){if(!this._mouseHoverThrottled){for(var f,_,E=this._drawFirst;E;E=E.next)f=E.layer,f.options.interactive&&f._containsPoint(d)&&(_=f);_!==this._hoveredLayer&&(this._handleMouseOut(r),_&&(ne(this._container,"leaflet-interactive"),this._fireEvent([_],r,"mouseover"),this._hoveredLayer=_)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,r),this._mouseHoverThrottled=!0,setTimeout(a(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(r,d,f){this._map._fireDOMEvent(d,f||d.type,r)},_bringToFront:function(r){var d=r._order;if(d){var f=d.next,_=d.prev;if(f)f.prev=_;else return;_?_.next=f:f&&(this._drawFirst=f),d.prev=this._drawLast,this._drawLast.next=d,d.next=null,this._drawLast=d,this._requestRedraw(r)}},_bringToBack:function(r){var d=r._order;if(d){var f=d.next,_=d.prev;if(_)_.next=f;else return;f?f.prev=_:_&&(this._drawLast=_),d.prev=null,d.next=this._drawFirst,this._drawFirst.prev=d,this._drawFirst=d,this._requestRedraw(r)}}});function Xh(r){return zt.canvas?new Qh(r):null}var ir=function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(r){return document.createElement("<lvml:"+r+' class="lvml">')}}catch{}return function(r){return document.createElement("<"+r+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),Uy={_initContainer:function(){this._container=pe("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Gn.prototype._update.call(this),this.fire("update"))},_initPath:function(r){var d=r._container=ir("shape");ne(d,"leaflet-vml-shape "+(this.options.className||"")),d.coordsize="1 1",r._path=ir("path"),d.appendChild(r._path),this._updateStyle(r),this._layers[c(r)]=r},_addPath:function(r){var d=r._container;this._container.appendChild(d),r.options.interactive&&r.addInteractiveTarget(d)},_removePath:function(r){var d=r._container;Ee(d),r.removeInteractiveTarget(d),delete this._layers[c(r)]},_updateStyle:function(r){var d=r._stroke,f=r._fill,_=r.options,E=r._container;E.stroked=!!_.stroke,E.filled=!!_.fill,_.stroke?(d||(d=r._stroke=ir("stroke")),E.appendChild(d),d.weight=_.weight+"px",d.color=_.color,d.opacity=_.opacity,_.dashArray?d.dashStyle=H(_.dashArray)?_.dashArray.join(" "):_.dashArray.replace(/( *, *)/g," "):d.dashStyle="",d.endcap=_.lineCap.replace("butt","flat"),d.joinstyle=_.lineJoin):d&&(E.removeChild(d),r._stroke=null),_.fill?(f||(f=r._fill=ir("fill")),E.appendChild(f),f.color=_.fillColor||_.color,f.opacity=_.fillOpacity):f&&(E.removeChild(f),r._fill=null)},_updateCircle:function(r){var d=r._point.round(),f=Math.round(r._radius),_=Math.round(r._radiusY||f);this._setPath(r,r._empty()?"M0 0":"AL "+d.x+","+d.y+" "+f+","+_+" 0,"+65535*360)},_setPath:function(r,d){r._path.v=d},_bringToFront:function(r){lo(r._container)},_bringToBack:function(r){zn(r._container)}},pa=zt.vml?ir:X,nr=Gn.extend({_initContainer:function(){this._container=pa("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=pa("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){Ee(this._container),ke(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Gn.prototype._update.call(this);var r=this._bounds,d=r.getSize(),f=this._container;(!this._svgSize||!this._svgSize.equals(d))&&(this._svgSize=d,f.setAttribute("width",d.x),f.setAttribute("height",d.y)),Ie(f,r.min),f.setAttribute("viewBox",[r.min.x,r.min.y,d.x,d.y].join(" ")),this.fire("update")}},_initPath:function(r){var d=r._path=pa("path");r.options.className&&ne(d,r.options.className),r.options.interactive&&ne(d,"leaflet-interactive"),this._updateStyle(r),this._layers[c(r)]=r},_addPath:function(r){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(r._path),r.addInteractiveTarget(r._path)},_removePath:function(r){Ee(r._path),r.removeInteractiveTarget(r._path),delete this._layers[c(r)]},_updatePath:function(r){r._project(),r._update()},_updateStyle:function(r){var d=r._path,f=r.options;d&&(f.stroke?(d.setAttribute("stroke",f.color),d.setAttribute("stroke-opacity",f.opacity),d.setAttribute("stroke-width",f.weight),d.setAttribute("stroke-linecap",f.lineCap),d.setAttribute("stroke-linejoin",f.lineJoin),f.dashArray?d.setAttribute("stroke-dasharray",f.dashArray):d.removeAttribute("stroke-dasharray"),f.dashOffset?d.setAttribute("stroke-dashoffset",f.dashOffset):d.removeAttribute("stroke-dashoffset")):d.setAttribute("stroke","none"),f.fill?(d.setAttribute("fill",f.fillColor||f.color),d.setAttribute("fill-opacity",f.fillOpacity),d.setAttribute("fill-rule",f.fillRule||"evenodd")):d.setAttribute("fill","none"))},_updatePoly:function(r,d){this._setPath(r,wt(r._parts,d))},_updateCircle:function(r){var d=r._point,f=Math.max(Math.round(r._radius),1),_=Math.max(Math.round(r._radiusY),1)||f,E="a"+f+","+_+" 0 1,0 ",O=r._empty()?"M0 0":"M"+(d.x-f)+","+d.y+E+f*2+",0 "+E+-f*2+",0 ";this._setPath(r,O)},_setPath:function(r,d){r._path.setAttribute("d",d)},_bringToFront:function(r){lo(r._path)},_bringToBack:function(r){zn(r._path)}});zt.vml&&nr.include(Uy);function tu(r){return zt.svg||zt.vml?new nr(r):null}g.include({getRenderer:function(r){var d=r.options.renderer||this._getPaneRenderer(r.options.pane)||this.options.renderer||this._renderer;return d||(d=this._renderer=this._createRenderer()),this.hasLayer(d)||this.addLayer(d),d},_getPaneRenderer:function(r){if(r==="overlayPane"||r===void 0)return!1;var d=this._paneRenderers[r];return d===void 0&&(d=this._createRenderer({pane:r}),this._paneRenderers[r]=d),d},_createRenderer:function(r){return this.options.preferCanvas&&Xh(r)||tu(r)}});var eu=os.extend({initialize:function(r,d){os.prototype.initialize.call(this,this._boundsToLatLngs(r),d)},setBounds:function(r){return this.setLatLngs(this._boundsToLatLngs(r))},_boundsToLatLngs:function(r){return r=Et(r),[r.getSouthWest(),r.getNorthWest(),r.getNorthEast(),r.getSouthEast()]}});function jy(r,d){return new eu(r,d)}nr.create=pa,nr.pointsToPath=wt,Zn.geometryToLayer=ra,Zn.coordsToLatLng=uc,Zn.coordsToLatLngs=aa,Zn.latLngToCoords=pc,Zn.latLngsToCoords=la,Zn.getFeature=ss,Zn.asFeature=ca,g.mergeOptions({boxZoom:!0});var iu=Y.extend({initialize:function(r){this._map=r,this._container=r._container,this._pane=r._panes.overlayPane,this._resetStateTimeout=0,r.on("unload",this._destroy,this)},addHooks:function(){Gt(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){ke(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){Ee(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(r){if(!r.shiftKey||r.which!==1&&r.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),cn(),bn(),this._startPoint=this._map.mouseEventToContainerPoint(r),Gt(document,{contextmenu:wn,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(r){this._moved||(this._moved=!0,this._box=pe("div","leaflet-zoom-box",this._container),ne(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(r);var d=new Tt(this._point,this._startPoint),f=d.getSize();Ie(this._box,d.min),this._box.style.width=f.x+"px",this._box.style.height=f.y+"px"},_finish:function(){this._moved&&(Ee(this._box),Re(this._container,"leaflet-crosshair")),Vn(),Vs(),ke(document,{contextmenu:wn,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(r){if(!(r.which!==1&&r.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(a(this._resetState,this),0);var d=new At(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(d).fire("boxzoomend",{boxZoomBounds:d})}},_onKeyDown:function(r){r.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});g.addInitHook("addHandler","boxZoom",iu),g.mergeOptions({doubleClickZoom:!0});var nu=Y.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(r){var d=this._map,f=d.getZoom(),_=d.options.zoomDelta,E=r.originalEvent.shiftKey?f-_:f+_;d.options.doubleClickZoom==="center"?d.setZoom(E):d.setZoomAround(r.containerPoint,E)}});g.addInitHook("addHandler","doubleClickZoom",nu),g.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var ou=Y.extend({addHooks:function(){if(!this._draggable){var r=this._map;this._draggable=new Ut(r._mapPane,r._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),r.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),r.on("zoomend",this._onZoomEnd,this),r.whenReady(this._onZoomEnd,this))}ne(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){Re(this._map._container,"leaflet-grab"),Re(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var r=this._map;if(r._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var d=Et(this._map.options.maxBounds);this._offsetLimit=mt(this._map.latLngToContainerPoint(d.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(d.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;r.fire("movestart").fire("dragstart"),r.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(r){if(this._map.options.inertia){var d=this._lastTime=+new Date,f=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(f),this._times.push(d),this._prunePositions(d)}this._map.fire("move",r).fire("drag",r)},_prunePositions:function(r){for(;this._positions.length>1&&r-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var r=this._map.getSize().divideBy(2),d=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=d.subtract(r).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(r,d){return r-(r-d)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var r=this._draggable._newPos.subtract(this._draggable._startPos),d=this._offsetLimit;r.x<d.min.x&&(r.x=this._viscousLimit(r.x,d.min.x)),r.y<d.min.y&&(r.y=this._viscousLimit(r.y,d.min.y)),r.x>d.max.x&&(r.x=this._viscousLimit(r.x,d.max.x)),r.y>d.max.y&&(r.y=this._viscousLimit(r.y,d.max.y)),this._draggable._newPos=this._draggable._startPos.add(r)}},_onPreDragWrap:function(){var r=this._worldWidth,d=Math.round(r/2),f=this._initialWorldOffset,_=this._draggable._newPos.x,E=(_-d+f)%r+d-f,O=(_+d+f)%r-d-f,K=Math.abs(E+f)<Math.abs(O+f)?E:O;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=K},_onDragEnd:function(r){var d=this._map,f=d.options,_=!f.inertia||r.noInertia||this._times.length<2;if(d.fire("dragend",r),_)d.fire("moveend");else{this._prunePositions(+new Date);var E=this._lastPos.subtract(this._positions[0]),O=(this._lastTime-this._times[0])/1e3,K=f.easeLinearity,et=E.multiplyBy(K/O),at=et.distanceTo([0,0]),_t=Math.min(f.inertiaMaxSpeed,at),Rt=et.multiplyBy(_t/at),Jt=_t/(f.inertiaDeceleration*K),le=Rt.multiplyBy(-Jt/2).round();!le.x&&!le.y?d.fire("moveend"):(le=d._limitOffset(le,d.options.maxBounds),gt(function(){d.panBy(le,{duration:Jt,easeLinearity:K,noMoveStart:!0,animate:!0})}))}}});g.addInitHook("addHandler","dragging",ou),g.mergeOptions({keyboard:!0,keyboardPanDelta:80});var su=Y.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(r){this._map=r,this._setPanDelta(r.options.keyboardPanDelta),this._setZoomDelta(r.options.zoomDelta)},addHooks:function(){var r=this._map._container;r.tabIndex<=0&&(r.tabIndex="0"),Gt(r,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),ke(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var r=document.body,d=document.documentElement,f=r.scrollTop||d.scrollTop,_=r.scrollLeft||d.scrollLeft;this._map._container.focus(),window.scrollTo(_,f)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(r){var d=this._panKeys={},f=this.keyCodes,_,E;for(_=0,E=f.left.length;_<E;_++)d[f.left[_]]=[-1*r,0];for(_=0,E=f.right.length;_<E;_++)d[f.right[_]]=[r,0];for(_=0,E=f.down.length;_<E;_++)d[f.down[_]]=[0,r];for(_=0,E=f.up.length;_<E;_++)d[f.up[_]]=[0,-1*r]},_setZoomDelta:function(r){var d=this._zoomKeys={},f=this.keyCodes,_,E;for(_=0,E=f.zoomIn.length;_<E;_++)d[f.zoomIn[_]]=r;for(_=0,E=f.zoomOut.length;_<E;_++)d[f.zoomOut[_]]=-r},_addHooks:function(){Gt(document,"keydown",this._onKeyDown,this)},_removeHooks:function(){ke(document,"keydown",this._onKeyDown,this)},_onKeyDown:function(r){if(!(r.altKey||r.ctrlKey||r.metaKey)){var d=r.keyCode,f=this._map,_;if(d in this._panKeys){if(!f._panAnim||!f._panAnim._inProgress)if(_=this._panKeys[d],r.shiftKey&&(_=ht(_).multiplyBy(3)),f.options.maxBounds&&(_=f._limitOffset(ht(_),f.options.maxBounds)),f.options.worldCopyJump){var E=f.wrapLatLng(f.unproject(f.project(f.getCenter()).add(_)));f.panTo(E)}else f.panBy(_)}else if(d in this._zoomKeys)f.setZoom(f.getZoom()+(r.shiftKey?3:1)*this._zoomKeys[d]);else if(d===27&&f._popup&&f._popup.options.closeOnEscapeKey)f.closePopup();else return;wn(r)}}});g.addInitHook("addHandler","keyboard",su),g.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var ru=Y.extend({addHooks:function(){Gt(this._map._container,"wheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){ke(this._map._container,"wheel",this._onWheelScroll,this)},_onWheelScroll:function(r){var d=Js(r),f=this._map.options.wheelDebounceTime;this._delta+=d,this._lastMousePos=this._map.mouseEventToContainerPoint(r),this._startTime||(this._startTime=+new Date);var _=Math.max(f-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(a(this._performZoom,this),_),wn(r)},_performZoom:function(){var r=this._map,d=r.getZoom(),f=this._map.options.zoomSnap||0;r._stop();var _=this._delta/(this._map.options.wheelPxPerZoomLevel*4),E=4*Math.log(2/(1+Math.exp(-Math.abs(_))))/Math.LN2,O=f?Math.ceil(E/f)*f:E,K=r._limitZoom(d+(this._delta>0?O:-O))-d;this._delta=0,this._startTime=null,K&&(r.options.scrollWheelZoom==="center"?r.setZoom(d+K):r.setZoomAround(this._lastMousePos,d+K))}});g.addInitHook("addHandler","scrollWheelZoom",ru);var qy=600;g.mergeOptions({tapHold:zt.touchNative&&zt.safari&&zt.mobile,tapTolerance:15});var au=Y.extend({addHooks:function(){Gt(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){ke(this._map._container,"touchstart",this._onDown,this)},_onDown:function(r){if(clearTimeout(this._holdTimeout),r.touches.length===1){var d=r.touches[0];this._startPos=this._newPos=new ut(d.clientX,d.clientY),this._holdTimeout=setTimeout(a(function(){this._cancel(),this._isTapValid()&&(Gt(document,"touchend",qe),Gt(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",d))},this),qy),Gt(document,"touchend touchcancel contextmenu",this._cancel,this),Gt(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function r(){ke(document,"touchend",qe),ke(document,"touchend touchcancel",r)},_cancel:function(){clearTimeout(this._holdTimeout),ke(document,"touchend touchcancel contextmenu",this._cancel,this),ke(document,"touchmove",this._onMove,this)},_onMove:function(r){var d=r.touches[0];this._newPos=new ut(d.clientX,d.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(r,d){var f=new MouseEvent(r,{bubbles:!0,cancelable:!0,view:window,screenX:d.screenX,screenY:d.screenY,clientX:d.clientX,clientY:d.clientY});f._simulated=!0,d.target.dispatchEvent(f)}});g.addInitHook("addHandler","tapHold",au),g.mergeOptions({touchZoom:zt.touch,bounceAtZoomLimits:!0});var lu=Y.extend({addHooks:function(){ne(this._map._container,"leaflet-touch-zoom"),Gt(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){Re(this._map._container,"leaflet-touch-zoom"),ke(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(r){var d=this._map;if(!(!r.touches||r.touches.length!==2||d._animatingZoom||this._zooming)){var f=d.mouseEventToContainerPoint(r.touches[0]),_=d.mouseEventToContainerPoint(r.touches[1]);this._centerPoint=d.getSize()._divideBy(2),this._startLatLng=d.containerPointToLatLng(this._centerPoint),d.options.touchZoom!=="center"&&(this._pinchStartLatLng=d.containerPointToLatLng(f.add(_)._divideBy(2))),this._startDist=f.distanceTo(_),this._startZoom=d.getZoom(),this._moved=!1,this._zooming=!0,d._stop(),Gt(document,"touchmove",this._onTouchMove,this),Gt(document,"touchend touchcancel",this._onTouchEnd,this),qe(r)}},_onTouchMove:function(r){if(!(!r.touches||r.touches.length!==2||!this._zooming)){var d=this._map,f=d.mouseEventToContainerPoint(r.touches[0]),_=d.mouseEventToContainerPoint(r.touches[1]),E=f.distanceTo(_)/this._startDist;if(this._zoom=d.getScaleZoom(E,this._startZoom),!d.options.bounceAtZoomLimits&&(this._zoom<d.getMinZoom()&&E<1||this._zoom>d.getMaxZoom()&&E>1)&&(this._zoom=d._limitZoom(this._zoom)),d.options.touchZoom==="center"){if(this._center=this._startLatLng,E===1)return}else{var O=f._add(_)._divideBy(2)._subtract(this._centerPoint);if(E===1&&O.x===0&&O.y===0)return;this._center=d.unproject(d.project(this._pinchStartLatLng,this._zoom).subtract(O),this._zoom)}this._moved||(d._moveStart(!0,!1),this._moved=!0),Ct(this._animRequest);var K=a(d._move,d,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=gt(K,this,!0),qe(r)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,Ct(this._animRequest),ke(document,"touchmove",this._onTouchMove,this),ke(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});g.addInitHook("addHandler","touchZoom",lu),g.BoxZoom=iu,g.DoubleClickZoom=nu,g.Drag=ou,g.Keyboard=su,g.ScrollWheelZoom=ru,g.TapHold=au,g.TouchZoom=lu,e.Bounds=Tt,e.Browser=zt,e.CRS=k,e.Canvas=Qh,e.Circle=hc,e.CircleMarker=sa,e.Class=Nt,e.Control=w,e.DivIcon=Gh,e.DivOverlay=_n,e.DomEvent=lc,e.DomUtil=ac,e.Draggable=Ut,e.Evented=te,e.FeatureGroup=qn,e.GeoJSON=Zn,e.GridLayer=er,e.Handler=Y,e.Icon=ns,e.ImageOverlay=da,e.LatLng=dt,e.LatLngBounds=At,e.Layer=dn,e.LayerGroup=is,e.LineUtil=ky,e.Map=g,e.Marker=oa,e.Mixin=yt,e.Path=po,e.Point=ut,e.PolyUtil=se,e.Polygon=os,e.Polyline=Kn,e.Popup=ha,e.PosAnimation=h,e.Projection=Cy,e.Rectangle=eu,e.Renderer=Gn,e.SVG=nr,e.SVGOverlay=Zh,e.TileLayer=rs,e.Tooltip=ua,e.Transformation=B,e.Util=St,e.VideoOverlay=Kh,e.bind=a,e.bounds=mt,e.canvas=Xh,e.circle=Ny,e.circleMarker=Ly,e.control=C,e.divIcon=Wy,e.extend=n,e.featureGroup=Ey,e.geoJSON=qh,e.geoJson=Oy,e.gridLayer=Hy,e.icon=Iy,e.imageOverlay=Dy,e.latLng=b,e.latLngBounds=Et,e.layerGroup=Ty,e.map=y,e.marker=Ay,e.point=ht,e.polygon=Py,e.polyline=My,e.popup=zy,e.rectangle=jy,e.setOptions=P,e.stamp=c,e.svg=tu,e.svgOverlay=By,e.tileLayer=Yh,e.tooltip=Fy,e.transformation=V,e.version=i,e.videoOverlay=Ry;var Ky=window.L;e.noConflict=function(){return window.L=Ky,this},window.L=e})}(vr,vr.exports)),vr.exports}var MT=NT();const Vc=Br(MT),PT=`<div class="geo-map-widget">
|
||
<style>
|
||
.note-detail-geo-map,
|
||
.geo-map-widget,
|
||
.geo-map-container {
|
||
height: 100%;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.leaflet-top,
|
||
.leaflet-bottom {
|
||
z-index: 900;
|
||
}
|
||
</style>
|
||
|
||
<div class="geo-map-container"></div>
|
||
</div>`;class OT extends hi{map;$container;initCallback;constructor(t,e){super(),this.initCallback=e}doRender(){this.$widget=$(PT),this.$container=this.$widget.find(".geo-map-container");const t=Vc.map(this.$container[0],{worldCopyJump:!0});this.map=t,this.initCallback&&this.initCallback(Vc),Vc.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',detectRetina:!0}).addTo(t)}}function DT(o,t){Ho.show({x:t.pageX,y:t.pageY,items:[...$r.getItems(),{title:m("geo-map-context.open-location"),command:"openGeoLocation",uiIcon:"bx bx-map-alt"},{title:"----"},{title:m("geo-map-context.remove-from-map"),command:"deleteFromMap",uiIcon:"bx bx-trash"}],selectMenuItemHandler:({command:e},i)=>{if(e==="deleteFromMap"){Pt.triggerCommand(e,{noteId:o});return}if(e==="openGeoLocation"){Pt.triggerCommand(e,{noteId:o,event:i});return}$r.handleLinkContextMenuItem(e,o)}})}const RT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",BT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",zT=`<div class="note-detail-geo-map note-detail-printable">
|
||
<style>
|
||
.leaflet-pane {
|
||
z-index: 1;
|
||
}
|
||
|
||
.geo-map-container.placing-note {
|
||
cursor: crosshair;
|
||
}
|
||
|
||
.geo-map-container .marker-pin {
|
||
position: relative;
|
||
}
|
||
|
||
.geo-map-container .leaflet-div-icon {
|
||
position: relative;
|
||
background: transparent;
|
||
border: 0;
|
||
overflow: visible;
|
||
}
|
||
|
||
.geo-map-container .leaflet-div-icon .icon-shadow {
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
z-index: -1;
|
||
}
|
||
|
||
.geo-map-container .leaflet-div-icon .bx {
|
||
position: absolute;
|
||
top: 3px;
|
||
left: 2px;
|
||
background-color: white;
|
||
color: black;
|
||
padding: 2px;
|
||
border-radius: 50%;
|
||
font-size: 17px;
|
||
}
|
||
|
||
.geo-map-container .leaflet-div-icon .title-label {
|
||
display: block;
|
||
position: absolute;
|
||
top: 100%;
|
||
left: 50%;
|
||
transform: translateX(-50%);
|
||
font-size: 0.75rem;
|
||
height: 1rem;
|
||
color: black;
|
||
width: 100px;
|
||
text-align: center;
|
||
text-overflow: ellipsis;
|
||
text-shadow: -1px -1px 0 white, 1px -1px 0 white, -1px 1px 0 white, 1px 1px 0 white;
|
||
white-space: no-wrap;
|
||
overflow: hidden;
|
||
}
|
||
</style>
|
||
</div>`,Uc="geolocation",FT="bx bx-pin",WT=[3.878638227135724,446.6630455551659],HT=2;class VT extends Ue{geoMapWidget;_state;L;currentMarkerData;currentTrackData;gpxLoaded;ignoreNextZoomEvent;static getType(){return"geoMap"}constructor(){super(),this.geoMapWidget=new OT("type",t=>this.#t(t)),this.currentMarkerData={},this.currentTrackData={},this._state=0,this.child(this.geoMapWidget)}doRender(){super.doRender(),this.$widget=$(zT),this.$widget.append(this.geoMapWidget.render())}async#t(t){this.L=t;const e=this.geoMapWidget.map;if(!e)throw new Error(m("geo-map.unable-to-load-map"));this.#i(),await this.#e(),setTimeout(()=>{e.invalidateSize()},100);const i=()=>this.spacedUpdate.scheduleUpdate();e.on("moveend",i),e.on("zoomend",i),e.on("click",n=>this.#r(n)),Sr&&e.on("zoom",()=>{this.ignoreNextZoomEvent||this.triggerCommand("refreshTouchBar"),this.ignoreNextZoomEvent=!1})}async#i(){const t=this.geoMapWidget.map;if(!t||!this.note)return;const e=await this.note.getBlob();let i={};e&&e.content&&(i=JSON.parse(e.content));const n=i.view?.center??WT,s=i.view?.zoom??HT;t.setView(n,s)}async#e(){if(!this.note)return;for(const e of Object.values(this.currentMarkerData))e.remove();for(const e of Object.values(this.currentTrackData))e.remove();this.currentMarkerData={};const t=await this.note.getChildNotes();for(const e of t){if(e.mime==="application/gpx+xml"){this.#o(e);continue}const i=e.getAttributeValue("label",Uc);i&&this.#n(e,i)}}async#o(t){if(!this.L||!this.geoMapWidget.map)return;this.gpxLoaded||(await Z(()=>import("./gpx.js"),[],import.meta.url),this.gpxLoaded=!0);const e=await pt.get(`notes/${t.noteId}/open`,void 0,!0);let i;e instanceof Uint8Array?i=new TextDecoder().decode(e):i=e;const n=new this.L.GPX(i,{markers:{startIcon:this.#s(t.getIcon(),t.getColorClass(),t.title),endIcon:this.#s("bxs-flag-checkered"),wptIcons:{"":this.#s("bx bx-pin")}},polyline_options:{color:t.getLabelValue("color")??"blue"}});n.addTo(this.geoMapWidget.map),this.currentTrackData[t.noteId]=n}#n(t,e){const i=this.geoMapWidget.map;if(!i)return;const[n,s]=e.split(",",2).map(p=>parseFloat(p)),a=this.L,l=this.#s(t.getIcon(),t.getColorClass(),t.title),c=a.marker(a.latLng(n,s),{icon:l,draggable:!0,autoPan:!0,autoPanSpeed:5}).addTo(i).on("moveend",p=>{this.moveMarker(t.noteId,p.target.getLatLng())});c.on("mousedown",({originalEvent:p})=>{if(p.button===1){const v=this.hoistedNoteId;return Pt.tabManager.openInNewTab(t.noteId,v),!0}}),c.on("contextmenu",p=>{DT(t.noteId,p.originalEvent)});const u=c.getElement();if(u){const p=$(u);p.attr("data-href",`#${t.noteId}`),gb.setupElementTooltip($(p))}this.currentMarkerData[t.noteId]=c}#s(t,e,i){return this.L.divIcon({html:` <img class="icon" src="${RT}" />
|
||
<img class="icon-shadow" src="${BT}" />
|
||
<span class="bx ${t} ${e??""}"></span>
|
||
<span class="title-label">${i??""}</span>`,iconSize:[25,41],iconAnchor:[12,41]})}#a(t){this._state=t,this.geoMapWidget.$container.toggleClass("placing-note",t===1),Sr&&this.triggerCommand("refreshTouchBar")}async#r(t){if(this._state!==1)return;ft.closePersistent("geo-new-note");const e=await Me.prompt({message:m("relation_map.enter_title_of_new_note"),defaultValue:m("relation_map.default_new_note_title")});if(e?.trim()){const{note:i}=await pt.post(`notes/${this.noteId}/children?target=into`,{title:e,content:"",type:"text"});Be.setLabel(i.noteId,"iconClass",FT),this.moveMarker(i.noteId,t.latlng)}this.#a(0)}async moveMarker(t,e){const i=e?[e.lat,e.lng].join(","):"";await Be.setLabel(t,Uc,i)}getData(){const t=this.geoMapWidget.map;if(!t)return;const e={view:{center:t.getBounds().getCenter(),zoom:t.getZoom()}};return{content:JSON.stringify(e)}}async geoMapCreateChildNoteEvent({ntxId:t}){if(!this.isNoteContext(t))return;ft.showPersistent({icon:"plus",id:"geo-new-note",title:"New note",message:m("geo-map.create-child-note-instruction")}),this.#a(1);const e=i=>{i.key==="Escape"&&(this.#a(0),window.removeEventListener("keydown",e),ft.closePersistent("geo-new-note"))};window.addEventListener("keydown",e)}async doRefresh(t){await this.geoMapWidget.refresh(),this.#i(),await this.#e()}entitiesReloadedEvent({loadResults:t}){if(t.getBranchRows().find(i=>i.parentNoteId===this.noteId)){this.#e();return}t.getAttributeRows().find(i=>[Uc,"color"].includes(i.name??""))&&this.#e()}openGeoLocationEvent({noteId:t,event:e}){if(!this.currentMarkerData[t])return;const n=this.currentMarkerData[t].getLatLng(),s=`geo:${n.lat},${n.lng}`;Pe.goToLinkExt(e,s)}deleteFromMapEvent({noteId:t}){this.moveMarker(t,null)}buildTouchBarCommand({TouchBar:t}){const e=this.geoMapWidget.map,i=this;if(e)return[new t.TouchBarSlider({label:"Zoom",value:e.getZoom(),minValue:e.getMinZoom(),maxValue:e.getMaxZoom(),change(n){i.ignoreNextZoomEvent=!0,e.setZoom(n)}}),new t.TouchBarButton({label:"New geo note",click:()=>this.triggerCommand("geoMapCreateChildNote",{ntxId:this.ntxId}),enabled:this._state===0})]}}const UT=`<button class="button-widget bx"
|
||
data-bs-toggle="tooltip"
|
||
title=""></button>`;class Qv extends hi{settings;tooltip;isEnabled(){return!0}doRender(){this.$widget=$(UT),this.tooltip=new As(this.$widget[0],{html:!0,title:()=>this.getTitle()||"",trigger:"hover",placement:this.settings.titlePlacement,fallbackPlacements:[this.settings.titlePlacement]}),this.settings.onContextMenu&&this.$widget.on("contextmenu",t=>(this.tooltip.hide(),this.settings.onContextMenu&&this.settings.onContextMenu(t),!1)),super.doRender()}getTitle(){return typeof this.settings.title=="function"?this.settings.title():this.settings.title}refreshIcon(){for(const e of this.$widget[0].classList)e.startsWith("bx-")&&this.$widget.removeClass(e);const t=typeof this.settings.icon=="function"?this.settings.icon():this.settings.icon;t&&this.$widget.addClass(t)}initialRenderCompleteEvent(){this.refreshIcon()}icon(t){return this.settings.icon=t,this}title(t){return this.settings.title=t,this}titlePlacement(t){return this.settings.titlePlacement=t,this}onContextMenu(t){return this.settings.onContextMenu=t,this}}class Wo extends Qv{constructor(){super(),this.settings={titlePlacement:"right",title:null,icon:null,onContextMenu:null}}doRender(){super.doRender(),this.settings.onClick?this.$widget.on("click",t=>{this.$widget.tooltip("hide"),this.settings.onClick&&this.settings.onClick(this,t)}):console.warn(m("onclick_button.no_click_handler",{componentId:this.componentId}),this.settings),this.settings.onAuxClick&&this.$widget.on("auxclick",t=>{this.$widget.tooltip("hide"),this.settings.onAuxClick&&this.settings.onAuxClick(this,t)})}onClick(t){return this.settings.onClick=t,this}onAuxClick(t){return this.settings.onAuxClick=t,this}}var Gi=typeof window<"u"?window:null,Bh=Gi===null,Rr=Bh?void 0:Gi.document,hn="addEventListener",un="removeEventListener",jc="getBoundingClientRect",hr="_a",pn="_b",Jn="_c",Wa="horizontal",fn=function(){return!1},jT=Bh?"calc":["","-webkit-","-moz-","-o-"].filter(function(o){var t=Rr.createElement("div");return t.style.cssText="width:"+o+"calc(9px)",!!t.style.length}).shift()+"calc",Xv=function(o){return typeof o=="string"||o instanceof String},wf=function(o){if(Xv(o)){var t=Rr.querySelector(o);if(!t)throw new Error("Selector "+o+" did not match a DOM element");return t}return o},pi=function(o,t,e){var i=o[t];return i!==void 0?i:e},Ha=function(o,t,e,i){if(t){if(i==="end")return 0;if(i==="center")return o/2}else if(e){if(i==="start")return 0;if(i==="center")return o/2}return o},qT=function(o,t){var e=Rr.createElement("div");return e.className="gutter gutter-"+t,e},KT=function(o,t,e){var i={};return Xv(t)?i[o]=t:i[o]=jT+"("+t+"% - "+e+"px)",i},ZT=function(o,t){var e;return e={},e[o]=t+"px",e},zh=function(o,t){if(t===void 0&&(t={}),Bh)return{};var e=o,i,n,s,a,l,c;Array.from&&(e=Array.from(e));var u=wf(e[0]),p=u.parentNode,v=getComputedStyle?getComputedStyle(p):null,x=v?v.flexDirection:null,T=pi(t,"sizes")||e.map(function(){return 100/e.length}),M=pi(t,"minSize",100),P=Array.isArray(M)?M:e.map(function(){return M}),F=pi(t,"maxSize",1/0),R=Array.isArray(F)?F:e.map(function(){return F}),q=pi(t,"expandToMin",!1),H=pi(t,"gutterSize",10),Q=pi(t,"gutterAlign","center"),tt=pi(t,"snapOffset",30),it=Array.isArray(tt)?tt:e.map(function(){return tt}),rt=pi(t,"dragInterval",1),vt=pi(t,"direction",Wa),Dt=pi(t,"cursor",vt===Wa?"col-resize":"row-resize"),jt=pi(t,"gutter",qT),gt=pi(t,"elementStyle",KT),Ct=pi(t,"gutterStyle",ZT);vt===Wa?(i="width",n="clientX",s="left",a="right",l="clientWidth"):vt==="vertical"&&(i="height",n="clientY",s="top",a="bottom",l="clientHeight");function St(S,I,N,B){var V=gt(i,I,N,B);Object.keys(V).forEach(function(G){S.style[G]=V[G]})}function Nt(S,I,N){var B=Ct(i,I,N);Object.keys(B).forEach(function(V){S.style[V]=B[V]})}function Zt(){return c.map(function(S){return S.size})}function re(S){return"touches"in S?S.touches[0][n]:S[n]}function te(S){var I=c[this.a],N=c[this.b],B=I.size+N.size;I.size=S/this.size*B,N.size=B-S/this.size*B,St(I.element,I.size,this[pn],I.i),St(N.element,N.size,this[Jn],N.i)}function ut(S){var I,N=c[this.a],B=c[this.b];this.dragging&&(I=re(S)-this.start+(this[pn]-this.dragOffset),rt>1&&(I=Math.round(I/rt)*rt),I<=N.minSize+N.snapOffset+this[pn]?I=N.minSize+this[pn]:I>=this.size-(B.minSize+B.snapOffset+this[Jn])&&(I=this.size-(B.minSize+this[Jn])),I>=N.maxSize-N.snapOffset+this[pn]?I=N.maxSize+this[pn]:I<=this.size-(B.maxSize-B.snapOffset+this[Jn])&&(I=this.size-(B.maxSize+this[Jn])),te.call(this,I),pi(t,"onDrag",fn)(Zt()))}function bt(){var S=c[this.a].element,I=c[this.b].element,N=S[jc](),B=I[jc]();this.size=N[i]+B[i]+this[pn]+this[Jn],this.start=N[s],this.end=N[a]}function ht(S){if(!getComputedStyle)return null;var I=getComputedStyle(S);if(!I)return null;var N=S[l];return N===0?null:(vt===Wa?N-=parseFloat(I.paddingLeft)+parseFloat(I.paddingRight):N-=parseFloat(I.paddingTop)+parseFloat(I.paddingBottom),N)}function Tt(S){var I=ht(p);if(I===null||P.reduce(function(G,J){return G+J},0)>I)return S;var N=0,B=[],V=S.map(function(G,J){var X=I*G/100,wt=Ha(H,J===0,J===S.length-1,Q),$t=P[J]+wt;return X<$t?(N+=$t-X,B.push(0),$t):(B.push(X-$t),X)});return N===0?S:V.map(function(G,J){var X=G;if(N>0&&B[J]-N>0){var wt=Math.min(N,B[J]-N);N-=wt,X=G-wt}return X/I*100})}function mt(){var S=this,I=c[S.a].element,N=c[S.b].element;S.dragging&&pi(t,"onDragEnd",fn)(Zt()),S.dragging=!1,Gi[un]("mouseup",S.stop),Gi[un]("touchend",S.stop),Gi[un]("touchcancel",S.stop),Gi[un]("mousemove",S.move),Gi[un]("touchmove",S.move),S.stop=null,S.move=null,I[un]("selectstart",fn),I[un]("dragstart",fn),N[un]("selectstart",fn),N[un]("dragstart",fn),I.style.userSelect="",I.style.webkitUserSelect="",I.style.MozUserSelect="",I.style.pointerEvents="",N.style.userSelect="",N.style.webkitUserSelect="",N.style.MozUserSelect="",N.style.pointerEvents="",S.gutter.style.cursor="",S.parent.style.cursor="",Rr.body.style.cursor=""}function At(S){if(!("button"in S&&S.button!==0)){var I=this,N=c[I.a].element,B=c[I.b].element;I.dragging||pi(t,"onDragStart",fn)(Zt()),S.preventDefault(),I.dragging=!0,I.move=ut.bind(I),I.stop=mt.bind(I),Gi[hn]("mouseup",I.stop),Gi[hn]("touchend",I.stop),Gi[hn]("touchcancel",I.stop),Gi[hn]("mousemove",I.move),Gi[hn]("touchmove",I.move),N[hn]("selectstart",fn),N[hn]("dragstart",fn),B[hn]("selectstart",fn),B[hn]("dragstart",fn),N.style.userSelect="none",N.style.webkitUserSelect="none",N.style.MozUserSelect="none",N.style.pointerEvents="none",B.style.userSelect="none",B.style.webkitUserSelect="none",B.style.MozUserSelect="none",B.style.pointerEvents="none",I.gutter.style.cursor=Dt,I.parent.style.cursor=Dt,Rr.body.style.cursor=Dt,bt.call(I),I.dragOffset=re(S)-I.end}}T=Tt(T);var Et=[];c=e.map(function(S,I){var N={element:wf(S),size:T[I],minSize:P[I],maxSize:R[I],snapOffset:it[I],i:I},B;if(I>0&&(B={a:I-1,b:I,dragging:!1,direction:vt,parent:p},B[pn]=Ha(H,I-1===0,!1,Q),B[Jn]=Ha(H,!1,I===e.length-1,Q),x==="row-reverse"||x==="column-reverse")){var V=B.a;B.a=B.b,B.b=V}if(I>0){var G=jt(I,vt,N.element);Nt(G,H,I),B[hr]=At.bind(B),G[hn]("mousedown",B[hr]),G[hn]("touchstart",B[hr]),p.insertBefore(G,N.element),B.gutter=G}return St(N.element,N.size,Ha(H,I===0,I===e.length-1,Q),I),I>0&&Et.push(B),N});function dt(S){var I=S.i===Et.length,N=I?Et[S.i-1]:Et[S.i];bt.call(N);var B=I?N.size-S.minSize-N[Jn]:S.minSize+N[pn];te.call(N,B)}c.forEach(function(S){var I=S.element[jc]()[i];I<S.minSize&&(q?dt(S):S.minSize=I)});function b(S){var I=Tt(S);I.forEach(function(N,B){if(B>0){var V=Et[B-1],G=c[V.a],J=c[V.b];G.size=I[B-1],J.size=N,St(G.element,G.size,V[pn],G.i),St(J.element,J.size,V[Jn],J.i)}})}function k(S,I){Et.forEach(function(N){if(I!==!0?N.parent.removeChild(N.gutter):(N.gutter[un]("mousedown",N[hr]),N.gutter[un]("touchstart",N[hr])),S!==!0){var B=gt(i,N.a.size,N[pn]);Object.keys(B).forEach(function(V){c[N.a].element.style[V]="",c[N.b].element.style[V]=""})}})}return{setSizes:b,getSizes:Zt,collapse:function(I){dt(c[I])},destroy:k,parent:p,pairs:Et}};const Fh=5;let fo,qc,Va,Ua,mo,ja;function GT(o){Ua&&(Ua.destroy(),Ua=null),$("#left-pane").toggle(o),Va=Va??Qt.get("layoutOrientation"),qc=qc??(Va==="vertical"&&$("#launcher-pane").outerWidth()||0);const t=qc/window.innerWidth*100;if(!o){$("#rest-pane").css("width",Va==="vertical"?`${100-t}%`:"100%");return}fo=fo??Qt.getInt("leftPaneWidth")??0,(!fo||fo<5)&&(fo=5);const e=100-fo-t;o&&requestAnimationFrame(()=>{Ua=zh(["#left-pane","#rest-pane"],{sizes:[fo,e],gutterSize:Fh,minSize:[150,300],onDragEnd:i=>{fo=Math.round(i[0]),Qt.save("leftPaneWidth",Math.round(i[0]))}})})}function YT(){ja&&(ja.destroy(),ja=null);const o=$("#right-pane").is(":visible");if(!o){$("#center-pane").css("width","100%");return}mo=mo??Qt.getInt("rightPaneWidth")??0,(!mo||mo<5)&&(mo=5),o&&(ja=zh(["#center-pane","#right-pane"],{sizes:[100-mo,mo],gutterSize:Fh,minSize:[300,180],onDragEnd:t=>{mo=Math.round(t[1]),Qt.save("rightPaneWidth",Math.round(t[1]))}}))}const BA={setupLeftPaneResizer:GT,setupRightPaneResizer:YT},JT=`<div class="note-detail-split note-detail-printable">
|
||
<div class="note-detail-split-editor-col">
|
||
<div class="note-detail-split-editor"></div>
|
||
<div class="admonition caution note-detail-error-container hidden-ext"></div>
|
||
</div>
|
||
<div class="note-detail-split-preview-col">
|
||
<div class="note-detail-split-preview"></div>
|
||
<div class="btn-group btn-group-sm map-type-switcher content-floating-buttons preview-buttons bottom-right" role="group"></div>
|
||
</div>
|
||
|
||
<style>
|
||
.note-detail-split {
|
||
display: flex;
|
||
height: 100%;
|
||
}
|
||
|
||
.note-detail-split-editor-col {
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.note-detail-split-preview-col {
|
||
position: relative;
|
||
}
|
||
|
||
.note-detail-split .note-detail-split-editor {
|
||
width: 100%;
|
||
flex-grow: 1;
|
||
}
|
||
|
||
.note-detail-split .note-detail-split-editor .note-detail-code {
|
||
contain: size !important;
|
||
}
|
||
|
||
.note-detail-split .note-detail-error-container {
|
||
font-family: var(--monospace-font-family);
|
||
margin: 5px;
|
||
white-space: pre-wrap;
|
||
font-size: 0.85em;
|
||
}
|
||
|
||
.note-detail-split .note-detail-split-preview {
|
||
transition: opacity 250ms ease-in-out;
|
||
height: 100%;
|
||
}
|
||
|
||
.note-detail-split .note-detail-split-preview.on-error {
|
||
opacity: 0.5;
|
||
}
|
||
|
||
/* Horizontal layout */
|
||
|
||
.note-detail-split.split-horizontal > .note-detail-split-preview-col {
|
||
border-left: 1px solid var(--main-border-color);
|
||
}
|
||
|
||
.note-detail-split.split-horizontal > .note-detail-split-editor-col,
|
||
.note-detail-split.split-horizontal > .note-detail-split-preview-col {
|
||
height: 100%;
|
||
width: 50%;
|
||
}
|
||
|
||
.note-detail-split.split-horizontal .note-detail-split-preview {
|
||
height: 100%;
|
||
}
|
||
|
||
/* Vertical layout */
|
||
|
||
.note-detail-split.split-vertical {
|
||
flex-direction: column;
|
||
}
|
||
|
||
.note-detail-split.split-vertical > .note-detail-split-editor-col,
|
||
.note-detail-split.split-vertical > .note-detail-split-preview-col {
|
||
width: 100%;
|
||
height: 50%;
|
||
}
|
||
|
||
.note-detail-split.split-vertical > .note-detail-split-editor-col {
|
||
border-top: 1px solid var(--main-border-color);
|
||
}
|
||
|
||
.note-detail-split.split-vertical .note-detail-split-preview-col {
|
||
order: -1;
|
||
}
|
||
|
||
/* Read-only view */
|
||
|
||
.note-detail-split.split-read-only .note-detail-split-preview-col {
|
||
width: 100%;
|
||
}
|
||
</style>
|
||
</div>
|
||
`;class QT extends Ue{splitInstance;$preview;$editorCol;$previewCol;$editor;$errorContainer;editorTypeWidget;layoutOrientation;isReadOnly;constructor(){super(),this.editorTypeWidget=new Kv,this.editorTypeWidget.updateBackgroundColor=()=>{},this.editorTypeWidget.isEnabled=()=>!0;const t=this.editorTypeWidget.getExtraOpts();this.editorTypeWidget.getExtraOpts=()=>({...t,...this.buildEditorExtraOptions()})}doRender(){this.$widget=$(JT),this.$previewCol=this.$widget.find(".note-detail-split-preview-col"),this.$preview=this.$widget.find(".note-detail-split-preview"),this.$editorCol=this.$widget.find(".note-detail-split-editor-col"),this.$editor=this.$widget.find(".note-detail-split-editor"),this.$editor.append(this.editorTypeWidget.render()),this.$errorContainer=this.$widget.find(".note-detail-error-container"),this.#t();const t=this.$previewCol.find(".preview-buttons"),e=this.buildPreviewButtons();t.toggle(e.length>0);for(const i of e){const n=i.render();n.removeClass("button-widget").addClass("btn").addClass("tn-tool-button"),t.append(n),i.refreshIcon()}super.doRender()}cleanup(){this.#e(),this.editorTypeWidget.cleanup()}async doRefresh(t){this.#t(),this.isReadOnly||(await this.editorTypeWidget.initialized,this.editorTypeWidget.noteContext=this.noteContext,this.editorTypeWidget.spacedUpdate=this.spacedUpdate,this.editorTypeWidget.doRefresh(t))}#t(){const t=this.note?.hasLabel("readOnly");this.isReadOnly!==t&&this.$editorCol.toggle(!t);const e=ct.isMobile()?"vertical":Qt.get("splitEditorOrientation")??"horizontal";(this.layoutOrientation!==e||this.isReadOnly!==t)&&(this.$widget.toggleClass("split-horizontal",!t&&e==="horizontal").toggleClass("split-vertical",!t&&e==="vertical").toggleClass("split-read-only",t),this.layoutOrientation=e,this.isReadOnly=t,this.#e()),this.splitInstance||this.#i()}#i(){if(!ct.isDesktop())return;let t=[this.$editorCol[0],this.$previewCol[0]];this.layoutOrientation==="vertical"&&t.reverse(),this.splitInstance?.destroy(),this.isReadOnly?this.splitInstance=void 0:this.splitInstance=zh(t,{sizes:[50,50],direction:this.layoutOrientation,gutterSize:Fh,...this.buildSplitExtraOptions()})}#e(){this.splitInstance?.destroy(),this.splitInstance=void 0}buildSplitExtraOptions(){return{}}buildEditorExtraOptions(){return{lineWrapping:!1}}buildPreviewButtons(){return[]}setError(t){this.$errorContainer.toggleClass("hidden-ext",!t),this.$preview.toggleClass("on-error",!!t),this.$errorContainer.text(t??"")}getData(){return this.editorTypeWidget.getData()}entitiesReloadedEvent({loadResults:t}){t.isOptionReloaded("splitEditorOrientation")&&this.refresh()}}class XT extends QT{$renderContainer;zoomHandler;zoomInstance;svg;constructor(){super(),this.zoomHandler=()=>{this.zoomInstance&&(this.zoomInstance.resize(),this.zoomInstance.fit(),this.zoomInstance.center())}}doRender(){super.doRender(),this.$renderContainer=$("<div>").addClass("render-container").css("height","100%"),this.$preview.append(this.$renderContainer),$(window).on("resize",this.zoomHandler)}async doRefresh(t){super.doRefresh(t);const i=(await t?.getBlob())?.content||"";this.onContentChanged(i,!0),this.note?.getAttachments().then(n=>{const s=`${this.attachmentName}.svg`;n.find(a=>a.title===s)||this.#t()})}getData(){const t=super.getData();return this.onContentChanged(t.content,!1),this.#t(),t}async onContentChanged(t,e){if(!this.note)return;let i="";try{if(i=await this.renderSvg(t),this.setError(null),i===this.svg)return;this.svg=i,this.$renderContainer.html(i)}catch(n){this.setError(n?.message)}await this.#i(!e)}#t(){const t={role:"image",title:`${this.attachmentName}.svg`,mime:"image/svg+xml",content:this.svg,position:0};pt.post(`notes/${this.noteId}/attachments?matchBy=title`,t)}cleanup(){this.#e(),$(window).off("resize",this.zoomHandler),super.cleanup()}async#i(t){let e=null,i=null;t&&this.zoomInstance&&(e=this.zoomInstance.getPan(),i=this.zoomInstance.getZoom(),this.#e());const n=this.$renderContainer.find("svg");if(n.attr("width","100%").attr("height","100%").css("max-width","100%"),!n.length)return;const s=(await Z(async()=>{const{default:l}=await import("./svg-pan-zoom.js").then(c=>c.s);return{default:l}},__vite__mapDeps([80,5]),import.meta.url)).default,a=s(n[0],{zoomEnabled:!0,controlIconsEnabled:!1});t&&e&&i?(a.zoom(i),a.pan(e)):(a.resize(),a.center(),a.fit()),this.zoomInstance=a}buildSplitExtraOptions(){return{onDrag:()=>this.zoomHandler?.()}}buildPreviewButtons(){return[new Wo().icon("bx-zoom-in").title(m("relation_map_buttons.zoom_in_title")).titlePlacement("top").onClick(()=>this.zoomInstance?.zoomIn()),new Wo().icon("bx-zoom-out").title(m("relation_map_buttons.zoom_out_title")).titlePlacement("top").onClick(()=>this.zoomInstance?.zoomOut()),new Wo().icon("bx-crop").title(m("relation_map_buttons.reset_pan_zoom_title")).titlePlacement("top").onClick(()=>this.zoomHandler())]}#e(){this.zoomInstance&&(this.zoomInstance.destroy(),this.zoomInstance=void 0)}async exportSvgEvent({ntxId:t}){!this.isNoteContext(t)||this.note?.type!=="mermaid"||!this.svg||ct.downloadSvg(this.note.title,this.svg)}async exportPngEvent({ntxId:t}){if(console.log("Export to PNG",this.noteContext?.noteId,t,this.svg),!this.isNoteContext(t)||this.note?.type!=="mermaid"||!this.svg){console.log("Return");return}try{await ct.downloadSvgAsPng(this.note.title,this.svg)}catch(e){console.warn(e),ft.showError(m("svg.export_to_png"))}}}let _f=1;class tE extends XT{static getType(){return"mermaid"}get attachmentName(){return"mermaid-export"}async renderSvg(t){const e=(await Z(async()=>{const{default:n}=await import("./mermaid.core.js").then(s=>s.bh);return{default:n}},__vite__mapDeps([14,2,4,5,15,16,17,12,3]),import.meta.url)).default;await vb(e,t),e.initialize({startOnLoad:!1,...Qd()}),_f++;const{svg:i}=await e.render(`mermaid-graph-${_f}`,t);return yb(i)}}function ty(o){if(!o)return"";const t=[];let e=o.replace(/<div class=['"](thinking-process|reasoning-process)['"][\s\S]*?<\/div>/g,n=>{const s=`__THINKING_BLOCK_${t.length}__`;return t.push(n),s});const i=wb(e,{breaks:!0,gfm:!0,silent:!0});return typeof i=="string"?e=i:(console.warn("Marked returned a promise unexpectedly"),e=o),t.forEach((n,s)=>{e=e.replace(`__THINKING_BLOCK_${s}__`,n)}),e}function eE(o){Yd($(o))}const iE=`
|
||
<div class="note-context-chat h-100 w-100 d-flex flex-column">
|
||
<!-- Move validation warning outside the card with better styling -->
|
||
<div class="provider-validation-warning alert alert-warning m-2 border-left border-warning" style="display: none; padding-left: 15px; border-left: 4px solid #ffc107; background-color: rgba(255, 248, 230, 0.9); font-size: 0.9rem; box-shadow: 0 2px 5px rgba(0,0,0,0.05);"></div>
|
||
|
||
<div class="note-context-chat-container flex-grow-1 overflow-auto p-3">
|
||
<div class="note-context-chat-messages"></div>
|
||
|
||
<!-- Thinking display area -->
|
||
<div class="llm-thinking-container" style="display: none;">
|
||
<div class="thinking-bubble">
|
||
<div class="thinking-header d-flex align-items-center">
|
||
<div class="thinking-dots">
|
||
<span></span>
|
||
<span></span>
|
||
<span></span>
|
||
</div>
|
||
<span class="thinking-label ms-2 text-muted small">AI is thinking...</span>
|
||
<button type="button" class="btn btn-sm btn-link p-0 ms-auto thinking-toggle" title="Toggle thinking details">
|
||
<i class="bx bx-chevron-down"></i>
|
||
</button>
|
||
</div>
|
||
<div class="thinking-content" style="display: none;">
|
||
<div class="thinking-text"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="loading-indicator" style="display: none;">
|
||
<div class="spinner-border spinner-border-sm text-primary" role="status">
|
||
<span class="visually-hidden">Loading...</span>
|
||
</div>
|
||
<span class="ms-2">${m("ai_llm.agent.processing")}</span>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="sources-container p-2 border-top" style="display: none;">
|
||
<h6 class="m-0 p-1 d-flex align-items-center">
|
||
<i class="bx bx-link-alt me-1"></i> ${m("ai_llm.sources")}
|
||
<span class="badge bg-primary rounded-pill ms-2 sources-count"></span>
|
||
</h6>
|
||
<div class="sources-list mt-2"></div>
|
||
</div>
|
||
|
||
<form class="note-context-chat-form d-flex flex-column border-top p-2">
|
||
<div class="d-flex chat-input-container mb-2">
|
||
<div
|
||
class="form-control note-context-chat-input flex-grow-1"
|
||
style="min-height: 60px; max-height: 200px; overflow-y: auto;"
|
||
data-placeholder="${m("ai_llm.enter_message")}"
|
||
></div>
|
||
<button type="submit" class="btn btn-primary note-context-chat-send-button ms-2 d-flex align-items-center justify-content-center">
|
||
<i class="bx bx-send"></i>
|
||
</button>
|
||
</div>
|
||
<div class="d-flex align-items-center context-option-container mt-1 justify-content-end">
|
||
<small class="text-muted me-auto fst-italic">Options:</small>
|
||
<div class="form-check form-switch me-3 small">
|
||
<input class="form-check-input use-advanced-context-checkbox" type="checkbox" id="useEnhancedContext" checked>
|
||
<label class="form-check-label small" for="useEnhancedContext" title="${m("ai.enhanced_context_description")}">
|
||
${m("ai_llm.use_enhanced_context")}
|
||
<i class="bx bx-info-circle small text-muted"></i>
|
||
</label>
|
||
</div>
|
||
<div class="form-check form-switch small">
|
||
<input class="form-check-input show-thinking-checkbox" type="checkbox" id="showThinking">
|
||
<label class="form-check-label small" for="showThinking" title="${m("ai.show_thinking_description")}">
|
||
${m("ai_llm.show_thinking")}
|
||
<i class="bx bx-info-circle small text-muted"></i>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
`;function nE(o,t,e,i){const n=document.createElement("div");n.className=`chat-message ${e}-message mb-3 d-flex`;const s=document.createElement("div");s.className="message-avatar d-flex align-items-center justify-content-center me-2",e==="user"?(s.innerHTML='<i class="bx bx-user"></i>',s.classList.add("user-avatar")):(s.innerHTML='<i class="bx bx-bot"></i>',s.classList.add("assistant-avatar"));const a=document.createElement("div");a.className="message-content p-3 rounded flex-grow-1",e==="user"?a.classList.add("user-content","bg-light"):a.classList.add("assistant-content"),a.innerHTML=ty(i),n.appendChild(s),n.appendChild(a),o.appendChild(n),eE(a),t.scrollTop=t.scrollHeight}function oE(o,t,e,i,n){o.innerHTML="",e.textContent=i.length.toString(),i.forEach(s=>{const a=document.createElement("div");a.className="source-item p-2 mb-1 border rounded d-flex align-items-center",a.innerHTML=`
|
||
<div class="d-flex align-items-center w-100">
|
||
<a href="#root/${s.noteId}"
|
||
data-note-id="${s.noteId}"
|
||
class="source-link text-truncate d-flex align-items-center"
|
||
title="Open note: ${s.title}">
|
||
<i class="bx bx-file-blank me-1"></i>
|
||
<span class="source-title">${s.title}</span>
|
||
</a>
|
||
</div>`,a.querySelector(".source-link")?.addEventListener("click",l=>(l.preventDefault(),l.stopPropagation(),n(s.noteId),!1)),o.appendChild(a)}),t.style.display="block"}function sE(o){o.style.display="none"}function xf(o){const t=`ui-${Date.now()}`;console.log(`[${t}] Showing loading indicator`);try{o.style.display="flex";const e=o.offsetHeight;console.log(`[${t}] Loading indicator initialized`)}catch(e){console.error(`[${t}] Error showing loading indicator:`,e)}}function Kc(o){const t=`ui-${Date.now()}`;console.log(`[${t}] Hiding loading indicator`);try{o.style.display="none";const e=o.offsetHeight;console.log(`[${t}] Loading indicator hidden`)}catch(e){console.error(`[${t}] Error hiding loading indicator:`,e)}}async function rE(o){try{const t=await pt.post("llm/chat",{title:"Note Chat",currentNoteId:o});if(t&&t.id)return t.id}catch(t){console.error("Failed to create chat session:",t)}return null}async function aE(o,t,e,i,n,s,a){return new Promise((l,c)=>{let u="",p=null,v=null,x=null,T=!1,M=null;const P=`llm-stream-${Date.now()}-${Math.floor(Math.random()*1e3)}`;console.log(`[${P}] Setting up WebSocket streaming for chat note ${o}`),(async()=>{try{const R=await pt.post(`llm/chat/${o}/messages/stream`,{content:t.content,useAdvancedContext:t.useAdvancedContext,showThinking:t.showThinking,options:{temperature:.7,maxTokens:2e3}});if(!R||!R.success){console.error(`[${P}] Failed to initiate streaming`),c(new Error("Failed to initiate streaming"));return}console.log(`[${P}] Streaming initiated successfully`)}catch(R){console.error(`[${P}] Error initiating streaming:`,R),c(R);return}})();const F=()=>{x&&(window.clearTimeout(x),x=null),console.log(`[${P}] Performing final cleanup of event listener`),lE(M),s(),l()};v=window.setTimeout(()=>{T||(console.error(`[${P}] No initial message received within timeout`),F(),c(new Error("No response received from server")))},1e4),M=R=>{const H=R.detail;if(!(!H||H.chatNoteId!==o)){if(x&&(console.log(`[${P}] Cancelling scheduled cleanup due to new message`),window.clearTimeout(x),x=null),console.log(`[${P}] LLM Stream message received: content=${!!H.content}, contentLength=${H.content?.length||0}, thinking=${!!H.thinking}, toolExecution=${!!H.toolExecution}, done=${!!H.done}`),T||(T=!0,console.log(`[${P}] First message received for chat note ${o}`),v!==null&&(window.clearTimeout(v),v=null)),H.error){console.error(`[${P}] Stream error: ${H.error}`),F(),c(new Error(H.error));return}H.thinking&&t.showThinking&&(console.log(`[${P}] Received thinking: ${H.thinking.substring(0,100)}...`),i(H.thinking)),H.toolExecution&&(console.log(`[${P}] Tool execution update:`,H.toolExecution),n(H.toolExecution)),H.content&&(u+=H.content,e(u,H.done||!1),p!==null&&window.clearTimeout(p),p=window.setTimeout(()=>{console.warn(`[${P}] Stream timeout for chat note ${o}`),F(),c(new Error("Stream timeout"))},3e4)),H.done&&(console.log(`[${P}] Stream completed for chat note ${o}, final response: ${u.length} chars`),p!==null&&(window.clearTimeout(p),p=null),x=window.setTimeout(()=>{F()},100))}},window.addEventListener("llm-stream-message",M),console.log(`[${P}] Event listener registered, waiting for messages...`)})}function lE(o){if(o)try{window.removeEventListener("llm-stream-message",o),console.log("Successfully removed event listener")}catch(t){console.error("Error removing event listener:",t)}}async function cE(o,t){try{return await pt.post(`llm/chat/${o}/messages`,{message:t.content,includeContext:t.useAdvancedContext,options:{temperature:.7,maxTokens:2e3}})}catch(e){throw console.error("Error getting direct response:",e),e}}function kf(o){const t=[],e=o.querySelector(".chat-tool-execution");return e&&e.querySelectorAll(".tool-step").forEach(n=>{const s=n.innerHTML;let a="info",l,c="";if(s.includes("bx-code-block"))a="executing",c="Executing tools...";else if(s.includes("bx-terminal")){a="result";const u=s.match(/<span[^>]*>Tool: ([^<]+)<\/span>/);l=u?u[1]:"unknown";const p=n.querySelector(".mt-1.ps-3");c=p?p.innerHTML:""}else if(s.includes("bx-error-circle")){a="error";const u=s.match(/<span[^>]*>Tool: ([^<]+)<\/span>/);l=u?u[1]:"unknown";const p=n.querySelector(".mt-1.ps-3.text-danger");c=p?p.innerHTML:""}else if(s.includes("bx-message-dots"))a="generating",c="Generating response with tool results...";else if(s.includes("bx-loader-alt"))return;t.push({type:a,name:l,content:c})}),t}async function Cf(o){try{if(!Qt.is("aiEnabled")){o.style.display="none";return}const e=Qt.get("aiProviderPrecedence")||"openai,anthropic,ollama";let i=[];if(e)if(e.startsWith("[")&&e.endsWith("]"))try{i=JSON.parse(e)}catch(s){console.error("Error parsing precedence list:",s),i=["openai"]}else e.includes(",")?i=e.split(",").map(s=>s.trim()):i=[e];const n=[];n.push(m("ai_llm.experimental_warning"));for(const s of i)s==="openai"?Qt.get("openaiApiKey")||n.push("OpenAI API key is missing (optional for OpenAI-compatible endpoints)"):s==="anthropic"?Qt.get("anthropicApiKey")||n.push("Anthropic API key is missing"):s==="ollama"&&(Qt.get("ollamaBaseUrl")||n.push("Ollama Base URL is missing"));if(n.length>0){let s='<i class="bx bx-error-circle me-2"></i><strong>AI Provider Configuration Issues</strong>';s+='<ul class="mb-1 ps-4">';for(const a of n)s+=`<li>${a}</li>`;s+="</ul>",s+='<div class="mt-2"><a href="javascript:" class="settings-link btn btn-sm btn-outline-secondary"><i class="bx bx-cog me-1"></i>Open AI Settings</a></div>',o.innerHTML=s,o.style.display="block"}else o.style.display="none"}catch(t){console.error("Error validating providers:",t),o.style.display="none"}}class dE extends ge{noteContextChatMessages;noteContextChatForm;noteContextChatInput;noteContextChatInputEditor;noteContextChatSendButton;chatContainer;loadingIndicator;sourcesList;sourcesContainer;sourcesCount;useAdvancedContextCheckbox;showThinkingCheckbox;validationWarning;thinkingContainer;thinkingBubble;thinkingText;thinkingToggle;noteId=null;currentNoteId=null;_messageHandlerId=null;_messageHandler=null;onSaveData=null;onGetData=null;messages=[];sources=[];metadata={temperature:.7,toolExecutions:[]};getCurrentNoteId(){return this.currentNoteId}setCurrentNoteId(t){this.currentNoteId=t}getMessages(){return this.messages}setMessages(t){this.messages=t}getNoteId(){return this.noteId}setNoteId(t){this.noteId=t}getChatNoteId(){return this.noteId}setChatNoteId(t){this.noteId=t}getNoteContextChatMessages(){return this.noteContextChatMessages}clearNoteContextChatMessages(){this.noteContextChatMessages.innerHTML=""}doRender(){this.$widget=$(iE);const t=this.$widget[0];return this.noteContextChatMessages=t.querySelector(".note-context-chat-messages"),this.noteContextChatForm=t.querySelector(".note-context-chat-form"),this.noteContextChatInput=t.querySelector(".note-context-chat-input"),this.noteContextChatSendButton=t.querySelector(".note-context-chat-send-button"),this.chatContainer=t.querySelector(".note-context-chat-container"),this.loadingIndicator=t.querySelector(".loading-indicator"),this.sourcesList=t.querySelector(".sources-list"),this.sourcesContainer=t.querySelector(".sources-container"),this.sourcesCount=t.querySelector(".sources-count"),this.useAdvancedContextCheckbox=t.querySelector(".use-advanced-context-checkbox"),this.showThinkingCheckbox=t.querySelector(".show-thinking-checkbox"),this.validationWarning=t.querySelector(".provider-validation-warning"),this.thinkingContainer=t.querySelector(".llm-thinking-container"),this.thinkingBubble=t.querySelector(".thinking-bubble"),this.thinkingText=t.querySelector(".thinking-text"),this.thinkingToggle=t.querySelector(".thinking-toggle"),this.validationWarning.addEventListener("click",e=>{const i=e.target;(i.classList.contains("settings-link")||i.closest(".settings-link"))&&(console.log("Settings link clicked, navigating to AI settings URL"),window.location.href="#root/_hidden/_options/_optionsAi")}),this.setupThinkingToggle(),this.initializeCKEditor().then(()=>{this.initializeEventListeners()}).catch(e=>{console.error("Failed to initialize CKEditor, falling back to basic event listeners:",e),this.initializeBasicEventListeners()}),this.$widget}async initializeCKEditor(){const t=[{marker:"@",feed:i=>Xe.autocompleteSourceForCKEditor(i),itemRenderer:i=>{const n=i,s=document.createElement("button");return s.innerHTML=`${n.highlightedNotePathTitle} `,s},minimumCharacters:0}];this.noteContextChatInputEditor=await Yc.create(this.noteContextChatInput,{toolbar:{items:[]},placeholder:this.noteContextChatInput.getAttribute("data-placeholder")||"Enter your message...",mention:{feeds:t},licenseKey:"GPL"});const e=this.noteContextChatInputEditor.ui.getEditableElement();e&&(e.style.minHeight="60px",e.style.maxHeight="200px",e.style.overflowY="auto"),this.setupEditorKeyBindings(),console.log("CKEditor initialized successfully for LLM chat input")}initializeBasicEventListeners(){this.noteContextChatForm.addEventListener("submit",t=>{t.preventDefault();const e=this.noteContextChatInput.querySelector("textarea");if(e){const i=e.value;this.sendMessage(i)}})}cleanup(){console.log("LlmChatPanel cleanup called, removing any active WebSocket subscriptions"),this._messageHandler=null,this._messageHandlerId=null,this.noteContextChatInputEditor&&this.noteContextChatInputEditor.destroy().catch(t=>{console.error("Error destroying CKEditor:",t)})}setDataCallbacks(t,e){this.onSaveData=t,this.onGetData=e}async saveCurrentData(){if(this.onSaveData)try{const t=kf(this.noteContextChatMessages);let e=[];this.metadata?.toolExecutions&&Array.isArray(this.metadata.toolExecutions)&&(e=[...this.metadata.toolExecutions],console.log(`Including ${e.length} tool executions from metadata`));const i=t.map(a=>{if(a.type==="tool-execution")try{const l=JSON.parse(a.content);return{id:l.toolCallId||`tool-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,name:l.tool||"unknown",arguments:l.args||{},result:l.result||{},error:l.error,timestamp:new Date().toISOString()}}catch{return{id:`tool-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,name:"unknown",arguments:{},result:a.content,timestamp:new Date().toISOString()}}else if(a.type==="result"&&a.name)return{id:`tool-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,name:a.name,arguments:{},result:a.content,timestamp:new Date().toISOString()};return{id:`tool-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,name:"unknown",arguments:{},result:"Unrecognized tool step",timestamp:new Date().toISOString()}}),n=new Set(e.map(a=>a.id));for(const a of i)n.has(a.id)||(e.push(a),n.add(a.id));if(!this.noteId){console.warn("Cannot save chat data: no noteId available");return}const s={messages:this.messages,noteId:this.noteId,chatNoteId:this.noteId,toolSteps:t,sources:this.sources||[],metadata:{model:this.metadata?.model||void 0,provider:this.metadata?.provider||void 0,temperature:this.metadata?.temperature||.7,lastUpdated:new Date().toISOString(),toolExecutions:e}};console.log(`Saving chat data with noteId: ${this.noteId}, ${t.length} tool steps, ${this.sources?.length||0} sources, ${e.length} tool executions`),await this.onSaveData(s)}catch(t){console.error("Error saving chat data:",t)}}async saveCurrentDataToSpecificNote(t){if(!this.onSaveData||!t){console.warn("Cannot save chat data: no saveData callback or no targetNoteId available");return}try{const e=kf(this.noteContextChatMessages);let i=[];this.metadata?.toolExecutions&&Array.isArray(this.metadata.toolExecutions)&&(i=[...this.metadata.toolExecutions],console.log(`Including ${i.length} tool executions from metadata`));const n=e.map(l=>{if(l.type==="tool-execution")try{const c=JSON.parse(l.content);return{id:c.toolCallId||`tool-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,name:c.tool||"unknown",arguments:c.args||{},result:c.result||{},error:c.error,timestamp:new Date().toISOString()}}catch{return{id:`tool-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,name:"unknown",arguments:{},result:l.content,timestamp:new Date().toISOString()}}else if(l.type==="result"&&l.name)return{id:`tool-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,name:l.name,arguments:{},result:l.content,timestamp:new Date().toISOString()};return{id:`tool-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,name:"unknown",arguments:{},result:"Unrecognized tool step",timestamp:new Date().toISOString()}}),s=new Set(i.map(l=>l.id));for(const l of n)s.has(l.id)||(i.push(l),s.add(l.id));const a={messages:this.messages,noteId:t,chatNoteId:t,toolSteps:e,sources:this.sources||[],metadata:{model:this.metadata?.model||void 0,provider:this.metadata?.provider||void 0,temperature:this.metadata?.temperature||.7,lastUpdated:new Date().toISOString(),toolExecutions:i}};console.log(`Saving chat data to specific note ${t}, ${e.length} tool steps, ${this.sources?.length||0} sources, ${i.length} tool executions`),await this.onSaveData(a)}catch(e){console.error("Error saving chat data to specific note:",e)}}async loadSavedData(){if(!this.onGetData)return!1;try{const t=await this.onGetData();if(t?.messages?.length>0){const e=this.messages.length,i=t.messages.length;if(!(i>e||JSON.stringify(this.messages)!==JSON.stringify(t.messages)))return console.log("No new content detected, skipping UI rebuild"),!0;console.log(`Loading saved data: ${e} -> ${i} messages`);const s=i>e&&e>0,a=s?this.chatContainer.scrollTop:0,l=s?this.chatContainer.scrollHeight:0,c=[...this.messages];if(this.messages=t.messages,i>e){const u=t.messages.slice(e);console.log(`Adding ${u.length} new messages to UI`),u.forEach(p=>{const v=p.role;this.addMessageToChat(v,p.content)})}else console.log("Message content changed, rebuilding UI"),this.noteContextChatMessages.innerHTML="",this.messages.forEach(u=>{const p=u.role;this.addMessageToChat(p,u.content)});if(t.toolSteps&&Array.isArray(t.toolSteps)&&t.toolSteps.length>0&&(console.log(`Restoring ${t.toolSteps.length} saved tool steps`),this.restoreInChatToolSteps(t.toolSteps)),t.sources&&Array.isArray(t.sources)&&(this.sources=t.sources,console.log(`Loaded ${this.sources.length} sources from saved data`),this.sources.length>0&&this.showSources(this.sources)),t.metadata&&(this.metadata={...this.metadata,...t.metadata},t.metadata.toolExecutions&&Array.isArray(t.metadata.toolExecutions)&&(console.log(`Loaded ${t.metadata.toolExecutions.length} tool executions from saved data`),this.metadata.toolExecutions||(this.metadata.toolExecutions=[]),this.metadata.toolExecutions=t.metadata.toolExecutions),console.log("Loaded metadata from saved data:",this.metadata)),t.noteId)console.log(`Using noteId as Chat Note ID: ${t.noteId}`),this.noteId=t.noteId;else return console.log("No noteId found in saved data, cannot load chat session"),!1;if(s){const u=this.chatContainer.scrollHeight,p=u-l,v=a+p;a+this.chatContainer.clientHeight>=l-50?(this.chatContainer.scrollTop=u,console.log("User was at bottom, scrolling to new bottom")):(this.chatContainer.scrollTop=v,console.log(`Preserving scroll position: ${a} -> ${v}`))}return!0}}catch(t){console.error("Failed to load saved chat data",t)}return!1}restoreInChatToolSteps(t){if(!t||t.length===0)return;const e=document.createElement("div");e.className="chat-tool-execution mb-3";const i=this.noteContextChatMessages.querySelector(".assistant-message:last-child");i?this.noteContextChatMessages.insertBefore(e,i):this.noteContextChatMessages.appendChild(e),e.innerHTML=`
|
||
<div class="tool-execution-header d-flex align-items-center p-2 rounded">
|
||
<i class="bx bx-terminal me-2"></i>
|
||
<span class="flex-grow-1 fw-bold">Tool Execution</span>
|
||
<button type="button" class="btn btn-sm btn-link p-0 text-muted tool-execution-toggle" title="Toggle tool execution details">
|
||
<i class="bx bx-chevron-down"></i>
|
||
</button>
|
||
</div>
|
||
<div class="tool-execution-container p-2 rounded mb-2">
|
||
<div class="tool-execution-chat-steps">
|
||
${this.renderToolStepsHtml(t)}
|
||
</div>
|
||
</div>
|
||
`;const n=e.querySelector(".tool-execution-toggle");n&&n.addEventListener("click",()=>{const a=e.querySelector(".tool-execution-container"),l=n.querySelector("i");a&&(a.classList.contains("collapsed")?(a.classList.remove("collapsed"),a.style.display="block",l&&(l.className="bx bx-chevron-down")):(a.classList.add("collapsed"),a.style.display="none",l&&(l.className="bx bx-chevron-right")))});const s=e.querySelector(".tool-execution-header");s&&(s.addEventListener("click",a=>{const l=a.target;l&&!l.closest(".tool-execution-toggle")&&e.querySelector(".tool-execution-toggle")?.dispatchEvent(new Event("click"))}),s.style.cursor="pointer")}renderToolStepsHtml(t){return!t||t.length===0?"":t.map(e=>{let i="bx-info-circle",n="info",s="";return e.type==="executing"?(i="bx-code-block",n="executing",s=`<div>${e.content||"Executing tools..."}</div>`):e.type==="result"?(i="bx-terminal",n="result",s=`
|
||
<div>Tool: <strong>${e.name||"unknown"}</strong></div>
|
||
<div class="mt-1 ps-3">${e.content||""}</div>
|
||
`):e.type==="error"?(i="bx-error-circle",n="error",s=`
|
||
<div>Tool: <strong>${e.name||"unknown"}</strong></div>
|
||
<div class="mt-1 ps-3 text-danger">${e.content||"Error occurred"}</div>
|
||
`):e.type==="generating"&&(i="bx-message-dots",n="generating",s=`<div>${e.content||"Generating response..."}</div>`),`
|
||
<div class="tool-step ${n} p-2 mb-2 rounded">
|
||
<div class="d-flex align-items-center">
|
||
<i class="bx ${i} me-2"></i>
|
||
${s}
|
||
</div>
|
||
</div>
|
||
`}).join("")}async refresh(){if(!this.isVisible())return;await Cf(this.validationWarning);const t=Pt.tabManager.getActiveContext()?.note?.noteId||null;if(this.noteId&&t===this.noteId){console.log(`Refreshing AI Chat note ${this.noteId} - loading saved data`),await this.loadSavedData();return}this.currentNoteId!==t&&(console.log(`Note ID changed from ${this.currentNoteId} to ${t}, resetting chat panel`),this.noteContextChatMessages.innerHTML="",this.messages=[],this.noteId=null,this.hideSources(),this.currentNoteId=t);const e=await this.loadSavedData();(!this.noteId||!e)&&await this.createChatSession()}async createChatSession(){try{const t=this.noteId||this.currentNoteId,e=await rE(t||void 0);if(e)this.noteId=e,console.log(`Created new chat session with noteId: ${this.noteId}`);else throw new Error("Failed to create chat session - no ID returned");await this.saveCurrentData()}catch(t){console.error("Error creating chat session:",t),ft.showError("Failed to create chat session")}}async sendMessage(t){if(!t.trim())return;let e=[],i=t;if(this.noteContextChatInputEditor){const n=this.extractMentionsAndContent(t);e=n.mentions,i=n.content}this.addMessageToChat("user",i),this.messages.push({role:"user",content:i,mentions:e.length>0?e:void 0}),await this.saveCurrentData(),this.noteContextChatInputEditor&&this.noteContextChatInputEditor.setData(""),xf(this.loadingIndicator),this.hideSources();try{const n=this.useAdvancedContextCheckbox.checked,s=this.showThinkingCheckbox.checked;console.log(`Sending message with: useAdvancedContext=${n}, showThinking=${s}, noteId=${this.currentNoteId}, sessionId=${this.noteId}`);const a={content:i,useAdvancedContext:n,showThinking:s,mentions:e.length>0?e:void 0};try{await this.setupStreamingResponse(a)}catch(l){if(console.warn("WebSocket streaming failed, falling back to direct response:",l),!await this.handleDirectResponse(a))throw new Error("Failed to get response from server")}}catch(n){console.error("Error processing user message:",n),ft.showError("Failed to process message"),this.addMessageToChat("assistant","Sorry, I encountered an error processing your message. Please try again."),this.messages.push({role:"assistant",content:"Sorry, I encountered an error processing your message. Please try again."}),await this.saveCurrentData()}}async processUserMessage(t){if(await Cf(this.validationWarning),!this.noteId&&(await this.createChatSession(),!this.noteId)){console.error("Failed to create chat session"),ft.showError("Failed to create chat session");return}this.messages.some(e=>e.role==="user"&&e.content===t)||this.messages.push({role:"user",content:t}),this.noteContextChatInputEditor&&this.noteContextChatInputEditor.setData(""),xf(this.loadingIndicator),this.hideSources();try{const e=this.useAdvancedContextCheckbox.checked,i=this.showThinkingCheckbox.checked;await this.saveCurrentData(),console.log(`Sending message with: useAdvancedContext=${e}, showThinking=${i}, noteId=${this.currentNoteId}, sessionId=${this.noteId}`);const n={content:t,useAdvancedContext:e,showThinking:i};try{await this.setupStreamingResponse(n)}catch(s){if(console.warn("WebSocket streaming failed, falling back to direct response:",s),!await this.handleDirectResponse(n))throw new Error("Failed to get response from server")}await this.saveCurrentData()}catch(e){this.handleError(e),await this.saveCurrentData()}}async handleDirectResponse(t){try{if(!this.noteId)return!1;console.log(`Getting direct response using sessionId: ${this.noteId} (noteId: ${this.noteId})`);const e=await cE(this.noteId,t);return e&&e.content?(e.metadata&&(console.log("Received metadata from response:",e.metadata),this.metadata={...this.metadata,...e.metadata}),e.sources&&e.sources.length>0&&(console.log(`Received ${e.sources.length} sources from response`),this.sources=e.sources,this.showSources(e.sources)),this.processAssistantResponse(e.content,e,this.noteId),Kc(this.loadingIndicator),!0):!1}catch(e){return console.error("Error with direct response:",e),!1}}async processAssistantResponse(t,e,i){this.addMessageToChat("assistant",t),this.messages.push({role:"assistant",content:t,timestamp:new Date}),e?.metadata?.toolExecutions&&(console.log(`Storing ${e.metadata.toolExecutions.length} tool executions from response`),this.metadata.toolExecutions||(this.metadata.toolExecutions=[]),this.metadata.toolExecutions=[...this.metadata.toolExecutions,...e.metadata.toolExecutions]),this.saveCurrentDataToSpecificNote(i||this.noteId).catch(n=>{console.error("Failed to save assistant response to note:",n)})}async setupStreamingResponse(t){if(!this.noteId)throw new Error("No session ID available");console.log(`Setting up streaming response using sessionId: ${this.noteId} (noteId: ${this.noteId})`);const e=[],i=this.noteId;return aE(this.noteId,t,(n,s=!1)=>{this.updateStreamingUI(n,s,i),s&&pt.get(`llm/chat/${this.noteId}`).then(a=>{if(console.log("Got updated session data:",a),a.metadata&&(this.metadata={...this.metadata,...a.metadata}),a.sources&&a.sources.length>0&&(this.sources=a.sources,this.showSources(a.sources)),e.length>0){console.log(`Including ${e.length} cached tool executions in metadata`),this.metadata.toolExecutions||(this.metadata.toolExecutions=[]);const l=new Set((this.metadata.toolExecutions||[]).map(c=>c.id));for(const c of e)l.has(c.id)||(this.metadata.toolExecutions.push(c),l.add(c.id))}console.log("Updated metadata after streaming completion, server should save")}).catch(a=>console.error("Error fetching session data after streaming:",a))},n=>{this.showThinkingState(n)},n=>{if(this.showToolExecutionInfo(n),n&&n.action==="result"&&n.tool){const s={id:n.toolCallId||`tool-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,name:n.tool,arguments:n.args||{},result:n.result||{},error:n.error,timestamp:new Date().toISOString()};e.push(s),this.metadata.toolExecutions||(this.metadata.toolExecutions=[]),this.metadata.toolExecutions.push(s),console.log(`Cached tool execution for ${n.tool} to be saved later`),console.log("Tool execution cached, will be saved by server")}},()=>{Kc(this.loadingIndicator)})}updateStreamingUI(t,e=!1,i){const n=!!this.noteContextChatMessages.querySelector(".assistant-message.streaming");let s;if(n)s=this.noteContextChatMessages.querySelector(".assistant-message.streaming");else{s=document.createElement("div"),s.className="assistant-message message mb-3 streaming",this.noteContextChatMessages.appendChild(s);const l=document.createElement("div");l.className="profile-icon",l.innerHTML='<i class="bx bx-bot"></i>',s.appendChild(l);const c=document.createElement("div");c.className="message-content",s.appendChild(c)}const a=s.querySelector(".message-content");a.innerHTML=ty(t),e&&(s.classList.remove("streaming"),Yd($(s)),this.hideThinkingDisplay(),this.messages.push({role:"assistant",content:t,timestamp:new Date}),this.saveCurrentDataToSpecificNote(i||this.noteId)),this.chatContainer.scrollTop=this.chatContainer.scrollHeight}handleError(t){Kc(this.loadingIndicator),ft.showError("Error sending message: "+t.message)}addMessageToChat(t,e){nE(this.noteContextChatMessages,this.chatContainer,t,e)}showSources(t){oE(this.sourcesList,this.sourcesContainer,this.sourcesCount,t,e=>{Pt.tabManager.openTabWithNoteWithHoisting(e,{activate:!1})})}hideSources(){sE(this.sourcesContainer)}showToolExecutionInfo(t){if(console.log(`Showing tool execution info: ${JSON.stringify(t)}`),!t){console.error("Tool execution data is missing or undefined");return}const e=t.action||"",i=t.tool||"unknown";console.log(`Tool execution details: action=${e}, tool=${i}, hasResult=${!!t.result}`),!e&&t.result&&(console.log('Setting missing action to "result" since result is present'),t.action="result");let n=this.noteContextChatMessages.querySelector(".chat-tool-execution");if(!n){n=document.createElement("div"),n.className="chat-tool-execution mb-3";const l=document.createElement("div");l.className="tool-execution-header d-flex align-items-center p-2 rounded",l.innerHTML=`
|
||
<i class="bx bx-terminal me-2"></i>
|
||
<span class="flex-grow-1">Tool Execution</span>
|
||
<button type="button" class="btn btn-sm btn-link p-0 text-muted tool-execution-toggle" title="Toggle tool execution details">
|
||
<i class="bx bx-chevron-down"></i>
|
||
</button>
|
||
`,n.appendChild(l);const c=document.createElement("div");c.className="tool-execution-container p-2 rounded mb-2",n.appendChild(c),this.noteContextChatMessages.appendChild(n);const u=n.querySelector(".tool-execution-toggle");u&&u.addEventListener("click",()=>{const p=n?.querySelector(".tool-execution-container"),v=u.querySelector("i");p&&(p.classList.contains("collapsed")?(p.classList.remove("collapsed"),p.style.display="block",v&&(v.className="bx bx-chevron-down")):(p.classList.add("collapsed"),p.style.display="none",v&&(v.className="bx bx-chevron-right")))}),l.addEventListener("click",p=>{const v=p.target;v&&!v.closest(".tool-execution-toggle")&&n?.querySelector(".tool-execution-toggle")?.dispatchEvent(new Event("click"))}),l.style.cursor="pointer"}const s=n.querySelector(".tool-execution-container");if(!s)return;const a=t.action||"";if(a==="start"||a==="executing"){const l=document.createElement("div");l.className="tool-step executing p-2 mb-2 rounded",l.innerHTML=`
|
||
<div class="d-flex align-items-center">
|
||
<i class="bx bx-code-block me-2"></i>
|
||
<span>Executing tool: <strong>${t.tool||"unknown"}</strong></span>
|
||
</div>
|
||
${t.args?`
|
||
<div class="tool-args mt-1 ps-3">
|
||
<code>Args: ${JSON.stringify(t.args||{},null,2)}</code>
|
||
</div>`:""}
|
||
`,s.appendChild(l)}else if(a==="result"||a==="complete"){const l=document.createElement("div");l.className="tool-step result p-2 mb-2 rounded";let c="";if((t.tool==="search_notes"||t.tool==="keyword_search_notes")&&typeof t.result=="object"&&t.result.results){const u=t.result.results;u.length===0?c='<div class="text-muted">No notes found matching the search criteria.</div>':c=`
|
||
<div class="search-results">
|
||
<div class="mb-2">Found ${u.length} notes:</div>
|
||
<ul class="list-unstyled ps-1">
|
||
${u.map(p=>`
|
||
<li class="mb-1">
|
||
<a href="#" class="note-link" data-note-id="${p.noteId}">${p.title}</a>
|
||
${p.similarity<1?`<span class="text-muted small ms-1">(similarity: ${(p.similarity*100).toFixed(0)}%)</span>`:""}
|
||
</li>
|
||
`).join("")}
|
||
</ul>
|
||
</div>
|
||
`}else typeof t.result=="object"?c=`<pre class="mb-0"><code>${JSON.stringify(t.result,null,2)}</code></pre>`:c=`<div>${String(t.result)}</div>`;l.innerHTML=`
|
||
<div class="d-flex align-items-center">
|
||
<i class="bx bx-terminal me-2"></i>
|
||
<span>Tool: <strong>${t.tool||"unknown"}</strong></span>
|
||
</div>
|
||
<div class="tool-result mt-1 ps-3">
|
||
${c}
|
||
</div>
|
||
`,s.appendChild(l),(t.tool==="search_notes"||t.tool==="keyword_search_notes")&&l.querySelectorAll(".note-link").forEach(p=>{p.addEventListener("click",v=>{v.preventDefault();const x=v.currentTarget.getAttribute("data-note-id");x&&Pt.tabManager.openTabWithNoteWithHoisting(x,{activate:!1})})})}else if(a==="error"){const l=document.createElement("div");l.className="tool-step error p-2 mb-2 rounded",l.innerHTML=`
|
||
<div class="d-flex align-items-center">
|
||
<i class="bx bx-error-circle me-2"></i>
|
||
<span>Error in tool: <strong>${t.tool||"unknown"}</strong></span>
|
||
</div>
|
||
<div class="tool-error mt-1 ps-3 text-danger">
|
||
${t.error||"Unknown error"}
|
||
</div>
|
||
`,s.appendChild(l)}else if(a==="generating"){const l=document.createElement("div");l.className="tool-step generating p-2 mb-2 rounded",l.innerHTML=`
|
||
<div class="d-flex align-items-center">
|
||
<i class="bx bx-message-dots me-2"></i>
|
||
<span>Generating response with tool results...</span>
|
||
</div>
|
||
`,s.appendChild(l)}this.loadingIndicator.style.display="flex",this.chatContainer.scrollTop=this.chatContainer.scrollHeight}showThinkingState(t){const e=this.parseThinkingContent(t);e?this.showThinkingDisplay(e):this.showThinkingDisplay(t),this.loadingIndicator.style.display="flex"}parseThinkingContent(t){if(!t)return null;const e=/<think>([\s\S]*?)<\/think>/gi,i=[];let n;for(;(n=e.exec(t))!==null;)i.push(n[1].trim());if(i.length>0)return i.join(`
|
||
|
||
--- Next thought ---
|
||
|
||
`);const s=/<think>([\s\S]*?)$/i,a=t.match(s);return a&&a[1]?a[1].trim()+`
|
||
|
||
[Thinking in progress...]`:t.toLowerCase().includes("thinking")||t.toLowerCase().includes("reasoning")||t.toLowerCase().includes("let me think")||t.toLowerCase().includes("i need to")||t.toLowerCase().includes("first, ")||t.toLowerCase().includes("step 1")||t.toLowerCase().includes("analysis:")?t:null}initializeEventListeners(){this.noteContextChatForm.addEventListener("submit",t=>{t.preventDefault();let e="";if(this.noteContextChatInputEditor&&this.noteContextChatInputEditor.getData)e=this.noteContextChatInputEditor.getData();else{const i=this.noteContextChatInput.querySelector("textarea");i?e=i.value:e=this.noteContextChatInput.textContent||this.noteContextChatInput.innerText||""}e.trim()&&this.sendMessage(e)}),this.setupEditorKeyBindings()}setupEditorKeyBindings(){if(this.noteContextChatInputEditor&&this.noteContextChatInputEditor.keystrokes)try{this.noteContextChatInputEditor.keystrokes.set("Enter",(t,e)=>{t.shiftKey||(e(),this.noteContextChatForm.dispatchEvent(new Event("submit")))}),console.log("CKEditor keybindings set up successfully")}catch(t){console.warn("Failed to set up CKEditor keybindings:",t)}}extractMentionsAndContent(t){const e=[],i=document.createElement("div");i.innerHTML=t,i.querySelectorAll("[data-mention], .mention, span[data-id]").forEach(a=>{try{let l=null;if(a.hasAttribute("data-mention"))l=JSON.parse(a.getAttribute("data-mention")||"{}");else if(a.hasAttribute("data-id")){const c=a.getAttribute("data-id"),u=a.textContent||"";if(c&&c.startsWith("@")){const p=c.substring(1);l={id:p,name:u,notePath:p}}}else if(a.tagName==="A"&&a.hasAttribute("href")){const c=a.getAttribute("href");c&&c.startsWith("#")&&(l={notePath:c.substring(1),noteTitle:a.textContent||"Unknown Note"})}if(l&&(l.notePath||l.link)){const c=l.notePath||l.link?.substring(1),u=c?c.split("/").pop():null,p=l.noteTitle||l.name||a.textContent||"Unknown Note";u&&(e.push({noteId:u,title:p,notePath:c}),console.log(`Extracted mention: noteId=${u}, title=${p}, notePath=${c}`))}}catch(l){console.warn("Failed to parse mention data:",l,a)}});const s=i.textContent||i.innerText||"";return console.log(`Extracted ${e.length} mentions from editor content`),{content:s,mentions:e}}setupThinkingToggle(){this.thinkingToggle&&this.thinkingToggle.addEventListener("click",e=>{e.stopPropagation(),this.toggleThinkingDetails()});const t=this.thinkingBubble?.querySelector(".thinking-header");t&&t.addEventListener("click",e=>{e.target.closest(".thinking-toggle")||this.toggleThinkingDetails()})}toggleThinkingDetails(){const t=this.thinkingBubble?.querySelector(".thinking-content"),e=this.thinkingToggle?.querySelector("i");t&&e&&(t.style.display!=="none"?(t.style.display="none",e.className="bx bx-chevron-down",this.thinkingToggle.classList.remove("expanded")):(t.style.display="block",e.className="bx bx-chevron-up",this.thinkingToggle.classList.add("expanded")))}showThinkingDisplay(t=""){this.thinkingContainer&&(this.thinkingContainer.style.display="block",t&&this.thinkingText&&this.updateThinkingText(t),this.chatContainer.scrollTop=this.chatContainer.scrollHeight)}updateThinkingText(t){if(this.thinkingText){const e=this.formatThinkingText(t);this.thinkingText.textContent=e;const i=this.thinkingBubble?.querySelector(".thinking-content");i&&i.style.display!=="none"&&(this.chatContainer.scrollTop=this.chatContainer.scrollHeight)}}formatThinkingText(t){if(!t)return t;let e=t.trim();return e=e.replace(/(\d+\.\s)/g,`
|
||
$1`).replace(/\n\s*\n\s*\n/g,`
|
||
|
||
`).trim(),e}hideThinkingDisplay(){if(this.thinkingContainer){this.thinkingContainer.style.display="none";const t=this.thinkingBubble?.querySelector(".thinking-content"),e=this.thinkingToggle?.querySelector("i");t&&e&&(t.style.display="none",e.className="bx bx-chevron-down",this.thinkingToggle?.classList.remove("expanded")),this.thinkingText&&(this.thinkingText.textContent="")}}appendThinkingText(t){if(this.thinkingText&&t){const i=(this.thinkingText.textContent||"")+t;this.updateThinkingText(i)}}}class hE extends Ue{llmChatPanel;isInitialized=!1;initPromise=null;constructor(){super(),this.llmChatPanel=new dE,this.llmChatPanel.setDataCallbacks(t=>this.saveData(t),()=>this.getData())}static getType(){return"aiChat"}doRender(){return this.$widget=$('<div class="ai-chat-widget-container" style="height: 100%;"></div>'),this.$widget.append(this.llmChatPanel.render()),this.$widget}async refreshWithNote(t){console.log("refreshWithNote called for note:",t?.noteId),this.note?.noteId!==t?.noteId&&(console.log(`Note ID changed from ${this.note?.noteId} to ${t?.noteId}, forcing reset`),this.isInitialized=!1,this.initPromise=null,t&&this.llmChatPanel.setCurrentNoteId(t.noteId)),await this.doRefresh(t)}async doRefresh(t){try{if(console.log("doRefresh called for note:",t?.noteId),this.initPromise){await this.initPromise;return}if(!this.isInitialized){if(console.log("Initializing AI Chat Panel for note:",t?.noteId),t)try{const e=await t.getContent();!e||e==="{}"?(await this.saveData({messages:[],title:t.title,noteId:t.noteId}),console.log("Initialized empty chat history for new note")):console.log("Note already has content, will load in LlmChatPanel.refresh()")}catch(e){console.error("Error initializing AI Chat note content:",e)}this.initPromise=(async()=>{try{this.llmChatPanel.clearNoteContextChatMessages(),this.llmChatPanel.setMessages([]),t&&this.llmChatPanel.setNoteId(t.noteId),await this.llmChatPanel.refresh(),this.isInitialized=!0}catch(e){console.error("Error initializing LlmChatPanel:",e),ft.showError("Failed to initialize chat panel. Try reloading.")}})(),await this.initPromise,this.initPromise=null}}catch(e){console.error("Error in doRefresh:",e),ft.showError("Error refreshing chat. Please try again.")}}async entitiesReloadedEvent(t){}async noteSwitched(){console.log("Note switched to:",this.noteId),this.isInitialized=!1,this.initPromise=null,this.note&&(this.llmChatPanel.setCurrentNoteId(this.note.noteId),this.llmChatPanel.clearNoteContextChatMessages(),this.llmChatPanel.setMessages([]),this.llmChatPanel.setNoteId(this.note.noteId)),await super.noteSwitched()}async activeContextChangedEvent(t){if(this.isActive()){console.log("Active context changed, refreshing AI Chat Panel");try{this.isInitialized=!1,this.note&&(this.llmChatPanel.setCurrentNoteId(this.note.noteId),this.llmChatPanel.setNoteId(this.note.noteId)),this.initPromise=(async()=>{try{this.llmChatPanel.clearNoteContextChatMessages(),this.llmChatPanel.setMessages([]),await this.llmChatPanel.refresh(),this.isInitialized=!0}catch(e){console.error("Error refreshing LlmChatPanel:",e)}})(),await this.initPromise,this.initPromise=null}catch(e){console.error("Error in activeContextChangedEvent:",e)}}}async saveData(t){const e=t.noteId,i=e||this.note?.noteId;if(!i){console.warn("Cannot save AI Chat data: no note ID available");return}try{console.log(`AiChatTypeWidget: Saving data for note ${i} (current note: ${this.note?.noteId}, data.noteId: ${t.noteId})`),e&&this.note?.noteId&&e!==this.note.noteId&&console.warn(`Note ID mismatch: saving to ${e} but current note is ${this.note.noteId}`);const n={messages:t.messages||[],noteId:i,toolSteps:t.toolSteps||[],sources:t.sources||[],metadata:{...t.metadata||{},lastUpdated:new Date().toISOString()}};await pt.put(`notes/${i}/data`,{content:JSON.stringify(n,null,2)})}catch(n){console.error("Error saving AI Chat data:",n),ft.showError("Failed to save chat data")}}async getData(){if(!this.note)return null;try{console.log(`AiChatTypeWidget: Getting data for note ${this.note.noteId}`);const t=await this.note.getContent();if(!t)return console.log("Note content is empty"),null;let e;try{e=JSON.parse(t),console.log("Successfully parsed note content as JSON")}catch(i){return console.error("Error parsing chat content as JSON:",i),null}if(e.content&&typeof e.content=="string"&&e.blobId&&e.contentLength)try{console.log("Detected blob response structure, parsing inner content");const i=JSON.parse(e.content);return console.log("Successfully parsed blob inner content"),i}catch(i){return console.error("Error parsing inner blob content:",i),null}return e}catch(t){return console.error("Error loading AI Chat data:",t),null}}}const uE=`
|
||
<div class="note-detail">
|
||
<style>
|
||
.note-detail {
|
||
font-family: var(--detail-font-family);
|
||
font-size: var(--detail-font-size);
|
||
}
|
||
|
||
.note-detail.full-height {
|
||
height: 100%;
|
||
}
|
||
</style>
|
||
</div>
|
||
`,pE={empty:gw,editableText:$w,readOnlyText:f1,editableCode:Kv,readOnlyCode:g1,file:G$,image:J$,search:y1,render:X$,relationMap:s1,canvas:a1,protectedSession:d1,book:u1,noteMap:x1,webView:$1,doc:T1,contentWidget:wT,attachmentDetail:ST,attachmentList:CT,mindMap:AT,geoMap:VT,aiChat:hE,mermaid:tE};class zA extends hi{typeWidgets;spacedUpdate;type;mime;constructor(){super(),this.typeWidgets={},this.spacedUpdate=new Hi(async()=>{if(!this.noteContext)return;const{note:t}=this.noteContext;if(!t)return;const{noteId:e}=t,i=await this.getTypeWidget().getData();i!==void 0&&(Mi.touchProtectedSessionIfNecessary(t),await pt.put(`notes/${e}/data`,i,this.componentId),this.getTypeWidget().dataSaved())}),Pt.addBeforeUnloadListener(this)}isEnabled(){return!0}doRender(){this.$widget=$(uE),this.contentSized()}async refresh(){if(this.type=await this.getWidgetType(),this.mime=this.note?.mime,!(this.type in this.typeWidgets)){const t=pE[this.type];if(!t)throw new Error(`Cannot find type widget for type '${this.type}'`);const e=this.typeWidgets[this.type]=new t;e.spacedUpdate=this.spacedUpdate,e.setParent(this),this.noteContext&&e.setNoteContextEvent({noteContext:this.noteContext});const i=e.render();qo.updateDisplayedShortcuts(i),this.$widget.append(i),this.noteContext&&await e.handleEvent("setNoteContext",{noteContext:this.noteContext}),this.noteContext&&await e.handleEvent("noteSwitched",{noteContext:this.noteContext,notePath:this.noteContext.notePath}),this.child(e)}if(this.checkFullHeight(),ct.isMobile()){const t=this.noteContext?.hoistedNoteId==="_lbMobileRoot";$("body").toggleClass("force-fixed-tree",t)}}checkFullHeight(){const t=this.noteContext?.noteId==="_backendLog",e=this.mime==="text/x-sqlite;schema=trilium",i=["canvas","webView","noteMap","mindMap","geoMap","mermaid"].includes(this.type??""),n=!this.noteContext?.hasNoteList()&&i&&!e||this.noteContext?.viewScope?.viewMode==="attachments"||t;this.$widget.toggleClass("full-height",n)}getTypeWidget(){if(!this.type||!this.typeWidgets[this.type])throw new Error(m("note_detail.could_not_find_typewidget",{type:this.type}));return this.typeWidgets[this.type]}async getWidgetType(){const t=this.note;if(!t)return"empty";const e=t.type;let i;const n=this.noteContext?.viewScope;return n?.viewMode==="source"?i="readOnlyCode":n&&n.viewMode==="attachments"?i=n.attachmentId?"attachmentDetail":"attachmentList":e==="text"&&await this.noteContext?.isReadOnly()?i="readOnlyText":(e==="code"||e==="mermaid")&&await this.noteContext?.isReadOnly()?i="readOnlyCode":e==="text"?i="editableText":e==="code"?i="editableCode":e==="launcher"?i="doc":i=e,t.isProtected&&!Mi.isProtectedSessionAvailable()&&(i="protectedSession"),i}async focusOnDetailEvent({ntxId:t}){if(this.noteContext?.ntxId!==t)return;await this.refresh();const e=this.getTypeWidget();await e.initialized,e.focus()}async scrollToEndEvent({ntxId:t}){if(this.noteContext?.ntxId!==t)return;await this.refresh();const e=this.getTypeWidget();await e.initialized,e.scrollToEnd&&e.scrollToEnd()}async beforeNoteSwitchEvent({noteContext:t}){this.isNoteContext(t.ntxId)&&await this.spacedUpdate.updateNowIfNecessary()}async beforeNoteContextRemoveEvent({ntxIds:t}){this.isNoteContext(t)&&await this.spacedUpdate.updateNowIfNecessary()}async runActiveNoteCommand(t){return this.isNoteContext(t.ntxId)&&await this.spacedUpdate.updateNowIfNecessary(),await this.parent?.triggerCommand("runActiveNote",t)}async printActiveNoteEvent(){this.noteContext?.isActive()&&window.print()}async exportAsPdfEvent(){if(!this.noteContext?.isActive()||!this.note)return;const{ipcRenderer:t}=ct.dynamicRequire("electron");t.send("export-as-pdf",{title:this.note.title,pageSize:this.note.getAttributeValue("label","printPageSize")??"Letter",landscape:this.note.hasAttribute("label","printLandscape")})}hoistedNoteChangedEvent({ntxId:t}){this.isNoteContext(t)&&this.refresh()}async entitiesReloadedEvent({loadResults:t}){if(this.noteId&&t.isNoteContentReloaded(this.noteId,this.componentId))this.handleEvent("noteTypeMimeChanged",{noteId:this.noteId});else if(this.noteId&&t.isNoteReloaded(this.noteId,this.componentId)&&(this.type!==await this.getWidgetType()||this.mime!==this.note?.mime))this.triggerEvent("noteTypeMimeChanged",{noteId:this.noteId});else{const e=t.getAttributeRows(),i=e.find(s=>s.type==="label"&&["readOnly","autoReadOnlyDisabled","cssClass","displayRelations","hideRelations"].includes(s.name??"")&&Be.isAffecting(s,this.note)),n=e.find(s=>s.type==="relation"&&["template","inherit","renderNote"].includes(s.name??"")&&Be.isAffecting(s,this.note));this.noteId&&(i||n)&&this.triggerEvent("noteTypeMimeChanged",{noteId:this.noteId})}}beforeUnloadEvent(){return this.spacedUpdate.isAllSavedAndTriggerUpdate()}readOnlyTemporarilyDisabledEvent({noteContext:t}){this.isNoteContext(t.ntxId)&&this.refresh()}async executeInActiveNoteDetailWidgetEvent({callback:t}){this.isActiveNoteContext()&&(await this.initialized,t(this))}async cutIntoNoteCommand(){const t=Pt.tabManager.getActiveContextNote();if(!t)return;const e=Pt.tabManager.getActiveContextNotePath();this.noteContext&&e&&yr.createNote(e,{isProtected:t.isProtected,saveSelection:!0,textEditor:await this.noteContext.getTextEditor()})}async saveNoteDetailNowCommand(){await this.spacedUpdate.updateNowIfNecessary()}renderActiveNoteEvent(){this.noteContext?.isActive()&&this.refresh()}async executeWithTypeWidgetEvent({resolve:t,ntxId:e}){this.isNoteContext(e)&&(await this.initialized,await this.getWidgetType(),t(this.getTypeWidget()))}}const fE=`
|
||
<div class="promoted-attributes-widget">
|
||
<style>
|
||
body.mobile .promoted-attributes-widget {
|
||
/* https://github.com/zadam/trilium/issues/4468 */
|
||
flex-shrink: 0.4;
|
||
overflow: auto;
|
||
}
|
||
|
||
.promoted-attributes-container {
|
||
margin: 0 1.5em;
|
||
overflow: auto;
|
||
max-height: 400px;
|
||
flex-wrap: wrap;
|
||
display: table;
|
||
}
|
||
.promoted-attribute-cell {
|
||
display: flex;
|
||
align-items: center;
|
||
margin: 10px;
|
||
display: table-row;
|
||
}
|
||
.promoted-attribute-cell > label {
|
||
user-select: none;
|
||
font-weight: bold;
|
||
vertical-align: middle;
|
||
}
|
||
.promoted-attribute-cell > * {
|
||
display: table-cell;
|
||
padding: 1px 0;
|
||
}
|
||
|
||
.promoted-attribute-cell div.input-group {
|
||
margin-left: 10px;
|
||
display: flex;
|
||
min-height: 40px;
|
||
}
|
||
.promoted-attribute-cell strong {
|
||
word-break:keep-all;
|
||
white-space: nowrap;
|
||
}
|
||
.promoted-attribute-cell input[type="checkbox"] {
|
||
width: 22px !important;
|
||
flex-grow: 0;
|
||
width: unset;
|
||
}
|
||
|
||
</style>
|
||
|
||
<div class="promoted-attributes-container"></div>
|
||
</div>`;class FA extends hi{$container;get name(){return"promotedAttributes"}get toggleCommand(){return"toggleRibbonTabPromotedAttributes"}doRender(){this.$widget=$(fE),this.contentSized(),this.$container=this.$widget.find(".promoted-attributes-container")}getTitle(t){return t.getPromotedDefinitionAttributes().length===0?{show:!1}:{show:!0,activate:Qt.is("promotedAttributesOpenInRibbon"),title:m("promoted_attributes.promoted_attributes"),icon:"bx bx-table"}}async refreshWithNote(t){this.$container.empty();const e=t.getPromotedDefinitionAttributes(),i=t.getOwnedAttributes();if(i.sort((s,a)=>s.position-a.position),e.length===0){this.toggleInt(!1);return}const n=[];for(const s of e){const a=s.name.startsWith("label:")?"label":"relation",l=s.name.substr(a.length+1);let c=i.filter(u=>u.name===l&&u.type===a);c.length===0&&c.push({attributeId:"",type:a,name:l,value:""}),s.getDefinition().multiplicity==="single"&&(c=c.slice(0,1));for(const u of c){const p=await this.createPromotedAttributeCell(s,u,l);p&&n.push(p)}}this.$container.empty().append(...n),this.toggleInt(!0)}async createPromotedAttributeCell(t,e,i){const n=t.getDefinition(),s=`value-${e.attributeId}`,a=$("<input>").prop("tabindex",200+t.position).prop("id",s).attr("data-attribute-id",e.noteId===this.noteId?e.attributeId??"":"").attr("data-attribute-type",e.type).attr("data-attribute-name",e.name).prop("value",e.value).prop("placeholder",m("promoted_attributes.unset-field-placeholder")).addClass("form-control").addClass("promoted-attribute-input").on("change",p=>this.promotedAttributeChanged(p)),l=$("<div>"),c=$("<td>").addClass("multiplicity").attr("nowrap","true"),u=$('<div class="promoted-attribute-cell">').append($("<label>").prop("for",s).text(n.promotedAlias??i)).append($("<div>").addClass("input-group").append(a)).append(l).append(c);if(e.type==="label")if(n.labelType==="text")a.prop("type","text"),ct.isDesktop()&&pt.get(`attribute-values/${encodeURIComponent(e.name)}`).then(p=>{if(p.length===0)return;const v=p.map(x=>({value:x}));a.autocomplete({appendTo:document.querySelector("body"),hint:!1,autoselect:!1,openOnFocus:!0,minLength:0,tabAutocomplete:!1},[{displayKey:"value",source:function(x,T){x=x.toLowerCase();const M=v.filter(P=>P.value.toLowerCase().includes(x));T(M)}}]),a.on("autocomplete:selected",x=>this.promotedAttributeChanged(x))});else if(n.labelType==="number"){a.prop("type","number");let p=1;for(let v=0;v<(n.numberPrecision||0)&&v<10;v++)p/=10;a.prop("step",p),a.css("text-align","right").css("width","120")}else if(n.labelType==="boolean")a.prop("type","checkbox"),a.wrap($('<label class="tn-checkbox"></label>')),u.find(".input-group").removeClass("input-group"),e.value==="true"&&a.prop("checked","checked");else if(n.labelType==="date")a.prop("type","date");else if(n.labelType==="datetime")a.prop("type","datetime-local");else if(n.labelType==="time")a.prop("type","time");else if(n.labelType==="url"){a.prop("placeholder",m("promoted_attributes.url_placeholder"));const p=$("<span>").addClass("input-group-text open-external-link-button bx bx-window-open").prop("title",m("promoted_attributes.open_external_link")).on("click",()=>window.open(a.val(),"_blank"));a.after(p)}else yi.logError(m("promoted_attributes.unknown_label_type",{type:n.labelType}));else if(e.type==="relation")e.value&&a.val(await fe.getNoteTitle(e.value)),ct.isDesktop()?(Xe.initNoteAutocomplete(a,{allowCreatingNotes:!0}),a.on("autocomplete:noteselected",(p,v,x)=>{this.promotedAttributeChanged(p)}),a.setSelectedNotePath(e.value)):a.attr("readonly","readonly");else{yi.logError(m("promoted_attributes.unknown_attribute_type",{type:e.type}));return}if(n.multiplicity==="multi"){const p=$("<span>").addClass("bx bx-plus pointer tn-tool-button").prop("title",m("promoted_attributes.add_new_attribute")).on("click",async()=>{const x=await this.createPromotedAttributeCell(t,{attributeId:"",type:e.type,name:i,value:""},i);x&&(u.after(x),x.find("input").trigger("focus"))}),v=$("<span>").addClass("bx bx-trash pointer tn-tool-button").prop("title",m("promoted_attributes.remove_this_attribute")).on("click",async()=>{const x=a.attr("data-attribute-id");x&&await pt.remove(`notes/${this.noteId}/attributes/${x}`,this.componentId);const T=`input[data-attribute-type='${e.type}'][data-attribute-name='${i}']`;if(this.$widget.find(T).length<=1){const M=await this.createPromotedAttributeCell(t,{attributeId:"",type:e.type,name:i,value:""},i);M&&u.after(M)}u.remove()});c.append(" ").append(p).append(" ").append(v)}return u}async promotedAttributeChanged(t){const e=$(t.target);let i;if(e.prop("type")==="checkbox")i=e.is(":checked")?"true":"false";else if(e.attr("data-attribute-type")==="relation"){const s=e.getSelectedNotePath();i=s?fe.getNoteIdFromUrl(s):""}else i=e.val();const n=await pt.put(`notes/${this.noteId}/attribute`,{attributeId:e.attr("data-attribute-id"),type:e.attr("data-attribute-type"),name:e.attr("data-attribute-name"),value:i},this.componentId);e.attr("data-attribute-id",n.attributeId)}focus(){this.$widget.find(".promoted-attribute-input:first").focus()}entitiesReloadedEvent({loadResults:t}){t.getAttributeRows(this.componentId).find(e=>Be.isAffecting(e,this.note))&&this.refresh()}}class ey{constructor(t){t.$parent.empty()}onEntitiesReloaded(t){}get isFullHeight(){return!1}}var qa={exports:{}},$f;function mE(){if($f)return qa.exports;$f=1;function o(t,e=100,i={}){if(typeof t!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);if(e<0)throw new RangeError("`wait` must not be negative.");const{immediate:n}=typeof i=="boolean"?{immediate:i}:i;let s,a,l,c,u;function p(){const T=s,M=a;return s=void 0,a=void 0,u=t.apply(T,M),u}function v(){const T=Date.now()-c;T<e&&T>=0?l=setTimeout(v,e-T):(l=void 0,n||(u=p()))}const x=function(...T){if(s&&this!==s&&Object.getPrototypeOf(this)===Object.getPrototypeOf(s))throw new Error("Debounced method called with different contexts of the same prototype.");s=this,a=T,c=Date.now();const M=n&&!l;return l||(l=setTimeout(v,e)),M&&(u=p()),u};return Object.defineProperty(x,"isPending",{get(){return l!==void 0}}),x.clear=()=>{l&&(clearTimeout(l),l=void 0)},x.flush=()=>{l&&x.trigger()},x.trigger=()=>{u=p(),x.clear()},x}return qa.exports.debounce=o,qa.exports=o,qa.exports}var gE=mE();const vE=Br(gE),yE=`
|
||
<div class="calendar-view">
|
||
<style>
|
||
.calendar-view {
|
||
overflow: hidden;
|
||
position: relative;
|
||
height: 100%;
|
||
user-select: none;
|
||
padding: 10px;
|
||
}
|
||
|
||
.calendar-view a {
|
||
color: unset;
|
||
}
|
||
|
||
.search-result-widget-content .calendar-view {
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
}
|
||
|
||
.calendar-container {
|
||
height: 100%;
|
||
--fc-page-bg-color: var(--main-background-color);
|
||
--fc-border-color: var(--main-border-color);
|
||
--fc-neutral-bg-color: var(--launcher-pane-background-color);
|
||
--fc-list-event-hover-bg-color: var(--left-pane-item-hover-background);
|
||
}
|
||
|
||
.calendar-container .fc-toolbar.fc-header-toolbar {
|
||
margin-bottom: 0.5em;
|
||
}
|
||
|
||
.calendar-container .fc-list-sticky .fc-list-day > * {
|
||
z-index: 50;
|
||
}
|
||
|
||
body.desktop:not(.zen) .calendar-container .fc-toolbar.fc-header-toolbar {
|
||
padding-right: 5em;
|
||
}
|
||
|
||
.search-result-widget-content .calendar-view .fc-toolbar.fc-header-toolbar {
|
||
padding-right: unset !important;
|
||
}
|
||
|
||
.calendar-container .fc-toolbar-title {
|
||
font-size: 1.3rem;
|
||
font-weight: normal;
|
||
}
|
||
|
||
.calendar-container a.fc-event {
|
||
text-decoration: none;
|
||
}
|
||
|
||
.calendar-container .fc-button {
|
||
padding: 0.2em 0.5em;
|
||
}
|
||
|
||
.calendar-container .promoted-attribute {
|
||
font-size: 0.85em;
|
||
opacity: 0.85;
|
||
overflow: hidden;
|
||
}
|
||
</style>
|
||
|
||
<div class="calendar-container" tabindex="100">
|
||
</div>
|
||
</div>
|
||
`,Sf=["timeGridWeek","dayGridMonth","multiMonthYear","listMonth"];class We extends ey{$root;$calendarContainer;noteIds;parentNote;calendar;isCalendarRoot;lastView;debouncedSaveView;constructor(t){super(t),this.$root=$(yE),this.$calendarContainer=this.$root.find(".calendar-container"),this.noteIds=t.noteIds,this.parentNote=t.parentNote,this.isCalendarRoot=!1,t.$parent.append(this.$root)}get isFullHeight(){return!0}async renderList(){this.isCalendarRoot=this.parentNote.hasLabel("calendarRoot")||this.parentNote.hasLabel("workspaceCalendarRoot");const t=!this.isCalendarRoot,{Calendar:e}=await Z(async()=>{const{Calendar:c}=await import("./index2.js").then(u=>u.aX);return{Calendar:c}},__vite__mapDeps([81,71,70]),import.meta.url),i=[];i.push((await Z(async()=>{const{default:c}=await import("./index.js");return{default:c}},__vite__mapDeps([82,81,71,70,83]),import.meta.url)).default),i.push((await Z(async()=>{const{default:c}=await import("./index5.js");return{default:c}},__vite__mapDeps([84,81,71,70,83]),import.meta.url)).default),i.push((await Z(async()=>{const{default:c}=await import("./index6.js");return{default:c}},__vite__mapDeps([85,81,71,70]),import.meta.url)).default),i.push((await Z(async()=>{const{default:c}=await import("./index3.js");return{default:c}},__vite__mapDeps([86,81,71,70,83]),import.meta.url)).default),(t||this.isCalendarRoot)&&i.push((await Z(async()=>{const{default:c}=await import("./index4.js");return{default:c}},__vite__mapDeps([87,81,71,70]),import.meta.url)).default);let n;this.isCalendarRoot?n=async c=>await this.#a(c):n=async()=>await We.buildEvents(this.noteIds);let s="dayGridMonth";const a=this.parentNote.getLabelValue("calendar:view");a&&Sf.includes(a)&&(s=a);const l=new e(this.$calendarContainer[0],{plugins:i,initialView:s,events:n,editable:t,selectable:t,select:c=>this.#e(c),eventChange:c=>this.#s(c),firstDay:Qt.getInt("firstDayOfWeek")??0,weekends:!this.parentNote.hasAttribute("label","calendar:hideWeekends"),weekNumbers:this.parentNote.hasAttribute("label","calendar:weekNumbers"),locale:await We.#t(),height:"100%",nowIndicator:!0,handleWindowResize:!1,eventDidMount:c=>{const{iconClass:u,promotedAttributes:p}=c.event.extendedProps;if(u){let v;switch(c.view.type){case"timeGridWeek":case"dayGridMonth":v=c.el.querySelector(".fc-event-title");break;case"multiMonthYear":break;case"listMonth":v=c.el.querySelector(".fc-list-event-title a");break}if(v){const x=`<span class="${u}"></span> `;v.insertAdjacentHTML("afterbegin",x)}}if(p){let v="";for(const[T,M]of p)v=v+` <div class="promoted-attribute">
|
||
<span class="promoted-attribute-name">${T}</span>: <span class="promoted-attribute-value">${M}</span>
|
||
</div>`;let x;switch(c.view.type){case"timeGridWeek":case"dayGridMonth":x=c.el.querySelector(".fc-event-main");break;case"multiMonthYear":break;case"listMonth":x=c.el.querySelector(".fc-list-event-title");break}$(x??c.el).append($(v))}},dateClick:async c=>{if(!this.isCalendarRoot)return;const u=await cl.getDayNote(c.dateStr);u&&Pt.tabManager.getActiveContext()?.setNote(u.noteId)},datesSet:c=>this.#i(c),headerToolbar:{start:"title",end:`${Sf.join(",")} today prev,next`}});return l.render(),this.calendar=l,new ResizeObserver(()=>l.updateSize()).observe(this.$calendarContainer[0]),this.$root}static async#t(){switch(Qt.get("locale")){case"de":return(await Z(async()=>{const{default:e}=await import("./de.js");return{default:e}},[],import.meta.url)).default;case"es":return(await Z(async()=>{const{default:e}=await import("./es.js");return{default:e}},[],import.meta.url)).default;case"fr":return(await Z(async()=>{const{default:e}=await import("./fr.js");return{default:e}},[],import.meta.url)).default;case"ko":return(await Z(async()=>{const{default:e}=await import("./ko.js");return{default:e}},[],import.meta.url)).default;case"cn":return(await Z(async()=>{const{default:e}=await import("./zh-cn.js");return{default:e}},[],import.meta.url)).default;case"tw":return(await Z(async()=>{const{default:e}=await import("./zh-tw.js");return{default:e}},[],import.meta.url)).default;case"ro":return(await Z(async()=>{const{default:e}=await import("./ro.js");return{default:e}},[],import.meta.url)).default;case"en":default:return}}#i(t){const e=t.view.type;e!==this.lastView&&(this.debouncedSaveView||(this.debouncedSaveView=vE(()=>{this.lastView&&Be.setLabel(this.parentNote.noteId,"calendar:view",this.lastView)},1e3)),this.debouncedSaveView(),this.lastView=e,Sr&&Pt.triggerCommand("refreshTouchBar"))}async#e(t){const{startDate:e,endDate:i}=this.#o(t);if(!e)return;const{startTime:n,endTime:s}=this.#n(t),a=await Me.prompt({message:m("relation_map.enter_title_of_new_note"),defaultValue:m("relation_map.default_new_note_title")});if(!a?.trim())return;const{note:l}=await pt.post(`notes/${this.parentNote.noteId}/children?target=into`,{title:a,content:"",type:"text"});Be.setLabel(l.noteId,"startDate",e),i&&Be.setLabel(l.noteId,"endDate",i),n&&Be.setLabel(l.noteId,"startTime",n),s&&Be.setLabel(l.noteId,"endTime",s)}#o(t){const e=We.#l(t.start);if(!e)return{startDate:null,endDate:null};let i;return t.allDay?i=We.#l(We.#h(t.end,-1)):i=We.#l(t.end),{startDate:e,endDate:i}}#n(t){let e=null,i=null;return t.allDay||(e=We.#d(t.start),i=We.#d(t.end)),{startTime:e,endTime:i}}async#s(t){let{startDate:e,endDate:i}=this.#o(t.event);if(!e)return;const n=t.event.extendedProps.noteId;i===e&&(i=void 0);const s=await Mt.getNote(n);if(!s)return;const a=s.getAttributes("label").filter(c=>c.name=="calendar:startDate").shift()?.value||"startDate",l=s.getAttributes("label").filter(c=>c.name=="calendar:endDate").shift()?.value||"endDate";if(Be.setAttribute(s,"label",a,e),Be.setAttribute(s,"label",l,i),!t.event.allDay){const c=s.getAttributes("label").filter(x=>x.name=="calendar:startTime").shift()?.value||"startTime",u=s.getAttributes("label").filter(x=>x.name=="calendar:endTime").shift()?.value||"endTime",{startTime:p,endTime:v}=this.#n(t.event);Be.setAttribute(s,"label",c,p),Be.setAttribute(s,"label",u,v)}}onEntitiesReloaded({loadResults:t}){if(t.getBranchRows().some(e=>e.parentNoteId===this.parentNote.noteId)&&(this.noteIds=this.parentNote.getChildNoteIds()),t.getAttributeRows().some(e=>e.noteId===this.parentNote.noteId&&e.name?.startsWith("calendar:")&&e.name!=="calendar:view"))return!0;this.calendar&&t.getAttributeRows().some(e=>this.noteIds.includes(e.noteId??""))&&this.calendar.refetchEvents()}async#a(t){const e=[],i=ct.getMonthsInDateRange(t.startStr,t.endStr);let n=[];for(const u of i){const p=await pt.get(`special-notes/notes-for-month/${u}?calendarRoot=${this.parentNote.noteId}`),v=Object.values(p);n=[...n,...v]}const s=await Mt.getNotes(n),a={};for(const u of s){const p=u.getLabelValue("dateNote");if(p&&(e.push(await We.buildEvent(u,{startDate:p})),u.hasChildren())){const v=u.getChildNoteIds();for(const x of v)a[x]=p}}const l=Object.keys(a),c=await Mt.getNotes(l);for(const u of c){const p=a[u.noteId],v=await We.buildEvent(u,{startDate:p});e.push(v)}return e.flat()}static async buildEvents(t){const e=await Mt.getNotes(t),i=[];for(const n of e){const s=We.#r(n,"startDate","calendar:startDate");if(n.hasChildren()){const u=await this.buildEvents(n.getChildNoteIds());u.length>0&&i.push(u)}if(!s)continue;const a=We.#r(n,"endDate","calendar:endDate"),l=We.#r(n,"startTime","calendar:startTime"),c=We.#r(n,"endTime","calendar:endTime");i.push(await We.buildEvent(n,{startDate:s,endDate:a,startTime:l,endTime:c}))}return i.flat()}static#r(t,e,i){const n=t.getLabelValue(i);if(n){const s=t.getLabelValue(n);if(s)return s}return t.getLabelValue(e)}static async buildEvent(t,{startDate:e,endDate:i,startTime:n,endTime:s}){const a=t.getLabelValue("calendar:title"),l=await We.#c(a,t),c=t.getLabelValue("calendar:color")??t.getLabelValue("color"),u=[],p=t.getLabelValue("calendar:displayedAttributes")?.split(",");let v=null;p&&(v=await this.#u(t,p));for(const x of l){if(n&&s&&!i&&(i=e),e=n?`${e}T${n}:00`:e,!n){const M=We.#h(i??e,1);M&&(i=We.#l(M))}i=s?`${i}T${s}:00`:i;const T={title:x,start:e,url:`#${t.noteId}`,noteId:t.noteId,color:c??void 0,iconClass:t.getLabelValue("iconClass"),promotedAttributes:v};i&&(T.end=i),u.push(T)}return u}static async#u(t,e){const i=t.getAttributes().filter(s=>e.includes(s.name)),n=[];for(const s of i)s.type==="label"?n.push([s.name,s.value]):n.push([s.name,(await s.getTargetNote())?.title||""]);return n}static async#c(t,e,i=!0){if(t){const n=e.getAttributeValue("label",t);if(n)return[n];if(i){const s=e.getRelations(t);if(s.length>0){const a=s.map(u=>u.targetNoteId),l=await Mt.getNotes(a),c=[];for(const u of l){const p=u.getAttributeValue("label","calendar:title"),v=await We.#c(p,u,!1);c.push(v.flat())}return c.flat()}}}return[e.title]}static#l(t){if(!t)return;const e=t.getTimezoneOffset();return new Date(t.getTime()-e*60*1e3).toISOString().split("T")[0]}static#d(t){if(!t)return;const e=t.getTimezoneOffset();return new Date(t.getTime()-e*60*1e3).toISOString().split("T")[1].substring(0,5)}static#h(t,e){if(!t)return;const i=new Date(t);return i.setDate(i.getDate()+e),i}buildTouchBarCommand({TouchBar:t,buildIcon:e}){if(!this.calendar)return;const i=[],n=this.$calendarContainer.find(".fc-toolbar-chunk .fc-button-group, .fc-toolbar-chunk > button");for(const s of n){if(s.classList.contains("fc-button-group")){let a="single",l=0;const c=[],u=s.childNodes;let p=0;for(const v of u){if(v.ariaPressed==="true"&&(l=p),p++,v.innerText){c.push({label:v.innerText});continue}const x=v.querySelector("span.fc-icon");let T=null;x?.classList.contains("fc-icon-chevron-left")?(T="NSImageNameTouchBarGoBackTemplate",a="buttons"):x?.classList.contains("fc-icon-chevron-right")&&(T="NSImageNameTouchBarGoForwardTemplate",a="buttons"),T&&c.push({icon:e(T)})}i.push(new t.TouchBarSegmentedControl({mode:a,segments:c,selectedIndex:l,change:(v,x)=>u[v].click()}));continue}s.innerText&&i.push(new t.TouchBarButton({label:s.innerText,click:()=>s.click()}))}return i}}const bE=`
|
||
<div class="note-list">
|
||
<style>
|
||
.note-list {
|
||
overflow: hidden;
|
||
position: relative;
|
||
height: 100%;
|
||
}
|
||
|
||
.note-list.grid-view .note-list-container {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
.note-list.grid-view .note-book-card {
|
||
flex-basis: 300px;
|
||
border: 1px solid transparent;
|
||
}
|
||
|
||
.note-list.grid-view .note-expander {
|
||
display: none;
|
||
}
|
||
|
||
.note-list.grid-view .note-book-card {
|
||
max-height: 300px;
|
||
}
|
||
|
||
.note-list.grid-view .note-book-card img {
|
||
max-height: 220px;
|
||
object-fit: contain;
|
||
}
|
||
|
||
.note-list.grid-view .note-book-card:hover {
|
||
cursor: pointer;
|
||
border: 1px solid var(--main-border-color);
|
||
background: var(--more-accented-background-color);
|
||
}
|
||
|
||
.note-book-card {
|
||
border-radius: 10px;
|
||
background-color: var(--accented-background-color);
|
||
padding: 10px 15px 15px 8px;
|
||
margin: 5px 5px 5px 5px;
|
||
overflow: hidden;
|
||
display: flex;
|
||
flex-direction: column;
|
||
flex-shrink: 0;
|
||
flex-grow: 1;
|
||
}
|
||
|
||
.note-book-card:not(.expanded) .note-book-content {
|
||
display: none !important;
|
||
padding: 10px
|
||
}
|
||
|
||
.note-book-card.expanded .note-book-content {
|
||
display: block;
|
||
min-height: 0;
|
||
height: 100%;
|
||
padding-top: 10px;
|
||
}
|
||
|
||
.note-book-content .rendered-content {
|
||
height: 100%;
|
||
}
|
||
|
||
.note-book-header {
|
||
border-bottom: 1px solid var(--main-border-color);
|
||
margin-bottom: 0;
|
||
padding-bottom: .5rem;
|
||
word-break: break-all;
|
||
}
|
||
|
||
/* not-expanded title is limited to one line only */
|
||
.note-book-card:not(.expanded) .note-book-header {
|
||
overflow: hidden;
|
||
white-space: nowrap;
|
||
text-overflow: ellipsis;
|
||
}
|
||
|
||
.note-book-header .rendered-note-attributes {
|
||
font-size: medium;
|
||
}
|
||
|
||
.note-book-header .rendered-note-attributes:before {
|
||
content: "\\00a0\\00a0";
|
||
}
|
||
|
||
.note-book-header .note-icon {
|
||
font-size: 100%;
|
||
display: inline-block;
|
||
padding-right: 7px;
|
||
position: relative;
|
||
}
|
||
|
||
.note-book-card .note-book-card {
|
||
border: 1px solid var(--main-border-color);
|
||
}
|
||
|
||
.note-book-content.type-image, .note-book-content.type-file, .note-book-content.type-protectedSession {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
text-align: center;
|
||
padding: 10px;
|
||
}
|
||
|
||
.note-book-content.type-image img, .note-book-content.type-canvas svg {
|
||
max-width: 100%;
|
||
max-height: 100%;
|
||
object-fit: contain;
|
||
}
|
||
|
||
.note-book-card.type-image .note-book-content img,
|
||
.note-book-card.type-text .note-book-content img,
|
||
.note-book-card.type-canvas .note-book-content img {
|
||
max-width: 100%;
|
||
max-height: 100%;
|
||
}
|
||
|
||
.note-book-header {
|
||
flex-grow: 0;
|
||
}
|
||
|
||
.note-list-wrapper {
|
||
height: 100%;
|
||
overflow: auto;
|
||
}
|
||
|
||
.note-expander {
|
||
font-size: x-large;
|
||
position: relative;
|
||
top: 3px;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.note-list-pager {
|
||
text-align: center;
|
||
}
|
||
</style>
|
||
|
||
<div class="note-list-wrapper">
|
||
<div class="note-list-pager"></div>
|
||
|
||
<div class="note-list-container use-tn-links"></div>
|
||
|
||
<div class="note-list-pager"></div>
|
||
</div>
|
||
</div>`;class wE extends ey{$noteList;parentNote;noteIds;page;pageSize;viewType;showNotePath;highlightRegex;constructor(t,e){super(e),this.$noteList=$(bE),this.viewType=t,this.parentNote=e.parentNote;const i=this.getIncludedNoteIds();this.noteIds=e.noteIds.filter(n=>!i.has(n)&&n!=="_hidden"),this.noteIds.length!==0&&(e.$parent.append(this.$noteList),this.page=1,this.pageSize=parseInt(e.parentNote.getLabelValue("pageSize")||""),(!this.pageSize||this.pageSize<1)&&(this.pageSize=20),this.$noteList.addClass(`${this.viewType}-view`),this.showNotePath=e.showNotePath)}getIncludedNoteIds(){const t=this.parentNote?this.parentNote.getRelations().filter(e=>e.name==="imageLink"||e.name==="includeNoteLink"):[];return new Set(t.map(e=>e.value))}async renderList(){if(this.noteIds.length===0||!this.page||!this.pageSize){this.$noteList.hide();return}const t=this.parentNote.highlightedTokens||[];if(t.length>0){const l=t.map(c=>ct.escapeRegExp(c)).join("|");this.highlightRegex=new RegExp(l,"gi")}else this.highlightRegex=null;this.$noteList.show();const e=this.$noteList.find(".note-list-container").empty(),i=(this.page-1)*this.pageSize,n=i+this.pageSize,s=this.noteIds.slice(i,Math.min(n,this.noteIds.length)),a=await Mt.getNotes(s);for(const l of a){const c=await this.renderNote(l,this.parentNote.isLabelTruthy("expanded"));e.append(c)}return this.renderPager(),this.$noteList}renderPager(){const t=this.$noteList.find(".note-list-pager").empty();if(!this.page||!this.pageSize)return;const e=Math.ceil(this.noteIds.length/this.pageSize);t.toggle(e>1);let i;for(let n=1;n<=e;n++)if(e<20||n<=5||e-n<=5||Math.abs(this.page-n)<=2){i=!0;const s=(n-1)*this.pageSize+1,a=Math.min(this.noteIds.length,n*this.pageSize);t.append(n===this.page?$("<span>").text(n).css("text-decoration","underline").css("font-weight","bold"):$('<a href="javascript:">').text(n).attr("title",`Page of ${s} - ${a}`).on("click",()=>{this.page=n,this.renderList()})," ")}else i&&(t.append("... "),i=!1);t.append(`<span class="note-list-pager-total-count">(${this.noteIds.length} notes)</span>`)}async renderNote(t,e=!1){const i=$('<span class="note-expander bx bx-chevron-right"></span>'),{$renderedAttributes:n}=await bb.renderNormalAttributes(t),s=this.parentNote.type==="search"?t.noteId:`${this.parentNote.noteId}/${t.noteId}`,a=$('<div class="note-book-card">').attr("data-note-id",t.noteId).append($('<h5 class="note-book-header">').append(i).append($('<span class="note-icon">').addClass(t.getIcon())).append(this.viewType==="grid"?$('<span class="note-book-title">').text(await fe.getNoteTitle(t.noteId,this.parentNote.noteId)):(await Pe.createLink(s,{showTooltip:!1,showNotePath:this.showNotePath})).addClass("note-book-title")).append(n));return this.viewType==="grid"&&a.addClass("block-link").attr("data-href",`#${s}`).on("click",l=>Pe.goToLink(l)),i.on("click",()=>this.toggleContent(a,t,!a.hasClass("expanded"))),this.highlightRegex&&new(await Z(async()=>{const{default:c}=await import("./mark.js").then(u=>u.m);return{default:c}},__vite__mapDeps([88,5]),import.meta.url)).default(a.find(".note-book-title")[0]).markRegExp(this.highlightRegex,{element:"span",className:"ck-find-result"}),await this.toggleContent(a,t,e),a}async toggleContent(t,e,i){if(this.viewType==="list"&&(i&&t.hasClass("expanded")||!i&&!t.hasClass("expanded")))return;const n=t.find("> .note-book-header .note-expander");i||this.viewType==="grid"?(t.addClass("expanded"),n.addClass("bx-chevron-down").removeClass("bx-chevron-right")):(t.removeClass("expanded"),n.addClass("bx-chevron-right").removeClass("bx-chevron-down")),(i||this.viewType==="grid")&&t.find(".note-book-content").length===0&&t.append(await this.renderNoteContent(e))}async renderNoteContent(t){const e=$('<div class="note-book-content">');try{const{$renderedContent:i,type:n}=await Jd.getRenderedContent(t,{trim:this.viewType==="grid"});this.highlightRegex&&new(await Z(async()=>{const{default:a}=await import("./mark.js").then(l=>l.m);return{default:a}},__vite__mapDeps([88,5]),import.meta.url)).default(i[0]).markRegExp(this.highlightRegex,{element:"span",className:"ck-find-result"}),e.append(i),e.addClass(`type-${n}`)}catch(i){console.warn(`Caught error while rendering note '${t.noteId}' of type '${t.type}'`),console.error(i),e.append("rendering error")}if(this.viewType==="list"){const i=t.getRelations("imageLink"),n=(await t.getChildNotes()).filter(s=>!i.find(a=>a.value===s.noteId));for(const s of n)e.append(await this.renderNote(s))}return e}}class _E{viewType;viewMode;constructor(t,e,i,n=!1){this.viewType=this.#t(e);const s={$parent:t,parentNote:e,noteIds:i,showNotePath:n};this.viewType==="list"||this.viewType==="grid"?this.viewMode=new wE(this.viewType,s):this.viewType==="calendar"?this.viewMode=new We(s):this.viewMode=null}#t(t){const e=t.getLabelValue("viewType");return["list","grid","calendar"].includes(e||"")?e:t.type==="search"?"list":"grid"}get isFullHeight(){return this.viewMode?.isFullHeight}async renderList(){return this.viewMode?await this.viewMode.renderList():null}}const xE=`
|
||
<div class="note-list-widget">
|
||
<style>
|
||
.note-list-widget {
|
||
min-height: 0;
|
||
overflow: auto;
|
||
}
|
||
|
||
.note-list-widget .note-list {
|
||
padding: 10px;
|
||
}
|
||
|
||
.note-list-widget.full-height,
|
||
.note-list-widget.full-height .note-list-widget-content {
|
||
height: 100%;
|
||
}
|
||
|
||
.note-list-widget video {
|
||
height: 100%;
|
||
}
|
||
</style>
|
||
|
||
<div class="note-list-widget-content">
|
||
</div>
|
||
</div>`;class WA extends hi{$content;isIntersecting;noteIdRefreshed;shownNoteId;viewMode;isEnabled(){return super.isEnabled()&&this.noteContext?.hasNoteList()}doRender(){this.$widget=$(xE),this.contentSized(),this.$content=this.$widget.find(".note-list-widget-content");const t=new IntersectionObserver(e=>{this.isIntersecting=e[0].isIntersecting,this.checkRenderStatus()},{rootMargin:"50px",threshold:.1});setTimeout(()=>t.observe(this.$widget[0]),10)}checkRenderStatus(){this.note&&this.isIntersecting&&this.noteIdRefreshed===this.noteId&&this.shownNoteId!==this.noteId&&(this.shownNoteId=this.noteId,this.renderNoteList(this.note))}async renderNoteList(t){const e=new _E(this.$content,t,t.getChildNoteIds());this.$widget.toggleClass("full-height",e.isFullHeight),await e.renderList(),this.viewMode=e.viewMode}async refresh(){this.shownNoteId=null,await super.refresh()}async refreshNoteListEvent({noteId:t}){this.isNote(t)&&this.note&&await this.renderNoteList(this.note)}noteDetailRefreshedEvent({ntxId:t}){this.isNoteContext(t)&&(this.noteIdRefreshed=this.noteId,setTimeout(()=>this.checkRenderStatus(),100))}notesReloadedEvent({noteIds:t}){this.noteId&&t.includes(this.noteId)&&this.refresh()}entitiesReloadedEvent(t){t.loadResults.getAttributeRows().find(e=>e.noteId===this.noteId&&e.name&&["viewType","expanded","pageSize"].includes(e.name))&&(this.refresh(),this.checkRenderStatus()),this.viewMode&&this.viewMode.onEntitiesReloaded(t)&&(this.refresh(),this.checkRenderStatus())}buildTouchBarCommand(t){if(this.viewMode&&"buildTouchBarCommand"in this.viewMode)return this.viewMode.buildTouchBarCommand(t)}}class Vi{attribute;actionDef;constructor(t,e){this.attribute=t,this.actionDef=e}render(){try{const t=this.doRender();return t.find(".action-conf-del").on("click",()=>this.deleteAction()).attr("title",m("abstract_bulk_action.remove_this_search_action")),ct.initHelpDropdown(t),t}catch(t){return logError(`Failed rendering search action: ${JSON.stringify(this.attribute.dto)} with error: ${t.message} ${t.stack}`),null}}static get actionName(){return""}async saveAction(t){const e=Object.assign({name:this.constructor.actionName},t);await pt.put(`notes/${this.attribute.noteId}/attribute`,{attributeId:this.attribute.attributeId,type:"label",name:"action",value:JSON.stringify(e)}),await yi.waitForMaxKnownEntityChangeId()}async deleteAction(){await pt.remove(`notes/${this.attribute.noteId}/attributes/${this.attribute.attributeId}`),await yi.waitForMaxKnownEntityChangeId()}}const kE=`
|
||
<tr>
|
||
<td colspan="2">
|
||
<div style="display: flex; align-items: center">
|
||
<div style="margin-right: 10px;" class="text-nowrap">${m("move_note.move_note")}</div>
|
||
|
||
<div style="margin-right: 10px;" class="text-nowrap">${m("move_note.to")}</div>
|
||
|
||
<div class="input-group">
|
||
<input type="text" class="form-control target-parent-note" placeholder="${m("move_note.target_parent_note")}"/>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
<td class="button-column">
|
||
<div class="dropdown help-dropdown">
|
||
<span class="bx bx-help-circle icon-action" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
|
||
<div class="dropdown-menu dropdown-menu-right p-4">
|
||
<p>${m("move_note.on_all_matched_notes")}:</p>
|
||
|
||
<ul style="margin-bottom: 0;">
|
||
<li>${m("move_note.move_note_new_parent")}</li>
|
||
<li>${m("move_note.clone_note_new_parent")}</li>
|
||
<li>${m("move_note.nothing_will_happen")}</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
|
||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||
</td>
|
||
</tr>`;class iy extends Vi{static get actionName(){return"moveNote"}static get actionTitle(){return m("move_note.move_note")}doRender(){const t=$(kE),e=t.find(".target-parent-note");Xe.initNoteAutocomplete(e),e.setNote(this.actionDef.targetParentNoteId),e.on("autocomplete:closed",()=>i.scheduleUpdate());const i=new Hi(async()=>{await this.saveAction({targetParentNoteId:e.getSelectedNoteId()})},1e3);return e.on("input",()=>i.scheduleUpdate()),t}}const CE=`
|
||
<tr>
|
||
<td colspan="2">
|
||
<span class="bx bx-trash"></span>
|
||
|
||
${m("delete_note.delete_matched_notes")}
|
||
</td>
|
||
<td class="button-column">
|
||
<div class="dropdown help-dropdown">
|
||
<span class="bx bx-help-circle icon-action" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
|
||
<div class="dropdown-menu dropdown-menu-right p-4">
|
||
<p>${m("delete_note.delete_matched_notes_description")}</p>
|
||
|
||
<p>${m("delete_note.undelete_notes_instruction")}</p>
|
||
|
||
${m("delete_note.erase_notes_instruction")}
|
||
</div>
|
||
</div>
|
||
|
||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||
</td>
|
||
</tr>`;class ny extends Vi{static get actionName(){return"deleteNote"}static get actionTitle(){return m("delete_note.delete_note")}doRender(){return $(CE)}}const $E=`
|
||
<tr>
|
||
<td colspan="2">
|
||
<span class="bx bx-trash"></span>
|
||
${m("delete_revisions.delete_note_revisions")}
|
||
</td>
|
||
<td class="button-column">
|
||
<div class="dropdown help-dropdown">
|
||
<span class="bx bx-help-circle icon-action" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
|
||
<div class="dropdown-menu dropdown-menu-right p-4">
|
||
${m("delete_revisions.all_past_note_revisions")}
|
||
</div>
|
||
</div>
|
||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||
</td>
|
||
</tr>`;class oy extends Vi{static get actionName(){return"deleteRevisions"}static get actionTitle(){return m("delete_revisions.delete_note_revisions")}doRender(){return $($E)}}const SE=`
|
||
<tr>
|
||
<td>
|
||
${m("delete_label.delete_label")}
|
||
</td>
|
||
<td>
|
||
<input type="text"
|
||
class="form-control label-name"
|
||
pattern="[\\p{L}\\p{N}_:]+"
|
||
title="${m("delete_label.label_name_title")}"
|
||
placeholder="${m("delete_label.label_name_placeholder")}"/>
|
||
</td>
|
||
<td class="button-column">
|
||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||
</td>
|
||
</tr>`;class sy extends Vi{static get actionName(){return"deleteLabel"}static get actionTitle(){return m("delete_label.delete_label")}doRender(){const t=$(SE),e=t.find(".label-name");e.val(this.actionDef.labelName||"");const i=new Hi(async()=>{await this.saveAction({labelName:e.val()})},1e3);return e.on("input",()=>i.scheduleUpdate()),t}}const TE=`
|
||
<tr>
|
||
<td>
|
||
${m("delete_relation.delete_relation")}
|
||
</td>
|
||
<td>
|
||
<div style="display: flex; align-items: center">
|
||
<input type="text"
|
||
class="form-control relation-name"
|
||
pattern="[\\p{L}\\p{N}_:]+"
|
||
placeholder="${m("delete_relation.relation_name")}"
|
||
title="${m("delete_relation.allowed_characters")}"/>
|
||
</div>
|
||
</td>
|
||
<td class="button-column">
|
||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||
</td>
|
||
</tr>`;class ry extends Vi{static get actionName(){return"deleteRelation"}static get actionTitle(){return m("delete_relation.delete_relation")}doRender(){const t=$(TE),e=t.find(".relation-name");e.val(this.actionDef.relationName||"");const i=new Hi(async()=>{await this.saveAction({relationName:e.val()})},1e3);return e.on("input",()=>i.scheduleUpdate()),t}}const EE=`
|
||
<tr>
|
||
<td colspan="2">
|
||
<div style="display: flex; align-items: center">
|
||
<div style="margin-right: 10px; flex-shrink: 0;">${m("rename_label.rename_label_from")}</div>
|
||
|
||
<input type="text"
|
||
class="form-control old-label-name"
|
||
placeholder="${m("rename_label.old_name_placeholder")}"
|
||
pattern="[\\p{L}\\p{N}_:]+"
|
||
title="${m("rename_label.name_title")}"/>
|
||
|
||
<div style="margin-right: 10px; margin-left: 10px;" class="text-nowrap">${m("rename_label.to")}</div>
|
||
|
||
<input type="text"
|
||
class="form-control new-label-name"
|
||
placeholder="${m("rename_label.new_name_placeholder")}"
|
||
pattern="[\\p{L}\\p{N}_:]+"
|
||
title="${m("rename_label.name_title")}"/>
|
||
</div>
|
||
</td>
|
||
<td class="button-column">
|
||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||
</td>
|
||
</tr>`;class ay extends Vi{static get actionName(){return"renameLabel"}static get actionTitle(){return m("rename_label.rename_label")}doRender(){const t=$(EE),e=t.find(".old-label-name");e.val(this.actionDef.oldLabelName||"");const i=t.find(".new-label-name");i.val(this.actionDef.newLabelName||"");const n=new Hi(async()=>{await this.saveAction({oldLabelName:e.val(),newLabelName:i.val()})},1e3);return e.on("input",()=>n.scheduleUpdate()),i.on("input",()=>n.scheduleUpdate()),t}}const IE=`
|
||
<tr>
|
||
<td colspan="2">
|
||
<div style="display: flex; align-items: center">
|
||
<div style="margin-right: 10px; flex-shrink: 0;">${m("rename_relation.rename_relation_from")}</div>
|
||
|
||
<input type="text"
|
||
class="form-control old-relation-name"
|
||
placeholder="${m("rename_relation.old_name")}"
|
||
pattern="[\\p{L}\\p{N}_:]+"
|
||
title="${m("rename_relation.allowed_characters")}"/>
|
||
|
||
<div style="margin-right: 10px; margin-left: 10px;" class="text-nowrap">${m("rename_relation.to")}</div>
|
||
|
||
<input type="text"
|
||
class="form-control new-relation-name"
|
||
placeholder="${m("rename_relation.new_name")}"
|
||
pattern="[\\p{L}\\p{N}_:]+"
|
||
title="${m("rename_relation.allowed_characters")}"/>
|
||
</div>
|
||
</td>
|
||
<td class="button-column">
|
||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||
</td>
|
||
</tr>`;class ly extends Vi{static get actionName(){return"renameRelation"}static get actionTitle(){return m("rename_relation.rename_relation")}doRender(){const t=$(IE),e=t.find(".old-relation-name");e.val(this.actionDef.oldRelationName||"");const i=t.find(".new-relation-name");i.val(this.actionDef.newRelationName||"");const n=new Hi(async()=>{await this.saveAction({oldRelationName:e.val(),newRelationName:i.val()})},1e3);return e.on("input",()=>n.scheduleUpdate()),i.on("input",()=>n.scheduleUpdate()),t}}const AE=`
|
||
<tr>
|
||
<td colspan="2">
|
||
<div style="display: flex; align-items: center">
|
||
<div style="margin-right: 10px;" class="text-nowrap">${m("update_label_value.update_label_value")}</div>
|
||
|
||
<input type="text"
|
||
class="form-control label-name"
|
||
placeholder="${m("update_label_value.label_name_placeholder")}"
|
||
pattern="[\\p{L}\\p{N}_:]+"
|
||
title="${m("update_label_value.label_name_title")}"/>
|
||
|
||
<div style="margin-right: 10px; margin-left: 10px;" class="text-nowrap">${m("update_label_value.to_value")}</div>
|
||
|
||
<input type="text" class="form-control label-value" placeholder="${m("update_label_value.new_value_placeholder")}"/>
|
||
</div>
|
||
</td>
|
||
<td class="button-column">
|
||
<div class="dropdown help-dropdown">
|
||
<span class="bx bx-help-circle icon-action" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
|
||
<div class="dropdown-menu dropdown-menu-right p-4">
|
||
<p>${m("update_label_value.help_text")}</p>
|
||
|
||
${m("update_label_value.help_text_note")}
|
||
</div>
|
||
</div>
|
||
|
||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||
</td>
|
||
</tr>`;class cy extends Vi{static get actionName(){return"updateLabelValue"}static get actionTitle(){return m("update_label_value.update_label_value")}doRender(){const t=$(AE),e=t.find(".label-name");e.val(this.actionDef.labelName||"");const i=t.find(".label-value");i.val(this.actionDef.labelValue||"");const n=new Hi(async()=>{await this.saveAction({labelName:e.val(),labelValue:i.val()})},1e3);return e.on("input",()=>n.scheduleUpdate()),i.on("input",()=>n.scheduleUpdate()),t}}const LE=`
|
||
<tr>
|
||
<td colspan="2">
|
||
<div style="display: flex; align-items: center">
|
||
<div style="margin-right: 10px;" class="text-nowrap">${m("update_relation_target.update_relation")}</div>
|
||
|
||
<input type="text"
|
||
class="form-control relation-name"
|
||
placeholder="${m("update_relation_target.relation_name")}"
|
||
pattern="[\\p{L}\\p{N}_:]+"
|
||
style="flex-shrink: 3"
|
||
title="${m("update_relation_target.allowed_characters")}"/>
|
||
|
||
<div style="margin-right: 10px; margin-left: 10px;" class="text-nowrap">${m("update_relation_target.to")}</div>
|
||
|
||
<div class="input-group" style="flex-shrink: 2">
|
||
<input type="text" class="form-control target-note" placeholder="${m("update_relation_target.target_note")}"/>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
<td class="button-column">
|
||
<div class="dropdown help-dropdown">
|
||
<span class="bx bx-help-circle icon-action" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
|
||
<div class="dropdown-menu dropdown-menu-right p-4">
|
||
<p>${m("update_relation_target.on_all_matched_notes")}:</p>
|
||
|
||
<ul style="margin-bottom: 0;">
|
||
<li>${m("update_relation_target.change_target_note")}</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
|
||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||
</td>
|
||
</tr>`;class dy extends Vi{static get actionName(){return"updateRelationTarget"}static get actionTitle(){return m("update_relation_target.update_relation_target")}doRender(){const t=$(LE),e=t.find(".relation-name");e.val(this.actionDef.relationName||"");const i=t.find(".target-note");Xe.initNoteAutocomplete(i),i.setNote(this.actionDef.targetNoteId),i.on("autocomplete:closed",()=>n.scheduleUpdate());const n=new Hi(async()=>{await this.saveAction({relationName:e.val(),targetNoteId:i.getSelectedNoteId()})},1e3);return e.on("input",()=>n.scheduleUpdate()),i.on("input",()=>n.scheduleUpdate()),t}}const NE=`
|
||
<tr>
|
||
<td>
|
||
${m("execute_script.execute_script")}
|
||
</td>
|
||
<td>
|
||
<input type="text"
|
||
class="form-control script"
|
||
placeholder="note.title = note.title + '- suffix';"/>
|
||
</td>
|
||
<td class="button-column">
|
||
<div style="display: flex; align-items: center; justify-content: space-between;">
|
||
<div class="dropdown help-dropdown">
|
||
<span class="bx bx-help-circle icon-action" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
|
||
<div class="dropdown-menu dropdown-menu-right p-4">
|
||
${m("execute_script.help_text")}
|
||
|
||
${m("execute_script.example_1")}
|
||
|
||
<pre>note.title = note.title + ' - suffix';</pre>
|
||
|
||
${m("execute_script.example_2")}
|
||
|
||
<pre>for (const attr of note.getOwnedAttributes) { attr.markAsDeleted(); }</pre>
|
||
</div>
|
||
</div>
|
||
|
||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||
</div>
|
||
</td>
|
||
</tr>`;class hy extends Vi{static get actionName(){return"executeScript"}static get actionTitle(){return m("execute_script.execute_script")}doRender(){const t=$(NE),e=t.find(".script");e.val(this.actionDef.script||"");const i=new Hi(async()=>{await this.saveAction({script:e.val()})},1e3);return e.on("input",()=>i.scheduleUpdate()),t}}const ME=`
|
||
<tr>
|
||
<td colspan="2">
|
||
<div style="display: flex; align-items: center">
|
||
<div style="margin-right: 10px;" class="text-nowrap">${m("add_label.add_label")}</div>
|
||
|
||
<input type="text"
|
||
class="form-control label-name"
|
||
placeholder="${m("add_label.label_name_placeholder")}"
|
||
pattern="[\\p{L}\\p{N}_:]+"
|
||
title="${m("add_label.label_name_title")}"/>
|
||
|
||
<div style="margin-right: 10px; margin-left: 10px;" class="text-nowrap">${m("add_label.to_value")}</div>
|
||
|
||
<input type="text" class="form-control label-value" placeholder="${m("add_label.new_value_placeholder")}"/>
|
||
</div>
|
||
</td>
|
||
<td class="button-column">
|
||
<div class="dropdown help-dropdown">
|
||
<span class="bx bx-help-circle icon-action" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
|
||
<div class="dropdown-menu dropdown-menu-right p-4">
|
||
<p>${m("add_label.help_text")}</p>
|
||
|
||
<ul>
|
||
<li>${m("add_label.help_text_item1")}</li>
|
||
<li>${m("add_label.help_text_item2")}</li>
|
||
</ul>
|
||
|
||
${m("add_label.help_text_note")}
|
||
</div>
|
||
</div>
|
||
|
||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||
</td>
|
||
</tr>`;class uy extends Vi{static get actionName(){return"addLabel"}static get actionTitle(){return m("add_label.add_label")}doRender(){const t=$(ME),e=t.find(".label-name");e.val(this.actionDef.labelName||"");const i=t.find(".label-value");i.val(this.actionDef.labelValue||"");const n=new Hi(async()=>{await this.saveAction({labelName:e.val(),labelValue:i.val()})},1e3);return e.on("input",()=>n.scheduleUpdate()),i.on("input",()=>n.scheduleUpdate()),t}}const PE=`
|
||
<tr>
|
||
<td colspan="2">
|
||
<div style="display: flex; align-items: center">
|
||
<div style="margin-right: 10px;" class="text-nowrap">${m("add_relation.add_relation")}</div>
|
||
|
||
<input type="text"
|
||
class="form-control relation-name"
|
||
placeholder="${m("add_relation.relation_name")}"
|
||
pattern="[\\p{L}\\p{N}_:]+"
|
||
style="flex-shrink: 3"
|
||
title="${m("add_relation.allowed_characters")}"/>
|
||
|
||
<div style="margin-right: 10px; margin-left: 10px;" class="text-nowrap">${m("add_relation.to")}</div>
|
||
|
||
<div class="input-group" style="flex-shrink: 2">
|
||
<input type="text" class="form-control target-note" placeholder="${m("add_relation.target_note")}"/>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
<td class="button-column">
|
||
<div class="dropdown help-dropdown">
|
||
<span class="bx bx-help-circle icon-action" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
|
||
<div class="dropdown-menu dropdown-menu-right p-4">
|
||
${m("add_relation.create_relation_on_all_matched_notes")}
|
||
</div>
|
||
</div>
|
||
|
||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||
</td>
|
||
</tr>`;class py extends Vi{static get actionName(){return"addRelation"}static get actionTitle(){return m("add_relation.add_relation")}doRender(){const t=$(PE),e=t.find(".relation-name");e.val(this.actionDef.relationName||"");const i=t.find(".target-note");Xe.initNoteAutocomplete(i),i.setNote(this.actionDef.targetNoteId),i.on("autocomplete:closed",()=>n.scheduleUpdate());const n=new Hi(async()=>{await this.saveAction({relationName:e.val(),targetNoteId:i.getSelectedNoteId()})},1e3);return e.on("input",()=>n.scheduleUpdate()),i.on("input",()=>n.scheduleUpdate()),t}}const OE=`
|
||
<tr>
|
||
<td colspan="2">
|
||
<div style="display: flex; align-items: center">
|
||
<div style="margin-right: 10px; flex-shrink: 0;">${m("rename_note.rename_note_title_to")}</div>
|
||
|
||
<input type="text"
|
||
class="form-control new-title"
|
||
placeholder="${m("rename_note.new_note_title")}"
|
||
title="${m("rename_note.click_help_icon")}"/>
|
||
</div>
|
||
</td>
|
||
<td class="button-column">
|
||
<div class="dropdown help-dropdown">
|
||
<span class="bx bx-help-circle icon-action" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
|
||
<div class="dropdown-menu dropdown-menu-right p-4">
|
||
<p>${m("rename_note.evaluated_as_js_string")}</p>
|
||
|
||
<ul>
|
||
<li>${m("rename_note.example_note")}</li>
|
||
<li>${m("rename_note.example_new_title")}</li>
|
||
<li>${m("rename_note.example_date_prefix")}</li>
|
||
</ul>
|
||
|
||
${m("rename_note.api_docs")}
|
||
</div>
|
||
</div>
|
||
|
||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||
</td>
|
||
</tr>`;class fy extends Vi{static get actionName(){return"renameNote"}static get actionTitle(){return m("rename_note.rename_note")}doRender(){const t=$(OE),e=t.find(".new-title");e.val(this.actionDef.newTitle||"");const i=new Hi(async()=>{await this.saveAction({newTitle:e.val()})},1e3);return e.on("input",()=>i.scheduleUpdate()),t}}const DE=[{title:m("bulk_actions.labels"),actions:[uy,cy,ay,sy]},{title:m("bulk_actions.relations"),actions:[py,dy,ly,ry]},{title:m("bulk_actions.notes"),actions:[fy,iy,ny,oy]},{title:m("bulk_actions.other"),actions:[hy]}],my=[fy,iy,ny,oy,sy,ry,ay,ly,uy,py,cy,dy,hy];async function RE(o,t){await pt.post(`notes/${o}/attributes`,{type:"label",name:"action",value:JSON.stringify({name:t})}),await yi.waitForMaxKnownEntityChangeId()}function BE(o){return o.getLabels("action").map(e=>{let i;try{i=JSON.parse(e.value)}catch(s){return logError(`Parsing of attribute: '${e.value}' failed with error: ${s.message}`),null}const n=my.find(s=>s.actionName===i.name);return n?new n(e,i):(logError(`No action class for '${i.name}' found.`),null)}).filter(e=>!!e)}const Zc={addAction:RE,parseActions:BE,ACTION_CLASSES:my,ACTION_GROUPS:DE},zE=`
|
||
<div class="file-properties-widget">
|
||
<style>
|
||
.file-table {
|
||
width: 100%;
|
||
margin-top: 10px;
|
||
}
|
||
|
||
.file-table th, .file-table td {
|
||
padding: 5px;
|
||
overflow-wrap: anywhere;
|
||
}
|
||
|
||
.file-buttons {
|
||
padding: 10px;
|
||
display: flex;
|
||
justify-content: space-evenly;
|
||
}
|
||
</style>
|
||
|
||
<table class="file-table">
|
||
<tr>
|
||
<th class="text-nowrap">${m("file_properties.note_id")}:</th>
|
||
<td class="file-note-id"></td>
|
||
<th class="text-nowrap">${m("file_properties.original_file_name")}:</th>
|
||
<td class="file-filename"></td>
|
||
</tr>
|
||
<tr>
|
||
<th class="text-nowrap">${m("file_properties.file_type")}:</th>
|
||
<td class="file-filetype"></td>
|
||
<th class="text-nowrap">${m("file_properties.file_size")}:</th>
|
||
<td class="file-filesize"></td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td colspan="4">
|
||
<div class="file-buttons">
|
||
<button class="file-download btn btn-sm btn-primary" type="button">
|
||
<span class="bx bx-download"></span>
|
||
${m("file_properties.download")}
|
||
</button>
|
||
|
||
<button class="file-open btn btn-sm btn-primary" type="button">
|
||
<span class="bx bx-link-external"></span>
|
||
${m("file_properties.open")}
|
||
</button>
|
||
|
||
<button class="file-upload-new-revision btn btn-sm btn-primary">
|
||
<span class="bx bx-folder-open"></span>
|
||
${m("file_properties.upload_new_revision")}
|
||
</button>
|
||
|
||
<input type="file" class="file-upload-new-revision-input" style="display: none">
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>`;class HA extends hi{$fileNoteId;$fileName;$fileType;$fileSize;$downloadButton;$openButton;$uploadNewRevisionButton;$uploadNewRevisionInput;get name(){return"fileProperties"}get toggleCommand(){return"toggleRibbonTabFileProperties"}isEnabled(){return this.note&&this.note.type==="file"}getTitle(){return{show:this.isEnabled(),activate:!0,title:m("file_properties.title"),icon:"bx bx-file"}}doRender(){this.$widget=$(zE),this.contentSized(),this.$fileNoteId=this.$widget.find(".file-note-id"),this.$fileName=this.$widget.find(".file-filename"),this.$fileType=this.$widget.find(".file-filetype"),this.$fileSize=this.$widget.find(".file-filesize"),this.$downloadButton=this.$widget.find(".file-download"),this.$openButton=this.$widget.find(".file-open"),this.$uploadNewRevisionButton=this.$widget.find(".file-upload-new-revision"),this.$uploadNewRevisionInput=this.$widget.find(".file-upload-new-revision-input"),this.$downloadButton.on("click",()=>this.noteId&&en.downloadFileNote(this.noteId)),this.$openButton.on("click",()=>this.noteId&&this.note&&en.openNoteExternally(this.noteId,this.note.mime)),this.$uploadNewRevisionButton.on("click",()=>{this.$uploadNewRevisionInput.trigger("click")}),this.$uploadNewRevisionInput.on("change",async()=>{const t=this.$uploadNewRevisionInput[0].files[0];this.$uploadNewRevisionInput.val(""),(await pt.upload(`notes/${this.noteId}/file`,t)).uploaded?(ft.showMessage(m("file_properties.upload_success")),this.refresh()):ft.showError(m("file_properties.upload_failed"))})}async refreshWithNote(t){if(this.$widget.show(),!this.note)return;this.$fileNoteId.text(t.noteId),this.$fileName.text(t.getLabelValue("originalFileName")||"?"),this.$fileType.text(t.mime);const e=await this.note.getBlob();this.$fileSize.text(ct.formatSize(e?.contentLength??0)),this.$openButton.toggle(!t.isProtected),this.$downloadButton.toggle(!t.isProtected||Mi.isProtectedSessionAvailable()),this.$uploadNewRevisionButton.toggle(!t.isProtected||Mi.isProtectedSessionAvailable())}}class VA extends Bf{noteContext;constructor(){super(),this.class("scrolling-container"),this.css("overflow","auto"),this.css("scroll-behavior","smooth"),this.css("position","relative")}setNoteContextEvent({noteContext:t}){this.noteContext=t}async noteSwitchedEvent({noteContext:t,notePath:e}){this.$widget.scrollTop(0)}async noteSwitchedAndActivatedEvent({noteContext:t,notePath:e}){this.noteContext=t,this.$widget.scrollTop(0)}async activeContextChangedEvent({noteContext:t}){this.noteContext=t}async handleEventInChildren(t,e){if(t==="readOnlyTemporarilyDisabled"&&this.noteContext&&"noteContext"in e&&this.noteContext.ntxId===e.noteContext?.ntxId){const i=this.$widget.scrollTop()??0,n=super.handleEventInChildren(t,e);return n&&n.then(()=>setTimeout(()=>this.$widget.scrollTop(i),500)),n}else return super.handleEventInChildren(t,e)}scrollContainerToCommand({position:t}){this.$widget.scrollTop(t)}}class UA extends Xd{originalViewportHeight;constructor(t){super(t?"column":"row"),this.id("root-widget"),this.css("height","100dvh"),this.originalViewportHeight=Tf()}render(){return ct.isMobile()&&window.visualViewport?.addEventListener("resize",()=>this.#t()),super.render()}#t(){const e=Tf()<this.originalViewportHeight;this.$widget.toggleClass("virtual-keyboard-opened",e)}}function Tf(){return window.visualViewport?.height??window.innerHeight}const FE='<div class="spacer"></div>';class WE extends ge{baseSize;growthFactor;constructor(t=0,e=1e3){super(),this.baseSize=t,this.growthFactor=e}doRender(){this.$widget=$(FE),this.$widget.css("flex-basis",this.baseSize),this.$widget.css("flex-grow",this.growthFactor),this.$widget.css("flex-shrink",1e3),this.$widget.on("contextmenu",t=>(this.$widget.tooltip("hide"),Ho.show({x:t.pageX,y:t.pageY,items:[{title:m("spacer.configure_launchbar"),command:"showLaunchBarSubtree",uiIcon:"bx "+(ct.isMobile()?"bx-mobile":"bx-sidebar")}],selectMenuItemHandler:({command:e})=>{e&&Pt.triggerCommand(e)}}),!1))}}const HE=`
|
||
<div class="quick-search input-group input-group-sm">
|
||
<style>
|
||
.quick-search {
|
||
padding: 10px 10px 10px 0px;
|
||
height: 50px;
|
||
}
|
||
|
||
.quick-search button, .quick-search input {
|
||
border: 0;
|
||
font-size: 100% !important;
|
||
}
|
||
|
||
.quick-search .dropdown-menu {
|
||
max-height: 600px;
|
||
max-width: 400px;
|
||
overflow-y: auto;
|
||
overflow-x: hidden;
|
||
text-overflow: ellipsis;
|
||
box-shadow: -30px 50px 93px -50px black;
|
||
}
|
||
</style>
|
||
|
||
<div class="input-group-prepend">
|
||
<button class="btn btn-outline-secondary search-button" type="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||
<span class="bx bx-search"></span>
|
||
</button>
|
||
<div class="dropdown-menu tn-dropdown-list"></div>
|
||
</div>
|
||
<input type="text" class="form-control form-control-sm search-string" placeholder="${m("quick-search.placeholder")}">
|
||
</div>`,Gc=15;class VE extends ge{dropdown;$searchString;$dropdownMenu;doRender(){return this.$widget=$(HE),this.$searchString=this.$widget.find(".search-string"),this.$dropdownMenu=this.$widget.find(".dropdown-menu"),this.dropdown=Ko.getOrCreateInstance(this.$widget.find("[data-bs-toggle='dropdown']")[0],{reference:this.$searchString[0],popperConfig:{strategy:"fixed",placement:"bottom"}}),this.$widget.find(".input-group-prepend").on("shown.bs.dropdown",()=>this.search()),ct.isMobile()&&this.$searchString.keydown(t=>{t.which===13&&(this.$dropdownMenu.is(":visible")?this.search():this.dropdown.show(),t.preventDefault(),t.stopPropagation())}),Bi.bindElShortcut(this.$searchString,"return",()=>{this.$dropdownMenu.is(":visible")?this.search():this.dropdown.show(),this.$searchString.focus()}),Bi.bindElShortcut(this.$searchString,"down",()=>{this.$dropdownMenu.find(".dropdown-item:not(.disabled):first").focus()}),Bi.bindElShortcut(this.$searchString,"esc",()=>{this.dropdown.hide()}),this.$widget}async search(){const t=String(this.$searchString.val())?.trim();if(!t){this.dropdown.hide();return}this.$dropdownMenu.empty(),this.$dropdownMenu.append(`<span class="dropdown-item disabled"><span class="bx bx-loader bx-spin"></span>${m("quick-search.searching")}</span>`);const{searchResultNoteIds:e,error:i}=await pt.get(`quick-search/${encodeURIComponent(t)}`);if(i){let a=new As(this.$searchString[0],{trigger:"manual",title:`Search error: ${i}`,placement:"right"});a.show(),setTimeout(()=>a.dispose(),4e3)}const n=e.slice(0,Math.min(Gc,e.length));this.$dropdownMenu.empty(),n.length===0&&this.$dropdownMenu.append(`<span class="dropdown-item disabled">${m("quick-search.no-results")}</span>`);for(const a of await Mt.getNotes(n)){const l=await Pe.createLink(a.noteId,{showNotePath:!0,showNoteIcon:!0});l.addClass("dropdown-item"),l.attr("tabIndex","0"),l.on("click",c=>{if(this.dropdown.hide(),!c.target||c.target.nodeName!=="A"){const u=Pt.tabManager.getActiveContext();u&&u.setNote(a.noteId)}}),Bi.bindElShortcut(l,"return",()=>{this.dropdown.hide();const c=Pt.tabManager.getActiveContext();c&&c.setNote(a.noteId)}),this.$dropdownMenu.append(l)}if(e.length>Gc){const a=e.length-Gc;this.$dropdownMenu.append(`<span class="dropdown-item disabled">${m("quick-search.more-results",{number:a})}</span>`)}const s=$('<a class="dropdown-item" tabindex="0">').text(m("quick-search.show-in-full-search"));this.$dropdownMenu.append($('<div class="dropdown-divider">')),this.$dropdownMenu.append(s),s.on("click",()=>this.showInFullSearch()),Bi.bindElShortcut(s,"return",()=>this.showInFullSearch()),Bi.bindElShortcut(this.$dropdownMenu.find(".dropdown-item:first"),"up",()=>this.$searchString.focus()),this.dropdown.update()}async showInFullSearch(){this.dropdown.hide(),await Pt.triggerCommand("searchNotes",{searchString:String(this.$searchString.val())})}quickSearchEvent(){this.$searchString.focus()}}let gy;qo.getActions().then(o=>gy=o);class Yl extends Qv{constructor(){super(),this.settings={titlePlacement:"right",title:null,icon:null,onContextMenu:null}}doRender(){super.doRender(),this.settings.command?this.$widget.on("click",()=>{this.tooltip.hide(),this._command&&this.triggerCommand(this._command)}):console.warn(`Button widget '${this.componentId}' has no defined command`,this.settings)}getTitle(){const t=super.getTitle(),e=gy.find(i=>i.actionName===this._command);return e&&e.effectiveShortcuts.length>0?`${t} (${e.effectiveShortcuts.join(", ")})`:t}onClick(t){return this.settings.onClick=t,this}command(t){return this.settings.command=t,this}get _command(){return typeof this.settings.command=="function"?this.settings.command():this.settings.command}}async function UE(o=!1){const t=await pt.post("sync/now");t.success?ft.showMessage(m("sync.finished-successfully")):(t.message.length>200&&(t.message=`${t.message.substr(0,200)}...`),(!o||t.errorCode!=="NOT_CONFIGURED")&&ft.showError(m("sync.failed",{message:t.message})))}const jE={syncNow:UE};class jA extends Wo{isEnabled(){return!!(super.isEnabled()&&this.note&&this.noteContext?.viewScope?.viewMode==="default")}constructor(){super(),this.icon("bx-pencil").title(m("edit_button.edit_this_note")).titlePlacement("bottom").onClick(t=>{this.noteContext?.viewScope&&(this.noteContext.viewScope.readOnlyTemporarilyDisabled=!0,Pt.triggerEvent("readOnlyTemporarilyDisabled",{noteContext:this.noteContext}))})}async refreshWithNote(t){if(Qt.is("databaseReadonly")){this.toggleInt(!1);return}if(t.isProtected&&!Mi.isProtectedSessionAvailable())this.toggleInt(!1);else{this.toggleInt(!1);const e=this.isVisible(),i=await this.noteContext?.isReadOnly();this.toggleInt(!!i),this.isVisible()&&!e&&this.$widget&&(this.$widget.addClass("bx-tada bx-lg"),setTimeout(()=>{this.$widget?.removeClass("bx-tada bx-lg")},1700))}await super.refreshWithNote(t)}entitiesReloadedEvent({loadResults:t}){t.getAttributeRows().find(e=>e.type==="label"&&e.name?.toLowerCase().includes("readonly")&&this.note&&Be.isAffecting(e,this.note))&&(this.noteContext?.viewScope&&(this.noteContext.viewScope.readOnlyTemporarilyDisabled=!1),this.refresh())}readOnlyTemporarilyDisabledEvent(){this.refresh()}async noteTypeMimeChangedEvent({noteId:t}){this.isNote(t)&&await this.refresh()}}const qE=`
|
||
<div class="backlinks-widget has-overflow">
|
||
<style>
|
||
.backlinks-widget {
|
||
position: relative;
|
||
}
|
||
|
||
.backlinks-ticker {
|
||
border-radius: 10px;
|
||
border-color: var(--main-border-color);
|
||
background-color: var(--more-accented-background-color);
|
||
padding: 4px 10px 4px 10px;
|
||
opacity: 90%;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
}
|
||
|
||
.backlinks-count {
|
||
cursor: pointer;
|
||
}
|
||
|
||
.backlinks-items {
|
||
z-index: 10;
|
||
position: absolute;
|
||
top: 50px;
|
||
right: 10px;
|
||
width: 400px;
|
||
border-radius: 10px;
|
||
background-color: var(--accented-background-color);
|
||
color: var(--main-text-color);
|
||
padding: 20px;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.backlink-excerpt {
|
||
border-left: 2px solid var(--main-border-color);
|
||
padding-left: 10px;
|
||
opacity: 80%;
|
||
font-size: 90%;
|
||
}
|
||
|
||
.backlink-excerpt .backlink-link { /* the actual backlink */
|
||
font-weight: bold;
|
||
background-color: yellow;
|
||
}
|
||
</style>
|
||
|
||
<div class="backlinks-ticker">
|
||
<span class="backlinks-count"></span>
|
||
</div>
|
||
|
||
<div class="backlinks-items dropdown-menu" style="display: none;"></div>
|
||
</div>
|
||
`;class qA extends hi{$count;$items;$ticker;doRender(){this.$widget=$(qE),this.$count=this.$widget.find(".backlinks-count"),this.$items=this.$widget.find(".backlinks-items"),this.$ticker=this.$widget.find(".backlinks-ticker"),this.$count.on("click",()=>{this.$items.toggle(),this.$items.css("max-height",($(window).height()??0)-(this.$items.offset()?.top??0)-10),this.$items.is(":visible")&&this.renderBacklinks()}),this.contentSized()}async refreshWithNote(t){if(this.clearItems(),this.noteContext?.viewScope?.viewMode!=="default"){this.toggle(!1);return}const e=await pt.get(`note-map/${this.noteId}/backlink-count`);if(!e||!e.count){this.toggle(!1);return}this.toggle(!0),this.$count.text(`${m("zpetne_odkazy.backlink",{count:e.count})}`)}toggle(t){this.$widget.toggleClass("hidden-no-content",!t).toggleClass("visible",!!t)}clearItems(){this.$items.empty().hide()}async renderBacklinks(){if(!this.note)return;this.$items.empty();const t=await pt.get(`note-map/${this.noteId}/backlinks`);if(t.length){await Mt.getNotes(t.map(e=>e.noteId));for(const e of t){const i=$("<div>");i.append(await Pe.createLink(e.noteId,{showNoteIcon:!0,showNotePath:!0,showTooltip:!1})),e.relationName?i.append($("<p>").text(`${m("zpetne_odkazy.relation")}: ${e.relationName}`)):i.append(...e.excerpts??[]),this.$items.append(i)}}}}const KE=`
|
||
<div class="shared-info-widget alert alert-warning use-tn-links">
|
||
<style>
|
||
.shared-info-widget {
|
||
margin: 10px;
|
||
contain: none;
|
||
padding: 10px;
|
||
font-weight: bold;
|
||
}
|
||
</style>
|
||
|
||
<span class="shared-text"></span> <a class="shared-link external"></a>. ${m("shared_info.help_link")}
|
||
</div>`;class KA extends hi{$sharedLink;$sharedText;isEnabled(){return super.isEnabled()&&this.noteId!=="_share"&&this.note?.hasAncestor("_share")}doRender(){this.$widget=$(KE),this.$sharedLink=this.$widget.find(".shared-link"),this.$sharedText=this.$widget.find(".shared-text"),this.contentSized()}async refreshWithNote(t){const e=Qt.get("syncServerHost");let i;const n=this.getShareId(t);if(e)i=`${e}/share/${n}`,this.$sharedText.text(m("shared_info.shared_publicly"));else{let s=location.host;s.endsWith("/")&&(s=s.substr(0,s.length-1)),i=`${location.protocol}//${s}${location.pathname}share/${n}`,this.$sharedText.text(m("shared_info.shared_locally"))}this.$sharedLink.attr("href",i).text(i)}getShareId(t){return t.hasOwnedLabel("shareRoot")?"":t.getOwnedLabelValue("shareAlias")||t.noteId}entitiesReloadedEvent({loadResults:t}){t.getAttributeRows().find(e=>e.name?.startsWith("_share")&&Be.isAffecting(e,this.note))?this.refresh():t.getBranchRows().find(e=>e.noteId===this.noteId)&&this.refresh()}}const ZE=`
|
||
<div class="floating-buttons no-print">
|
||
<style>
|
||
.floating-buttons {
|
||
position: relative;
|
||
}
|
||
|
||
.floating-buttons-children,
|
||
.show-floating-buttons {
|
||
position: absolute;
|
||
top: 10px;
|
||
right: 10px;
|
||
display: flex;
|
||
flex-direction: row;
|
||
z-index: 100;
|
||
}
|
||
|
||
.note-split.rtl .floating-buttons-children,
|
||
.note-split.rtl .show-floating-buttons {
|
||
right: unset;
|
||
left: 10px;
|
||
}
|
||
|
||
.note-split.rtl .close-floating-buttons {
|
||
order: -1;
|
||
}
|
||
|
||
.note-split.rtl .close-floating-buttons,
|
||
.note-split.rtl .show-floating-buttons {
|
||
transform: rotate(180deg);
|
||
}
|
||
|
||
.type-canvas .floating-buttons-children {
|
||
top: 70px;
|
||
}
|
||
|
||
.type-canvas .floating-buttons-children > * {
|
||
--border-radius: 0; /* Overridden by themes */
|
||
}
|
||
|
||
.floating-buttons-children > *:not(.hidden-int):not(.no-content-hidden) {
|
||
margin: 2px;
|
||
}
|
||
|
||
.floating-buttons-children > *:not(.has-overflow) {
|
||
overflow: hidden;
|
||
}
|
||
|
||
.floating-buttons-children > button, .floating-buttons-children .floating-button {
|
||
font-size: 150%;
|
||
padding: 5px 10px 4px 10px;
|
||
width: 40px;
|
||
cursor: pointer;
|
||
color: var(--button-text-color);
|
||
background: var(--button-background-color);
|
||
border-radius: var(--button-border-radius);
|
||
border: 1px solid transparent;
|
||
display: flex;
|
||
justify-content: space-around;
|
||
}
|
||
|
||
.floating-buttons-children > button:hover, .floating-buttons-children .floating-button:hover {
|
||
text-decoration: none;
|
||
border-color: var(--button-border-color);
|
||
}
|
||
|
||
.floating-buttons .floating-buttons-children.temporarily-hidden {
|
||
display: none;
|
||
}
|
||
</style>
|
||
|
||
<div class="floating-buttons-children"></div>
|
||
|
||
<!-- Show button that displays floating button after click on close button -->
|
||
<div class="show-floating-buttons">
|
||
<style>
|
||
.floating-buttons-children.temporarily-hidden+.show-floating-buttons {
|
||
display: block;
|
||
}
|
||
|
||
.floating-buttons-children:not(.temporarily-hidden)+.show-floating-buttons {
|
||
display: none;
|
||
}
|
||
|
||
.show-floating-buttons {
|
||
/* display: none;*/
|
||
margin-left: 5px !important;
|
||
}
|
||
|
||
.show-floating-buttons-button {
|
||
border: 1px solid transparent;
|
||
color: var(--button-text-color);
|
||
padding: 6px;
|
||
border-radius: 100px;
|
||
}
|
||
|
||
.show-floating-buttons-button:hover {
|
||
border: 1px solid var(--button-border-color);
|
||
}
|
||
</style>
|
||
|
||
<button type="button" class="show-floating-buttons-button btn bx bx-chevrons-left"
|
||
title="${m("show_floating_buttons_button.button_title")}"></button>
|
||
</div>
|
||
</div>`;class ZA extends hi{$children;doRender(){this.$widget=$(ZE),this.$children=this.$widget.find(".floating-buttons-children");for(const t of this.children)"render"in t&&this.$children.append(t.render())}async refreshWithNote(t){this.toggle(!0),this.$widget.find(".show-floating-buttons-button").on("click",()=>this.toggle(!0))}toggle(t){this.$widget.find(".floating-buttons-children").toggleClass("temporarily-hidden",!t)}hideFloatingButtonsCommand(){this.toggle(!1)}}const GE=`
|
||
<div class="relation-map-buttons">
|
||
<style>
|
||
.relation-map-buttons {
|
||
display: flex;
|
||
gap: 10px;
|
||
}
|
||
</style>
|
||
|
||
<button type="button"
|
||
class="relation-map-create-child-note floating-button btn bx bx-folder-plus"
|
||
title="${m("relation_map_buttons.create_child_note_title")}"></button>
|
||
|
||
<button type="button"
|
||
class="relation-map-reset-pan-zoom floating-button btn bx bx-crop"
|
||
title="${m("relation_map_buttons.reset_pan_zoom_title")}"></button>
|
||
|
||
<div class="btn-group">
|
||
<button type="button"
|
||
class="relation-map-zoom-in floating-button btn bx bx-zoom-in"
|
||
title="${m("relation_map_buttons.zoom_in_title")}"></button>
|
||
|
||
<button type="button"
|
||
class="relation-map-zoom-out floating-button btn bx bx-zoom-out"
|
||
title="${m("relation_map_buttons.zoom_out_title")}"></button>
|
||
</div>
|
||
</div>`;class GA extends hi{$createChildNote;$zoomInButton;$zoomOutButton;$resetPanZoomButton;isEnabled(){return super.isEnabled()&&this.note?.type==="relationMap"}doRender(){super.doRender(),this.$widget=$(GE),this.$createChildNote=this.$widget.find(".relation-map-create-child-note"),this.$zoomInButton=this.$widget.find(".relation-map-zoom-in"),this.$zoomOutButton=this.$widget.find(".relation-map-zoom-out"),this.$resetPanZoomButton=this.$widget.find(".relation-map-reset-pan-zoom"),this.$createChildNote.on("click",()=>this.triggerEvent("relationMapCreateChildNote",{ntxId:this.ntxId})),this.$resetPanZoomButton.on("click",()=>this.triggerEvent("relationMapResetPanZoom",{ntxId:this.ntxId})),this.$zoomInButton.on("click",()=>this.triggerEvent("relationMapResetZoomIn",{ntxId:this.ntxId})),this.$zoomOutButton.on("click",()=>this.triggerEvent("relationMapResetZoomOut",{ntxId:this.ntxId})),this.contentSized()}}const YE=`
|
||
<button type="button"
|
||
class="export-svg-button"
|
||
title="${m("svg_export_button.button_title")}">
|
||
<span class="bx bxs-file-image"></span>
|
||
</button>
|
||
`;class YA extends hi{isEnabled(){return super.isEnabled()&&["mermaid","mindMap"].includes(this.note?.type??"")&&this.note?.isContentAvailable()&&this.noteContext?.viewScope?.viewMode==="default"}doRender(){super.doRender(),this.$widget=$(YE),this.$widget.on("click",()=>this.triggerEvent("exportSvg",{ntxId:this.ntxId})),this.contentSized()}}const JE=`
|
||
<div class="dropdown right-dropdown-widget">
|
||
<button type="button" data-bs-toggle="dropdown"
|
||
aria-haspopup="true" aria-expanded="false"
|
||
class="bx right-dropdown-button launcher-button"></button>
|
||
|
||
<div class="tooltip-trigger"></div>
|
||
|
||
<div class="dropdown-menu"></div>
|
||
</div>
|
||
`;class vy extends ge{iconClass;title;dropdownTpl;settings;$dropdownMenu;dropdown;$tooltip;tooltip;$dropdownContent;constructor(t,e,i){super(),this.iconClass=e,this.title=t,this.dropdownTpl=i,this.settings={titlePlacement:"right"}}doRender(){this.$widget=$(JE),this.$dropdownMenu=this.$widget.find(".dropdown-menu"),this.dropdown=Ko.getOrCreateInstance(this.$widget.find("[data-bs-toggle='dropdown']")[0],{popperConfig:{placement:this.settings.titlePlacement}}),this.$tooltip=this.$widget.find(".tooltip-trigger").attr("title",this.title),this.tooltip=new As(this.$tooltip[0],{placement:this.settings.titlePlacement,fallbackPlacements:[this.settings.titlePlacement]}),this.$widget.find(".right-dropdown-button").addClass(this.iconClass).on("click",()=>this.tooltip.hide()).on("mouseenter",()=>this.tooltip.show()).on("mouseleave",()=>this.tooltip.hide()),this.$widget.on("show.bs.dropdown",async()=>{await this.dropdownShown();const t=this.$dropdownMenu[0].getBoundingClientRect(),i=($(window).height()||0)-t.bottom;i<0&&this.$dropdownMenu.css("top",i)}),this.$dropdownContent=$(this.dropdownTpl),this.$widget.find(".dropdown-menu").append(this.$dropdownContent)}async dropdownShown(){}}var sl={exports:{}},QE=sl.exports,Ef;function XE(){return Ef||(Ef=1,function(o,t){(function(e,i){o.exports=i()})(QE,function(){var e="minute",i=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(s,a,l){var c=a.prototype;l.utc=function(P){var F={date:P,utc:!0,args:arguments};return new a(F)},c.utc=function(P){var F=l(this.toDate(),{locale:this.$L,utc:!0});return P?F.add(this.utcOffset(),e):F},c.local=function(){return l(this.toDate(),{locale:this.$L,utc:!1})};var u=c.parse;c.parse=function(P){P.utc&&(this.$u=!0),this.$utils().u(P.$offset)||(this.$offset=P.$offset),u.call(this,P)};var p=c.init;c.init=function(){if(this.$u){var P=this.$d;this.$y=P.getUTCFullYear(),this.$M=P.getUTCMonth(),this.$D=P.getUTCDate(),this.$W=P.getUTCDay(),this.$H=P.getUTCHours(),this.$m=P.getUTCMinutes(),this.$s=P.getUTCSeconds(),this.$ms=P.getUTCMilliseconds()}else p.call(this)};var v=c.utcOffset;c.utcOffset=function(P,F){var R=this.$utils().u;if(R(P))return this.$u?0:R(this.$offset)?v.call(this):this.$offset;if(typeof P=="string"&&(P=function(tt){tt===void 0&&(tt="");var it=tt.match(i);if(!it)return null;var rt=(""+it[0]).match(n)||["-",0,0],vt=rt[0],Dt=60*+rt[1]+ +rt[2];return Dt===0?0:vt==="+"?Dt:-Dt}(P),P===null))return this;var q=Math.abs(P)<=16?60*P:P,H=this;if(F)return H.$offset=q,H.$u=P===0,H;if(P!==0){var Q=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(H=this.local().add(q+Q,e)).$offset=q,H.$x.$localOffset=Q}else H=this.utc();return H};var x=c.format;c.format=function(P){var F=P||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return x.call(this,F)},c.valueOf=function(){var P=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*P},c.isUTC=function(){return!!this.$u},c.toISOString=function(){return this.toDate().toISOString()},c.toString=function(){return this.toDate().toUTCString()};var T=c.toDate;c.toDate=function(P){return P==="s"&&this.$offset?l(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():T.call(this)};var M=c.diff;c.diff=function(P,F,R){if(P&&this.$u===P.$u)return M.call(this,P,F,R);var q=this.local(),H=l(P).local();return M.call(q,H,F,R)}}})}(sl)),sl.exports}var tI=XE();const eI=Br(tI);var rl={exports:{}},iI=rl.exports,If;function nI(){return If||(If=1,function(o,t){(function(e,i){o.exports=i()})(iI,function(){return function(e,i){i.prototype.isSameOrAfter=function(n,s){return this.isSame(n,s)||this.isAfter(n,s)}}})}(rl)),rl.exports}var oI=nI();const sI=Br(oI);br.extend(eI);br.extend(sI);const yy=[m("calendar.january"),m("calendar.febuary"),m("calendar.march"),m("calendar.april"),m("calendar.may"),m("calendar.june"),m("calendar.july"),m("calendar.august"),m("calendar.september"),m("calendar.october"),m("calendar.november"),m("calendar.december")],rI=`
|
||
<div class="calendar-dropdown-widget">
|
||
<style>
|
||
.calendar-dropdown-widget {
|
||
width: 400px;
|
||
}
|
||
</style>
|
||
|
||
<div class="calendar-header">
|
||
<div class="calendar-month-selector">
|
||
<button class="calendar-btn tn-tool-button bx bx-chevron-left" data-calendar-toggle="previous"></button>
|
||
|
||
<button class="btn dropdown-toggle select-button" type="button"
|
||
data-bs-toggle="dropdown" data-bs-auto-close="true"
|
||
aria-expanded="false"
|
||
data-calendar-input="month"></button>
|
||
<ul class="dropdown-menu" data-calendar-input="month-list">
|
||
${Object.entries(yy).map(([o,t])=>`<li><button class="dropdown-item" data-value=${o}>${t}</button></li>`).join("")}
|
||
</ul>
|
||
|
||
<button class="calendar-btn tn-tool-button bx bx-chevron-right" data-calendar-toggle="next"></button>
|
||
</div>
|
||
|
||
<div class="calendar-year-selector">
|
||
<button class="calendar-btn tn-tool-button bx bx-chevron-left" data-calendar-toggle="previousYear"></button>
|
||
|
||
<input type="number" min="1900" max="2999" step="1" data-calendar-input="year" />
|
||
|
||
<button class="calendar-btn tn-tool-button bx bx-chevron-right" data-calendar-toggle="nextYear"></button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="calendar-week"></div>
|
||
<div class="calendar-body" data-calendar-area="month"></div>
|
||
</div>`,aI=[m("calendar.sun"),m("calendar.mon"),m("calendar.tue"),m("calendar.wed"),m("calendar.thu"),m("calendar.fri"),m("calendar.sat")];class lI extends vy{$month;$weekHeader;$monthSelect;$yearSelect;$next;$previous;$nextYear;$previousYear;monthDropdown;firstDayOfWeek;weekCalculationOptions;activeDate=null;todaysDate;date;weekNoteEnable=!1;weekNotes=[];constructor(t="",e=""){super(t,e,rI)}doRender(){super.doRender(),this.$month=this.$dropdownContent.find('[data-calendar-area="month"]'),this.$weekHeader=this.$dropdownContent.find(".calendar-week"),this.manageFirstDayOfWeek(),this.initWeekCalculation(),this.$monthSelect=this.$dropdownContent.find('[data-calendar-input="month"]'),this.$monthSelect.on("show.bs.dropdown",t=>{t.stopPropagation()}),this.monthDropdown=Ko.getOrCreateInstance(this.$monthSelect[0]),this.$dropdownContent.find('[data-calendar-input="month-list"] button').on("click",t=>{const i=t.target.dataset.value;i&&(this.date=this.date.month(parseInt(i)),this.createMonth())}),this.$next=this.$dropdownContent.find('[data-calendar-toggle="next"]'),this.$next.on("click",()=>{this.date=this.date.add(1,"month"),this.createMonth()}),this.$previous=this.$dropdownContent.find('[data-calendar-toggle="previous"]'),this.$previous.on("click",()=>{this.date=this.date.subtract(1,"month"),this.createMonth()}),this.$yearSelect=this.$dropdownContent.find('[data-calendar-input="year"]'),this.$yearSelect.on("input",t=>{const e=t.target;this.date=this.date.year(parseInt(e.value)),this.createMonth()}),this.$nextYear=this.$dropdownContent.find('[data-calendar-toggle="nextYear"]'),this.$nextYear.on("click",()=>{this.date=this.date.add(1,"year"),this.createMonth()}),this.$previousYear=this.$dropdownContent.find('[data-calendar-toggle="previousYear"]'),this.$previousYear.on("click",()=>{this.date=this.date.subtract(1,"year"),this.createMonth()}),this.$dropdownContent.on("click",".calendar-date",async t=>{const e=$(t.target).closest(".calendar-date").attr("data-calendar-date");if(e){const i=await cl.getDayNote(e);i?(Pt.tabManager.getActiveContext()?.setNote(i.noteId),this.dropdown?.hide()):ft.showError(m("calendar.cannot_find_day_note"))}t.stopPropagation()}),this.$dropdownContent.on("click",".calendar-week-number",async t=>{if(!this.weekNoteEnable)return;const e=$(t.target).closest(".calendar-week-number").attr("data-calendar-week-number");if(e){const i=await cl.getWeekNote(e);i?(Pt.tabManager.getActiveContext()?.setNote(i.noteId),this.dropdown?.hide()):ft.showError(m("calendar.cannot_find_week_note"))}t.stopPropagation()}),this.$dropdownContent.on("click",t=>{const e=$(t.target);if(e.closest(".btn.dropdown-toggle.select-button").length||e.closest(".calendar-year-selector").length){t.stopPropagation();return}this.monthDropdown.hide(),t.stopPropagation()})}async getWeekNoteEnable(){const t=await pt.get(`search/${encodeURIComponent("#calendarRoot")}`);if(t.length===0){this.weekNoteEnable=!1;return}const e=await pt.get(`notes/${t}/attributes`);for(const i of e)if(i.name==="enableWeekNote"){this.weekNoteEnable=!0;return}this.weekNoteEnable=!1}manageFirstDayOfWeek(){this.firstDayOfWeek=Qt.getInt("firstDayOfWeek")||0;let t=[...aI];const e=t.splice(0,this.firstDayOfWeek);t=["",...t,...e],this.$weekHeader.html(t.map(i=>`<span>${i}</span>`).join(""))}initWeekCalculation(){this.weekCalculationOptions={firstWeekType:Qt.getInt("firstWeekOfYear")||0,minDaysInFirstWeek:Qt.getInt("minDaysInFirstWeek")||4}}getWeekNumber(t){const e=t.year(),i=P=>(P-this.firstDayOfWeek+7)%7,n=t.clone().year(e).month(0).date(1),s=n.day(),a=i(s);let l=n.clone().subtract(a,"day");switch(this.weekCalculationOptions.firstWeekType){case 1:{l.clone().add(3,"day").year()<e&&(l=l.add(7,"day"));break}case 2:{7-a<this.weekCalculationOptions.minDaysInFirstWeek&&(l=l.add(7,"day"));break}}const c=t.startOf("day").diff(l.startOf("day"),"day"),u=Math.floor(c/7)+1;if(u<=0)return this.getWeekNumber(t.subtract(1,"day"));const p=e+1,v=t.clone().year(p).month(0).date(1),x=v.day(),T=i(x);let M=v.clone().subtract(T,"day");switch(this.weekCalculationOptions.firstWeekType){case 1:{M.clone().add(3,"day").year()<p&&(M=M.add(7,"day"));break}case 2:{7-T<this.weekCalculationOptions.minDaysInFirstWeek&&(M=M.add(7,"day"));break}}return t.isSameOrAfter(M)?1:u}async dropdownShown(){await this.getWeekNoteEnable(),this.weekNotes=await pt.get("attribute-values/weekNote"),this.init(Pt.tabManager.getActiveContextNote()?.getOwnedLabelValue("dateNote")??null)}init(t){this.activeDate=t?br(`${t}T12:00:00`):null,this.todaysDate=br(),this.date=br(this.activeDate||this.todaysDate).startOf("month"),this.createMonth()}createDay(t,e){const i=$("<a>").addClass("calendar-date").attr("data-calendar-date",this.date.local().format("YYYY-MM-DD")),n=$("<span>").html(String(e)),s=t[this.date.local().format("YYYY-MM-DD")];return s&&(i.addClass("calendar-date-exists"),i.attr("data-href",`#root/${s}`)),this.date.isSame(this.activeDate,"day")&&i.addClass("calendar-date-active"),this.date.isSame(this.todaysDate,"day")&&i.addClass("calendar-date-today"),i.append(n),i}createWeekNumber(t){const e=this.date.local().format("YYYY-")+"W"+String(t).padStart(2,"0");let i;return this.weekNoteEnable?(i=$("<a>").addClass("calendar-date"),this.weekNotes.includes(e)&&(i.addClass("calendar-date-exists"),i.attr("data-href",`#root/${e}`))):i=$("<span>").addClass("calendar-week-number-disabled"),i.addClass("calendar-week-number").attr("data-calendar-week-number",e),i.append($("<span>").html(String(t))),i}getPrevMonthDays(t){const e=this.date.subtract(1,"month").endOf("month"),i=(t-this.firstDayOfWeek+7)%7,n=[],s=this.date.startOf("month"),a=this.getWeekNumber(s);for(let l=i-1;l>=0;l--)n.push(e.subtract(l,"day"));return{weekNumber:a,dates:n}}getNextMonthDays(t){const e=this.date.add(1,"month").startOf("month"),i=[],s=((this.firstDayOfWeek+6)%7-t+7)%7;for(let a=0;a<s;a++)i.push(e.add(a,"day"));return i}async createMonth(){const t=this.date.format("YYYY-MM"),e=await pt.get(`special-notes/notes-for-month/${t}`);this.$month.empty();const n=this.date.startOf("month").day();if(n!==this.firstDayOfWeek){const{weekNumber:u,dates:p}=this.getPrevMonthDays(n),v=this.date.subtract(1,"month").format("YYYY-MM"),x=await pt.get(`special-notes/notes-for-month/${v}`),T=this.createWeekNumber(u);this.$month.append(T),p.forEach(M=>{const P=this.date;this.date=M;const F=this.createDay(x,M.date());F.addClass("calendar-date-prev-month"),this.$month.append(F),this.date=P})}const s=this.date.month();for(;this.date.month()===s;){const u=this.getWeekNumber(this.date);if(this.date.day()===this.firstDayOfWeek){const v=this.createWeekNumber(u);this.$month.append(v)}const p=this.createDay(e,this.date.date());this.$month.append(p),this.date=this.date.add(1,"day")}this.date=this.date.startOf("month").subtract(1,"month");const l=this.date.endOf("month").day(),c=(this.firstDayOfWeek+6)%7;if(l!==c){const u=this.getNextMonthDays(l),p=this.date.add(1,"month").format("YYYY-MM"),v=await pt.get(`special-notes/notes-for-month/${p}`);u.forEach(x=>{const T=this.date;this.date=x;const M=this.createDay(v,x.date());M.addClass("calendar-date-next-month"),this.$month.append(M),this.date=T})}this.$monthSelect.text(yy[this.date.month()]),this.$yearSelect.val(this.date.year())}async entitiesReloadedEvent({loadResults:t}){!t.getOptionNames().includes("firstDayOfWeek")&&!t.getOptionNames().includes("firstWeekOfYear")&&!t.getOptionNames().includes("minDaysInFirstWeek")||(this.manageFirstDayOfWeek(),this.initWeekCalculation(),this.createMonth())}}class cI extends Wo{noteToOpen;constructor(t){super(),this.noteToOpen=t,this.title(()=>ct.escapeHtml(this.noteToOpen.title)).icon(()=>this.noteToOpen.getIcon()).onClick((e,i)=>this.launch(i)).onAuxClick((e,i)=>this.launch(i)).onContextMenu(e=>{e&&$r.openContextMenu(this.noteToOpen.noteId,e)})}async launch(t){if(t.which===3)return;const e=this.getHoistedNoteId(),i=ct.isCtrlKey(t);if(t.which===1&&i||t.which===2){const n=!!t.shiftKey;await Pt.tabManager.openInNewTab(this.noteToOpen.noteId,e,n)}else await Pt.tabManager.openInSameTab(this.noteToOpen.noteId)}getHoistedNoteId(){return this.noteToOpen.getRelationValue("hoistedNote")||Pt.tabManager.getActiveContext()?.hoistedNoteId}initialRenderCompleteEvent(){}}const dI=`
|
||
<div class="bookmark-folder-widget">
|
||
<style>
|
||
.bookmark-folder-widget {
|
||
min-width: 400px;
|
||
max-height: 500px;
|
||
padding: 7px 15px 0 15px;
|
||
font-size: 1.2rem;
|
||
overflow: auto;
|
||
}
|
||
|
||
.bookmark-folder-widget ul {
|
||
padding: 0;
|
||
list-style-type: none;
|
||
}
|
||
|
||
.bookmark-folder-widget .note-link {
|
||
display: block;
|
||
padding: 5px 10px 5px 5px;
|
||
}
|
||
|
||
.bookmark-folder-widget .note-link:hover {
|
||
background-color: var(--accented-background-color);
|
||
text-decoration: none;
|
||
}
|
||
|
||
.dropdown-menu .bookmark-folder-widget a:hover {
|
||
text-decoration: none;
|
||
background: transparent !important;
|
||
}
|
||
|
||
.bookmark-folder-widget li .note-link {
|
||
padding-left: 35px;
|
||
}
|
||
</style>
|
||
|
||
<div class="parent-note"></div>
|
||
|
||
<ul class="children-notes"></ul>
|
||
</div>`;class hI extends vy{note;$parentNote;$childrenNotes;constructor(t){super(ct.escapeHtml(t.title),t.getIcon(),dI),this.note=t}doRender(){super.doRender(),this.$parentNote=this.$dropdownContent.find(".parent-note"),this.$childrenNotes=this.$dropdownContent.find(".children-notes")}async dropdownShown(){this.$parentNote.empty(),this.$childrenNotes.empty();const t={showTooltip:!1,showNoteIcon:!0};this.$parentNote.append((await Pe.createLink(this.note.noteId,t)).addClass("note-link"));for(const e of await this.note.getChildNotes())this.$childrenNotes.append($("<li>").append((await Pe.createLink(e.noteId,t)).addClass("note-link")))}refreshIcon(){}}class uI extends Xd{settings;noteIds;constructor(t){super(t?"row":"column"),this.contentSized(),this.settings={},this.noteIds=[]}async refresh(){this.$widget.empty(),this.children=[],this.noteIds=[];const t=await Mt.getNote("_lbBookmarks");if(t){for(const e of await t.getChildNotes()){this.noteIds.push(e.noteId);let i=e.isLabelTruthy("bookmarkFolder")?new hI(e):new cI(e).class("launcher-button");this.settings.titlePlacement&&("settings"in i||(i.settings={}),i.settings.titlePlacement=this.settings.titlePlacement),this.child(i),this.$widget.append(i.render()),i.refreshIcon()}ct.reloadTray()}}initialRenderCompleteEvent(){this.refresh()}entitiesReloadedEvent({loadResults:t}){t.getBranchRows().find(e=>e.parentNoteId==="_lbBookmarks")&&this.refresh(),t.getAttributeRows().find(e=>e.type==="label"&&e.name&&["iconClass","workspaceIconClass","bookmarkFolder"].includes(e.name)&&e.noteId&&this.noteIds.includes(e.noteId))&&this.refresh()}}class pI extends Yl{constructor(){super(),this.class("launcher-button"),this.settings.icon=()=>Mi.isProtectedSessionAvailable()?"bx-check-shield":"bx-shield-quarter",this.settings.title=()=>Mi.isProtectedSessionAvailable()?m("protected_session_status.active"):m("protected_session_status.inactive"),this.settings.command=()=>Mi.isProtectedSessionAvailable()?"leaveProtectedSession":"enterProtectedSession"}protectedSessionStartedEvent(){this.refreshIcon()}}const fI=`
|
||
<div class="sync-status-widget launcher-button">
|
||
<style>
|
||
.sync-status-widget {
|
||
}
|
||
|
||
.sync-status {
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.sync-status .sync-status-icon {
|
||
display: inline-block;
|
||
position: relative;
|
||
top: -5px;
|
||
font-size: 110%;
|
||
}
|
||
|
||
.sync-status .sync-status-sub-icon {
|
||
font-size: 40%;
|
||
position: absolute;
|
||
left: 0;
|
||
top: 16px;
|
||
}
|
||
|
||
.sync-status .sync-status-icon span {
|
||
border: none !important;
|
||
}
|
||
|
||
.sync-status-icon:not(.sync-status-in-progress):hover {
|
||
background-color: var(--hover-item-background-color);
|
||
cursor: pointer;
|
||
}
|
||
</style>
|
||
|
||
<div class="sync-status">
|
||
<span class="sync-status-icon sync-status-unknown bx bx-time"
|
||
data-bs-toggle="tooltip"
|
||
title="${Qn(m("sync_status.unknown"))}">
|
||
</span>
|
||
<span class="sync-status-icon sync-status-connected-with-changes bx bx-wifi"
|
||
data-bs-toggle="tooltip"
|
||
title="${Qn(m("sync_status.connected_with_changes"))}">
|
||
<span class="bx bxs-star sync-status-sub-icon"></span>
|
||
</span>
|
||
<span class="sync-status-icon sync-status-connected-no-changes bx bx-wifi"
|
||
data-bs-toggle="tooltip"
|
||
title="${Qn(m("sync_status.connected_no_changes"))}">
|
||
</span>
|
||
<span class="sync-status-icon sync-status-disconnected-with-changes bx bx-wifi-off"
|
||
data-bs-toggle="tooltip"
|
||
title="${Qn(m("sync_status.disconnected_with_changes"))}">
|
||
<span class="bx bxs-star sync-status-sub-icon"></span>
|
||
</span>
|
||
<span class="sync-status-icon sync-status-disconnected-no-changes bx bx-wifi-off"
|
||
data-bs-toggle="tooltip"
|
||
title="${Qn(m("sync_status.disconnected_no_changes"))}">
|
||
</span>
|
||
<span class="sync-status-icon sync-status-in-progress bx bx-analyse bx-spin"
|
||
data-bs-toggle="tooltip"
|
||
title="${Qn(m("sync_status.in_progress"))}">
|
||
</span>
|
||
</div>
|
||
</div>
|
||
`;class mI extends ge{syncState;allChangesPushed;lastSyncedPush;settings;constructor(){super(),this.syncState="unknown",this.allChangesPushed=!1,this.settings={titlePlacement:"right"}}doRender(){this.$widget=$(fI),this.$widget.hide(),this.$widget.find(".sync-status-icon:not(.sync-status-in-progress)").on("click",()=>jE.syncNow()),yi.subscribeToMessages(t=>this.processMessage(t))}showIcon(t){if(!Qt.get("syncServerHost")){this.toggleInt(!1);return}As.getOrCreateInstance(this.$widget.find(`.sync-status-${t}`)[0],{html:!0,placement:this.settings.titlePlacement,fallbackPlacements:[this.settings.titlePlacement]}),this.$widget.show(),this.$widget.find(".sync-status-icon").hide(),this.$widget.find(`.sync-status-${t}`).show()}processMessage(t){t.type==="sync-pull-in-progress"?(this.syncState="in-progress",this.lastSyncedPush=t.lastSyncedPush):t.type==="sync-push-in-progress"?(this.syncState="in-progress",this.lastSyncedPush=t.lastSyncedPush):t.type==="sync-finished"?(this.syncState="connected",this.lastSyncedPush=t.lastSyncedPush):t.type==="sync-failed"?(this.syncState="disconnected",this.lastSyncedPush=t.lastSyncedPush):t.type==="frontend-update"&&(this.lastSyncedPush=t.data.lastSyncedPush),this.allChangesPushed=this.lastSyncedPush===yi.getMaxKnownEntityChangeSyncId(),["unknown","in-progress"].includes(this.syncState)?this.showIcon(this.syncState):this.showIcon(`${this.syncState}-${this.allChangesPushed?"no-changes":"with-changes"}`)}}class by extends Wo{launcherNote;constructor(t){super(),this.class("launcher-button"),this.launcherNote=t;for(const e of t.getOwnedLabels("keyboardShortcut"))this.bindNoteShortcutHandler(e)}bindNoteShortcutHandler(t){const e=t.attributeId;"isDeleted"in t&&t.isDeleted?Bi.removeGlobalShortcut(e):t.value&&Bi.bindGlobalShortcut(t.value,()=>this.launch(),e)}entitiesReloadedEvent({loadResults:t}){for(const e of t.getAttributeRows())e.noteId===this.launcherNote.noteId&&e.type==="label"&&e.name==="keyboardShortcut"?this.bindNoteShortcutHandler(e):e.type==="label"&&e.name==="iconClass"&&Be.isAffecting(e,this.launcherNote)&&this.refreshIcon()}}class wy extends by{constructor(t){super(t),this.title(()=>this.launcherNote.title).icon(()=>this.launcherNote.getIcon()).onClick((e,i)=>this.launch(i)).onAuxClick((e,i)=>this.launch(i)).onContextMenu(async e=>{let i=await Promise.resolve(this.getTargetNoteId());if(!i||!e)return;const n=this.getHoistedNoteId();$r.openContextMenu(i,e,{},n)})}async launch(t){const e=await this.getTargetNoteId();if(!e||t?.which===3)return;const i=await this.getHoistedNoteId();if(i)if(!t)await Pt.tabManager.openInSameTab(e,i);else{const n=ct.isCtrlKey(t),s=!!t.shiftKey;t.which===1&&n||t.which===2?await Pt.tabManager.openInNewTab(e,i,s):await Pt.tabManager.openInSameTab(e,i)}}getTargetNoteId(){const t=this.launcherNote.getRelationValue("target");if(!t){Me.info(m("note_launcher.this_launcher_doesnt_define_target_note"));return}return t}getHoistedNoteId(){return this.launcherNote.getRelationValue("hoistedNote")||Pt.tabManager.getActiveContext()?.hoistedNoteId}getTitle(){const t=this.launcherNote.getLabels("keyboardShortcut").map(i=>i.value).filter(i=>!!i).join(", ");let e=super.getTitle();return t&&(e+=` (${t})`),e}}class gI extends by{constructor(t){super(t),this.title(()=>this.launcherNote.title).icon(()=>this.launcherNote.getIcon()).onClick(()=>this.launch())}async launch(){if(this.launcherNote.isLabelTruthy("scriptInLauncherContent"))await this.launcherNote.executeScript();else{const t=await this.launcherNote.getRelationTarget("script");t&&await t.executeScript()}}}class vI extends wy{async getTargetNoteId(){return(await cl.getTodayNote())?.noteId}getHoistedNoteId(){return Pt.tabManager.getActiveContext()?.hoistedNoteId}}class yI extends Yl{constructor(){super(),this.settings.buttonNoteIdProvider=null}buttonNoteIdProvider(t){return this.settings.buttonNoteIdProvider=t,this}doRender(){super.doRender(),this.updateIcon()}updateIcon(){if(!this.settings.buttonNoteIdProvider){console.error(`buttonNoteId for '${this.componentId}' is not defined.`);return}const t=this.settings.buttonNoteIdProvider();if(!t){console.error(`buttonNoteId for '${this.componentId}' is not defined.`);return}Mt.getNote(t).then(e=>{const i=e?.getIcon();i&&(this.settings.icon=i),this.refreshIcon()})}entitiesReloadedEvent({loadResults:t}){const e=Mt.getNoteFromCache(this.buttonNoteIdProvider());e&&t.getAttributeRows(this.componentId).find(i=>i.type==="label"&&i.name==="iconClass"&&Be.isAffecting(i,e))&&this.updateIcon()}}class Af extends yI{webContents;constructor(t,e){super(),this.title(()=>t.title).icon(()=>t.getIcon()).command(()=>e).titlePlacement("right").buttonNoteIdProvider(()=>t.noteId).onContextMenu(i=>{i&&this.showContextMenu(i)}).class("launcher-button")}doRender(){super.doRender(),ct.isElectron()&&(this.webContents=ct.dynamicRequire("@electron/remote").getCurrentWebContents(),this.webContents?.clearHistory(),this.refresh())}async showContextMenu(t){if(t.preventDefault(),!this.webContents||this.webContents.history.length<2)return;let e=[];const i=this.webContents.getActiveIndex(),n=this.webContents.history;for(const s in n){const l=n[s].split("#");if(l.length<2)continue;const u=l[1].split("-")[0],p=await fe.getNotePathTitle(u);e.push({title:p,idx:s,uiIcon:parseInt(s)===i?"bx bx-radio-circle-marked":parseInt(s)<i?"bx bx-left-arrow-alt":"bx bx-right-arrow-alt"})}e.reverse(),e.length>20&&(e=e.slice(0,50)),Ho.show({x:t.pageX,y:t.pageY,items:e,selectMenuItemHandler:s=>{s&&s.idx&&this.webContents&&this.webContents.goToIndex(s.idx)}})}activeNoteChangedEvent(){this.refresh()}}class bI extends VE{isHorizontalLayout;constructor(t){super(),this.isHorizontalLayout=t}isEnabled(){return!this.isHorizontalLayout||ct.isMobile()?!1:super.isEnabled()}}class wI extends Yl{constructor(t){super(),this.command("createAiChat").title(()=>t.title).icon(()=>t.getIcon()).class("launcher-button")}isEnabled(){return Qt.get("aiEnabled")==="true"}entitiesReloadedEvent({loadResults:t}){t.isOptionReloaded("aiEnabled")&&this.refresh()}}class _I extends ge{innerWidget;isHorizontalLayout;constructor(t){super(),this.isHorizontalLayout=t}isEnabled(){return this.innerWidget.isEnabled()}doRender(){this.$widget=this.innerWidget.render()}async initLauncher(t){if(t.type!=="launcher")throw new Error(`Note '${t.noteId}' '${t.title}' is not a launcher even though it's in the launcher subtree`);if(!ct.isDesktop()&&t.isLabelTruthy("desktopOnly"))return!1;const e=t.getLabelValue("launcherType");if(glob.TRILIUM_SAFE_MODE&&e==="customWidget")return!1;let i;if(e==="command")i=this.initCommandLauncherWidget(t).class("launcher-button");else if(e==="note")i=new wy(t).class("launcher-button");else if(e==="script")i=new gI(t).class("launcher-button");else if(e==="customWidget")i=await this.initCustomWidget(t);else if(e==="builtinWidget")i=this.initBuiltinWidget(t);else throw new Error(`Unrecognized launcher type '${e}' for launcher '${t.noteId}' title '${t.title}'`);if(!i)throw new Error(`Unknown initialization error for note '${t.noteId}', title '${t.title}'`);return this.child(i),this.innerWidget=i,this.isHorizontalLayout&&this.innerWidget.settings&&(this.innerWidget.settings.titlePlacement="bottom"),!0}initCommandLauncherWidget(t){return new Yl().title(()=>t.title).icon(()=>t.getIcon()).command(()=>t.getLabelValue("command"))}async initCustomWidget(t){const e=await t.getRelationTarget("widget");if(e)return await e.executeScript();throw new Error(`Custom widget of launcher '${t.noteId}' '${t.title}' is not defined.`)}initBuiltinWidget(t){const e=t.getLabelValue("builtinWidget");switch(e){case"calendar":return new lI(t.title,t.getIcon());case"spacer":const i=parseInt(t.getLabelValue("baseSize")||"40"),n=parseInt(t.getLabelValue("growthFactor")||"100");return new WE(i,n);case"bookmarks":return new uI(this.isHorizontalLayout);case"protectedSession":return new pI;case"syncStatus":return new mI;case"backInHistoryButton":return new Af(t,"backInNoteHistory");case"forwardInHistoryButton":return new Af(t,"forwardInNoteHistory");case"todayInJournal":return new vI(t);case"quickSearch":return new bI(this.isHorizontalLayout);case"aiChatLauncher":return new wI(t);default:throw new Error(`Unrecognized builtin widget ${e} for launcher ${t.noteId} "${t.title}"`)}}}class JA extends Xd{isHorizontalLayout;constructor(t){super(t?"row":"column"),this.id("launcher-container"),this.filling(),this.isHorizontalLayout=t,this.load()}async load(){await Mt.initializedPromise;const t=ct.isMobile()?"_lbMobileVisibleLaunchers":"_lbVisibleLaunchers",e=await Mt.getNote(t,!0);if(!e){console.log("Visible launchers root note doesn't exist.");return}const i=[];for(const s of await e.getChildNotes())try{const a=new _I(this.isHorizontalLayout);await a.initLauncher(s)&&i.push(a)}catch(a){console.error(a)}this.children=[],this.child(...i),this.$widget.empty(),this.renderChildren(),await this.handleEventInChildren("initialRenderComplete",{});const n=Pt.tabManager.getActiveContext();n&&(await this.handleEvent("setNoteContext",{noteContext:n}),n.notePath&&await this.handleEvent("noteSwitched",{noteContext:n,notePath:n.notePath}))}entitiesReloadedEvent({loadResults:t}){t.getBranchRows().find(e=>e.parentNoteId&&Mt.getNoteFromCache(e.parentNoteId)?.isLaunchBarConfig())&&this.load()}}const xI=`
|
||
<div class="close-floating-buttons">
|
||
<style>
|
||
.close-floating-buttons {
|
||
display: none;
|
||
margin-left: 5px !important;
|
||
}
|
||
|
||
/* conditionally display close button if there's some other button visible */
|
||
.floating-buttons *:not(.hidden-int):not(.hidden-no-content) ~ .close-floating-buttons {
|
||
display: block;
|
||
}
|
||
|
||
.close-floating-buttons-button {
|
||
border: 1px solid transparent;
|
||
color: var(--button-text-color);
|
||
padding: 6px;
|
||
border-radius: 100px;
|
||
}
|
||
|
||
.close-floating-buttons-button:hover {
|
||
border: 1px solid var(--button-border-color);
|
||
}
|
||
</style>
|
||
|
||
<button type="button"
|
||
class="close-floating-buttons-button btn bx bx-chevrons-right"
|
||
title="${m("hide_floating_buttons_button.button_title")}"></button>
|
||
</div>
|
||
`;class QA extends hi{doRender(){super.doRender(),this.$widget=$(xI),this.$widget.on("click",()=>this.triggerCommand("hideFloatingButtons")),this.contentSized()}}async function _y(o,t,e,i){if(!["notes","attachments"].includes(o))throw new Error(`Unrecognized import entity type '${o}'.`);if(e.length===0)return;const n=ct.randomString(10);let s=0;for(const a of e){s++;const l=new FormData;l.append("upload",a),l.append("taskId",n),l.append("last",s===e.length?"true":"false");for(const c in i)l.append(c,i[c]);await $.ajax({url:`${window.glob.baseApiUrl}notes/${t}/${o}-import`,headers:await pt.getHeaders(),data:l,dataType:"json",type:"POST",timeout:60*60*1e3,error:function(c){ft.showError(m("import.failed",{message:c.responseText}))},contentType:!1,processData:!1})}}function Al(o,t){return{id:o,title:m("import.import-status"),message:t,icon:"plus"}}yi.subscribeToMessages(async o=>{if(o.taskType==="importNotes"){if(o.type==="taskError")ft.closePersistent(o.taskId),ft.showError(o.message);else if(o.type==="taskProgressCount")ft.showPersistent(Al(o.taskId,m("import.in-progress",{progress:o.progressCount})));else if(o.type==="taskSucceeded"){const t=Al(o.taskId,m("import.successful"));t.closeAfter=5e3,ft.showPersistent(t),o.result.importedNoteId&&await Pt.tabManager.getActiveContext()?.setNote(o.result.importedNoteId)}}});yi.subscribeToMessages(async o=>{if(o.taskType==="importAttachments"){if(o.type==="taskError")ft.closePersistent(o.taskId),ft.showError(o.message);else if(o.type==="taskProgressCount")ft.showPersistent(Al(o.taskId,m("import.in-progress",{progress:o.progressCount})));else if(o.type==="taskSucceeded"){const t=Al(o.taskId,m("import.successful"));t.closeAfter=5e3,ft.showPersistent(t),o.result.parentNoteId&&await Pt.tabManager.getActiveContext()?.setNote(o.result.importedNoteId,{viewScope:{viewMode:"attachments"}})}}});const xy={uploadFiles:_y},kI=Object.freeze(Object.defineProperty({__proto__:null,default:xy,uploadFiles:_y},Symbol.toStringTag,{value:"Module"}));class XA extends Wo{constructor(){super(),this.title(m("backend_log.refresh")).icon("bx-refresh").onClick(()=>this.triggerEvent("refreshData",{ntxId:this.noteContext?.ntxId}))}isEnabled(){return super.isEnabled()&&this.note?.noteId==="_backendLog"&&this.noteContext?.viewScope?.viewMode==="default"}}const CI=`
|
||
<div class="about-dialog modal fade mx-auto" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog modal-lg" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">${m("about.title")}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("about.close")}"></button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<table class="table table-borderless">
|
||
<tr>
|
||
<th>${m("about.homepage")}</th>
|
||
<td><a class="tn-link" href="https://github.com/TriliumNext/Notes" class="external">https://github.com/TriliumNext/Notes</a></td>
|
||
</tr>
|
||
<tr>
|
||
<th>${m("about.app_version")}</th>
|
||
<td class="app-version"></td>
|
||
</tr>
|
||
<tr>
|
||
<th>${m("about.db_version")}</th>
|
||
<td class="db-version"></td>
|
||
</tr>
|
||
<tr>
|
||
<th>${m("about.sync_version")}</th>
|
||
<td class="sync-version"></td>
|
||
</tr>
|
||
<tr>
|
||
<th>${m("about.build_date")}</th>
|
||
<td class="build-date"></td>
|
||
</tr>
|
||
<tr>
|
||
<th>${m("about.build_revision")}</th>
|
||
<td><a class="tn-link build-revision external" href="" target="_blank"></a></td>
|
||
</tr>
|
||
<tr>
|
||
<th>${m("about.data_directory")}</th>
|
||
<td class="data-directory"></td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<style>
|
||
.about-dialog a {
|
||
word-break: break-all;
|
||
}
|
||
</style>
|
||
`;class $I extends ge{$appVersion;$dbVersion;$syncVersion;$buildDate;$buildRevision;$dataDirectory;doRender(){this.$widget=$(CI),this.$appVersion=this.$widget.find(".app-version"),this.$dbVersion=this.$widget.find(".db-version"),this.$syncVersion=this.$widget.find(".sync-version"),this.$buildDate=this.$widget.find(".build-date"),this.$buildRevision=this.$widget.find(".build-revision"),this.$dataDirectory=this.$widget.find(".data-directory")}async refresh(){const t=await pt.get("app-info");this.$appVersion.text(t.appVersion),this.$dbVersion.text(t.dbVersion.toString()),this.$syncVersion.text(t.syncVersion.toString()),this.$buildDate.text(Dr(t.buildDate)),this.$buildRevision.text(t.buildRevision),this.$buildRevision.attr("href",`https://github.com/TriliumNext/Notes/commit/${t.buildRevision}`),ct.isElectron()?(this.$dataDirectory.html($("<a></a>",{href:"#",class:"tn-link",text:t.dataDirectory}).prop("outerHTML")),this.$dataDirectory.find("a").on("click",e=>{e.preventDefault(),en.openDirectory(t.dataDirectory)})):this.$dataDirectory.text(t.dataDirectory)}async openAboutDialogEvent(){await this.refresh(),ct.openDialog(this.$widget)}}const SI=`
|
||
<div class="help-dialog modal use-tn-links" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog" role="document" style="min-width: 90%;">
|
||
<div class="modal-content" style="height: auto;">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">${m("help.fullDocumentation")}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("help.close")}"></button>
|
||
</div>
|
||
<div class="modal-body" style="overflow: auto;">
|
||
<div class="help-cards row row-cols-md-3 g-3">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<h5 class="card-title">${m("help.noteNavigation")}</h5>
|
||
|
||
<p class="card-text">
|
||
<ul>
|
||
<li>${m("help.goUpDown")}</li>
|
||
<li>${m("help.collapseExpand")}</li>
|
||
<li><kbd data-command="backInNoteHistory">${m("help.notSet")}</kbd>, <kbd data-command="forwardInNoteHistory">${m("help.notSet")}</kbd> - ${m("help.goBackForwards")}</li>
|
||
<li><kbd data-command="jumpToNote">${m("help.notSet")}</kbd> - ${m("help.showJumpToNoteDialog")}</li>
|
||
<li><kbd data-command="scrollToActiveNote">${m("help.notSet")}</kbd> - ${m("help.scrollToActiveNote")}</li>
|
||
<li>${m("help.jumpToParentNote")}</li>
|
||
<li><kbd data-command="collapseTree">${m("help.notSet")}</kbd> - ${m("help.collapseWholeTree")}</li>
|
||
<li><kbd data-command="collapseSubtree">${m("help.notSet")}</kbd> - ${m("help.collapseSubTree")}</li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<h5 class="card-title">${m("help.tabShortcuts")}</h5>
|
||
|
||
<p class="card-text">
|
||
<ul>
|
||
<li>${m("help.newTabNoteLink")}</li>
|
||
<li>${m("help.newTabWithActivationNoteLink")}</li>
|
||
</ul>
|
||
<h6>${m("help.onlyInDesktop")}:</h6>
|
||
<ul>
|
||
<li><kbd data-command="openNewTab">${m("help.notSet")}</kbd> ${m("help.openEmptyTab")}</li>
|
||
<li><kbd data-command="closeActiveTab">${m("help.notSet")}</kbd> ${m("help.closeActiveTab")}</li>
|
||
<li><kbd data-command="activateNextTab">${m("help.notSet")}</kbd> ${m("help.activateNextTab")}</li>
|
||
<li><kbd data-command="activatePreviousTab">${m("help.notSet")}</kbd> ${m("help.activatePreviousTab")}</li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<h5 class="card-title">${m("help.creatingNotes")}</h5>
|
||
|
||
<p class="card-text">
|
||
<ul>
|
||
<li><kbd data-command="createNoteAfter">${m("help.notSet")}</kbd> - ${m("help.createNoteAfter")}</li>
|
||
<li><kbd data-command="createNoteInto">${m("help.notSet")}</kbd> - ${m("help.createNoteInto")}</li>
|
||
<li><kbd data-command="editBranchPrefix">${m("help.notSet")}</kbd> - ${m("help.editBranchPrefix")}</li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<h5 class="card-title">${m("help.movingCloningNotes")}</h5>
|
||
|
||
<p class="card-text">
|
||
<ul>
|
||
<li><kbd data-command="moveNoteUp">${m("help.notSet")}</kbd>, <kbd data-command="moveNoteDown">${m("help.notSet")}</kbd> - ${m("help.moveNoteUpDown")}</li>
|
||
<li><kbd data-command="moveNoteUpInHierarchy">${m("help.notSet")}</kbd>, <kbd data-command="moveNoteDownInHierarchy">${m("help.notSet")}</kbd> - ${m("help.moveNoteUpHierarchy")}</li>
|
||
<li><kbd data-command="addNoteAboveToSelection">${m("help.notSet")}</kbd>, <kbd data-command="addNoteBelowToSelection">${m("help.notSet")}</kbd> - ${m("help.multiSelectNote")}</li>
|
||
<li><kbd data-command="selectAllNotesInParent">${m("help.notSet")}</kbd> - ${m("help.selectAllNotes")}</li>
|
||
<li>${m("help.selectNote")}</li>
|
||
<li><kbd data-command="copyNotesToClipboard">${m("help.notSet")}</kbd> - ${m("help.copyNotes")}</li>
|
||
<li><kbd data-command="cutNotesToClipboard">${m("help.notSet")}</kbd> - ${m("help.cutNotes")}</li>
|
||
<li><kbd data-command="pasteNotesFromClipboard">${m("help.notSet")}</kbd> - ${m("help.pasteNotes")}</li>
|
||
<li><kbd data-command="deleteNotes">${m("help.notSet")}</kbd> - ${m("help.deleteNotes")}</li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<h5 class="card-title">${m("help.editingNotes")}</h5>
|
||
|
||
<p class="card-text">
|
||
<ul>
|
||
<li><kbd data-command="editNoteTitle">${m("help.notSet")}</kbd> ${m("help.editNoteTitle")}</li>
|
||
<li>${m("help.createEditLink")}</li>
|
||
<li><kbd data-command="addLinkToText">${m("help.notSet")}</kbd> - ${m("help.createInternalLink")}</li>
|
||
<li><kbd data-command="followLinkUnderCursor">${m("help.notSet")}</kbd> - ${m("help.followLink")}</li>
|
||
<li><kbd data-command="insertDateTimeToText">${m("help.notSet")}</kbd> - ${m("help.insertDateTime")}</li>
|
||
<li><kbd data-command="scrollToActiveNote">${m("help.notSet")}</kbd> - ${m("help.jumpToTreePane")}</li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<h5 class="card-title"><a class="external" href="https://triliumnext.github.io/Docs/Wiki/text-notes.html#markdown--autoformat">${m("help.markdownAutoformat")}</a></h5>
|
||
|
||
<p class="card-text">
|
||
<ul>
|
||
<li>${m("help.headings")}</li>
|
||
<li>${m("help.bulletList")}</li>
|
||
<li>${m("help.numberedList")}</li>
|
||
<li>${m("help.blockQuote")}</li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<h5 class="card-title">${m("help.troubleshooting")}</h5>
|
||
|
||
<p class="card-text">
|
||
<ul>
|
||
<li><kbd data-command="reloadFrontendApp">${m("help.notSet")}</kbd> - ${m("help.reloadFrontend")}</li>
|
||
<li><kbd data-command="openDevTools">${m("help.notSet")}</kbd> - ${m("help.showDevTools")}</li>
|
||
<li><kbd data-command="showSQLConsole">${m("help.notSet")}</kbd> - ${m("help.showSQLConsole")}</li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<h5 class="card-title">${m("help.other")}</h5>
|
||
|
||
<p class="card-text">
|
||
<ul>
|
||
<li><kbd data-command="quickSearch">${m("help.notSet")}</kbd> - ${m("help.quickSearch")}</li>
|
||
<li><kbd data-command="findInText">${m("help.notSet")}</kbd> - ${m("help.inPageSearch")}</li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`;class TI extends ge{doRender(){this.$widget=$(SI)}showCheatsheetEvent(){ct.openDialog(this.$widget)}}const EI=`<div class="jump-to-note-dialog modal mx-auto" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog modal-lg" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<div class="input-group">
|
||
<input class="jump-to-note-autocomplete form-control" placeholder="${m("jump_to_note.search_placeholder")}">
|
||
</div>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("jump_to_note.close")}"></button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="algolia-autocomplete-container jump-to-note-results"></div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button class="show-in-full-text-button btn btn-sm">${m("jump_to_note.search_button")}</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`,II=120;class AI extends ge{lastOpenedTs;modal;$autoComplete;$results;$showInFullTextButton;constructor(){super(),this.lastOpenedTs=0}doRender(){this.$widget=$(EI),this.modal=Pi.getOrCreateInstance(this.$widget[0]),this.$autoComplete=this.$widget.find(".jump-to-note-autocomplete"),this.$results=this.$widget.find(".jump-to-note-results"),this.$showInFullTextButton=this.$widget.find(".show-in-full-text-button"),this.$showInFullTextButton.on("click",t=>this.showInFullText(t)),Bi.bindElShortcut(this.$widget,"ctrl+return",t=>this.showInFullText(t))}async jumpToNoteEvent(){const t=ct.openDialog(this.$widget);ct.isMobile()&&t.then(e=>{const i=e.find(">.modal-dialog")[0];function n(){const a=(window.visualViewport?.height??0)-100,l=(window.visualViewport?.height??0)-window.innerHeight;i.style.height=`${a}px`,i.style.bottom=`${(window.visualViewport?.height??0)-a-l-100}px`}this.$autoComplete.on("focus",()=>{n()}),window.visualViewport?.addEventListener("resize",()=>{n()}),n()}),this.refresh(),this.lastOpenedTs=Date.now()}async refresh(){Xe.initNoteAutocomplete(this.$autoComplete,{allowCreatingNotes:!0,hideGoToSelectedNoteButton:!0,allowJumpToSearchNotes:!0,container:this.$results[0]}).off("autocomplete:noteselected").on("autocomplete:noteselected",function(t,e,i){if(!e.notePath)return!1;Pt.tabManager.getActiveContext()?.setNote(e.notePath)}),Date.now()-this.lastOpenedTs>II*1e3?Xe.showRecentNotes(this.$autoComplete):this.$autoComplete.autocomplete("val",this.$autoComplete.next().text()).trigger("focus").trigger("select")}showInFullText(t){t.preventDefault(),t.stopPropagation();const e=String(this.$autoComplete.val());this.triggerCommand("searchNotes",{searchString:e}),this.modal.hide()}}const LI=`
|
||
<div class="recent-changes-dialog modal fade mx-auto" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog modal-lg modal-dialog-scrollable" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title flex-grow-1">${m("recent_changes.title")}</h5>
|
||
<button class="erase-deleted-notes-now-button btn btn-sm" style="padding: 0 10px">${m("recent_changes.erase_notes_button")}</button>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("recent_changes.close")}"></button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="recent-changes-content"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`;class NI extends ge{ancestorNoteId;modal;$content;$eraseDeletedNotesNow;doRender(){this.$widget=$(LI),this.modal=Pi.getOrCreateInstance(this.$widget[0]),this.$content=this.$widget.find(".recent-changes-content"),this.$eraseDeletedNotesNow=this.$widget.find(".erase-deleted-notes-now-button"),this.$eraseDeletedNotesNow.on("click",()=>{pt.post("notes/erase-deleted-notes-now").then(()=>{this.refresh(),ft.showMessage(m("recent_changes.deleted_notes_message"))})})}async showRecentChangesEvent({ancestorNoteId:t}){this.ancestorNoteId=t,await this.refresh(),ct.openDialog(this.$widget)}async refresh(){this.ancestorNoteId||(this.ancestorNoteId=li.getHoistedNoteId());const t=await pt.get(`recent-changes/${this.ancestorNoteId}`);await Mt.getNotes(t.map(i=>i.noteId),!0),this.$content.empty(),t.length===0&&this.$content.append(m("recent_changes.no_changes_message"));const e=this.groupByDate(t);for(const[i,n]of e){const s=$("<ul>"),a=Dr(i,"full","none"),l=$("<div>").append($("<b>").text(a)).append(s);for(const c of n){const u=Dr(c.date,"none","short");let p;if(c.current_isDeleted){if(p=$("<span>"),p.append($("<span>").addClass("note-title").text(c.current_title)),c.canBeUndeleted){const v=$('<a href="javascript:">').text(m("recent_changes.undelete_link")).on("click",async()=>{const x=m("recent_changes.confirm_undelete");if(await Me.confirm(x)){await pt.put(`notes/${c.noteId}/undelete`),this.modal.hide(),await yi.waitForMaxKnownEntityChangeId();const T=Pt.tabManager.getActiveContext();T&&T.setNote(c.noteId)}});p.append(" (").append(v).append(")")}}else{const v=await Mt.getNote(c.noteId),x=v?.getBestNotePathString();x?p=await Pe.createLink(x,{title:c.title,showNotePath:!0}):p=$("<span>").text(v?.title??"")}s.append($("<li>").on("click",v=>{if(v.target?.nodeName!=="A"&&!c.current_isDeleted){const x=Pt.tabManager.getActiveContext();x&&x.setNote(c.noteId)}}).toggleClass("deleted-note",!!c.current_isDeleted).append($("<span>").text(u).attr("title",c.date)).append(p.addClass("note-title")))}this.$content.append(l)}}groupByDate(t){const e=new Map;for(const i of t){const n=i.date.substr(0,10);e.has(n)||e.set(n,[]),e.get(n).push(i)}return e}}const MI=`
|
||
<div class="prompt-dialog modal mx-auto" tabindex="-1" role="dialog" style="z-index: 2000;">
|
||
<div class="modal-dialog modal-lg" role="document">
|
||
<div class="modal-content">
|
||
<form class="prompt-dialog-form">
|
||
<div class="modal-header">
|
||
<h5 class="prompt-title modal-title">${m("prompt.title")}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("prompt.close")}"></button>
|
||
</div>
|
||
<div class="modal-body"></div>
|
||
<div class="modal-footer">
|
||
<button class="prompt-dialog-ok-button btn btn-primary btn-sm">${m("prompt.ok")}</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>`;class PI extends ge{resolve;shownCb;modal;$dialogBody;$question;$answer;$form;constructor(){super(),this.resolve=null,this.shownCb=null}doRender(){this.$widget=$(MI),this.modal=Pi.getOrCreateInstance(this.$widget[0]),this.$dialogBody=this.$widget.find(".modal-body"),this.$form=this.$widget.find(".prompt-dialog-form"),this.$question=null,this.$answer=null,this.$widget.on("shown.bs.modal",()=>{this.shownCb&&this.shownCb({$dialog:this.$widget,$question:this.$question,$answer:this.$answer,$form:this.$form}),this.$answer?.trigger("focus").select()}),this.$widget.on("hidden.bs.modal",()=>{this.resolve&&this.resolve(null)}),this.$form.on("submit",t=>{t.preventDefault(),this.resolve&&this.resolve(this.$answer?.val()),this.modal.hide()})}showPromptDialogEvent({title:t,message:e,defaultValue:i,shown:n,callback:s}){this.shownCb=n,this.resolve=s,this.$widget.find(".prompt-title").text(t||m("prompt.defaultTitle")),this.$question=$("<label>").prop("for","prompt-dialog-answer").text(e||""),this.$answer=$("<input>").prop("type","text").prop("id","prompt-dialog-answer").addClass("form-control").val(i||""),this.$dialogBody.empty().append($("<div>").addClass("form-group").append(this.$question).append(this.$answer)),ct.openDialog(this.$widget,!1)}}const OI=`
|
||
<div class="add-link-dialog modal mx-auto" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog modal-lg" style="max-width: 1000px" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title flex-grow-1">${m("add_link.add_link")}</h5>
|
||
<button type="button" class="help-button" title="${m("add_link.help_on_links")}" data-help-page="links.html">?</button>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("add_link.close")}"></button>
|
||
</div>
|
||
<form class="add-link-form">
|
||
<div class="modal-body">
|
||
<div class="form-group">
|
||
<label for="add-link-note-autocomplete">${m("add_link.note")}</label>
|
||
|
||
<div class="input-group">
|
||
<input class="add-link-note-autocomplete form-control" placeholder="${m("add_link.search_note")}">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="add-link-title-settings">
|
||
<div class="add-link-title-radios form-check">
|
||
<label class="form-check-label">
|
||
<input class="form-check-input" type="radio" name="link-type" value="reference-link" checked>
|
||
${m("add_link.link_title_mirrors")}
|
||
</label>
|
||
</div>
|
||
<div class="add-link-title-radios form-check">
|
||
<label class="form-check-label">
|
||
<input class="form-check-input" type="radio" name="link-type" value="hyper-link">
|
||
${m("add_link.link_title_arbitrary")}
|
||
</label>
|
||
</div>
|
||
|
||
<div class="add-link-title-form-group form-group">
|
||
<br/>
|
||
<label>
|
||
${m("add_link.link_title")}
|
||
|
||
<input class="link-title form-control" style="width: 100%;">
|
||
</label>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="submit" class="btn btn-primary">${m("add_link.button_add_link")}</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>`;class DI extends ge{$form;$autoComplete;$linkTitle;$addLinkTitleSettings;$addLinkTitleRadios;$addLinkTitleFormGroup;textTypeWidget=null;doRender(){this.$widget=$(OI),this.$form=this.$widget.find(".add-link-form"),this.$autoComplete=this.$widget.find(".add-link-note-autocomplete"),this.$linkTitle=this.$widget.find(".link-title"),this.$addLinkTitleSettings=this.$widget.find(".add-link-title-settings"),this.$addLinkTitleRadios=this.$widget.find(".add-link-title-radios"),this.$addLinkTitleFormGroup=this.$widget.find(".add-link-title-form-group"),this.$form.on("submit",()=>{if(this.$autoComplete.getSelectedNotePath()){this.$widget.modal("hide");const t=this.getLinkType()==="reference-link"?null:this.$linkTitle.val();this.textTypeWidget?.addLink(this.$autoComplete.getSelectedNotePath(),t)}else this.$autoComplete.getSelectedExternalLink()?(this.$widget.modal("hide"),this.textTypeWidget?.addLink(this.$autoComplete.getSelectedExternalLink(),this.$linkTitle.val(),!0)):logError("No link to add.");return!1})}async showAddLinkDialogEvent({textTypeWidget:t,text:e=""}){this.textTypeWidget=t,this.$addLinkTitleSettings.toggle(!this.textTypeWidget.hasSelection()),this.$addLinkTitleSettings.find("input[type=radio]").on("change",()=>this.updateTitleSettingsVisibility()),this.textTypeWidget.hasSelection()?this.$addLinkTitleSettings.find("input[value='hyper-link']").prop("checked",!0):this.$addLinkTitleSettings.find("input[value='reference-link']").prop("checked",!0),this.updateTitleSettingsVisibility(),ct.openDialog(this.$widget),this.$autoComplete.val(""),this.$linkTitle.val("");const i=async n=>{const s=await fe.getNoteTitle(n);this.$linkTitle.val(s)};Xe.initNoteAutocomplete(this.$autoComplete,{allowExternalLinks:!0,allowCreatingNotes:!0}),this.$autoComplete.on("autocomplete:noteselected",(n,s)=>{if(!s.notePath)return!1;this.updateTitleSettingsVisibility();const a=fe.getNoteIdFromUrl(s.notePath);a&&i(a)}),this.$autoComplete.on("autocomplete:externallinkselected",(n,s)=>{if(!s.externalLink)return!1;this.updateTitleSettingsVisibility(),this.$linkTitle.val(s.externalLink)}),this.$autoComplete.on("autocomplete:cursorchanged",(n,s)=>{if(s.externalLink)this.$linkTitle.val(s.externalLink);else{const a=fe.getNoteIdFromUrl(s.notePath);a&&i(a)}}),e&&e.trim()?Xe.setText(this.$autoComplete,e):Xe.showRecentNotes(this.$autoComplete),this.$autoComplete.trigger("focus").trigger("select")}getLinkType(){return this.$autoComplete.getSelectedExternalLink()?"external-link":this.$addLinkTitleSettings.find("input[type=radio]:checked").val()}updateTitleSettingsVisibility(){const t=this.getLinkType();this.$addLinkTitleFormGroup.toggle(t!=="reference-link"),this.$addLinkTitleRadios.toggle(t!=="external-link")}}const RI=`
|
||
<div class="include-note-dialog modal mx-auto" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog modal-lg" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">${m("include_note.dialog_title")}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("include_note.close")}"></button>
|
||
</div>
|
||
<form class="include-note-form">
|
||
<div class="modal-body">
|
||
<div class="form-group">
|
||
<label for="include-note-autocomplete">${m("include_note.label_note")}</label>
|
||
<div class="input-group">
|
||
<input class="include-note-autocomplete form-control" placeholder="${m("include_note.placeholder_search")}">
|
||
</div>
|
||
</div>
|
||
|
||
${m("include_note.box_size_prompt")}
|
||
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-radio">
|
||
<input class="form-check-input" type="radio" name="include-note-box-size" value="small">
|
||
${m("include_note.box_size_small")}
|
||
</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-radio">
|
||
<input class="form-check-input" type="radio" name="include-note-box-size" value="medium" checked>
|
||
${m("include_note.box_size_medium")}
|
||
</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-radio">
|
||
<input class="form-check-input" type="radio" name="include-note-box-size" value="full">
|
||
${m("include_note.box_size_full")}
|
||
</label>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="submit" class="btn btn-primary">${m("include_note.button_include")}</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>`;class BI extends ge{modal;$form;$autoComplete;textTypeWidget;doRender(){this.$widget=$(RI),this.modal=Pi.getOrCreateInstance(this.$widget[0]),this.$form=this.$widget.find(".include-note-form"),this.$autoComplete=this.$widget.find(".include-note-autocomplete"),this.$form.on("submit",()=>{const t=this.$autoComplete.getSelectedNotePath();return t?(this.modal.hide(),this.includeNote(t)):logError("No noteId to include."),!1})}async showIncludeNoteDialogEvent({textTypeWidget:t}){this.textTypeWidget=t,await this.refresh(),ct.openDialog(this.$widget),this.$autoComplete.trigger("focus").trigger("select")}async refresh(){this.$autoComplete.val(""),Xe.initNoteAutocomplete(this.$autoComplete,{hideGoToSelectedNoteButton:!0,allowCreatingNotes:!0}),Xe.showRecentNotes(this.$autoComplete)}async includeNote(t){const e=fe.getNoteIdFromUrl(t);if(!e)return;const i=await Mt.getNote(e),n=$("input[name='include-note-box-size']:checked").val();["image","canvas","mermaid"].includes(i?.type??"")?this.textTypeWidget?.addImage(e):this.textTypeWidget?.addIncludeNote(e,n)}}const zI=`
|
||
<div class="bulk-actions-dialog modal mx-auto" tabindex="-1" role="dialog">
|
||
<style>
|
||
.bulk-actions-dialog .modal-body h4:not(:first-child) {
|
||
margin-top: 20px;
|
||
}
|
||
|
||
.bulk-actions-dialog .bulk-available-action-list button {
|
||
padding: 2px 7px;
|
||
margin-right: 10px;
|
||
margin-bottom: 5px;
|
||
}
|
||
|
||
.bulk-actions-dialog .bulk-existing-action-list {
|
||
width: 100%;
|
||
}
|
||
|
||
.bulk-actions-dialog .bulk-existing-action-list td {
|
||
padding: 7px;
|
||
}
|
||
|
||
.bulk-actions-dialog .bulk-existing-action-list .button-column {
|
||
/* minimal width so that table remains static sized and most space remains for middle column with settings */
|
||
width: 50px;
|
||
white-space: nowrap;
|
||
text-align: right;
|
||
}
|
||
</style>
|
||
|
||
<div class="modal-dialog modal-xl" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">${m("bulk_actions.bulk_actions")}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("bulk_actions.close")}"></button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<h4>${m("bulk_actions.affected_notes")}: <span class="affected-note-count">0</span></h4>
|
||
|
||
<div class="form-check">
|
||
<label for="include-descendants" class="form-check-label tn-checkbox">
|
||
<input id="include-descendants" class="include-descendants form-check-input" type="checkbox" value="">
|
||
${m("bulk_actions.include_descendants")}
|
||
</label>
|
||
</div>
|
||
|
||
<h4>${m("bulk_actions.available_actions")}</h4>
|
||
|
||
<table class="bulk-available-action-list"></table>
|
||
|
||
<h4>${m("bulk_actions.chosen_actions")}</h4>
|
||
|
||
<table class="bulk-existing-action-list"></table>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="submit" class="execute-bulk-actions btn btn-primary">${m("bulk_actions.execute_bulk_actions")}</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`;class FI extends ge{$includeDescendants;$affectedNoteCount;$availableActionList;$existingActionList;$executeButton;selectedOrActiveNoteIds=null;doRender(){this.$widget=$(zI),this.$includeDescendants=this.$widget.find(".include-descendants"),this.$includeDescendants.on("change",()=>this.refresh()),this.$affectedNoteCount=this.$widget.find(".affected-note-count"),this.$availableActionList=this.$widget.find(".bulk-available-action-list"),this.$existingActionList=this.$widget.find(".bulk-existing-action-list"),this.$widget.on("click","[data-action-add]",async t=>{const e=$(t.target).attr("data-action-add");e&&(await Zc.addAction("_bulkAction",e),await this.refresh())}),this.$executeButton=this.$widget.find(".execute-bulk-actions"),this.$executeButton.on("click",async()=>{await pt.post("bulk-action/execute",{noteIds:this.selectedOrActiveNoteIds,includeDescendants:this.$includeDescendants.is(":checked")}),ft.showMessage(m("bulk_actions.bulk_actions_executed"),3e3),ct.closeActiveDialog()})}async refresh(){if(this.renderAvailableActions(),!this.selectedOrActiveNoteIds)return;const{affectedNoteCount:t}=await pt.post("bulk-action/affected-notes",{noteIds:this.selectedOrActiveNoteIds,includeDescendants:this.$includeDescendants.is(":checked")});this.$affectedNoteCount.text(t);const e=await Mt.getNote("_bulkAction");if(!e)return;const i=Zc.parseActions(e);this.$existingActionList.empty(),i.length>0?this.$existingActionList.append(...i.map(n=>n.render()).filter(n=>n!==null)):this.$existingActionList.append($("<p>").text(m("bulk_actions.none_yet")))}renderAvailableActions(){this.$availableActionList.empty();for(const t of Zc.ACTION_GROUPS){const e=$("<td>"),i=$("<tr>").append($("<td>").text(`${t.title}: `)).append(e);for(const n of t.actions)e.append($('<button class="btn btn-sm">').attr("data-action-add",n.actionName).text(n.actionTitle));this.$availableActionList.append(i)}}entitiesReloadedEvent({loadResults:t}){t.getAttributeRows().find(e=>e.type==="label"&&e.name==="action"&&e.noteId==="_bulkAction"&&e.isDeleted)&&this.selectedOrActiveNoteIds&&this.$widget.is(":visible")&&this.refresh()}async openBulkActionsDialogEvent({selectedOrActiveNoteIds:t}){this.selectedOrActiveNoteIds=t,this.$includeDescendants.prop("checked",!1),await this.refresh(),ct.openDialog(this.$widget)}}const WI=`<div class="branch-prefix-dialog modal fade mx-auto" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog modal-lg" role="document">
|
||
<form class="branch-prefix-form">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title flex-grow-1">${m("branch_prefix.edit_branch_prefix")}</h5>
|
||
<button class="help-button" type="button" data-help-page="tree-concepts.html#prefix" title="${m("branch_prefix.help_on_tree_prefix")}">?</button>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("branch_prefix.close")}"></button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="form-group">
|
||
<label for="branch-prefix-input">${m("branch_prefix.prefix")}</label>
|
||
|
||
<div class="input-group">
|
||
<input class="branch-prefix-input form-control">
|
||
<div class="branch-prefix-note-title input-group-text"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button class="btn btn-primary btn-sm">${m("branch_prefix.save")}</button>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>`;class HI extends ge{modal;$form;$treePrefixInput;$noteTitle;branchId=null;doRender(){this.$widget=$(WI),this.modal=Pi.getOrCreateInstance(this.$widget[0]),this.$form=this.$widget.find(".branch-prefix-form"),this.$treePrefixInput=this.$widget.find(".branch-prefix-input"),this.$noteTitle=this.$widget.find(".branch-prefix-note-title"),this.$form.on("submit",()=>(this.savePrefix(),!1)),this.$widget.on("shown.bs.modal",()=>this.$treePrefixInput.trigger("focus"))}async refresh(t){const{noteId:e,parentNoteId:i}=fe.getNoteIdAndParentIdFromUrl(t);if(!e||!i)return;const n=await Mt.getBranchId(i,e);if(!n)return;this.branchId=n;const s=Mt.getBranch(this.branchId);if(!s||s.noteId==="root")return;const a=await Mt.getNote(s.parentNoteId);if(!a||a.type==="search")return;this.$treePrefixInput.val(s.prefix||"");const l=await fe.getNoteTitle(e);this.$noteTitle.text(` - ${l}`)}async editBranchPrefixEvent(){const t=Pt.tabManager.getActiveContextNotePath();t&&(await this.refresh(t),ct.openDialog(this.$widget))}async savePrefix(){const t=this.$treePrefixInput.val();await pt.put(`branches/${this.branchId}/set-prefix`,{prefix:t}),this.modal.hide(),ft.showMessage(m("branch_prefix.branch_prefix_saved"))}}const VI=`<div class="sort-child-notes-dialog modal mx-auto" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog modal-lg" style="max-width: 500px" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">${m("sort_child_notes.sort_children_by")}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("sort_child_notes.close")}"></button>
|
||
</div>
|
||
<form class="sort-child-notes-form">
|
||
<div class="modal-body">
|
||
<h5>${m("sort_child_notes.sorting_criteria")}</h5>
|
||
<div class="form-check">
|
||
<label for="sort-by-title" class="form-check-label tn-radio">
|
||
<input id="sort-by-title" class="form-check-input" type="radio" name="sort-by" value="title" checked>
|
||
${m("sort_child_notes.title")}
|
||
</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<label for="sort-by-dateCreated" class="form-check-label tn-radio">
|
||
<input id="sort-by-dateCreated" class="form-check-input" type="radio" name="sort-by" value="dateCreated">
|
||
${m("sort_child_notes.date_created")}
|
||
</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<label for="sort-by-dateModified" class="form-check-label tn-radio">
|
||
<input id="sort-by-dateModified" class="form-check-input" type="radio" name="sort-by" value="dateModified">
|
||
${m("sort_child_notes.date_modified")}
|
||
</label>
|
||
</div>
|
||
<br/>
|
||
<h5>${m("sort_child_notes.sorting_direction")}</h5>
|
||
<div class="form-check">
|
||
<label for="sort-direction-asc" class="form-check-label tn-radio">
|
||
<input id="sort-direction-asc" class="form-check-input" type="radio" name="sort-direction" value="asc" checked>
|
||
${m("sort_child_notes.ascending")}
|
||
</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<label for="sort-direction-desc" class="form-check-label tn-radio">
|
||
<input id="sort-direction-desc" class="form-check-input" type="radio" name="sort-direction" value="desc">
|
||
${m("sort_child_notes.descending")}
|
||
</label>
|
||
</div>
|
||
<br />
|
||
<h5>${m("sort_child_notes.folders")}</h5>
|
||
<div class="form-check">
|
||
<label for="sort-folders-first" class="form-check-label tn-checkbox">
|
||
<input id="sort-folders-first" class="form-check-input" type="checkbox" name="sort-folders-first" value="1">
|
||
${m("sort_child_notes.sort_folders_at_top")}
|
||
</label>
|
||
</div>
|
||
<br />
|
||
<h5>${m("sort_child_notes.natural_sort")}</h5>
|
||
<div class="form-check">
|
||
<label for="sort-natural" class="form-check-label tn-checkbox">
|
||
<input id="sort-natural" class="form-check-input" type="checkbox" name="sort-natural" value="1">
|
||
${m("sort_child_notes.sort_with_respect_to_different_character_sorting")}
|
||
</label>
|
||
</div>
|
||
<br />
|
||
<div class="form-check">
|
||
<label>
|
||
${m("sort_child_notes.natural_sort_language")}
|
||
<input class="form-control" name="sort-locale">
|
||
${m("sort_child_notes.the_language_code_for_natural_sort")}
|
||
</label>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="submit" class="btn btn-primary">${m("sort_child_notes.sort")}</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>`;class UI extends ge{parentNoteId;$form;doRender(){this.$widget=$(VI),this.$form=this.$widget.find(".sort-child-notes-form"),this.$form.on("submit",async()=>{const t=this.$form.find("input[name='sort-by']:checked").val(),e=this.$form.find("input[name='sort-direction']:checked").val(),i=this.$form.find("input[name='sort-folders-first']").is(":checked"),n=this.$form.find("input[name='sort-natural']").is(":checked"),s=this.$form.find("input[name='sort-locale']").val();await pt.put(`notes/${this.parentNoteId}/sort-children`,{sortBy:t,sortDirection:e,foldersFirst:i,sortNatural:n,sortLocale:s}),ct.closeActiveDialog()})}async sortChildNotesEvent({node:t}){this.parentNoteId=t.data.noteId,ct.openDialog(this.$widget),this.$form.find("input:first").focus()}}async function jI(o){const t=[{title:m("note_types.text"),command:o,type:"text",uiIcon:"bx bx-note"},{title:m("note_types.code"),command:o,type:"code",uiIcon:"bx bx-code"},{title:m("note_types.saved-search"),command:o,type:"search",uiIcon:"bx bx-file-find"},{title:m("note_types.relation-map"),command:o,type:"relationMap",uiIcon:"bx bxs-network-chart"},{title:m("note_types.note-map"),command:o,type:"noteMap",uiIcon:"bx bxs-network-chart"},{title:m("note_types.render-note"),command:o,type:"render",uiIcon:"bx bx-extension"},{title:m("note_types.book"),command:o,type:"book",uiIcon:"bx bx-book"},{title:m("note_types.mermaid-diagram"),command:o,type:"mermaid",uiIcon:"bx bx-selection"},{title:m("note_types.canvas"),command:o,type:"canvas",uiIcon:"bx bx-pen"},{title:m("note_types.web-view"),command:o,type:"webView",uiIcon:"bx bx-globe-alt"},{title:m("note_types.mind-map"),command:o,type:"mindMap",uiIcon:"bx bx-sitemap"},{title:m("note_types.geo-map"),command:o,type:"geoMap",uiIcon:"bx bx-map-alt"}],e=await pt.get("search-templates"),i=await Mt.getNotes(e);if(i.length>0){t.push({title:"----"});for(const n of i)t.push({title:n.title,uiIcon:n.getIcon(),command:o,type:n.type,templateNoteId:n.noteId})}return t}const qI={getNoteTypeItems:jI},KI=`
|
||
<div class="note-type-chooser-dialog modal mx-auto" tabindex="-1" role="dialog">
|
||
<style>
|
||
.note-type-chooser-dialog {
|
||
/* note type chooser needs to be higher than other dialogs from which it is triggered, e.g. "add link"*/
|
||
z-index: 1100 !important;
|
||
}
|
||
|
||
.note-type-chooser-dialog .note-type-dropdown {
|
||
position: relative;
|
||
font-size: large;
|
||
padding: 20px;
|
||
width: 100%;
|
||
margin-top: 15px;
|
||
max-height: 80vh;
|
||
overflow: auto;
|
||
}
|
||
</style>
|
||
<div class="modal-dialog" style="max-width: 500px;" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">${m("note_type_chooser.modal_title")}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("note_type_chooser.close")}"></button>
|
||
</div>
|
||
<div class="modal-body">
|
||
${m("note_type_chooser.modal_body")}
|
||
|
||
<div class="dropdown" style="display: flex;">
|
||
<button class="note-type-dropdown-trigger" type="button" style="display: none;"
|
||
data-bs-toggle="dropdown" data-bs-display="static">
|
||
</button>
|
||
|
||
<div class="note-type-dropdown dropdown-menu"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`;class ZI extends ge{resolve;dropdown;modal;$noteTypeDropdown;$originalFocused;$originalDialog;constructor(){super(),this.resolve=null,this.$originalFocused=null,this.$originalDialog=null}doRender(){this.$widget=$(KI),this.modal=Pi.getOrCreateInstance(this.$widget[0]),this.$noteTypeDropdown=this.$widget.find(".note-type-dropdown"),this.dropdown=Ko.getOrCreateInstance(this.$widget.find(".note-type-dropdown-trigger")[0]),this.$widget.on("hidden.bs.modal",()=>{this.resolve&&this.resolve({success:!1}),this.$originalFocused&&(this.$originalFocused.trigger("focus"),this.$originalFocused=null),glob.activeDialog=this.$originalDialog}),this.$noteTypeDropdown.on("click",".dropdown-item",t=>this.doResolve(t)),this.$noteTypeDropdown.on("focus",".dropdown-item",t=>{this.$noteTypeDropdown.find(".dropdown-item").each((e,i)=>{$(i).toggleClass("active",i===t.target)})}),this.$noteTypeDropdown.on("keydown",".dropdown-item",t=>{if(t.key==="Enter")return this.doResolve(t),t.preventDefault(),!1}),this.$noteTypeDropdown.parent().on("hide.bs.dropdown",t=>{t.clickEvent?t.preventDefault():this.modal.hide()})}async chooseNoteTypeEvent({callback:t}){this.$originalFocused=$(":focus");const e=await qI.getNoteTypeItems();this.$noteTypeDropdown.empty();for(const i of e)if(i.title==="----")this.$noteTypeDropdown.append($('<h6 class="dropdown-header">').append(m("note_type_chooser.templates")));else{const n=i;this.$noteTypeDropdown.append($('<a class="dropdown-item" tabindex="0">').attr("data-note-type",n.type||"").attr("data-template-note-id",n.templateNoteId||"").append($("<span>").addClass(n.uiIcon||"")).append(` ${i.title}`))}this.dropdown.show(),this.$originalDialog=glob.activeDialog,glob.activeDialog=this.$widget,this.modal.show(),this.$noteTypeDropdown.find(".dropdown-item:first").focus(),this.resolve=t}doResolve(t){const e=$(t.target).closest(".dropdown-item"),i=e.attr("data-note-type"),n=e.attr("data-template-note-id");this.resolve&&this.resolve({success:!0,noteType:i,templateNoteId:n}),this.resolve=null,this.modal.hide()}}const GI=`
|
||
<div class="move-to-dialog modal mx-auto" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog modal-lg" style="max-width: 1000px" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title me-auto">${m("move_to.dialog_title")}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("move_to.close")}"></button>
|
||
</div>
|
||
<form class="move-to-form">
|
||
<div class="modal-body">
|
||
<h5>${m("move_to.notes_to_move")}</h5>
|
||
|
||
<ul class="move-to-note-list" style="max-height: 200px; overflow: auto;"></ul>
|
||
|
||
<div class="form-group">
|
||
<label style="width: 100%">
|
||
${m("move_to.target_parent_note")}
|
||
<div class="input-group">
|
||
<input class="move-to-note-autocomplete form-control" placeholder="${m("move_to.search_placeholder")}">
|
||
</div>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="submit" class="btn btn-primary">${m("move_to.move_button")}</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>`;class YI extends ge{movedBranchIds;$form;$noteAutoComplete;$noteList;constructor(){super(),this.movedBranchIds=null}doRender(){this.$widget=$(GI),this.$form=this.$widget.find(".move-to-form"),this.$noteAutoComplete=this.$widget.find(".move-to-note-autocomplete"),this.$noteList=this.$widget.find(".move-to-note-list"),this.$form.on("submit",()=>{const t=this.$noteAutoComplete.getSelectedNotePath();if(t){this.$widget.modal("hide");const{noteId:e,parentNoteId:i}=fe.getNoteIdAndParentIdFromUrl(t);i&&Mt.getBranchId(i,e).then(n=>{n&&this.moveNotesTo(n)})}else logError(m("move_to.error_no_path"));return!1})}async moveBranchIdsToEvent({branchIds:t}){this.movedBranchIds=t,ct.openDialog(this.$widget),this.$noteAutoComplete.val("").trigger("focus"),this.$noteList.empty();for(const e of this.movedBranchIds){const i=Mt.getBranch(e);if(!i)continue;const n=await Mt.getNote(i.noteId);n&&this.$noteList.append($("<li>").text(n.title))}Xe.initNoteAutocomplete(this.$noteAutoComplete),Xe.showRecentNotes(this.$noteAutoComplete)}async moveNotesTo(t){this.movedBranchIds&&await ri.moveToParentNote(this.movedBranchIds,t);const i=await Mt.getBranch(t)?.getNote();ft.showMessage(`${m("move_to.move_success_message")} ${i?.title}`)}}const JI=`
|
||
<div class="clone-to-dialog modal mx-auto" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog modal-lg" style="max-width: 1000px" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title flex-grow-1">${m("clone_to.clone_notes_to")}</h5>
|
||
<button type="button" class="help-button" title="${m("clone_to.help_on_links")}" data-help-page="cloning-notes.html">?</button>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("clone_to.close")}"></button>
|
||
</div>
|
||
<form class="clone-to-form">
|
||
<div class="modal-body">
|
||
<h5>${m("clone_to.notes_to_clone")}</h5>
|
||
|
||
<ul class="clone-to-note-list" style="max-height: 200px; overflow: auto;"></ul>
|
||
|
||
<div class="form-group">
|
||
<label style="width: 100%">
|
||
${m("clone_to.target_parent_note")}
|
||
<div class="input-group">
|
||
<input class="clone-to-note-autocomplete form-control" placeholder="${m("clone_to.search_for_note_by_its_name")}">
|
||
</div>
|
||
</label>
|
||
</div>
|
||
|
||
<div class="form-group" title="${m("clone_to.cloned_note_prefix_title")}">
|
||
<label style="width: 100%">
|
||
${m("clone_to.prefix_optional")}
|
||
<input class="clone-prefix form-control" style="width: 100%;">
|
||
</label>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="submit" class="btn btn-primary">${m("clone_to.clone_to_selected_note")}</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>`;class QI extends ge{$form;$noteAutoComplete;$clonePrefix;$noteList;clonedNoteIds=null;constructor(){super()}doRender(){this.$widget=$(JI),this.$form=this.$widget.find(".clone-to-form"),this.$noteAutoComplete=this.$widget.find(".clone-to-note-autocomplete"),this.$clonePrefix=this.$widget.find(".clone-prefix"),this.$noteList=this.$widget.find(".clone-to-note-list"),this.$form.on("submit",()=>{const t=this.$noteAutoComplete.getSelectedNotePath();return t?(this.$widget.modal("hide"),this.cloneNotesTo(t)):logError(m("clone_to.no_path_to_clone_to")),!1})}async cloneNoteIdsToEvent({noteIds:t}){(!t||t.length===0)&&(t=[Pt.tabManager.getActiveContextNoteId()??""]),this.clonedNoteIds=[];for(const e of t)this.clonedNoteIds.includes(e)||this.clonedNoteIds.push(e);ct.openDialog(this.$widget),this.$noteAutoComplete.val("").trigger("focus"),this.$noteList.empty();for(const e of this.clonedNoteIds){const i=await Mt.getNote(e);i&&this.$noteList.append($("<li>").text(i.title))}Xe.initNoteAutocomplete(this.$noteAutoComplete),Xe.showRecentNotes(this.$noteAutoComplete)}async cloneNotesTo(t){const{noteId:e,parentNoteId:i}=fe.getNoteIdAndParentIdFromUrl(t);if(!e||!i)return;const n=await Mt.getBranchId(i,e);if(!(!n||!this.clonedNoteIds))for(const s of this.clonedNoteIds){await ri.cloneNoteToBranch(s,n,this.$clonePrefix.val());const a=await Mt.getNote(s),l=Mt.getBranch(n);if(!a||!l)continue;const c=await l.getNote();c&&ft.showMessage(m("clone_to.note_cloned",{clonedTitle:a.title,targetTitle:c.title}))}}}const XI=`
|
||
<div class="import-dialog modal fade mx-auto" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog modal-lg" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">${m("import.importIntoNote")}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("import.close")}"></button>
|
||
</div>
|
||
<form class="import-form">
|
||
<div class="modal-body">
|
||
<div class="form-group">
|
||
<label for="import-file-upload-input"><strong>${m("import.chooseImportFile")}</strong></label>
|
||
|
||
<label class="tn-file-input tn-input-field">
|
||
<input type="file" class="import-file-upload-input form-control-file" multiple />
|
||
</label>
|
||
|
||
<p>${m("import.importDescription")} <strong class="import-note-title"></strong>.
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<strong>${m("import.options")}:</strong>
|
||
|
||
<div class="checkbox">
|
||
<label class="tn-checkbox" data-bs-toggle="tooltip" title="${Qn(m("import.safeImportTooltip"))}">
|
||
<input class="safe-import-checkbox" value="1" type="checkbox" checked>
|
||
<span>${m("import.safeImport")}</span>
|
||
</label>
|
||
</div>
|
||
|
||
<div class="checkbox">
|
||
<label class="tn-checkbox" data-bs-toggle="tooltip" title="${Qn(m("import.explodeArchivesTooltip"))}">
|
||
<input class="explode-archives-checkbox" value="1" type="checkbox" checked>
|
||
<span>${m("import.explodeArchives")}</span>
|
||
</label>
|
||
</div>
|
||
|
||
<div class="checkbox">
|
||
<label class="tn-checkbox" data-bs-toggle="tooltip" title="${Qn(m("import.shrinkImagesTooltip"))}">
|
||
<input class="shrink-images-checkbox" value="1" type="checkbox" checked> <span>${m("import.shrinkImages")}</span>
|
||
</label>
|
||
</div>
|
||
|
||
<div class="checkbox">
|
||
<label class="tn-checkbox">
|
||
<input class="text-imported-as-text-checkbox" value="1" type="checkbox" checked>
|
||
${m("import.textImportedAsText")}
|
||
</label>
|
||
</div>
|
||
|
||
<div class="checkbox">
|
||
<label class="tn-checkbox">
|
||
<input class="code-imported-as-code-checkbox" value="1" type="checkbox" checked> ${m("import.codeImportedAsCode")}
|
||
</label>
|
||
</div>
|
||
|
||
<div class="checkbox">
|
||
<label class="tn-checkbox">
|
||
<input class="replace-underscores-with-spaces-checkbox" value="1" type="checkbox" checked>
|
||
${m("import.replaceUnderscoresWithSpaces")}
|
||
</label>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button class="import-button btn btn-primary">${m("import.import")}</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>`;class tA extends ge{parentNoteId;$form;$noteTitle;$fileUploadInput;$importButton;$safeImportCheckbox;$shrinkImagesCheckbox;$textImportedAsTextCheckbox;$codeImportedAsCodeCheckbox;$explodeArchivesCheckbox;$replaceUnderscoresWithSpacesCheckbox;constructor(){super(),this.parentNoteId=null}doRender(){this.$widget=$(XI),Pi.getOrCreateInstance(this.$widget[0]),this.$form=this.$widget.find(".import-form"),this.$noteTitle=this.$widget.find(".import-note-title"),this.$fileUploadInput=this.$widget.find(".import-file-upload-input"),this.$importButton=this.$widget.find(".import-button"),this.$safeImportCheckbox=this.$widget.find(".safe-import-checkbox"),this.$shrinkImagesCheckbox=this.$widget.find(".shrink-images-checkbox"),this.$textImportedAsTextCheckbox=this.$widget.find(".text-imported-as-text-checkbox"),this.$codeImportedAsCodeCheckbox=this.$widget.find(".code-imported-as-code-checkbox"),this.$explodeArchivesCheckbox=this.$widget.find(".explode-archives-checkbox"),this.$replaceUnderscoresWithSpacesCheckbox=this.$widget.find(".replace-underscores-with-spaces-checkbox"),this.$form.on("submit",()=>(this.$importButton.attr("disabled","disabled"),this.parentNoteId&&this.importIntoNote(this.parentNoteId),!1)),this.$fileUploadInput.on("change",()=>{this.$fileUploadInput.val()?this.$importButton.removeAttr("disabled"):this.$importButton.attr("disabled","disabled")}),[...this.$widget.find('[data-bs-toggle="tooltip"]')].forEach(t=>{As.getOrCreateInstance(t,{html:!0})})}async showImportDialogEvent({noteId:t}){this.parentNoteId=t,this.$fileUploadInput.val("").trigger("change"),this.$safeImportCheckbox.prop("checked",!0),this.$shrinkImagesCheckbox.prop("checked",Qt.is("compressImages")),this.$textImportedAsTextCheckbox.prop("checked",!0),this.$codeImportedAsCodeCheckbox.prop("checked",!0),this.$explodeArchivesCheckbox.prop("checked",!0),this.$replaceUnderscoresWithSpacesCheckbox.prop("checked",!0),this.$noteTitle.text(await fe.getNoteTitle(this.parentNoteId)),ct.openDialog(this.$widget)}async importIntoNote(t){const e=Array.from(this.$fileUploadInput[0].files??[]),i=s=>s.is(":checked")?"true":"false",n={safeImport:i(this.$safeImportCheckbox),shrinkImages:i(this.$shrinkImagesCheckbox),textImportedAsText:i(this.$textImportedAsTextCheckbox),codeImportedAsCode:i(this.$codeImportedAsCodeCheckbox),explodeArchives:i(this.$explodeArchivesCheckbox),replaceUnderscoresWithSpaces:i(this.$replaceUnderscoresWithSpacesCheckbox)};this.$widget.modal("hide"),await xy.uploadFiles("notes",t,e,n)}}const eA=`
|
||
<div class="export-dialog modal fade mx-auto" tabindex="-1" role="dialog">
|
||
<style>
|
||
.export-dialog .export-form .form-check {
|
||
padding-top: 10px;
|
||
padding-bottom: 10px;
|
||
}
|
||
|
||
.export-dialog .export-form .format-choice {
|
||
padding-left: 40px;
|
||
display: none;
|
||
}
|
||
|
||
.export-dialog .export-form .opml-versions {
|
||
padding-left: 60px;
|
||
display: none;
|
||
}
|
||
|
||
.export-dialog .export-form .form-check-label {
|
||
padding: 2px;
|
||
}
|
||
</style>
|
||
|
||
<div class="modal-dialog modal-lg" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">${m("export.export_note_title")} <span class="export-note-title"></span></h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("export.close")}"></button>
|
||
</div>
|
||
<form class="export-form">
|
||
<div class="modal-body">
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-radio">
|
||
<input class="export-type-subtree form-check-input" type="radio" name="export-type" value="subtree">
|
||
${m("export.export_type_subtree")}
|
||
</label>
|
||
</div>
|
||
|
||
<div class="export-subtree-formats format-choice">
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-radio">
|
||
<input class="form-check-input" type="radio" name="export-subtree-format" value="html">
|
||
${m("export.format_html_zip")}
|
||
</label>
|
||
</div>
|
||
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-radio">
|
||
<input class="form-check-input" type="radio" name="export-subtree-format" value="markdown">
|
||
${m("export.format_markdown")}
|
||
</label>
|
||
</div>
|
||
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-radio">
|
||
<input class="form-check-input" type="radio" name="export-subtree-format" value="opml">
|
||
${m("export.format_opml")}
|
||
</label>
|
||
</div>
|
||
|
||
<div class="opml-versions">
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-radio">
|
||
<input class="form-check-input" type="radio" name="opml-version" value="1.0">
|
||
${m("export.opml_version_1")}
|
||
</label>
|
||
</div>
|
||
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-radio">
|
||
<input class="form-check-input" type="radio" name="opml-version" value="2.0">
|
||
${m("export.opml_version_2")}
|
||
</label>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-radio">
|
||
<input class="form-check-input" type="radio" name="export-type" value="single">
|
||
${m("export.export_type_single")}
|
||
</label>
|
||
</div>
|
||
|
||
<div class="export-single-formats format-choice">
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-radio">
|
||
<input class="form-check-input" type="radio" name="export-single-format" value="html">
|
||
${m("export.format_html")}
|
||
</label>
|
||
</div>
|
||
|
||
<div class="form-check">
|
||
<label class="form-check-label tn-radio">
|
||
<input class="form-check-input" type="radio" name="export-single-format" value="markdown">
|
||
${m("export.format_markdown")}
|
||
</label>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button class="export-button btn btn-primary">${m("export.export")}</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>`;class iA extends ge{taskId;branchId;modal;$form;$noteTitle;$subtreeFormats;$singleFormats;$subtreeType;$singleType;$exportButton;$opmlVersions;constructor(){super(),this.taskId="",this.branchId=null}doRender(){this.$widget=$(eA),this.modal=Pi.getOrCreateInstance(this.$widget[0]),this.$form=this.$widget.find(".export-form"),this.$noteTitle=this.$widget.find(".export-note-title"),this.$subtreeFormats=this.$widget.find(".export-subtree-formats"),this.$singleFormats=this.$widget.find(".export-single-formats"),this.$subtreeType=this.$widget.find(".export-type-subtree"),this.$singleType=this.$widget.find(".export-type-single"),this.$exportButton=this.$widget.find(".export-button"),this.$opmlVersions=this.$widget.find(".opml-versions"),this.$form.on("submit",()=>{this.modal?.hide();const t=this.$widget.find("input[name='export-type']:checked").val();if(!t){ft.showError(m("export.choose_export_type"));return}const e=t==="subtree"?this.$widget.find("input[name=export-subtree-format]:checked").val():this.$widget.find("input[name=export-single-format]:checked").val(),i=e==="opml"?this.$widget.find("input[name='opml-version']:checked").val():"1.0";return this.branchId&&this.exportBranch(this.branchId,String(t),String(e),String(i)),!1}),this.$widget.find("input[name=export-type]").on("change",t=>{t.currentTarget.value==="subtree"?(this.$widget.find("input[name=export-subtree-format]:checked").length===0&&this.$widget.find("input[name=export-subtree-format]:first").prop("checked",!0),this.$subtreeFormats.slideDown(),this.$singleFormats.slideUp()):(this.$widget.find("input[name=export-single-format]:checked").length===0&&this.$widget.find("input[name=export-single-format]:first").prop("checked",!0),this.$subtreeFormats.slideUp(),this.$singleFormats.slideDown())}),this.$widget.find("input[name=export-subtree-format]").on("change",t=>{t.currentTarget.value==="opml"?this.$opmlVersions.slideDown():this.$opmlVersions.slideUp()})}async showExportDialogEvent({notePath:t,defaultType:e}){if(this.taskId="",this.$exportButton.removeAttr("disabled"),e==="subtree")this.$subtreeType.prop("checked",!0).trigger("change"),this.$widget.find("input[name=export-subtree-format]:checked").trigger("change");else if(e==="single")this.$singleType.prop("checked",!0).trigger("change");else throw new Error(`Unrecognized type '${e}'`);this.$widget.find(".opml-v2").prop("checked",!0),ct.openDialog(this.$widget);const{noteId:i,parentNoteId:n}=fe.getNoteIdAndParentIdFromUrl(t);n&&(this.branchId=await Mt.getBranchId(n,i)),i&&this.$noteTitle.text(await fe.getNoteTitle(i))}exportBranch(t,e,i,n){this.taskId=ct.randomString(10);const s=en.getUrlForDownload(`api/branches/${t}/export/${e}/${i}/${n}/${this.taskId}`);en.download(s)}}yi.subscribeToMessages(async o=>{function t(e,i){return{id:e,title:m("export.export_status"),message:i,icon:"arrow-square-up-right"}}if(o.taskType==="export"){if(o.type==="taskError")ft.closePersistent(o.taskId),ft.showError(o.message);else if(o.type==="taskProgressCount")ft.showPersistent(t(o.taskId,m("export.export_in_progress",{progressCount:o.progressCount})));else if(o.type==="taskSucceeded"){const e=t(o.taskId,m("export.export_finished_successfully"));e.closeAfter=5e3,ft.showPersistent(e)}}});const nA=`
|
||
<div class="markdown-import-dialog modal fade mx-auto" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog modal-lg" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">${m("markdown_import.dialog_title")}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("markdown_import.close")}"></button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<p>${m("markdown_import.modal_body_text")}</p>
|
||
|
||
<textarea class="markdown-import-textarea" style="height: 340px; width: 100%"></textarea>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button class="markdown-import-button btn btn-primary">${m("markdown_import.import_button")}</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`;class oA extends ge{lastOpenedTs;modal;$importTextarea;$importButton;constructor(){super(),this.lastOpenedTs=0}doRender(){this.$widget=$(nA),this.modal=Pi.getOrCreateInstance(this.$widget[0]),this.$importTextarea=this.$widget.find(".markdown-import-textarea"),this.$importButton=this.$widget.find(".markdown-import-button"),this.$importButton.on("click",()=>this.sendForm()),this.$widget.on("shown.bs.modal",()=>this.$importTextarea.trigger("focus")),Bi.bindElShortcut(this.$widget,"ctrl+return",()=>this.sendForm())}async convertMarkdownToHtml(t){const{htmlContent:e}=await pt.post("other/render-markdown",{markdownContent:t}),i=await Pt.tabManager.getActiveContext()?.getTextEditor();if(!i)return;const n=i.data.processor.toView(e),s=i.data.toModel(n);i.model.insertContent(s,i.model.document.selection),i.editing.view.focus(),ft.showMessage(m("markdown_import.import_success"))}async pasteMarkdownIntoTextEvent(){await this.importMarkdownInlineEvent()}async importMarkdownInlineEvent(){if(Pt.tabManager.getActiveContextNoteType()==="text")if(ct.isElectron()){const{clipboard:t}=ct.dynamicRequire("electron"),e=t.readText();this.convertMarkdownToHtml(e)}else ct.openDialog(this.$widget)}async sendForm(){const t=String(this.$importTextarea.val());this.modal.hide(),await this.convertMarkdownToHtml(t),this.$importTextarea.val("")}}const sA=`
|
||
<div class="protected-session-password-dialog modal mx-auto" data-backdrop="false" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog modal-md" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title flex-grow-1">${m("protected_session_password.modal_title")}</h5>
|
||
<button class="help-button" type="button" data-help-page="protected-notes.html" title="${m("protected_session_password.help_title")}">?</button>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("protected_session_password.close_label")}"></button>
|
||
</div>
|
||
<form class="protected-session-password-form">
|
||
<div class="modal-body">
|
||
<label for="protected-session-password" class="col-form-label">${m("protected_session_password.form_label")}</label>
|
||
<input id="protected-session-password" class="form-control protected-session-password" type="password" autocomplete="current-password">
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button class="btn btn-primary">${m("protected_session_password.start_button")}</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>`;class rA extends ge{modal;$passwordForm;$passwordInput;doRender(){this.$widget=$(sA),this.modal=Pi.getOrCreateInstance(this.$widget[0]),this.$passwordForm=this.$widget.find(".protected-session-password-form"),this.$passwordInput=this.$widget.find(".protected-session-password"),this.$passwordForm.on("submit",()=>{const t=String(this.$passwordInput.val());return this.$passwordInput.val(""),ll.setupProtectedSession(t),!1})}showProtectedSessionPasswordDialogEvent(){ct.openDialog(this.$widget),this.$passwordInput.trigger("focus")}closeProtectedSessionPasswordDialogEvent(){this.modal.hide()}}const Lf="confirm-dialog-delete-note",aA=`
|
||
<div class="confirm-dialog modal mx-auto" tabindex="-1" role="dialog" style="z-index: 2000;">
|
||
<div class="modal-dialog modal-dialog-scrollable" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">${m("confirm.confirmation")}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("confirm.close")}"></button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="confirm-dialog-content"></div>
|
||
|
||
<div class="confirm-dialog-custom"></div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button class="confirm-dialog-cancel-button btn btn-sm">${m("confirm.cancel")}</button>
|
||
|
||
|
||
|
||
<button class="confirm-dialog-ok-button btn btn-primary btn-sm">${m("confirm.ok")}</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`;class lA extends ge{resolve;modal;$originallyFocused;$confirmContent;$okButton;$cancelButton;$custom;constructor(){super(),this.resolve=null,this.$originallyFocused=null}doRender(){this.$widget=$(aA),this.modal=Pi.getOrCreateInstance(this.$widget[0]),this.$confirmContent=this.$widget.find(".confirm-dialog-content"),this.$okButton=this.$widget.find(".confirm-dialog-ok-button"),this.$cancelButton=this.$widget.find(".confirm-dialog-cancel-button"),this.$custom=this.$widget.find(".confirm-dialog-custom"),this.$widget.on("shown.bs.modal",()=>this.$okButton.trigger("focus")),this.$widget.on("hidden.bs.modal",()=>{this.resolve&&this.resolve(!1),this.$originallyFocused&&(this.$originallyFocused.trigger("focus"),this.$originallyFocused=null)}),this.$cancelButton.on("click",()=>this.doResolve(!1)),this.$okButton.on("click",()=>this.doResolve(!0))}showConfirmDialogEvent({message:t,callback:e}){this.$originallyFocused=$(":focus"),this.$custom.hide(),glob.activeDialog=this.$widget,typeof t=="string"&&(t=$("<div>").text(t)),this.$confirmContent.empty().append(t),this.modal.show(),this.resolve=e}showConfirmDeleteNoteBoxWithNoteDialogEvent({title:t,callback:e}){glob.activeDialog=this.$widget,this.$confirmContent.text(`${m("confirm.are_you_sure_remove_note",{title:t})}`),this.$custom.empty().append("<br/>").append($("<div>").addClass("form-check").append($("<label>").addClass("form-check-label").attr("style","text-decoration: underline dotted var(--main-text-color)").attr("title",`${m("confirm.if_you_dont_check")}`).append($("<input>").attr("type","checkbox").addClass(`form-check-input ${Lf}`)).append(`${m("confirm.also_delete_note")}`))),this.$custom.show(),this.modal.show(),this.resolve=e}doResolve(t){this.resolve&&this.resolve({confirmed:t,isDeleteNoteChecked:this.$widget.find(`.${Lf}:checked`).length>0}),this.resolve=null,this.modal.hide()}}const cA=`
|
||
<div class="revisions-dialog modal fade mx-auto" tabindex="-1" role="dialog">
|
||
<style>
|
||
.revisions-dialog .revision-content-wrapper {
|
||
flex-grow: 1;
|
||
margin-left: 20px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
min-width: 0;
|
||
}
|
||
|
||
.revisions-dialog .revision-content {
|
||
overflow: auto;
|
||
word-break: break-word;
|
||
}
|
||
|
||
.revisions-dialog .revision-content img {
|
||
max-width: 100%;
|
||
object-fit: contain;
|
||
}
|
||
|
||
.revisions-dialog .revision-content pre {
|
||
max-width: 100%;
|
||
word-break: break-all;
|
||
white-space: pre-wrap;
|
||
}
|
||
</style>
|
||
|
||
<div class="modal-dialog modal-xl" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title flex-grow-1">${m("revisions.note_revisions")}</h5>
|
||
<button class="revisions-erase-all-revisions-button btn btn-sm"
|
||
title="${m("revisions.delete_all_revisions")}"
|
||
style="padding: 0 10px 0 10px;" type="button">${m("revisions.delete_all_button")}</button>
|
||
<button class="help-button" type="button" data-help-page="note-revisions.html" title="${m("revisions.help_title")}">?</button>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("revisions.close")}"></button>
|
||
</div>
|
||
<div class="modal-body" style="display: flex; height: 80vh;">
|
||
<div class="dropdown">
|
||
<button class="revision-list-dropdown" type="button" style="display: none;"
|
||
data-bs-toggle="dropdown" data-bs-display="static">
|
||
</button>
|
||
|
||
<div class="revision-list dropdown-menu static" style="position: static; height: 100%; overflow: auto;"></div>
|
||
</div>
|
||
|
||
<div class="revision-content-wrapper">
|
||
<div style="flex-grow: 0; display: flex; justify-content: space-between;">
|
||
<h3 class="revision-title" style="margin: 3px; flex-grow: 100;"></h3>
|
||
|
||
<div class="revision-title-buttons"></div>
|
||
</div>
|
||
|
||
<div class="revision-content use-tn-links"></div>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer py-0">
|
||
<span class="revisions-snapshot-interval flex-grow-1 my-0 py-0"></span>
|
||
<span class="maximum-revisions-for-current-note flex-grow-1 my-0 py-0"></span>
|
||
<button class="revision-settings-button icon-action bx bx-cog my-0 py-0" title="${m("revisions.settings")}"></button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`;class dA extends ge{revisionItems;note;revisionId;modal;listDropdown;$list;$listDropdown;$content;$title;$titleButtons;$eraseAllRevisionsButton;$maximumRevisions;$snapshotInterval;$revisionSettingsButton;constructor(){super(),this.revisionItems=[],this.note=null,this.revisionId=null}doRender(){this.$widget=$(cA),this.modal=Pi.getOrCreateInstance(this.$widget[0]),this.$list=this.$widget.find(".revision-list"),this.$listDropdown=this.$widget.find(".revision-list-dropdown"),this.listDropdown=Ko.getOrCreateInstance(this.$listDropdown[0],{autoClose:!1}),this.$content=this.$widget.find(".revision-content"),this.$title=this.$widget.find(".revision-title"),this.$titleButtons=this.$widget.find(".revision-title-buttons"),this.$eraseAllRevisionsButton=this.$widget.find(".revisions-erase-all-revisions-button"),this.$snapshotInterval=this.$widget.find(".revisions-snapshot-interval"),this.$maximumRevisions=this.$widget.find(".maximum-revisions-for-current-note"),this.$revisionSettingsButton=this.$widget.find(".revision-settings-button"),this.listDropdown.show(),this.$listDropdown.parent().on("hide.bs.dropdown",t=>{this.modal.hide()}),this.$widget.on("shown.bs.modal",()=>{this.$list.find(`[data-revision-id="${this.revisionId}"]`).trigger("focus")}),this.$eraseAllRevisionsButton.on("click",async()=>{if(!this.note)return;const t=m("revisions.confirm_delete_all");await Me.confirm(t)&&(await pt.remove(`notes/${this.note.noteId}/revisions`),this.modal.hide(),ft.showMessage(m("revisions.revisions_deleted")))}),this.$list.on("focus",".dropdown-item",t=>{this.$list.find(".dropdown-item").each((e,i)=>{$(i).toggleClass("active",i===t.target)}),this.setContentPane()}),this.$revisionSettingsButton.on("click",async()=>{Pt.tabManager.openContextWithNote("_optionsOther",{activate:!0})})}async showRevisionsEvent({noteId:t=Pt.tabManager.getActiveContextNoteId()}){t&&(ct.openDialog(this.$widget),await this.loadRevisions(t))}async loadRevisions(t){this.$title.empty(),this.$list.empty(),this.$content.empty(),this.$titleButtons.empty(),this.note=Pt.tabManager.getActiveContextNote(),this.revisionItems=await pt.get(`notes/${t}/revisions`);for(const i of this.revisionItems)this.$list.append($('<a class="dropdown-item" tabindex="0">').text(`${i.dateLastEdited.substr(0,16)} (${ct.formatSize(i.contentLength)})`).attr("data-revision-id",i.revisionId).attr("title",m("revisions.revision_last_edited",{date:i.dateLastEdited})));this.listDropdown.show(),this.revisionItems.length>0?this.revisionId||(this.revisionId=this.revisionItems[0].revisionId):(this.$title.text(m("revisions.no_revisions")),this.revisionId=null),this.$eraseAllRevisionsButton.toggle(this.revisionItems.length>0),this.$snapshotInterval.text(m("revisions.snapshot_interval",{seconds:Qt.getInt("revisionSnapshotTimeInterval")}));let e=parseInt(this.note?.getLabelValue("versioningLimit")??"");Number.isInteger(e)||(e=Qt.getInt("revisionSnapshotNumberLimit")??0),e===-1&&(e="∞"),this.$maximumRevisions.text(m("revisions.maximum_revisions",{number:e}))}async setContentPane(){const t=this.$list.find(".active").attr("data-revision-id"),e=this.revisionItems.find(i=>i.revisionId===t);e&&(this.$title.html(e.title),this.renderContentButtons(e),await this.renderContent(e))}renderContentButtons(t){this.$titleButtons.empty();const e=$(`
|
||
<button class="btn btn-sm" type="button">
|
||
<span class="bx bx-history"></span>
|
||
${m("revisions.restore_button")}
|
||
</button>
|
||
`);e.on("click",async()=>{const s=m("revisions.confirm_restore");await Me.confirm(s)&&(await pt.post(`revisions/${t.revisionId}/restore`),this.modal.hide(),ft.showMessage(m("revisions.revision_restored")))});const i=$(`
|
||
<button class="btn btn-sm" type="button">
|
||
<span class="bx bx-trash"></span>
|
||
${m("revisions.delete_button")}
|
||
</button>
|
||
`);i.on("click",async()=>{const s=m("revisions.confirm_delete");await Me.confirm(s)&&(await pt.remove(`revisions/${t.revisionId}`),this.loadRevisions(t.noteId),ft.showMessage(m("revisions.revision_deleted")))}),(!t.isProtected||Mi.isProtectedSessionAvailable())&&this.$titleButtons.append(e).append(" "),this.$titleButtons.append(i).append(" ");const n=$(`
|
||
<button class="btn btn-sm btn-primary" type="button">
|
||
<span class="bx bx-download"></span>
|
||
${m("revisions.download_button")}
|
||
</button>
|
||
`);n.on("click",()=>en.downloadRevision(t.noteId,t.revisionId)),(!t.isProtected||Mi.isProtectedSessionAvailable())&&this.$titleButtons.append(n)}async renderContent(t){this.$content.empty();const e=await pt.get(`revisions/${t.revisionId}`);if(t.type==="text")this.$content.html(`<div class="ck-content">${e.content}</div>`),this.$content.find("span.math-tex").length>0&&Rf(this.$content[0],{trust:!0});else if(t.type==="code")this.$content.html($("<pre>").text(e.content).prop("outerHTML"));else if(t.type==="image")if(e.mime==="image/svg+xml"){let i=encodeURIComponent(e.content);this.$content.html($("<img>").attr("src",`data:${e.mime};utf8,${i}`).css("max-width","100%").css("max-height","100%").prop("outerHTML"))}else this.$content.html($("<img>").attr("src",`data:${e.mime};base64,${e.content}`).css("max-width","100%").css("max-height","100%").prop("outerHTML"));else if(t.type==="file"){const i=$("<table cellpadding='10'>").append($("<tr>").append($("<th>").text(m("revisions.mime")),$("<td>").text(t.mime))).append($("<tr>").append($("<th>").text(m("revisions.file_size")),$("<td>").text(ct.formatSize(t.contentLength))));e.content&&i.append($("<tr>").append($('<td colspan="2">').append($('<div style="font-weight: bold;">').text(m("revisions.preview")),$('<pre class="file-preview-content"></pre>').text(e.content)))),this.$content.html(i.prop("outerHTML"))}else if(["canvas","mindMap"].includes(t.type)){const i=encodeURIComponent(t.title);this.$content.html($("<img>").attr("src",`api/revisions/${t.revisionId}/image/${i}?${Math.random()}`).css("max-width","100%").prop("outerHTML"))}else if(t.type==="mermaid"){const i=encodeURIComponent(t.title);this.$content.html($("<img>").attr("src",`api/revisions/${t.revisionId}/image/${i}?${Math.random()}`).css("max-width","100%").prop("outerHTML")),this.$content.append($("<pre>").text(e.content))}else this.$content.text(m("revisions.preview_not_available"))}}const hA=`
|
||
<div class="delete-notes-dialog modal mx-auto" tabindex="-1" role="dialog">
|
||
<div class="modal-dialog modal-dialog-scrollable modal-xl" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title">${m("delete_notes.delete_notes_preview")}</h4>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("delete_notes.close")}"></button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="form-checkbox">
|
||
<label for="delete-all-clones" class="form-check-label tn-checkbox">
|
||
<input id="delete-all-clones" class="delete-all-clones form-check-input" value="1" type="checkbox">
|
||
${m("delete_notes.delete_all_clones_description")}
|
||
</label>
|
||
</div>
|
||
|
||
<div class="form-checkbox" style="margin-bottom: 1rem">
|
||
<label for="erase-notes" class="form-check-label tn-checkbox">
|
||
<input id="erase-notes" class="erase-notes form-check-input" value="1" type="checkbox">
|
||
${m("delete_notes.erase_notes_warning")}
|
||
</label>
|
||
</div>
|
||
|
||
<div class="delete-notes-list-wrapper">
|
||
<h4>${m("delete_notes.notes_to_be_deleted",{noteCount:'<span class="deleted-notes-count"></span>'})}</h4>
|
||
|
||
<ul class="delete-notes-list" style="max-height: 200px; overflow: auto;"></ul>
|
||
</div>
|
||
|
||
<div class="no-note-to-delete-wrapper alert alert-info">
|
||
${m("delete_notes.no_note_to_delete")}
|
||
</div>
|
||
|
||
<div class="broken-relations-wrapper">
|
||
<div class="alert alert-danger">
|
||
<h4>${m("delete_notes.broken_relations_to_be_deleted",{relationCount:'<span class="broke-relations-count"></span>'})}</h4>
|
||
|
||
<ul class="broken-relations-list" style="max-height: 200px; overflow: auto;"></ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button class="delete-notes-dialog-cancel-button btn btn-sm">${m("delete_notes.cancel")}</button>
|
||
|
||
|
||
|
||
<button class="delete-notes-dialog-ok-button btn btn-primary btn-sm">${m("delete_notes.ok")}</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`;class uA extends ge{branchIds;resolve;$content;$okButton;$cancelButton;$deleteNotesList;$brokenRelationsList;$deletedNotesCount;$noNoteToDeleteWrapper;$deleteNotesListWrapper;$brokenRelationsListWrapper;$brokenRelationsCount;$deleteAllClones;$eraseNotes;forceDeleteAllClones;constructor(){super(),this.branchIds=null}doRender(){this.$widget=$(hA),this.$content=this.$widget.find(".recent-changes-content"),this.$okButton=this.$widget.find(".delete-notes-dialog-ok-button"),this.$cancelButton=this.$widget.find(".delete-notes-dialog-cancel-button"),this.$deleteNotesList=this.$widget.find(".delete-notes-list"),this.$brokenRelationsList=this.$widget.find(".broken-relations-list"),this.$deletedNotesCount=this.$widget.find(".deleted-notes-count"),this.$noNoteToDeleteWrapper=this.$widget.find(".no-note-to-delete-wrapper"),this.$deleteNotesListWrapper=this.$widget.find(".delete-notes-list-wrapper"),this.$brokenRelationsListWrapper=this.$widget.find(".broken-relations-wrapper"),this.$brokenRelationsCount=this.$widget.find(".broke-relations-count"),this.$deleteAllClones=this.$widget.find(".delete-all-clones"),this.$eraseNotes=this.$widget.find(".erase-notes"),this.$widget.on("shown.bs.modal",()=>this.$okButton.trigger("focus")),this.$cancelButton.on("click",()=>{ct.closeActiveDialog(),this.resolve({proceed:!1})}),this.$okButton.on("click",()=>{ct.closeActiveDialog(),this.resolve({proceed:!0,deleteAllClones:this.forceDeleteAllClones||this.isDeleteAllClonesChecked(),eraseNotes:this.isEraseNotesChecked()})}),this.$deleteAllClones.on("click",()=>this.renderDeletePreview())}async renderDeletePreview(){const t=await pt.post("delete-notes-preview",{branchIdsToDelete:this.branchIds,deleteAllClones:this.forceDeleteAllClones||this.isDeleteAllClonesChecked()});this.$deleteNotesList.empty(),this.$brokenRelationsList.empty(),this.$deleteNotesListWrapper.toggle(t.noteIdsToBeDeleted.length>0),this.$noNoteToDeleteWrapper.toggle(t.noteIdsToBeDeleted.length===0);for(const e of await Mt.getNotes(t.noteIdsToBeDeleted))this.$deleteNotesList.append($("<li>").append(await Pe.createLink(e.noteId,{showNotePath:!0})));this.$deletedNotesCount.text(t.noteIdsToBeDeleted.length),this.$brokenRelationsListWrapper.toggle(t.brokenRelations.length>0),this.$brokenRelationsCount.text(t.brokenRelations.length),await Mt.getNotes(t.brokenRelations.map(e=>e.noteId));for(const e of t.brokenRelations)this.$brokenRelationsList.append($("<li>").html(m("delete_notes.deleted_relation_text",{note:(await Pe.createLink(e.value)).html(),relation:`<code>${e.name}</code>`,source:(await Pe.createLink(e.noteId)).html()})))}async showDeleteNotesDialogEvent({branchIdsToDelete:t,callback:e,forceDeleteAllClones:i}){this.branchIds=t,this.forceDeleteAllClones=i,await this.renderDeletePreview(),ct.openDialog(this.$widget),this.$deleteAllClones.prop("checked",!!i).prop("disabled",!!i),this.$eraseNotes.prop("checked",!1),this.resolve=e}isDeleteAllClonesChecked(){return this.$deleteAllClones.is(":checked")}isEraseNotesChecked(){return this.$eraseNotes.is(":checked")}}const pA=`
|
||
<div class="info-dialog modal mx-auto" tabindex="-1" role="dialog" style="z-index: 2000;">
|
||
<div class="modal-dialog" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">${m("info.modalTitle")}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${m("info.closeButton")}"></button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="info-dialog-content"></div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button class="info-dialog-ok-button btn btn-primary btn-sm">${m("info.okButton")}</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`;class fA extends ge{resolve;modal;$originallyFocused;$infoContent;$okButton;constructor(){super(),this.resolve=null,this.$originallyFocused=null}doRender(){this.$widget=$(pA),this.modal=Pi.getOrCreateInstance(this.$widget[0]),this.$infoContent=this.$widget.find(".info-dialog-content"),this.$okButton=this.$widget.find(".info-dialog-ok-button"),this.$widget.on("shown.bs.modal",()=>this.$okButton.trigger("focus")),this.$widget.on("hidden.bs.modal",()=>{this.resolve&&this.resolve(),this.$originallyFocused&&(this.$originallyFocused.trigger("focus"),this.$originallyFocused=null)}),this.$okButton.on("click",()=>this.modal.hide())}showInfoDialogEvent({message:t,callback:e}){this.$originallyFocused=$(":focus"),typeof t=="string"?this.$infoContent.text(t):Array.isArray(t)?this.$infoContent.html(t[0]):this.$infoContent.html(t),ct.openDialog(this.$widget),this.resolve=e}}const mA=`
|
||
<div class="cpu-arch-dialog modal mx-auto" tabindex="-1" role="dialog" style="z-index: 2000;">
|
||
<div class="modal-dialog modal-lg" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">${m("cpu_arch_warning.title")}</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<p>${ct.isMac()?m("cpu_arch_warning.message_macos"):m("cpu_arch_warning.message_windows")}</p>
|
||
|
||
<p>${m("cpu_arch_warning.recommendation")}</p>
|
||
</div>
|
||
<div class="modal-footer d-flex justify-content-between align-items-center">
|
||
<button class="download-correct-version-button btn btn-primary btn-lg me-2">
|
||
<span class="bx bx-download"></span>
|
||
${m("cpu_arch_warning.download_link")}
|
||
</button>
|
||
|
||
<button class="btn btn-secondary" data-bs-dismiss="modal">${m("cpu_arch_warning.continue_anyway")}</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`;class gA extends ge{modal;$downloadButton;doRender(){this.$widget=$(mA),this.modal=Pi.getOrCreateInstance(this.$widget[0]),this.$downloadButton=this.$widget.find(".download-correct-version-button"),this.$downloadButton.on("click",()=>{if(ct.isElectron()){const{shell:t}=ct.dynamicRequire("electron");t.openExternal("https://github.com/TriliumNext/Notes/releases/latest")}else window.open("https://github.com/TriliumNext/Notes/releases/latest","_blank")}),this.$widget.on("shown.bs.modal",()=>{this.$downloadButton.trigger("focus")})}showCpuArchWarningEvent(){this.modal.show()}}function tL(o){o.child(new FI).child(new $I).child(new TI).child(new NI).child(new HI).child(new UI).child(new BI).child(new ZI).child(new AI).child(new DI).child(new QI).child(new YI).child(new tA).child(new iA).child(new oA).child(new rA).child(new dA).child(new uA).child(new fA).child(new lA).child(new PI).child(new gA)}export{VE as $,ze as A,Yi as B,Tg as C,hk as D,zi as E,F0 as F,Wt as G,W0 as H,Qe as I,ve as J,Ol as K,Fo as L,$s as M,tk as N,Wl as O,xt as P,PA as Q,ri as R,Xd as S,A0 as T,LA as U,UA as V,Pl as W,OA as X,MA as Y,DA as Z,mh as _,Cg as a,IA as a0,AA as a1,KA as a2,ZA as a3,XA as a4,jA as a5,GA as a6,YA as a7,qA as a8,QA as a9,FA as aa,VA as ab,zA as ac,WA as ad,HA as ae,EA as af,JA as ag,TA as ah,tL as ai,fw as aj,Be as ak,Zc as al,_E as am,Yl as an,BA as ao,Wo as ap,jE as aq,Dr as ar,w1 as as,xy as at,WE as au,Wi as b,ga as c,Ig as d,RA as e,Ci as f,Le as g,ye as h,me as i,Ts as j,$0 as k,Yt as l,Nd as m,qI as n,de as o,dg as p,Ft as q,a0 as r,_g as s,$i as t,mi as u,Zo as v,ws as w,To as x,NA as y,Ot as z};
|