import{a as e,l as t}from"./preact.module-CNakwbc9.js";import{a as n,d as r,i,l as a,t as o}from"./hooks.module-BrXTvcfS.js";import{G as s,R as c,c as l,o as u,r as d,s as f,u as p,y as m}from"./content_renderer-DOj8g78V.js";import{r as h}from"./i18n-BaLR3UdQ.js";import{t as g}from"./jsxRuntime.module-Cao1NCKs.js";import{D as _,G as v,J as y,X as b,Z as x,j as S}from"./hooks-ClTXKdUl.js";import{n as C}from"./RawHtml-BZRPHliO.js";import{n as w}from"./math-BDK0Mxr3.js";import"./src-Bbn-vyQI.js";import{n as T,r as E,t as D}from"./utils-DmG16PJC.js";r(),t();function O({note:t,noteContext:n,ntxId:r,parentComponent:i,isVisible:s}){let c=_(t,i?.componentId,{reportLoadStateTo:n,isVisible:s,refreshOnShow:!0}),{isRtl:l}=A(t),u=o(null);return a(()=>{let e=n?.viewScope;!e?.bookmark||!u.current||(u.current.querySelector(`[id="${CSS.escape(e.bookmark)}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`}),e.bookmark=void 0)},[c]),g(e,{children:g(k,{html:c?.content??``,ntxId:r,dir:l?`rtl`:`ltr`,contentRef:u})})}function k({html:e,ntxId:t,dir:r,className:i,contentRef:o}){let h=v(o),[_]=x(`codeBlockWordWrap`),[S]=b(`codeBlockTabWidth`);return a(()=>{document.body.style.setProperty(`--code-block-tab-width`,S||`4`)},[S]),n(()=>{let e=h.current;e&&(t&&s.triggerEvent(`contentElRefreshed`,{ntxId:t,contentEl:e}),d(e,Promise.all([l(e),f(e),j(e),m(e),u(e),p($(e))])),M(e),E(e,!0))},[e,t,h]),y(`refreshIncludedNote`,({noteId:e})=>{h.current&&T(h.current,e)}),y(`executeWithContentElement`,({resolve:e,ntxId:n})=>{!t||n!==t||!h.current||e($(h.current))}),g(C,{containerRef:h,className:c(`note-detail-readonly-text-content ck-content use-tn-links selectable-text`,_&&`word-wrap`,i),tabindex:100,dir:r,html:e})}function A(e){let[t]=S(e,`language`);return{isRtl:i(()=>h(t)?.rtl,[t])}}function j(e){let t=[],n=e.querySelectorAll(`section.include-note`);for(let e of n){let n=e.dataset.noteId;n&&t.push(D(n,$(e)))}return Promise.all(t)}function M(e){let t=e.querySelectorAll(`span.math-tex`);for(let e of t)w(e,{trust:!0,throwOnError:!1})}export{k as n,O as t};