import{u as e}from"./utils-BakkG8Vx.js";import{d as t,m as n,s as r,t as i,y as a}from"./hooks.module-5xe-uC6c.js";import{G as o,N as s,_t as c,n as l}from"./content_renderer-CoENEE63.js";import{s as u}from"./options-CDt8ZGCW.js";import{t as d}from"./jsxRuntime.module--xb8gfv5.js";import{Q as f,U as p,j as m}from"./hooks-CSTgmcXO.js";import{a as h}from"./FormList-BjfvxCF_.js";import{i as g,t as _}from"./Button-XVZ6KZoL.js";import{t as v}from"./FormGroup--CU8SFQh.js";import{t as y}from"./NoteAutocomplete-CVTb6kKc.js";import{t as b}from"./Admonition-J_fzSnDf.js";import{t as x}from"./SetupForm-DSf0oesd.js";t();var S=`HcABDtFCkbFN`,C=`export default function() {
    return <p>Hello world.</p>;
}
`,w=`<p>Hello world.</p>
`;function T(e){let{note:t}=e,[n]=m(t,`renderNote`),[r]=m(t,`disabled:renderNote`);return d(r?D:n?E:O,{...e})}function E({note:t,noteContext:o,ntxId:c}){let u=i(null),[m,h]=r(null);function g(){u&&(h(null),l.render(t,s(u),h))}return n(g,[t]),p(`renderActiveNote`,()=>{o?.isActive()&&g()}),p(`refreshData`,({ntxId:e})=>{e===c&&g()}),p(`entitiesReloaded`,({loadResults:e})=>{e.getAttributeRows().some(e=>e.type===`relation`&&e.name===`renderNote`&&f.isAffecting(e,t))&&g()}),p(`executeWithContentElement`,({resolve:e,ntxId:t})=>{t===c&&e(s(u))}),d(a,{children:[m&&d(b,{type:`caution`,children:e(m)}),d(`div`,{ref:u,className:`note-detail-render-content`})]})}function D({note:e}){return d(x,{icon:`bx bx-extension`,inAppHelpPage:S,children:[d(`p`,{children:u(`render.disabled_description`)}),d(_,{text:u(`render.disabled_button_enable`),icon:`bx bx-check-shield`,onClick:()=>f.toggleDangerousAttribute(e,`relation`,`renderNote`,!0),kind:`primary`})]})}function O({note:e}){return d(x,{icon:`bx bx-extension`,inAppHelpPage:S,children:[d(v,{name:`render-target-note`,label:u(`render.setup_title`),children:d(y,{noteIdChanged:t=>{t&&k(e,t)}})}),d(g,{text:u(`render.setup_create_sample_preact`),icon:`bx bxl-react`,onClick:()=>A(e,`text/jsx`,C),children:d(h,{icon:`bx bxl-html5`,onClick:()=>A(e,`text/html`,w),children:u(`render.setup_create_sample_html`)})})]})}async function k(e,t){await f.setRelation(e.noteId,`renderNote`,t)}async function A(e,t,n){let{note:r}=await o.createNote(e.noteId,{type:`code`,mime:t,content:n,activate:!1});r&&(await k(e,r.noteId),c.showMessage(u(`render.setup_sample_created`)))}export{T as default};