import{G as e,H as t,ft as n,t as r}from"./content_renderer-DOj8g78V.js";import{U as i}from"./i18n-BaLR3UdQ.js";async function a(e,i,a){let o=await t.getNote(e);if(!o)return;let s=(a??i.closest(`section.include-note`).attr(`data-box-size`))===`expandable`,c=i.hasClass(`include-note-wrapper`),l=$(`<div class="include-note-wrapper">`),u=await n.createLink(o.noteId,{showTooltip:!1,showNoteIcon:!0});if(s){let e=$(`<div class="include-note-title-row">`),t=$(`<button class="include-note-toggle bx bx-chevron-right" aria-expanded="false">`),n=$(`<h4 class="include-note-title">`).append(u);e.append(t,n),l.append(e);let{$renderedContent:i,type:a}=await r.getRenderedContent(o,{interactive:!0,includesAsReferenceLinks:!0,mediaEnvironment:`embedded`}),s=$(`<div class="include-note-content type-${a}" style="display: none;">`).append(i);l.append(s),t.on(`click`,e=>{e.stopPropagation();let n=t.attr(`aria-expanded`)===`true`;t.attr(`aria-expanded`,String(!n)),t.toggleClass(`expanded`),s.slideToggle(200)})}else{l.append($(`<h4 class="include-note-title">`).append(u));let{$renderedContent:e,type:t}=await r.getRenderedContent(o,{interactive:!0,includesAsReferenceLinks:!0,mediaEnvironment:`embedded`});l.append($(`<div class="include-note-content type-${t}">`).append(e))}r.disposeInteractiveContent(i),i.empty().append(c?l.children():l)}function o(e,t){let n=e.querySelectorAll(`section[data-note-id="${t}"]`);for(let e of n)a(t,$(e))}function s(e,t){let n=$(e);n.on(`dblclick`,`img`,e=>c($(e.target))),n.on(`click`,`img`,e=>{e.stopPropagation();let n=e.which===1,r=e.which===2,a=i.isCtrlKey(e),o=n&&a&&e.shiftKey||r&&e.shiftKey;n&&a||r?l($(e.target),o):n&&t&&c($(e.target))})}async function c(t){let n=await u(t);n?e.tabManager.getActiveContext()?.setNote(n.noteId,{viewScope:n.viewScope}):window.open(t.prop(`src`),`_blank`)}async function l(t,n=!1){let r=await u(t);r?e.tabManager.openTabWithNoteWithHoisting(r.noteId,{activate:n,viewScope:r.viewScope}):window.open(t.prop(`src`),`_blank`)}async function u(e){let n=e.prop(`src`),r=n.match(/\/api\/images\/([A-Za-z0-9_]+)\//);if(r)return{noteId:r[1],viewScope:{}};let i=n.match(/\/api\/attachments\/([A-Za-z0-9_]+)\/image\//);if(i){let e=i[1],n=await t.getAttachment(e);return n?{noteId:n.ownerId,viewScope:{viewMode:`attachments`,attachmentId:e}}:null}return null}export{o as n,s as r,a as t};