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=$("
"),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=`
`;class xb extends ge{doRender(){this.$widget=$(_b)}updateVersionStatus(t){this.$widget.toggle(ct.isUpdateAvailable(t,glob.triliumVersion))}}const kb=` `;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($(` `)),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=`
`,Vb='
',Ub=`
+
`,jb='
',qb=`
`;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=$("

${m("note_tree.tree-settings-title")}


`,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()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=$("