require(`./chunk-Bmb41Sf3.cjs`);let e=require(`@tiptap/core`),t=require(`@tiptap/pm/model`);function n(t,n,r){let i=t.attrs;return i?n.filter(e=>e.type===(typeof t.type==`string`?t.type:t.type.name)?r?e.attribute.rendered:!0:!1).map(e=>e.attribute.renderHTML&&e.attribute.renderHTML(i)||{[e.name]:e.name in i?i[e.name]:e.attribute.default}).reduce((t,n)=>(0,e.mergeAttributes)(t,n),{}):{}}function r(e,t){return n(e,t,!0)}function i(t,n,i,a){let o=(0,e.getExtensionField)(n,`renderHTML`,{name:n.name,options:n.options,storage:n.storage,parent:n.parent});return o?[n.name,({node:e,children:a})=>{try{return t(o({node:e,HTMLAttributes:r(e,i)}))(a)}catch(e){throw Error(`[tiptap error]: Node ${n.name} cannot be rendered, it's "renderToHTML" method threw an error: ${e.message}`,{cause:e})}}]:a?.unhandledNode?[n.name,a.unhandledNode]:[n.name,()=>{throw Error(`[tiptap error]: Node ${n.name} cannot be rendered, it is missing a "renderToHTML" method, please implement it or override the corresponding "nodeMapping" method to have a custom rendering`)}]}function a(t,n,i,a){let o=(0,e.getExtensionField)(n,`renderHTML`,{name:n.name,options:n.options,storage:n.storage,parent:n.parent});return o?[n.name,({mark:e,children:a})=>{try{return t(o({mark:e,HTMLAttributes:r(e,i)}))(a)}catch(e){throw Error(`[tiptap error]: Mark ${n.name} cannot be rendered, it's "renderToHTML" method threw an error: ${e.message}`,{cause:e})}}]:a?.unhandledMark?[n.name,a.unhandledMark]:[n.name,()=>{throw Error(`Node ${n.name} cannot be rendered, it is missing a "renderToHTML" method`)}]}function o({renderer:n,domOutputSpecToElement:r,mapDefinedTypes:o,content:s,extensions:c,options:l}){c=(0,e.resolveExtensions)(c);let u=(0,e.getAttributesFromExtensions)(c),{nodeExtensions:d,markExtensions:f}=(0,e.splitExtensions)(c);return s instanceof t.Node||(s=t.Node.fromJSON((0,e.getSchemaByResolvedExtensions)(c),s)),n({...l,nodeMapping:{...Object.fromEntries(d.filter(e=>e.name in o?!1:l?.nodeMapping?!(e.name in l.nodeMapping):!0).map(e=>i(r,e,u,l))),...o,...l?.nodeMapping},markMapping:{...Object.fromEntries(f.filter(e=>l?.markMapping?!(e.name in l.markMapping):!0).map(e=>a(r,e,u,l))),...l?.markMapping}})({content:s})}function s(e,{nodeMapping:t,markMapping:n,unhandledNode:r,unhandledMark:i}){return function a({content:o,parent:s}){let c=typeof o.type==`string`?o.type:o.type.name,l=t[c]??r;if(!l)throw Error(`missing handler for node type ${c}`);let u=e({component:l,props:{node:o,parent:s,renderElement:a,get children(){let e=[];return o.content&&o.content.forEach(t=>{e.push(a({content:t,parent:o}))}),e}}});return o.marks?o.marks.reduce((t,r)=>{let a=typeof r.type==`string`?r.type:r.type.name,c=n[a]??i;if(!c)throw Error(`missing handler for mark type ${a}`);return e({component:c,props:{mark:r,parent:s,node:o,children:t}})},u):u}}function c(e){return s(e=>e.component(e.props),e)}function l(e){let t=Object.entries(e||{}).map(([e,t])=>`${e.split(` `).at(-1)}=${JSON.stringify(t)}`).join(` `);return t?` ${t}`:``}function u(e){return[].concat(e||``).filter(Boolean).join(``)}var d=new Set([`iframe`,`script`,`style`,`title`,`textarea`,`div`,`span`,`a`,`button`]);function f(e){if(typeof e==`string`)return()=>e;if(typeof e==`object`&&`length`in e){let[t,n,r,...i]=e,a=t,o=a.split(` `);if(o.length>1&&(a=`${o[1]} xmlns="${o[0]}"`),n===void 0)return()=>`<${a}/>`;if(n===0)return e=>`<${a}>${u(e)}</${a}>`;if(typeof n==`object`)return Array.isArray(n)?r===void 0||r===0?e=>`<${a}>${f(n)(e)}</${a}>`:e=>`<${a}>${f(n)(e)}${[r].concat(i).map(t=>f(t)(e))}</${a}>`:r===void 0?d.has(a)?()=>`<${a}${l(n)}></${a}>`:()=>`<${a}${l(n)}/>`:r===0?e=>`<${a}${l(n)}>${u(e)}</${a}>`:e=>`<${a}${l(n)}>${[r].concat(i).map(t=>f(t)(e)).join(``)}</${a}>`}throw Error("[tiptap error]: Unsupported DomOutputSpec type, check the `renderHTML` method output or implement a node mapping",{cause:e})}function p({content:e,extensions:t,options:n}){return o({renderer:c,domOutputSpecToElement:f,mapDefinedTypes:{doc:({children:e})=>u(e),text:({node:e})=>e.text??``},content:e,extensions:t,options:n})}function m({content:e,extensions:t,options:n}){return p({content:e,extensions:t,options:{...n,nodeMapping:{bulletList({children:e}){return`
${u(e)}`},orderedList({children:e}){return`
${u(e)}`},listItem({node:e,children:t,parent:n}){if(n?.type.name===`bulletList`)return`- ${u(t).trim()}
`;if(n?.type.name===`orderedList`){let r=n.attrs.start||1;return n.forEach((t,n,i)=>{e===t&&(r=i+1)}),`${r}. ${u(t).trim()}
`}return u(t)},paragraph({children:e}){return`
${u(e)}
`},heading({node:e,children:t}){let n=e.attrs.level;return`${Array(n).fill(`#`).join(``)} ${t}
`},codeBlock({node:e,children:t}){return`
\`\`\`${e.attrs.language}
${u(t)}
\`\`\`
`},blockquote({children:e}){return`
${u(e).trim().split(`
`).map(e=>`> ${e}`).join(`
`)}`},image({node:e}){return`![${e.attrs.alt}](${e.attrs.src})`},hardBreak(){return`
`},horizontalRule(){return`
---
`},table({children:e,node:t}){if(!Array.isArray(e))return`
${u(e)}
`;let n=t.children[0].childCount;return`
${u(e[0])}| ${Array(n).fill(`---`).join(` | `)} |
${u(e.slice(1))}
`},tableRow({children:e}){return Array.isArray(e)?`| ${e.join(` | `)} |
`:`${u(e)}
`},tableHeader({children:e}){return u(e).trim()},tableCell({children:e}){return u(e).trim()},...n?.nodeMapping},markMapping:{bold({children:e}){return`**${u(e)}**`},italic({children:e,node:t}){let n=!1;return t?.marks.some(e=>e.type.name===`bold`)&&(n=!0),n?`*${u(e)}*`:`_${u(e)}_`},code({children:e}){return`\`${u(e)}\``},strike({children:e}){return`~~${u(e)}~~`},underline({children:e}){return`<u>${u(e)}</u>`},subscript({children:e}){return`<sub>${u(e)}</sub>`},superscript({children:e}){return`<sup>${u(e)}</sup>`},link({mark:e,children:t}){return`[${u(t)}](${e.attrs.href})`},highlight({children:e}){return`==${u(e)}==`},...n?.markMapping}}})}var h=e=>Array.isArray(e)?e.join(``):e||``,g=(e,t,n)=>{let r=e.trim();return r?`${e.slice(0,e.length-e.trimStart().length)}${t}${r}${n}${e.slice(e.trimEnd().length)}`:e};function _(e,t){return m({extensions:t,content:e,options:{nodeMapping:{blockquote({children:e}){return h(e).trim().split(`
`).map(e=>e?`> ${e}`:`>`).join(`
`)+`
`},codeBlock({node:e,children:t}){return`\`\`\`${e.attrs?.language||``}\n${h(t)}\n\`\`\`\n`},mention({node:e}){return`<!-- @mention: {"id": "${e.attrs?.id||``}", "contactKey": "${e.attrs?.contactKey||``}", "name": "${e.attrs?.name||``}"} -->`},channel({node:e}){return`<!-- @channel: {"id": "${e.attrs?.id||``}", "channelKey": "${e.attrs?.channelKey||``}", "name": "${e.attrs?.name||``}", "locked": "${String(e.attrs?.locked??``)}"} -->`},"slash-commands"({node:e}){return`/${e.attrs?.command||``}`},emoji({node:e}){return e.attrs?.code||``},variable({node:e}){return`{{${e.attrs?.id||``}=${e.attrs?.altText||``}}}`}},markMapping:{bold({children:e}){return g(h(e),`**`,`**`)},italic({children:e}){return g(h(e),`*`,`*`)},strike({children:e}){return g(h(e),`~~`,`~~`)},code({children:e}){return g(h(e),"`","`")},link({mark:e,children:t}){let n=h(t),r=e.attrs?.href||``,i=n.trim();return`${n.slice(0,n.length-n.trimStart().length)}[${i}](${r})${n.slice(n.trimEnd().length)}`},underline({children:e}){return h(e)}}}}).replace(/\n{3,}/g,`

`).replace(/^\n+|\n+$/g,``)}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return _}});
//# sourceMappingURL=markdownRenderer-DCgGQseq.cjs.map