const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./src-CRZ2yMRo.js","./src-Bbn-vyQI.js","./rolldown-runtime-DAXXjFlN.js","./preload-helper-HclGiUj8.js","./src-UeATgcQ9.js","./task_states-40T2foIO.js","./dayjs.min-yZk4pRyU.js","./isoWeek-DSe7EiHz.js","./bootstrap.esm-DbsKxb7T.js","./dist-Sc_lY_w3.js","./color-name-DfaNrEqF.js","./src-DOU5Yact.css","./EditableText-Bk4mS7Zf.js","./preact.module-CNakwbc9.js","./hooks.module-BrXTvcfS.js","./content_renderer-DOj8g78V.js","./theme-4HA_bZul.js","./purify.es-sLXpNpJ5.js","./i18n-BaLR3UdQ.js","./server-BXh06Wz_.js","./options-CDXBc9UM.js","./toast-C6WyPqyA.js","./jsxRuntime.module-Cao1NCKs.js","./react_utils-Bz0ffU2Y.js","./content_renderer-Oq750FP_.css","./utils-bj08OLzB.js","./compat.module-C8KToj4y.js","./hooks-ClTXKdUl.js","./mark-kZXE8V--.js","./note_autocomplete-BT55HtG6.js","./debounce-Fqb6O6Tb.js","./utils-DmG16PJC.js","./task_states-CgnEMRHE.js","./sample_diagrams-DcketTKF.js","./EditableText-BdPZrNuq.css","./SidebarChat-DQt3Do58.js","./ActionButton-DqIfNt93.js","./Dropdown-BUar6udP.js","./modal_focustrap-BhwPuWvY.js","./FormList-CnuOJg6b.js","./FormToggle-wwys3uI5.js","./FormToggle-DgUUoev9.css","./Icon-BEnt7704.js","./FormList-ByfmsXqb.css","./formatters-Dszv3NKH.js","./RightPanelWidget-NSw8KlRY.js","./ChatReadOnlyNotice-DKDPk4y6.js","./Button-Du0dYm4Z.js","./shortcut_kbd-CxTqyPZL.js","./NoItems-ZA3b1X1n.js","./NoItems-K35Ah64E.css","./CKEditor-DI777wJo.js","./ChatMessage-BURGqoUt.js","./Trans-CofL4-t5.js","./context-BtN0VmU6.js","./NoteLink-DzIkXtVf.js","./libesm-CWhOsFVl.js","./markdown_renderer-B83X0lzs.js","./ReadOnlyText-Dm8x8Q1I.js","./RawHtml-BZRPHliO.js","./math-BDK0Mxr3.js","./math-BI-ZUyP-.css","./ReadOnlyText-BdMg4PFb.css","./ChatMessage-B65D86b_.css","./MarkdownCommons-BFGqoXYW.css","./AddProviderModal-CmnAuV8u.js","./Modal-hBkTa-Ee.js","./Modal-B2OINckH.css","./Card-DHxlpCRf.js","./Card-a0v4CUz_.css","./FormTextBox-BLQGoABI.js","./Badge-B9svkCt1.js","./Badge-BB6J-xF3.css","./OptionsRow-CcGZJWUG.js","./OptionsRow-KoPoqbym.css","./FormCheckbox-B6Pj6_Zs.js","./SelectableCard-WSpOV0Di.js","./SelectableCard-nnaXz0Da.css","./AddProviderModal-Cyju-wUR.css","./ChatReadOnlyNotice-ST9yGjDT.css","./SidebarChat-DHeCw4OJ.css","./math-BdsX7GJL.js","./Ribbon-gcCvgg7Y.js","./NoteActions-DT2WQcSs.js","./bulk_action-LboOPmOm.js","./FormSelect-BDRio0zO.js","./NoteAutocomplete-Cpc7J_0A.js","./experimental_features-cVhuQmAy.js","./ribbon-interface-BiYA7e4K.js","./split_editor_mode-DCMayfDL.js","./FormDropdownList-CZjGhV_3.js","./note_types-DBtsBNjr.js","./i18n-B6qFeKf0.js","./syntax_highlighting-iHJxyTXm.js","./syntax_highlighting-DR-aZPjE.js","./OptionsSection-C2t30BmG.js","./OptionsSection-DDv1BzI4.css","./FormText-P1Ovp7qM.js","./i18n-CLNO7KAJ.css","./ribbon-interface-HR6oML3i.css","./LinkButton-Dzx5_ZkM.js","./LoadingSpinner-BT_849Kh.js","./Admonition-C4vnc1XO.js","./Admonition-DylwUTEV.css","./FormTextArea-Cn_4IrZw.js","./attribute_detail-D56dP-l3.js","./attribute_autocomplete-BWAlHWwK.js","./FormFileUpload-r12zFD32.js","./NoteActions-Dz5Wo5Xd.css","./NoteMap-fId8E6tB.js","./Slider-DyIUX7N-.js","./src-DmP8OL9D.js","./ordinal-hYBb2elL.js","./init-D6jRqBbL.js","./min-DKkL9U9e.js","./isObject-BNleAbAq.js","./debounce-BQF8WH3p.js","./now-fdb1ev71.js","./colors-Cg5Vh3br.js","./NoteMap-BWQgkFmc.css","./Ribbon-CVA4NE5S.css"])))=>i.map(i=>d[i]);
import{o as e,t}from"./rolldown-runtime-DAXXjFlN.js";import{t as n}from"./preload-helper-HclGiUj8.js";import{a as r,l as i}from"./preact.module-CNakwbc9.js";import{a,d as o,f as s,i as c,l,s as u,t as d}from"./hooks.module-BrXTvcfS.js";import{B as f,Ct as p,G as m,H as h,Pt as ee,R as g,bt as te,ht as _,jt as ne,zt as re}from"./content_renderer-DOj8g78V.js";import{a as ie}from"./src-UeATgcQ9.js";import{a as ae,c as oe,d as se,f as ce,i as le,l as ue,u as de}from"./PopupEditor-jIUhnaOn.js";import{r as v}from"./bootstrap.esm-DbsKxb7T.js";import{t as y}from"./purify.es-sLXpNpJ5.js";import{L as b,N as fe,S as pe,T as me,U as x,a as S,b as he}from"./i18n-BaLR3UdQ.js";import{p as ge,t as _e}from"./compat.module-C8KToj4y.js";import{t as ve}from"./server-BXh06Wz_.js";import{t as C}from"./options-CDXBc9UM.js";import{t as w}from"./jsxRuntime.module-Cao1NCKs.js";import{r as ye}from"./NoteList-CZrzG4tO.js";import{$ as be,I as T,J as E,K as D,S as xe,U as Se,X as Ce,Z as we,b as O,c as k,it as A,k as Te,m as j,n as M,nt as N,v as P,w as F}from"./hooks-ClTXKdUl.js";import{i as Ee}from"./experimental_features-cVhuQmAy.js";import{t as I}from"./ActionButton-DqIfNt93.js";import{C as De,S as L,b as R,o as Oe,t as ke,w as Ae,x as je}from"./NoteActions-DT2WQcSs.js";import{i as Me}from"./color_scheme-DE6TahTY.js";import{t as z}from"./Icon-BEnt7704.js";import{_ as Ne,a as Pe,c as Fe,d as Ie,f as Le,g as Re,h as ze,l as Be,m as Ve,n as He,p as Ue,r as We,s as Ge,t as Ke,u as qe,v as Je}from"./layout_commons-DUnSBlKh.js";import{n as Ye,t as Xe}from"./resizer-CYyI_eKA.js";import{t as Ze}from"./Modal-hBkTa-Ee.js";import{t as Qe}from"./Button-Du0dYm4Z.js";import{g as $e,n as et}from"./ribbon-interface-BiYA7e4K.js";import{t as tt}from"./RawHtml-BZRPHliO.js";import{t as nt}from"./right_panel_widget-CDMy3Ge9.js";import{t as rt}from"./react-window-B_BjKdTZ.js";import{t as it}from"./NoteDetail-k1cc0ILw.js";import{t as at}from"./NoItems-ZA3b1X1n.js";import{t as ot}from"./note_tree-CRaGDxoW.js";import{t as B}from"./RightPanelWidget-NSw8KlRY.js";import{t as st}from"./highlights_list_options-BHkhii-J.js";o(),i();function ct(){let{note:e,noteId:t}=Te(),[n,i]=u();E(`apiLogMessages`,({messages:e,noteId:n})=>{n===t&&i(e)}),l(()=>i(void 0),[e]);let a=e?.mime.startsWith(`application/javascript;env=`)&&n?.length;return w(`div`,{className:`api-log-widget ${a?``:`hidden-ext`}`,children:a&&w(r,{children:[w(I,{icon:`bx bx-x`,className:`close-api-log-button`,text:S(`api_log.close`),onClick:()=>i(void 0)}),w(`div`,{className:`api-log-container`,children:n.join(`
`)})]})})}o();function lt({isHorizontalLayout:e}){let[t,n]=u(C.is(`leftPaneVisible`));return E(`setLeftPaneVisibility`,({leftPaneVisible:e})=>{n(e??!t)}),l(()=>{Xe.setupLeftPaneResizer(t)},[t]),w(I,{className:`${e?`toggle-button`:`launcher-button`} left-pane-toggle-button ${t?`action-collapse`:`action-expand`}`,text:S(t?`left_pane_toggle.hide_panel`:`left_pane_toggle.show_panel`),triggerCommand:t?`hideLeftPane`:`showLeftPane`,icon:e?`bx bx-sidebar`:`bx bx-chevrons-left`,onContextMenu:Je})}o();function ut(){let[e,t]=u(C.is(`rightPaneVisible`));return E(`toggleRightPane`,s(()=>{t(e=>!e)},[])),w(I,{className:g(`toggle-button right-pane-toggle-button bx-flip-horizontal`,e?`action-collapse`:`action-expand`),text:S(`right_pane.toggle`),icon:`bx bx-sidebar`,triggerCommand:`toggleRightPane`})}var dt=class extends je{noteContext;thisElement;parentElement;resizeObserver;currentHeight=0;currentSafeMargin=NaN;constructor(){super(),this.class(`content-header-widget`),this.css(`contain`,`unset`),this.resizeObserver=new ResizeObserver(this.onResize.bind(this))}setNoteContextEvent({noteContext:e}){this.noteContext=e,this.init()}init(){if(this.parentElement=this.parent?.$widget.get(0),!this.parentElement){console.warn(`No parent set for <ContentHeader>.`);return}this.thisElement=this.$widget.get(0),this.resizeObserver.observe(this.thisElement),this.parentElement.addEventListener(`scroll`,this.updateSafeMargin.bind(this))}updateSafeMargin(){let e=Math.max(this.currentHeight-this.parentElement.scrollTop,0);e!==this.currentSafeMargin&&(this.currentSafeMargin=e,this.triggerEvent(`contentSafeMarginChanged`,{top:e,noteContext:this.noteContext}))}onResize(e){for(let t of e)t.target===this.thisElement&&(this.currentHeight=t.contentRect.height,this.updateSafeMargin())}},ft=class extends R{currentLeftPaneVisible;constructor(){super(`column`),this.currentLeftPaneVisible=C.is(`leftPaneVisible`),this.id(`left-pane`),this.css(`height`,`100%`),this.collapsible()}isEnabled(){return super.isEnabled()&&this.currentLeftPaneVisible}setLeftPaneVisibilityEvent({leftPaneVisible:e}){this.currentLeftPaneVisible=e??!this.currentLeftPaneVisible;let t=this.isEnabled();if(this.toggleInt(t),this.parent?.$widget.toggleClass(`left-pane-hidden`,!t),t)this.triggerEvent(`focusTree`,{});else{let e=m.tabManager.getActiveContext()?.ntxId;document.querySelector(`.note-split[data-ntx-id="${e}"]`)?.contains(document.activeElement)||this.triggerEvent(`focusOnDetail`,{ntxId:e})}C.save(`leftPaneVisible`,this.currentLeftPaneVisible.toString())}},pt=class extends R{rightPaneHidden;firstRender;constructor(){super(`column`),this.id(`right-pane`),this.css(`height`,`100%`),this.collapsible(),this.rightPaneHidden=!1,this.firstRender=!0}isEnabled(){return super.isEnabled()&&!this.rightPaneHidden&&this.children.length>0&&!!this.children.find(e=>e.isEnabled()&&e.canBeShown())}async handleEventInChildren(e,t){let n=super.handleEventInChildren(e,t);return[`activeContextChanged`,`noteSwitchedAndActivated`,`noteSwitched`].includes(e)&&(n?n.then(()=>this.reEvaluateRightPaneVisibilityCommand()):this.reEvaluateRightPaneVisibilityCommand()),n}reEvaluateRightPaneVisibilityCommand(){let e=!this.isHiddenInt(),t=this.isEnabled();(e!==t||this.firstRender)&&(this.toggleInt(t),Xe.setupRightPaneResizer(),this.firstRender=!1)}toggleRightPaneEvent(){this.rightPaneHidden=!this.rightPaneHidden,this.reEvaluateRightPaneVisibilityCommand()}};o();function mt(){let[e,t]=u(!1);return E(`showPasswordNotSet`,()=>t(!0)),w(Ze,{size:`md`,className:`password-not-set-dialog`,title:S(`password_not_set.title`),footer:w(Qe,{icon:`bx bx-lock`,text:S(`password_not_set.go_to_password_options`),onClick:()=>{t(!1),m.triggerCommand(`showOptions`,{section:`_optionsPassword`})}}),onHidden:()=>t(!1),show:e,children:[w(`p`,{children:S(`password_not_set.body1`)}),w(`p`,{children:S(`password_not_set.body2`)})]})}var ht=`<button class="button-widget bx"
      data-bs-toggle="tooltip"
      title=""></button>`,gt=class extends N{settings;tooltip;isEnabled(){return!0}doRender(){this.$widget=$(ht),this.tooltip=new v(this.$widget[0],{html:!0,title:()=>this.getTitle()||``,trigger:`hover`,placement:pe(this.settings.titlePlacement),fallbackPlacements:[pe(this.settings.titlePlacement)]}),this.settings.onContextMenu&&this.$widget.on(`contextmenu`,e=>(this.tooltip.hide(),this.settings.onContextMenu&&this.settings.onContextMenu(e),!1)),super.doRender()}getTitle(){return typeof this.settings.title==`function`?this.settings.title():this.settings.title}refreshIcon(){for(let e of this.$widget[0].classList)e.startsWith(`bx-`)&&this.$widget.removeClass(e);let e=typeof this.settings.icon==`function`?this.settings.icon():this.settings.icon;e&&this.$widget.addClass(e)}initialRenderCompleteEvent(){this.refreshIcon()}icon(e){return this.settings.icon=e,this}title(e){return this.settings.title=e,this}titlePlacement(e){return this.settings.titlePlacement=e,this}onContextMenu(e){return this.settings.onContextMenu=e,this}},V=class extends gt{constructor(){super(),this.settings={titlePlacement:`right`,title:null,icon:null,onContextMenu:null}}doRender(){super.doRender(),this.settings.onClick?this.$widget.on(`click`,e=>{this.$widget.tooltip(`hide`),this.settings.onClick&&this.settings.onClick(this,e)}):console.warn(S(`onclick_button.no_click_handler`,{componentId:this.componentId}),this.settings),this.settings.onAuxClick&&this.$widget.on(`auxclick`,e=>{this.$widget.tooltip(`hide`),this.settings.onAuxClick&&this.settings.onAuxClick(this,e)})}onClick(e){return this.settings.onClick=e,this}onAuxClick(e){return this.settings.onAuxClick=e,this}},_t={USE_PROFILES:{html:!0,mathMl:!0},FORBID_TAGS:`script.style.iframe.object.embed.link.meta.base.noscript.template.form.input.textarea.button.select.option.div.p.h1.h2.h3.h4.h5.h6.blockquote.pre.section.article.aside.nav.header.footer.main.figure.figcaption.table.thead.tbody.tfoot.tr.th.td.ul.ol.li.dl.dt.dd.hr.img.video.audio.picture.canvas.svg.foreignObject`.split(`.`),FORBID_ATTR:[`onerror`,`onload`,`onclick`,`onmouseover`,`onfocus`,`onblur`,`onsubmit`,`onreset`,`onchange`,`oninput`,`onkeydown`,`onkeyup`,`onkeypress`],RETURN_DOM:!1,RETURN_DOM_FRAGMENT:!1},vt=`<div class="highlights-list-widget">
    <style>
        .highlights-list-widget {
            padding: 10px;
            contain: none;
            overflow: auto;
            position: relative;
        }

        .highlights-list > ol {
            padding-inline-start: 20px;
        }

        .highlights-list li {
            cursor: pointer;
            margin-bottom: 3px;
            text-align: justify;
            word-wrap: break-word;
            hyphens: auto;
        }

        .highlights-list li:hover {
            font-weight: bold;
        }
    </style>

    <span class="highlights-list"></span>
</div>`,yt=class extends nt{$highlightsList;get widgetTitle(){return S(`highlights_list_2.title`)}get widgetButtons(){return[new V().icon(`bx-cog`).title(S(`highlights_list_2.options`)).titlePlacement(`left`).onClick(()=>m.tabManager.openContextWithNote(`_optionsTextNotes`,{activate:!0})).class(`icon-action`),new V().icon(`bx-x`).titlePlacement(`left`).onClick(e=>e.triggerCommand(`closeHlt`)).class(`icon-action`)]}isEnabled(){return super.isEnabled()&&this.note!=null&&this.note.type===`text`&&!this.noteContext?.viewScope?.highlightsListTemporarilyHidden&&this.noteContext?.viewScope?.viewMode==="default"}async doRenderBody(){this.$body.empty().append($(vt)),this.$highlightsList=this.$body.find(`.highlights-list`)}async refreshWithNote(e){this.noteContext?.viewScope?.highlightsListPreviousVisible?this.toggleInt(!0):this.toggleInt(!1);let t=JSON.parse(C.get(`highlightsList`));if(e?.isLabelTruthy(`hideHighlightWidget`)||!t.length){this.toggleInt(!1),this.triggerCommand(`reEvaluateRightPaneVisibility`);return}let n=null,r=-1;if(e&&this.note?.type===`text`){let i=await e.getNoteComplement();i&&`content`in i&&({$highlightsList:n,hlLiCount:r}=await this.getHighlightList(i.content,t))}this.$highlightsList.empty(),n&&this.$highlightsList.append(n),r>0?(this.toggleInt(!0),this.noteContext?.viewScope&&(this.noteContext.viewScope.highlightsListPreviousVisible=!0)):(this.toggleInt(!1),this.noteContext?.viewScope&&(this.noteContext.viewScope.highlightsListPreviousVisible=!1)),this.triggerCommand(`reEvaluateRightPaneVisibility`)}async getHighlightList(e,t){let n=/<span[^>]*style\s*=\s*[^>]*background-color:[^>]*?>[\s\S]*?<\/span>/gi,r=/<span[^>]*style\s*=\s*[^>]*[^-]color:[^>]*?>[\s\S]*?<\/span>/gi,i=/(<i>[\s\S]*?<\/i>|<em>[\s\S]*?<\/em>)/gi,a=/<strong>[\s\S]*?<\/strong>/gi,o=/<u>[\s\S]*?<\/u>/g,s=``,c=``;t.includes(`bgColor`)&&(s+=`,span[style*="background-color"]:not(section.include-note span[style*="background-color"])`,c+=`|${n.source}`),t.includes(`color`)&&(s+=`,span[style*="color"]:not(section.include-note span[style*="color"])`,c+=`|${r.source}`),t.includes(`italic`)&&(s+=`,i:not(section.include-note i)`,s+=`,em:not(section.include-note em)`,c+=`|${i.source}`),t.includes(`bold`)&&(s+=`,strong:not(section.include-note strong)`,c+=`|${a.source}`),t.includes(`underline`)&&(s+=`,u:not(section.include-note u)`,c+=`|${o.source}`),s=s.substring(1),c=`(${c.substring(1)})`;let l=new RegExp(c,`gi`),u=$(`<ol>`),d=-1,f=0;for(let t=null,n=0;(t=l.exec(e))!==null;n++){let e=t[0],r=t.index,i=l.lastIndex;if(!e.startsWith(`<strong><a href="#fnref`)){if(d!==-1&&r===d)u.children().last().append(y.sanitize(e,_t));else if($(e).text().trim())u.append($(`<li>`).html(y.sanitize(e,_t)).on(`click`,()=>this.jumpToHighlightsList(s,n))),f++;else continue;d=i}}return{$highlightsList:u,hlLiCount:f,findSubStr:s}}async jumpToHighlightsList(e,t){if(!this.noteContext)return;let n=await this.noteContext.isReadOnly(),r;if(n){let t=await this.noteContext.getContentElement();t&&(r=t.find(e).filter(function(){if(e.indexOf(`color`)>=0&&e.indexOf(`background-color`)<0){let e=this.style.color;return!($(this).prop(`tagName`)===`SPAN`&&e===``)}return!0}).filter(function(){let t=$(this);return t.parent(e).length===0&&t.parent().parent(e).length===0&&t.parent().parent().parent(e).length===0&&t.parent().parent().parent().parent(e).length===0}))}else{let t=(await this.noteContext.getTextEditor())?.editing.view.domRoots.values().next().value;t&&(r=$(t).find(e).filter(function(){let t=$(this);if(e.indexOf(`color`)>=0&&e.indexOf(`background-color`)<0){let e=this.style.color;return!(t.prop(`tagName`)===`SPAN`&&e===``)}return!0}).filter(function(){let t=$(this);return t.parent(e).length===0&&t.parent().parent(e).length===0&&t.parent().parent().parent(e).length===0&&t.parent().parent().parent().parent(e).length===0}))}r&&r[t]?r[t].scrollIntoView({behavior:`smooth`,block:`center`}):console.warn(`Unable to find the target element in the highlights list.`)}async closeHltCommand(){this.noteContext?.viewScope&&(this.noteContext.viewScope.highlightsListTemporarilyHidden=!0),await this.refresh(),this.triggerCommand(`reEvaluateRightPaneVisibility`),m.triggerEvent(`reEvaluateHighlightsListWidgetVisibility`,{noteId:this.noteId})}async showHighlightsListWidgetEvent({noteId:e}){this.noteId===e&&(await this.refresh(),this.triggerCommand(`reEvaluateRightPaneVisibility`),m.triggerEvent(`reEvaluateHighlightsListWidgetVisibility`,{noteId:this.noteId}))}async entitiesReloadedEvent({loadResults:e}){(this.noteId&&e.isNoteContentReloaded(this.noteId)||e.getAttributeRows().find(e=>e.type===`label`&&(e.name?.toLowerCase().includes(`readonly`)||e.name===`hideHighlightWidget`)&&A.isAffecting(e,this.note)))&&await this.refresh()}};o();function bt({loader:e}){let[t,n]=u(null);return l(()=>{let t=!1;return e().then(({default:e})=>{t||n(()=>e)}),()=>{t=!0}},[]),w(`div`,{className:`lazy-component`,children:t&&w(t,{})})}o();function xt(e,t){switch(t){case`togglePeek`:return e===`closed`?`peek`:`closed`;case`toggleDocked`:return e===`closed`?`docked`:`closed`;case`dock`:return`docked`;case`close`:return`closed`;case`dismiss`:return`closed`}}function St(e,t){return e===`docked`==(t===`docked`)?null:t===`docked`}function Ct(e){let[{mode:t,mounted:n},r]=u(()=>{let t=C.is(e);return{mode:t?`docked`:`closed`,mounted:t}}),i=s(e=>{r(t=>{let n=xt(t.mode,e),r;return r=n===`closed`?e===`togglePeek`||e===`dismiss`?t.mounted:!1:!0,{mode:n,mounted:r}})},[]),a=d(t);l(()=>{let n=a.current;if(n!==t){let r=St(n,t);r!==null&&C.save(e,r.toString()),a.current=t}},[t,e]);let o=s(()=>i(`togglePeek`),[i]),c=s(()=>i(`toggleDocked`),[i]),f=s(()=>i(`dock`),[i]),p=s(()=>i(`close`),[i]),m=s(()=>i(`dismiss`),[i]);return{mode:t,visible:t!==`closed`,mounted:n,togglePeek:o,toggleDocked:c,dock:f,close:p,dismiss:m}}var wt=`.gutter, .dropdown-menu, .tooltip, .modal, .popover, .ck-balloon-panel, .ck-body, .flatpickr-calendar`;function Tt(e,t){return e instanceof Element&&e.closest(t)!==null}function Et(e,t,{keepOpenSelector:n,focusSelector:r}){l(()=>{if(!e)return;let i=`${n}, ${wt}`,a=e=>{Tt(e.target,i)||t()},o=e=>{e.key===`Escape`&&!e.defaultPrevented&&(t(),r&&document.querySelector(r)?.focus())};return document.addEventListener(`pointerdown`,a,!0),document.addEventListener(`keydown`,o),()=>{document.removeEventListener(`pointerdown`,a,!0),document.removeEventListener(`keydown`,o)}},[e,t,n,r])}function Dt(){let e=j(`chatHighlights`),t=e?.highlights??[];return w(B,{id:`chat-highlights`,title:S(`llm_chat.highlights_title`,{count:t.length}),grow:!0,children:w(`div`,{className:`chat-highlights-list`,children:t.length>0?w(`ol`,{children:t.map(t=>w(`li`,{children:[w(`span`,{className:`chat-highlight-text`,role:`button`,tabIndex:0,onClick:()=>e?.scrollToHighlight(t.id),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e?.scrollToHighlight(t.id))},children:t.text}),w(I,{className:`chat-highlight-remove`,icon:`bx bx-x`,text:S(`llm_chat.highlight_remove`),onClick:n=>{n.stopPropagation(),(async()=>{await ee.confirm(S(`llm_chat.highlight_remove_confirm`))&&e?.removeHighlight(t.id)})()}})]},t.id))}):w(`div`,{className:`no-highlights`,children:S(`llm_chat.highlights_empty`)})})})}ge(),o(),i();function Ot(){let{note:e,noteContext:t}=M(),n=T(e,`type`),{isReadOnly:i}=P(e,t);return w(r,{children:[n===`text`&&i&&w(Pt,{}),n===`text`&&!i&&w(Mt,{})]})}function kt({shown:e,setShown:t}){return w(Ze,{className:`highlights-list-options-modal`,size:`md`,title:S(`highlights_list_2.modal_title`),show:e,onHidden:()=>t(!1),children:w(st,{})})}function At({highlights:e,scrollToHighlight:t}){let[n]=be(`highlightsList`),i=new Set(n||[]),a=e.filter(e=>{let{attrs:t}=e;return i.has(`bold`)&&t.bold||i.has(`italic`)&&t.italic||i.has(`underline`)&&t.underline||i.has(`color`)&&!!t.color||i.has(`bgColor`)&&!!t.background}),[o,s]=u(!1);return w(r,{children:[w(B,{id:`highlights`,title:S(`highlights_list_2.title_with_count`,{count:a.length}),contextMenuItems:[{title:S(`highlights_list_2.menu_configure`),uiIcon:`bx bx-cog`,handler:()=>s(!0)}],grow:!0,children:w(`span`,{className:`highlights-list`,children:a.length>0?w(`ol`,{children:a.map(e=>w(jt,{highlight:e,onClick:()=>t(e)},e.id))}):w(`div`,{className:`no-highlights`,children:S(`highlights_list_2.no_highlights`)})})}),_e(w(kt,{shown:o,setShown:s}),document.body)]})}function jt({highlight:e,onClick:t}){let n=d(null);return F(n,[e.text]),w(`li`,{onClick:t,children:w(tt,{containerRef:n,style:{fontWeight:e.attrs.bold?`700`:void 0,fontStyle:e.attrs.italic?`italic`:void 0,textDecoration:e.attrs.underline?`underline`:void 0,color:e.attrs.color,backgroundColor:e.attrs.background},html:e.text})})}function Mt(){let{note:e,noteContext:t}=M(),n=D(t),[r,i]=u([]);return l(()=>{if(!n)return;i(Nt(n));let e=()=>{n.model.document.differ.getChanges().some(e=>e.type===`insert`||e.type===`remove`||e.type===`attribute`&&(e.attributeKey===`bold`||e.attributeKey===`italic`||e.attributeKey===`underline`||e.attributeKey===`fontColor`||e.attributeKey===`fontBackgroundColor`))&&i(Nt(n))};return n.model.document.on(`change:data`,e),()=>n.model.document.off(`change:data`,e)},[n,e]),w(At,{highlights:r,scrollToHighlight:s(e=>{if(!n)return;let t=n.model.createPositionAt(e.textNode,`before`),r=n.editing.mapper.toViewPosition(t),i=n.editing.view.domConverter.viewPositionToDom(r);i&&(i.parent instanceof HTMLElement?i.parent.scrollIntoView():i.parent instanceof Text&&i.parent.parentElement?.scrollIntoView())},[n])})}function Nt(e){let t=[],n=e.model.document.getRoot();if(!n)return[];for(let{item:r}of e.model.createRangeIn(n).getWalker({ignoreElementEnd:!0})){if(!r.is(`$textProxy`)||!r.data.trim())continue;let n={bold:r.hasAttribute(`bold`),italic:r.hasAttribute(`italic`),underline:r.hasAttribute(`underline`),color:r.getAttribute(`fontColor`),background:r.getAttribute(`fontBackgroundColor`)};if(Object.values(n).some(Boolean)){let i=r.data;try{let t=e.model.createPositionAt(r.textNode,`before`),n=e.editing.mapper.toViewPosition(t),a=e.editing.view.domConverter.viewPositionToDom(n);a?.parent instanceof HTMLElement&&(i=a.parent.innerHTML)}catch{}t.push({id:b(),text:i,attrs:n,textNode:r.textNode,offset:r.startOffset})}}return t}function Pt(){let{noteContext:e}=M();return w(At,{highlights:Ft(k(e)),scrollToHighlight:s(e=>{e.element.scrollIntoView()},[])})}function Ft(e){if(!e)return[];let t=[],n=new Set,r=e.querySelectorAll(`[style*="background-color"], [style*="color"]`);for(let e of r){if(n.has(e)||!e.textContent?.trim())continue;let r={bold:!!e.closest(`strong`),italic:!!e.closest(`em`),underline:!!e.closest(`u`),background:e.style.backgroundColor,color:e.style.color};Object.values(r).some(Boolean)&&(n.add(e),t.push({id:b(),text:e.innerHTML,element:e,attrs:r}))}let i=e.querySelectorAll(`strong, em, u, b, i`);for(let e of i){if(n.has(e)||Array.from(n).some(t=>t.contains(e))||!e.textContent?.trim())continue;let r={bold:e.matches(`strong, b`),italic:e.matches(`em, i`),underline:e.matches(`u`),background:e.style.backgroundColor,color:e.style.color};Object.values(r).some(Boolean)&&(n.add(e),t.push({id:b(),text:e.innerHTML,element:e,attrs:r}))}return t}var It={text:`bx bxs-comment-detail`,highlight:`bx bx-highlight`};function Lt(){let{note:e}=M(),t=T(e,`type`),n=T(e,`mime`),r=j(`pdfAnnotations`);return t!==`file`||n!==`application/pdf`||!r||r.annotations.length===0?null:w(B,{id:`pdf-annotations`,title:S(`pdf.annotations`,{count:r.annotations.length}),children:w(`div`,{className:`pdf-annotations-list`,children:r.annotations.map(e=>w(Rt,{annotation:e,onNavigate:r.scrollToAnnotation},e.id))})})}function Rt({annotation:e,onNavigate:t}){let n=e.contents?`bx bxs-comment-detail`:It[e.type]??`bx bx-comment`;return w(`div`,{className:`pdf-annotation-item`,onClick:()=>t(e.id,e.pageNumber),style:e.color?{backgroundColor:e.color}:void 0,children:[w(z,{icon:n}),w(`div`,{className:`pdf-annotation-info`,children:[e.highlightedText&&w(`div`,{className:`pdf-annotation-highlighted-text`,children:e.highlightedText}),e.contents&&w(`div`,{className:`pdf-annotation-contents`,children:e.contents}),e.author&&w(`div`,{className:`pdf-annotation-author`,children:e.author})]})]})}function zt(){let{note:e}=M(),t=T(e,`type`),n=T(e,`mime`),r=j(`pdfAttachments`);return t!==`file`||n!==`application/pdf`||!r||r.attachments.length===0?null:w(B,{id:`pdf-attachments`,title:S(`pdf.attachments`,{count:r.attachments.length}),children:w(`div`,{className:`pdf-attachments-list`,children:r.attachments.map(e=>w(Bt,{attachment:e,onDownload:r.downloadAttachment},e.filename))})})}function Bt({attachment:e,onDownload:t}){let n=he(e.size);return w(`div`,{className:`pdf-attachment-item`,onClick:()=>t(e.filename),children:[w(z,{icon:`bx bx-paperclip`}),w(`div`,{className:`pdf-attachment-info`,children:[w(`div`,{className:`pdf-attachment-filename`,children:e.filename}),w(`div`,{className:`pdf-attachment-size`,children:n})]}),w(z,{icon:`bx bx-download`})]})}function Vt(){let{note:e}=M(),t=T(e,`type`),n=T(e,`mime`),r=j(`pdfLayers`);return t!==`file`||n!==`application/pdf`?null:r?.layers&&r.layers.length>0&&w(B,{id:`pdf-layers`,title:S(`pdf.layers`,{count:r.layers.length}),children:w(`div`,{className:`pdf-layers-list`,children:r.layers.map(e=>w(Ht,{layer:e,onToggle:r.toggleLayer},e.id))})})}function Ht({layer:e,onToggle:t}){return w(`div`,{className:`pdf-layer-item ${e.visible?`visible`:`hidden`}`,onClick:()=>t(e.id,!e.visible),children:[w(z,{icon:e.visible?`bx bx-show`:`bx bx-hide`}),w(`div`,{className:`pdf-layer-name`,children:e.name})]})}o();var Ut=180,H=2;function Wt(){let{note:e}=M(),t=T(e,`type`),n=T(e,`mime`),r=j(`pdfPages`);return t!==`file`||n!==`application/pdf`?null:r&&w(B,{id:`pdf-pages`,title:S(`pdf.pages`,{count:r?.totalPages||0}),grow:!0,children:w(Gt,{pagesData:r},e?.noteId)})}function Gt({pagesData:e}){let[t,n]=u(new Map),r=d(new Set),i=d(null),[a,o]=u(0);l(()=>{function e(e){let{pageNumber:t,dataUrl:r}=e.detail;n(e=>new Map(e).set(t,r))}return window.addEventListener(`pdf-thumbnail`,e),()=>{window.removeEventListener(`pdf-thumbnail`,e)}},[]),l(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(([e])=>{o(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]);let c=s(n=>{!r.current.has(n)&&!t.has(n)&&e&&(r.current.add(n),e.requestThumbnail(n))},[e,t]);return!e||e.totalPages===0?w(`div`,{className:`no-pages`,children:`No pages available`}):w(`div`,{ref:i,className:`pdf-pages-list`,children:a>0&&w(rt,{rowComponent:Kt,rowCount:Math.ceil(e.totalPages/H),rowHeight:Ut,rowProps:{totalPages:e.totalPages,thumbnails:t,currentPage:e.currentPage,requestThumbnail:c,scrollToPage:e.scrollToPage},style:{height:a}})})}function Kt({index:e,style:t,...n}){let{totalPages:r,thumbnails:i,currentPage:a,requestThumbnail:o,scrollToPage:s}=n,c=e*H+1;return w(`div`,{style:t,className:`pdf-page-row`,children:Array.from({length:H},(e,t)=>c+t).filter(e=>e<=r).map(e=>w(qt,{pageNumber:e,isActive:e===a,thumbnail:i.get(e),requestThumbnail:o,scrollToPage:s},e))})}function qt({pageNumber:e,isActive:t,thumbnail:n,requestThumbnail:r,scrollToPage:i}){let a=d(!1);return l(()=>{!n&&!a.current&&(a.current=!0,r(e))},[e,n,r]),w(`div`,{className:`pdf-page-item ${t?`active`:``}`,onClick:()=>i(e),children:[w(`div`,{className:`pdf-page-thumbnail`,children:n?w(`img`,{src:n,alt:S(`pdf.pages_alt`,{pageNumber:e})}):w(`div`,{className:`pdf-page-loading`,children:S(`pdf.pages_loading`)})}),w(`div`,{className:`pdf-page-number`,children:e})]})}o();var Jt=8;function Yt({rightPaneVisible:e,onToggle:t}){let n=d(null),r=d(null),i=s(()=>{t();let e=n.current;e&&(v.getInstance(e)?.hide(),e.blur())},[t]),a=S(e?`right_pane.hide`:`right_pane.peek`);return Se(n,c(()=>({title:a,placement:`left`,offset:()=>{let e=n.current?.getBoundingClientRect();return!e||r.current===null?[0,Jt]:[r.current-(e.top+e.height/2),Jt]}}),[a])),w(`button`,{ref:n,type:`button`,"aria-label":a,class:g(`right-pane-peek-button bx`,e?`bx-chevron-right`:`bx-chevron-left`,e?`right-pane-peek-button-action-collapse`:`right-pane-peek-button-action-expand`),onMouseEnter:e=>{r.current=e.clientY},onMouseLeave:()=>{r.current=null},onClick:i})}o(),i();function Xt(){let{note:e,noteContext:t}=M(),n=T(e,`type`),r=T(e,`mime`),{isReadOnly:i}=P(e,t);return w(B,{id:`toc`,title:S(`toc.table_of_contents`),grow:!0,children:[(n===`text`&&i||n===`doc`)&&w(nn,{}),n===`text`&&!i&&w(en,{}),n===`file`&&r===`application/pdf`&&w(U,{}),n===`llmChat`&&w(U,{}),e?.isMarkdown()&&w(U,{})]})}function U(){let e=j(`toc`);return w(W,{headings:e?.headings||[],scrollToHeading:e?.scrollToHeading||(()=>{}),activeHeadingId:e?.activeHeadingId})}function W({headings:e,scrollToHeading:t,activeHeadingId:n}){let r=Qt(e);return w(`span`,{className:`toc`,children:r.length>0?w(`ol`,{children:r.map(e=>w(Zt,{heading:e,scrollToHeading:t,activeHeadingId:n},e.id))}):w(`div`,{className:`no-headings`,children:S(`toc.no_headings`)})})}function Zt({heading:e,scrollToHeading:t,activeHeadingId:n}){let[i,a]=u(!1),o=e.id===n,s=d(null);return F(s,[e.text]),w(r,{children:[w(`li`,{className:g(i&&`collapsed`,o&&`active`),children:[e.children.length>0&&w(z,{className:`collapse-button`,icon:`bx bx-chevron-down`,onClick:()=>a(!i)}),w(tt,{containerRef:s,className:`item-content`,onClick:()=>t(e),html:e.text})]}),e.children.length>0&&w(`ol`,{children:e.children.map(e=>w(Zt,{heading:e,scrollToHeading:t,activeHeadingId:n},e.id))})]})}function Qt(e){let t={level:0,text:``,children:[],id:`_root`},n=[t];for(let t of e){let e={...t,children:[]};for(;n.length>1&&n[n.length-1].level>=t.level;)n.pop();n[n.length-1].children.push(e),n.push(e)}return t.children}var $t=`tocId`;function en(){let{noteContext:e}=M(),t=D(e),[r,i]=u([]);return l(()=>{if(!t)return;i(tn(t));let e=!1,r;return n(async()=>{let{attributeChangeAffectsHeading:e}=await import(`./src-CRZ2yMRo.js`);return{attributeChangeAffectsHeading:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34]),import.meta.url).then(({attributeChangeAffectsHeading:n})=>{if(e)return;let a=()=>{t.model.document.differ.getChanges().some(e=>e.type===`insert`||e.type===`remove`||e.type===`attribute`&&n(e,t))&&requestAnimationFrame(()=>{i(tn(t))})};t.model.document.on(`change:data`,a),r=()=>t.model.document.off(`change:data`,a)}),()=>{e=!0,r?.()}},[t]),w(W,{headings:r,scrollToHeading:s(e=>{if(!t)return;let n=t.editing.mapper.toViewElement(e.element);n&&t.editing.view.domConverter.mapViewToDom(n)?.scrollIntoView()},[t])})}function tn(e){let t=[],n=e.model.document.getRoot();return n?(e.model.change(r=>{for(let{type:i,item:a}of e.model.createRangeIn(n).getWalker()){if(i!==`elementStart`||!a.is(`element`)||!a.name.startsWith(`heading`))continue;let n=Number(a.name.replace(`heading`,``)),o=e.editing.mapper.toViewElement(a),s=``;if(o){let t=e.editing.view.domConverter.mapViewToDom(o);if(t instanceof HTMLElement){let e=t.cloneNode(!0),n=e.querySelectorAll(`.ck-math-tex`),r=0;for(let e of a.getChildren()){if(!e.is(`element`,`mathtex-inline`))continue;if(r>=n.length)break;let t=String(e.getAttribute(`equation`)??``),i=document.createElement(`span`);i.className=`math-tex`,i.textContent=`\\(${t}\\)`,n[r].replaceWith(i),r++}s=e.innerHTML}}s||=Array.from(a.getChildren()).map(e=>e.is(`$text`)?e.data:``).join(``);let c=a.getAttribute($t);c||(c=b(),r.setAttribute($t,c,a)),t.push({level:n,text:s,element:a,id:c})}}),t):[]}function nn(){let{noteContext:e}=M();return w(W,{headings:rn(k(e)),scrollToHeading:s(e=>{e.element.scrollIntoView()},[])})}function rn(e){if(!e)return[];let t=[];for(let n of e.querySelectorAll(`h1,h2,h3,h4,h5,h6`))t.push({id:b(),level:parseInt(n.tagName.substring(1),10),text:n.innerHTML,element:n});return t}o(),i();var an=5,G=90;function on({widgetsByParent:e}){let{mode:t,visible:n,mounted:i,togglePeek:a,toggleDocked:o,dock:s,close:c,dismiss:l}=Ct(`rightPaneVisible`),u=sn(i,e);return cn(t),E(`toggleRightPane`,o),E(`peekRightPane`,a),Et(t===`peek`,l,{keepOpenSelector:`#right-pane, .right-pane-peek-button`,focusSelector:`.right-pane-peek-button`}),w(r,{children:[w(Yt,{rightPaneVisible:n,onToggle:a}),w(`div`,{id:`right-pane-host`,class:g(t===`peek`&&`peek`,!n&&`hidden`),children:[w(`div`,{class:`right-pane-peek-spacer`}),w(`div`,{id:`right-pane`,class:n?`right-pane-mode-${t}`:void 0,children:[n&&w(`div`,{class:`right-pane-actions`,children:[t===`peek`&&w(I,{icon:`bx bx-pin`,text:S(`right_pane.dock`),onClick:s}),w(I,{icon:`bx bx-x`,text:S(`right_pane.close`),onClick:c})]}),i&&(u.length>0?u:w(at,{icon:`bx bx-sidebar`,text:S(`right_pane.empty_message`),children:t!==`peek`&&w(Qe,{text:S(`right_pane.empty_button`),triggerCommand:`toggleRightPane`})}))]})]})]})}function sn(e,t){let{note:r}=M(),i=T(r,`type`),a=T(r,`mime`),[o]=be(`highlightsList`),s=j(`chatHighlights`),[c]=we(`aiEnabled`),l=i===`file`&&a===`application/pdf`;if(!e)return[];let u=[{el:w(Xt,{}),enabled:i===`text`||i===`doc`||l||i===`llmChat`||!!r?.isMarkdown()},{el:w(Wt,{}),enabled:l},{el:w(zt,{}),enabled:l},{el:w(Vt,{}),enabled:l},{el:w(Lt,{}),enabled:l},{el:w(Ot,{}),enabled:i===`text`&&o.length>0},{el:w(Dt,{}),enabled:i===`llmChat`&&(s?.highlights.length??0)>0},{el:w(bt,{loader:()=>n(()=>import(`./SidebarChat-DQt3Do58.js`),__vite__mapDeps([35,13,2,14,15,16,3,4,5,6,7,8,17,18,19,20,21,22,23,10,24,27,26,28,36,37,38,39,40,41,42,43,44,45,46,29,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,1,9,11,31,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]),import.meta.url)}),enabled:i!==`llmChat`&&!fe&&c,position:1e3},...t.getLegacyWidgets(`right-pane`).map(e=>({el:w(ln,{originalWidget:e},e._noteId),enabled:!0,position:e.position})),...t.getPreactWidgets(`right-pane`).map(e=>{let t=e.render;return{el:w(t,{}),enabled:!0,position:e.position}})],d=10;for(let e of u)e.position||(e.position=d,d+=10);return u.filter(e=>e.enabled).toSorted((e,t)=>(e.position??10)-(t.position??10)).map(e=>e.el)}function cn(e){a(()=>{if(e===`closed`)return;let t=Math.min(G,Math.max(an,C.getInt(`rightPaneWidth`)??an)),n,r=e=>{e[1]>G&&n?.setSizes([100-G,G])},i=e=>C.save(`rightPaneWidth`,Math.round(e[1])),a=e===`docked`?[`#center-pane`,`#right-pane-host`]:[`.right-pane-peek-spacer`,`#right-pane`],o=e===`docked`?[300,180]:[0,180],s=()=>Ye(a,{sizes:[100-t,t],gutterSize:5,minSize:o,rtl:glob.isRtl,onDrag:r,onDragEnd:i}),c;return a.every(e=>document.querySelector(e))?n=s():c=requestAnimationFrame(()=>{c=void 0,a.every(e=>document.querySelector(e))&&(n=s())}),()=>{c!==void 0&&cancelAnimationFrame(c),n?.destroy()}},[e])}function ln({originalWidget:e}){let t=d(null);return w(B,{id:e._noteId,title:e.widgetTitle,containerRef:t,contextMenuItems:[{title:S(`right_pane.custom_widget_go_to_source`),uiIcon:`bx bx-code-curly`,handler:()=>m.tabManager.openInNewTab(e._noteId,null,!0)}],children:w(un,{originalWidget:e})})}function un({originalWidget:e}){let{noteContext:t}=M(),[n]=xe(()=>(e.contentSized(),e.doRender=function(){this.$widget=$(`<div>`),this.$body=this.$widget;let e=this.doRenderBody();typeof e==`object`&&`catch`in e?this.initialized=e.catch(e=>{this.logRenderingError(e)}):this.initialized=Promise.resolve()},e),{noteContext:t});return n}var dn=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.getSize=n()})(window,function(){function e(e){let t=parseFloat(e);return e.indexOf(`%`)==-1&&!isNaN(t)&&t}let t=[`paddingLeft`,`paddingRight`,`paddingTop`,`paddingBottom`,`marginLeft`,`marginRight`,`marginTop`,`marginBottom`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`borderBottomWidth`];t.length;function n(){let e={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0};return t.forEach(t=>{e[t]=0}),e}function r(r){if(typeof r==`string`&&(r=document.querySelector(r)),!(r&&typeof r==`object`&&r.nodeType))return;let i=getComputedStyle(r);if(i.display==`none`)return n();let a={};a.width=r.offsetWidth,a.height=r.offsetHeight;let o=a.isBorderBox=i.boxSizing==`border-box`;t.forEach(e=>{let t=i[e],n=parseFloat(t);a[e]=isNaN(n)?0:n});let s=a.paddingLeft+a.paddingRight,c=a.paddingTop+a.paddingBottom,l=a.marginLeft+a.marginRight,u=a.marginTop+a.marginBottom,d=a.borderLeftWidth+a.borderRightWidth,f=a.borderTopWidth+a.borderBottomWidth,p=e(i.width);p!==!1&&(a.width=p+(o?0:s+d));let m=e(i.height);return m!==!1&&(a.height=m+(o?0:c+f)),a.innerWidth=a.width-(s+d),a.innerHeight=a.height-(c+f),a.outerWidth=a.width+l,a.outerHeight=a.height+u,a}return r})})),fn=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.EvEmitter=n()})(typeof window<`u`?window:e,function(){function e(){}let t=e.prototype;return t.on=function(e,t){if(!e||!t)return this;let n=this._events=this._events||{},r=n[e]=n[e]||[];return r.includes(t)||r.push(t),this},t.once=function(e,t){if(!e||!t)return this;this.on(e,t);let n=this._onceEvents=this._onceEvents||{},r=n[e]=n[e]||{};return r[t]=!0,this},t.off=function(e,t){let n=this._events&&this._events[e];if(!n||!n.length)return this;let r=n.indexOf(t);return r!=-1&&n.splice(r,1),this},t.emitEvent=function(e,t){let n=this._events&&this._events[e];if(!n||!n.length)return this;n=n.slice(0),t||=[];let r=this._onceEvents&&this._onceEvents[e];for(let i of n)r&&r[i]&&(this.off(e,i),delete r[i]),i.apply(this,t);return this},t.allOff=function(){return delete this._events,delete this._onceEvents,this},e})})),pn=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n(e,fn()):e.Unidragger=n(e,e.EvEmitter)})(typeof window<`u`?window:e,function(e,t){function n(){}let r=n.prototype=Object.create(t.prototype);r.handleEvent=function(e){let t=`on`+e.type;this[t]&&this[t](e)};let i,a;`ontouchstart`in e?(i=`touchstart`,a=[`touchmove`,`touchend`,`touchcancel`]):e.PointerEvent?(i=`pointerdown`,a=[`pointermove`,`pointerup`,`pointercancel`]):(i=`mousedown`,a=[`mousemove`,`mouseup`]),r.touchActionValue=`none`,r.bindHandles=function(){this._bindHandles(`addEventListener`,this.touchActionValue)},r.unbindHandles=function(){this._bindHandles(`removeEventListener`,``)},r._bindHandles=function(t,n){this.handles.forEach(r=>{r[t](i,this),r[t](`click`,this),e.PointerEvent&&(r.style.touchAction=n)})},r.bindActivePointerEvents=function(){a.forEach(t=>{e.addEventListener(t,this)})},r.unbindActivePointerEvents=function(){a.forEach(t=>{e.removeEventListener(t,this)})},r.withPointer=function(e,t){t.pointerId===this.pointerIdentifier&&this[e](t,t)},r.withTouch=function(e,t){let n;for(let e of t.changedTouches)e.identifier===this.pointerIdentifier&&(n=e);n&&this[e](t,n)},r.onmousedown=function(e){this.pointerDown(e,e)},r.ontouchstart=function(e){this.pointerDown(e,e.changedTouches[0])},r.onpointerdown=function(e){this.pointerDown(e,e)};let o=[`TEXTAREA`,`INPUT`,`SELECT`,`OPTION`],s=[`radio`,`checkbox`,`button`,`submit`,`image`,`file`];return r.pointerDown=function(e,t){let n=o.includes(e.target.nodeName),r=s.includes(e.target.type),i=!n||r;!this.isPointerDown&&!e.button&&i&&(this.isPointerDown=!0,this.pointerIdentifier=t.pointerId===void 0?t.identifier:t.pointerId,this.pointerDownPointer={pageX:t.pageX,pageY:t.pageY},this.bindActivePointerEvents(),this.emitEvent(`pointerDown`,[e,t]))},r.onmousemove=function(e){this.pointerMove(e,e)},r.onpointermove=function(e){this.withPointer(`pointerMove`,e)},r.ontouchmove=function(e){this.withTouch(`pointerMove`,e)},r.pointerMove=function(e,t){let n={x:t.pageX-this.pointerDownPointer.pageX,y:t.pageY-this.pointerDownPointer.pageY};this.emitEvent(`pointerMove`,[e,t,n]),!this.isDragging&&this.hasDragStarted(n)&&this.dragStart(e,t),this.isDragging&&this.dragMove(e,t,n)},r.hasDragStarted=function(e){return Math.abs(e.x)>3||Math.abs(e.y)>3},r.dragStart=function(e,t){this.isDragging=!0,this.isPreventingClicks=!0,this.emitEvent(`dragStart`,[e,t])},r.dragMove=function(e,t,n){this.emitEvent(`dragMove`,[e,t,n])},r.onmouseup=function(e){this.pointerUp(e,e)},r.onpointerup=function(e){this.withPointer(`pointerUp`,e)},r.ontouchend=function(e){this.withTouch(`pointerUp`,e)},r.pointerUp=function(e,t){this.pointerDone(),this.emitEvent(`pointerUp`,[e,t]),this.isDragging?this.dragEnd(e,t):this.staticClick(e,t)},r.dragEnd=function(e,t){this.isDragging=!1,setTimeout(()=>delete this.isPreventingClicks),this.emitEvent(`dragEnd`,[e,t])},r.pointerDone=function(){this.isPointerDown=!1,delete this.pointerIdentifier,this.unbindActivePointerEvents(),this.emitEvent(`pointerDone`)},r.onpointercancel=function(e){this.withPointer(`pointerCancel`,e)},r.ontouchcancel=function(e){this.withTouch(`pointerCancel`,e)},r.pointerCancel=function(e,t){this.pointerDone(),this.emitEvent(`pointerCancel`,[e,t])},r.onclick=function(e){this.isPreventingClicks&&e.preventDefault()},r.staticClick=function(e,t){let n=e.type===`mouseup`;n&&this.isIgnoringMouseUp||(this.emitEvent(`staticClick`,[e,t]),n&&(this.isIgnoringMouseUp=!0,setTimeout(()=>{delete this.isIgnoringMouseUp},400)))},n})})),mn=e(t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n(e,dn(),pn()):e.Draggabilly=n(e,e.getSize,e.Unidragger)})(typeof window<`u`?window:e,function(e,t,n){function r(){}let i=e.jQuery;function a(e,t){this.element=typeof e==`string`?document.querySelector(e):e,i&&(this.$element=i(this.element)),this.options={},this.option(t),this._create()}let o=a.prototype=Object.create(n.prototype);o.option=function(e){this.options={...this.options,...e}};let s=[`relative`,`absolute`,`fixed`];o._create=function(){this.position={},this._getPosition(),this.startPoint={x:0,y:0},this.dragPoint={x:0,y:0},this.startPosition={...this.position};let e=getComputedStyle(this.element);s.includes(e.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()},o.setHandles=function(){let{handle:e}=this.options;typeof e==`string`?this.handles=this.element.querySelectorAll(e):typeof e==`object`&&e.length?this.handles=e:e instanceof HTMLElement?this.handles=[e]:this.handles=[this.element]};let c=[`dragStart`,`dragMove`,`dragEnd`],l=o.emitEvent;o.emitEvent=function(t,n){if(!this.isEnabled&&c.includes(t))return;l.call(this,t,n);let r=e.jQuery;if(!r||!this.$element)return;let i,a=n;n&&n[0]instanceof Event&&([i,...a]=n);let o=r.Event(i);o.type=t,this.$element.trigger(o,a)},o._getPosition=function(){let e=getComputedStyle(this.element),t=this._getPositionCoord(e.left,`width`),n=this._getPositionCoord(e.top,`height`);this.position.x=isNaN(t)?0:t,this.position.y=isNaN(n)?0:n,this._addTransformPosition(e)},o._getPositionCoord=function(e,n){if(e.includes(`%`)){let r=t(this.element.parentNode);return r?parseFloat(e)/100*r[n]:0}return parseInt(e,10)},o._addTransformPosition=function(e){let t=e.transform;if(!t.startsWith(`matrix`))return;let n=t.split(`,`),r=t.startsWith(`matrix3d`)?12:4,i=parseInt(n[r],10),a=parseInt(n[r+1],10);this.position.x+=i,this.position.y+=a},o.handlePointerDown=function(e,t){this.isEnabled&&(this.pointerDownPointer={pageX:t.pageX,pageY:t.pageY},e.preventDefault(),document.activeElement.blur(),this.bindActivePointerEvents(e),this.element.classList.add(`is-pointer-down`))},o.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())},o.measureContainment=function(){let e=this.getContainer();if(!e)return;let n=t(this.element),r=t(e),{borderLeftWidth:i,borderRightWidth:a,borderTopWidth:o,borderBottomWidth:s}=r,c=this.element.getBoundingClientRect(),l=e.getBoundingClientRect(),u=i+a,d=o+s,f=this.relativeStartPosition={x:c.left-(l.left+i),y:c.top-(l.top+o)};this.containSize={width:r.width-u-f.x-n.width,height:r.height-d-f.y-n.height}},o.getContainer=function(){let e=this.options.containment;if(e)return e instanceof HTMLElement?e:typeof e==`string`?document.querySelector(e):this.element.parentNode},o.handleDragMove=function(e,t,n){if(!this.isEnabled)return;let r=n.x,i=n.y,a=this.options.grid,o=a&&a[0],s=a&&a[1];r=u(r,o),i=u(i,s),r=this.containDrag(`x`,r,o),i=this.containDrag(`y`,i,s),r=this.options.axis==`y`?0:r,i=this.options.axis==`x`?0:i,this.position.x=this.startPosition.x+r,this.position.y=this.startPosition.y+i,this.dragPoint.x=r,this.dragPoint.y=i};function u(e,t,n){return t?(n||=`round`,Math[n](e/t)*t):e}o.containDrag=function(e,t,n){if(!this.options.containment)return t;let r=e==`x`?`width`:`height`,i=this.relativeStartPosition[e],a=u(-i,n,`ceil`),o=this.containSize[r];return o=u(o,n,`floor`),Math.max(a,Math.min(o,t))},o.handlePointerUp=function(){this.element.classList.remove(`is-pointer-down`)},o.handleDragEnd=function(){this.isEnabled&&(this.element.style.transform=``,this.setLeftTop(),this.element.classList.remove(`is-dragging`))},o.animate=function(){this.isDragging&&(this.positionDrag(),requestAnimationFrame(()=>this.animate()))},o.setLeftTop=function(){let{x:e,y:t}=this.position;this.element.style.left=`${e}px`,this.element.style.top=`${t}px`},o.positionDrag=function(){let{x:e,y:t}=this.dragPoint;this.element.style.transform=`translate3d(${e}px, ${t}px, 0)`},o.setPosition=function(e,t){this.position.x=e,this.position.y=t,this.setLeftTop()},o.enable=function(){this.isEnabled||(this.isEnabled=!0,this.bindHandles())},o.disable=function(){this.isEnabled&&(this.isEnabled=!1,this.isDragging&&this.dragEnd(),this.unbindHandles())};let d=[`transform`,`left`,`top`,`position`];return o.destroy=function(){this.disable(),d.forEach(e=>{this.element.style[e]=``}),this.unbindHandles(),this.$element&&this.$element.removeData(`draggabilly`)},o._init=r,i&&i.bridget&&i.bridget(`draggabilly`,a),a})}))()),K=` • `;function hn(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function gn(e,t,n={}){let r=e.map(e=>({text:e.title||t,active:e.active})),i=n.pinnedPrefix??``,a=r.length>1,o=r.map(e=>e.text).join(K),s=r.map(e=>{let t=hn(e.text);return e.active&&a?`<strong>${t}</strong>`:t}).join(K);return{segments:r,tooltip:`${i}${o}`,tooltipHtml:`${hn(i)}${s}`}}var _n=x.isDesktop(),vn=100,yn=240,bn=36,q=36,xn=_n?50:15,J=5,Sn=84,Cn=60,wn=48,Tn=`
<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-pin-indicator bx bx-pin" aria-label="${S(`tab_row.unpin_tab`)}"></div>
    <div class="note-tab-close bx bx-x" aria-label="${S(`tab_row.close_tab`)}"></div>
  </div>
</div>`,En=`<div class="tab-row-container-anchor"></div>`,Dn=`<div class="note-new-tab" data-trigger-command="openNewTab" aria-label="${S(`tab_row.add_new_tab`)}">+</div>`,On=`<div class="tab-row-filler"></div>`,kn=`
<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 ${q}px;
        height: ${q}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;
        min-width: ${xn}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-inline-start: 2px;
        padding-inline-end: 2px;
    }

    .tab-row-widget .note-tab .note-tab-title {
        flex: 1;
        vertical-align: top;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    /* In the active tab, dim every split segment except the focused one so it stands out. */
    .tab-row-widget .note-tab[active] .note-tab-segment:not(.note-tab-segment-active) {
        opacity: 0.55;
        font-weight: normal;
    }

    .tab-row-widget .note-tab .note-tab-icon {
        position: relative;
        padding-inline-end: 3px;
    }

    .tab-row-widget .note-tab[is-small] .note-tab-title {
        margin-inline-start: 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-row-widget .note-tab .note-tab-pin-indicator {
        display: none;
        flex: 0 0 22px;
        width: 22px;
        height: 22px;
        align-items: center;
        justify-content: center;
        text-align: center;
        /* purely a visual indicator: clicks fall through to the tab so it activates, never unpins */
        pointer-events: none;
    }

    .tab-row-widget .note-tab[pinned] .note-tab-pin-indicator {
        display: flex;
    }

    .tab-row-widget .note-tab[pinned] .note-tab-close {
        display: none;
    }

    .tab-scroll-button-left, .tab-scroll-button-right {
        display: none;
        flex: 0 0 ${bn}px;
        height: ${bn}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-inline-start: 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-inline-start: auto;
        margin-inline-end: 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>`,An=class extends f{isDragging;showNoteIcons;draggabillies;draggabillyDragging;$style;$tabScrollingContainer;$tabContainer;$scrollButtonLeft;$scrollButtonRight;$containerAnchor;$filler;$newTab;updateScrollTimeout;newTabOuterWidth=0;scrollButtonsOuterWidth=0;tabUpdateId=0;doRender(){this.$widget=$(kn),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`);let e=window.getComputedStyle(document.documentElement);this.showNoteIcons=e.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();let t=$(e.target).closest(`.note-tab`).attr(`data-ntx-id`),n=m.tabManager.getMainNoteContexts().find(e=>e.ntxId===t),r=!!n?.pinned,i=!n||n.isEmpty();_.show({x:e.pageX,y:e.pageY,items:[r?{title:S(`tab_row.unpin_tab`),command:`unpinTab`,uiIcon:`bx bx-pin`}:{title:S(`tab_row.pin_tab`),command:`pinTab`,uiIcon:`bx bx-pin`,enabled:!i},{kind:`separator`},{title:S(`tab_row.close`),command:`closeTab`,uiIcon:`bx bx-x`,enabled:!r},{title:S(`tab_row.close_other_tabs`),command:`closeOtherTabs`,uiIcon:`bx bx-empty`,enabled:m.tabManager.noteContexts.length!==1},{title:S(`tab_row.close_right_tabs`),command:`closeRightTabs`,uiIcon:`bx bx-empty`,enabled:m.tabManager.noteContexts?.at(-1)?.ntxId!==t},{title:S(`tab_row.close_all_tabs`),command:`closeAllTabs`,uiIcon:`bx bx-empty`},{kind:`separator`},{title:S(`tab_row.reopen_last_tab`),command:`reopenLastTab`,uiIcon:`bx bx-undo`,enabled:m.tabManager.recentlyClosedTabs.length!==0},{kind:`separator`},{title:S(`tab_row.move_tab_to_new_window`),command:`moveTabToNewWindow`,uiIcon:`bx bx-window-open`,enabled:!r},{title:S(`tab_row.copy_tab_to_new_window`),command:`copyTabToNewWindow`,uiIcon:`bx bx-empty`}],selectMenuItemHandler:({command:e})=>{e&&this.triggerCommand(e,{ntxId:t})}})})}setupStyle(){this.$style=$(`<style>`),this.$widget.append(this.$style)}scrollTabContainer(e,t=`smooth`){this.$tabScrollingContainer[0].scrollBy({left:e,behavior:t})}setupScrollEvents(){te(this.$tabScrollingContainer),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(){let e=this.$tabScrollingContainer[0].scrollLeft,t=this.$tabScrollingContainer[0].scrollWidth,n=this.$tabScrollingContainer[0].clientWidth;this.$scrollButtonLeft.toggleClass(`disabled`,Math.abs(e)<=1),this.$scrollButtonRight.toggleClass(`disabled`,Math.abs(e+n-t)<=1)}setScrollButtonVisibility(e=!0){e?(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(e=>{this.cleanUpPreviouslyDraggedTabs(),this.layoutTabs()}).observe(this.$widget[0]),this.tabEls.forEach(e=>this.setTabCloseEvent(e))}setVisibility(){this.$widget.show()}getTabTooltips(e){return[`.note-tab-drag-handle`,`.note-tab-close`].map(t=>e.querySelector(t)).map(e=>e?v.getInstance(e):null).filter(e=>!!e)}setTooltipsEnabled(e){for(let t of this.tabEls)for(let n of this.getTabTooltips(t))e?n.enable():(n.hide(),n.disable())}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(){let e=this.tabEls.length;this.updateOuterWidth();let t=Math.floor((this.$widget.width()??0)-this.newTabOuterWidth-xn);105*e>t?(t-=this.scrollButtonsOuterWidth,this.setScrollButtonVisibility(!0)):this.setScrollButtonVisibility(!1);let n=(e-1)*J,r=(t-n)/e,i=Math.floor(Math.max(vn,Math.min(yn,r))),a=i*e+n,o=t-a,s=[],c=o;for(let t=0;t<e;t+=1){let e=+(i<yn&&c>=1);s.push(i+e),c>=1&&--c}return s}getTabPositions(){let e=[],t=0;this.tabWidths.forEach(n=>{e.push(t),t+=n+J}),t-=J;let n=t;return glob.isRtl&&e.reverse(),{tabPositions:e,anchorPosition:n}}layoutTabs(){let e=this.tabWidths;this.tabEls.forEach((t,n)=>{let r=e[n];t.style.width=`${r}px`,t.removeAttribute(`is-small`),t.removeAttribute(`is-smaller`),t.removeAttribute(`is-mini`),r<Sn&&t.setAttribute(`is-small`,``),r<Cn&&t.setAttribute(`is-smaller`,``),r<wn&&t.setAttribute(`is-mini`,``)});let t=``,{tabPositions:n,anchorPosition:r}=this.getTabPositions();n.forEach((e,n)=>{t+=`.note-tab:nth-child(${n+1}) { transform: translate3d(${e}px, 0, 0)} `}),t+=`.tab-row-container-anchor { transform: translate3d(${r}px, 0, 0) } `,t+=`.tab-row-widget-container {width: ${r}px}`,this.$style.html(t)}addTab(e){let t=$(Tn).attr(`data-ntx-id`,e);re.updateDisplayedShortcuts(t),t.addClass(`note-tab-was-just-added`),setTimeout(()=>t.removeClass(`note-tab-was-just-added`),500),this.$containerAnchor.before(t);let n=m.tabManager.getMainNoteContexts();n[n.length-1]?.ntxId!==e&&this.syncTabOrder(),this.setVisibility(),this.setTabCloseEvent(t),this.updateTitle(t,S(`tab_row.new_tab`)),new v(t.find(`.note-tab-drag-handle`)[0],{html:!0,title:()=>t.attr(`data-tab-title`)||``,trigger:`hover`,placement:`bottom`,container:`body`,delay:{show:500,hide:0}}),new v(t.find(`.note-tab-close`)[0],{title:S(`tab_row.close_tab`),trigger:`hover`,placement:`bottom`,container:`body`,delay:{show:500,hide:0}}),this.cleanUpPreviouslyDraggedTabs(),this.layoutTabs(),this.setupDraggabilly()}closeActiveTabCommand({$el:e}){let t=e.closest(`.note-tab`).attr(`data-ntx-id`);m.tabManager.removeNoteContext(t??null)}setTabCloseEvent(e){e.on(`mousedown`,t=>{if(t.which===2)return m.tabManager.removeNoteContext(e.attr(`data-ntx-id`)??null),!0}),e.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 e=m.tabManager.getActiveContext();if(!e)return;e.mainNtxId&&(e=m.tabManager.getNoteContextById(e.mainNtxId));let t=this.getTabById(e.ntxId)[0],n=this.activeTabEl;n!==t&&(n&&(n.removeAttribute(`active`),this.refreshTab(n.getAttribute(`data-ntx-id`))),t&&t.setAttribute(`active`,``)),this.refreshTab(e.ntxId)}newNoteContextCreatedEvent({noteContext:e}){!e.mainNtxId&&e.ntxId&&this.addTab(e.ntxId)}removeTab(e){let t=this.getTabById(e)[0];if(t){for(let e of this.getTabTooltips(t))e.dispose();t.parentNode?.removeChild(t),this.cleanUpPreviouslyDraggedTabs(),this.layoutTabs(),this.setupDraggabilly(),this.setVisibility()}}getNtxIdsInOrder(){return this.tabEls.map(e=>e.getAttribute(`data-ntx-id`))}updateTitle(e,t){e.attr(`data-tab-title`,t),e.find(`.note-tab-title`).text(t)}getTabById(e){return this.$widget.find(`[data-ntx-id='${e}']`)}getTabId(e){return e.attr(`data-ntx-id`)}noteContextRemovedEvent({ntxIds:e}){for(let t of e)this.removeTab(t);this.refreshAllTabs()}cleanUpPreviouslyDraggedTabs(){this.tabEls.forEach(e=>e.classList.remove(`note-tab-was-just-dragged`))}setupDraggabilly(){let e=this.tabEls,{tabPositions:t}=this.getTabPositions(),n=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(e=>e.destroy()),e.forEach((e,r)=>{let i=t[r],a=new mn.default(e,{axis:`x`,handle:`.note-tab-drag-handle`,containment:this.$tabContainer[0]});this.draggabillies.push(a),a.on(`staticClick`,()=>{m.tabManager.activateTabContext(e.getAttribute(`data-ntx-id`))}),a.on(`dragStart`,()=>{this.isDragging=!0,this.draggabillyDragging=a,e.classList.add(`note-tab-is-dragging`),this.$widget.addClass(`tab-row-widget-is-sorting`),this.setTooltipsEnabled(!1),n=this.$tabScrollingContainer?.scrollLeft()??0,a.positionDrag=()=>{}}),a.on(`dragEnd`,()=>{this.isDragging=!1,this.setTooltipsEnabled(!0);let t=(this.$tabScrollingContainer?.scrollLeft()??0)-n,r=parseFloat(e.style.left)+t,i=this.$tabContainer[0]?.offsetWidth-e.offsetWidth,a=Math.min(i,Math.max(0,r));e.style.transform=`translate3d(0, 0, 0)`,requestAnimationFrame(t=>{e.style.left=`0`,e.style.transform=`translate3d(${a}px, 0, 0)`,requestAnimationFrame(t=>{e.classList.remove(`note-tab-is-dragging`),this.$widget.removeClass(`tab-row-widget-is-sorting`),e.classList.add(`note-tab-was-just-dragged`),requestAnimationFrame(t=>{e.style.transform=``,this.layoutTabs(),this.setupDraggabilly()})})})}),a.on(`dragMove`,(r,a,o)=>{let s=this.tabEls,c=s.indexOf(e),l=this.$tabScrollingContainer[0]?.getBoundingClientRect(),u=a.pageX;u<l.left?this.scrollTabContainer(-105):u>l.right&&this.scrollTabContainer(105);let d=(this.$tabScrollingContainer?.scrollLeft()??0)-n,f=o.x+d,m=this.$tabContainer[0]?.offsetWidth-e.offsetWidth-i,h=-i;f=Math.min(m,Math.max(h,f)),e.style.transform=`translate3d(${f}px, 0, 0)`;let ee=i+f,g=this.closest(ee,t),te=s.filter(e=>e.hasAttribute(`pinned`)).length,_=p(g,e.hasAttribute(`pinned`),te,s.length);c!==_&&this.animateTabMove(e,c,_),Math.abs(o.y)>100&&!e.hasAttribute(`pinned`)&&this.triggerCommand(`moveTabToNewWindow`,{ntxId:this.getTabId($(e))})})})}animateTabMove(e,t,n){if(n<t)e.parentNode?.insertBefore(e,this.tabEls[n]);else{let t=this.tabEls[n+1]||this.$containerAnchor[0];e.parentNode?.insertBefore(e,t)}this.triggerEvent(`tabReorder`,{ntxIdsInOrder:this.getNtxIdsInOrder()}),this.layoutTabs()}setupNewButton(){this.$newTab=$(Dn),this.$widget.append(this.$newTab),new v(this.$newTab[0],{title:S(`tab_row.add_new_tab`),trigger:`hover`,placement:`bottom`,container:`body`,delay:{show:500,hide:0}})}setupFiller(){this.$filler=$(On),this.$widget.append(this.$filler)}setupContainerAnchor(){this.$containerAnchor=$(En),this.$tabContainer.append(this.$containerAnchor)}closest(e,t){let n=1/0,r=-1;return t.forEach((t,i)=>{Math.abs(e-t)<n&&(n=Math.abs(e-t),r=i)}),r}noteSwitchedAndActivatedEvent({noteContext:e}){this.activeContextChangedEvent(),this.updateTabById(e.mainNtxId||e.ntxId)}noteSwitchedEvent({noteContext:e}){this.updateTabById(e.mainNtxId||e.ntxId)}noteContextReorderEvent({oldMainNtxId:e,newMainNtxId:t}){e&&t&&this.getTabById(e).attr(`data-ntx-id`,t),this.refreshAllTabs()}contextsReopenedEvent({mainNtxId:e,tabPosition:t}){if(!e||t<0)return;let n=this.getTabById(e)[0];n&&n.parentNode&&n.parentNode.insertBefore(n,this.tabEls[t]),this.refreshTab(e)}updateTabById(e){let t=this.getTabById(e);t[0].scrollIntoView({behavior:`smooth`});let n=m.tabManager.getNoteContextById(e);this.updateTab(t,n)}async updateTab(e,t){if(!e.length)return;let n=t.getMainContext();e.attr(`pinned`,n.pinned?``:null);for(let t of Array.from(e[0].classList))t!==`note-tab`&&e.removeClass(t);let r=``,i=h.getNoteFromCache(n.hoistedNoteId);i?(e.find(`.note-tab-wrapper`).css(`--workspace-tab-background-color`,i.getWorkspaceTabBackgroundColor()),this.showNoteIcons||(r=i.getWorkspaceIconClass())):e.find(`.note-tab-wrapper`).removeAttr(`style`);let a=++this.tabUpdateId;e.data(`update-id`,a);let o=n.getSubContexts(),s=this.getFocusedNtxId(n,o);if(await this.updateTabTitle(e,o,s,n.pinned,a),e.data(`update-id`)!==a)return;let c=(o.find(e=>e.ntxId===s)??n).note;c&&(e.addClass(c.getCssClass()),e.addClass(x.getNoteTypeClass(c.type)),e.addClass(x.getMimeTypeClass(c.mime)),this.showNoteIcons&&(r=c.getIcon())),r&&e.find(`.note-tab-icon`).removeClass().addClass(`note-tab-icon`).addClass(r)}async updateTabTitle(e,t,n,r,i){let a=await Promise.all(t.map(async e=>({title:e.note?await e.getNavigationTitle():null,active:!!e.ntxId&&e.ntxId===n})));if(i!==void 0&&e.data(`update-id`)!==i)return;let{segments:o,tooltipHtml:s}=gn(a,S(`tab_row.new_tab`),{pinnedPrefix:r?S(`tab_row.pinned_prefix`):void 0});e.attr(`data-tab-title`,s);let c=e.find(`.note-tab-title`).empty();o.forEach((e,t)=>{t>0&&c.append(document.createTextNode(K));let n=$(`<span>`).addClass(`note-tab-segment`).text(e.text);e.active&&n.addClass(`note-tab-segment-active`),c.append(n)})}getFocusedNtxId(e,t){let n=e.lastActiveNtxId;return n&&t.some(e=>e.ntxId===n)?n:e.ntxId}refreshTab(e){if(!e)return;let t=this.getTabById(e),n=m.tabManager.noteContexts.find(t=>t.ntxId===e);t.length&&n&&this.updateTab(t,n)}refreshAllTabs(){for(let e of m.tabManager.getMainNoteContexts())this.refreshTab(e.ntxId)}async entitiesReloadedEvent({loadResults:e}){let t=new Set;for(let n of m.tabManager.noteContexts)if(n.noteId&&(e.isNoteReloaded(n.noteId)||e.getAttributeRows().find(e=>[`workspace`,`iconClass`,`workspaceIconClass`,`workspaceTabBackgroundColor`].includes(e.name||``)&&A.isAffecting(e,n.note)))){let e=n.mainNtxId||n.ntxId;e&&t.add(e)}for(let e of t)this.refreshTab(e)}frocaReloadedEvent(){for(let e of m.tabManager.noteContexts){let t=this.getTabById(e.ntxId);this.updateTab(t,e)}}hoistedNoteChangedEvent({ntxId:e}){let t=this.getTabById(e);if(t&&e){let n=m.tabManager.getNoteContextById(e);this.updateTab(t,n)}}tabPinStateChangedEvent({ntxId:e,pinned:t}){let n=this.getTabById(e);n.length&&(n.attr(`pinned`,t?``:null),this.syncTabOrder(),this.layoutTabs(),this.setupDraggabilly())}syncTabOrder(){for(let e of m.tabManager.getMainNoteContexts()){let t=this.getTabById(e.ntxId)[0];t&&this.$containerAnchor.before(t)}}};o();function jn(){let e=me()&&window.electronApi,t=e?Le():void 0,{canGoBack:n,canGoForward:r}=Mn(e),i=O(`_lbBackInHistory`),a=O(`_lbForwardInHistory`);return w(`div`,{className:`tab-history-navigation-buttons`,children:[!i&&w(I,{icon:`bx bx-left-arrow-alt`,text:S(`tab_history_navigation_buttons.go-back`),triggerCommand:`backInNoteHistory`,onContextMenu:t,disabled:!n}),!a&&w(I,{icon:`bx bx-right-arrow-alt`,text:S(`tab_history_navigation_buttons.go-forward`),triggerCommand:`forwardInNoteHistory`,onContextMenu:t,disabled:!r})]})}function Mn(e){let[t,n]=u(()=>e?window.electronApi?.navigation.navigationCanGoBack()??!0:!0),[r,i]=u(()=>e?window.electronApi?.navigation.navigationCanGoForward()??!0:!0);return l(()=>{let e=window.electronApi?.navigation;if(!e)return;let t=()=>{n(e.navigationCanGoBack()),i(e.navigationCanGoForward())};return e.onDidNavigate(t),e.onDidNavigateInPage(t),()=>{e.removeDidNavigateListeners()}},[e]),{canGoBack:t,canGoForward:r}}i();function Nn(){let[e]=Ce(`nativeTitleBarVisible`);return w(`div`,{className:`title-bar-buttons`,children:me()&&e&&w(r,{children:[w(Y,{className:`minimize-btn`,icon:`bx bx-minus`,onClick:()=>window.electronApi?.window.minimizeWindow()}),w(Y,{className:`maximize-btn`,icon:`bx bx-checkbox`,onClick:()=>{let e=window.electronApi?.window;e&&(e.isMaximized()?e.unmaximizeWindow():e.maximizeWindow())}}),w(Y,{className:`close-btn`,icon:`bx bx-x`,onClick:()=>window.electronApi?.window.closeWindow()})]})})}function Y({className:e,icon:t,onClick:n}){return w(`div`,{className:e,children:w(`button`,{className:`btn ${t}`,onClick:n})})}var Pn={USE_PROFILES:{html:!0,mathMl:!0},FORBID_TAGS:`script.style.iframe.object.embed.link.meta.base.noscript.template.form.input.textarea.button.select.option.div.p.h1.h2.h3.h4.h5.h6.blockquote.pre.section.article.aside.nav.header.footer.main.figure.figcaption.table.thead.tbody.tfoot.tr.th.td.ul.ol.li.dl.dt.dd.hr.img.video.audio.picture.canvas.svg.foreignObject`.split(`.`),FORBID_ATTR:[`onerror`,`onload`,`onclick`,`onmouseover`,`onfocus`,`onblur`,`onsubmit`,`onreset`,`onchange`,`oninput`,`onkeydown`,`onkeyup`,`onkeypress`],RETURN_DOM:!1,RETURN_DOM_FRAGMENT:!1},Fn=`<div class="toc-widget">
    <style>
        .toc-widget {
            padding: 10px;
            contain: none;
            overflow: auto;
            position: relative;
            padding-inline-start:0px !important;
        }

        .toc ol {
            position: relative;
            overflow: hidden;
            padding-inline-start: 0px;
            transition: max-height 0.3s ease;
        }

        .toc li.collapsed + ol {
            display:none;
        }

        .toc li + ol:before {
            content: "";
            position: absolute;
            height: 100%;
            border-inline-start: 1px solid var(--main-border-color);
            z-index: 10;
        }

        .toc li {
            display: flex;
            position: relative;
            list-style: none;
            align-items: center;
            padding-inline-start: 7px;
            cursor: pointer;
            text-align: justify;
            word-wrap: break-word;
            hyphens: auto;
        }

        .toc > ol {
            --toc-depth-level: 1;
        }
        .toc > ol > ol {
            --toc-depth-level: 2;
        }
        .toc > ol > ol > ol {
            --toc-depth-level: 3;
        }
        .toc > ol > ol > ol > ol {
            --toc-depth-level: 4;
        }
        .toc > ol > ol > ol > ol > ol {
            --toc-depth-level: 5;
        }

        .toc > ol ol::before {
            inset-inline-start: calc((var(--toc-depth-level) - 2) * 20px + 14px);
        }

        .toc li {
            padding-inline-start: calc((var(--toc-depth-level) - 1) * 20px + 4px);
        }

        .toc li .collapse-button {
            display: flex;
            position: relative;
            width: 21px;
            height: 21px;
            flex-shrink: 0;
            align-items: center;
            justify-content: center;
            transition: transform 0.3s ease;
        }

        .toc li.collapsed .collapse-button {
            transform: rotate(-90deg);
        }

        .toc li .item-content {
            margin-inline-start: 25px;
            flex: 1;
        }

        .toc li .collapse-button + .item-content {
            margin-inline-start: 4px;
        }

        .toc li:hover {
            font-weight: bold;
        }
    </style>

    <span class="toc"></span>
</div>`,In=class extends nt{$toc;tocLabelValue;get widgetTitle(){return S(`toc.table_of_contents`)}get widgetButtons(){return[new V().icon(`bx-cog`).title(S(`toc.options`)).titlePlacement(`left`).onClick(()=>m.tabManager.openContextWithNote(`_optionsTextNotes`,{activate:!0})).class(`icon-action`),new V().icon(`bx-x`).titlePlacement(`left`).onClick(e=>e.triggerCommand(`closeToc`)).class(`icon-action`)]}isEnabled(){if(!super.isEnabled()||!this.note)return!1;let e=this.note.type===`doc`&&this.note.noteId.startsWith(`_help`);return(this.note.type===`text`||e)&&!this.noteContext?.viewScope?.tocTemporarilyHidden&&this.noteContext?.viewScope?.viewMode==="default"}async doRenderBody(){this.$body.empty().append($(Fn)),this.$toc=this.$body.find(`.toc`)}async refreshWithNote(e){if(this.toggleInt(!!this.noteContext?.viewScope?.tocPreviousVisible),this.tocLabelValue=e.getLabelValue(`toc`),this.tocLabelValue===`hide`){this.toggleInt(!1),this.triggerCommand(`reEvaluateRightPaneVisibility`);return}if(!(!this.note||!this.noteContext?.viewScope)){if(this.note.type===`text`){let t=await e.getBlob();if(t){let e=await this.getToc(t.content);this.#e(e)}return}this.note.type===`doc`&&setTimeout(async()=>{let e=await this.noteContext?.getContentElement();if(e){let t=e.html(),n=await this.getToc(t);this.#e(n)}else console.warn(`Unable to get content element for doctype`)},250)}}#e({$toc:e,headingCount:t}){this.$toc.empty(),e&&this.$toc.append(e);let n=this.tocLabelValue,r=n===``||n===`show`||t>=(C.getInt(`minTocHeadings`)??0);this.toggleInt(r),this.noteContext?.viewScope&&(this.noteContext.viewScope.tocPreviousVisible=r),this.triggerCommand(`reEvaluateRightPaneVisibility`)}async replaceMathTextWithKatax(e){var t=[...e.matchAll(/<span class="math-tex">\\\(([\s\S]*?)\\\)<\/span>/g)];let r=e;if(t.length>0){let{default:e}=await n(async()=>{let{default:e}=await import(`./math-BdsX7GJL.js`);return{default:e}},__vite__mapDeps([81,60,61]),import.meta.url);for(let n of t){let t=n[1],i;try{i=e.renderToString(t,{throwOnError:!1})}catch(e){console.error(`KaTeX rendering error:`,e),i=n[0]}r=r.replace(n[0],i)}}return r}async getToc(e){let t=/<h(\d+)[^>]*>(.*?)<\/h\1>/gi,n=$(`<ol>`),r=2,i=[n],a;this.noteContext?.viewScope?.tocCollapsedHeadings instanceof Set||(this.noteContext.viewScope.tocCollapsedHeadings=new Set);let o=this.noteContext.viewScope.tocCollapsedHeadings,s=new Set,c=0;for(let n=null,l=0;(n=t.exec(e))!==null;l++){let e=parseInt(n[1]),t=e-r;if(t>0)for(let n=0;n<t;n++){let t=$(`<ol>`);if(i[i.length-1].append(t),i.push(t),a){let n=`h${e}_${l}_${a?.text().trim()}`;this.setupCollapsibleHeading(t,a,n,o,s)}}else if(t<0)for(let e=0;e<-t&&i.length>1;++e)i.pop();r=e;let u=await this.replaceMathTextWithKatax(n[2]),d=$(`<div class="item-content">`).html(y.sanitize(u,Pn)),f=$(`<li>`).append(d).on(`click`,()=>this.jumpToHeading(l));i[i.length-1].append(f),c=l,a=f}for(let e of o)s.has(e)||o.delete(e);return n=this.pullLeft(n),{$toc:n,headingCount:c}}pullLeft(e){for(;e.children().length===1;){let t=e.children(`:first`);if(t[0].tagName.toLowerCase()!==`ol`)break;e=t}return e}async jumpToHeading(e){if(!this.note||!this.noteContext)return;let t=this.note.type===`doc`,n=await this.noteContext.isReadOnly(),r=null;if(n||t)r=await this.noteContext.getContentElement();else{let e=await this.noteContext.getTextEditor();e?.sourceElement&&(r=$(e.sourceElement))}(r?.find(`:header:not(section.include-note :header)`)?.[e])?.scrollIntoView({behavior:`smooth`})}async setupCollapsibleHeading(e,t,n,r,i){if(t&&t.find(`.collapse-button`).length===0){let a=$(`<div class="collapse-button bx bx-chevron-down"></div>`);t.prepend(a),r?.has(n)?(t.addClass(`collapsed`),i.add(n)):t.removeClass(`collapsed`),a.on(`click`,i=>{if(i.stopPropagation(),t.hasClass(`animating`))return;let o=!t.hasClass(`collapsed`);t.addClass(`animating`),o?(e.css(`maxHeight`,`${e.prop(`scrollHeight`)}px`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.css(`maxHeight`,`0px`),a.css(`transform`,`rotate(-90deg)`)})}),setTimeout(()=>{e.css(`maxHeight`,``),t.addClass(`collapsed`),t.removeClass(`animating`)},300)):(t.removeClass(`collapsed`),e.css(`maxHeight`,`0px`),requestAnimationFrame(()=>{e.css(`maxHeight`,`${e.prop(`scrollHeight`)}px`),a.css(`transform`,``)}),setTimeout(()=>{e.css(`maxHeight`,``),t.removeClass(`animating`)},300)),o?r.add(n):r.delete(n)})}}async closeTocCommand(){this.noteContext?.viewScope&&(this.noteContext.viewScope.tocTemporarilyHidden=!0),await this.refresh(),this.triggerCommand(`reEvaluateRightPaneVisibility`),m.triggerEvent(`reEvaluateTocWidgetVisibility`,{noteId:this.noteId})}async showTocWidgetEvent({noteId:e}){this.noteId===e&&(await this.refresh(),this.triggerCommand(`reEvaluateRightPaneVisibility`),m.triggerEvent(`reEvaluateTocWidgetVisibility`,{noteId:this.noteId}))}async entitiesReloadedEvent({loadResults:e}){(this.noteId&&e.isNoteContentReloaded(this.noteId)||e.getAttributeRows().find(e=>e.type===`label`&&((e.name??``).toLowerCase().includes(`readonly`)||e.name===`toc`)&&A.isAffecting(e,this.note)))&&await this.refresh()}},X={notes:{},attachments:{}};function Z(e){if(e!==`notes`&&e!==`attachments`)throw Error(`Unrecognized type '${e}', should be 'notes' or 'attachments'`)}function Ln(e,t){return Z(e),X[e][t]}function Rn(e,t){Z(e),delete X[e][t]}function zn(e,t){Z(e),delete X[e][t]}ne.subscribeToMessages(async e=>{e.type===`openedFileUpdated`&&(Z(e.entityType),X[e.entityType][e.entityId]=e,m.triggerEvent(`openedFileUpdated`,{entityType:e.entityType,entityId:e.entityId,lastModifiedMs:e.lastModifiedMs,filePath:e.filePath}))});var Q={getFileModificationStatus:Ln,fileModificationUploaded:Rn,ignoreModification:zn},Bn=`
<div class="dropdown watched-file-update-status-widget alert alert-warning">
    <style>
        .watched-file-update-status-widget {
            margin: 10px;
            contain: none;
        }
    </style>

    <p>${S(`watched_file_update_status.file_last_modified`)}</p>

    <div style="display: flex; flex-direction: row; justify-content: flex-start; gap: 8px;">
        <button class="btn btn-sm file-upload-button">${S(`watched_file_update_status.upload_modified_file`)}</button>

        <button class="btn btn-sm ignore-this-change-button">${S(`watched_file_update_status.ignore_this_change`)}</button>
    </div>
</div>`,Vn=class extends N{$filePath;$fileLastModified;$fileUploadButton;$ignoreThisChangeButton;isEnabled(){let{entityType:e,entityId:t}=this.getEntity();return super.isEnabled()&&!!e&&!!t&&!!Q.getFileModificationStatus(e,t)}doRender(){this.$widget=$(Bn),this.$filePath=this.$widget.find(`.file-path`),this.$fileLastModified=this.$widget.find(`.file-last-modified`),this.$fileUploadButton=this.$widget.find(`.file-upload-button`),this.$fileUploadButton.on(`click`,async()=>{let{entityType:e,entityId:t}=this.getEntity();await ve.post(`${e}/${t}/upload-modified-file`,{filePath:this.$filePath.text()}),e&&t&&Q.fileModificationUploaded(e,t),this.refresh()}),this.$ignoreThisChangeButton=this.$widget.find(`.ignore-this-change-button`),this.$ignoreThisChangeButton.on(`click`,()=>{let{entityType:e,entityId:t}=this.getEntity();e&&t&&Q.ignoreModification(e,t),this.refresh()})}async refreshWithNote(e){let{entityType:t,entityId:n}=this.getEntity();if(!t||!n)return;let r=Q.getFileModificationStatus(t,n);this.$filePath.text(r.filePath),r.lastModifiedMs&&this.$fileLastModified.text(ie.default.unix(r.lastModifiedMs/1e3).format(`HH:mm:ss`))}getEntity(){if(!this.noteContext)return{};let{viewScope:e}=this.noteContext;return e?.viewMode===`attachments`&&e.attachmentId?{entityType:`attachments`,entityId:e.attachmentId}:{entityType:`notes`,entityId:this.noteId}}openedFileUpdatedEvent(e){console.log(e);let{entityType:t,entityId:n}=this.getEntity();e.entityType===t&&e.entityId===n&&this.refresh()}},Hn=class{customWidgets;constructor(e){this.customWidgets=e}getRootWidget(e){e.noteTreeWidget=new ot;let t=C.get(`layoutOrientation`)===`horizontal`,r=this.#e(t),i=x.isElectron(),a=window.glob.platform===`darwin`,o=window.glob.hasNativeTitleBar,s=t||i&&!o&&a,c=!o&&x.isLinux(),l=Ee(`new-layout`),u=new Re(!0).setParent(e).class(`${t?`horizontal`:`vertical`}-layout`).optChild(s,new R(`row`).class(`tab-row-container`).child(new R(`row`).id(`tab-row-left-spacer`)).optChild(t,w(lt,{isHorizontalLayout:!0})).child(w(jn,{})).child(new An().class(`full-width`)).optChild(l,w(ut,{})).optChild(c,w(Nn,{})).css(`height`,`40px`).css(`background-color`,`var(--launcher-pane-background-color)`).setParent(e)).optChild(t,r).child(new R(`row`).css(`flex-grow`,`1`).id(`horizontal-main-container`).optChild(!t,r).child(new ft().optChild(!t,new Ie).child(e.noteTreeWidget).child(...this.customWidgets.get(`left-pane`))).child(new R(`column`).id(`rest-pane`).css(`flex-grow`,`1`).optChild(!s,new R(`row`).class(`tab-row-container`).child(w(jn,{})).child(new An).optChild(l,w(ut,{})).optChild(c,w(Nn,{})).css(`height`,`40px`).css(`align-items`,`center`)).optChild(l,w(et,{})).child(new R(`row`).filling().collapsible().id(`vertical-main-container`).child(new R(`column`).filling().collapsible().id(`center-pane`).child(new Ve(()=>new Oe().child(new R(`row`).class(`title-row note-split-title`).cssBlock(`.title-row > * { margin: 5px; }`).child(w(se,{})).child(w(de,{})).optChild(l,w(oe,{})).child(w(qe,{baseSize:0,growthFactor:1})).optChild(!l,w(L,{direction:`left`})).optChild(!l,w(L,{direction:`right`})).optChild(!l,w(Ae,{})).optChild(!l,w(De,{})).optChild(l,w(ke,{}))).optChild(!l,w(bt,{loader:()=>n(()=>import(`./Ribbon-gcCvgg7Y.js`),__vite__mapDeps([82,13,2,14,15,16,3,4,5,6,7,8,17,18,19,20,21,22,23,10,24,27,26,28,36,83,84,37,38,42,59,70,85,86,29,87,39,40,41,43,47,48,88,66,67,55,89,90,91,92,93,94,73,74,95,96,97,98,99,100,44,30,101,102,103,104,105,106,51,107,108,109,49,50,110,111,112,113,114,115,116,117,118,119,120]),import.meta.url)})).child(new Vn).optChild(!l,w(ce,{items:$e})).child(new ze().filling().optChild(l,w(Fe,{})).optChild(l,w(Ge,{})).optChild(!l,new dt().child(w(le,{})).child(w(ue,{}))).optChild(!l,w(ae,{})).child(w(it,{})).child(w(ye,{media:`screen`})).child(w(He,{})).child(w(We,{}))).child(w(ct,{})).child(new Ue).child(...this.customWidgets.get(`note-detail-pane`)))).child(...this.customWidgets.get(`center-pane`))).optChild(!l,new pt().child(new In).child(new yt).child(...this.customWidgets.get(`right-pane`))).optChild(l,w(on,{widgetsByParent:this.customWidgets}))).optChild(!t&&l,w(Pe,{})))).optChild(t&&l,w(Pe,{})).child(w(Ne,{})).child(w(mt,{}));return Ke(u),u}#e(e){let t;return t=e?new R(`row`).css(`height`,`53px`).class(`horizontal`).child(w(Be,{isHorizontalLayout:!0})).child(w(Me,{isHorizontalLayout:!0})):new R(`column`).css(`width`,`53px`).class(`vertical`).child(w(Me,{isHorizontalLayout:!1})).child(w(Be,{isHorizontalLayout:!1})).child(w(lt,{isHorizontalLayout:!1})),t.id(`launcher-pane`),t}};export{Hn as default};