import{r as B,j as o}from"./iframe-B8FSoBNY.js";import{c as $}from"./compiler-runtime-BXE7OOXE.js";import{o as U,T as q,Z as F,a0 as A,a1 as J,M as H,L as K,n as G,C as Q,D as W,f as X}from"./rich-text-theme-Bkhh9rAZ.js";import{D as V,T as Z,a as Y,b as z,c as ee,d as te,e as ne,q as se,C as oe,f as re,H as ie,J as P,l as ae,s as le,n as ce,I as fe,E as de,K as ue}from"./CodeBlockPlugin-C3OWpvP8.js";import{n as pe,T as me,a as _e}from"./TreeViewPlugin-CyVKCrKJ.js";import{s as he}from"./markdown-BLUemkxK.js";import{R as ge}from"./resource-badge-Bw5UoU4J.js";import{B as Ee}from"./index-B0y2_lLF.js";import{F as be}from"./flex-DAJL4AFZ.js";function xe(s){const e=$.c(5),{value:t,onUpdate:n}=s,[i]=U();let r,a;return e[0]!==i||e[1]!==n||e[2]!==t?(r=()=>{i&&i.update(()=>n(t),{tag:"history-merge"})},a=[t,i,n],e[0]=i,e[1]=n,e[2]=t,e[3]=r,e[4]=a):(r=e[3],a=e[4]),B.useEffect(r,a),null}class c extends q{__href;__label;static getType(){return"reference-link"}static clone(e){return new c(e.__href,e.__label,e.__key)}constructor(e,t,n){super(n),this.__href=e,this.__label=t}createDOM(e,t){return document.createElement("span")}updateDOM(e,t,n){return!1}getTextContent(){return`{{link('${this.__label??this.__href}')}}`}exportJSON(){return{type:c.getType(),version:1,href:this.__href,label:this.__label}}static importJSON(e){return M(e.href,e.label)}decorate(e,t){const n=this.__href,r=n.split("/").pop()||"unknown",a=/^https?:\/\//i.test(n),g=/^#?\$PROJECT\//i.test(n);return o.jsx(Ee,{width:"fit-content",display:"inline-block",children:o.jsx(ge,{fileName:r,onSelect:()=>{if(a)window.open(n,"_blank","noopener,noreferrer");else if(g){const l=n.replace(/^#?\$PROJECT\//i,""),f=new CustomEvent("ui:open-project-file",{detail:l});window.dispatchEvent(f)}else window.location.assign(n)}})})}}function M(s,e){return new c(s,e)}function Ne(s){return s instanceof c}const I=/\{\{\s*link\((['"])([^'"\s]+)\1\)\s*\}\}/,Te={dependencies:[c],export:s=>{if(Ne(s)){const e=s.__href,t=s.__label??e;return t?`{{link('${t}')}}`:`{{link('${e}')}}`}return null},regExp:I,importRegExp:I,replace:(s,e)=>{const t=e[2],i=/^(https?:\/\/|\/)/i.test(t)?t:`#${t}`,r=t;s.replace(M(i,r))},type:"text-match"},S=[...V,...Z,Y,z,Te];function ye(s){const e=$.c(30),{debug:t,defaultState:n,isEditable:i,onChange:r}=s,a=t===void 0?!1:t,g=n===void 0?"":n,l=i===void 0?!1:i;let f;e[0]!==g?(f=he(g),e[0]=g,e[1]=f):f=e[1];const{frontmatter:C,body:d}=f,k=l&&!!r;let E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=[F,A,ee,J,te,ne,se,oe,re,ie,c],e[2]=E):E=e[2];let u;e[3]!==d?(u=()=>P(d,S,void 0,!1),e[3]=d,e[4]=u):u=e[4];let b;e[5]!==l||e[6]!==u?(b={namespace:"RICH_MESSAGE",nodes:E,editorState:u,onError:je,editable:l,theme:H},e[5]=l,e[6]=u,e[7]=b):b=e[7];const w=b;let p;e[8]!==d?(p=o.jsx(xe,{value:d,onUpdate:Re}),e[8]=d,e[9]=p):p=e[9];let x,N,T,y,R;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(ae,{}),R=o.jsx(le,{}),x=o.jsx(ce,{}),N=o.jsx(fe,{}),T=o.jsx(de,{}),e[10]=x,e[11]=N,e[12]=T,e[13]=y,e[14]=R):(x=e[10],N=e[11],T=e[12],y=e[13],R=e[14]);let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(K,{contentEditable:o.jsx(Q,{fullWidth:!1}),ErrorBoundary:G}),e[15]=j):j=e[15];let m;e[16]!==C||e[17]!==r||e[18]!==k?(m=k?o.jsx(pe,{ignoreSelectionChange:!0,ignoreHistoryMergeTagChange:!1,onChange:O=>{O.read(()=>{const D=W(),L=ue(S,D);r?.(C+L)})}}):null,e[16]=C,e[17]=r,e[18]=k,e[19]=m):m=e[19];let _;e[20]!==l?(_=o.jsx(me,{isEditable:l}),e[20]=l,e[21]=_):_=e[21];let h;e[22]!==a?(h=a&&o.jsx(_e,{}),e[22]=a,e[23]=h):h=e[23];let v;return e[24]!==w||e[25]!==m||e[26]!==_||e[27]!==h||e[28]!==p?(v=o.jsx(be,{className:"rich-text",justifyContent:"space-between",width:"100%",maxWidth:"100%",height:"100%",position:"relative",direction:"column",overflow:"hidden",children:o.jsxs(X,{initialConfig:w,children:[p,y,R,x,N,T,j,m,_,h]})}),e[24]=w,e[25]=m,e[26]=_,e[27]=h,e[28]=p,e[29]=v):v=e[29],v}function Re(s){P(s,S,void 0,!1)}function je(s){return console.error(s)}ye.__docgenInfo={description:"",methods:[],displayName:"RichMessage",props:{debug:{required:!1,tsType:{name:"boolean"},description:""},defaultState:{required:!0,tsType:{name:"string"},description:""},isEditable:{required:!1,tsType:{name:"boolean"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(value: string) => void",signature:{arguments:[{type:{name:"string"},name:"value"}],return:{name:"void"}}},description:""}}};export{ye as R};
