wysimark-lite 0.21.2 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,45 +1,46 @@
1
- "use client";import{createRef as Eb,useCallback as xb,useImperativeHandle as yb,useRef as kb,useState as Tb}from"react";import{createRoot as vb}from"react-dom/client";import pb from"lodash.throttle";import{useCallback as Te,useRef as no,useState as Kc}from"react";import{Editor as db,Transforms as ub}from"slate";import{ReactEditor as fb,Slate as hb}from"slate-react";import up from"remark-parse";import{unified as fp}from"unified";function lo(){return{enter:{table:Gc,tableData:xr,tableHeader:xr,tableRow:Qc},exit:{codeText:jc,table:qc,tableData:ao,tableHeader:ao,tableRow:ao}}}function Gc(e){let t=e._align;this.enter({type:"table",align:t.map(function(o){return o==="none"?null:o}),children:[]},e),this.data.inTable=!0}function qc(e){this.exit(e),this.data.inTable=void 0}function Qc(e){this.enter({type:"tableRow",children:[]},e)}function ao(e){this.exit(e)}function xr(e){this.enter({type:"tableCell",children:[]},e)}function jc(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Jc));let o=this.stack[this.stack.length-1];o.type,o.value=t,this.exit(e)}function Jc(e,t){return t==="|"?t:e}import{gfm as Xc}from"micromark-extension-gfm";import{gfmToMarkdown as Yc}from"mdast-util-gfm";function yr(){return function(){if(!this)return;this.data?typeof this.data=="function"&&this.data():this.data={};let e=typeof this.data=="function"?this.data():this.data,t=e.micromarkExtensions||(e.micromarkExtensions=[]),o=e.fromMarkdownExtensions||(e.fromMarkdownExtensions=[]),r=e.toMarkdownExtensions||(e.toMarkdownExtensions=[]);t.push(Xc());let n=function(){let i=lo();if(i.enter){let a=i.enter.table;a&&(i.enter.table=function(l){this.data||(this.data={}),a.call(this,l),this.data.inTable=!0})}if(i.exit){let a=i.exit.table;a&&(i.exit.table=function(l){this.data||(this.data={}),a.call(this,l),this.data&&(this.data.inTable=void 0)})}return i};o.push(n()),r.push(Yc())}}function se(e){let t=/\[([^\]]+)\]\(([^)]+)\)/g,o=[],r=0,n=e.replace(t,s=>(o.push(s),`__MARKDOWN_LINK_${r++}__`)),i=/(https?:\/\/[^\s]+)/g,l=n.replace(i,s=>s.replace(/\//g,"\\/"));for(let s=0;s<o.length;s++)l=l.replace(`__MARKDOWN_LINK_${s}__`,o[s]);return l}function so(e){return e.replace(/\\(.)/g,(t,o)=>o)}function kr(e,t){if(!e)throw new Error(`${t}`)}function mt(e,t){if(e.type!==t)throw new Error(`Expected element to be of type ${JSON.stringify(e)} but is ${JSON.stringify(e,null,2)}`)}function me(e){throw new Error(`Didn't expect to get here with value ${JSON.stringify(e,null,2)}`)}function Tr(e){return[{type:"block-quote",children:ve(e.children)}]}function vr(e){let t=e.value.split(`
2
- `);return[{type:"code-block",language:e.lang||"text",children:t.map(o=>({type:"code-block-line",children:[{text:o}]}))}]}function wr(e){return[{type:"block-quote",children:[{type:"paragraph",children:[{text:`[${e.identifier}]`}]},...ve(e.children)]}]}import{Text as Lr}from"slate";import{Text as Sr}from"slate";import*as We from"slate";function R(e){return We.Text.isText(e)}function _(e){return We.Element.isElement(e)}function v(e){return We.Text.isText(e)&&!!e.text.match(/^\s+$/)&&!e.code}var Ir={bold:"**",italic:"_",strike:"~~",code:""};function Zc(e){if(e in Ir)return Ir[e];throw new Error(`Could not find mark ${JSON.stringify(e)} in MARK_KEY_TO_TOKEN lookup`)}function mo(e){return e.map(Zc).join("")}import{Text as ep}from"slate";function Ge(e){let{text:t,...o}=e;return Object.keys(o)}function co(e){if(ep.isText(e)){if(v(e))throw new Error("You probably didn't mean to do this. We should only be getting marks from segments that are not plain space segments.");return Ge(e)}else{if(e.type==="anchor")return po(e.children);throw new Error(`Unhandled type ${e.type}`)}}function po(e){let t;for(let o of e){if(!R(o)){if(o.type==="image-inline")continue;throw new Error("Expected every segment in an anchor to be a Text segment")}if(v(o))continue;let r=Ge(o);if(t===void 0){t=r;continue}t=t.filter(n=>r.includes(n))}if(t===void 0)throw new Error("No text segments were found as children in this anchor which should not be possible");return t}var Mr=["bold","italic","underline","strike","code"];function Pr(e){return e.slice().sort((t,o)=>Mr.indexOf(t)-Mr.indexOf(o))}var tp=["\\","`","*","_","[","]","(",")","#","+","-",".","!","|","^","~","<",">","{","}","=",":",";","$","%","&","?",'"',"'",",","\\","/","@"],op=new RegExp(`(${tp.map(e=>`\\${e}`).join("|")})`,"g");function Cr(e){return e.replace(op,t=>`\\${t}`)}function rp(e,t){let o=Ge(e),r=Ge(t);return o.length==r.length&&o.every(n=>r.includes(n))}function Rr(e,t){let o=Sr.isText(e),r=Sr.isText(t);return t&&!r&&!o?[{text:""},e]:o?t===void 0||!r?[e]:rp(t,e)?(t.text=[t.text,e.text].join(""),[]):[e]:[e]}function zr(e){let t=[];for(let o=0;o<e.length;o++){let r=t[t.length-1];t.push(...Rr(e[o],r))}return t.length===0&&t.push({text:""}),Lr.isText(t[0])||t.unshift({text:""}),Lr.isText(t[t.length-1])||t.push({text:""}),t}function Br(e){return{url:e.url,title:e.title||void 0,alt:e.alt||void 0}}var np=/^(\/[^?#]*)(?:\?([^#]*))?(#.*)?$/;function we(e){try{let t=new URL(e);return{origin:t.origin,hostname:t.hostname,pathname:t.pathname,searchParams:t.searchParams,hash:t.hash}}catch{let o=e.match(np);if(o===null)throw new Error(`Invalid format should not happen: ${e}`);let[r,n,i,a]=[...o];return{origin:"",hostname:"",pathname:n||"",searchParams:new URLSearchParams(i),hash:a||""}}}function qe(e){if(typeof e!="string")return null;let t=e.match(/^(\d+)x(\d+)$/);return t===null?null:{width:parseInt(t[1]),height:parseInt(t[2])}}function Nr(e){let t=we(e.url);if(!t.hostname.match(/[.]portive[.]com$/i))return;let o=t.searchParams.get("size");if(o===null)return;let r=qe(o);if(r===null)return;let n=t.pathname.match(/[-][-](\d+)x(\d+)[.][a-zA-Z]+$/);if(n!==null)return{url:`${t.origin}${t.pathname}`,title:e.title||void 0,alt:e.alt||void 0,width:r.width,height:r.height,srcWidth:parseInt(n[1]),srcHeight:parseInt(n[2])}}function Dr(e){let t=we(e.url);if(t.hash.length===0)return;let o=new URLSearchParams(t.hash.slice(1)),r=qe(o.get("size")),n=qe(o.get("srcSize"));if(!(!r||!n))return{url:`${t.origin}${t.pathname}`,title:e.title||void 0,alt:e.alt||void 0,width:r.width,height:r.height,srcWidth:n.width,srcHeight:n.height}}var $r=[Nr,Dr,Br];function Ar(e){for(let t of $r){let o=t(e);if(o)return[{type:"image-inline",...o,children:[{text:""}]}]}throw new Error("Shouldn't get here because last parser always returns data")}function B(e,t={}){let o=[];for(let n of e)o.push(...ip(n,t));return zr(o)}function ip(e,t={}){switch(e.type){case"delete":return B(e.children,{...t,strike:!0});case"emphasis":return B(e.children,{...t,italic:!0});case"footnoteReference":return[{text:`[${e.identifier}]`}];case"html":return[{text:e.value,code:!0}];case"image":return Ar(e);case"inlineCode":return[{text:e.value,...t,code:!0}];case"link":return[{type:"anchor",href:e.url,title:e.title==null?void 0:e.title,children:B(e.children,t)}];case"strong":return B(e.children,{...t,bold:!0});case"text":return[{text:e.value,...t}];case"linkReference":case"imageReference":throw new Error("linkReference and imageReference should be converted to link and image through our transformInlineLinks function");case"break":return[{text:`
3
- `}];case"footnote":throw new Error("footnote is not supported yet")}me(e)}function Hr(e){return[{type:"heading",level:e.depth,children:B(e.children)}]}function Or(e){return[{type:"code-block",language:"html",children:e.value.split(`
4
- `).map(t=>({type:"code-block-line",children:[{text:t}]}))}]}function Ur(e,{depth:t,ordered:o,checked:r}){switch(e.type){case"paragraph":return r===!0||r===!1?[{type:"task-list-item",depth:t,checked:r,children:B(e.children)}]:o?[{type:"ordered-list-item",depth:t,children:B(e.children)}]:[{type:"unordered-list-item",depth:t,children:B(e.children)}];case"list":return ct(e,t+1);default:return uo(e)}}function Fr(e,t){let o=[];for(let r of e.children)o.push(...Ur(r,{...t,checked:e.checked}));return o}function ct(e,t=0){let o=[];for(let r of e.children)o.push(...Fr(r,{depth:t,ordered:!!e.ordered}));return o}function ap(e){return!(e.length!==3||!("text"in e[0])||e[0].text!==""||!("text"in e[2])||e[2].text!==""||!("type"in e[1])||e[1].type!=="image-inline")}var lp="\xA0";function sp(e){return!(e.length!==1||!("text"in e[0])||e[0].text!==lp)}function Vr(e){let t=B(e.children);return ap(t)?[{...t[1],type:"image-block"}]:sp(t)?[{type:"paragraph",children:[{text:""}]}]:[{type:"paragraph",children:t}]}function Kr(e){if(e.align==null)throw new Error("Expected an array of AlignType for table.align");return[{type:"table",columns:e.align.map(t=>({align:t||"left"})),children:e.children.map(mp)}]}function mp(e){if(e.type!=="tableRow")throw new Error("Expected a tableRow");return{type:"table-row",children:e.children.map(cp)}}function cp(e){if(e.type!=="tableCell")throw new Error("Expected a tableCell");return{type:"table-cell",children:[{type:"table-content",children:B(e.children)}]}}function _r(){return[{type:"horizontal-rule",children:[{text:""}]}]}function ve(e){let t=[];for(let o of e)t.push(...uo(o));return t}function uo(e){switch(e.type){case"blockquote":return Tr(e);case"code":return vr(e);case"definition":throw new Error('The type "definition" should not exist. See comments');case"footnoteDefinition":return wr(e);case"heading":return Hr(e);case"html":return Or(e);case"list":return ct(e);case"paragraph":return Vr(e);case"table":return Kr(e);case"thematicBreak":return _r();case"yaml":return[]}me(e)}import{definitions as pp}from"mdast-util-definitions";import{SKIP as Wr,visit as dp}from"unist-util-visit";function Gr(e){let t=pp(e);dp(e,(o,r,n)=>{let i=o,a=n;if(i.type==="definition"&&a!==null&&typeof r=="number")return a.children.splice(r,1),[Wr,r];if(i.type==="imageReference"||i.type==="linkReference"){let l="identifier"in i&&typeof i.identifier=="string"?i.identifier:"",s=t(l);if(s&&a!==null&&typeof r=="number"){let m=i.type==="imageReference"?{type:"image",url:s.url,title:s.title,alt:i.alt}:{type:"link",url:s.url,title:s.title,children:i.children};return a.children[r]=m,[Wr,r]}}})}var hp=fp().use(up).use(yr());function gp(e){let t=hp.parse(e);return Gr(t),t}function ce(e){let t=gp(e);return t.children.length===0?[{type:"paragraph",children:[{text:""}]}]:ve(t.children)}function bp(e){return e.type==="ordered-list-item"||e.type==="unordered-list-item"||e.type==="task-list-item"}function qr(e){let t=[],o=-1;for(let r of e){if(!bp(r)){t.push(r),o=-1;continue}let n=r.depth>o+1?o+1:r.depth;t.push({...r,depth:n}),o=n}return t}function Qr(e){if(e.type!=="code-block-line")throw new Error(`Expected all children of code-block to be a codeline but is ${JSON.stringify(e,null,2)}`);return e.children.map(t=>t.text).join("")}function jr(e){let t=[],o=3;for(let r of e.children){let n=Qr(r),i=n.match(/^([`]+)/);i&&(o=Math.max(o,i[1].length+1)),t.push(n)}return t.unshift(`${"`".repeat(o)}${e.language}`),t.push(`${"`".repeat(o)}`),`${t.join(`
1
+ "use client";import{createRef as $b,useCallback as Hb,useImperativeHandle as Ab,useRef as Ob,useState as Ub}from"react";import{createRoot as Fb}from"react-dom/client";import Sb from"lodash.throttle";import{useCallback as Pe,useRef as uo,useState as ep}from"react";import{Editor as Rb,Transforms as Lb}from"slate";import{ReactEditor as Bb,Slate as zb}from"slate-react";import wp from"remark-parse";import{unified as Ip}from"unified";function go(){return{enter:{table:rp,tableData:Sr,tableHeader:Sr,tableRow:ip},exit:{codeText:ap,table:np,tableData:ho,tableHeader:ho,tableRow:ho}}}function rp(e){let t=e._align;this.enter({type:"table",align:t.map(function(o){return o==="none"?null:o}),children:[]},e),this.data.inTable=!0}function np(e){this.exit(e),this.data.inTable=void 0}function ip(e){this.enter({type:"tableRow",children:[]},e)}function ho(e){this.exit(e)}function Sr(e){this.enter({type:"tableCell",children:[]},e)}function ap(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,lp));let o=this.stack[this.stack.length-1];o.type,o.value=t,this.exit(e)}function lp(e,t){return t==="|"?t:e}import{gfm as sp}from"micromark-extension-gfm";import{gfmToMarkdown as mp}from"mdast-util-gfm";function Rr(){return function(){if(!this)return;this.data?typeof this.data=="function"&&this.data():this.data={};let e=typeof this.data=="function"?this.data():this.data,t=e.micromarkExtensions||(e.micromarkExtensions=[]),o=e.fromMarkdownExtensions||(e.fromMarkdownExtensions=[]),r=e.toMarkdownExtensions||(e.toMarkdownExtensions=[]);t.push(sp());let n=function(){let i=go();if(i.enter){let a=i.enter.table;a&&(i.enter.table=function(l){this.data||(this.data={}),a.call(this,l),this.data.inTable=!0})}if(i.exit){let a=i.exit.table;a&&(i.exit.table=function(l){this.data||(this.data={}),a.call(this,l),this.data&&(this.data.inTable=void 0)})}return i};o.push(n()),r.push(mp())}}function de(e){let t=/\[([^\]]+)\]\(([^)]+)\)/g,o=[],r=0,n=e.replace(t,s=>(o.push(s),`__MARKDOWN_LINK_${r++}__`)),i=/(https?:\/\/[^\s]+)/g,l=n.replace(i,s=>s.replace(/\//g,"\\/"));for(let s=0;s<o.length;s++)l=l.replace(`__MARKDOWN_LINK_${s}__`,o[s]);return l}function Ce(e){return e.replace(/\\(.)/g,(t,o)=>o)}function Lr(e,t){if(!e)throw new Error(`${t}`)}function pt(e,t){if(e.type!==t)throw new Error(`Expected element to be of type ${JSON.stringify(e)} but is ${JSON.stringify(e,null,2)}`)}function ue(e){throw new Error(`Didn't expect to get here with value ${JSON.stringify(e,null,2)}`)}function Br(e){return[{type:"block-quote",children:Se(e.children)}]}function zr(e){let t=e.value.split(`
2
+ `);return[{type:"code-block",language:e.lang||"text",children:t.map(o=>({type:"code-block-line",children:[{text:o}]}))}]}function Nr(e){return[{type:"block-quote",children:[{type:"paragraph",children:[{text:`[${e.identifier}]`}]},...Se(e.children)]}]}import{Text as Fr}from"slate";import{Text as Or}from"slate";import*as Je from"slate";function z(e){return Je.Text.isText(e)}function X(e){return Je.Element.isElement(e)}function C(e){return Je.Text.isText(e)&&!!e.text.match(/^\s+$/)&&!e.code}var Dr={bold:"**",italic:"_",strike:"~~",code:"",highlight:""};function cp(e){return e in Dr?Dr[e]:""}function bo(e){return e.map(cp).join("")}import{Text as pp}from"slate";function Ye(e){let{text:t,...o}=e;return Object.keys(o)}function Eo(e){if(pp.isText(e)){if(C(e))throw new Error("You probably didn't mean to do this. We should only be getting marks from segments that are not plain space segments.");return Ye(e)}else{if(e.type==="anchor")return xo(e.children);throw new Error(`Unhandled type ${e.type}`)}}function xo(e){let t;for(let o of e){if(!z(o)){if(o.type==="image-inline")continue;throw new Error("Expected every segment in an anchor to be a Text segment")}if(C(o))continue;let r=Ye(o);if(t===void 0){t=r;continue}t=t.filter(n=>r.includes(n))}if(t===void 0)throw new Error("No text segments were found as children in this anchor which should not be possible");return t}var $r=["bold","italic","underline","strike","code"];function Hr(e){return e.slice().sort((t,o)=>$r.indexOf(t)-$r.indexOf(o))}var dp=["\\","`","*","_","[","]","(",")","#","+","-",".","!","|","^","~","<",">","{","}","=",":",";","$","%","&","?",'"',"'",",","\\","/","@"],up=new RegExp(`(${dp.map(e=>`\\${e}`).join("|")})`,"g");function Ar(e){return e.replace(up,t=>`\\${t}`)}function fp(e,t){let o=Ye(e),r=Ye(t);return o.length==r.length&&o.every(n=>r.includes(n))}function Ur(e,t){let o=Or.isText(e),r=Or.isText(t);return t&&!r&&!o?[{text:""},e]:o?t===void 0||!r?[e]:fp(t,e)?(t.text=[t.text,e.text].join(""),[]):[e]:[e]}function Vr(e){let t=[];for(let o=0;o<e.length;o++){let r=t[t.length-1];t.push(...Ur(e[o],r))}return t.length===0&&t.push({text:""}),Fr.isText(t[0])||t.unshift({text:""}),Fr.isText(t[t.length-1])||t.push({text:""}),t}function Kr(e){return{url:e.url,title:e.title||void 0,alt:e.alt||void 0}}var hp=/^(\/[^?#]*)(?:\?([^#]*))?(#.*)?$/;function Re(e){try{let t=new URL(e);return{origin:t.origin,hostname:t.hostname,pathname:t.pathname,searchParams:t.searchParams,hash:t.hash}}catch{let t=e.match(hp);if(t===null)throw new Error(`Invalid format should not happen: ${e}`);let[,o,r,n]=[...t];return{origin:"",hostname:"",pathname:o||"",searchParams:new URLSearchParams(r),hash:n||""}}}function Ze(e){if(typeof e!="string")return null;let t=e.match(/^(\d+)x(\d+)$/);return t===null?null:{width:parseInt(t[1]),height:parseInt(t[2])}}function Wr(e){let t=Re(e.url);if(!t.hostname.match(/[.]portive[.]com$/i))return;let o=t.searchParams.get("size");if(o===null)return;let r=Ze(o);if(r===null)return;let n=t.pathname.match(/[-][-](\d+)x(\d+)[.][a-zA-Z]+$/);if(n!==null)return{url:`${t.origin}${t.pathname}`,title:e.title||void 0,alt:e.alt||void 0,width:r.width,height:r.height,srcWidth:parseInt(n[1]),srcHeight:parseInt(n[2])}}function _r(e){let t=Re(e.url);if(t.hash.length===0)return;let o=new URLSearchParams(t.hash.slice(1)),r=Ze(o.get("size")),n=Ze(o.get("srcSize"));if(!(!r||!n))return{url:`${t.origin}${t.pathname}`,title:e.title||void 0,alt:e.alt||void 0,width:r.width,height:r.height,srcWidth:n.width,srcHeight:n.height}}var Gr=[Wr,_r,Kr];function qr(e){for(let t of Gr){let o=t(e);if(o)return[{type:"image-inline",...o,children:[{text:""}]}]}throw new Error("Shouldn't get here because last parser always returns data")}function A(e,t={}){let o=[];for(let n of e)o.push(...gp(n,t));return Vr(o)}function gp(e,t={}){switch(e.type){case"delete":return A(e.children,{...t,strike:!0});case"emphasis":return A(e.children,{...t,italic:!0});case"footnoteReference":return[{text:`[${e.identifier}]`}];case"html":{let o=e.value.match(/^<mark>(.*)<\/mark>$/s);return o?[{text:o[1],...t,highlight:!0}]:[{text:e.value,code:!0}]}case"image":return qr(e);case"inlineCode":return[{text:e.value,...t,code:!0}];case"link":return[{type:"anchor",href:e.url,title:e.title==null?void 0:e.title,children:A(e.children,t)}];case"strong":return A(e.children,{...t,bold:!0});case"text":return[{text:e.value,...t}];case"linkReference":case"imageReference":throw new Error("linkReference and imageReference should be converted to link and image through our transformInlineLinks function");case"break":return[{text:`
3
+ `}];case"footnote":throw new Error("footnote is not supported yet")}ue(e)}function Qr(e){return[{type:"heading",level:e.depth,children:A(e.children)}]}function jr(e){return[{type:"html-block",html:e.value,children:[{text:""}]}]}function Xr(e,{depth:t,ordered:o,checked:r}){switch(e.type){case"paragraph":return r===!0||r===!1?[{type:"task-list-item",depth:t,checked:r,children:A(e.children)}]:o?[{type:"ordered-list-item",depth:t,children:A(e.children)}]:[{type:"unordered-list-item",depth:t,children:A(e.children)}];case"list":return dt(e,t+1);default:return yo(e)}}function Jr(e,t){let o=[];for(let r of e.children)o.push(...Xr(r,{...t,checked:e.checked}));return o}function dt(e,t=0){let o=[];for(let r of e.children)o.push(...Jr(r,{depth:t,ordered:!!e.ordered}));return o}function bp(e){return!(e.length!==3||!("text"in e[0])||e[0].text!==""||!("text"in e[2])||e[2].text!==""||!("type"in e[1])||e[1].type!=="image-inline")}var Ep="\xA0";function xp(e){return!(e.length!==1||!("text"in e[0])||e[0].text!==Ep)}function Yr(e){let t=A(e.children);return bp(t)?[{...t[1],type:"image-block"}]:xp(t)?[{type:"paragraph",children:[{text:""}]}]:[{type:"paragraph",children:t}]}function Zr(e){if(e.align==null)throw new Error("Expected an array of AlignType for table.align");return[{type:"table",columns:e.align.map(t=>({align:t||"left"})),children:e.children.map(yp)}]}function yp(e){if(e.type!=="tableRow")throw new Error("Expected a tableRow");return{type:"table-row",children:e.children.map(kp)}}function kp(e){if(e.type!=="tableCell")throw new Error("Expected a tableCell");return{type:"table-cell",children:[{type:"table-content",children:A(e.children)}]}}function en(){return[{type:"horizontal-rule",children:[{text:""}]}]}function Se(e){let t=[];for(let o of e)t.push(...yo(o));return t}function yo(e){switch(e.type){case"blockquote":return Br(e);case"code":return zr(e);case"definition":throw new Error('The type "definition" should not exist. See comments');case"footnoteDefinition":return Nr(e);case"heading":return Qr(e);case"html":return jr(e);case"list":return dt(e);case"paragraph":return Yr(e);case"table":return Zr(e);case"thematicBreak":return en();case"yaml":return[]}ue(e)}import{definitions as Tp}from"mdast-util-definitions";import{SKIP as tn,visit as vp}from"unist-util-visit";function on(e){let t=Tp(e);vp(e,(o,r,n)=>{let i=o,a=n;if(i.type==="definition"&&a!==null&&typeof r=="number")return a.children.splice(r,1),[tn,r];if(i.type==="imageReference"||i.type==="linkReference"){let l="identifier"in i&&typeof i.identifier=="string"?i.identifier:"",s=t(l);if(s&&a!==null&&typeof r=="number"){let c=i.type==="imageReference"?{type:"image",url:s.url,title:s.title,alt:i.alt}:{type:"link",url:s.url,title:s.title,children:i.children};return a.children[r]=c,[tn,r]}}})}var Mp=Ip().use(wp).use(Rr());function Pp(e){let t=Mp.parse(e);return on(t),t}function fe(e){let t=Pp(e);return t.children.length===0?[{type:"paragraph",children:[{text:""}]}]:Se(t.children)}function Cp(e){return e.type==="ordered-list-item"||e.type==="unordered-list-item"||e.type==="task-list-item"}function rn(e){let t=[],o=-1;for(let r of e){if(!Cp(r)){t.push(r),o=-1;continue}let n=r.depth>o+1?o+1:r.depth;t.push({...r,depth:n}),o=n}return t}function nn(e){if(e.type!=="code-block-line")throw new Error(`Expected all children of code-block to be a codeline but is ${JSON.stringify(e,null,2)}`);return e.children.map(t=>t.text).join("")}function an(e){let t=[],o=3;for(let r of e.children){let n=nn(r),i=n.match(/^([`]+)/);i&&(o=Math.max(o,i[1].length+1)),t.push(n)}return t.unshift(`${"`".repeat(o)}${e.language}`),t.push(`${"`".repeat(o)}`),`${t.join(`
5
4
  `)}
6
5
 
7
- `}function Jr(e){return e.url}function Xr(e){if(e.url.startsWith("$"))return"";let{hostname:t}=we(e.url);if(t.match(/[.]portive[.]com$/i)&&e.width&&e.height)return`${e.url}?size=${e.width}x${e.height}`}function Yr(e){if(e.width&&e.height&&e.srcWidth&&e.srcHeight)return`${e.url}#srcSize=${e.srcWidth}x${e.srcHeight}&size=${e.width}x${e.height}`}var Ep=[Xr,Yr,Jr];function pt(e){for(let t of Ep){let o=t(e);if(typeof o=="string")return o===""?"":`![${e.alt}](${o}${typeof e.title=="string"?` "${e.title}"`:""})`}throw new Error("Shouldn't get here")}function Zr(e){let t=pt(e);return t?`${t}
6
+ `}function ln(e){return e.url}function sn(e){if(e.url.startsWith("$"))return"";let{hostname:t}=Re(e.url);if(t.match(/[.]portive[.]com$/i)&&e.width&&e.height)return`${e.url}?size=${e.width}x${e.height}`}function mn(e){if(e.width&&e.height&&e.srcWidth&&e.srcHeight)return`${e.url}#srcSize=${e.srcWidth}x${e.srcHeight}&size=${e.width}x${e.height}`}var Sp=[sn,mn,ln];function ut(e){for(let t of Sp){let o=t(e);if(typeof o=="string")return o===""?"":`![${e.alt}](${o}${typeof e.title=="string"?` "${e.title}"`:""})`}throw new Error("Shouldn't get here")}function cn(e){let t=ut(e);return t?`${t}
8
7
 
9
- `:""}import{Element as vp,Text as wp}from"slate";function en(e,t){let o=t.filter(n=>!e.includes(n));return{orderedMarksToAdd:Pr(o)}}function tn(e,t){let o=[...e],r=e.filter(i=>!t.includes(i)),n=[];for(let i=0;i<e.length&&r.length!==0;i++){let a=o.pop();if(a===void 0)throw new Error("This shouldn't happen unless we made a mistake in the algorithm");n.push(a);let l=r.indexOf(a);l!==-1&&r.splice(l,1)}return{orderedMarksToRemove:n,nextOrderedMarks:o}}function fo(e,t){let{orderedMarksToRemove:o,nextOrderedMarks:r}=tn(e,t),{orderedMarksToAdd:n}=en(r,t);return{remove:o,add:n,nextOrderedMarks:[...r,...n]}}import{Element as yp}from"slate";function on({node:e,nextNode:t,nodes:o,index:r}){return!R(e)||!v(e)||e.code||!R(t)||!v(t)||e.code?!1:(o.splice(r,2,{text:`${e.text}${t.text}`}),!0)}function rn({node:e,nodes:t,prevNode:o,index:r}){if(!_(e)||e.type!=="anchor")return!1;let n=e.children[0];return R(n)&&v(n)?(e.children.splice(0,1),R(o)&&v(o)?o.text=`${o.text}${n.text}`:t.splice(r,0,{text:n.text}),!0):!1}function nn({node:e,nodes:t,nextNode:o,index:r}){if(!_(e)||e.type!=="anchor")return!1;let n=e.children[e.children.length-1];return R(n)&&v(n)?(e.children.splice(e.children.length-1,1),R(o)&&v(o)?o.text=`${n.text}${o.text}`:t.splice(r+1,0,{text:n.text}),!0):!1}function an({node:e}){return!_(e)||e.type!=="line"||e.children.length>0?!1:(e.children.push({text:""}),!0)}function ln({node:e,nodes:t,index:o}){if(!R(e)||v(e)||e.code)return!1;let r=e.text.match(/^(\s*)(.*?)(\s*)$/);if(!r||r[1].length===0&&r[3].length===0)return!1;let n=[{text:r[1]},{...e,text:r[2]},{text:r[3]}].filter(i=>i.text!=="");return t.splice(o,1,...n),!0}function sn({index:e,nodes:t,node:o,parent:r}){return e!==t.length-1||t.length<=1||!R(o)||!v(o)?!1:r&&_(r)&&r.type==="line"?(t.splice(t.length-1,1),!0):!1}function mn({index:e,nodes:t,node:o,parent:r}){return e!==0||t.length===0||!R(o)||!v(o)?!1:r&&_(r)&&r.type==="line"?(t.splice(0,1),!0):!1}var cn=[ln,rn,nn,on,mn,sn,an];function pn(e){for(let t of cn)if(t(e))return!0;return!1}var xp=72;function ho(e,t){let o=!1,r,n=0,i=(e.length+1)*xp;do{if(r=!1,n=n+1,n>i)throw new Error(`There have been ${n} normalization passes (72x the number of nodes at this level). This likely indicates a bug in the code.`);e:for(let a=0;a<e.length;a++){let l=e[a];if(_(l)&&ho(l.children,l)){r=!0,o=!0;break e}let s=e[a-1],m=e[a+1];if(pn({parent:t,node:l,prevNode:s,nextNode:m,index:a,nodes:e})){r=!0,o=!0;break e}}}while(r);return o}var dn=e=>e.map(t=>yp.isElement(t)&&t.type==="anchor"?{...t,children:dn(t.children)}:t);function un(e){let t={type:"line",children:dn(e)};return ho([t],void 0),t.children}import{Text as Tp}from"slate";function fn(e){let t=0;for(let o of e.text.matchAll(/[`]+/g))t=Math.max(t,o[0].length);return t===0?`\`${e.text.replace(/[`]/g,"\\`")}\``:`${"`".repeat(t+1)} ${e.text} ${"`".repeat(t+1)}`}function kp(e){return e.replace(/"/g,'\\"')}function hn(e){let t=po(e.children);return e.href.startsWith("$")?D(e.children,t,t):typeof e.title=="string"&&e.title.length>0?`[${D(e.children,t,t)}](${e.href} "${kp(e.title)}")`:`[${D(e.children,t,t)}](${e.href})`}function gn(e){return Cr(e.text)}function bn(e){if(Tp.isText(e))return e.code?fn(e):gn(e);switch(e.type){case"anchor":return hn(e);case"image-inline":return pt(e);default:me(e)}}function D(e,t=[],o=[]){let r=un(e),n=[],i=fo(t,co(r[0]));for(let a=0;a<r.length;a++){let l=r[a];if(wp.isText(l)&&v(l)){n.push(l.text);continue}n.push(mo(i.add)),n.push(bn(l));let s=Ip(r,a,o),m=fo(i.nextOrderedMarks,s);n.push(mo(m.remove)),i=m}return n.join("")}function Ip(e,t,o){for(let r=t+1;r<e.length;r++){let n=e[r];if(!v(n)&&!(vp.isElement(n)&&n.type==="image-inline"))return co(n)}return o}function xn(e){let t=[];return t.push(En(e.children[0])),t.push(Mp(e.columns)),e.children.slice(1).forEach(o=>{t.push(En(o))}),`${t.join(`
8
+ `:""}import{Element as Np,Text as Dp}from"slate";function pn(e,t){let o=t.filter(n=>!e.includes(n));return{orderedMarksToAdd:Hr(o)}}function dn(e,t){let o=[...e],r=e.filter(i=>!t.includes(i)),n=[];for(let i=0;i<e.length&&r.length!==0;i++){let a=o.pop();if(a===void 0)throw new Error("This shouldn't happen unless we made a mistake in the algorithm");n.push(a);let l=r.indexOf(a);l!==-1&&r.splice(l,1)}return{orderedMarksToRemove:n,nextOrderedMarks:o}}function ko(e,t){let{orderedMarksToRemove:o,nextOrderedMarks:r}=dn(e,t),{orderedMarksToAdd:n}=pn(r,t);return{remove:o,add:n,nextOrderedMarks:[...r,...n]}}import{Element as Lp}from"slate";function un({node:e,nextNode:t,nodes:o,index:r}){return!z(e)||!C(e)||e.code||!z(t)||!C(t)||e.code?!1:(o.splice(r,2,{text:`${e.text}${t.text}`}),!0)}function fn({node:e,nodes:t,prevNode:o,index:r}){if(!X(e)||e.type!=="anchor")return!1;let n=e.children[0];return z(n)&&C(n)?(e.children.splice(0,1),z(o)&&C(o)?o.text=`${o.text}${n.text}`:t.splice(r,0,{text:n.text}),!0):!1}function hn({node:e,nodes:t,nextNode:o,index:r}){if(!X(e)||e.type!=="anchor")return!1;let n=e.children[e.children.length-1];return z(n)&&C(n)?(e.children.splice(e.children.length-1,1),z(o)&&C(o)?o.text=`${n.text}${o.text}`:t.splice(r+1,0,{text:n.text}),!0):!1}function gn({node:e}){return!X(e)||e.type!=="line"||e.children.length>0?!1:(e.children.push({text:""}),!0)}function bn({node:e,nodes:t,index:o}){if(!z(e)||C(e)||e.code)return!1;let r=e.text.match(/^(\s*)(.*?)(\s*)$/);if(!r||r[1].length===0&&r[3].length===0)return!1;let n=[{text:r[1]},{...e,text:r[2]},{text:r[3]}].filter(i=>i.text!=="");return t.splice(o,1,...n),!0}function En({index:e,nodes:t,node:o,parent:r}){return e!==t.length-1||t.length<=1||!z(o)||!C(o)?!1:r&&X(r)&&r.type==="line"?(t.splice(t.length-1,1),!0):!1}function xn({index:e,nodes:t,node:o,parent:r}){return e!==0||t.length===0||!z(o)||!C(o)?!1:r&&X(r)&&r.type==="line"?(t.splice(0,1),!0):!1}var yn=[bn,fn,hn,un,xn,En,gn];function kn(e){for(let t of yn)if(t(e))return!0;return!1}var Rp=72;function To(e,t){let o=!1,r,n=0,i=(e.length+1)*Rp;do{if(r=!1,n=n+1,n>i)throw new Error(`There have been ${n} normalization passes (72x the number of nodes at this level). This likely indicates a bug in the code.`);e:for(let a=0;a<e.length;a++){let l=e[a];if(X(l)&&To(l.children,l)){r=!0,o=!0;break e}let s=e[a-1],c=e[a+1];if(kn({parent:t,node:l,prevNode:s,nextNode:c,index:a,nodes:e})){r=!0,o=!0;break e}}}while(r);return o}var Tn=e=>e.map(t=>Lp.isElement(t)&&t.type==="anchor"?{...t,children:Tn(t.children)}:t);function vn(e){let t={type:"line",children:Tn(e)};return To([t],void 0),t.children}import{Text as zp}from"slate";function wn(e){let t=0;for(let o of e.text.matchAll(/[`]+/g))t=Math.max(t,o[0].length);return t===0?`\`${e.text.replace(/[`]/g,"\\`")}\``:`${"`".repeat(t+1)} ${e.text} ${"`".repeat(t+1)}`}function Bp(e){return e.replace(/"/g,'\\"')}function In(e){let t=xo(e.children);return e.href.startsWith("$")?F(e.children,t,t):typeof e.title=="string"&&e.title.length>0?`[${F(e.children,t,t)}](${e.href} "${Bp(e.title)}")`:`[${F(e.children,t,t)}](${e.href})`}function Mn(e){return Ar(e.text)}function Pn(e){if(zp.isText(e))return e.code?wn(e):Mn(e);switch(e.type){case"anchor":return In(e);case"image-inline":return ut(e);default:ue(e)}}function F(e,t=[],o=[]){let r=vn(e),n=[],i=ko(t,Eo(r[0]));for(let a=0;a<r.length;a++){let l=r[a];if(Dp.isText(l)&&C(l)){n.push(l.text);continue}n.push(bo(i.add)),i.add.includes("highlight")&&n.push("<mark>"),n.push(Pn(l));let c=$p(r,a,o),m=ko(i.nextOrderedMarks,c);m.remove.includes("highlight")&&n.push("</mark>"),n.push(bo(m.remove)),i=m}return n.join("")}function $p(e,t,o){for(let r=t+1;r<e.length;r++){let n=e[r];if(!C(n)&&!(Np.isElement(n)&&n.type==="image-inline"))return Eo(n)}return o}function Sn(e){let t=[];return t.push(Cn(e.children[0])),t.push(Hp(e.columns)),e.children.slice(1).forEach(o=>{t.push(Cn(o))}),`${t.join(`
10
9
  `)}
11
10
 
12
- `}function Mp(e){return e.every(o=>o.align==="left")?`|${e.map(()=>"---").join("|")}|`:`|${e.map(o=>Pp(o.align)).join("|")}|`}function Pp(e){switch(e){case"left":return":---";case"center":return":---:";case"right":return"---:"}}function En(e){return mt(e,"table-row"),`|${e.children.map(Cp).join("|")}|`}function Cp(e){return mt(e,"table-cell"),kr(e.children.length===1,`Expected table-cell to have one child but is ${JSON.stringify(e.children)}`),e.children.map(Sp).join()}function Sp(e){return mt(e,"table-content"),D(e.children)}var go=4;function yn(e,t){switch(e.type){case"anchor":return`[${D(e.children)}](${e.href})`;case"block-quote":return`${dt(e.children).split(`
11
+ `}function Hp(e){return e.every(o=>o.align==="left")?`|${e.map(()=>"---").join("|")}|`:`|${e.map(o=>Ap(o.align)).join("|")}|`}function Ap(e){switch(e){case"left":return":---";case"center":return":---:";case"right":return"---:"}}function Cn(e){return pt(e,"table-row"),`|${e.children.map(Op).join("|")}|`}function Op(e){return pt(e,"table-cell"),Lr(e.children.length===1,`Expected table-cell to have one child but is ${JSON.stringify(e.children)}`),e.children.map(Up).join()}function Up(e){return pt(e,"table-content"),F(e.children)}var vo=4;function Rn(e,t){switch(e.type){case"anchor":return`[${F(e.children)}](${e.href})`;case"block-quote":return`${ft(e.children).split(`
13
12
  `).map(r=>`> ${r}`.trim()).join(`
14
13
  `)}
15
14
 
16
- `;case"heading":return`${"#".repeat(e.level)} ${D(e.children)}
15
+ `;case"heading":return`${"#".repeat(e.level)} ${F(e.children)}
17
16
 
18
17
  `;case"horizontal-rule":return`---
19
18
 
20
- `;case"paragraph":return`${D(e.children)}
19
+ `;case"paragraph":return`${F(e.children)}
21
20
 
22
- `;case"table":return xn(e);case"table-row":case"table-cell":case"table-content":throw new Error(`Table elements should only be present as children of table which should be handled by serializeTable. Got ${e.type} may indicate an error in normalization.`);case"unordered-list-item":return`${" ".repeat(e.depth*go)}- ${D(e.children)}
23
- `;case"ordered-list-item":return`${" ".repeat(e.depth*go)}${t[e.depth]}. ${D(e.children)}
24
- `;case"task-list-item":{let o=" ".repeat(e.depth*go),r=D(e.children);return r.trim()===""&&(r="&#32;"),`${o}- [${e.checked?"x":" "}] ${r}
25
- `}case"image-block":return Zr(e);case"code-block":return jr(e);case"code-block-line":throw new Error("Code block line elements should only be present as children of code-block which should be handled by serializeCodeBlock. Got code-block-line may indicate an error in normalization.")}me(e)}function dt(e){let t=[],o=[];for(let n=0;n<e.length;n++){let i=e[n],a=n<e.length-1?e[n+1]:null;i.type==="ordered-list-item"?(o[i.depth]=(o[i.depth]||0)+1,o=o.slice(0,i.depth+1)):i.type==="unordered-list-item"||i.type==="task-list-item"?o=o.slice(0,i.depth):o=[];let l=yn(i,o);(i.type==="ordered-list-item"||i.type==="unordered-list-item"||i.type==="task-list-item")&&(!a||a.type!=="ordered-list-item"&&a.type!=="unordered-list-item"&&a.type!=="task-list-item")&&(l=l.replace(/\n$/,`
21
+ `;case"table":return Sn(e);case"table-row":case"table-cell":case"table-content":throw new Error(`Table elements should only be present as children of table which should be handled by serializeTable. Got ${e.type} may indicate an error in normalization.`);case"unordered-list-item":return`${" ".repeat(e.depth*vo)}- ${F(e.children)}
22
+ `;case"ordered-list-item":return`${" ".repeat(e.depth*vo)}${t[e.depth]}. ${F(e.children)}
23
+ `;case"task-list-item":{let o=" ".repeat(e.depth*vo),r=F(e.children);return r.trim()===""&&(r="&#32;"),`${o}- [${e.checked?"x":" "}] ${r}
24
+ `}case"image-block":return cn(e);case"code-block":return an(e);case"code-block-line":throw new Error("Code block line elements should only be present as children of code-block which should be handled by serializeCodeBlock. Got code-block-line may indicate an error in normalization.");case"html-block":return`${e.html}
26
25
 
27
- `)),t.push(l)}let r=t.join("");return r.trim()===""?"":Lp(Rp(r)).trim()}function Rp(e){return e.replace(/^\n\n/g,`&nbsp;
26
+ `}ue(e)}function ft(e){let t=[],o=[];for(let n=0;n<e.length;n++){let i=e[n],a=n<e.length-1?e[n+1]:null;i.type==="ordered-list-item"?(o[i.depth]=(o[i.depth]||0)+1,o=o.slice(0,i.depth+1)):i.type==="unordered-list-item"||i.type==="task-list-item"?o=o.slice(0,i.depth):o=[];let l=Rn(i,o);(i.type==="ordered-list-item"||i.type==="unordered-list-item"||i.type==="task-list-item")&&(!a||a.type!=="ordered-list-item"&&a.type!=="unordered-list-item"&&a.type!=="task-list-item")&&(l=l.replace(/\n$/,`
28
27
 
29
- `)}function Lp(e){return e.replace(/(\n{4,})/g,t=>{let o=t.length,r=Math.floor((o-2)/2);return`
28
+ `)),t.push(l)}let r=t.join("");return r.trim()===""?"":Vp(Fp(r)).trim()}function Fp(e){return e.replace(/^\n\n/g,`&nbsp;
29
+
30
+ `)}function Vp(e){return e.replace(/(\n{4,})/g,t=>{let o=t.length,r=Math.floor((o-2)/2);return`
30
31
 
31
32
  `+Array(r).fill("&nbsp;").join(`
32
33
 
33
34
  `)+`
34
35
 
35
- `})}function Qe(e){let t=qr(e);return dt(t)}var bo={ja:{bold:"\u592A\u5B57",italic:"\u659C\u4F53",strike:"\u53D6\u308A\u6D88\u3057\u7DDA",inlineCode:"\u30A4\u30F3\u30E9\u30A4\u30F3\u30B3\u30FC\u30C9",underline:"\u4E0B\u7DDA",increaseDepth:"\u968E\u5C64\u3092\u6DF1\u304F\u3059\u308B",decreaseDepth:"\u968E\u5C64\u3092\u6D45\u304F\u3059\u308B",heading1:"\u898B\u51FA\u30571",heading2:"\u898B\u51FA\u30572",heading3:"\u898B\u51FA\u30573",normal:"\u6A19\u6E96",paragraph:"\u6BB5\u843D",paragraphStyle:"\u6BB5\u843D\u30B9\u30BF\u30A4\u30EB",bulletList:"\u7B87\u6761\u66F8\u304D",numberedList:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",checkList:"\u30C1\u30A7\u30C3\u30AF\u30EA\u30B9\u30C8",list:"\u30EA\u30B9\u30C8",linkUrl:"\u30EA\u30F3\u30AF\u306EURL",tooltipText:"\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7\u30C6\u30AD\u30B9\u30C8",tooltipHint:"\u30DE\u30A6\u30B9\u30DB\u30D0\u30FC\u6642\u306B\u8868\u793A\u3055\u308C\u308B\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7",apply:"\u9069\u7528",cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",insertLink:"\u30EA\u30F3\u30AF",quote:"\u5F15\u7528",insertTable:"\u8868",insertImage:"\u753B\u50CF",insertImageFromUrl:"\u753B\u50CF",insert:"\u633F\u5165",format:"\u66F8\u5F0F",imageUrlRequired:"\u753B\u50CFURL\uFF08\u5FC5\u9808\uFF09\uFF1A",altText:"\u4EE3\u66FF\u30C6\u30AD\u30B9\u30C8\uFF1A",title:"\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7\uFF1A",imageDescription:"\u753B\u50CF\u306E\u8AAC\u660E",imageTitle:"\u753B\u50CF\u306E\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7",switchToVisualEditor:"\u30D3\u30B8\u30E5\u30A2\u30EB\u30A8\u30C7\u30A3\u30BF\u306B\u5207\u308A\u66FF\u3048",switchToRawMarkdown:"\u30DE\u30FC\u30AF\u30C0\u30A6\u30F3\u8868\u793A\u306B\u5207\u308A\u66FF\u3048",codeBlock:"\u30B3\u30FC\u30C9\u30D6\u30ED\u30C3\u30AF",increaseQuoteDepth:"\u5F15\u7528\u3092\u91CD\u306D\u308B",register:"\u767B\u9332",imageSourceUrl:"URL",imageSourceFile:"\u30D5\u30A1\u30A4\u30EB",selectFile:"\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E",uploading:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D..."},en:{bold:"Bold",italic:"Italic",strike:"Strikethrough",inlineCode:"Inline Code",underline:"Underline",increaseDepth:"Increase Depth",decreaseDepth:"Decrease Depth",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",normal:"Normal",paragraph:"Paragraph",paragraphStyle:"Paragraph Style",bulletList:"Bullet List",numberedList:"Numbered List",checkList:"Check List",list:"List",linkUrl:"Link URL",tooltipText:"Tooltip Text",tooltipHint:"Tooltip shown on mouse hover",apply:"Apply",cancel:"Cancel",insertLink:"Link",quote:"Quote",insertTable:"Table",insertImage:"Image",insertImageFromUrl:"Image",insert:"Insert",format:"Format",imageUrlRequired:"Image URL (required):",altText:"Alt Text:",title:"tooltip:",imageDescription:"Description of the image",imageTitle:"tooltip",switchToVisualEditor:"Switch to visual editor",switchToRawMarkdown:"Switch to raw markdown",codeBlock:"Code Block",increaseQuoteDepth:"Increase Quote Depth",register:"Register",imageSourceUrl:"URL",imageSourceFile:"File",selectFile:"Select File",uploading:"Uploading..."}},kn=()=>{try{if(typeof window<"u"&&window.navigator)return window.navigator.language.split("-")[0]}catch{}return"en"},f=e=>{let t=kn();return bo[t==="ja"?"ja":"en"][e]},Eo=e=>{let t=kn();return Object.keys(bo[t==="ja"?"ja":"en"]).find(r=>bo[t==="ja"?"ja":"en"][r]===e)||""};var x=e=>({fn:e});import{useEffect as $p,useMemo as Ln}from"react";import{Editor as Ap}from"slate";import{useSlateStatic as Hp}from"slate-react";function J(e){return!!e}function Tn(e,t){let o=t.map(r=>r.editableProps?.decorate).filter(J);return function(r){let n=[];for(let i of o){let a=i(r);n.push(...a)}return e&&n.push(...e(r)),n}}import{Editable as zp}from"slate-react";import{jsx as Bp}from"react/jsx-runtime";function vn(e){let t=e.map(r=>r.renderEditable).filter(J),o=r=>Bp(zp,{...r});for(let r of t){let n=o;o=i=>r({attributes:i,Editable:n})}return o}function ut(e,t){let o=[];for(let r of e){let n=r.editableProps?.[t];n&&o.push(n)}return o}function ft(e,t){return function(o){for(let r of e)if(r(o))return;t?.(o)}}var wn=(e,t)=>{let o=ut(t,"onKeyDown");return ft(o,e)},In=(e,t)=>{let o=ut(t,"onKeyUp");return ft(o,e)},Mn=(e,t)=>{let o=ut(t,"onPaste");return ft(o,e)},Pn=(e,t)=>{let o=ut(t,"onDrop");return ft(o,e)};function Cn(e,t){let o=t.map(r=>r.editableProps?.renderElement).filter(J);return function(n){for(let i of o){let a=i(n);if(a)return a}if(e===void 0)throw new Error(`Element with type ${n.element.type} not handled. Note that renderElement is not defined on SinkEditable so this is only the result of checking the Sink Plugins.`);return e(n)}}import{cloneElement as Np}from"react";function Sn(e,t){if(e===void 0)throw new Error("renderLeaf was not defined on SinkEditable");let o=t.map(r=>r.editableProps?.renderLeaf).filter(J).reverse();return function(r){let n=e({...r,attributes:{}});for(let i of o){let a=i({...r,children:n});a&&(n=a)}return n=Np(n,r.attributes),n}}function Rn(e,t){if(e)return e;let o=t.map(r=>r.editableProps?.renderPlaceholder).filter(J);if(o.length!==0)return function(r){if(o.length>1)throw new Error(`Only one plugin can define renderPlaceholder but there are ${o.length}`);let n=o[0];if(n==null)throw new Error("Expected fn to be defined");return n(r)}}import Dp from"@emotion/styled";var je=Dp("div")`
36
+ `})}function et(e){let t=rn(e);return ft(t)}var wo={ja:{bold:"\u592A\u5B57",italic:"\u659C\u4F53",strike:"\u53D6\u308A\u6D88\u3057\u7DDA",inlineCode:"\u30A4\u30F3\u30E9\u30A4\u30F3\u30B3\u30FC\u30C9",underline:"\u4E0B\u7DDA",highlight:"\u30CF\u30A4\u30E9\u30A4\u30C8",increaseDepth:"\u968E\u5C64\u3092\u6DF1\u304F\u3059\u308B",decreaseDepth:"\u968E\u5C64\u3092\u6D45\u304F\u3059\u308B",heading1:"\u898B\u51FA\u30571",heading2:"\u898B\u51FA\u30572",heading3:"\u898B\u51FA\u30573",normal:"\u6A19\u6E96",paragraph:"\u6BB5\u843D",paragraphStyle:"\u6BB5\u843D\u30B9\u30BF\u30A4\u30EB",bulletList:"\u7B87\u6761\u66F8\u304D",numberedList:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",checkList:"\u30C1\u30A7\u30C3\u30AF\u30EA\u30B9\u30C8",list:"\u30EA\u30B9\u30C8",linkUrl:"\u30EA\u30F3\u30AF\u306EURL",linkText:"\u30EA\u30F3\u30AF\u30C6\u30AD\u30B9\u30C8",linkTextHint:"\u30EA\u30F3\u30AF\u3068\u3057\u3066\u8868\u793A\u3055\u308C\u308B\u30C6\u30AD\u30B9\u30C8",tooltipText:"\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7\u30C6\u30AD\u30B9\u30C8",tooltipHint:"\u30DE\u30A6\u30B9\u30DB\u30D0\u30FC\u6642\u306B\u8868\u793A\u3055\u308C\u308B\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7",apply:"\u9069\u7528",cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",insertLink:"\u30EA\u30F3\u30AF",quote:"\u5F15\u7528",insertTable:"\u8868",insertImage:"\u753B\u50CF",insertImageFromUrl:"\u753B\u50CF",insert:"\u633F\u5165",format:"\u66F8\u5F0F",imageUrlRequired:"\u753B\u50CFURL\uFF08\u5FC5\u9808\uFF09\uFF1A",altText:"\u4EE3\u66FF\u30C6\u30AD\u30B9\u30C8\uFF1A",title:"\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7\uFF1A",imageDescription:"\u753B\u50CF\u306E\u8AAC\u660E",imageTitle:"\u753B\u50CF\u306E\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7",switchToVisualEditor:"\u30D3\u30B8\u30E5\u30A2\u30EB\u30A8\u30C7\u30A3\u30BF\u306B\u5207\u308A\u66FF\u3048",switchToRawMarkdown:"\u30DE\u30FC\u30AF\u30C0\u30A6\u30F3\u8868\u793A\u306B\u5207\u308A\u66FF\u3048",codeBlock:"\u30B3\u30FC\u30C9\u30D6\u30ED\u30C3\u30AF",increaseQuoteDepth:"\u5F15\u7528\u3092\u91CD\u306D\u308B",register:"\u767B\u9332",imageSourceUrl:"URL",imageSourceFile:"\u30D5\u30A1\u30A4\u30EB",selectFile:"\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E",uploading:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D..."},en:{bold:"Bold",italic:"Italic",strike:"Strikethrough",inlineCode:"Inline Code",underline:"Underline",highlight:"Highlight",increaseDepth:"Increase Depth",decreaseDepth:"Decrease Depth",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",normal:"Normal",paragraph:"Paragraph",paragraphStyle:"Paragraph Style",bulletList:"Bullet List",numberedList:"Numbered List",checkList:"Check List",list:"List",linkUrl:"Link URL",linkText:"Link Text",linkTextHint:"Text displayed as the link",tooltipText:"Tooltip Text",tooltipHint:"Tooltip shown on mouse hover",apply:"Apply",cancel:"Cancel",insertLink:"Link",quote:"Quote",insertTable:"Table",insertImage:"Image",insertImageFromUrl:"Image",insert:"Insert",format:"Format",imageUrlRequired:"Image URL (required):",altText:"Alt Text:",title:"tooltip:",imageDescription:"Description of the image",imageTitle:"tooltip",switchToVisualEditor:"Switch to visual editor",switchToRawMarkdown:"Switch to raw markdown",codeBlock:"Code Block",increaseQuoteDepth:"Increase Quote Depth",register:"Register",imageSourceUrl:"URL",imageSourceFile:"File",selectFile:"Select File",uploading:"Uploading..."}},Ln=()=>{try{if(typeof window<"u"&&window.navigator)return window.navigator.language.split("-")[0]}catch{}return"en"},f=e=>{let t=Ln();return wo[t==="ja"?"ja":"en"][e]},Io=e=>{let t=Ln();return Object.keys(wo[t==="ja"?"ja":"en"]).find(r=>wo[t==="ja"?"ja":"en"][r]===e)||""};var x=e=>({fn:e});import{useEffect as qp,useMemo as Fn}from"react";import{Editor as Qp}from"slate";import{useSlateStatic as jp}from"slate-react";function ee(e){return!!e}function Bn(e,t){let o=t.map(r=>r.editableProps?.decorate).filter(ee);return function(r){let n=[];for(let i of o){let a=i(r);n.push(...a)}return e&&n.push(...e(r)),n}}import{Editable as Kp}from"slate-react";import{jsx as Wp}from"react/jsx-runtime";function zn(e){let t=e.map(r=>r.renderEditable).filter(ee),o=r=>Wp(Kp,{...r});for(let r of t){let n=o;o=i=>r({attributes:i,Editable:n})}return o}function ht(e,t){let o=[];for(let r of e){let n=r.editableProps?.[t];n&&o.push(n)}return o}function gt(e,t){return function(o){for(let r of e)if(r(o))return;t?.(o)}}var Nn=(e,t)=>{let o=ht(t,"onKeyDown");return gt(o,e)},Dn=(e,t)=>{let o=ht(t,"onKeyUp");return gt(o,e)},$n=(e,t)=>{let o=ht(t,"onPaste");return gt(o,e)},Hn=(e,t)=>{let o=ht(t,"onDrop");return gt(o,e)};function An(e,t){let o=t.map(r=>r.editableProps?.renderElement).filter(ee);return function(n){for(let i of o){let a=i(n);if(a)return a}if(e===void 0)throw new Error(`Element with type ${n.element.type} not handled. Note that renderElement is not defined on SinkEditable so this is only the result of checking the Sink Plugins.`);return e(n)}}import{cloneElement as _p}from"react";function On(e,t){if(e===void 0)throw new Error("renderLeaf was not defined on SinkEditable");let o=t.map(r=>r.editableProps?.renderLeaf).filter(ee).reverse();return function(r){let n=e({...r,attributes:{}});for(let i of o){let a=i({...r,children:n});a&&(n=a)}return n=_p(n,r.attributes),n}}function Un(e,t){if(e)return e;let o=t.map(r=>r.editableProps?.renderPlaceholder).filter(ee);if(o.length!==0)return function(r){if(o.length>1)throw new Error(`Only one plugin can define renderPlaceholder but there are ${o.length}`);let n=o[0];if(n==null)throw new Error("Expected fn to be defined");return n(r)}}import Gp from"@emotion/styled";var tt=Gp("div")`
36
37
  -webkit-font-smoothing: antialiased;
37
38
  -moz-osx-font-smoothing: grayscale;
38
39
  font-size: 16px;
39
40
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
40
41
  Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
41
42
  box-sizing: border-box;
42
- `;import{jsx as Op}from"react/jsx-runtime";function zn(e){let t=Hp();$p(()=>{Ap.normalize(t,{force:!0})},[]);let{plugins:o}=t.sink,r=Ln(()=>({...e,decorate:Tn(e.decorate,o),renderElement:Cn(e.renderElement,o),renderLeaf:Sn(e.renderLeaf,o),renderPlaceholder:Rn(e.renderPlaceholder,o),onKeyDown:wn(e.onKeyDown,o),onKeyUp:In(e.onKeyUp,o),onPaste:Mn(e.onPaste,o),onDrop:Pn(e.onDrop,o)}),Object.values(e)),n=Ln(()=>vn(o),[o]);return Op(n,{...r})}function Ie(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(a){for(let l of n){let s=l.editor?.[t]?.(a);if(typeof s=="boolean")return s}return r(a)}}function oe(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(...a){let l=!1,s=[];for(let m of n){let c=m.editor?.[t]?.(...a);if(typeof c=="function")s.push(c);else if(c===!0){l=!0;break}}l||r(...a),s.forEach(m=>m())}}function Bn(e){return(t,o)=>{let r=t,n=e.map(i=>i(r,o,{createPolicy:a=>a}));return r.sink={plugins:n},r.isMaster="isMaster"in r?r.isMaster:()=>!1,r.isSlave="isSlave"in r?r.isSlave:()=>!1,r.isStandalone="isStandalone"in r?r.isStandalone:()=>!1,Object.assign(r,{normalizeNode:oe(r,"normalizeNode",n),deleteBackward:oe(r,"deleteBackward",n),deleteForward:oe(r,"deleteForward",n),deleteFragment:oe(r,"deleteFragment",n),insertBreak:oe(r,"insertBreak",n),insertFragment:oe(r,"insertFragment",n),insertNode:oe(r,"insertNode",n),insertText:oe(r,"insertText",n),isInline:Ie(r,"isInline",n),isVoid:Ie(r,"isVoid",n),isMaster:Ie(r,"isMaster",n),isSlave:Ie(r,"isSlave",n),isStandalone:Ie(r,"isStandalone",n)}),r}}var Nn=e=>{let t=e.map(n=>n.fn);return{withSink:Bn(t),SinkEditable:zn}};import{Element as Up}from"slate";import{ReactEditor as Fp}from"slate-react";function Dn(e,t){return Up.isElement(t)?Fp.findPath(e,t):t}function d(e,t){return e.bind(null,t)}function $(e,t,o){return e.bind(null,t,o)}var Vp=/mac os x|macintosh/i,Je;function ht(){if(Je!==void 0)return Je;try{let{userAgent:e}=window.navigator;Je=Vp.test(e)}catch{Je=!1}return Je}function he(e){e.preventDefault(),e.stopPropagation()}import{Editor as Hn,Path as Kp}from"slate";import{Element as $n}from"slate";function An(e){if(typeof e=="function")return e;if(typeof e=="string")return t=>$n.isElement(t)&&t.type===e;if(Array.isArray(e))return t=>$n.isElement(t)&&e.includes(t.type);throw new Error(`Expected matchNode to be a function, string or array but is ${e}`)}function g(e,t,{at:o=e.selection}={}){if(o===null)return;let r=Dn(e,o),n=An(t);if(Kp.isPath(r)){let i=Hn.node(e,r);if(i&&n(i[0]))return i}return Hn.above(e,{at:r,match:n})}function Me(...e){return g(...e)?.[1]}import{jsx as _p}from"react/jsx-runtime";var b=({strokeWidth:e=1.5,...t})=>_p("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",strokeWidth:e,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...t});import{Range as Wp}from"slate";function ge(e){return e==null?!1:Wp.isCollapsed(e)}import{Element as On}from"slate";function gt(e){return Array.isArray(e)?t=>On.isElement(t)&&e.includes(t.type):t=>On.isElement(t)&&e==t.type}import{Editor as Gp}from"slate";function Un(e,t){let{selection:o}=e;if(!ge(o))return!1;let r=g(e,t,{at:o});return!!r&&Gp.isEnd(e,o.anchor,r[1])}import{Editor as wk}from"slate";import{Editor as qp}from"slate";function be(e,t){let{selection:o}=e;if(!ge(o))return!1;let r=g(e,t,{at:o});return!!r&&qp.isStart(e,o.anchor,r[1])}import{isHotkey as Fn}from"is-hotkey";import{Editor as xo,Element as Qp,Range as jp,Transforms as Jp}from"slate";var Xp=Fn(" "),Yp=Fn("SHIFT+SPACE");function Vn(e,t){return o=>{if(!Xp(o.nativeEvent)&&!Yp(o.nativeEvent))return!1;let{selection:r}=e;if(r===null||jp.isExpanded(r))return!1;let n=g(e,m=>Qp.isElement(m)&&e.convertElement.isConvertibleElement(m));if(!n)return!1;let i={anchor:xo.start(e,n[1]),focus:r.focus},a=xo.string(e,i),l=t[a];if(!l)return!1;he(o);let s={anchor:xo.start(e,n[1]),focus:r.focus};return Jp.delete(e,{at:s}),l(),!0}}import{isHotkey as Zp}from"is-hotkey";function Kn(e){let t=e.replace(/\bsuper\b/g,ht()?"cmd+alt":"ctrl+shift");return Zp(t)}function P(e){let t=null;return function(r){t==null&&(t=Object.entries(e).map(([n,i])=>[Kn(n),i]));for(let[n,i]of t)if(n(r.nativeEvent)){let a=i();if(a===!0||a===void 0)return r.preventDefault(),r.stopPropagation(),!0}return!1}}import{Editor as ed,Transforms as _n}from"slate";function Wn(e,t){ed.withoutNormalizing(e,()=>{_n.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:"123"},{at:t}),_n.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:null},{at:t})})}import{Editor as Gn}from"slate";function pe(e,t,o){let[,r]=t,n=Gn.previous(e,{at:r});if(n&&o(n,t))return!0;let i=Gn.next(e,{at:r});return!!(i&&o(t,i))}import{Editor as qn,Transforms as Qn}from"slate";function X(e,t){Qn.select(e,qn.start(e,t))}function jn(e,t){Qn.select(e,qn.end(e,t))}function Jn(e,t){return typeof t!="function"?t:t(e)}import{Editor as yo,Element as td,Path as od,Transforms as Xe}from"slate";function bt(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=g(e,n=>td.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;yo.withoutNormalizing(e,()=>{Xe.insertNodes(e,t,{at:o}),n&&(Xe.select(e,n),Xe.move(e))})}else{let n=od.next(r[1]);yo.withoutNormalizing(e,()=>{Xe.insertNodes(e,t,{at:n}),Xe.select(e,yo.start(e,n))})}return!0}import{Editor as Xn,Transforms as Yn}from"slate";function Ye(e,t,o){Xn.withoutNormalizing(e,()=>{let r=Xn.node(e,o),n=Jn(r[0],t);Yn.wrapNodes(e,n,{at:o}),Yn.unwrapNodes(e,{at:[...o,0]})})}import{Editor as rd,Transforms as nd}from"slate";function Et(e,t,o){let r=Array.from(rd.nodes(e,o));if(r.length===0)return!1;for(let n of r){let[i]=n;nd.setNodes(e,t(i),{at:n[1]})}return!0}function Zn(e,t){let o=t.clipboardData,{types:r}=o;if(r.length>1||r[0]!=="text/plain")return!1;let n=o.getData("text/plain");return id(n)?(t.preventDefault(),t.stopPropagation(),e.anchor.insertLink(n),!0):!1}function id(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"||t.protocol==="mailto:"}import{Transforms as ad}from"slate";function ei(e,{href:t,title:o},{at:r}){let n=g(e,"anchor",{at:r});return n?(ad.setNodes(e,{href:t,title:o},{at:n[1]}),!0):!1}import{Editor as xt,Range as ld,Text as sd,Transforms as ko}from"slate";function ti(e,t,o=t,{select:r=!0}={}){let n=e.selection||{anchor:xt.start(e,[0]),focus:xt.start(e,[0])};if(ld.isCollapsed(n)){if(ko.insertNodes(e,{type:"anchor",href:t,children:[{text:o}]},{select:r,at:n}),r&&e.selection){let i=xt.node(e,e.selection);ko.select(e,i[1])}}else ko.wrapNodes(e,{type:"anchor",href:t,children:[]},{split:!0,match:i=>sd.isText(i)||xt.isInline(e,i)})}import{Transforms as md}from"slate";function oi(e,{at:t}){let o=g(e,"anchor",{at:t});return o?(md.unwrapNodes(e,{at:o[1]}),!0):!1}function ri(e){return{insertLink:d(ti,e),removeLink:d(oi,e),editLink:d(ei,e)}}import{Element as ni,Transforms as cd}from"slate";function ii(e,t){if(!ni.isElement(t[0])||t[0].type!=="anchor")return!1;let o=t[0].children;for(let r=0;r<o.length;r++){let n=o[r];if(!(!ni.isElement(n)||n.type!=="anchor"))return cd.unwrapNodes(e,{at:[...t[1],r]}),!0}return!1}import{clsx as Yd}from"clsx";import{useEffect as Zd,useRef as Qi}from"react";import{useSelected as eu,useSlate as tu}from"slate-react";import{createContext as li,useState as dd}from"react";import{createPortal as pd}from"react-dom";function ai({children:e}){return pd(e,document.body)}import{jsx as To,jsxs as fd}from"react/jsx-runtime";var vo=li({}),ud=li({});function si({children:e}){let[t,o]=dd({});function r(i){o(a=>({...a,[i.type]:i}))}function n(i){o(a=>{let l={...a};return delete l[i],l})}return fd(vo.Provider,{value:{layers:t,setLayers:o,openLayer:r,closeLayer:n},children:[e,Object.entries(t).map(([,i])=>To(ai,{children:To(ud.Provider,{value:i,children:To(i.Component,{})})},i.type))]})}import{useContext as hd}from"react";function S(e){let{openLayer:t,closeLayer:o,layers:r}=hd(vo);function n(a){t({type:e,Component:a})}function i(){o(e)}return{open:n,close:i,layer:r[e],type:e}}import yt from"@emotion/styled";var mi=yt("a")`
43
+ `;import{jsx as Xp}from"react/jsx-runtime";function Vn(e){let t=jp();qp(()=>{Qp.normalize(t,{force:!0})},[]);let{plugins:o}=t.sink,r=Fn(()=>({...e,decorate:Bn(e.decorate,o),renderElement:An(e.renderElement,o),renderLeaf:On(e.renderLeaf,o),renderPlaceholder:Un(e.renderPlaceholder,o),onKeyDown:Nn(e.onKeyDown,o),onKeyUp:Dn(e.onKeyUp,o),onPaste:$n(e.onPaste,o),onDrop:Hn(e.onDrop,o)}),Object.values(e)),n=Fn(()=>zn(o),[o]);return Xp(n,{...r})}function Le(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(a){for(let l of n){let s=l.editor?.[t]?.(a);if(typeof s=="boolean")return s}return r(a)}}function ie(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(...a){let l=!1,s=[];for(let c of n){let m=c.editor?.[t]?.(...a);if(typeof m=="function")s.push(m);else if(m===!0){l=!0;break}}l||r(...a),s.forEach(c=>c())}}function Kn(e){return(t,o)=>{let r=t,n=e.map(i=>i(r,o,{createPolicy:a=>a}));return r.sink={plugins:n},r.isMaster="isMaster"in r?r.isMaster:()=>!1,r.isSlave="isSlave"in r?r.isSlave:()=>!1,r.isStandalone="isStandalone"in r?r.isStandalone:()=>!1,Object.assign(r,{normalizeNode:ie(r,"normalizeNode",n),deleteBackward:ie(r,"deleteBackward",n),deleteForward:ie(r,"deleteForward",n),deleteFragment:ie(r,"deleteFragment",n),insertBreak:ie(r,"insertBreak",n),insertFragment:ie(r,"insertFragment",n),insertNode:ie(r,"insertNode",n),insertText:ie(r,"insertText",n),isInline:Le(r,"isInline",n),isVoid:Le(r,"isVoid",n),isMaster:Le(r,"isMaster",n),isSlave:Le(r,"isSlave",n),isStandalone:Le(r,"isStandalone",n)}),r}}var Wn=e=>{let t=e.map(n=>n.fn);return{withSink:Kn(t),SinkEditable:Vn}};import{Element as Jp}from"slate";import{ReactEditor as Yp}from"slate-react";function _n(e,t){return Jp.isElement(t)?Yp.findPath(e,t):t}function u(e,t){return e.bind(null,t)}function V(e,t,o){return e.bind(null,t,o)}var Zp=/mac os x|macintosh/i,ot;function bt(){if(ot!==void 0)return ot;try{let{userAgent:e}=window.navigator;ot=Zp.test(e)}catch{ot=!1}return ot}function ye(e){e.preventDefault(),e.stopPropagation()}import{Editor as Qn,Path as ed}from"slate";import{Element as Gn}from"slate";function qn(e){if(typeof e=="function")return e;if(typeof e=="string")return t=>Gn.isElement(t)&&t.type===e;if(Array.isArray(e))return t=>Gn.isElement(t)&&e.includes(t.type);throw new Error(`Expected matchNode to be a function, string or array but is ${e}`)}function b(e,t,{at:o=e.selection}={}){if(o===null)return;let r=_n(e,o),n=qn(t);if(ed.isPath(r)){let i=Qn.node(e,r);if(i&&n(i[0]))return i}return Qn.above(e,{at:r,match:n})}function Be(...e){return b(...e)?.[1]}import{jsx as td}from"react/jsx-runtime";var y=({strokeWidth:e=1.5,...t})=>td("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",strokeWidth:e,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...t});import{Range as od}from"slate";function ae(e){return e==null?!1:od.isCollapsed(e)}import{Element as jn}from"slate";function Et(e){return Array.isArray(e)?t=>jn.isElement(t)&&e.includes(t.type):t=>jn.isElement(t)&&e==t.type}import{Editor as rd}from"slate";function Xn(e,t){let{selection:o}=e;if(!ae(o))return!1;let r=b(e,t,{at:o});return!!r&&rd.isEnd(e,o.anchor,r[1])}import{Editor as Vk}from"slate";import{Editor as nd}from"slate";function ke(e,t){let{selection:o}=e;if(!ae(o))return!1;let r=b(e,t,{at:o});return!!r&&nd.isStart(e,o.anchor,r[1])}import{isHotkey as Jn}from"is-hotkey";import{Editor as Mo,Element as id,Range as ad,Transforms as ld}from"slate";var sd=Jn(" "),md=Jn("SHIFT+SPACE");function Yn(e,t){return o=>{if(!sd(o.nativeEvent)&&!md(o.nativeEvent))return!1;let{selection:r}=e;if(r===null||ad.isExpanded(r))return!1;let n=b(e,c=>id.isElement(c)&&e.convertElement.isConvertibleElement(c));if(!n)return!1;let i={anchor:Mo.start(e,n[1]),focus:r.focus},a=Mo.string(e,i),l=t[a];if(!l)return!1;ye(o);let s={anchor:Mo.start(e,n[1]),focus:r.focus};return ld.delete(e,{at:s}),l(),!0}}import{isHotkey as cd}from"is-hotkey";function Zn(e){let t=e.replace(/\bsuper\b/g,bt()?"cmd+alt":"ctrl+shift");return cd(t)}function B(e){let t=null;return function(r){t==null&&(t=Object.entries(e).map(([n,i])=>[Zn(n),i]));for(let[n,i]of t)if(n(r.nativeEvent)){let a=i();if(a===!0||a===void 0)return r.preventDefault(),r.stopPropagation(),!0}return!1}}import{Editor as pd,Transforms as ei}from"slate";function ti(e,t){pd.withoutNormalizing(e,()=>{ei.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:"123"},{at:t}),ei.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:null},{at:t})})}import{Editor as oi}from"slate";function he(e,t,o){let[,r]=t,n=oi.previous(e,{at:r});if(n&&o(n,t))return!0;let i=oi.next(e,{at:r});return!!(i&&o(t,i))}import{Editor as ri,Transforms as ni}from"slate";function K(e,t){ni.select(e,ri.start(e,t))}function ii(e,t){ni.select(e,ri.end(e,t))}function ai(e,t){return typeof t!="function"?t:t(e)}import{Editor as Po,Element as dd,Path as ud,Transforms as rt}from"slate";function xt(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=b(e,n=>dd.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;Po.withoutNormalizing(e,()=>{rt.insertNodes(e,t,{at:o}),n&&(rt.select(e,n),rt.move(e))})}else{let n=ud.next(r[1]);Po.withoutNormalizing(e,()=>{rt.insertNodes(e,t,{at:n}),rt.select(e,Po.start(e,n))})}return!0}import{Editor as li,Transforms as si}from"slate";function nt(e,t,o){li.withoutNormalizing(e,()=>{let r=li.node(e,o),n=ai(r[0],t);si.wrapNodes(e,n,{at:o}),si.unwrapNodes(e,{at:[...o,0]})})}import{Editor as fd,Transforms as hd}from"slate";function yt(e,t,o){let r=Array.from(fd.nodes(e,o));if(r.length===0)return!1;for(let n of r){let[i]=n;hd.setNodes(e,t(i),{at:n[1]})}return!0}function mi(e,t){let o=t.clipboardData,{types:r}=o;if(r.length>1||r[0]!=="text/plain")return!1;let n=o.getData("text/plain");return gd(n)?(t.preventDefault(),t.stopPropagation(),e.anchor.insertLink(n),!0):!1}function gd(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"||t.protocol==="mailto:"}import{Editor as bd,Node as Ed,Transforms as Co}from"slate";function ci(e,{href:t,title:o,text:r},{at:n}){let i=b(e,"anchor",{at:n});if(!i)return!1;let[a,l]=i;if(Co.setNodes(e,{href:t,title:o},{at:l}),r!==void 0){let s=Ed.string(a);r!==s&&bd.withoutNormalizing(e,()=>{let c=a.children.length;for(let m=c-1;m>=0;m--)Co.removeNodes(e,{at:[...l,m]});Co.insertNodes(e,{text:r},{at:[...l,0]})})}return!0}import{Editor as kt,Range as xd,Text as yd,Transforms as So}from"slate";function pi(e,t,o=t,{select:r=!0,title:n}={}){let i=e.selection||{anchor:kt.start(e,[0]),focus:kt.start(e,[0])};if(xd.isCollapsed(i)){if(So.insertNodes(e,{type:"anchor",href:t,title:n,children:[{text:o}]},{select:r,at:i}),r&&e.selection){let a=kt.node(e,e.selection);So.select(e,a[1])}}else So.wrapNodes(e,{type:"anchor",href:t,title:n,children:[]},{split:!0,match:a=>yd.isText(a)||kt.isInline(e,a)})}import{Transforms as kd}from"slate";function di(e,{at:t}){let o=b(e,"anchor",{at:t});return o?(kd.unwrapNodes(e,{at:o[1]}),!0):!1}function ui(e){return{insertLink:u(pi,e),removeLink:u(di,e),editLink:u(ci,e)}}import{Element as fi,Transforms as Td}from"slate";function hi(e,t){if(!fi.isElement(t[0])||t[0].type!=="anchor")return!1;let o=t[0].children;for(let r=0;r<o.length;r++){let n=o[r];if(!(!fi.isElement(n)||n.type!=="anchor"))return Td.unwrapNodes(e,{at:[...t[1],r]}),!0}return!1}import{clsx as pu}from"clsx";import{useEffect as du,useRef as Yi}from"react";import{useSelected as uu,useSlate as fu}from"slate-react";import{createContext as bi,useState as wd}from"react";import{createPortal as vd}from"react-dom";function gi({children:e}){return vd(e,document.body)}import{jsx as Ro,jsxs as Md}from"react/jsx-runtime";var Lo=bi({}),Id=bi({});function Ei({children:e}){let[t,o]=wd({});function r(i){o(a=>({...a,[i.type]:i}))}function n(i){o(a=>{let l={...a};return delete l[i],l})}return Md(Lo.Provider,{value:{layers:t,setLayers:o,openLayer:r,closeLayer:n},children:[e,Object.entries(t).map(([,i])=>Ro(gi,{children:Ro(Id.Provider,{value:i,children:Ro(i.Component,{})})},i.type))]})}import{useContext as Pd}from"react";function $(e){let{openLayer:t,closeLayer:o,layers:r}=Pd(Lo);function n(a){t({type:e,Component:a})}function i(){o(e)}return{open:n,close:i,layer:r[e],type:e}}import Tt from"@emotion/styled";var xi=Tt("a")`
43
44
  /**
44
45
  * Link colors
45
46
  */
@@ -58,10 +59,10 @@
58
59
  &.--selected {
59
60
  background: var(--blue-50);
60
61
  }
61
- `,wo=yt("span")`
62
+ `,Bo=Tt("span")`
62
63
  display: inline;
63
64
  padding: 0 1px 0 0;
64
- `,RT=yt("span")`
65
+ `,qT=Tt("span")`
65
66
  position: fixed;
66
67
  width: 100px;
67
68
  background: var(--shade-50);
@@ -70,14 +71,14 @@
70
71
  border: 1px solid var(--shade-400);
71
72
  overflow: hidden;
72
73
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
73
- `,LT=yt("span")`
74
+ `,QT=Tt("span")`
74
75
  position: absolute;
75
76
  left: 0;
76
77
  top: 0;
77
78
  height: 14px;
78
79
  background: var(--blue-400);
79
80
  transition: width 100ms linear;
80
- `;import Qd from"@emotion/styled";import{useCallback as qi}from"react";import{useSlateStatic as jd}from"slate-react";import{useRef as bd}from"react";import gd from"@emotion/styled";var ci=gd("div")`
81
+ `;import lu from"@emotion/styled";import{useCallback as Ji}from"react";import{useSlateStatic as su}from"slate-react";import{useRef as Sd}from"react";import Cd from"@emotion/styled";var yi=Cd("div")`
81
82
  position: fixed;
82
83
  user-select: none;
83
84
  top: 0;
@@ -86,7 +87,7 @@
86
87
  bottom: 0;
87
88
  overflow-y: auto;
88
89
  background: rgba(0, 0, 0, 0.01);
89
- `;import{jsx as Ed}from"react/jsx-runtime";function de({close:e}){let t=bd(null);return Ed(ci,{ref:t,onClick:e})}var Y={cmd:"\u2318",ctrl:"\u2303",shift:"\u21E7",opt:"\u2325",enter:"\u23CE"},xd={shift:Y.shift,opt:Y.opt,alt:Y.opt,ctrl:Y.ctrl,mod:Y.cmd,cmd:Y.cmd,enter:Y.enter,super:`${Y.opt}${Y.cmd}`},yd={alt:"ALT",ctrl:"CTRL",opt:"ALT",shift:"SHIFT",mod:"CTRL",cmd:"CTRL",enter:Y.enter,super:"CTRL+SHIFT"};function pi(e,t){let o=e.findIndex(r=>r===t);o!==-1&&e.splice(o,1)}function kd(e){let t=[];return Object.entries(xd).forEach(([o,r])=>{e.includes(o)&&(t.push(r),pi(e,o))}),t.push(...e.map(o=>o.toUpperCase())),t.join("")}function Td(e){let t=[];return Object.entries(yd).forEach(([o,r])=>{e.includes(o)&&(t.push(r),pi(e,o))}),t.push(...e.map(o=>o.toUpperCase())),t.join("+")}function kt(e){let t=e.toLowerCase().split("+");return ht()?kd(t):Td(t)}import{useRef as Bd}from"react";import{useSlateStatic as Nd}from"slate-react";function Io(e){let t=e.getBoundingClientRect();return{top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width,height:t.height}}function di(e){let t=Io(e),{scrollY:o}=window;return Object.assign(t,{top:t.top+o,bottom:t.bottom+o})}function Mo(){let e=document.documentElement.clientWidth||document.body.clientWidth;return{top:0,right:e,bottom:window.innerHeight,left:0,width:e,height:window.innerHeight}}function ui(){let e=Mo();return Object.assign(e,{top:window.scrollY,bottom:window.scrollY+e.height})}var fi=vd;function vd(e,t){for(var o={},r=Object.keys(e),n=r.length,i=0;i<n;i++){var a=r[i];o[a]=t(e[a],a,e)}return o}function Po(e,t){return fi(e,r=>{let n=r instanceof HTMLElement?r:r.current;return n?t(n):null})}import{useEffect as Md}from"react";import wd from"lodash.throttle";import{useState as Id}from"react";function Tt(e=100){let[t,o]=Id(0),r=wd(()=>{o(n=>n+1)},e,{trailing:!0});return Object.assign(r,{counter:t})}function Co(){let e=Tt();return Md(()=>(e(),window.addEventListener("resize",e),window.addEventListener("scroll",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e)}),[]),e}function U(e,t){let o=Co(),r=Po(e,n=>di(n));return t(r,ui(),o)}function vt(e,t,o,{margin:r=0}={}){return e==null?{...o,left:-1024}:o.left+e.width<=t.right-r?o:{...o,left:t.right-e.width-r}}import So from"@emotion/styled";import Pd from"@emotion/styled";var F=Pd(je)`
90
+ `;import{jsx as Rd}from"react/jsx-runtime";function ge({close:e}){let t=Sd(null);return Rd(yi,{ref:t,onClick:e})}var te={cmd:"\u2318",ctrl:"\u2303",shift:"\u21E7",opt:"\u2325",enter:"\u23CE"},Ld={shift:te.shift,opt:te.opt,alt:te.opt,ctrl:te.ctrl,mod:te.cmd,cmd:te.cmd,enter:te.enter,super:`${te.opt}${te.cmd}`},Bd={alt:"ALT",ctrl:"CTRL",opt:"ALT",shift:"SHIFT",mod:"CTRL",cmd:"CTRL",enter:te.enter,super:"CTRL+SHIFT"};function ki(e,t){let o=e.findIndex(r=>r===t);o!==-1&&e.splice(o,1)}function zd(e){let t=[];return Object.entries(Ld).forEach(([o,r])=>{e.includes(o)&&(t.push(r),ki(e,o))}),t.push(...e.map(o=>o.toUpperCase())),t.join("")}function Nd(e){let t=[];return Object.entries(Bd).forEach(([o,r])=>{e.includes(o)&&(t.push(r),ki(e,o))}),t.push(...e.map(o=>o.toUpperCase())),t.join("+")}function vt(e){let t=e.toLowerCase().split("+");return bt()?zd(t):Nd(t)}import{useRef as _d}from"react";import{useSlateStatic as Gd}from"slate-react";function zo(e){let t=e.getBoundingClientRect();return{top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width,height:t.height}}function Ti(e){let t=zo(e),{scrollY:o}=window;return Object.assign(t,{top:t.top+o,bottom:t.bottom+o})}function No(){let e=document.documentElement.clientWidth||document.body.clientWidth;return{top:0,right:e,bottom:window.innerHeight,left:0,width:e,height:window.innerHeight}}function vi(){let e=No();return Object.assign(e,{top:window.scrollY,bottom:window.scrollY+e.height})}var wi=Dd;function Dd(e,t){for(var o={},r=Object.keys(e),n=r.length,i=0;i<n;i++){var a=r[i];o[a]=t(e[a],a,e)}return o}function Do(e,t){return wi(e,r=>{let n=r instanceof HTMLElement?r:r.current;return n?t(n):null})}import{useEffect as Ad}from"react";import $d from"lodash.throttle";import{useState as Hd}from"react";function wt(e=100){let[t,o]=Hd(0),r=$d(()=>{o(n=>n+1)},e,{trailing:!0});return Object.assign(r,{counter:t})}function $o(){let e=wt();return Ad(()=>(e(),window.addEventListener("resize",e),window.addEventListener("scroll",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e)}),[]),e}function q(e,t){let o=$o(),r=Do(e,n=>Ti(n));return t(r,vi(),o)}function It(e,t,o,{margin:r=0}={}){return e==null?{...o,left:-1024}:o.left+e.width<=t.right-r?o:{...o,left:t.right-e.width-r}}import Ho from"@emotion/styled";import Od from"@emotion/styled";var Q=Od(tt)`
90
91
  position: absolute;
91
92
  z-index: 1000;
92
93
  border: 1px solid var(--table-border-color);
@@ -112,13 +113,13 @@
112
113
  * even if we did, it looks better this way.
113
114
  */
114
115
  /* transition: left 100ms, top 100ms; */
115
- `;var hi=So(F)`
116
+ `;var Ii=Ho(Q)`
116
117
  padding: 1em;
117
118
  width: 24em;
118
- `,gi=So("div")`
119
+ `,Mt=Ho("div")`
119
120
  display: flex;
120
121
  gap: 0.5em;
121
- `,bi=So("input")`
122
+ `,Pt=Ho("input")`
122
123
  flex: 1 1 auto;
123
124
  padding: 0.5em 0.75em;
124
125
  border-radius: 0.25em;
@@ -128,7 +129,7 @@
128
129
  &:focus {
129
130
  outline: 2px solid var(--blue-200);
130
131
  }
131
- `;import xi from"@emotion/styled";import Cd from"@emotion/styled";var Ei=Cd(je)`
132
+ `;import Pi from"@emotion/styled";import Ud from"@emotion/styled";var Mi=Ud(tt)`
132
133
  border: 1px solid var(--shade-300); /* shade-300 */
133
134
  border-radius: 0.5em;
134
135
  color: rgb(39 39 42); /* shade-800 */
@@ -144,9 +145,9 @@
144
145
  */
145
146
  outline: 2px solid var(--select-editor-color) !important;
146
147
  }
147
- `;var yi=xi("div")`
148
+ `;var Ci=Pi("div")`
148
149
  padding: 2em;
149
- `,ki=xi(Ei)`
150
+ `,Si=Pi(Mi)`
150
151
  /**
151
152
  * We use this to make sure the top of the container is rounded even though
152
153
  * the toolbar inside is square. We keep the toolbar square so that as the
@@ -167,7 +168,7 @@
167
168
  overflow-y: clip;
168
169
  display: flex;
169
170
  flex-direction: column;
170
- `;import Ro from"@emotion/styled";var Ti=Ro(F)`
171
+ `;import Ao from"@emotion/styled";var Ri=Ao(Q)`
171
172
  position: absolute;
172
173
  padding-top: 0.5em;
173
174
  padding-bottom: 0.5em;
@@ -176,7 +177,7 @@
176
177
  * Prevent clicks from stealing focus from the editor
177
178
  */
178
179
  user-select: none;
179
- `,vi=Ro("div")`
180
+ `,Li=Ao("div")`
180
181
  display: flex;
181
182
  z-index: 10;
182
183
  padding: 0 1em 0 1.5em;
@@ -215,12 +216,12 @@
215
216
  &:hover {
216
217
  background: var(--blue-50);
217
218
  }
218
- `,wi=Ro("div")`
219
+ `,Bi=Ao("div")`
219
220
  height: 1px;
220
221
  background: var(--shade-200);
221
222
  margin-top: 0.25em;
222
223
  margin-bottom: 0.25em;
223
- `;import Ze from"@emotion/styled";var Ii=Ze("div")`
224
+ `;import it from"@emotion/styled";var zi=it("div")`
224
225
  /**
225
226
  * This flex rule applies to the "display: flex;" of the parent container.
226
227
  * Ensures the toolbar does not shrink or grow vertically.
@@ -259,22 +260,22 @@
259
260
  3em + 1px
260
261
  ); // $ToolbarDivider height + border-bottom of 1px above
261
262
  overflow: hidden;
262
- `,Mi=Ze("div")`
263
+ `,Ni=it("div")`
263
264
  display: inline-block;
264
265
  height: calc(
265
266
  3em + 1px
266
267
  ); // $ToolbarDivider height + border-bottom of 1px above
267
- `,Pi=Ze("div")`
268
+ `,Di=it("div")`
268
269
  display: inline-block;
269
270
  height: 3em;
270
271
  padding: 0 0.375em;
271
- `,Ci=Ze("div")`
272
+ `,$i=it("div")`
272
273
  display: inline-block;
273
274
  background: var(--shade-300);
274
275
  opacity: 50%;
275
276
  width: 1px;
276
277
  height: 3em;
277
- `,Si=Ze("div")`
278
+ `,Hi=it("div")`
278
279
  box-sizing: border-box;
279
280
  position: relative;
280
281
  display: inline-block;
@@ -324,7 +325,7 @@
324
325
  margin-left: -0.25em;
325
326
  opacity: 0.375;
326
327
  }
327
- `;import{useCallback as Sd}from"react";import{ReactEditor as Rd}from"slate-react";import{Fragment as zd,jsx as Pe,jsxs as Ld}from"react/jsx-runtime";function Ri({editor:e,item:t,close:o,dest:r}){let n=S("menu"),i=Sd(()=>{if(t.Component){let a=t.Component;n.open(()=>Pe(a,{dest:r,close:n.close}))}else t.action&&(t.action(e),Rd.focus(e),o())},[e,t]);return Pe(zd,{children:Ld(vi,{onClick:i,children:[Pe("div",{className:"--icon",children:Pe(t.icon,{})}),Pe("div",{className:"--title",children:t.title}),Pe("div",{className:"--hotkey",children:t.hotkey?kt(t.hotkey):void 0})]})})}import{Fragment as Dd,jsx as wt,jsxs as $d}from"react/jsx-runtime";function Ce({dest:e,items:t,close:o}){let r=Nd(),n=Bd(null),i=U({src:n,dest:e},({dest:a})=>({left:a.left-8,top:a.top+a.height}));return $d(Dd,{children:[wt(de,{close:o}),wt(Ti,{ref:n,style:i,children:t.map((a,l)=>a==="divider"?wt(wi,{},l):a.show&&!a.show(r)?null:wt(Ri,{editor:r,item:a,close:o,dest:e},l))})]})}import{useCallback as Ni}from"react";import Li from"@emotion/styled";import{jsx as Od,jsxs as Ud}from"react/jsx-runtime";function Lo(e){return e.getBoundingClientRect()}var Ad=Li("div")`
328
+ `;import{useCallback as Fd}from"react";import{ReactEditor as Vd}from"slate-react";import{Fragment as Wd,jsx as ze,jsxs as Kd}from"react/jsx-runtime";function Ai({editor:e,item:t,close:o,dest:r}){let n=$("menu"),i=Fd(()=>{if(t.Component){let a=t.Component;n.open(()=>ze(a,{dest:r,close:n.close}))}else t.action&&(t.action(e),Vd.focus(e),o())},[e,t]);return ze(Wd,{children:Kd(Li,{onClick:i,children:[ze("div",{className:"--icon",children:ze(t.icon,{})}),ze("div",{className:"--title",children:t.title}),ze("div",{className:"--hotkey",children:t.hotkey?vt(t.hotkey):void 0})]})})}import{Fragment as qd,jsx as Ct,jsxs as Qd}from"react/jsx-runtime";function St({dest:e,items:t,close:o}){let r=Gd(),n=_d(null),i=q({src:n,dest:e},({dest:a})=>({left:a.left-8,top:a.top+a.height}));return Qd(qd,{children:[Ct(ge,{close:o}),Ct(Ri,{ref:n,style:i,children:t.map((a,l)=>a==="divider"?Ct(Bi,{},l):a.show&&!a.show(r)?null:Ct(Ai,{editor:r,item:a,close:o,dest:e},l))})]})}import{useCallback as Vi}from"react";import Oi from"@emotion/styled";import{jsx as Jd,jsxs as Yd}from"react/jsx-runtime";function Oo(e){return e.getBoundingClientRect()}var jd=Oi("div")`
328
329
  position: fixed;
329
330
  z-index: 10;
330
331
  -webkit-font-smoothing: antialiased;
@@ -340,12 +341,12 @@
340
341
  background: var(--shade-700);
341
342
  border-radius: 0.25em;
342
343
  white-space: nowrap;
343
- `,Hd=Li("span")`
344
+ `,Xd=Oi("span")`
344
345
  margin-left: 0.75em;
345
346
  font-size: 0.875em;
346
347
  font-weight: 500;
347
348
  color: var(--shade-400);
348
- `;function zi({title:e,hotkey:t,dest:o}){let r=Lo(o);return Ud(Ad,{style:{left:r.left,top:`calc(${r.top}px - 2em)`},children:[e,t?Od(Hd,{children:t}):null]})}import Fd from"@emotion/styled";import{jsx as Kd}from"react/jsx-runtime";var Vd=Fd("span")`
349
+ `;function Ui({title:e,hotkey:t,dest:o}){let r=Oo(o);return Yd(jd,{style:{left:r.left,top:`calc(${r.top}px - 2em)`},children:[e,t?Jd(Xd,{children:t}):null]})}import Zd from"@emotion/styled";import{jsx as tu}from"react/jsx-runtime";var eu=Zd("span")`
349
350
  position: fixed;
350
351
  z-index: 10;
351
352
  width: 0;
@@ -353,7 +354,7 @@
353
354
  border-left: 0.375em solid transparent;
354
355
  border-right: 0.375em solid transparent;
355
356
  border-top: 0.375em solid var(--shade-700);
356
- `;function Bi({dest:e}){let t=Lo(e);return Kd(Vd,{style:{left:`calc(${t.left+t.width/2}px - 0.375em)`,top:`calc(${t.top}px - 0.5em)`}})}import{jsx as Di}from"react/jsx-runtime";function W({title:e,hotkey:t},o=[]){let r=S("tooltip-label"),n=S("tooltip-triangle"),i=Ni(l=>{let s=l.currentTarget;e!==void 0&&(r.open(()=>Di(zi,{title:e,hotkey:typeof t=="function"?t():t,dest:s})),n.open(()=>Di(Bi,{dest:s})))},o),a=Ni(()=>{r.close(),n.close()},o);return{onMouseEnter:i,onMouseLeave:a}}import _d from"@emotion/styled";import{useCallback as It,useRef as Wd,useState as Vi}from"react";import{useSlateStatic as Gd}from"slate-react";import ue from"@emotion/styled";var et=ue("div")`
357
+ `;function Fi({dest:e}){let t=Oo(e);return tu(eu,{style:{left:`calc(${t.left+t.width/2}px - 0.375em)`,top:`calc(${t.top}px - 0.5em)`}})}import{jsx as Ki}from"react/jsx-runtime";function J({title:e,hotkey:t},o=[]){let r=$("tooltip-label"),n=$("tooltip-triangle"),i=Vi(l=>{let s=l.currentTarget;e!==void 0&&(r.open(()=>Ki(Ui,{title:e,hotkey:typeof t=="function"?t():t,dest:s})),n.open(()=>Ki(Fi,{dest:s})))},o),a=Vi(()=>{r.close(),n.close()},o);return{onMouseEnter:i,onMouseLeave:a}}import ou from"@emotion/styled";import{useCallback as at,useRef as ru,useState as Fo}from"react";import{Node as nu}from"slate";import{useSlateStatic as iu}from"slate-react";import be from"@emotion/styled";var Ne=be("div")`
357
358
  margin: 0.5em 0;
358
359
  &:first-of-type {
359
360
  margin-top: 0;
@@ -361,15 +362,15 @@
361
362
  &:last-of-type {
362
363
  margin-bottom: 0;
363
364
  }
364
- `,zo=ue("div")`
365
+ `,Rt=be("div")`
365
366
  font-size: 0.9375em;
366
367
  margin-bottom: 0.25em;
367
368
  color: var(--shade-700);
368
- `,$i=ue("div")`
369
+ `,Uo=be("div")`
369
370
  font-size: 0.875em;
370
371
  margin-top: 0.25em;
371
372
  color: var(--shade-500);
372
- `,Ai=ue("input")`
373
+ `,Xw=be("input")`
373
374
  box-sizing: border-box;
374
375
  width: 100%;
375
376
  height: 6em;
@@ -382,7 +383,7 @@
382
383
  &:focus {
383
384
  outline: 2px solid var(--blue-200);
384
385
  }
385
- `,Hi=ue("input")`
386
+ `,Lt=be("input")`
386
387
  box-sizing: border-box;
387
388
  width: 100%;
388
389
  padding: 0.5em 0.75em;
@@ -393,7 +394,7 @@
393
394
  &:focus {
394
395
  outline: 2px solid var(--blue-200);
395
396
  }
396
- `,Oi=ue("div")`
397
+ `,Wi=be("div")`
397
398
  /* Center vertically and horizontally */
398
399
  display: flex;
399
400
  align-items: center;
@@ -407,7 +408,7 @@
407
408
  font-size: 1.25em;
408
409
  stroke-width: 2px;
409
410
  }
410
- `,Ui=ue(Oi)`
411
+ `,_i=be(Wi)`
411
412
  color: var(--blue-50);
412
413
  background: var(--blue-500);
413
414
  outline: 0px solid white;
@@ -419,7 +420,7 @@
419
420
  svg {
420
421
  color: var(--blue-200);
421
422
  }
422
- `,Fi=ue(Oi)`
423
+ `,Gi=be(Wi)`
423
424
  color: var(--shade-500);
424
425
  background: var(--shade-200);
425
426
  outline: 0px solid white;
@@ -431,11 +432,11 @@
431
432
  svg {
432
433
  color: var(--shade-400);
433
434
  }
434
- `;import{jsx as Z,jsxs as Bo}from"react/jsx-runtime";var qd=_d(F)`
435
+ `;import{jsx as W,jsxs as Bt}from"react/jsx-runtime";var au=ou(Q)`
435
436
  position: absolute;
436
437
  width: 20em;
437
438
  padding: 1em;
438
- `;function Ki({destAnchor:e,destStartEdge:t,element:o}){let r=S("dialog"),n=U({destAnchor:e,destStartEdge:t},({destAnchor:k,destStartEdge:C})=>({left:C.left,top:k.top+k.height})),i=Gd(),[a,l]=Vi(o.href),[s,m]=Vi(o.title||""),c=Wd({href:a,title:s});c.current={href:a,title:s};let p=It(k=>{l(k.target.value)},[]),h=It(k=>{m(k.target.value)},[]),y=It(()=>{r.open(()=>Z(Mt,{destAnchor:e,destStartEdge:t,element:o}))},[e,t,o]),E=It(()=>{let{href:k,title:C}=c.current;i.anchor.editLink({href:k,title:C},{at:o}),y()},[y]);return Bo(qd,{contentEditable:!1,style:n,children:[Bo(et,{children:[Z(zo,{children:f("linkUrl")}),Z(Ai,{as:"textarea",value:a,onChange:p})]}),Bo(et,{children:[Z(zo,{children:f("tooltipText")}),Z(Hi,{type:"text",value:s,onChange:h}),Z($i,{children:f("tooltipHint")})]}),Z(et,{children:Z(Ui,{onClick:E,children:f("apply")})}),Z(et,{children:Z(Fi,{onClick:y,children:f("cancel")})})]})}import{jsx as Se}from"react/jsx-runtime";var _i=e=>Se(b,{...e,children:Se("path",{d:"M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6M11 13l9-9M15 4h5v5"})}),Wi=e=>Se(b,{...e,children:Se("path",{d:"m9 15 3-3m2-2 1-1M11 6l.463-.536a5 5 0 0 1 7.071 7.072L18 13M3 3l18 18M13 18l-.397.534a5.068 5.068 0 0 1-7.127 0 4.972 4.972 0 0 1 0-7.071L6 11"})}),Gi=e=>Se(b,{...e,children:Se("path",{d:"M4 20h4L18.5 9.5a1.5 1.5 0 0 0-4-4L4 16v4M13.5 6.5l4 4"})});import{jsx as re,jsxs as Pt}from"react/jsx-runtime";var Jd=Qd(F)`
439
+ `;function qi({destAnchor:e,destStartEdge:t,element:o}){let r=$("dialog"),n=q({destAnchor:e,destStartEdge:t},({destAnchor:v,destStartEdge:k})=>({left:k.left,top:v.top+v.height})),i=iu(),[a,l]=Fo(o.href),[s,c]=Fo(nu.string(o)),[m,d]=Fo(o.title||""),p=ru({href:a,text:s,title:m});p.current={href:a,text:s,title:m};let g=at(v=>{l(v.target.value)},[]),E=at(v=>{c(v.target.value)},[]),T=at(v=>{d(v.target.value)},[]),M=at(()=>{r.open(()=>W(zt,{destAnchor:e,destStartEdge:t,element:o}))},[e,t,o]),I=at(()=>{let{href:v,text:k,title:w}=p.current;i.anchor.editLink({href:v,text:k,title:w},{at:o}),M()},[M]);return Bt(au,{contentEditable:!1,style:n,children:[Bt(Ne,{children:[W(Rt,{children:f("linkUrl")}),W(Lt,{type:"text",value:a,onChange:g})]}),Bt(Ne,{children:[W(Rt,{children:f("linkText")}),W(Lt,{type:"text",value:s,onChange:E}),W(Uo,{children:f("linkTextHint")})]}),Bt(Ne,{children:[W(Rt,{children:f("tooltipText")}),W(Lt,{type:"text",value:m,onChange:T}),W(Uo,{children:f("tooltipHint")})]}),W(Ne,{children:W(_i,{onClick:I,children:f("apply")})}),W(Ne,{children:W(Gi,{onClick:M,children:f("cancel")})})]})}import{jsx as De}from"react/jsx-runtime";var Qi=e=>De(y,{...e,children:De("path",{d:"M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6M11 13l9-9M15 4h5v5"})}),ji=e=>De(y,{...e,children:De("path",{d:"m9 15 3-3m2-2 1-1M11 6l.463-.536a5 5 0 0 1 7.071 7.072L18 13M3 3l18 18M13 18l-.397.534a5.068 5.068 0 0 1-7.127 0 4.972 4.972 0 0 1 0-7.071L6 11"})}),Xi=e=>De(y,{...e,children:De("path",{d:"M4 20h4L18.5 9.5a1.5 1.5 0 0 0-4-4L4 16v4M13.5 6.5l4 4"})});import{jsx as le,jsxs as Nt}from"react/jsx-runtime";var mu=lu(Q)`
439
440
  position: absolute;
440
441
  display: flex;
441
442
  width: 20em;
@@ -519,10 +520,10 @@
519
520
  height: 1.25em;
520
521
  stroke-width: 1.5;
521
522
  }
522
- `;function Xd(e){try{let t=new URL(e);return{hostname:t.hostname,pathname:t.pathname}}catch{return{hostname:"",pathname:""}}}function Mt({destAnchor:e,destStartEdge:t,element:o}){let r=S("dialog"),n=jd(),i=Xd(o.href),a=U({destAnchor:e,destStartEdge:t},({destAnchor:p,destStartEdge:h})=>({left:h.left,top:p.top+p.height})),l=W({title:"\u30EA\u30F3\u30AF\u3092\u524A\u9664"}),s=W({title:"\u30EA\u30F3\u30AF\u3092\u7DE8\u96C6"}),m=qi(()=>{n.anchor.removeLink({at:o}),r.close()},[n,r]),c=qi(()=>{s.onMouseLeave(),r.open(()=>re(Ki,{destAnchor:e,destStartEdge:t,element:o}))},[e,t,o]);return Pt(Jd,{contentEditable:!1,style:a,children:[Pt("a",{className:"--link",href:o.href,target:"_blank",rel:"noreferrer",children:[re(_i,{}),Pt("div",{className:"--url",children:[re("div",{className:"--hostname",children:i.hostname}),i.pathname===""||i.pathname==="/"?null:re("div",{className:"--pathname",children:i.pathname}),o.title==null||o.title===""?null:re("div",{className:"--tooltip",children:o.title})]})]}),Pt("span",{className:"--icons",children:[re("span",{className:"--icon",onClick:m,onMouseEnter:l.onMouseEnter,onMouseLeave:l.onMouseLeave,children:re(Wi,{})}),re("span",{className:"--icon",onMouseEnter:s.onMouseEnter,onMouseLeave:s.onMouseLeave,onClick:c,children:re(Gi,{})})]})]})}import{jsx as Ct,jsxs as ou}from"react/jsx-runtime";function ji({element:e,attributes:t,children:o}){let r=Qi(null),n=Qi(null),i=eu(),a=tu(),l=S("dialog");return Zd(()=>{let s=n.current,m=r.current;if(!s||!m)return;let c=a.selection&&a.selection.anchor.offset!==a.selection.focus.offset;i&&!c?setTimeout(()=>{l.open(()=>Ct(Mt,{destAnchor:s,destStartEdge:m,element:e}))}):l.close()},[i,e]),ou(mi,{className:Yd({"--selected":i}),href:e.href,target:e.target,...t,ref:n,children:[Ct(wo,{ref:r,contentEditable:!1}),Ct("span",{children:o}),Ct(wo,{contentEditable:!1})]})}import{jsx as ru}from"react/jsx-runtime";var Ji=x((e,t,{createPolicy:o})=>(e.anchor=ri(e),o({name:"anchor",editor:{isInline(r){if(r.type==="anchor")return!0},normalizeNode:d(ii,e)},editableProps:{onPaste:d(Zn,e),renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="anchor")return ru(ji,{element:r,attributes:n,children:i})}}})));import{Editor as St,Transforms as Zi}from"slate";import{Element as Xi,Path as Yi}from"slate";function No(e,t,o){if(!t||!o||Yi.equals(t[1],o[1]))return!0;let r=g(e,i=>Xi.isElement(i)&&e.isMaster(i),{at:t[1]}),n=g(e,i=>Xi.isElement(i)&&e.isMaster(i),{at:o[1]});return!!(!r&&!n||r&&n&&Yi.equals(r[1],n[1]))}var ea=x(e=>(e.atomicDelete=!0,{name:"atomic-delete",editor:{deleteBackward(){if(e.selection==null)return!1;let t=St.node(e,e.selection),o=St.previous(e,{mode:"lowest"});return No(e,t,o)?!1:(Zi.move(e,{unit:"character",reverse:!0}),!0)},deleteForward(){if(e.selection==null)return!1;let t=St.node(e,e.selection),o=St.next(e,{mode:"lowest"});return No(e,t,o)?!1:(Zi.move(e,{unit:"character"}),!0)}}}));import{Transforms as _u}from"slate";import{ReactEditor as Wu}from"slate-react";import{Editor as nu,Transforms as ta}from"slate";import{ReactEditor as iu}from"slate-react";function au(e){}function lu(e,t,o,r){let{selection:n}=e;if(ta.insertNodes(e,{type:"image-block",url:t,alt:o||"",title:r||"",width:320,height:240,children:[{text:""}]}),!n){let i=nu.end(e,[]);ta.select(e,i),iu.focus(e)}}function oa(e){return{noop:d(au,e),insertImageFromUrl:d(lu,e)}}function ra(e,t){return!1}import{useSlateStatic as Ou}from"slate-react";import su from"@emotion/styled";var na=su("div")`
523
+ `;function cu(e){try{let t=new URL(e);return{hostname:t.hostname,pathname:t.pathname}}catch{return{hostname:"",pathname:""}}}function zt({destAnchor:e,destStartEdge:t,element:o}){let r=$("dialog"),n=su(),i=cu(o.href),a=q({destAnchor:e,destStartEdge:t},({destAnchor:d,destStartEdge:p})=>({left:p.left,top:d.top+d.height})),l=J({title:"\u30EA\u30F3\u30AF\u3092\u524A\u9664"}),s=J({title:"\u30EA\u30F3\u30AF\u3092\u7DE8\u96C6"}),c=Ji(()=>{n.anchor.removeLink({at:o}),r.close()},[n,r]),m=Ji(()=>{s.onMouseLeave(),r.open(()=>le(qi,{destAnchor:e,destStartEdge:t,element:o}))},[e,t,o]);return Nt(mu,{contentEditable:!1,style:a,children:[Nt("a",{className:"--link",href:o.href,target:"_blank",rel:"noreferrer",children:[le(Qi,{}),Nt("div",{className:"--url",children:[le("div",{className:"--hostname",children:i.hostname}),i.pathname===""||i.pathname==="/"?null:le("div",{className:"--pathname",children:i.pathname}),o.title==null||o.title===""?null:le("div",{className:"--tooltip",children:o.title})]})]}),Nt("span",{className:"--icons",children:[le("span",{className:"--icon",onClick:c,onMouseEnter:l.onMouseEnter,onMouseLeave:l.onMouseLeave,children:le(ji,{})}),le("span",{className:"--icon",onMouseEnter:s.onMouseEnter,onMouseLeave:s.onMouseLeave,onClick:m,children:le(Xi,{})})]})]})}import{jsx as Dt,jsxs as hu}from"react/jsx-runtime";function Zi({element:e,attributes:t,children:o}){let r=Yi(null),n=Yi(null),i=uu(),a=fu(),l=$("dialog");return du(()=>{let s=n.current,c=r.current;if(!s||!c)return;let m=a.selection&&a.selection.anchor.offset!==a.selection.focus.offset;i&&!m?setTimeout(()=>{l.open(()=>Dt(zt,{destAnchor:s,destStartEdge:c,element:e}))}):l.close()},[i,e]),hu(xi,{className:pu({"--selected":i}),href:e.href,target:e.target,...t,ref:n,children:[Dt(Bo,{ref:r,contentEditable:!1}),Dt("span",{children:o}),Dt(Bo,{contentEditable:!1})]})}import{jsx as gu}from"react/jsx-runtime";var ea=x((e,t,{createPolicy:o})=>(e.anchor=ui(e),o({name:"anchor",editor:{isInline(r){if(r.type==="anchor")return!0},normalizeNode:u(hi,e)},editableProps:{onPaste:u(mi,e),renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="anchor")return gu(Zi,{element:r,attributes:n,children:i})}}})));import{Editor as $t,Transforms as ra}from"slate";import{Element as ta,Path as oa}from"slate";function Vo(e,t,o){if(!t||!o||oa.equals(t[1],o[1]))return!0;let r=b(e,i=>ta.isElement(i)&&e.isMaster(i),{at:t[1]}),n=b(e,i=>ta.isElement(i)&&e.isMaster(i),{at:o[1]});return!!(!r&&!n||r&&n&&oa.equals(r[1],n[1]))}var na=x(e=>(e.atomicDelete=!0,{name:"atomic-delete",editor:{deleteBackward(){if(e.selection==null)return!1;let t=$t.node(e,e.selection),o=$t.previous(e,{mode:"lowest"});return Vo(e,t,o)?!1:(ra.move(e,{unit:"character",reverse:!0}),!0)},deleteForward(){if(e.selection==null)return!1;let t=$t.node(e,e.selection),o=$t.next(e,{mode:"lowest"});return Vo(e,t,o)?!1:(ra.move(e,{unit:"character"}),!0)}}}));import{Transforms as rf}from"slate";import{ReactEditor as nf}from"slate-react";import{Editor as bu,Transforms as ia}from"slate";import{ReactEditor as Eu}from"slate-react";function xu(e){}function yu(e,t,o,r){let{selection:n}=e;if(ia.insertNodes(e,{type:"image-block",url:t,alt:o||"",title:r||"",width:320,height:240,children:[{text:""}]}),!n){let i=bu.end(e,[]);ia.select(e,i),Eu.focus(e)}}function aa(e){return{noop:u(xu,e),insertImageFromUrl:u(yu,e)}}function la(e,t){return!1}import{useSlateStatic as Yu}from"slate-react";import ku from"@emotion/styled";var sa=ku("div")`
523
524
  display: block;
524
525
  margin: 1em 0;
525
- `;import{clsx as $u}from"clsx";import{useState as Oa}from"react";import{useSelected as Au}from"slate-react";import ia from"@emotion/styled";var aa=ia("span")`
526
+ `;import{clsx as ju}from"clsx";import{useState as Ka}from"react";import{useSelected as Xu}from"slate-react";import ma from"@emotion/styled";var ca=ma("span")`
526
527
  /**
527
528
  * In order for this container to wrap tightly (without space), it needs to be
528
529
  * an "inline-block". If it's just an "inline" we end up with spacing
@@ -534,7 +535,7 @@
534
535
  * so that we can place UI controls for the image in and around the image.
535
536
  */
536
537
  position: relative;
537
- `,la=ia("img")`
538
+ `,pa=ma("img")`
538
539
  /**
539
540
  * TODO:
540
541
  *
@@ -596,7 +597,7 @@
596
597
  .--dragging > & {
597
598
  transition: border-radius 250ms;
598
599
  }
599
- `;import{clsx as uu}from"clsx";import{useCallback as ua}from"react";import{Transforms as fa}from"slate";import{ReactEditor as $o,useSlateStatic as fu}from"slate-react";import{useEffect as mu}from"react";function sa(){let e=Tt();return mu(()=>(e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}),[]),e}import ma from"@emotion/styled";var ca=ma("span")`
600
+ `;import{clsx as Mu}from"clsx";import{useCallback as ba}from"react";import{Transforms as Ea}from"slate";import{ReactEditor as Wo,useSlateStatic as Pu}from"slate-react";import{useEffect as Tu}from"react";function da(){let e=wt();return Tu(()=>(e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}),[]),e}import ua from"@emotion/styled";var fa=ua("span")`
600
601
  position: absolute;
601
602
  display: block;
602
603
  /**
@@ -623,7 +624,7 @@
623
624
  /* background: green; */
624
625
  width: 1.25em;
625
626
  }
626
- `,pa=ma("span")`
627
+ `,ha=ua("span")`
627
628
  position: absolute;
628
629
  display: block;
629
630
  background: var(--select-color);
@@ -716,7 +717,7 @@
716
717
  .--small > & > .--bar-right {
717
718
  left: calc(50% + 1px);
718
719
  }
719
- `;function Do({value:e,min:t,max:o}){if(!(o>=t))throw new Error("Expected max >= min but is not");return Math.max(t,Math.min(o,e))}import{ReactEditor as cu}from"slate-react";function Rt(e,t){e=Math.round(e);let o=t.width/t.height;return{width:e,height:Math.round(e/o)}}function pu(e,t){e=Math.round(e);let o=t.width/t.height;return{width:Math.round(e*o),height:e}}function du(e,t){let o=e.width/e.height,r=t.width/t.height;if(o>=r){if(e.width>t.width)return Rt(t.width,e)}else if(e.height>t.width)return pu(t.height,e);return e}function Ee(e,t,o){switch(o.type){case"bounds":return du(t,o);case"scale":return{width:Math.round(t.width*o.scale),height:Math.round(t.height*o.scale)}}}function da(e){let t=cu.toDOMNode(e,e),o=getComputedStyle(t),r=parseInt(o.paddingLeft)+parseInt(o.paddingRight);return t.clientWidth-r}import{Fragment as bu,jsx as tt,jsxs as gu}from"react/jsx-runtime";function hu(e,t){let r=$o.toDOMNode(e,t).querySelector("img");if(!r)throw new Error("Image Element could not be found but should exist");return r.getBoundingClientRect()}function ha({element:e,srcSize:t,size:o,setSize:r,isDragging:n,setIsDragging:i}){let a=fu();sa();let l=da(a),s=o.width,m=Math.min(t.width,l),c=Math.min(12,t.width),p=ua(E=>{he(E),i(!0);let k=E.clientX,T=hu(a,e).width,z={...o},q=j=>{let K=Do({value:T+j.clientX-k,min:c,max:m});z=Rt(K,t),r(z)},Q=()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",Q);let j=$o.findPath(a,e),K={width:z.width,height:z.height};r(K),fa.setNodes(a,K,{at:j}),i(!1)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",Q)},[t.width,t.height,o.width,e]),h=ua(E=>{he(E),i(!0);let k=E.changedTouches[0].clientX,C=o.width,T={...o},z=Q=>{let j=Q.changedTouches[0],K=Do({value:C+j.clientX-k,min:c,max:m});T=Rt(K,t),r(T)},q=()=>{document.removeEventListener("touchmove",z),document.removeEventListener("touchend",q);let Q=$o.findPath(a,e);fa.setNodes(a,{width:T.width,height:T.height},{at:Q}),i(!1)};document.addEventListener("touchmove",z),document.addEventListener("touchend",q)},[t.width,t.height,o.width,e]),y=uu({"--center":s<m&&s>c,"--left":s>=m&&s>c,"--right":s<=c&&s<m,"--dragging":n,"--small":s<=64||o.height<=64});return tt(bu,{children:tt(ca,{className:y,onMouseDown:p,onTouchStart:h,children:gu(pa,{children:[tt("span",{className:"--bar --bar-left"}),tt("span",{className:"--bar --bar-center"}),tt("span",{className:"--bar --bar-right"})]})})})}import Eu from"@emotion/styled";var ga=Eu("span")`
720
+ `;function Ko({value:e,min:t,max:o}){if(!(o>=t))throw new Error("Expected max >= min but is not");return Math.max(t,Math.min(o,e))}import{ReactEditor as vu}from"slate-react";function Ht(e,t){e=Math.round(e);let o=t.width/t.height;return{width:e,height:Math.round(e/o)}}function wu(e,t){e=Math.round(e);let o=t.width/t.height;return{width:Math.round(e*o),height:e}}function Iu(e,t){let o=e.width/e.height,r=t.width/t.height;if(o>=r){if(e.width>t.width)return Ht(t.width,e)}else if(e.height>t.width)return wu(t.height,e);return e}function Te(e,t,o){switch(o.type){case"bounds":return Iu(t,o);case"scale":return{width:Math.round(t.width*o.scale),height:Math.round(t.height*o.scale)}}}function ga(e){let t=vu.toDOMNode(e,e),o=getComputedStyle(t),r=parseInt(o.paddingLeft)+parseInt(o.paddingRight);return t.clientWidth-r}import{Fragment as Ru,jsx as lt,jsxs as Su}from"react/jsx-runtime";function Cu(e,t){let r=Wo.toDOMNode(e,t).querySelector("img");if(!r)throw new Error("Image Element could not be found but should exist");return r.getBoundingClientRect()}function xa({element:e,srcSize:t,size:o,setSize:r,isDragging:n,setIsDragging:i}){let a=Pu();da();let l=ga(a),s=o.width,c=Math.min(t.width,l),m=Math.min(12,t.width),d=ba(E=>{ye(E),i(!0);let T=E.clientX,I=Cu(a,e).width,v={...o},k=D=>{let H=Ko({value:I+D.clientX-T,min:m,max:c});v=Ht(H,t),r(v)},w=()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",w);let D=Wo.findPath(a,e),H={width:v.width,height:v.height};r(H),Ea.setNodes(a,H,{at:D}),i(!1)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",w)},[t.width,t.height,o.width,e]),p=ba(E=>{ye(E),i(!0);let T=E.changedTouches[0].clientX,M=o.width,I={...o},v=w=>{let D=w.changedTouches[0],H=Ko({value:M+D.clientX-T,min:m,max:c});I=Ht(H,t),r(I)},k=()=>{document.removeEventListener("touchmove",v),document.removeEventListener("touchend",k);let w=Wo.findPath(a,e);Ea.setNodes(a,{width:I.width,height:I.height},{at:w}),i(!1)};document.addEventListener("touchmove",v),document.addEventListener("touchend",k)},[t.width,t.height,o.width,e]),g=Mu({"--center":s<c&&s>m,"--left":s>=c&&s>m,"--right":s<=m&&s<c,"--dragging":n,"--small":s<=64||o.height<=64});return lt(Ru,{children:lt(fa,{className:g,onMouseDown:d,onTouchStart:p,children:Su(ha,{children:[lt("span",{className:"--bar --bar-left"}),lt("span",{className:"--bar --bar-center"}),lt("span",{className:"--bar --bar-right"})]})})})}import Lu from"@emotion/styled";var ya=Lu("span")`
720
721
  position: absolute;
721
722
  /**
722
723
  * The status appears with a 1px gap from the outline.
@@ -738,7 +739,7 @@
738
739
 
739
740
  /* force numbers to be monospaced for better alignment */
740
741
  font-variant-numeric: tabular-nums;
741
- `;import{jsxs as xu}from"react/jsx-runtime";function ba({size:e}){return xu(ga,{children:[e.width," \xD7 ",e.height]})}import yu from"@emotion/styled";var Ea=yu("span")`
742
+ `;import{jsxs as Bu}from"react/jsx-runtime";function ka({size:e}){return Bu(ya,{children:[e.width," \xD7 ",e.height]})}import zu from"@emotion/styled";var Ta=zu("span")`
742
743
  position: absolute;
743
744
  /**
744
745
  * On top of the image +1 for space inside outline, +2 for outline,
@@ -769,7 +770,7 @@
769
770
  }
770
771
  display: flex;
771
772
  gap: 0.25em;
772
- `;import xa from"@emotion/styled";var Lt=xa("span")`
773
+ `;import va from"@emotion/styled";var At=va("span")`
773
774
  /* font-size: 0.75em; */
774
775
  border-radius: 0.5em;
775
776
  display: flex;
@@ -782,7 +783,7 @@
782
783
  * see the border of the buttons.
783
784
  */
784
785
  outline: 1px solid white;
785
- `,Re=xa("span")`
786
+ `,$e=va("span")`
786
787
  font-size: 0.75em;
787
788
  line-height: 2em;
788
789
  padding: 0 0.625em;
@@ -836,17 +837,17 @@
836
837
  font-size: 1.33em;
837
838
  line-height: 1em;
838
839
  }
839
- `;import{clsx as ku}from"clsx";import{useCallback as Tu}from"react";import{Transforms as vu}from"slate";import{ReactEditor as wu,useSlateStatic as Iu}from"slate-react";import{jsx as Mu}from"react/jsx-runtime";function ya({element:e,preset:t,size:o,setSize:r,srcSize:n}){let i=Iu(),a=Ee(o,n,t),l=W({title:t.title,hotkey:`${a.width}x${a.height}`}),s=Tu(()=>{let y=wu.findPath(i,e),E=Ee(o,n,t);r(E),vu.setNodes(i,E,{at:y})},[e,t,o,n]),c=!(t.type==="scale"?!0:t.width<=n.width||t.height<=n.height),p=o.width===a.width&&o.height===a.height,h=ku({"--disabled":c,"--selected":!c&&p});return Mu(Re,{className:h,onClick:c?void 0:s,onMouseEnter:l.onMouseEnter,onMouseLeave:l.onMouseLeave,children:t.name})}import{jsx as ka}from"react/jsx-runtime";function Ta({element:e,size:t,setSize:o,srcSize:r,presets:n}){return ka(Lt,{children:n.map((i,a)=>ka(ya,{element:e,preset:i,size:t,setSize:o,srcSize:r},a))})}import{useCallback as Su}from"react";import{useSlateStatic as Ru}from"slate-react";import{jsx as zt,jsxs as Ia}from"react/jsx-runtime";var va=e=>Ia(b,{...e,children:[zt("rect",{width:6,height:6,x:4,y:5,rx:1}),zt("path",{d:"M4 15h16M4 19h16"})]}),wa=e=>Ia(b,{...e,children:[zt("rect",{width:6,height:6,x:9,y:5,rx:1}),zt("path",{d:"M4 7h1M4 11h1M19 7h1M19 11h1M4 15h16M4 19h16"})]});import{Editor as Pu,Transforms as Ma}from"slate";import{ReactEditor as Cu}from"slate-react";function Pa(e,t){if(!t.width||!t.height||!t.srcWidth||!t.srcHeight)return;let o={width:t.width,height:t.height},r={width:t.srcWidth,height:t.srcHeight},n=Cu.findPath(e,t);Pu.withoutNormalizing(e,()=>{let i=Ee(o,r,{name:"initial-inline-image",title:"",type:"bounds",width:24,height:24});Ma.setNodes(e,{type:"image-inline",...i},{at:n}),Ma.wrapNodes(e,{type:"paragraph",children:[]},{at:n})})}import{jsx as Ca}from"react/jsx-runtime";function Sa({element:e}){let t=Ru(),o=W({title:"Inline Image",hotkey:"In a line with text"}),r=Su(()=>{e.type==="image-block"&&Pa(t,e)},[t,e]);return Ca(Re,{className:e.type==="image-inline"?"--selected":"",onClick:e.type==="image-inline"?void 0:r,onMouseEnter:o.onMouseEnter,onMouseLeave:o.onMouseLeave,children:Ca(wa,{})})}import{useCallback as zu}from"react";import{useSlateStatic as Bu}from"slate-react";import{Editor as Ra,Text as La,Transforms as Bt}from"slate";import{ReactEditor as Lu}from"slate-react";function za(e,t){if(!t.width||!t.height||!t.srcWidth||!t.srcHeight)return;let o={width:t.width,height:t.height},r={width:t.srcWidth,height:t.srcHeight},n=Lu.findPath(e,t);Ra.withoutNormalizing(e,()=>{let i=Ee(o,r,{name:"initial-block-image",title:"",type:"bounds",width:320,height:320});Bt.setNodes(e,{type:"image-block",...i},{at:n});let a=g(e,k=>Ra.isBlock(e,k)&&k.type!=="image-block");if(!a)throw new Error("This shouldn't happen");let[l,s]=a,m=l.children,c=l.children.length,p=n.slice(-1)[0],h=m[c-1];p===c-2&&La.isText(h)&&h.text===""&&Bt.removeNodes(e,{at:[...s,c-1]});let y=m[0],E=p===1&&La.isText(y)&&y.text==="";E&&Bt.removeNodes(e,{at:[...s,0]}),Bt.liftNodes(e,{at:[...s,E?p-1:p]})})}import{jsx as Ba}from"react/jsx-runtime";function Na({element:e}){let t=Bu(),o=W({title:"Block Image",hotkey:"On a line by itself"}),r=zu(()=>{e.type==="image-inline"&&za(t,e)},[t,e]);return Ba(Re,{className:e.type==="image-block"?"--selected":"",onClick:e.type==="image-block"?void 0:r,onMouseEnter:o.onMouseEnter,onMouseLeave:o.onMouseLeave,children:Ba(va,{})})}import{jsx as Da,jsxs as Nu}from"react/jsx-runtime";function $a({element:e}){return Nu(Lt,{children:[Da(Na,{element:e}),Da(Sa,{element:e})]})}import{jsx as Aa,jsxs as Du}from"react/jsx-runtime";function Ha({element:e,size:t,setSize:o,srcSize:r,presets:n}){return Du(Ea,{children:[Aa($a,{element:e}),Aa(Ta,{element:e,size:t,setSize:o,srcSize:r,presets:n})]})}import{jsx as Nt,jsxs as Hu}from"react/jsx-runtime";function Dt({element:e,presets:t}){let o=e.url,r=Au(),[n,i]=Oa(!1),[a,l]=Oa(e.srcWidth&&e.srcHeight&&e.width&&e.height?{width:e.width,height:e.height}:null),s=e.srcWidth&&e.srcHeight?{width:e.srcWidth,height:e.srcHeight}:null,m=r&&a&&s,c=$u({"--selected":r,"--dragging":n,"--small":a&&(a.width<=64||a.height<=64)});return Hu(aa,{className:c,children:[Nt(la,{src:o,width:a?.width,height:a?.height}),m?Nt(Ha,{element:e,size:a,setSize:l,srcSize:s,presets:t}):null,n&&a?Nt(ba,{size:a}):null,m?Nt(ha,{element:e,srcSize:s,isDragging:n,setIsDragging:i,size:a,setSize:l}):null]})}import{jsx as Ua,jsxs as Uu}from"react/jsx-runtime";function Fa({element:e,attributes:t,children:o}){let r=Ou();return Uu("div",{...t,children:[Ua(na,{contentEditable:!1,children:Ua(Dt,{element:e,presets:r.image.imageBlockPresets})}),o]})}import{useSlateStatic as Vu}from"slate-react";import Fu from"@emotion/styled";var Va=Fu("span")`
840
+ `;import{clsx as Nu}from"clsx";import{useCallback as Du}from"react";import{Transforms as $u}from"slate";import{ReactEditor as Hu,useSlateStatic as Au}from"slate-react";import{jsx as Ou}from"react/jsx-runtime";function wa({element:e,preset:t,size:o,setSize:r,srcSize:n}){let i=Au(),a=Te(o,n,t),l=J({title:t.title,hotkey:`${a.width}x${a.height}`}),s=Du(()=>{let g=Hu.findPath(i,e),E=Te(o,n,t);r(E),$u.setNodes(i,E,{at:g})},[e,t,o,n]),m=!(t.type==="scale"?!0:t.width<=n.width||t.height<=n.height),d=o.width===a.width&&o.height===a.height,p=Nu({"--disabled":m,"--selected":!m&&d});return Ou($e,{className:p,onClick:m?void 0:s,onMouseEnter:l.onMouseEnter,onMouseLeave:l.onMouseLeave,children:t.name})}import{jsx as Ia}from"react/jsx-runtime";function Ma({element:e,size:t,setSize:o,srcSize:r,presets:n}){return Ia(At,{children:n.map((i,a)=>Ia(wa,{element:e,preset:i,size:t,setSize:o,srcSize:r},a))})}import{useCallback as Vu}from"react";import{useSlateStatic as Ku}from"slate-react";import{jsx as Ot,jsxs as Sa}from"react/jsx-runtime";var Pa=e=>Sa(y,{...e,children:[Ot("rect",{width:6,height:6,x:4,y:5,rx:1}),Ot("path",{d:"M4 15h16M4 19h16"})]}),Ca=e=>Sa(y,{...e,children:[Ot("rect",{width:6,height:6,x:9,y:5,rx:1}),Ot("path",{d:"M4 7h1M4 11h1M19 7h1M19 11h1M4 15h16M4 19h16"})]});import{Editor as Uu,Transforms as Ra}from"slate";import{ReactEditor as Fu}from"slate-react";function La(e,t){if(!t.width||!t.height||!t.srcWidth||!t.srcHeight)return;let o={width:t.width,height:t.height},r={width:t.srcWidth,height:t.srcHeight},n=Fu.findPath(e,t);Uu.withoutNormalizing(e,()=>{let i=Te(o,r,{name:"initial-inline-image",title:"",type:"bounds",width:24,height:24});Ra.setNodes(e,{type:"image-inline",...i},{at:n}),Ra.wrapNodes(e,{type:"paragraph",children:[]},{at:n})})}import{jsx as Ba}from"react/jsx-runtime";function za({element:e}){let t=Ku(),o=J({title:"Inline Image",hotkey:"In a line with text"}),r=Vu(()=>{e.type==="image-block"&&La(t,e)},[t,e]);return Ba($e,{className:e.type==="image-inline"?"--selected":"",onClick:e.type==="image-inline"?void 0:r,onMouseEnter:o.onMouseEnter,onMouseLeave:o.onMouseLeave,children:Ba(Ca,{})})}import{useCallback as _u}from"react";import{useSlateStatic as Gu}from"slate-react";import{Editor as Na,Text as Da,Transforms as Ut}from"slate";import{ReactEditor as Wu}from"slate-react";function $a(e,t){if(!t.width||!t.height||!t.srcWidth||!t.srcHeight)return;let o={width:t.width,height:t.height},r={width:t.srcWidth,height:t.srcHeight},n=Wu.findPath(e,t);Na.withoutNormalizing(e,()=>{let i=Te(o,r,{name:"initial-block-image",title:"",type:"bounds",width:320,height:320});Ut.setNodes(e,{type:"image-block",...i},{at:n});let a=b(e,T=>Na.isBlock(e,T)&&T.type!=="image-block");if(!a)throw new Error("This shouldn't happen");let[l,s]=a,c=l.children,m=l.children.length,d=n.slice(-1)[0],p=c[m-1];d===m-2&&Da.isText(p)&&p.text===""&&Ut.removeNodes(e,{at:[...s,m-1]});let g=c[0],E=d===1&&Da.isText(g)&&g.text==="";E&&Ut.removeNodes(e,{at:[...s,0]}),Ut.liftNodes(e,{at:[...s,E?d-1:d]})})}import{jsx as Ha}from"react/jsx-runtime";function Aa({element:e}){let t=Gu(),o=J({title:"Block Image",hotkey:"On a line by itself"}),r=_u(()=>{e.type==="image-inline"&&$a(t,e)},[t,e]);return Ha($e,{className:e.type==="image-block"?"--selected":"",onClick:e.type==="image-block"?void 0:r,onMouseEnter:o.onMouseEnter,onMouseLeave:o.onMouseLeave,children:Ha(Pa,{})})}import{jsx as Oa,jsxs as qu}from"react/jsx-runtime";function Ua({element:e}){return qu(At,{children:[Oa(Aa,{element:e}),Oa(za,{element:e})]})}import{jsx as Fa,jsxs as Qu}from"react/jsx-runtime";function Va({element:e,size:t,setSize:o,srcSize:r,presets:n}){return Qu(Ta,{children:[Fa(Ua,{element:e}),Fa(Ma,{element:e,size:t,setSize:o,srcSize:r,presets:n})]})}import{jsx as Ft,jsxs as Ju}from"react/jsx-runtime";function Vt({element:e,presets:t}){let o=e.url,r=Xu(),[n,i]=Ka(!1),[a,l]=Ka(e.srcWidth&&e.srcHeight&&e.width&&e.height?{width:e.width,height:e.height}:null),s=e.srcWidth&&e.srcHeight?{width:e.srcWidth,height:e.srcHeight}:null,c=r&&a&&s,m=ju({"--selected":r,"--dragging":n,"--small":a&&(a.width<=64||a.height<=64)});return Ju(ca,{className:m,children:[Ft(pa,{src:o,width:a?.width,height:a?.height}),c?Ft(Va,{element:e,size:a,setSize:l,srcSize:s,presets:t}):null,n&&a?Ft(ka,{size:a}):null,c?Ft(xa,{element:e,srcSize:s,isDragging:n,setIsDragging:i,size:a,setSize:l}):null]})}import{jsx as Wa,jsxs as Zu}from"react/jsx-runtime";function _a({element:e,attributes:t,children:o}){let r=Yu();return Zu("div",{...t,children:[Wa(sa,{contentEditable:!1,children:Wa(Vt,{element:e,presets:r.image.imageBlockPresets})}),o]})}import{useSlateStatic as tf}from"slate-react";import ef from"@emotion/styled";var Ga=ef("span")`
840
841
  display: inline;
841
- `;import{jsx as Ka,jsxs as Ku}from"react/jsx-runtime";function _a({element:e,attributes:t,children:o}){let r=Vu();return Ku("span",{...t,style:{display:"inline-block"},children:[Ka(Va,{contentEditable:!1,children:Ka(Dt,{element:e,presets:r.image.imageInlinePresets})}),o]})}import{jsx as Wa}from"react/jsx-runtime";function Ga({element:e,attributes:t,children:o}){switch(e.type){case"image-block":return Wa(Fa,{element:e,attributes:t,children:o});case"image-inline":return Wa(_a,{element:e,attributes:t,children:o})}}function Gu(e){return t=>{let{dataTransfer:o}=t;if(!o.files||o.files.length===0)return!1;let r=Array.from(o.files).filter(a=>a.type.startsWith("image/"));if(r.length===0)return!1;t.preventDefault(),t.stopPropagation();let n=Wu.findEventRange(e,t);n&&_u.select(e,n);let i=e.wysimark?.onImageChange;return r.forEach(async a=>{if(i)try{let l=await i(a);l&&e.image.insertImageFromUrl(l,a.name,"")}catch(l){console.error("Failed to upload image:",l)}else{let l=new FileReader;l.onload=()=>{let s=l.result;e.image.insertImageFromUrl(s,a.name,"")},l.readAsDataURL(a)}}),!0}}var qu={maxInitialInlineImageSize:{width:64,height:64},maxInitialImageSize:{width:320,height:320},maxImageSize:{width:1024,height:1024},imageBlockPresets:[{name:"S",title:"Small",type:"bounds",width:160,height:160},{name:"M",title:"Medium",type:"bounds",width:320,height:320},{name:"L",title:"Large",type:"bounds",width:640,height:640},{name:"\u2153",title:"1/3 scale",type:"scale",scale:1/3},{name:"\xBD",title:"1/2 scale",type:"scale",scale:.5},{name:"Full",title:"Full size",type:"scale",scale:1}],imageInlinePresets:[{name:"16",title:"16 pixels",type:"bounds",width:16,height:16},{name:"24",title:"24 pixels",type:"bounds",width:24,height:24},{name:"32",title:"32 pixels",type:"bounds",width:32,height:32},{name:"\u2153",title:"1/3 scale",type:"scale",scale:1/3},{name:"\xBD",title:"1/2 scale",type:"scale",scale:.5},{name:"Full",title:"Full size",type:"scale",scale:1}]},qa=x((e,t,{createPolicy:o})=>{let r={...qu,...t.image};return e.image={...oa(e),maxInitialInlineImageSize:r.maxInitialInlineImageSize,maxInitialImageSize:r.maxInitialImageSize,maxImageSize:r.maxImageSize,imageBlockPresets:r.imageBlockPresets,imageInlinePresets:r.imageInlinePresets},o({name:"image",editor:{isVoid:n=>{if(["image-block","image-inline"].includes(n.type))return!0},isInline:n=>{if(n.type==="image-inline")return!0},normalizeNode:d(ra,e)},editableProps:{renderElement:Ga,onDrop:Gu(e)}})});import{Editor as ot,Element as A,Transforms as Le}from"slate";import Qu from"@emotion/styled";var Qa=Qu("blockquote")`
842
+ `;import{jsx as qa,jsxs as of}from"react/jsx-runtime";function Qa({element:e,attributes:t,children:o}){let r=tf();return of("span",{...t,style:{display:"inline-block"},children:[qa(Ga,{contentEditable:!1,children:qa(Vt,{element:e,presets:r.image.imageInlinePresets})}),o]})}import{jsx as ja}from"react/jsx-runtime";function Xa({element:e,attributes:t,children:o}){switch(e.type){case"image-block":return ja(_a,{element:e,attributes:t,children:o});case"image-inline":return ja(Qa,{element:e,attributes:t,children:o})}}function af(e){return t=>{let{dataTransfer:o}=t;if(!o.files||o.files.length===0)return!1;let r=Array.from(o.files).filter(a=>a.type.startsWith("image/"));if(r.length===0)return!1;t.preventDefault(),t.stopPropagation();let n=nf.findEventRange(e,t);n&&rf.select(e,n);let i=e.wysimark?.onImageChange;for(let a of r)if(i)i(a).then(l=>{l&&e.image.insertImageFromUrl(l,a.name,"")}).catch(()=>{});else{let l=new FileReader;l.onload=()=>{let s=l.result;e.image.insertImageFromUrl(s,a.name,"")},l.readAsDataURL(a)}return!0}}var lf={maxInitialInlineImageSize:{width:64,height:64},maxInitialImageSize:{width:320,height:320},maxImageSize:{width:1024,height:1024},imageBlockPresets:[{name:"S",title:"Small",type:"bounds",width:160,height:160},{name:"M",title:"Medium",type:"bounds",width:320,height:320},{name:"L",title:"Large",type:"bounds",width:640,height:640},{name:"\u2153",title:"1/3 scale",type:"scale",scale:1/3},{name:"\xBD",title:"1/2 scale",type:"scale",scale:.5},{name:"Full",title:"Full size",type:"scale",scale:1}],imageInlinePresets:[{name:"16",title:"16 pixels",type:"bounds",width:16,height:16},{name:"24",title:"24 pixels",type:"bounds",width:24,height:24},{name:"32",title:"32 pixels",type:"bounds",width:32,height:32},{name:"\u2153",title:"1/3 scale",type:"scale",scale:1/3},{name:"\xBD",title:"1/2 scale",type:"scale",scale:.5},{name:"Full",title:"Full size",type:"scale",scale:1}]},Ja=x((e,t,{createPolicy:o})=>{let r={...lf,...t.image};return e.image={...aa(e),maxInitialInlineImageSize:r.maxInitialInlineImageSize,maxInitialImageSize:r.maxInitialImageSize,maxImageSize:r.maxImageSize,imageBlockPresets:r.imageBlockPresets,imageInlinePresets:r.imageInlinePresets},o({name:"image",editor:{isVoid:n=>{if(["image-block","image-inline"].includes(n.type))return!0},isInline:n=>{if(n.type==="image-inline")return!0},normalizeNode:u(la,e)},editableProps:{renderElement:Xa,onDrop:af(e)}})});import{Editor as st,Element as _,Transforms as He}from"slate";import sf from"@emotion/styled";var Ya=sf("blockquote")`
842
843
  position: relative;
843
844
  margin-top: 1em;
844
845
  margin-bottom: 1em;
845
846
  margin-left: 0;
846
847
  border-left: 0.25em solid rgba(0, 0, 0, 0.075);
847
848
  padding-left: 1.5em;
848
- `;import{jsx as Ju}from"react/jsx-runtime";function ja(e){return A.isElement(e)&&(e.type==="paragraph"||e.type==="code-block"||e.type==="table"||e.type==="horizontal-rule"||e.type==="task-list-item"||e.type==="unordered-list-item"||e.type==="ordered-list-item"||e.type==="heading")}var ju=2,Ja=x(e=>(e.supportsBlockQuote=!0,e.blockQuotePlugin={indent:()=>{Le.wrapNodes(e,{type:"block-quote",children:[]},{match:ja})},outdent:()=>{Le.liftNodes(e,{match:(t,o)=>ja(t)&&o.length>1})},isActive:()=>{let[t]=ot.nodes(e,{match:o=>A.isElement(o)&&o.type==="block-quote"});return!!t},increaseDepth:()=>{let[t]=ot.nodes(e,{match:r=>A.isElement(r)&&r.type==="block-quote"});if(!t||!e.blockQuotePlugin.canIncreaseDepth())return;let[,o]=t;Le.select(e,o),Le.wrapNodes(e,{type:"block-quote",children:[]},{at:o,split:!1})},decreaseDepth:()=>{let[t]=ot.nodes(e,{match:i=>A.isElement(i)&&i.type==="block-quote"});if(!t||!e.blockQuotePlugin.canDecreaseDepth())return;let[o,r]=t,n=o.children;n.length===1&&A.isElement(n[0])&&n[0].type==="block-quote"&&Le.unwrapNodes(e,{at:[...r,0],match:i=>A.isElement(i)&&i.type==="block-quote"})},canIncreaseDepth:()=>{let[t]=ot.nodes(e,{match:i=>A.isElement(i)&&i.type==="block-quote"});if(!t)return!1;let[o]=t,r=0,n=o;for(;n.children.length===1&&A.isElement(n.children[0])&&n.children[0]&&n.children[0]&&n.children[0].type==="block-quote";)r++,n=n.children[0];return r<ju},canDecreaseDepth:()=>{let[t]=ot.nodes(e,{match:r=>A.isElement(r)&&r.type==="block-quote"});if(!t)return!1;let[o]=t;return o.children.length===1&&A.isElement(o.children[0])&&o.children[0]&&o.children[0].type==="block-quote"}},{name:"block-quote",editor:{normalizeNode(t){let[o,r]=t;return!A.isElement(o)||o.type!=="block-quote"?!1:pe(e,[o,r],(n,i)=>(A.isElement(n[0])&&A.isElement(i[0])&&n[0].type==="block-quote"&&i[0].type==="block-quote"&&Le.mergeNodes(e,{at:i[1]}),!0))}},editableProps:{renderElement:({element:t,attributes:o,children:r})=>{if(t.type==="block-quote")return Ju(Qa,{...o,children:r})},onKeyDown:P({"super+.":e.blockQuotePlugin.indent,"super+,":e.blockQuotePlugin.outdent})}}));import{Editor as uf,Element as ff,Transforms as xl}from"slate";import Xu from"prismjs";import{Element as ef,Node as tf}from"slate";var{languages:Yu,tokenize:Zu}=Xu;function of(e){let t=0,o=[];for(let r of e)o.push(t),t=t+r.length;return o}function Xa(e){let[t,o]=e;if(!ef.isElement(t))return[];if(t.type!=="code-block")return[];let r=Yu[t.language];if(r===void 0)return[];let i=t.children.map(h=>`${tf.string(h)}
849
- `),a=i.join(""),l=of(i);function s(h){for(let y=l.length;y>=0;y--){let E=l[y];if(E<=h)return{path:[...o,y],offset:h-E}}throw new Error("This shouldn't happen and indicates a bug in the logic")}let m=[],c=Zu(a,r),p=0;for(let h of c)if(typeof h=="string")p+=h.length;else{let y=s(p),E=s(p+h.length);m.push({anchor:y,focus:E,prismToken:h.type}),p+=h.length}return m}function Ya(e,{language:t}){bt(e,{type:"code-block",language:t,children:[{type:"code-block-line",children:[{text:""}]}]})}import{Element as rf,Transforms as nf}from"slate";function Za(e,t,o={}){let r=g(e,n=>rf.isElement(n)&&n.type==="code-block",{at:o.at});return r?(nf.setNodes(e,{language:t},{at:r[1]}),!0):!1}function el(e){return{createCodeBlock:d(Ya,e),setCodeBlockLanguage:d(Za,e)}}var $t={color:"#999988",fontStyle:"italic"},af={opacity:"0.7"},tl={color:"#e3116c"},ol={color:"#393a34"},ee={color:"#36acaa"},Ao={color:"#00a4db"},rl={color:"#9a050f"},nl={color:"#00009f"},Ho={fontWeight:"bold"},lf={fontStyle:"italic"},il={comment:$t,prolog:$t,doctype:$t,cdata:$t,namespace:af,string:tl,"attr-value":tl,puncutation:ol,operator:ol,entity:ee,url:ee,symbol:ee,number:ee,boolean:ee,variable:ee,constant:ee,property:ee,regex:ee,insert:ee,atrule:Ao,keyword:Ao,"attr-name":Ao,function:{...rl,...Ho},delete:rl,tag:nl,selector:nl,important:Ho,bold:Ho,italic:lf};var al=["text","html","css","svg","javascript","java","c"];import{Element as Oo,Node as Uo,Transforms as ze}from"slate";function ll(e,t){if(!Oo.isElement(t[0]))return!1;if(t[0].type==="code-block-line"){for(let[o,r]of Uo.children(e,t[1]))if(Oo.isElement(o))return e.isVoid(o)?(ze.removeNodes(e,{at:r}),!0):(ze.unwrapNodes(e,{at:r}),!0)}if(t[0].type==="code-block"){for(let[o,r]of Uo.children(e,t[1]))if(Oo.isElement(o)&&o.type!=="code-block-line")return o.type==="code-block"?(ze.unwrapNodes(e,{at:r}),!0):e.isVoid(o)?(ze.removeNodes(e,{at:r}),!0):(ze.removeNodes(e,{at:r}),ze.insertNodes(e,{type:"code-block-line",children:[{text:Uo.string(o)}]}),!0)}return!1}import{useCallback as sf,useRef as mf}from"react";import{useSelected as cf}from"slate-react";import{jsx as sl}from"react/jsx-runtime";var ml=e=>sl(b,{...e,children:sl("path",{d:"m6 9 6 6 6-6"})});import At from"@emotion/styled";var cl=At("div")`
849
+ `;import{jsx as cf}from"react/jsx-runtime";function Za(e){return _.isElement(e)&&(e.type==="paragraph"||e.type==="code-block"||e.type==="table"||e.type==="horizontal-rule"||e.type==="task-list-item"||e.type==="unordered-list-item"||e.type==="ordered-list-item"||e.type==="heading")}var mf=2,el=x(e=>(e.supportsBlockQuote=!0,e.blockQuotePlugin={indent:()=>{He.wrapNodes(e,{type:"block-quote",children:[]},{match:Za})},outdent:()=>{He.liftNodes(e,{match:(t,o)=>Za(t)&&o.length>1})},isActive:()=>{let[t]=st.nodes(e,{match:o=>_.isElement(o)&&o.type==="block-quote"});return!!t},increaseDepth:()=>{let[t]=st.nodes(e,{match:r=>_.isElement(r)&&r.type==="block-quote"});if(!t||!e.blockQuotePlugin.canIncreaseDepth())return;let[,o]=t;He.select(e,o),He.wrapNodes(e,{type:"block-quote",children:[]},{at:o,split:!1})},decreaseDepth:()=>{let[t]=st.nodes(e,{match:i=>_.isElement(i)&&i.type==="block-quote"});if(!t||!e.blockQuotePlugin.canDecreaseDepth())return;let[o,r]=t,n=o.children;n.length===1&&_.isElement(n[0])&&n[0].type==="block-quote"&&He.unwrapNodes(e,{at:[...r,0],match:i=>_.isElement(i)&&i.type==="block-quote"})},canIncreaseDepth:()=>{let[t]=st.nodes(e,{match:i=>_.isElement(i)&&i.type==="block-quote"});if(!t)return!1;let[o]=t,r=0,n=o;for(;n.children.length===1&&_.isElement(n.children[0])&&n.children[0]&&n.children[0]&&n.children[0].type==="block-quote";)r++,n=n.children[0];return r<mf},canDecreaseDepth:()=>{let[t]=st.nodes(e,{match:r=>_.isElement(r)&&r.type==="block-quote"});if(!t)return!1;let[o]=t;return o.children.length===1&&_.isElement(o.children[0])&&o.children[0]&&o.children[0].type==="block-quote"}},{name:"block-quote",editor:{normalizeNode(t){let[o,r]=t;return!_.isElement(o)||o.type!=="block-quote"?!1:he(e,[o,r],(n,i)=>(_.isElement(n[0])&&_.isElement(i[0])&&n[0].type==="block-quote"&&i[0].type==="block-quote"&&He.mergeNodes(e,{at:i[1]}),!0))}},editableProps:{renderElement:({element:t,attributes:o,children:r})=>{if(t.type==="block-quote")return cf(Ya,{...o,children:r})},onKeyDown:B({"super+.":e.blockQuotePlugin.indent,"super+,":e.blockQuotePlugin.outdent})}}));import{Editor as Mf,Element as Pf,Transforms as yl}from"slate";import pf from"prismjs";import{Element as ff,Node as hf}from"slate";var{languages:df,tokenize:uf}=pf;function gf(e){let t=0,o=[];for(let r of e)o.push(t),t=t+r.length;return o}function tl(e){let[t,o]=e;if(!ff.isElement(t))return[];if(t.type!=="code-block")return[];let r=df[t.language];if(r===void 0)return[];let i=t.children.map(p=>`${hf.string(p)}
850
+ `),a=i.join(""),l=gf(i);function s(p){for(let g=l.length;g>=0;g--){let E=l[g];if(E<=p)return{path:[...o,g],offset:p-E}}throw new Error("This shouldn't happen and indicates a bug in the logic")}let c=[],m=uf(a,r),d=0;for(let p of m)if(typeof p=="string")d+=p.length;else{let g=s(d),E=s(d+p.length);c.push({anchor:g,focus:E,prismToken:p.type}),d+=p.length}return c}function ol(e,{language:t}){xt(e,{type:"code-block",language:t,children:[{type:"code-block-line",children:[{text:""}]}]})}import{Element as bf,Transforms as Ef}from"slate";function rl(e,t,o={}){let r=b(e,n=>bf.isElement(n)&&n.type==="code-block",{at:o.at});return r?(Ef.setNodes(e,{language:t},{at:r[1]}),!0):!1}function nl(e){return{createCodeBlock:u(ol,e),setCodeBlockLanguage:u(rl,e)}}var Kt={color:"#999988",fontStyle:"italic"},xf={opacity:"0.7"},il={color:"#e3116c"},al={color:"#393a34"},oe={color:"#36acaa"},_o={color:"#00a4db"},ll={color:"#9a050f"},sl={color:"#00009f"},Go={fontWeight:"bold"},yf={fontStyle:"italic"},ml={comment:Kt,prolog:Kt,doctype:Kt,cdata:Kt,namespace:xf,string:il,"attr-value":il,puncutation:al,operator:al,entity:oe,url:oe,symbol:oe,number:oe,boolean:oe,variable:oe,constant:oe,property:oe,regex:oe,insert:oe,atrule:_o,keyword:_o,"attr-name":_o,function:{...ll,...Go},delete:ll,tag:sl,selector:sl,important:Go,bold:Go,italic:yf};import{Element as qo,Node as Qo,Transforms as Ae}from"slate";function cl(e,t){if(!qo.isElement(t[0]))return!1;if(t[0].type==="code-block-line"){for(let[o,r]of Qo.children(e,t[1]))if(qo.isElement(o))return e.isVoid(o)?(Ae.removeNodes(e,{at:r}),!0):(Ae.unwrapNodes(e,{at:r}),!0)}if(t[0].type==="code-block"){for(let[o,r]of Qo.children(e,t[1]))if(qo.isElement(o)&&o.type!=="code-block-line")return o.type==="code-block"?(Ae.unwrapNodes(e,{at:r}),!0):e.isVoid(o)?(Ae.removeNodes(e,{at:r}),!0):(Ae.removeNodes(e,{at:r}),Ae.insertNodes(e,{type:"code-block-line",children:[{text:Qo.string(o)}]}),!0)}return!1}import{useCallback as jo,useState as hl}from"react";import{useSelected as kf,useSlateStatic as Tf}from"slate-react";import Wt from"@emotion/styled";var pl=Wt("div")`
850
851
  position: relative;
851
852
  background: var(--code-block-bgcolor);
852
853
  margin: 1em 0;
@@ -865,11 +866,11 @@
865
866
  * Otherwise they will be square.
866
867
  */
867
868
  overflow-x: hidden;
868
- `,pl=At("div")`
869
+ `,dl=Wt("div")`
869
870
  padding: 2.25em 1em 1.5em 1em;
870
871
  border-radius: 0.5em;
871
872
  overflow-x: auto;
872
- `,dl=At("span")`
873
+ `,ul=Wt("span")`
873
874
  cursor: pointer;
874
875
  position: absolute;
875
876
  top: 0.25em;
@@ -895,7 +896,7 @@
895
896
  color: var(--shade-800);
896
897
  background: var(--shade-300);
897
898
  }
898
- `,ul=At("div")`
899
+ `,fl=Wt("div")`
899
900
  white-space: pre;
900
901
  line-height: 1.5em;
901
902
  counter-increment: line;
@@ -918,9 +919,35 @@
918
919
  display: inline-block;
919
920
  width: 2em;
920
921
  } */
921
- `;import{jsx as rt,jsxs as fl}from"react/jsx-runtime";function hl({element:e,attributes:t,children:o}){let r=mf(null),n=cf(),i=S("code-block-dropdown"),a=sf(()=>{i.layer&&i.close();let l=r.current;if(l===null)return;let s=al.map(m=>({icon:()=>rt("span",{}),title:m,action:c=>{c.codeBlock.setCodeBlockLanguage(m,{at:e})}}));i.open(()=>rt(Ce,{dest:l,items:s,close:i.close}))},[e]);return fl(cl,{className:n?"--selected":"",...t,children:[fl(dl,{contentEditable:!1,onClick:a,ref:r,children:[rt("span",{children:e.language}),rt(ml,{})]}),rt(pl,{children:o})]})}import{useSelected as pf}from"slate-react";import{jsx as df}from"react/jsx-runtime";function gl({attributes:e,children:t}){let o=pf();return df(ul,{className:o?"--selected":"",...e,spellCheck:"false",children:t})}import{jsx as bl}from"react/jsx-runtime";function El({element:e,attributes:t,children:o}){if(e.type==="code-block")return bl(hl,{element:e,attributes:t,children:o});if(e.type==="code-block-line")return bl(gl,{element:e,attributes:t,children:o})}import{jsx as hf}from"react/jsx-runtime";var yl=x((e,t,{createPolicy:o})=>{e.codeBlock=el(e);function r(){let{selection:n}=e;if(!ge(n))return!1;let i=g(e,"code-block");return i==null?!1:uf.string(e,i[1])===""?(xl.removeNodes(e,{at:i[1]}),!0):!1}return o({name:"code-block",editor:{deleteBackward:r,deleteForward:r,isInline(n){if(n.type==="code-block"||n.type==="code-block-line")return!1},isVoid(n){if(n.type==="code-block"||n.type=="code-block-line")return!1},isMaster(n){if(n.type==="code-block")return!0},normalizeNode:d(ll,e)},editableProps:{decorate:Xa,onKeyDown:P({"super+`":()=>e.codeBlock.createCodeBlock({language:"text"}),"mod+a":()=>{let n=g(e,i=>ff.isElement(i)&&i.type==="code-block");return n?(xl.select(e,n[1]),!0):!1}}),renderElement:El,renderLeaf:({leaf:n,children:i})=>{let a=n.prismToken&&il[n.prismToken]||null;return a===null?i:hf("span",{style:a,children:i})}}})});import{Editor as Mf}from"slate";import{Element as yf}from"slate";import{Element as gf,Transforms as bf}from"slate";function kl(e){return gf.isElement(e)&&e.type==="paragraph"}function Tl(e,t){return pe(e,t,(o,r)=>!kl(o[0])||!kl(r[0])?!1:o[0].__collapsible&&r[0].__collapsible?(bf.removeNodes(e,{at:o[1]}),!0):!1)}import{Element as Ef,Transforms as xf}from"slate";function Fo(e,t){return Ef.isElement(t)?e.isVoid(t)||e.isMaster(t):!1}function vl(e,t){return Fo(e,t[0])?pe(e,t,(o,r)=>!Fo(e,o[0])||!Fo(e,r[0])?!1:(xf.insertNodes(e,{type:"paragraph",__collapsible:!0,children:[{text:""}]},{at:r[1]}),!0)):!1}function wl(e,t){let[o,r]=t;return yf.isElement(o)?!!(vl(e,[o,r])||Tl(e,[o,r])):!1}import{clsx as vf}from"clsx";import{useSelected as wf}from"slate-react";import kf from"@emotion/styled";var Il=kf("p")`
922
- padding: 0;
922
+ `;import{jsx as _t,jsxs as vf}from"react/jsx-runtime";function gl({element:e,attributes:t,children:o}){let r=Tf(),n=kf(),[i,a]=hl(!1),[l,s]=hl(e.language),c=jo(()=>{s(e.language),a(!0)},[e.language]),m=jo(()=>{a(!1),l!==e.language&&r.codeBlock.setCodeBlockLanguage(l||"text",{at:e})},[r,e,l]),d=jo(p=>{p.key==="Enter"?(p.preventDefault(),p.target.blur()):p.key==="Escape"&&(s(e.language),a(!1))},[e.language]);return vf(pl,{className:n?"--selected":"",...t,children:[_t(ul,{contentEditable:!1,children:i?_t("input",{type:"text",value:l,onChange:p=>s(p.target.value),onBlur:m,onKeyDown:d,autoFocus:!0,style:{width:"100%",border:"none",background:"transparent",font:"inherit",color:"inherit",padding:0,outline:"none",textAlign:"right"}}):_t("span",{onClick:c,style:{cursor:"pointer",width:"100%"},children:e.language||"text"})}),_t(dl,{children:o})]})}import{useSelected as wf}from"slate-react";import{jsx as If}from"react/jsx-runtime";function bl({attributes:e,children:t}){let o=wf();return If(fl,{className:o?"--selected":"",...e,spellCheck:"false",children:t})}import{jsx as El}from"react/jsx-runtime";function xl({element:e,attributes:t,children:o}){if(e.type==="code-block")return El(gl,{element:e,attributes:t,children:o});if(e.type==="code-block-line")return El(bl,{element:e,attributes:t,children:o})}import{jsx as Cf}from"react/jsx-runtime";var kl=x((e,t,{createPolicy:o})=>{e.codeBlock=nl(e);function r(){let{selection:n}=e;if(!ae(n))return!1;let i=b(e,"code-block");return i==null?!1:Mf.string(e,i[1])===""?(yl.removeNodes(e,{at:i[1]}),!0):!1}return o({name:"code-block",editor:{deleteBackward:r,deleteForward:r,isInline(n){if(n.type==="code-block"||n.type==="code-block-line")return!1},isVoid(n){if(n.type==="code-block"||n.type=="code-block-line")return!1},isMaster(n){if(n.type==="code-block")return!0},normalizeNode:u(cl,e)},editableProps:{decorate:tl,onKeyDown:B({"super+`":()=>e.codeBlock.createCodeBlock({language:"text"}),"mod+a":()=>{let n=b(e,i=>Pf.isElement(i)&&i.type==="code-block");return n?(yl.select(e,n[1]),!0):!1}}),renderElement:xl,renderLeaf:({leaf:n,children:i})=>{let a=n.prismToken&&ml[n.prismToken]||null;return a===null?i:Cf("span",{style:a,children:i})}}})});import{Transforms as Rf}from"slate";import Tl from"@emotion/styled";var vl=Tl("div")`
923
+ position: relative;
924
+ background-color: var(--shade-100);
925
+ border: 1px solid var(--shade-300);
926
+ border-radius: 0.5em;
927
+ padding: 2em 1em 1em 1em;
923
928
  margin: 1em 0;
929
+ font-family: "andale mono", AndaleMono, monospace;
930
+ font-size: 0.875em;
931
+ line-height: 1.5;
932
+ white-space: pre-wrap;
933
+ word-break: break-word;
934
+ color: var(--shade-700);
935
+ overflow-x: auto;
936
+
937
+ &.--selected {
938
+ outline: 2px solid var(--select-color);
939
+ }
940
+ `,wl=Tl("span")`
941
+ position: absolute;
942
+ top: 0.25em;
943
+ right: 0.5em;
944
+ font-size: 0.625em;
945
+ color: var(--shade-500);
946
+ text-transform: uppercase;
947
+ letter-spacing: 0.5px;
948
+ `;import{jsx as Il,jsxs as Sf}from"react/jsx-runtime";function Ml({attributes:e,children:t,element:o}){return Sf(vl,{...e,contentEditable:!1,children:[Il(wl,{children:"HTML"}),Il("div",{children:Ce(o.html)}),t]})}import{jsx as Lf}from"react/jsx-runtime";var Pl=x((e,t,{createPolicy:o})=>{function r(){let{selection:n}=e;if(!ae(n))return!1;let i=b(e,"html-block");return i==null?!1:(Rf.removeNodes(e,{at:i[1]}),!0)}return o({name:"html-block",editor:{deleteBackward:r,deleteForward:r,isInline(n){if(n.type==="html-block")return!1},isVoid(n){if(n.type==="html-block")return!0},isMaster(n){if(n.type==="html-block")return!0}},editableProps:{renderElement:({element:n,attributes:i,children:a})=>{if(n.type==="html-block")return Lf(Ml,{element:n,attributes:i,children:a})}}})});import{Editor as Dl}from"slate";import{Element as $f}from"slate";import{Element as Bf,Transforms as zf}from"slate";function Cl(e){return Bf.isElement(e)&&e.type==="paragraph"}function Sl(e,t){return he(e,t,(o,r)=>!Cl(o[0])||!Cl(r[0])?!1:o[0].__collapsible&&r[0].__collapsible?(zf.removeNodes(e,{at:o[1]}),!0):!1)}import{Element as Nf,Transforms as Df}from"slate";function Xo(e,t){return Nf.isElement(t)?e.isVoid(t)||e.isMaster(t):!1}function Rl(e,t){return Xo(e,t[0])?he(e,t,(o,r)=>!Xo(e,o[0])||!Xo(e,r[0])?!1:(Df.insertNodes(e,{type:"paragraph",__collapsible:!0,children:[{text:""}]},{at:r[1]}),!0)):!1}function Ll(e,t){let[o,r]=t;return $f.isElement(o)?!!(Rl(e,[o,r])||Sl(e,[o,r])):!1}import{clsx as Of}from"clsx";import{useSelected as Uf}from"slate-react";import Hf from"@emotion/styled";var Bl=Hf("p")`
949
+ padding: 0;
950
+ margin: 0;
924
951
  &:first-child {
925
952
  margin-top: 0;
926
953
  }
@@ -930,8 +957,8 @@
930
957
 
931
958
  &.--collapsible&.--empty {
932
959
  font-size: 0.25em; /* font-size is collapsed to 1/4 of regular em */
933
- margin: -4em 0; /* margin grows to 3/4 of regular em leaving space */
934
- padding: 1em 0; /* this is kind of eye-balling it */
960
+ margin: -0.4em 0;
961
+ padding: 0.1em 0; /* this is kind of eye-balling it */
935
962
  border-radius: 1em;
936
963
  &:hover {
937
964
  background: rgba(0, 127, 255, 0.1);
@@ -941,48 +968,49 @@
941
968
  &.--collapsible&.--empty&.--selected {
942
969
  font-size: 1em;
943
970
  padding: 0;
944
- margin: 1em 0;
971
+ margin: 0;
945
972
  &:hover {
946
973
  background: none;
947
974
  cursor: default;
948
975
  }
949
976
  border-radius: 8px;
950
977
  }
951
- `;import{Node as Tf}from"slate";function Ml(e){return e.children.length===1&&Tf.string(e.children[0]).length===0}import{jsx as If}from"react/jsx-runtime";function Pl({element:e,attributes:t,children:o}){let r=wf(),n=Ml(e);return If(Il,{...t,className:vf({"--selected":r,"--empty":n,"--collapsible":!!e.__collapsible}),children:o})}import{jsx as Pf}from"react/jsx-runtime";var Cl=x(e=>{let{insertBreak:t}=e;if(e.insertBreak=()=>{let{selection:o}=e;if(o&&o.anchor.path[0]===o.focus.path[0]){let r=Mf.string(e,[o.anchor.path[0]]);r.match(/\n$/)||r.match(/\n\n/)?t():e.insertText(`
952
- `)}else t()},e.convertElement.addConvertElementType("paragraph"),e.collapsibleParagraph={convertParagraph:()=>{e.convertElement.convertElements(()=>!1,{type:"paragraph"},!1)}},!e.normalizeAfterDelete)throw new Error("The collapsible-paragraph-plugin has a dependency on the normalize-after-delete plugin. Please add that plugin before this one.");return{name:"collapsible-paragraph",editor:{normalizeNode:d(wl,e)},editableProps:{renderElement:({element:o,attributes:r,children:n})=>{switch(o.type){case"paragraph":return Pf(Pl,{element:o,attributes:r,children:n})}},onKeyDown:P({"super+0":e.collapsibleParagraph.convertParagraph})}}});function Sl(e,t){Array.isArray(t)?e.convertElement.convertElementTypes.push(...t):e.convertElement.convertElementTypes.push(t)}import{Editor as ne,Element as Rl,Node as Ot,Point as Ht,Transforms as nt}from"slate";function Cf(e){return Ot.string(e).includes(`
953
- `)}function Sf(e,t,o,r){let n=Ot.string(t),i=n.split(`
954
- `),a=ne.start(e,o),l=ne.end(e,o),s=Ht.isBefore(r.anchor,a)?a:Ht.isAfter(r.anchor,l)?l:r.anchor,m=Ht.isBefore(r.focus,a)?a:Ht.isAfter(r.focus,l)?l:r.focus,c=Math.min(ne.string(e,{anchor:a,focus:s}).length,n.length),p=Math.min(ne.string(e,{anchor:a,focus:m}).length,n.length),h=Math.min(c,p),y=Math.max(c,p),E=0,k=0,C=i.length-1;for(let T=0;T<i.length;T++){let z=E+i[T].length;if(E<=h&&h<=z&&(k=T),E<=y&&y<=z){C=T;break}E=z+1}return{startLineIndex:k,endLineIndex:C}}function Rf(e,t,o,r){let n=Ot.string(t);if(!n.includes(`
978
+ `;import{Node as Af}from"slate";function zl(e){return e.children.length===1&&Af.string(e.children[0]).length===0}import{jsx as Ff}from"react/jsx-runtime";function Nl({element:e,attributes:t,children:o}){let r=Uf(),n=zl(e);return Ff(Bl,{...t,className:Of({"--selected":r,"--empty":n,"--collapsible":!!e.__collapsible}),children:o})}import{jsx as Vf}from"react/jsx-runtime";var $l=x(e=>{let{insertBreak:t}=e;if(e.insertBreak=()=>{let{selection:o}=e;if(o&&o.anchor.path[0]===o.focus.path[0]){let r=[o.anchor.path[0]],n=Dl.start(e,r);Dl.string(e,{anchor:n,focus:o.anchor}).endsWith(`
979
+ `)?t():e.insertText(`
980
+ `)}else t()},e.convertElement.addConvertElementType("paragraph"),e.collapsibleParagraph={convertParagraph:()=>{e.convertElement.convertElements(()=>!1,{type:"paragraph"},!1)}},!e.normalizeAfterDelete)throw new Error("The collapsible-paragraph-plugin has a dependency on the normalize-after-delete plugin. Please add that plugin before this one.");return{name:"collapsible-paragraph",editor:{normalizeNode:u(Ll,e)},editableProps:{renderElement:({element:o,attributes:r,children:n})=>{switch(o.type){case"paragraph":return Vf(Nl,{element:o,attributes:r,children:n})}},onKeyDown:B({"super+0":e.collapsibleParagraph.convertParagraph})}}});function Hl(e,t){Array.isArray(t)?e.convertElement.convertElementTypes.push(...t):e.convertElement.convertElementTypes.push(t)}import{Editor as O,Element as Gt,Node as Y,Point as Oe,Range as Kf,Transforms as ve}from"slate";function Al(e,t,o){try{let r=O.start(e,o),n=O.end(e,o);if(Oe.isBefore(t,r)||Oe.isAfter(t,n))return-1;let i={anchor:r,focus:t};return O.string(e,i).length}catch{return-1}}function Ol(e,t,o){try{let r=Y.get(e,t);if(!Gt.isElement(r))return;let n=Y.string(r),i=Math.min(o,n.length),a=O.start(e,t),l=0,s=a.path,c=0;for(let[d,p]of Y.texts(r)){let g=d.text.length;if(l+g>=i){s=[...t,...p],c=i-l;break}l+=g}let m={path:s,offset:c};ve.select(e,{anchor:m,focus:m})}catch{}}function Wf(e){return Y.string(e).includes(`
981
+ `)}function _f(e,t,o,r){let n=Y.string(t),i=n.split(`
982
+ `),a=O.start(e,o),l=O.end(e,o),s=Oe.isBefore(r.anchor,a)?a:Oe.isAfter(r.anchor,l)?l:r.anchor,c=Oe.isBefore(r.focus,a)?a:Oe.isAfter(r.focus,l)?l:r.focus,m=Math.min(O.string(e,{anchor:a,focus:s}).length,n.length),d=Math.min(O.string(e,{anchor:a,focus:c}).length,n.length),p=Math.min(m,d),g=Math.max(m,d),E=0,T=0,M=i.length-1;for(let I=0;I<i.length;I++){let v=E+i[I].length;if(E<=p&&p<=v&&(T=I),E<=g&&g<=v){M=I;break}E=v+1}return{startLineIndex:T,endLineIndex:M}}function Gf(e,t,o,r){let n=Y.string(t);if(!n.includes(`
955
983
  `))return o;let i=n.split(`
956
- `);if(i.length<=1)return o;let{startLineIndex:a,endLineIndex:l}=Sf(e,t,o,r),s=i.slice(0,a),m=i.slice(a,l+1),c=i.slice(l+1);return s.length===0&&c.length===0?o:(ne.withoutNormalizing(e,()=>{let p=o.slice(0,-1),h=o[o.length-1];if(c.length>0){let E=c.join(`
957
- `),k={...t,children:[{text:E}]};nt.insertNodes(e,k,{at:[...p,h+1]})}let y=t.children.length;for(let E=y-1;E>=0;E--)nt.removeNodes(e,{at:[...o,E]});if(s.length>0){nt.insertNodes(e,{text:s.join(`
958
- `)},{at:[...o,0]});let k={type:"paragraph",children:[{text:m.join(`
959
- `)}]};nt.insertNodes(e,k,{at:[...p,h+1]})}else nt.insertNodes(e,{text:m.join(`
960
- `)},{at:[...o,0]})}),s.length>0?[...o.slice(0,-1),o[o.length-1]+1]:o)}function Ll(e,t,o,r){let{selection:n}=e;if(!n)return!1;let i=Array.from(ne.nodes(e,{match:m=>Rl.isElement(m)&&e.convertElement.isConvertibleElement(m)}));if(i.length===0)return!1;let a=[];ne.withoutNormalizing(e,()=>{for(let m=i.length-1;m>=0;m--){let[c,p]=i[m];if(Cf(c)){let h=Rf(e,c,p,n);a.unshift(h)}else a.unshift(p)}});let l=a.map(m=>{try{let c=Ot.get(e,m);return Rl.isElement(c)?[c,m]:null}catch{return null}}).filter(m=>m!==null);return l.length===0?!1:(r&&l.every(m=>t(m[0]))?ne.withoutNormalizing(e,()=>{for(let m of l)Ye(e,{type:"paragraph"},m[1])}):ne.withoutNormalizing(e,()=>{for(let m of l)Ye(e,o,m[1])}),!0)}function zl(e,t){return e.convertElement.convertElementTypes.includes(t.type)}function Bl(e){return{convertElementTypes:[],addConvertElementType:d(Sl,e),isConvertibleElement:d(zl,e),convertElements:d(Ll,e)}}var Nl=x(e=>(e.convertElement=Bl(e),{name:"convert-element"}));import{Editor as Vo,Path as Lf,Range as zf,Transforms as Dl}from"slate";function $l(e){let t=g(e,"heading");if(!t||!e.selection||zf.isExpanded(e.selection)||!Vo.isEnd(e,e.selection.anchor,t[1]))return!1;let o=Lf.next(t[1]);return Dl.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:o}),Dl.select(e,{anchor:Vo.start(e,o),focus:Vo.start(e,o)}),!0}import{Editor as Bf}from"slate";function Nf(e,t,o){e.convertElement.convertElements(r=>r.type==="heading"&&r.level==t,{type:"heading",level:t},o)}function Df(e,t){let[o]=Bf.nodes(e,{match:r=>"type"in r&&"level"in r&&r.type==="heading"&&r.level===t});return!!o}function Al(e){return{convertHeading:d(Nf,e),isHeadingActive:d(Df,e)}}import{css as $f}from"@emotion/react";import Be from"@emotion/styled";var Ne=$f`
984
+ `);if(i.length<=1)return o;let{startLineIndex:a,endLineIndex:l}=_f(e,t,o,r),s=i.slice(0,a),c=i.slice(a,l+1),m=i.slice(l+1);return s.length===0&&m.length===0?o:(O.withoutNormalizing(e,()=>{let d=o.slice(0,-1),p=o[o.length-1];if(m.length>0){let E=m.join(`
985
+ `),T={...t,children:[{text:E}]};ve.insertNodes(e,T,{at:[...d,p+1]})}let g=t.children.length;for(let E=g-1;E>=0;E--)ve.removeNodes(e,{at:[...o,E]});if(s.length>0){ve.insertNodes(e,{text:s.join(`
986
+ `)},{at:[...o,0]});let T={type:"paragraph",children:[{text:c.join(`
987
+ `)}]};ve.insertNodes(e,T,{at:[...d,p+1]})}else ve.insertNodes(e,{text:c.join(`
988
+ `)},{at:[...o,0]})}),s.length>0?[...o.slice(0,-1),o[o.length-1]+1]:o)}function Ul(e,t,o,r){let{selection:n}=e;if(!n)return!1;let i=Array.from(O.nodes(e,{match:p=>Gt.isElement(p)&&e.convertElement.isConvertibleElement(p)}));if(i.length===0)return!1;let a=-1,l=-1,s=Kf.isCollapsed(n);if(i.length>0){let[,p]=i[0];a=Al(e,n.anchor,p),l=Al(e,n.focus,p)}let c=[];O.withoutNormalizing(e,()=>{for(let p=i.length-1;p>=0;p--){let[g,E]=i[p];if(Wf(g)){let T=Gf(e,g,E,n);c.unshift(T)}else c.unshift(E)}});let m=c.map(p=>{try{let g=Y.get(e,p);return Gt.isElement(g)?[g,p]:null}catch{return null}}).filter(p=>p!==null);if(m.length===0)return!1;if(r&&m.every(p=>t(p[0]))?O.withoutNormalizing(e,()=>{for(let p of m)nt(e,{type:"paragraph"},p[1])}):O.withoutNormalizing(e,()=>{for(let p of m)nt(e,o,p[1])}),m.length>0&&a>=0){let[,p]=m[0];if(s)Ol(e,p,a);else if(l>=0)try{let g=Y.get(e,p);if(Gt.isElement(g)){let E=Y.string(g),T=Math.min(a,E.length),M=Math.min(l,E.length),I=O.start(e,p),v=I.path,k=T,w=0;for(let[ne,P]of Y.texts(g)){let L=ne.text.length;if(w+L>=T){v=[...p,...P],k=T-w;break}w+=L}let D=I.path,H=M;w=0;for(let[ne,P]of Y.texts(g)){let L=ne.text.length;if(w+L>=M){D=[...p,...P],H=M-w;break}w+=L}ve.select(e,{anchor:{path:v,offset:k},focus:{path:D,offset:H}})}}catch{Ol(e,p,a)}}return!0}function Fl(e,t){return e.convertElement.convertElementTypes.includes(t.type)}function Vl(e){return{convertElementTypes:[],addConvertElementType:u(Hl,e),isConvertibleElement:u(Fl,e),convertElements:u(Ul,e)}}var Kl=x(e=>(e.convertElement=Vl(e),{name:"convert-element"}));import{Editor as Jo,Path as qf,Range as Qf,Transforms as Wl}from"slate";function _l(e){let t=b(e,"heading");if(!t||!e.selection||Qf.isExpanded(e.selection)||!Jo.isEnd(e,e.selection.anchor,t[1]))return!1;let o=qf.next(t[1]);return Wl.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:o}),Wl.select(e,{anchor:Jo.start(e,o),focus:Jo.start(e,o)}),!0}import{Editor as jf}from"slate";function Xf(e,t,o){e.convertElement.convertElements(r=>r.type==="heading"&&r.level==t,{type:"heading",level:t},o)}function Jf(e,t){let[o]=jf.nodes(e,{match:r=>"type"in r&&"level"in r&&r.type==="heading"&&r.level===t});return!!o}function Gl(e){return{convertHeading:u(Xf,e),isHeadingActive:u(Jf,e)}}import{css as Yf}from"@emotion/react";import Ue from"@emotion/styled";var Fe=Yf`
961
989
  margin-top: 1em;
962
990
  &:first-child {
963
991
  margin-top: 0;
964
992
  }
965
993
  font-weight: bold;
966
- `,Hl=Be("h1")`
967
- ${Ne}
994
+ `,ql=Ue("h1")`
995
+ ${Fe}
968
996
  font-size: 2.25em;
969
997
  letter-spacing: -0.01em;
970
- `,Ol=Be("h2")`
971
- ${Ne}
998
+ `,Ql=Ue("h2")`
999
+ ${Fe}
972
1000
  font-size: 1.5em;
973
- `,Ul=Be("h3")`
974
- ${Ne}
1001
+ `,jl=Ue("h3")`
1002
+ ${Fe}
975
1003
  font-size: 1.25em;
976
- `,Fl=Be("h4")`
977
- ${Ne}
1004
+ `,Xl=Ue("h4")`
1005
+ ${Fe}
978
1006
  font-size: 1em;
979
- `,Vl=Be("h5")`
980
- ${Ne}
1007
+ `,Jl=Ue("h5")`
1008
+ ${Fe}
981
1009
  font-size: 1em;
982
- `,Kl=Be("h6")`
983
- ${Ne}
1010
+ `,Yl=Ue("h6")`
1011
+ ${Fe}
984
1012
  font-size: 1em;
985
- `;import{jsx as De}from"react/jsx-runtime";var _l=x(e=>{e.convertElement.addConvertElementType("heading"),e.heading=Al(e);let t=P({"super+1":$(e.heading.convertHeading,1,!0),"super+2":$(e.heading.convertHeading,2,!0),"super+3":$(e.heading.convertHeading,3,!0),"super+4":$(e.heading.convertHeading,4,!0),"super+5":$(e.heading.convertHeading,5,!0),"super+6":$(e.heading.convertHeading,6,!0)}),o=Vn(e,{"#":$(e.heading.convertHeading,1,!1),"##":$(e.heading.convertHeading,2,!1),"###":$(e.heading.convertHeading,3,!1),"####":$(e.heading.convertHeading,4,!1),"#####":$(e.heading.convertHeading,5,!1),"######":$(e.heading.convertHeading,6,!1)});return{name:"heading",editor:{insertBreak:d($l,e)},editableProps:{renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="heading")switch(r.level){case 1:return De(Hl,{...n,children:i});case 2:return De(Ol,{...n,children:i});case 3:return De(Ul,{...n,children:i});case 4:return De(Fl,{...n,children:i});case 5:return De(Vl,{...n,children:i});case 6:return De(Kl,{...n,children:i});default:throw new Error(`Expected element.level to be 1-6 but got ${r.level}`)}},onKeyDown:r=>!!(t(r)||o(r))}}});import{useSelected as Hf}from"slate-react";import Af from"@emotion/styled";var Wl=Af("hr")`
1013
+ `;import{jsx as Ve}from"react/jsx-runtime";var Zl=x(e=>{e.convertElement.addConvertElementType("heading"),e.heading=Gl(e);let t=B({"super+1":V(e.heading.convertHeading,1,!0),"super+2":V(e.heading.convertHeading,2,!0),"super+3":V(e.heading.convertHeading,3,!0),"super+4":V(e.heading.convertHeading,4,!0),"super+5":V(e.heading.convertHeading,5,!0),"super+6":V(e.heading.convertHeading,6,!0)}),o=Yn(e,{"#":V(e.heading.convertHeading,1,!1),"##":V(e.heading.convertHeading,2,!1),"###":V(e.heading.convertHeading,3,!1),"####":V(e.heading.convertHeading,4,!1),"#####":V(e.heading.convertHeading,5,!1),"######":V(e.heading.convertHeading,6,!1)});return{name:"heading",editor:{insertBreak:u(_l,e)},editableProps:{renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="heading")switch(r.level){case 1:return Ve(ql,{...n,children:i});case 2:return Ve(Ql,{...n,children:i});case 3:return Ve(jl,{...n,children:i});case 4:return Ve(Xl,{...n,children:i});case 5:return Ve(Jl,{...n,children:i});case 6:return Ve(Yl,{...n,children:i});default:{let a=r.level;throw new Error(`Expected element.level to be 1-6 but got ${a}`)}}},onKeyDown:r=>!!(t(r)||o(r))}}});import{useSelected as eh}from"slate-react";import Zf from"@emotion/styled";var es=Zf("hr")`
986
1014
  position: relative;
987
1015
  height: 1em;
988
1016
  /* background-color: var(--hr-color); */
@@ -1012,7 +1040,7 @@
1012
1040
  outline: 2px solid var(--select-color, blue);
1013
1041
  }
1014
1042
  }
1015
- `;import{jsx as Gl,jsxs as Of}from"react/jsx-runtime";function ql({attributes:e,children:t}){let o=Hf();return Of("div",{...e,draggable:!0,children:[t,Gl("div",{contentEditable:!1,children:Gl(Wl,{className:o?"--selected":""})})]})}function Uf(e){return bt(e,{type:"horizontal-rule",children:[{text:""}]})}function Ql(e){return{insertHorizontalRule:d(Uf,e)}}import{jsx as Ff}from"react/jsx-runtime";var jl=x((e,t,{createPolicy:o})=>(e.horizontalRule=Ql(e),o({name:"horizontal-rule",editor:{isVoid(r){if(r.type==="horizontal-rule")return!0}},editableProps:{renderElement:r=>{if(r.element.type==="horizontal-rule")return Ff(ql,{...r})},onKeyDown:P({"super+-":e.horizontalRule.insertHorizontalRule})}})));import Jl from"@emotion/styled";var Xl=Jl("code")`
1043
+ `;import{jsx as ts,jsxs as th}from"react/jsx-runtime";function os({attributes:e,children:t}){let o=eh();return th("div",{...e,draggable:!0,children:[t,ts("div",{contentEditable:!1,children:ts(es,{className:o?"--selected":""})})]})}function oh(e){return xt(e,{type:"horizontal-rule",children:[{text:""}]})}function rs(e){return{insertHorizontalRule:u(oh,e)}}import{jsx as rh}from"react/jsx-runtime";var ns=x((e,t,{createPolicy:o})=>(e.horizontalRule=rs(e),o({name:"horizontal-rule",editor:{isVoid(r){if(r.type==="horizontal-rule")return!0}},editableProps:{renderElement:r=>{if(r.element.type==="horizontal-rule")return rh(os,{...r})},onKeyDown:B({"super+-":e.horizontalRule.insertHorizontalRule})}})));import is from"@emotion/styled";var as=is("code")`
1016
1044
  color: var(--shade-600);
1017
1045
  background-color: var(--inline-code-bgcolor);
1018
1046
  border: 1px solid var(--inline-code-border-color);
@@ -1033,17 +1061,16 @@
1033
1061
  */
1034
1062
  font-size: 0.75em;
1035
1063
  vertical-align: baseline;
1036
- `,Ko=Jl("span")`
1064
+ `,Yo=is("span")`
1037
1065
  display: inline-block;
1038
1066
  opacity: 0;
1039
1067
  width: 1px;
1040
1068
  overflow: hidden;
1041
- `;import{jsx as Yl,jsxs as Vf}from"react/jsx-runtime";var Zl=x(e=>{if(!e.marksPlugin)throw new Error("InlineCodePlugin has a dependency on the MarksPlugin but the MarksPlugin has not been added or is added after the InlineCodePlugin");return e.inlineCode={toggleInlineCode:()=>e.marksPlugin.toggleMark("code")},{name:"inline-code",editableProps:{renderLeaf:({leaf:t,children:o})=>t.code?Vf(Xl,{spellCheck:!1,children:[Yl(Ko,{contentEditable:!1,children:"|"}),o,Yl(Ko,{contentEditable:!1,children:"|"})]}):o,onKeyDown:P({"mod+j":()=>e.inlineCode.toggleInlineCode()})}}});import{Editor as ws,Path as Is}from"slate";function es(e,t){return e.convertElement.convertElements(o=>o.type==="ordered-list-item",o=>({type:"ordered-list-item",depth:"depth"in o?o.depth:0}),t)}function ts(e,t){return e.convertElement.convertElements(o=>o.type==="task-list-item",o=>({type:"task-list-item",checked:"checked"in o?o.checked:!1,depth:"depth"in o?o.depth:0}),t)}function os(e,t){return e.convertElement.convertElements(o=>o.type==="unordered-list-item",o=>({type:"unordered-list-item",depth:"depth"in o?o.depth:0}),t)}var Kf=2;function Ut(e){let t=g(e,w);return t?t[0].depth:0}function _o(e){return be(e,w)?Ut(e)<Kf:!1}function Wo(e){return be(e,w)?Ut(e)>0:!1}function rs(e){_o(e)&&e.list.indent()}function ns(e){Wo(e)&&e.list.outdent()}function is(e){return Et(e,t=>({depth:t.depth+1}),{match:w})}import{Editor as _f,Transforms as Go}from"slate";function as(e){let t=g(e,w);if(!t)return!1;let[o,r]=t;if(_f.isEmpty(e,o))return o.depth>0?(Go.setNodes(e,{depth:o.depth-1},{at:r}),!0):(Ye(e,{type:"paragraph"},r),!0);Go.splitNodes(e,{always:!0});let n=g(e,w);return n&&n[0].type==="task-list-item"&&n[0].checked===!0&&Go.setNodes(e,{checked:!1},{at:n[1]}),!0}import{Editor as Wf}from"slate";function ls(e){let t=Array.from(Wf.nodes(e,{match:w}));for(let o of t)if(o[0].depth===0)return!0;return Et(e,o=>({depth:Math.max(0,o.depth-1)}),{match:w})}import{Transforms as Gf}from"slate";function ss(e,{at:t=e.selection}={}){let o=g(e,"task-list-item",{at:t});if(!o)return!1;let r=!o[0].checked;Gf.setNodes(e,{checked:r},{at:o[1]})}function ms(e){return{indent:d(is,e),outdent:d(ls,e),convertUnorderedList:d(os,e),convertOrderedList:d(es,e),convertTaskList:d(ts,e),insertBreak:d(as,e),toggleTaskListItem:d(ss,e),getListDepth:d(Ut,e),canIncreaseDepth:d(_o,e),canDecreaseDepth:d(Wo,e),increaseDepth:d(rs,e),decreaseDepth:d(ns,e)}}import{Element as qf,Transforms as Qf}from"slate";var cs=gt(["ordered-list-item"]);function Ft(e,t){let[o,r]=t;return qf.isElement(o)?pe(e,[o,r],(n,i)=>{if(!cs(i[0]))return!1;let a=cs(n[0])||w(n[0])?i[0].depth>n[0].depth:!0;return i[0].__firstAtDepth!==a?(Qf.setNodes(e,{__firstAtDepth:a},{at:i[1]}),!0):!1}):!1}function ps(e,t){let[o]=t;return w(o)?Ft(e,t):!1}import{clsx as Jf}from"clsx";import{useEffect as Xf}from"react";import{ReactEditor as Yf,useSlateStatic as Zf}from"slate-react";import Vt from"@emotion/styled";var qo=Vt("li")`
1069
+ `;import{jsx as ls,jsxs as nh}from"react/jsx-runtime";var ss=x(e=>{if(!e.marksPlugin)throw new Error("InlineCodePlugin has a dependency on the MarksPlugin but the MarksPlugin has not been added or is added after the InlineCodePlugin");return e.inlineCode={toggleInlineCode:()=>e.marksPlugin.toggleMark("code")},{name:"inline-code",editableProps:{renderLeaf:({leaf:t,children:o})=>t.code?nh(as,{spellCheck:!1,children:[ls(Yo,{contentEditable:!1,children:"|"}),o,ls(Yo,{contentEditable:!1,children:"|"})]}):o,onKeyDown:B({"mod+j":()=>e.inlineCode.toggleInlineCode()})}}});import{Editor as zs,Path as Ns}from"slate";function ms(e,t){return e.convertElement.convertElements(o=>o.type==="ordered-list-item",o=>({type:"ordered-list-item",depth:"depth"in o?o.depth:0}),t)}function cs(e,t){return e.convertElement.convertElements(o=>o.type==="task-list-item",o=>({type:"task-list-item",checked:"checked"in o?o.checked:!1,depth:"depth"in o?o.depth:0}),t)}function ps(e,t){return e.convertElement.convertElements(o=>o.type==="unordered-list-item",o=>({type:"unordered-list-item",depth:"depth"in o?o.depth:0}),t)}var ih=2;function qt(e){let t=b(e,S);return t?t[0].depth:0}function Zo(e){return ke(e,S)?qt(e)<ih:!1}function er(e){return ke(e,S)?qt(e)>0:!1}function ds(e){Zo(e)&&e.list.indent()}function us(e){er(e)&&e.list.outdent()}function fs(e){return yt(e,t=>({depth:t.depth+1}),{match:S})}import{Editor as ah,Transforms as tr}from"slate";function hs(e){let t=b(e,S);if(!t)return!1;let[o,r]=t;if(ah.isEmpty(e,o))return o.depth>0?(tr.setNodes(e,{depth:o.depth-1},{at:r}),!0):(nt(e,{type:"paragraph"},r),!0);tr.splitNodes(e,{always:!0});let n=b(e,S);return n&&n[0].type==="task-list-item"&&n[0].checked===!0&&tr.setNodes(e,{checked:!1},{at:n[1]}),!0}import{Editor as lh}from"slate";function gs(e){let t=Array.from(lh.nodes(e,{match:S}));for(let o of t)if(o[0].depth===0)return!0;return yt(e,o=>({depth:Math.max(0,o.depth-1)}),{match:S})}import{Transforms as sh}from"slate";function bs(e,{at:t=e.selection}={}){let o=b(e,"task-list-item",{at:t});if(!o)return!1;let r=!o[0].checked;sh.setNodes(e,{checked:r},{at:o[1]})}function Es(e){return{indent:u(fs,e),outdent:u(gs,e),convertUnorderedList:u(ps,e),convertOrderedList:u(ms,e),convertTaskList:u(cs,e),insertBreak:u(hs,e),toggleTaskListItem:u(bs,e),getListDepth:u(qt,e),canIncreaseDepth:u(Zo,e),canDecreaseDepth:u(er,e),increaseDepth:u(ds,e),decreaseDepth:u(us,e)}}import{Element as mh,Transforms as ch}from"slate";var xs=Et(["ordered-list-item"]);function Qt(e,t){let[o,r]=t;return mh.isElement(o)?he(e,[o,r],(n,i)=>{if(!xs(i[0]))return!1;let a=xs(n[0])||S(n[0])?i[0].depth>n[0].depth:!0;return i[0].__firstAtDepth!==a?(ch.setNodes(e,{__firstAtDepth:a},{at:i[1]}),!0):!1}):!1}function ys(e,t){let[o]=t;return S(o)?Qt(e,t):!1}import{clsx as dh}from"clsx";import{useEffect as uh}from"react";import{ReactEditor as fh,useSlateStatic as hh}from"slate-react";import jt from"@emotion/styled";var or=jt("li")`
1042
1070
  margin-top: 0.5em;
1043
1071
  margin-bottom: 0.5em;
1044
1072
  list-style-position: outside;
1045
- margin-left: calc(2em + var(--list-item-depth) * 2em);
1046
- `,ds=Vt(qo)`
1073
+ `,ks=jt(or)`
1047
1074
  position: relative;
1048
1075
  list-style-type: none;
1049
1076
  .--list-item-icon {
@@ -1053,7 +1080,7 @@
1053
1080
  line-height: 1.5em;
1054
1081
  color: var(--shade-600);
1055
1082
  }
1056
- `,us=Vt(qo)`
1083
+ `,Ts=jt(or)`
1057
1084
  position: relative;
1058
1085
  list-style-type: none;
1059
1086
  counter-increment: var(--list-item-var);
@@ -1078,7 +1105,7 @@
1078
1105
  /* force numbers to be monospaced for better alignment */
1079
1106
  font-variant-numeric: tabular-nums;
1080
1107
  }
1081
- `,fs=Vt(qo)`
1108
+ `,vs=jt(or)`
1082
1109
  position: relative;
1083
1110
  list-style-type: none;
1084
1111
  .--list-item-icon {
@@ -1092,7 +1119,7 @@
1092
1119
  stroke-width: 3px;
1093
1120
  }
1094
1121
  }
1095
- `;import{jsx as eh}from"react/jsx-runtime";function hs({element:e,attributes:t,children:o}){let r=Zf();Xf(()=>{let a=Yf.findPath(r,e);Ft(r,[e,a])},[]);let n={"--list-item-depth":e.depth,"--list-item-var":`list-item-depth-${e.depth}`},i=Jf({"--first-at-depth":e.__firstAtDepth});return eh(us,{...t,className:i,style:n,children:o})}import{useCallback as th}from"react";import{useSlateStatic as oh}from"slate-react";import{jsx as xe,jsxs as xs}from"react/jsx-runtime";var gs=e=>xs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[xe("path",{d:"M0 0h24v24H0z",stroke:"none"}),xe("rect",{x:4,y:4,width:16,height:16,rx:2})]}),bs=e=>xs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-checkbox",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[xe("path",{d:"M0 0h24v24H0z",stroke:"none"}),xe("path",{d:"m9 11 3 3 8-8",className:"--checkmark"}),xe("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),Es=e=>xe("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em",...e,children:xe("path",{d:"M12 8.25a3.75 3.75 0 1 0 0 7.5 3.75 3.75 0 0 0 0-7.5z"})});import{jsx as Qo,jsxs as rh}from"react/jsx-runtime";function ys({element:e,attributes:t,children:o}){let r=oh(),n=th(()=>{r.list.toggleTaskListItem({at:e})},[r,e]),i={"--list-item-depth":e.depth};return rh(fs,{...t,style:i,children:[Qo("div",{className:"--list-item-icon",contentEditable:!1,children:e.checked?Qo(bs,{onClick:n,style:{cursor:"pointer"}}):Qo(gs,{onClick:n,style:{cursor:"pointer"}})}),o]})}import{jsx as ks,jsxs as nh}from"react/jsx-runtime";function Ts({element:e,attributes:t,children:o}){let r={"--list-item-depth":e.depth};return nh(ds,{...t,style:r,children:[ks("div",{className:"--list-item-icon",contentEditable:!1,children:ks(Es,{})}),o]})}import{jsx as jo}from"react/jsx-runtime";function vs({element:e,attributes:t,children:o}){switch(e.type){case"ordered-list-item":return jo(hs,{element:e,attributes:t,children:o});case"unordered-list-item":return jo(Ts,{element:e,attributes:t,children:o});case"task-list-item":return jo(ys,{element:e,attributes:t,children:o})}}var Ms=["unordered-list-item","ordered-list-item","task-list-item"],w=gt(Ms),Ps=x((e,t,{createPolicy:o})=>{e.convertElement.addConvertElementType(Ms);let r=e.list=ms(e),n=P({tab:r.indent,"shift+tab":r.outdent,"super+7":d(r.convertOrderedList,!0),"super+8":d(r.convertUnorderedList,!0),"super+9":d(r.convertTaskList,!0)});return o({name:"list",editor:{normalizeNode:i=>ps(e,i),insertBreak:r.insertBreak,deleteBackward:i=>{if(i!=="character"||!be(e,w))return!1;let a=g(e,w);if(!a)return!1;let l=a[1];if(!Is.hasPrevious(l))return e.collapsibleParagraph.convertParagraph(),!0;let s=Is.previous(l),m=ws.node(e,s);return w(m[0])?!1:(e.collapsibleParagraph.convertParagraph(),!0)}},editableProps:{renderElement:vs,onKeyDown(i){return ws.nodes(e,{match:w})?n(i):!1}}})});import{clsx as ch}from"clsx";import{Editor as Jo,Point as ph,Range as dh}from"slate";import{Editor as ih,Text as Cs,Transforms as ah}from"slate";function Ss(e,{at:t=e.selection}={}){if(t==null)return;let o=[...ih.nodes(e,{match:n=>Cs.isText(n),at:t})],r={};for(let[n]of o)for(let i of Object.keys(n))i!=="text"&&(r[i]=null);ah.setNodes(e,r,{match:n=>Cs.isText(n),split:!0,at:t})}import{Editor as ye,Point as lh,Range as sh}from"slate";function $e(e,t,o,{at:r=e.selection}={}){if(r==null)return;let n=sh.isRange(r)?r.focus:r,i=lh.isPoint(n)&&(ye.after(e,n)===null||ye.isEnd(e,n,ye.end(e,[]))),a=t,s=(ye.marks(e)||{})[a]===!0;if(i)if(!s)e.activeMarks={...e.activeMarks,[a]:!0};else{let{[a]:m,...c}=e.activeMarks||{};e.activeMarks=c}s?ye.removeMark(e,a):ye.addMark(e,a,!0),typeof o=="string"&&ye.removeMark(e,o)}function Rs(e){return{removeMarks:d(Ss,e),toggleMark:d($e,e),toggleBold:()=>$e(e,"bold"),toggleItalic:()=>$e(e,"italic"),toggleUnderline:()=>$e(e,"underline"),toggleStrike:()=>$e(e,"strike")}}import mh from"@emotion/styled";var Ls=mh("span")`
1122
+ `;import{jsx as gh}from"react/jsx-runtime";function ws({element:e,attributes:t,children:o}){let r=hh();uh(()=>{let a=fh.findPath(r,e);Qt(r,[e,a])},[]);let n={marginLeft:`${2+e.depth*2}em`,"--list-item-var":`list-item-depth-${e.depth}`},i=dh({"--first-at-depth":e.__firstAtDepth});return gh(Ts,{...t,className:i,style:n,children:o})}import{useCallback as bh}from"react";import{useSlateStatic as Eh}from"slate-react";import{jsx as we,jsxs as Cs}from"react/jsx-runtime";var Is=e=>Cs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[we("path",{d:"M0 0h24v24H0z",stroke:"none"}),we("rect",{x:4,y:4,width:16,height:16,rx:2})]}),Ms=e=>Cs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-checkbox",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[we("path",{d:"M0 0h24v24H0z",stroke:"none"}),we("path",{d:"m9 11 3 3 8-8",className:"--checkmark"}),we("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),Ps=e=>we("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em",...e,children:we("path",{d:"M12 8.25a3.75 3.75 0 1 0 0 7.5 3.75 3.75 0 0 0 0-7.5z"})});import{jsx as rr,jsxs as xh}from"react/jsx-runtime";function Ss({element:e,attributes:t,children:o}){let r=Eh(),n=bh(()=>{r.list.toggleTaskListItem({at:e})},[r,e]),i=`${2+e.depth*2}em`;return xh(vs,{...t,style:{marginLeft:i},children:[rr("div",{className:"--list-item-icon",contentEditable:!1,children:e.checked?rr(Ms,{onClick:n,style:{cursor:"pointer"}}):rr(Is,{onClick:n,style:{cursor:"pointer"}})}),o]})}import{jsx as Rs,jsxs as yh}from"react/jsx-runtime";function Ls({element:e,attributes:t,children:o}){let r=`${2+e.depth*2}em`;return yh(ks,{...t,style:{marginLeft:r},children:[Rs("div",{className:"--list-item-icon",contentEditable:!1,children:Rs(Ps,{})}),o]})}import{jsx as nr}from"react/jsx-runtime";function Bs({element:e,attributes:t,children:o}){switch(e.type){case"ordered-list-item":return nr(ws,{element:e,attributes:t,children:o});case"unordered-list-item":return nr(Ls,{element:e,attributes:t,children:o});case"task-list-item":return nr(Ss,{element:e,attributes:t,children:o})}}var Ds=["unordered-list-item","ordered-list-item","task-list-item"],S=Et(Ds),$s=x((e,t,{createPolicy:o})=>{e.convertElement.addConvertElementType(Ds);let r=e.list=Es(e),n=B({tab:r.indent,"shift+tab":r.outdent,"super+7":u(r.convertOrderedList,!0),"super+8":u(r.convertUnorderedList,!0),"super+9":u(r.convertTaskList,!0)});return o({name:"list",editor:{normalizeNode:i=>ys(e,i),insertBreak:r.insertBreak,deleteBackward:i=>{if(i!=="character"||!ke(e,S))return!1;let a=b(e,S);if(!a)return!1;let l=a[1];if(!Ns.hasPrevious(l))return e.collapsibleParagraph.convertParagraph(),!0;let s=Ns.previous(l),c=zs.node(e,s);return S(c[0])?!1:(e.collapsibleParagraph.convertParagraph(),!0)}},editableProps:{renderElement:Bs,onKeyDown(i){return zs.nodes(e,{match:S})?n(i):!1}}})});import{clsx as Mh}from"clsx";import{Editor as ir,Point as Ph,Range as Ch}from"slate";import{Editor as kh,Text as Hs,Transforms as Th}from"slate";function As(e,{at:t=e.selection}={}){if(t==null)return;let o=[...kh.nodes(e,{match:n=>Hs.isText(n),at:t})],r={};for(let[n]of o)for(let i of Object.keys(n))i!=="text"&&(r[i]=null);Th.setNodes(e,r,{match:n=>Hs.isText(n),split:!0,at:t})}import{Editor as Ie,Point as vh,Range as wh}from"slate";function Me(e,t,o,{at:r=e.selection}={}){if(r==null)return;let n=wh.isRange(r)?r.focus:r,i=vh.isPoint(n)&&(Ie.after(e,n)===null||Ie.isEnd(e,n,Ie.end(e,[]))),a=t,s=(Ie.marks(e)||{})[a]===!0;if(i)if(!s)e.activeMarks={...e.activeMarks,[a]:!0};else{let{[a]:c,...m}=e.activeMarks||{};e.activeMarks=m}s?Ie.removeMark(e,a):Ie.addMark(e,a,!0),typeof o=="string"&&Ie.removeMark(e,o)}function Os(e){return{removeMarks:u(As,e),toggleMark:u(Me,e),toggleBold:()=>Me(e,"bold"),toggleItalic:()=>Me(e,"italic"),toggleUnderline:()=>Me(e,"underline"),toggleStrike:()=>Me(e,"strike"),toggleHighlight:()=>Me(e,"highlight")}}import Ih from"@emotion/styled";var Us=Ih("span")`
1096
1123
  &.--bold {
1097
1124
  font-weight: bold;
1098
1125
  }
@@ -1112,7 +1139,10 @@
1112
1139
  &.--underline.--strike {
1113
1140
  text-decoration: underline line-through;
1114
1141
  }
1115
- `;import{jsx as uh}from"react/jsx-runtime";var zs=x(e=>{e.marksPlugin=Rs(e),e.activeMarks={};let t=P({"mod+b":e.marksPlugin.toggleBold,"mod+i":e.marksPlugin.toggleItalic,"mod+u":e.marksPlugin.toggleUnderline,"super+0":e.marksPlugin.removeMarks,"super+k":e.marksPlugin.toggleStrike}),{insertText:o}=e;e.insertText=n=>{if(e.activeMarks&&Object.keys(e.activeMarks).length>0){let{activeMarks:i}=e;Object.entries(i).forEach(([a,l])=>{l&&e.addMark(a,!0)})}o(n)};let{removeMarks:r}=e.marksPlugin;return e.marksPlugin.removeMarks=()=>{if(r(),e.selection){let n=dh.isRange(e.selection)?e.selection.focus:e.selection;ph.isPoint(n)&&(Jo.after(e,n)===null||Jo.isEnd(e,n,Jo.end(e,[])))&&(e.activeMarks={})}},{name:"marks",editableProps:{renderLeaf:({leaf:n,children:i})=>uh(Ls,{className:ch({"--bold":n.bold,"--italic":n.italic,"--underline":n.underline,"--strike":n.strike}),children:i}),onKeyDown:n=>!!t(n)}}});import{Editor as it,Point as Bs}from"slate";function Ns(e){if(!e.selection)return;let t=it.parent(e,e.selection);Wn(e,t[1])}var Ds=x(e=>(e.normalizeAfterDelete=!0,{name:"normalize-after-delete",editor:{deleteBackward(){if(!e.selection)return!1;let t=it.parent(e,e.selection);return Bs.equals(it.start(e,t[1]),e.selection.anchor)?function(){Ns(e)}:!1},deleteForward(){if(!e.selection)return!1;let t=it.parent(e,e.selection);return Bs.equals(it.end(e,t[1]),e.selection.anchor)?function(){Ns(e)}:!1}},editableProps:{}}));import{Element as Yh}from"slate";import{Editor as As,Path as gh,Transforms as Hs}from"slate";import{Editor as fh,Path as hh}from"slate";function $s(e,t,o){let r=[...fh.positions(e,{at:t})],n=[],i,a,l;i=a=r[0],l=Me(e,o,{at:i});for(let m of r){let c=Me(e,o,{at:m});if(l&&c&&hh.equals(l,c)||l==null&&c==null)a=m;else{let p={anchor:i,focus:a};n.push(p),i=a=m,l=c}}let s={anchor:i,focus:a};return n.push(s),n.reverse(),n}function Os(e,t){if(e.selection==null)return!1;let[o,r]=As.edges(e,e.selection),n=Me(e,t,{at:o}),i=Me(e,t,{at:r});if(!n&&!i||n&&i&&gh.equals(n,i))return!1;let a=$s(e,e.selection,t);return As.withoutNormalizing(e,()=>{for(let l of a)Hs.delete(e,{at:l});Hs.collapse(e,{edge:"start"})}),!0}import{Transforms as Lh}from"slate";function M(e,{at:t=e.selection}={}){if(t==null)return;let o=g(e,"table-cell",{at:t});if(!o)return;let r=g(e,"table-row",{at:t});if(!r)return;let n=g(e,"table",{at:t});if(!n)return;let[i,a]=n,[l,s]=r,[m,c]=o;return{tableElement:i,tablePath:a,tableColumns:i.columns,rowElement:l,rowPath:s,rowIndex:s.slice(-1)[0],rowCount:i.children.length,cellElement:m,cellPath:c,cellIndex:c.slice(-1)[0],cellCount:l.children.length}}import{Editor as bh,Transforms as Us}from"slate";function Ae(e,t=[{type:"table-content",children:[{text:""}]}]){return{type:"table-cell",children:t}}function Fs(e,{offset:t=0,at:o=e.selection}={}){let r=M(e,{at:o});if(r===void 0)return!1;let{tableElement:n,tablePath:i,cellIndex:a}=r,l=a+t;return bh.withoutNormalizing(e,()=>{let{columns:s}=n,m=[...s];m.splice(l,0,s[l]),Us.setNodes(e,{columns:m},{at:i}),n.children.forEach((c,p)=>{Us.insertNodes(e,Ae(l),{at:[...i,p,l]})})}),!0}import{Transforms as Eh}from"slate";function xh(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>Ae(t))}}function Xo(e,{at:t=e.selection,offset:o=0}={}){let r=M(e,{at:t});if(!r)return!1;let n=xh(r.tableElement.columns.length);return Eh.insertNodes(e,n,{at:[...r.tablePath,r.rowIndex+o]}),!0}function Vs(e,{at:t}={}){return Xo(e,{at:t,offset:1})}import{Editor as Yo,Element as yh,Path as kh,Transforms as at}from"slate";function Ks(e){return[...Array(e).keys()]}function Th(e){return Ks(e).map(()=>({align:"left"}))}function vh(e,t){return{type:"table",columns:Th(e),children:Ks(t).map(()=>wh(e))}}function wh(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>Ae(t))}}function _s(e,t,o,{at:r=e.selection}={}){let n=vh(t,o);return Ih(e,n,{at:r})}function Ih(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=g(e,n=>yh.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;Yo.withoutNormalizing(e,()=>{at.insertNodes(e,t,{at:o}),n&&(at.select(e,n),at.move(e))})}else{let n=kh.next(r[1]);Yo.withoutNormalizing(e,()=>{at.insertNodes(e,t,{at:n}),at.select(e,Yo.start(e,n))})}return!0}import{Path as Ws}from"slate";function Gs(e,t){let{cellIndex:o,rowIndex:r,rowCount:n,tablePath:i}=t;if(r<n-1)return X(e,[...i,r+1,o]),!0;try{return X(e,Ws.next(i)),!0}catch{return!1}}function qs(e,t){let{cellIndex:o,rowIndex:r,tablePath:n}=t;if(r>0)return X(e,[...n,r-1,o]),!0;try{return jn(e,Ws.previous(n)),!0}catch{return!1}}import{ReactEditor as Mh}from"slate-react";function Ph(){let e=window.getSelection();return e?e.getRangeAt(0).getBoundingClientRect():null}function Ch(e,t){return Mh.toDOMNode(e,t).getBoundingClientRect()}function Zo(e,t){let o=Ph();if(!o)return!1;let r=Ch(e,t);return o.right<r.right&&o.left>r.left&&o.bottom<r.bottom&&o.top>r.top}function Qs(e){let t=M(e);return t&&setTimeout(()=>{Zo(e,t.cellElement)||Gs(e,t)}),!1}function js(e){let t=M(e);return t&&setTimeout(()=>{Zo(e,t.cellElement)||qs(e,t)}),!1}import{Editor as Js,Transforms as er}from"slate";import{Transforms as Sh}from"slate";function He(e){let t=e.tablePlugin.getTableInfo();return t===void 0?!1:(Sh.removeNodes(e,{at:t.tablePath}),!0)}function Xs(e,{at:t=e.selection}={}){let o=M(e,{at:t});if(!o)return!1;let{tableElement:r,tablePath:n,rowIndex:i,cellIndex:a,cellCount:l}=o;if(l===1)return He(e);Js.withoutNormalizing(e,()=>{let s=[...r.columns];s.splice(a,1),er.setNodes(e,{columns:s},{at:n}),r.children.forEach((c,p)=>{er.removeNodes(e,{at:[...n,p,a]})});let m=Js.start(e,[...n,i,Math.min(a,l-2)]);er.select(e,m)})}import{Editor as Ys,Transforms as Zs}from"slate";function em(e,{at:t=e.selection}={}){let o=M(e,{at:t});return o===void 0?!1:o.rowCount===1?(He(e),!0):(Ys.withoutNormalizing(e,()=>{Zs.removeNodes(e,{at:o.rowPath}),Zs.select(e,Ys.start(e,[...o.tablePath,Math.min(o.rowIndex,o.rowCount-2),o.cellIndex]))}),!0)}import{Transforms as Rh}from"slate";function tm(e,t){let o=M(e);if(o===void 0)return!1;let{tableElement:r,tablePath:n,cellIndex:i}=o,a=r.columns.slice();return a.splice(i,1,{align:t.align}),Rh.setNodes(e,{columns:a},{at:n}),!0}function om(e){let t=M(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,rowCount:i,tablePath:a}=t;return o<r-1?(X(e,[...a,n,o+1]),!0):n<i-1?(X(e,[...a,n+1,0]),!0):(Vs(e),X(e,[...a,n+1,0]),!0)}function rm(e){let t=M(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,tablePath:i}=t;if(o>0)return X(e,[...i,n,o-1]),!0;if(n>0)return X(e,[...i,n-1,r-1]),!0}function nm(e){return{getTableInfo:d(M,e),insertTable:d(_s,e),insertColumn:d(Fs,e),insertRow:d(Xo,e),removeTable:d(He,e),removeColumn:d(Xs,e),removeRow:d(em,e),tabForward:d(om,e),tabBackward:d(rm,e),selectCell:d(zh,e),down:d(Qs,e),up:d(js,e),setTableColumnAlign:d(tm,e)}}function zh(e,{at:t=e.selection}={}){let o=M(e,{at:t});if(o===void 0)return!1;let{cellPath:r}=o;return Lh.select(e,r),!0}import{Transforms as Bh}from"slate";function Kt(e,t){let o=!1;return t[0].children.forEach((n,i)=>{n.children.forEach((l,s)=>{(l.x!==s||l.y!==i)&&(Bh.setNodes(e,{x:s,y:i},{at:[...t[1],i,s]}),o=!0)})}),o}import{Editor as Nh,Transforms as tr}from"slate";function im(e,t){let[o,r]=t;return o.children.length===1&&o.children[0].type==="table-content"?!1:(Nh.withoutNormalizing(e,()=>{tr.insertNodes(e,{type:"table-content",children:[{text:"X"}]},{at:[...t[1],0]});for(let n=o.children.length;n>=0;n--)tr.mergeNodes(e,{at:[...r,n]});tr.delete(e,{at:{path:[...r,0,0],offset:0},unit:"character"})}),!0)}import{useEffect as $h}from"react";import{ReactEditor as Ah,useSelected as Hh,useSlateStatic as Oh}from"slate-react";import Wt from"@emotion/styled";import ie from"@emotion/styled";var am=ie("div")`
1142
+ &.--highlight {
1143
+ background-color: #ffeb3b;
1144
+ }
1145
+ `;import{jsx as Sh}from"react/jsx-runtime";var Fs=x(e=>{e.marksPlugin=Os(e),e.activeMarks={};let t=B({"mod+b":e.marksPlugin.toggleBold,"mod+i":e.marksPlugin.toggleItalic,"mod+u":e.marksPlugin.toggleUnderline,"super+0":e.marksPlugin.removeMarks,"super+k":e.marksPlugin.toggleStrike}),{insertText:o}=e;e.insertText=n=>{if(e.activeMarks&&Object.keys(e.activeMarks).length>0){let{activeMarks:i}=e;Object.entries(i).forEach(([a,l])=>{l&&e.addMark(a,!0)})}o(n)};let{removeMarks:r}=e.marksPlugin;return e.marksPlugin.removeMarks=()=>{if(r(),e.selection){let n=Ch.isRange(e.selection)?e.selection.focus:e.selection;Ph.isPoint(n)&&(ir.after(e,n)===null||ir.isEnd(e,n,ir.end(e,[])))&&(e.activeMarks={})}},{name:"marks",editableProps:{renderLeaf:({leaf:n,children:i})=>Sh(Us,{className:Mh({"--bold":n.bold,"--italic":n.italic,"--underline":n.underline,"--strike":n.strike,"--highlight":n.highlight}),children:i}),onKeyDown:n=>!!t(n)}}});import{Editor as mt,Point as Vs}from"slate";function Ks(e){if(!e.selection)return;let t=mt.parent(e,e.selection);ti(e,t[1])}var Ws=x(e=>(e.normalizeAfterDelete=!0,{name:"normalize-after-delete",editor:{deleteBackward(){if(!e.selection)return!1;let t=mt.parent(e,e.selection);return Vs.equals(mt.start(e,t[1]),e.selection.anchor)?function(){Ks(e)}:!1},deleteForward(){if(!e.selection)return!1;let t=mt.parent(e,e.selection);return Vs.equals(mt.end(e,t[1]),e.selection.anchor)?function(){Ks(e)}:!1}},editableProps:{}}));import{Element as gg}from"slate";import{Editor as Gs,Path as Bh,Transforms as qs}from"slate";import{Editor as Rh,Path as Lh}from"slate";function _s(e,t,o){let r=[...Rh.positions(e,{at:t})],n=[],i,a,l;i=a=r[0],l=Be(e,o,{at:i});for(let c of r){let m=Be(e,o,{at:c});if(l&&m&&Lh.equals(l,m)||l==null&&m==null)a=c;else{let d={anchor:i,focus:a};n.push(d),i=a=c,l=m}}let s={anchor:i,focus:a};return n.push(s),n.reverse(),n}function Qs(e,t){if(e.selection==null)return!1;let[o,r]=Gs.edges(e,e.selection),n=Be(e,t,{at:o}),i=Be(e,t,{at:r});if(!n&&!i||n&&i&&Bh.equals(n,i))return!1;let a=_s(e,e.selection,t);return Gs.withoutNormalizing(e,()=>{for(let l of a)qs.delete(e,{at:l});qs.collapse(e,{edge:"start"})}),!0}import{Transforms as jh}from"slate";function R(e,{at:t=e.selection}={}){if(t==null)return;let o=b(e,"table-cell",{at:t});if(!o)return;let r=b(e,"table-row",{at:t});if(!r)return;let n=b(e,"table",{at:t});if(!n)return;let[i,a]=n,[l,s]=r,[c,m]=o;return{tableElement:i,tablePath:a,tableColumns:i.columns,rowElement:l,rowPath:s,rowIndex:s.slice(-1)[0],rowCount:i.children.length,cellElement:c,cellPath:m,cellIndex:m.slice(-1)[0],cellCount:l.children.length}}import{Editor as zh,Transforms as js}from"slate";function Ke(e,t=[{type:"table-content",children:[{text:""}]}]){return{type:"table-cell",children:t}}function Xs(e,{offset:t=0,at:o=e.selection}={}){let r=R(e,{at:o});if(r===void 0)return!1;let{tableElement:n,tablePath:i,cellIndex:a}=r,l=a+t;return zh.withoutNormalizing(e,()=>{let{columns:s}=n,c=[...s];c.splice(l,0,s[l]),js.setNodes(e,{columns:c},{at:i}),n.children.forEach((m,d)=>{js.insertNodes(e,Ke(l),{at:[...i,d,l]})})}),!0}import{Transforms as Nh}from"slate";function Dh(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>Ke(t))}}function ar(e,{at:t=e.selection,offset:o=0}={}){let r=R(e,{at:t});if(!r)return!1;let n=Dh(r.tableElement.columns.length);return Nh.insertNodes(e,n,{at:[...r.tablePath,r.rowIndex+o]}),!0}function Js(e,{at:t}={}){return ar(e,{at:t,offset:1})}import{Editor as lr,Element as $h,Path as Hh,Transforms as ct}from"slate";function Ys(e){return[...Array(e).keys()]}function Ah(e){return Ys(e).map(()=>({align:"left"}))}function Oh(e,t){return{type:"table",columns:Ah(e),children:Ys(t).map(()=>Uh(e))}}function Uh(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>Ke(t))}}function Zs(e,t,o,{at:r=e.selection}={}){let n=Oh(t,o);return Fh(e,n,{at:r})}function Fh(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=b(e,n=>$h.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;lr.withoutNormalizing(e,()=>{ct.insertNodes(e,t,{at:o}),n&&(ct.select(e,n),ct.move(e))})}else{let n=Hh.next(r[1]);lr.withoutNormalizing(e,()=>{ct.insertNodes(e,t,{at:n}),ct.select(e,lr.start(e,n))})}return!0}import{Path as em}from"slate";function tm(e,t){let{cellIndex:o,rowIndex:r,rowCount:n,tablePath:i}=t;if(r<n-1)return K(e,[...i,r+1,o]),!0;try{return K(e,em.next(i)),!0}catch{return!1}}function om(e,t){let{cellIndex:o,rowIndex:r,tablePath:n}=t;if(r>0)return K(e,[...n,r-1,o]),!0;try{return ii(e,em.previous(n)),!0}catch{return!1}}import{ReactEditor as Vh}from"slate-react";function Kh(){let e=window.getSelection();return e?e.getRangeAt(0).getBoundingClientRect():null}function Wh(e,t){return Vh.toDOMNode(e,t).getBoundingClientRect()}function sr(e,t){let o=Kh();if(!o)return!1;let r=Wh(e,t);return o.right<r.right&&o.left>r.left&&o.bottom<r.bottom&&o.top>r.top}function rm(e){let t=R(e);return t&&setTimeout(()=>{sr(e,t.cellElement)||tm(e,t)}),!1}function nm(e){let t=R(e);return t&&setTimeout(()=>{sr(e,t.cellElement)||om(e,t)}),!1}import{Editor as im,Transforms as mr}from"slate";import{Transforms as _h}from"slate";function We(e){let t=e.tablePlugin.getTableInfo();return t===void 0?!1:(_h.removeNodes(e,{at:t.tablePath}),!0)}function am(e,{at:t=e.selection}={}){let o=R(e,{at:t});if(!o)return!1;let{tableElement:r,tablePath:n,rowIndex:i,cellIndex:a,cellCount:l}=o;if(l===1)return We(e);im.withoutNormalizing(e,()=>{let s=[...r.columns];s.splice(a,1),mr.setNodes(e,{columns:s},{at:n}),r.children.forEach((m,d)=>{mr.removeNodes(e,{at:[...n,d,a]})});let c=im.start(e,[...n,i,Math.min(a,l-2)]);mr.select(e,c)})}import{Editor as lm,Transforms as sm}from"slate";function mm(e,{at:t=e.selection}={}){let o=R(e,{at:t});return o===void 0?!1:o.rowCount===1?(We(e),!0):(lm.withoutNormalizing(e,()=>{sm.removeNodes(e,{at:o.rowPath}),sm.select(e,lm.start(e,[...o.tablePath,Math.min(o.rowIndex,o.rowCount-2),o.cellIndex]))}),!0)}import{Transforms as Gh}from"slate";function cm(e,t){let o=R(e);if(o===void 0)return!1;let{tableElement:r,tablePath:n,cellIndex:i}=o,a=r.columns.slice();return a.splice(i,1,{align:t.align}),Gh.setNodes(e,{columns:a},{at:n}),!0}import{Path as qh,Transforms as Qh}from"slate";function pm(e){let t=R(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,rowCount:i,tablePath:a}=t;if(o<r-1)return K(e,[...a,n,o+1]),!0;if(n<i-1)return K(e,[...a,n+1,0]),!0;let l=qh.next(a);return Qh.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:l}),K(e,l),!0}function dm(e){let t=R(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,tablePath:i}=t;if(o>0)return K(e,[...i,n,o-1]),!0;if(n>0)return K(e,[...i,n-1,r-1]),!0}function um(e){let t=R(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,rowCount:i,tablePath:a}=t;return o<r-1?(K(e,[...a,n,o+1]),!0):n<i-1?(K(e,[...a,n+1,0]),!0):(Js(e),K(e,[...a,n+1,0]),!0)}function fm(e){return{getTableInfo:u(R,e),insertTable:u(Zs,e),insertColumn:u(Xs,e),insertRow:u(ar,e),removeTable:u(We,e),removeColumn:u(am,e),removeRow:u(mm,e),tabForward:u(pm,e),tabBackward:u(dm,e),shiftEnterForward:u(um,e),selectCell:u(Xh,e),down:u(rm,e),up:u(nm,e),setTableColumnAlign:u(cm,e)}}function Xh(e,{at:t=e.selection}={}){let o=R(e,{at:t});if(o===void 0)return!1;let{cellPath:r}=o;return jh.select(e,r),!0}import{Transforms as Jh}from"slate";function Xt(e,t){let o=!1;return t[0].children.forEach((n,i)=>{n.children.forEach((l,s)=>{(l.x!==s||l.y!==i)&&(Jh.setNodes(e,{x:s,y:i},{at:[...t[1],i,s]}),o=!0)})}),o}import{Editor as Yh,Transforms as cr}from"slate";function hm(e,t){let[o,r]=t;return o.children.length===1&&o.children[0].type==="table-content"?!1:(Yh.withoutNormalizing(e,()=>{cr.insertNodes(e,{type:"table-content",children:[{text:"X"}]},{at:[...t[1],0]});for(let n=o.children.length;n>=0;n--)cr.mergeNodes(e,{at:[...r,n]});cr.delete(e,{at:{path:[...r,0,0],offset:0},unit:"character"})}),!0)}import{useEffect as eg}from"react";import{ReactEditor as tg,useSelected as og,useSlateStatic as rg}from"slate-react";import Yt from"@emotion/styled";import se from"@emotion/styled";var gm=se("div")`
1116
1146
  position: absolute;
1117
1147
  /**
1118
1148
  * very slightly shaded
@@ -1136,7 +1166,7 @@
1136
1166
  background: rgba(0, 0, 0, 0.15);
1137
1167
  }
1138
1168
  }
1139
- `,lm=ie(am)`
1169
+ `,bm=se(gm)`
1140
1170
  cursor: pointer;
1141
1171
  /**
1142
1172
  * hangs out on top
@@ -1146,7 +1176,7 @@
1146
1176
  right: 0;
1147
1177
  height: 3em;
1148
1178
  top: -3em;
1149
- `,sm=ie(am)`
1179
+ `,Em=se(gm)`
1150
1180
  /**
1151
1181
  * hangs out on left
1152
1182
  */
@@ -1154,7 +1184,7 @@
1154
1184
  bottom: -1px;
1155
1185
  width: 3em;
1156
1186
  left: -3em;
1157
- `,mm=ie("div")`
1187
+ `,xm=se("div")`
1158
1188
  position: absolute;
1159
1189
  background: rgba(0, 0, 0, 0.05);
1160
1190
  border: 1px solid rgba(0, 0, 0, 0.05);
@@ -1166,7 +1196,7 @@
1166
1196
  left: 0;
1167
1197
  right: 0;
1168
1198
  bottom: 0;
1169
- `,cm=ie(mm)`
1199
+ `,ym=se(xm)`
1170
1200
  top: 50%;
1171
1201
  border-bottom: none;
1172
1202
  border-right: none;
@@ -1192,7 +1222,7 @@
1192
1222
 
1193
1223
  /* border-top-left-radius: 0.5em;
1194
1224
  border-top-right-radius: 0.5em; */
1195
- `,pm=ie(mm)`
1225
+ `,km=se(xm)`
1196
1226
  left: 50%;
1197
1227
  border-right: none;
1198
1228
  border-bottom: none;
@@ -1218,7 +1248,7 @@
1218
1248
 
1219
1249
  /* border-top-left-radius: 0.5em;
1220
1250
  border-bottom-left-radius: 0.5em; */
1221
- `,dm=ie("div")`
1251
+ `,Tm=se("div")`
1222
1252
  position: absolute;
1223
1253
  font-size: 1.5em;
1224
1254
  background: white;
@@ -1227,27 +1257,27 @@
1227
1257
  svg {
1228
1258
  display: block;
1229
1259
  }
1230
- `,Oe=ie(dm)`
1260
+ `,_e=se(Tm)`
1231
1261
  color: #c0c0c0;
1232
1262
  &:hover {
1233
1263
  color: royalblue;
1234
1264
  }
1235
- `,_t=ie(dm)`
1265
+ `,Jt=se(Tm)`
1236
1266
  color: #c0c0c0;
1237
1267
  &:hover {
1238
1268
  color: firebrick;
1239
1269
  }
1240
- `;var um=Wt("table")`
1270
+ `;var vm=Yt("table")`
1241
1271
  border-collapse: collapse;
1242
1272
  margin: 1em 0;
1243
1273
  ${({columns:e})=>e.map((t,o)=>`td:nth-of-type(${o+1}) { text-align: ${t.align}; }`).join(`
1244
1274
  `)}
1245
- `,fm=Wt("tr")`
1275
+ `,wm=Yt("tr")`
1246
1276
  position: relative;
1247
1277
  &:first-of-type {
1248
1278
  background: var(--table-head-bgcolor);
1249
1279
  }
1250
- `,hm=Wt("td")`
1280
+ `,Im=Yt("td")`
1251
1281
  position: relative;
1252
1282
  border-width: 1px;
1253
1283
  border-style: solid;
@@ -1267,7 +1297,7 @@
1267
1297
  &:last-of-type {
1268
1298
  border-right-color: var(--table-border-color);
1269
1299
  }
1270
- `,gm=Wt("div")`
1300
+ `,Mm=Yt("div")`
1271
1301
  /**
1272
1302
  * Smaller font inside a table than outside of it
1273
1303
  */
@@ -1279,7 +1309,7 @@
1279
1309
  color: rgba(0, 0, 0, 0.6);
1280
1310
  font-size: 0.875em; /* 14px */
1281
1311
  }
1282
- `;import{createContext as Dh}from"react";var Gt=Dh({isSelected:!1});import{jsx as or}from"react/jsx-runtime";function bm({element:e,attributes:t,children:o}){let r=Oh(),n=Hh();return $h(()=>{let i=Ah.findPath(r,e);Kt(r,[e,i])},[]),or(Gt.Provider,{value:{isSelected:n},children:or(um,{...t,columns:e.columns,children:or("tbody",{children:o})})})}import{useContext as qh}from"react";import{useSelected as Qh}from"slate-react";import{useCallback as rr,useRef as Uh,useState as Fh}from"react";import{useSlateStatic as Vh}from"slate-react";import{jsx as V}from"react/jsx-runtime";var Ue=e=>V("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"1em",height:"1em",...e,children:V("path",{fillRule:"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm.75-11.25a.75.75 0 0 0-1.5 0v2.5h-2.5a.75.75 0 0 0 0 1.5h2.5v2.5a.75.75 0 0 0 1.5 0v-2.5h2.5a.75.75 0 0 0 0-1.5h-2.5v-2.5z",clipRule:"evenodd"})}),qt=e=>V("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"1em",height:"1em",...e,children:V("path",{fillRule:"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM6.75 9.25a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5z",clipRule:"evenodd"})}),Qt=()=>V(b,{children:V("path",{d:"M4 6h16M4 12h16M4 18h16"})}),Em=()=>V(b,{children:V("path",{d:"M4 6h16M4 12h10M4 18h14"})}),xm=()=>V(b,{children:V("path",{d:"M4 6h16M8 12h8M6 18h12"})}),ym=()=>V(b,{children:V("path",{d:"M4 6h16M10 12h10M6 18h14"})});import{Fragment as Kh,jsx as ae,jsxs as km}from"react/jsx-runtime";function Tm({cellElement:e}){let t=Vh(),o=S("column-menu"),r=Uh(null),[n,i]=Fh(!1),a=rr(()=>{i(!0)},[]),l=rr(()=>{i(!1)},[]),s=rr(()=>{o.layer&&o.close();let m=r.current;if(m===null)return;let c=[{icon:Em,title:"\u5DE6\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"left"})}},{icon:xm,title:"\u4E2D\u592E\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"center"})}},{icon:ym,title:"\u53F3\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"right"})}}];o.open(()=>ae(Ce,{dest:m,items:c,close:o.close}))},[]);return km(lm,{ref:r,contentEditable:!1,onClick:s,onMouseEnter:a,onMouseLeave:l,children:[ae(cm,{className:"--tile",children:ae(Qt,{})}),n?km(Kh,{children:[ae(_t,{style:{top:0,left:"50%",marginLeft:"-0.5em"},onMouseDown:()=>t.tablePlugin.removeColumn({at:e}),children:ae(qt,{})}),ae(Oe,{style:{left:"-0.5em",top:0},onMouseDown:()=>t.tablePlugin.insertColumn({at:e}),children:ae(Ue,{})}),ae(Oe,{style:{right:"-0.5em",top:0},onMouseDown:()=>t.tablePlugin.insertColumn({at:e,offset:1}),children:ae(Ue,{})})]}):null]})}import{useState as _h}from"react";import{useSlateStatic as Wh}from"slate-react";import{Fragment as Gh,jsx as fe,jsxs as vm}from"react/jsx-runtime";function wm({cellElement:e}){let t=Wh(),[o,r]=_h(!1);return vm(sm,{contentEditable:!1,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[fe(pm,{className:"--tile",children:fe(Qt,{})}),o?vm(Gh,{children:[fe(_t,{style:{top:"50%",left:"0.5em",marginTop:"-0.5em"},onMouseDown:()=>t.tablePlugin.removeRow({at:e}),children:fe(qt,{})}),fe(Oe,{style:{top:"-0.5em",left:"0.5em"},onMouseDown:()=>t.tablePlugin.insertRow({at:e}),children:fe(Ue,{})}),fe(Oe,{style:{bottom:"-0.5em",left:"0.5em"},onMouseDown:()=>t.tablePlugin.insertRow({at:e,offset:1}),children:fe(Ue,{})})]}):null]})}import Im from"@emotion/styled";var Mm=Im("div")`
1312
+ `;import{createContext as Zh}from"react";var Zt=Zh({isSelected:!1});import{jsx as pr}from"react/jsx-runtime";function Pm({element:e,attributes:t,children:o}){let r=rg(),n=og();return eg(()=>{let i=tg.findPath(r,e);Xt(r,[e,i])},[]),pr(Zt.Provider,{value:{isSelected:n},children:pr(vm,{...t,columns:e.columns,children:pr("tbody",{children:o})})})}import{useContext as pg}from"react";import{useSelected as dg}from"slate-react";import{useCallback as dr,useRef as ng,useState as ig}from"react";import{useSlateStatic as ag}from"slate-react";import{jsx as j}from"react/jsx-runtime";var Ge=e=>j("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"1em",height:"1em",...e,children:j("path",{fillRule:"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm.75-11.25a.75.75 0 0 0-1.5 0v2.5h-2.5a.75.75 0 0 0 0 1.5h2.5v2.5a.75.75 0 0 0 1.5 0v-2.5h2.5a.75.75 0 0 0 0-1.5h-2.5v-2.5z",clipRule:"evenodd"})}),eo=e=>j("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"1em",height:"1em",...e,children:j("path",{fillRule:"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM6.75 9.25a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5z",clipRule:"evenodd"})}),to=()=>j(y,{children:j("path",{d:"M4 6h16M4 12h16M4 18h16"})}),Cm=()=>j(y,{children:j("path",{d:"M4 6h16M4 12h10M4 18h14"})}),Sm=()=>j(y,{children:j("path",{d:"M4 6h16M8 12h8M6 18h12"})}),Rm=()=>j(y,{children:j("path",{d:"M4 6h16M10 12h10M6 18h14"})});import{Fragment as lg,jsx as me,jsxs as Lm}from"react/jsx-runtime";function Bm({cellElement:e}){let t=ag(),o=$("column-menu"),r=ng(null),[n,i]=ig(!1),a=dr(()=>{i(!0)},[]),l=dr(()=>{i(!1)},[]),s=dr(()=>{o.layer&&o.close();let c=r.current;if(c===null)return;let m=[{icon:Cm,title:"\u5DE6\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"left"})}},{icon:Sm,title:"\u4E2D\u592E\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"center"})}},{icon:Rm,title:"\u53F3\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"right"})}}];o.open(()=>me(St,{dest:c,items:m,close:o.close}))},[]);return Lm(bm,{ref:r,contentEditable:!1,onClick:s,onMouseEnter:a,onMouseLeave:l,children:[me(ym,{className:"--tile",children:me(to,{})}),n?Lm(lg,{children:[me(Jt,{style:{top:0,left:"50%",marginLeft:"-0.5em"},onMouseDown:()=>t.tablePlugin.removeColumn({at:e}),children:me(eo,{})}),me(_e,{style:{left:"-0.5em",top:0},onMouseDown:()=>t.tablePlugin.insertColumn({at:e}),children:me(Ge,{})}),me(_e,{style:{right:"-0.5em",top:0},onMouseDown:()=>t.tablePlugin.insertColumn({at:e,offset:1}),children:me(Ge,{})})]}):null]})}import{useState as sg}from"react";import{useSlateStatic as mg}from"slate-react";import{Fragment as cg,jsx as Ee,jsxs as zm}from"react/jsx-runtime";function Nm({cellElement:e}){let t=mg(),[o,r]=sg(!1);return zm(Em,{contentEditable:!1,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[Ee(km,{className:"--tile",children:Ee(to,{})}),o?zm(cg,{children:[Ee(Jt,{style:{top:"50%",left:"0.5em",marginTop:"-0.5em"},onMouseDown:()=>t.tablePlugin.removeRow({at:e}),children:Ee(eo,{})}),Ee(_e,{style:{top:"-0.5em",left:"0.5em"},onMouseDown:()=>t.tablePlugin.insertRow({at:e}),children:Ee(Ge,{})}),Ee(_e,{style:{bottom:"-0.5em",left:"0.5em"},onMouseDown:()=>t.tablePlugin.insertRow({at:e,offset:1}),children:Ee(Ge,{})})]}):null]})}import Dm from"@emotion/styled";var $m=Dm("div")`
1283
1313
  position: absolute;
1284
1314
  /**
1285
1315
  * very slightly shaded
@@ -1311,7 +1341,7 @@
1311
1341
  background: rgba(0, 0, 0, 0.15);
1312
1342
  }
1313
1343
  }
1314
- `,Pm=Im("div")`
1344
+ `,Hm=Dm("div")`
1315
1345
  position: absolute;
1316
1346
  left: 0;
1317
1347
  top: 0;
@@ -1319,7 +1349,8 @@
1319
1349
  height: 1.5em;
1320
1350
  background: rgba(0, 0, 0, 0.05);
1321
1351
  border-radius: 50%;
1322
- `;import{jsx as Cm}from"react/jsx-runtime";function Sm(){return Cm(Mm,{contentEditable:!1,children:Cm(Pm,{className:"--table-menu-tile"})})}import{jsx as nr,jsxs as jh}from"react/jsx-runtime";function Rm({element:e,attributes:t,children:o}){let r=qh(Gt),n=Qh(),i=r.isSelected&&e.x===0&&e.y===0,a=r.isSelected&&e.x===0,l=r.isSelected&&e.y===0;return jh(hm,{className:n?"--selected":"",...t,"data-x":e.x,"data-y":e.y,children:[o,i?nr(Sm,{}):null,a?nr(wm,{cellElement:e}):null,l?nr(Tm,{cellElement:e}):null]})}import{jsx as Jh}from"react/jsx-runtime";function Lm({attributes:e,children:t}){return Jh(gm,{...e,children:t})}import{jsx as Xh}from"react/jsx-runtime";function zm({attributes:e,children:t}){return Xh(fm,{...e,children:t})}import{jsx as jt}from"react/jsx-runtime";function Bm({element:e,attributes:t,children:o}){switch(e.type){case"table":return jt(bm,{element:e,attributes:t,children:o});case"table-row":return jt(zm,{element:e,attributes:t,children:o});case"table-cell":return jt(Rm,{element:e,attributes:t,children:o});case"table-content":return jt(Lm,{element:e,attributes:t,children:o})}}var Nm=x((e,t,{createPolicy:o})=>(e.supportsTable=!0,e.tablePlugin=nm(e),o({name:"table",editor:{deleteBackward:()=>be(e,"table-cell"),deleteForward:()=>Un(e,"table-cell"),deleteFragment:()=>Os(e,["table-cell"]),insertBreak:()=>!!g(e,"table-cell"),isMaster(r){if(r.type==="table")return!0},normalizeNode:r=>{let[n]=r;if(!Yh.isElement(n))return!1;switch(n.type){case"table":return Kt(e,r);case"table-cell":return im(e,r)}return!1}},editableProps:{renderElement:Bm,onKeyDown:P({tab:e.tablePlugin.tabForward,"shift+tab":e.tablePlugin.tabBackward,down:e.tablePlugin.down,up:e.tablePlugin.up,"mod+a":e.tablePlugin.selectCell,"super+t":()=>e.tablePlugin.insertTable(3,2),"mod+shift+enter":()=>e.tablePlugin.insertRow({offset:0}),"mod+enter":()=>e.tablePlugin.insertRow({offset:1}),"super+[":()=>e.tablePlugin.insertColumn({offset:0}),"super+]":()=>e.tablePlugin.insertColumn({offset:1}),"super+backspace":e.tablePlugin.removeTable,"mod+backspace":e.tablePlugin.removeRow,"mod+shift+backspace":e.tablePlugin.removeColumn})}})));import{Global as og}from"@emotion/react";import{css as Zh}from"@emotion/react";var eg=`
1352
+ `;import{jsx as Am}from"react/jsx-runtime";function Om(){return Am($m,{contentEditable:!1,children:Am(Hm,{className:"--table-menu-tile"})})}import{jsx as ur,jsxs as ug}from"react/jsx-runtime";function Um({element:e,attributes:t,children:o}){let r=pg(Zt),n=dg(),i=r.isSelected&&e.x===0&&e.y===0,a=r.isSelected&&e.x===0,l=r.isSelected&&e.y===0;return ug(Im,{className:n?"--selected":"",...t,"data-x":e.x,"data-y":e.y,children:[o,i?ur(Om,{}):null,a?ur(Nm,{cellElement:e}):null,l?ur(Bm,{cellElement:e}):null]})}import{jsx as fg}from"react/jsx-runtime";function Fm({attributes:e,children:t}){return fg(Mm,{...e,children:t})}import{jsx as hg}from"react/jsx-runtime";function Vm({attributes:e,children:t}){return hg(wm,{...e,children:t})}import{jsx as oo}from"react/jsx-runtime";function Km({element:e,attributes:t,children:o}){switch(e.type){case"table":return oo(Pm,{element:e,attributes:t,children:o});case"table-row":return oo(Vm,{element:e,attributes:t,children:o});case"table-cell":return oo(Um,{element:e,attributes:t,children:o});case"table-content":return oo(Fm,{element:e,attributes:t,children:o})}}var Wm=x((e,t,{createPolicy:o})=>(e.supportsTable=!0,e.tablePlugin=fm(e),o({name:"table",editor:{deleteBackward:()=>ke(e,"table-cell"),deleteForward:()=>Xn(e,"table-cell"),deleteFragment:()=>Qs(e,["table-cell"]),insertBreak:()=>b(e,"table-cell")?(e.insertText(`
1353
+ `),!0):!1,isMaster(r){if(r.type==="table")return!0},normalizeNode:r=>{let[n]=r;if(!gg.isElement(n))return!1;switch(n.type){case"table":return Xt(e,r);case"table-cell":return hm(e,r)}return!1}},editableProps:{renderElement:Km,onKeyDown:B({tab:e.tablePlugin.tabForward,"shift+tab":e.tablePlugin.tabBackward,"shift+enter":e.tablePlugin.shiftEnterForward,down:e.tablePlugin.down,up:e.tablePlugin.up,"mod+a":e.tablePlugin.selectCell,"super+t":()=>e.tablePlugin.insertTable(3,2),"mod+shift+enter":()=>e.tablePlugin.insertRow({offset:0}),"mod+enter":()=>e.tablePlugin.insertRow({offset:1}),"super+[":()=>e.tablePlugin.insertColumn({offset:0}),"super+]":()=>e.tablePlugin.insertColumn({offset:1}),"super+backspace":e.tablePlugin.removeTable,"mod+backspace":e.tablePlugin.removeRow,"mod+shift+backspace":e.tablePlugin.removeColumn})}})));import{Global as yg}from"@emotion/react";import{css as bg}from"@emotion/react";var Eg=`
1323
1354
  --blue-50: rgb(239 246 255);
1324
1355
  --blue-100: rgb(219 234 254);
1325
1356
  --blue-200: rgb(191 219 254);
@@ -1330,7 +1361,7 @@
1330
1361
  --blue-700: rgb(29 78 216);
1331
1362
  --blue-800: rgb(30 64 175);
1332
1363
  --blue-900: rgb(30 58 138);
1333
- `;var tg=`
1364
+ `;var xg=`
1334
1365
  --shade-50: rgb(250 250 250);
1335
1366
  --shade-100: rgb(244 244 245);
1336
1367
  --shade-200: rgb(228 228 231);
@@ -1341,11 +1372,11 @@
1341
1372
  --shade-700: rgb(63 63 70);
1342
1373
  --shade-800: rgb(39 39 42);
1343
1374
  --shade-900: rgb(24 24 27);
1344
- `,Dm=Zh`
1375
+ `,_m=bg`
1345
1376
  :root {
1346
1377
  /* Tailwind Colors */
1347
- ${eg}
1348
- ${tg}
1378
+ ${Eg}
1379
+ ${xg}
1349
1380
  /* Select Colors */
1350
1381
  --select-color: var(--blue-400);
1351
1382
  --select-editor-color: var(--blue-200);
@@ -1367,14 +1398,14 @@
1367
1398
  /* Horizontal Rule Colors */
1368
1399
  --hr-color: var(--shade-300);
1369
1400
  }
1370
- `;import{Fragment as rg,jsx as $m,jsxs as ng}from"react/jsx-runtime";var Am=x(e=>(e.theme=!0,{name:"theme",editor:{},renderEditable:({attributes:t,Editable:o})=>ng(rg,{children:[$m(og,{styles:Dm}),$m(o,{...t})]}),editableProps:{}}));import{clsx as Vg}from"clsx";import{useCallback as Kg,useRef as _g}from"react";import{Editor as Wg,Transforms as Gg}from"slate";import{ReactEditor as qg,useFocused as Qg,useSlateStatic as jg}from"slate-react";import{clsx as ig}from"clsx";import{useCallback as Fm,useRef as ag,useState as lg}from"react";import{ReactEditor as sg,useSlateStatic as mg}from"slate-react";import ir from"@emotion/styled";var Hm=ir(F)`
1401
+ `;import{Fragment as kg,jsx as Gm,jsxs as Tg}from"react/jsx-runtime";var qm=x(e=>(e.theme=!0,{name:"theme",editor:{},renderEditable:({attributes:t,Editable:o})=>Tg(kg,{children:[Gm(yg,{styles:_m}),Gm(o,{...t})]}),editableProps:{}}));import{clsx as lb}from"clsx";import{useCallback as sb,useRef as mb}from"react";import{Editor as cb,Transforms as pb}from"slate";import{ReactEditor as db,useFocused as ub,useSlateStatic as fb}from"slate-react";import{clsx as vg}from"clsx";import{useCallback as Jm,useRef as wg,useState as Ig}from"react";import{ReactEditor as Mg,useSlateStatic as Pg}from"slate-react";import fr from"@emotion/styled";var Qm=fr(Q)`
1371
1402
  padding: 0.5em;
1372
- `,Om=ir("div")`
1403
+ `,jm=fr("div")`
1373
1404
  display: grid;
1374
1405
  grid-template-columns: repeat(5, 1.75em);
1375
1406
  grid-template-rows: 1.5em;
1376
1407
  /* grid-gap: 1px; */
1377
- `,Um=ir("div")`
1408
+ `,Xm=fr("div")`
1378
1409
  background: var(--shade-100);
1379
1410
  height: 1.5em;
1380
1411
  border-radius: 0.125em;
@@ -1384,10 +1415,10 @@
1384
1415
  &.--selected {
1385
1416
  background: var(--blue-100);
1386
1417
  }
1387
- `;import{Fragment as cg,jsx as Jt,jsxs as pg}from"react/jsx-runtime";function Vm(e){return[...Array(e).keys()]}function Km({dest:e,close:t}){let[o,r]=lg({x:0,y:0}),n=mg(),i=ag(null),a=U({src:i,dest:e},({dest:p})=>({left:p.left-8,top:p.top+p.height})),l=Vm(5).map(p=>p+1),s=Vm(5).map(p=>p+1),m=Fm((p,h)=>{r({x:p,y:h})},[r]),c=Fm((p,h)=>{n.tablePlugin.insertTable(p,h),sg.focus(n),t()},[n]);return pg(cg,{children:[Jt(de,{close:t}),Jt(Hm,{ref:i,style:a,children:Jt(Om,{onMouseLeave:()=>m(0,0),children:l.map(p=>s.map(h=>{let y=h<=o.x&&p<=o.y;return Jt(Um,{className:ig({"--selected":y}),onMouseEnter:()=>m(h,p),onClick:()=>c(h,p)},`${h},${p}`)}))})})]})}import Bg from"lodash.throttle";import{useEffect as Ng,useRef as Dg,useState as $g}from"react";import{useSlateStatic as Ag}from"slate-react";import{jsx as u,jsxs as ke}from"react/jsx-runtime";var _m=()=>u(b,{children:u("path",{d:"M7 12h10M7 5v14M17 5v14M15 19h4M15 5h4M5 19h4M5 5h4"})}),Wm=()=>u(b,{className:"--more-icon",width:"0.5em",viewBox:"0 0 12 24",children:u("path",{d:"m2 12 4 4 4-4"})}),Gm=()=>u(b,{width:"0.5em",viewBox:"6 0 12 24",children:u("path",{d:"M9 12h6M12 9v6"})}),qm=()=>u(b,{children:u("path",{d:"M19 18v-8l-2 2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})}),Qm=()=>u(b,{children:u("path",{d:"M17 12a2 2 0 1 1 4 0c0 .591-.417 1.318-.816 1.858L17 18.001h4M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})}),jm=()=>u(b,{children:u("path",{d:"M19 14a2 2 0 1 0-2-2M17 16a2 2 0 1 0 2-2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})});var Jm=()=>u(b,{children:u("path",{d:"M8 18V6h2l6 9V6h2v12h-2l-6-9v9H8z"})}),ar=()=>u(b,{children:u("path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7H7zM13 12h1a3.5 3.5 0 0 1 0 7H7v-7"})}),Xm=()=>u(b,{children:u("path",{d:"M11 5h6M7 19h6M14 5l-4 14"})});var Xt=()=>ke(b,{children:[u("path",{d:"M10 14a3.5 3.5 0 0 0 5 0l4-4a3.5 3.5 0 0 0-5-5l-.5.5"}),u("path",{d:"M14 10a3.5 3.5 0 0 0-5 0l-4 4a3.5 3.5 0 0 0 5 5l.5-.5"})]});var lr=()=>u(b,{children:u("path",{d:"M10 11H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5M19 11h-4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5"})}),Ym=()=>ke(b,{children:[u("path",{d:"M10 9l4 3-4 3"}),u("path",{d:"M16 9l4 3-4 3"})]});var Zm=()=>u(b,{children:u("path",{d:"M9 6h11M9 12h11M9 18h11M5 6v.01M5 12v.01M5 18v.01"})}),ec=()=>ke(b,{children:[u("rect",{x:4,y:4,width:16,height:16,rx:2}),u("path",{d:"M4 10h16M10 4v16"})]}),tc=()=>u(b,{children:u("path",{d:"m7 8-4 4 4 4M17 8l4 4-4 4M14 4l-4 16"})}),oc=()=>u(b,{children:u("path",{d:"M9 8L5 12L9 16M15 8L19 12L15 16"})}),rc=()=>ke(b,{children:[u("path",{d:"M15 8h.01"}),u("rect",{x:4,y:4,width:16,height:16,rx:3}),u("path",{d:"m4 15 4-4a3 5 0 0 1 3 0l5 5"}),u("path",{d:"m14 14 1-1a3 5 0 0 1 3 0l2 2"})]});var nc=()=>u(b,{children:u("path",{d:"M12 5v14M5 12h14"})}),ic=()=>u(b,{children:u("path",{d:"M5 12h14M16 6.5A4 2 0 0 0 12 5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1-4-1.5"})}),ac=()=>u(b,{children:u("path",{d:"M7 5v5a5 5 0 0 0 10 0V5M5 19h14"})});var lc=()=>ke(b,{children:[u("path",{d:"m9 11 3 3 8-8"}),u("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),sr=()=>u(b,{children:u("path",{d:"M11 6h9M11 12h9M12 18h8M4 16a2 2 0 1 1 4 0c0 .591-.5 1-1 1.5L4 20h4M6 10V4L4 6"})}),sc=()=>u(b,{children:u("path",{d:"M4 6h16M8 12h12M12 18h8M7 12l-3-3M7 12l-3 3"})}),mc=()=>u(b,{children:u("path",{d:"M4 6h16M8 12h12M12 18h8M4 12l3-3M4 12l3 3"})}),cc=()=>ke(b,{children:[u("path",{d:"M5 5h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2z"}),u("path",{d:"M7 15V9l2 2 2-2v6M14 9v6h4M14 13h2"})]}),Yt=()=>ke(b,{children:[u("path",{d:"M5 5h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2z"}),u("path",{d:"M8 8h8M8 12h8M8 16h5"}),u("path",{d:"M16 16h1"})]});var mr=[{icon:sc,title:f("increaseDepth"),hotkey:"tab",action:e=>e.list.increaseDepth(),active:e=>e.list.canIncreaseDepth()},{icon:mc,title:f("decreaseDepth"),hotkey:"shift+tab",action:e=>e.list.decreaseDepth(),active:e=>e.list.canDecreaseDepth()}],pc=[{icon:Jm,title:f("normal"),hotkey:"super+0",action:e=>{e.collapsibleParagraph.convertParagraph()}},{icon:qm,title:f("heading1"),hotkey:"super+1",action:e=>e.heading.convertHeading(1,!0),active:e=>e.heading.isHeadingActive(1)},{icon:Qm,title:f("heading2"),hotkey:"super+2",action:e=>e.heading.convertHeading(2,!0),active:e=>e.heading.isHeadingActive(2)},{icon:jm,title:f("heading3"),hotkey:"super+3",action:e=>e.heading.convertHeading(3,!0),active:e=>e.heading.isHeadingActive(3)}],dc=[...pc],cr=[{icon:_m,title:f("paragraphStyle"),more:!0,children:pc}];import{useState as Fe,useRef as fc,useEffect as ug}from"react";import{useSlateStatic as fg}from"slate-react";import dg from"@emotion/styled";var uc=dg(F)`
1418
+ `;import{Fragment as Cg,jsx as ro,jsxs as Sg}from"react/jsx-runtime";function Ym(e){return[...Array(e).keys()]}function Zm({dest:e,close:t}){let[o,r]=Ig({x:0,y:0}),n=Pg(),i=wg(null),a=q({src:i,dest:e},({dest:d})=>({left:d.left-8,top:d.top+d.height})),l=Ym(5).map(d=>d+1),s=Ym(5).map(d=>d+1),c=Jm((d,p)=>{r({x:d,y:p})},[r]),m=Jm((d,p)=>{n.tablePlugin.insertTable(d,p),Mg.focus(n),t()},[n]);return Sg(Cg,{children:[ro(ge,{close:t}),ro(Qm,{ref:i,style:a,children:ro(jm,{onMouseLeave:()=>c(0,0),children:l.map(d=>s.map(p=>{let g=p<=o.x&&d<=o.y;return ro(Xm,{className:vg({"--selected":g}),onMouseEnter:()=>c(p,d),onClick:()=>m(p,d)},`${p},${d}`)}))})})]})}import Yg from"lodash.throttle";import{useEffect as Zg,useRef as eb,useState as tb}from"react";import{useSlateStatic as ob}from"slate-react";import{jsx as h,jsxs as xe}from"react/jsx-runtime";var ec=()=>h(y,{children:h("path",{d:"M7 12h10M7 5v14M17 5v14M15 19h4M15 5h4M5 19h4M5 5h4"})}),tc=()=>h(y,{className:"--more-icon",width:"0.5em",viewBox:"0 0 12 24",children:h("path",{d:"m2 12 4 4 4-4"})}),oc=()=>h(y,{width:"0.5em",viewBox:"6 0 12 24",children:h("path",{d:"M9 12h6M12 9v6"})}),rc=()=>h(y,{children:h("path",{d:"M19 18v-8l-2 2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})}),nc=()=>h(y,{children:h("path",{d:"M17 12a2 2 0 1 1 4 0c0 .591-.417 1.318-.816 1.858L17 18.001h4M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})}),ic=()=>h(y,{children:h("path",{d:"M19 14a2 2 0 1 0-2-2M17 16a2 2 0 1 0 2-2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})});var ac=()=>h(y,{children:h("path",{d:"M8 18V6h2l6 9V6h2v12h-2l-6-9v9H8z"})}),hr=()=>h(y,{children:h("path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7H7zM13 12h1a3.5 3.5 0 0 1 0 7H7v-7"})}),lc=()=>h(y,{children:h("path",{d:"M11 5h6M7 19h6M14 5l-4 14"})});var no=()=>xe(y,{children:[h("path",{d:"M10 14a3.5 3.5 0 0 0 5 0l4-4a3.5 3.5 0 0 0-5-5l-.5.5"}),h("path",{d:"M14 10a3.5 3.5 0 0 0-5 0l-4 4a3.5 3.5 0 0 0 5 5l.5-.5"})]});var gr=()=>h(y,{children:h("path",{d:"M10 11H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5M19 11h-4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5"})}),sc=()=>xe(y,{children:[h("path",{d:"M10 9l4 3-4 3"}),h("path",{d:"M16 9l4 3-4 3"})]});var mc=()=>h(y,{children:h("path",{d:"M9 6h11M9 12h11M9 18h11M5 6v.01M5 12v.01M5 18v.01"})}),cc=()=>xe(y,{children:[h("rect",{x:4,y:4,width:16,height:16,rx:2}),h("path",{d:"M4 10h16M10 4v16"})]}),pc=()=>h(y,{children:h("path",{d:"m7 8-4 4 4 4M17 8l4 4-4 4M14 4l-4 16"})}),dc=()=>h(y,{children:h("path",{d:"M9 8L5 12L9 16M15 8L19 12L15 16"})}),uc=()=>xe(y,{children:[h("path",{d:"M15 8h.01"}),h("rect",{x:4,y:4,width:16,height:16,rx:3}),h("path",{d:"m4 15 4-4a3 5 0 0 1 3 0l5 5"}),h("path",{d:"m14 14 1-1a3 5 0 0 1 3 0l2 2"})]});var fc=()=>h(y,{children:h("path",{d:"M12 5v14M5 12h14"})}),hc=()=>h(y,{children:h("path",{d:"M5 12h14M16 6.5A4 2 0 0 0 12 5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1-4-1.5"})}),gc=()=>h(y,{children:h("path",{d:"M7 5v5a5 5 0 0 0 10 0V5M5 19h14"})});var bc=()=>xe(y,{children:[h("path",{d:"m9 11 3 3 8-8"}),h("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),br=()=>h(y,{children:h("path",{d:"M11 6h9M11 12h9M12 18h8M4 16a2 2 0 1 1 4 0c0 .591-.5 1-1 1.5L4 20h4M6 10V4L4 6"})}),Ec=()=>h(y,{children:h("path",{d:"M4 6h16M8 12h12M12 18h8M7 12l-3-3M7 12l-3 3"})}),xc=()=>h(y,{children:h("path",{d:"M4 6h16M8 12h12M12 18h8M4 12l3-3M4 12l3 3"})}),yc=()=>xe(y,{children:[h("path",{d:"M5 5h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2z"}),h("path",{d:"M7 15V9l2 2 2-2v6M14 9v6h4M14 13h2"})]}),io=()=>xe(y,{children:[h("path",{d:"M5 5h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2z"}),h("path",{d:"M8 8h8M8 12h8M8 16h5"}),h("path",{d:"M16 16h1"})]}),kc=()=>xe(y,{children:[h("path",{d:"M3 19h4L17.5 8.5a2.828 2.828 0 1 0-4-4L3 15v4"}),h("path",{d:"m12.5 5.5 4 4"}),h("path",{d:"M3 21h7"}),h("path",{d:"M18 19h3M19.5 17.5v3"})]});var Er=[{icon:Ec,title:f("increaseDepth"),hotkey:"tab",action:e=>e.list?.increaseDepth(),active:e=>e.list?.canIncreaseDepth()??!1,show:e=>!!e.list},{icon:xc,title:f("decreaseDepth"),hotkey:"shift+tab",action:e=>e.list?.decreaseDepth(),active:e=>e.list?.canDecreaseDepth()??!1,show:e=>!!e.list}],Tc=[{icon:ac,title:f("normal"),hotkey:"super+0",action:e=>{e.collapsibleParagraph.convertParagraph()}},{icon:rc,title:f("heading1"),hotkey:"super+1",action:e=>e.heading.convertHeading(1,!0),active:e=>e.heading.isHeadingActive(1)},{icon:nc,title:f("heading2"),hotkey:"super+2",action:e=>e.heading.convertHeading(2,!0),active:e=>e.heading.isHeadingActive(2)},{icon:ic,title:f("heading3"),hotkey:"super+3",action:e=>e.heading.convertHeading(3,!0),active:e=>e.heading.isHeadingActive(3)}],vc=[...Tc],xr=[{icon:ec,title:f("paragraphStyle"),more:!0,children:Tc}];import{useState as qe,useRef as Ic,useEffect as Lg}from"react";import{useSlateStatic as Bg}from"slate-react";import Rg from"@emotion/styled";var wc=Rg(Q)`
1388
1419
  padding: 1em;
1389
1420
  width: 18em;
1390
- `;import{Fragment as hg,jsx as L,jsxs as G}from"react/jsx-runtime";function hc({dest:e,close:t}){let o=fg(),r=fc(void 0),n=fc(null),i=o.wysimark?.imageDialogState,a=!!o.wysimark?.onImageChange,[l,s]=Fe(i?.url??""),[m,c]=Fe(i?.alt??""),[p,h]=Fe(i?.title??""),[y,E]=Fe(i?.imageSource??(a?"file":"url")),[k,C]=Fe(!1),[T,z]=Fe(i?.uploadedUrl??"");ug(()=>{o.wysimark&&(o.wysimark.imageDialogState={url:l,alt:m,title:p,imageSource:y,uploadedUrl:T})},[l,m,p,y,T]);let q=()=>{o.wysimark&&(o.wysimark.imageDialogState=void 0)},Q=U({src:r,dest:e},({src:N,dest:O})=>vt(N,O,{left:O.left-16,top:O.top+O.height},{margin:16}));function j(N){N.preventDefault();let O=y==="file"?T:l;O.trim()!==""&&(o.image.insertImageFromUrl(O,m,p),q(),t())}function K(){q(),t()}async function _e(N){let O=N.target.files?.[0];if(!(!O||!o.wysimark?.onImageChange)){C(!0);try{let io=await o.wysimark.onImageChange(O);z(io)}catch(io){console.error("Failed to upload image:",io)}finally{C(!1)}}}function I(){n.current?.click()}let H=y==="file"?T.trim()===""||k:l.trim()==="";return G(hg,{children:[L(de,{close:t}),L(uc,{ref:r,style:Q,children:G("form",{onSubmit:j,style:{padding:"8px"},children:[a&&G("div",{style:{marginBottom:"12px"},children:[G("label",{style:{display:"inline-flex",alignItems:"center",marginRight:"16px",cursor:"pointer"},children:[L("input",{type:"radio",name:"imageSource",value:"file",checked:y==="file",onChange:()=>E("file"),style:{marginRight:"4px"}}),f("imageSourceFile")]}),G("label",{style:{display:"inline-flex",alignItems:"center",cursor:"pointer"},children:[L("input",{type:"radio",name:"imageSource",value:"url",checked:y==="url",onChange:()=>E("url"),style:{marginRight:"4px"}}),f("imageSourceUrl")]})]}),y==="url"?G("div",{style:{marginBottom:"8px"},children:[L("label",{style:{display:"block",marginBottom:"4px"},children:f("imageUrlRequired")}),L("input",{type:"text",value:l,onChange:N=>s(N.target.value),style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid #ccc",borderRadius:"4px"},placeholder:"https://example.com/image.jpg"})]}):G("div",{style:{marginBottom:"8px"},children:[L("input",{ref:n,type:"file",accept:"image/*",onChange:_e,style:{display:"none"}}),L("button",{type:"button",onClick:I,disabled:k,style:{padding:"8px 16px",backgroundColor:k?"#ccc":"#f0f0f0",border:"1px solid #ccc",borderRadius:"4px",cursor:k?"not-allowed":"pointer",marginBottom:"8px"},children:k?f("uploading"):f("selectFile")}),T&&G("div",{style:{marginTop:"8px"},children:[L("label",{style:{display:"block",marginBottom:"4px"},children:f("imageUrlRequired")}),L("input",{type:"text",value:T,disabled:!0,style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid #ccc",borderRadius:"4px",backgroundColor:"#f5f5f5",color:"#666"}})]})]}),G("div",{style:{marginBottom:"8px"},children:[L("label",{style:{display:"block",marginBottom:"4px"},children:f("altText")}),L("input",{type:"text",value:m,onChange:N=>c(N.target.value),style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid #ccc",borderRadius:"4px"},placeholder:f("imageDescription")})]}),G("div",{style:{marginBottom:"8px"},children:[L("label",{style:{display:"block",marginBottom:"4px"},children:f("title")}),L("input",{type:"text",value:p,onChange:N=>h(N.target.value),style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid #ccc",borderRadius:"4px"},placeholder:f("imageTitle")})]}),G("div",{style:{display:"flex",gap:"8px"},children:[L("button",{type:"submit",disabled:H,style:{display:"flex",alignItems:"center",padding:"8px 16px",backgroundColor:H?"#ccc":"#0078d4",color:"white",border:"none",borderRadius:"4px",cursor:H?"not-allowed":"pointer",fontWeight:"bold"},children:f("register")}),L("button",{type:"button",onClick:K,style:{padding:"8px 16px",backgroundColor:"#f0f0f0",color:"#333",border:"1px solid #ccc",borderRadius:"4px",cursor:"pointer"},children:f("cancel")})]})]})})]})}import{isHotkey as gg}from"is-hotkey";import{useCallback as bg,useRef as Eg,useState as xg}from"react";import{ReactEditor as yg,useSlateStatic as kg}from"slate-react";import gc from"@emotion/styled";var bc=gc("div")`
1421
+ `;import{Fragment as zg,jsx as N,jsxs as Z}from"react/jsx-runtime";function Mc({dest:e,close:t}){let o=Bg(),r=Ic(void 0),n=Ic(null),i=o.wysimark?.imageDialogState,a=!!o.wysimark?.onImageChange,[l,s]=qe(i?.url??""),[c,m]=qe(i?.alt??""),[d,p]=qe(i?.title??""),[g,E]=qe(i?.imageSource??(a?"file":"url")),[T,M]=qe(!1),[I,v]=qe(i?.uploadedUrl??"");Lg(()=>{o.wysimark&&(o.wysimark.imageDialogState={url:l,alt:c,title:d,imageSource:g,uploadedUrl:I})},[l,c,d,g,I]);let k=()=>{o.wysimark&&(o.wysimark.imageDialogState=void 0)},w=q({src:r,dest:e},({src:U,dest:G})=>It(U,G,{left:G.left-16,top:G.top+G.height},{margin:16}));function D(U){U.preventDefault();let G=g==="file"?I:l;G.trim()!==""&&(o.image.insertImageFromUrl(G,c,d),k(),t())}function H(){k(),t()}async function ne(U){let G=U.target.files?.[0];if(!(!G||!o.wysimark?.onImageChange)){M(!0);try{let fo=await o.wysimark.onImageChange(G);v(fo)}catch(fo){console.error("Failed to upload image:",fo)}finally{M(!1)}}}function P(){n.current?.click()}let L=g==="file"?I.trim()===""||T:l.trim()==="";return Z(zg,{children:[N(ge,{close:t}),N(wc,{ref:r,style:w,children:Z("form",{onSubmit:D,style:{padding:"8px"},children:[a&&Z("div",{style:{marginBottom:"12px"},children:[Z("label",{style:{display:"inline-flex",alignItems:"center",marginRight:"16px",cursor:"pointer"},children:[N("input",{type:"radio",name:"imageSource",value:"file",checked:g==="file",onChange:()=>E("file"),style:{marginRight:"4px"}}),f("imageSourceFile")]}),Z("label",{style:{display:"inline-flex",alignItems:"center",cursor:"pointer"},children:[N("input",{type:"radio",name:"imageSource",value:"url",checked:g==="url",onChange:()=>E("url"),style:{marginRight:"4px"}}),f("imageSourceUrl")]})]}),g==="url"?Z("div",{style:{marginBottom:"8px"},children:[N("label",{style:{display:"block",marginBottom:"4px"},children:f("imageUrlRequired")}),N("input",{type:"text",value:l,onChange:U=>s(U.target.value),style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid #ccc",borderRadius:"4px"},placeholder:"https://example.com/image.jpg"})]}):Z("div",{style:{marginBottom:"8px"},children:[N("input",{ref:n,type:"file",accept:"image/*",onChange:ne,style:{display:"none"}}),N("button",{type:"button",onClick:P,disabled:T,style:{padding:"8px 16px",backgroundColor:T?"#ccc":"#f0f0f0",border:"1px solid #ccc",borderRadius:"4px",cursor:T?"not-allowed":"pointer",marginBottom:"8px"},children:T?f("uploading"):f("selectFile")}),I&&Z("div",{style:{marginTop:"8px"},children:[N("label",{style:{display:"block",marginBottom:"4px"},children:f("imageUrlRequired")}),N("input",{type:"text",value:I,disabled:!0,style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid #ccc",borderRadius:"4px",backgroundColor:"#f5f5f5",color:"#666"}})]})]}),Z("div",{style:{marginBottom:"8px"},children:[N("label",{style:{display:"block",marginBottom:"4px"},children:f("altText")}),N("input",{type:"text",value:c,onChange:U=>m(U.target.value),style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid #ccc",borderRadius:"4px"},placeholder:f("imageDescription")})]}),Z("div",{style:{marginBottom:"8px"},children:[N("label",{style:{display:"block",marginBottom:"4px"},children:f("title")}),N("input",{type:"text",value:d,onChange:U=>p(U.target.value),style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid #ccc",borderRadius:"4px"},placeholder:f("imageTitle")})]}),Z("div",{style:{display:"flex",gap:"8px"},children:[N("button",{type:"submit",disabled:L,style:{display:"flex",alignItems:"center",padding:"8px 16px",backgroundColor:L?"#ccc":"#0078d4",color:"white",border:"none",borderRadius:"4px",cursor:L?"not-allowed":"pointer",fontWeight:"bold"},children:f("register")}),N("button",{type:"button",onClick:H,style:{padding:"8px 16px",backgroundColor:"#f0f0f0",color:"#333",border:"1px solid #ccc",borderRadius:"4px",cursor:"pointer"},children:f("cancel")})]})]})})]})}import{isHotkey as Ng}from"is-hotkey";import{useCallback as yr,useMemo as Dg,useRef as $g,useState as ao}from"react";import{Editor as Hg,Range as Ag}from"slate";import{ReactEditor as Og,useSlateStatic as Ug}from"slate-react";import Pc from"@emotion/styled";var Cc=Pc("div")`
1391
1422
  /* Center vertically and horizontally */
1392
1423
  display: flex;
1393
1424
  align-items: center;
@@ -1411,9 +1442,9 @@
1411
1442
  font-size: 1.25em;
1412
1443
  stroke-width: 2px;
1413
1444
  }
1414
- `,Ec=gc("div")`
1445
+ `,Sc=Pc("div")`
1415
1446
  font-size: 0.875em;
1416
1447
  margin-top: 0.5em;
1417
1448
  color: var(--shade-500);
1418
1449
  line-height: 1.375;
1419
- `;import{Fragment as vg,jsx as lt,jsxs as Zt}from"react/jsx-runtime";var Tg=gg("enter");function xc({dest:e,close:t}){let o=kg(),r=Eg(null),n=U({src:r,dest:e},({src:c,dest:p},h)=>vt(c,h,{left:p.left-12,top:p.top+p.height},{margin:16})),[i,a]=xg(""),l=()=>{o.anchor.insertLink(i,i,{select:!0}),yg.focus(o),t()},s=bg(c=>{a(c.currentTarget.value)},[a]);return Zt(vg,{children:[lt(de,{close:t}),Zt(hi,{ref:r,style:n,children:[Zt(gi,{children:[lt(bi,{type:"text",value:i,autoFocus:!0,onChange:s,onKeyDown:c=>{Tg(c)&&(c.preventDefault(),c.stopPropagation(),l())}}),Zt(bc,{onClick:l,children:[lt(Xt,{}),lt(Gm,{})]})]}),lt(Ec,{children:"Enter URL of link"})]})]})}var pr=[{icon:Xt,title:f("insertLink"),more:!0,hotkey:"mod+k",Component:xc},{icon:ec,title:f("insertTable"),more:!0,Component:Km},{icon:rc,title:f("insertImageFromUrl"),more:!0,Component:hc}],yc=pr,kc=pr,Tc=[{icon:nc,title:f("insert"),more:!0,children:pr}];import{Editor as wg}from"slate";function st(e){let t=wg.marks(e);return{bold:t?.bold||!1,italic:t?.italic||!1,strike:t?.strike||!1,code:t?.code||!1,underline:t?.underline||!1}}var vc=[{icon:ar,title:f("bold"),hotkey:"mod+b",action:e=>e.marksPlugin.toggleBold(),active:e=>st(e).bold},{icon:Xm,title:f("italic"),hotkey:"mod+i",action:e=>e.marksPlugin.toggleItalic(),active:e=>st(e).italic},{icon:ic,title:f("strike"),hotkey:"super+k",action:e=>e.marksPlugin.toggleStrike(),active:e=>st(e).strike},{icon:tc,title:f("inlineCode"),hotkey:"mod+j",action:e=>e.inlineCode.toggleInlineCode(),active:e=>st(e).code},{icon:ac,title:f("underline"),hotkey:"mod+u",action:e=>e.marksPlugin.toggleUnderline(),active:e=>st(e).underline}],dr=vc,wc=[{icon:ar,title:f("format"),more:!0,children:vc}];var Ic=[{icon:Zm,title:f("bulletList"),hotkey:"super+8",action:e=>e.list.convertUnorderedList(!0)},{icon:sr,title:f("numberedList"),hotkey:"super+7",action:e=>e.list.convertOrderedList(!0)},{icon:lc,title:f("checkList"),hotkey:"super+9",action:e=>e.list.convertTaskList(!0)}],ur=[...Ic,"divider",...mr],Mc=[{icon:sr,title:f("list"),more:!0,children:[...Ic,"divider",...mr]}];import{Editor as Pc,Transforms as eo}from"slate";var Cc=[{icon:lr,title:f("quote"),hotkey:"super+.",action:e=>{e.blockQuotePlugin.isActive()?e.blockQuotePlugin.outdent():e.blockQuotePlugin.indent()},active:e=>e.blockQuotePlugin.isActive()},{icon:Ym,title:f("increaseQuoteDepth"),action:e=>e.blockQuotePlugin.increaseDepth(),active:e=>e.blockQuotePlugin.canIncreaseDepth()},{icon:oc,title:f("codeBlock"),action:e=>{let{selection:t}=e,o=g(e,"code-block");if(o){let[r,n]=o,i=Pc.string(e,n);eo.removeNodes(e,{at:n}),eo.insertNodes(e,{type:"paragraph",children:[{text:i}]},{at:n});return}if(t&&JSON.stringify(t.anchor.path)!==JSON.stringify(t.focus.path)){e.codeBlock.createCodeBlock({language:"text"});return}if(t&&(t.anchor.offset!==t.focus.offset||JSON.stringify(t.anchor.path)!==JSON.stringify(t.focus.path))){let r=Pc.string(e,t);eo.delete(e),eo.insertNodes(e,{type:"code-block",language:"text",children:[{type:"code-block-line",children:[{text:r}]}]});return}e.codeBlock.createCodeBlock({language:"text"})},active:e=>!!g(e,"code-block")}],fr=Cc,Sc=[{icon:lr,title:f("quote"),more:!0,children:Cc}];var to={icon:cc,title:f("switchToRawMarkdown"),action:e=>{e.wysimark&&typeof e.wysimark.toggleRawMode=="function"&&e.wysimark.toggleRawMode()},show:e=>e.wysimark&&!e.wysimark.isRawMode,active:()=>!1},oo={icon:Yt,title:f("switchToVisualEditor"),action:e=>{e.wysimark&&typeof e.wysimark.toggleRawMode=="function"&&e.wysimark.toggleRawMode()},show:e=>!!(e.wysimark&&e.wysimark.isRawMode),active:()=>!1};var Ig=[...dc,"divider",...ur,"divider",...dr,"divider",...yc,"divider",...fr,"divider",to,oo],Mg=[...cr,"divider",...ur,"divider",...dr,"divider",...kc,"divider",...fr,"divider",to,oo],Rc=[...cr,"divider",...Mc,"divider",...wc,"divider",...Tc,"divider",...Sc,"divider",to,oo],Lc=Rc;var Ve=[Ig,Mg,Rc];import{clsx as Pg}from"clsx";import{useCallback as hr,useRef as Cg}from"react";import{ReactEditor as Sg,useSlate as Rg,useSlateStatic as Lg}from"slate-react";import{jsx as ro,jsxs as zg}from"react/jsx-runtime";function zc({item:e}){let t=Lg(),o=Rg(),r=e.active?e.active(o):!1,n=Cg(null),i=W({title:e.title,hotkey:()=>e.hotkey?kt(e.hotkey):void 0}),a=S("menu"),l=hr(()=>{let c=n.current,p=e.children,h=e.Component;c&&(p?a.open(()=>ro(Ce,{dest:c,items:p,close:a.close})):h&&a.open(()=>ro(h,{dest:c,close:a.close})))},[e]),s=hr(()=>{if(e.action){e.action(t),Sg.focus(t);return}a.layer?a.close():l()},[a.layer,e]),m=hr(c=>{i.onMouseEnter(c),a.layer&&l()},[a.layer]);return zg(Si,{"data-item-type":"button",ref:n,onMouseEnter:m,onMouseLeave:i.onMouseLeave,onClick:s,className:Pg({"--active":r&&!Eo(e?.title)?.includes("Depth"),"--more":e.more,"--disabled":!r&&Eo(e?.title)?.includes("Depth")}),children:[ro(e.icon,{}),e.more?ro(Wm,{}):null]})}import{jsx as Ke}from"react/jsx-runtime";function Hg({item:e}){let t=Ag();return e==="divider"?Ke(Pi,{"data-item-type":"divider",children:Ke(Ci,{})}):(e.show===void 0?!0:e.show(t))?Ke(zc,{item:e}):null}function Og(e){let t=e.querySelector("[data-item-type=button]"),o=e.querySelector("[data-item-type=divider]");if(!t||!o)throw new Error("Button or divider not found");return{toolbar:e.offsetWidth,button:t.offsetWidth,divider:o.offsetWidth}}function Ug(e,t,o){let r=0;for(let n of e)r+=n==="divider"?o:t;return r}var Fg=48;function Bc(){let e=Dg(null),[t,o]=$g(Lc);return Ng(()=>{let r=Bg(()=>{let i=e.current;if(!i)throw new Error("Toolbar not found");let a=Og(i);for(let l=0;l<Ve.length-1;l++)if(Ug(Ve[l],a.button,a.divider)<a.toolbar-Fg){o(Ve[l]);return}o(Ve[Ve.length-1])},100,{trailing:!0}),n=setTimeout(r,0);return window.addEventListener("resize",r),()=>{clearTimeout(n),window.removeEventListener("resize",r)}},[]),Ke(Ii,{ref:e,children:Ke(Mi,{children:t.map((r,n)=>Ke(Hg,{item:r},typeof r=="string"?n:r.title))})})}import{jsx as gr,jsxs as Jg}from"react/jsx-runtime";function Nc({attributes:e,Editable:t}){let o=_g(null),r=jg(),n=Qg(),i=Kg(a=>{a.target===a.currentTarget&&(Gg.select(r,Wg.end(r,[])),qg.focus(r))},[r]);return gr(si,{children:Jg(ki,{ref:o,className:Vg({"--focused":n}),style:{height:r.toolbar.height,minHeight:r.toolbar.minHeight,maxHeight:r.toolbar.maxHeight},onClick:i,children:[gr(Bc,{}),gr(t,{as:yi,...e,style:{overflowY:"auto"}})]})})}var Dc=x((e,t)=>(e.toolbar={height:t.toolbar?.height,minHeight:t.toolbar?.minHeight,maxHeight:t.toolbar?.maxHeight,showUploadButtons:t.toolbar?.showUploadButtons??!0},{name:"toolbar",editor:{},renderEditable:Nc,editableProps:{}}));import{Editor as br,Node as Xg,Path as Yg,Transforms as Zg}from"slate";var $c=x(e=>(e.allowTrailingBlock=!0,{name:"trailing-block",editor:{normalizeNode:t=>{if(!br.isEditor(t[0]))return!1;let o=[e.children.length-1],r=Xg.child(e,e.children.length-1);return(br.hasBlocks(e,r)||br.isVoid(e,r))&&Zg.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:Yg.next(o)}),!0}}}));import{Transforms as eb}from"slate";function tb(e,t){let o=se(t),r=ce(o);eb.insertNodes(e,r)}function Ac(e){return{pasteMarkdown:d(tb,e)}}var Hc=x(e=>(e.pasteMarkdown=Ac(e),{name:"paste-markdown",editor:{},editableProps:{onPaste(t){let{types:o}=t.clipboardData;if(o.length!==1||o[0]!=="text/plain")return!1;let r=t.clipboardData.getData("text/plain");return e.pasteMarkdown.pasteMarkdown(r),he(t),!0}}}));import{jsx as rb}from"react/jsx-runtime";function ob(e){let t={...e.attributes,style:{...e.attributes.style,width:void 0,maxWidth:void 0}};return rb("span",{...t,children:e.children})}var Oc=x((e,t,{createPolicy:o})=>(e.placeholder={},o({name:"placeholder",editableProps:{renderPlaceholder:ob}})));var Uc=[Hc,Nl,Ji,_l,zs,Zl,Ja,yl,Nm,jl,$c,Ps,ea,Ds,Cl,Am,Dc,qa,Oc];var nb=Nn(Uc),{withSink:Fc,SinkEditable:Vc}=nb;import{useState as ib}from"react";import{createEditor as ab,Editor as lb,Transforms as sb}from"slate";import{withHistory as mb}from"slate-history";import{withReact as cb}from"slate-react";function Er({authToken:e,height:t,minHeight:o,maxHeight:r}){let[n]=ib(()=>{let i=ab(),a=Fc(cb(mb(i)),{toolbar:{height:t,minHeight:o,maxHeight:r,showUploadButtons:!!e},image:{}});return a.convertElement.addConvertElementType("paragraph"),i.wysimark={},i.getMarkdown=()=>Qe(i.children),i.setMarkdown=l=>{let s=se(l),m=ce(s);i.children=m,i.selection=null,sb.select(i,lb.start(i,[0]))},a});return n}import{jsx as te,jsxs as bb}from"react/jsx-runtime";function gb({children:e,attributes:t}){return te("span",{...t,children:e})}function _c({editor:e,value:t,onChange:o,throttleInMs:r=1e3,placeholder:n,className:i,style:a,onImageChange:l}){let[s,m]=Kc(!1),[c,p]=Kc(t),h=no(!1),y=no(void 0),E=no(void 0),k=no(void 0),C=Te(pb(()=>{let I=Qe(e.children);e.wysimark.prevValue={markdown:I,children:e.children},k.current=I,o(I)},r,{leading:!1,trailing:!0}),[e,o,r]),T=Te(I=>{if(h.current){h.current=!1,E.current=I;return}E.current!==I&&(E.current=I,C())},[C]);if(e.wysimark.prevValue==null||y.current==null){h.current=!0;let I=s?t:se(t),H=ce(I);e.children=H,E.current=y.current=H,e.wysimark.prevValue={markdown:t,children:H},k.current=t}else if(s)e.wysimark.prevValue.markdown=t,k.current=t;else{let I=t!==e.wysimark.prevValue.markdown,H=t!==k.current;if(I&&H){h.current=!0;let N=se(t),O=ce(N);e.children=O,e.selection=null,ub.select(e,db.start(e,[0]))}}let z=Te(()=>{navigator.userAgent.toLowerCase().includes("firefox")&&fb.focus(e)},[e]),q=Te(()=>{C.flush()},[C]),Q=I=>{let H=I.target.value;p(H),o(H)},j=Te(()=>{c!==e.getMarkdown()&&e.setMarkdown(c)},[e,c]),K=Te(()=>{p(t)},[t]),_e=Te(()=>{s?j():K(),m(!s)},[s,j,K]);return e.wysimark.isRawMode=s,e.wysimark.toggleRawMode=_e,e.wysimark.onImageChange=l,bb("div",{style:{position:"relative"},children:[s&&te("div",{style:{position:"absolute",top:"5px",right:"25px",zIndex:10},children:te("div",{onClick:_e,style:{background:"none",border:"1px solid #4a90e2",cursor:"pointer",padding:"6px",borderRadius:"4px",backgroundColor:"rgba(74, 144, 226, 0.1)",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)",transition:"all 0.2s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center"},title:f("switchToVisualEditor"),role:"button",tabIndex:0,onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(_e(),I.preventDefault())},children:te("span",{style:{color:"#4a90e2",fontSize:"1.25em"},children:te(Yt,{})})})}),te("div",{style:{display:s?"block":"none",textAlign:"center"},children:te("textarea",{value:so(c).replace(/&nbsp;/g,""),onChange:Q,placeholder:n,className:i,style:{width:"calc(100% - 60px)",margin:"0 auto",minHeight:"200px",padding:"20px",fontFamily:"monospace",fontSize:"14px",color:"#333",lineHeight:"1.5",backgroundColor:"#fff",border:"1px solid #ddd",borderRadius:"4px",...a}})}),te("div",{style:{display:s?"none":"block"},children:te(hb,{editor:e,initialValue:y.current??e.children,onChange:T,children:te(Vc,{renderLeaf:gb,onMouseDown:z,onBlur:q,placeholder:n,className:i,style:a})})})]})}import{jsx as Wc}from"react/jsx-runtime";function wb({standaloneOptions:{onChange:e,placeholder:t,className:o,...r},standaloneMethodsRef:n}){let[i,a]=Tb(r.initialMarkdown||""),l=kb(i),s=Er(r);l.current=i,yb(n,()=>({getMarkdown(){return l.current},setMarkdown(c){l.current=c,a(c)}}),[l,a]);let m=xb(c=>{l.current=c,a(c),e?.(c)},[s]);return Wc(_c,{editor:s,value:i,className:o||"",onChange:m,placeholder:t})}function iA(e,t){let o=Eb(),r=vb(e);return r.render(Wc(wb,{standaloneMethodsRef:o,standaloneOptions:t})),{unmount(){try{r.unmount()}catch{}},getMarkdown(){return o.current?.getMarkdown()||""},setMarkdown(n){o.current?.setMarkdown(n)}}}export{_c as Editable,iA as createWysimark,Er as useEditor};
1450
+ `;import{Fragment as Vg,jsx as pe,jsxs as lo}from"react/jsx-runtime";var Fg=Ng("enter");function Rc({dest:e,close:t}){let o=Ug(),r=$g(null),n=q({src:r,dest:e},({src:k,dest:w},D)=>It(k,D,{left:w.left-12,top:w.top+w.height},{margin:16})),i=Dg(()=>{let{selection:k}=o;return k&&!Ag.isCollapsed(k)?Hg.string(o,k):""},[]),[a,l]=ao(""),[s,c]=ao(i),[m,d]=ao(i),[p,g]=ao(!1),E=()=>{let k=s.trim()||a,w=m.trim()||void 0;o.anchor.insertLink(a,k,{select:!0,title:w}),Og.focus(o),t()},T=yr(k=>{l(k.currentTarget.value)},[l]),M=yr(k=>{let w=k.currentTarget.value;c(w),p||d(w)},[c,d,p]),I=yr(k=>{d(k.currentTarget.value),g(!0)},[d]),v=k=>{Fg(k)&&(k.preventDefault(),k.stopPropagation(),E())};return lo(Vg,{children:[pe(ge,{close:t}),lo(Ii,{ref:r,style:n,children:[pe(Mt,{children:pe(Pt,{type:"text",value:a,autoFocus:!0,placeholder:f("linkUrl"),onChange:T,onKeyDown:v})}),pe(Mt,{style:{marginTop:"0.5em"},children:pe(Pt,{type:"text",value:s,placeholder:f("linkText"),onChange:M,onKeyDown:v})}),lo(Mt,{style:{marginTop:"0.5em"},children:[pe(Pt,{type:"text",value:m,placeholder:f("tooltipText"),onChange:I,onKeyDown:v}),lo(Cc,{onClick:E,children:[pe(no,{}),pe(oc,{})]})]}),pe(Sc,{children:f("tooltipHint")})]})]})}var kr=[{icon:no,title:f("insertLink"),more:!0,hotkey:"mod+k",Component:Rc},{icon:uc,title:f("insertImageFromUrl"),more:!0,Component:Mc},{icon:cc,title:f("insertTable"),more:!0,Component:Zm}],Lc=kr,Bc=kr,zc=[{icon:fc,title:f("insert"),more:!0,children:kr}];import{Editor as Kg}from"slate";function Qe(e){let t=Kg.marks(e);return{bold:t?.bold||!1,italic:t?.italic||!1,strike:t?.strike||!1,code:t?.code||!1,underline:t?.underline||!1,highlight:t?.highlight||!1}}var Nc=[{icon:hr,title:f("bold"),hotkey:"mod+b",action:e=>e.marksPlugin.toggleBold(),active:e=>Qe(e).bold},{icon:lc,title:f("italic"),hotkey:"mod+i",action:e=>e.marksPlugin.toggleItalic(),active:e=>Qe(e).italic},{icon:hc,title:f("strike"),hotkey:"super+k",action:e=>e.marksPlugin.toggleStrike(),active:e=>Qe(e).strike},{icon:pc,title:f("inlineCode"),hotkey:"mod+j",action:e=>e.inlineCode.toggleInlineCode(),active:e=>Qe(e).code},{icon:gc,title:f("underline"),hotkey:"mod+u",action:e=>e.marksPlugin.toggleUnderline(),active:e=>Qe(e).underline},{icon:kc,title:f("highlight"),action:e=>e.marksPlugin.toggleHighlight(),active:e=>Qe(e).highlight,show:e=>!e.wysimark?.disableHighlight}],Tr=Nc,Dc=[{icon:hr,title:f("format"),more:!0,children:Nc}];var $c=[{icon:mc,title:f("bulletList"),hotkey:"super+8",action:e=>e.list?.convertUnorderedList(!0),show:e=>!!e.list},{icon:br,title:f("numberedList"),hotkey:"super+7",action:e=>e.list?.convertOrderedList(!0),show:e=>!!e.list},{icon:bc,title:f("checkList"),hotkey:"super+9",action:e=>e.list?.convertTaskList(!0),show:e=>!!e.list&&!e.wysimark?.disableTaskList}],vr=[...$c,"divider",...Er],Hc=[{icon:br,title:f("list"),more:!0,children:[...$c,"divider",...Er],show:e=>!!e.list}];import{Editor as Ac,Transforms as so}from"slate";var Oc=[{icon:gr,title:f("quote"),hotkey:"super+.",action:e=>{e.blockQuotePlugin.isActive()?e.blockQuotePlugin.outdent():e.blockQuotePlugin.indent()},active:e=>e.blockQuotePlugin.isActive()},{icon:sc,title:f("increaseQuoteDepth"),action:e=>e.blockQuotePlugin.increaseDepth(),active:e=>e.blockQuotePlugin.canIncreaseDepth()},{icon:dc,title:f("codeBlock"),action:e=>{let{selection:t}=e,o=b(e,"code-block");if(o){let[r,n]=o,i=Ac.string(e,n);so.removeNodes(e,{at:n}),so.insertNodes(e,{type:"paragraph",children:[{text:i}]},{at:n});return}if(t&&JSON.stringify(t.anchor.path)!==JSON.stringify(t.focus.path)){e.codeBlock?.createCodeBlock({language:"text"});return}if(t&&(t.anchor.offset!==t.focus.offset||JSON.stringify(t.anchor.path)!==JSON.stringify(t.focus.path))){let r=Ac.string(e,t);so.delete(e),so.insertNodes(e,{type:"code-block",language:"text",children:[{type:"code-block-line",children:[{text:r}]}]});return}e.codeBlock?.createCodeBlock({language:"text"})},active:e=>!!b(e,"code-block"),show:e=>!!e.codeBlock&&!e.wysimark?.disableCodeBlock}],wr=Oc,Uc=[{icon:gr,title:f("quote"),more:!0,children:Oc}];var mo={icon:yc,title:f("switchToRawMarkdown"),action:e=>{e.wysimark&&typeof e.wysimark.toggleRawMode=="function"&&e.wysimark.toggleRawMode()},show:e=>e.wysimark&&typeof e.wysimark.toggleRawMode=="function"&&!e.wysimark.isRawMode,active:()=>!1},co={icon:io,title:f("switchToVisualEditor"),action:e=>{e.wysimark&&typeof e.wysimark.toggleRawMode=="function"&&e.wysimark.toggleRawMode()},show:e=>!!(e.wysimark&&e.wysimark.isRawMode),active:()=>!1};var Wg=[...vc,"divider",...vr,"divider",...Tr,"divider",...Lc,"divider",...wr,"divider",mo,co],_g=[...xr,"divider",...vr,"divider",...Tr,"divider",...Bc,"divider",...wr,"divider",mo,co],Fc=[...xr,"divider",...Hc,"divider",...Dc,"divider",...zc,"divider",...Uc,"divider",mo,co],Vc=Fc;var je=[Wg,_g,Fc];import{clsx as Gg}from"clsx";import{useCallback as Ir,useRef as qg}from"react";import{ReactEditor as Qg,useSlate as jg,useSlateStatic as Xg}from"slate-react";import{jsx as po,jsxs as Jg}from"react/jsx-runtime";function Kc({item:e}){let t=Xg(),o=jg(),r=e.active?e.active(o):!1,n=qg(null),i=J({title:e.title,hotkey:()=>e.hotkey?vt(e.hotkey):void 0}),a=$("menu"),l=Ir(()=>{let m=n.current,d=e.children,p=e.Component;m&&(d?a.open(()=>po(St,{dest:m,items:d,close:a.close})):p&&a.open(()=>po(p,{dest:m,close:a.close})))},[e]),s=Ir(()=>{if(e.action){e.action(t),Qg.focus(t);return}a.layer?a.close():l()},[a.layer,e]),c=Ir(m=>{i.onMouseEnter(m),a.layer&&l()},[a.layer]);return Jg(Hi,{"data-item-type":"button",ref:n,onMouseEnter:c,onMouseLeave:i.onMouseLeave,onClick:s,className:Gg({"--active":r&&!Io(e?.title)?.includes("Depth"),"--more":e.more,"--disabled":!r&&Io(e?.title)?.includes("Depth")}),children:[po(e.icon,{}),e.more?po(tc,{}):null]})}import{jsx as Xe}from"react/jsx-runtime";function rb({item:e}){let t=ob();return e==="divider"?Xe(Di,{"data-item-type":"divider",children:Xe($i,{})}):(e.show===void 0?!0:e.show(t))?Xe(Kc,{item:e}):null}function nb(e){let t=e.querySelector("[data-item-type=button]"),o=e.querySelector("[data-item-type=divider]");if(!t||!o)throw new Error("Button or divider not found");return{toolbar:e.offsetWidth,button:t.offsetWidth,divider:o.offsetWidth}}function ib(e,t,o){let r=0;for(let n of e)r+=n==="divider"?o:t;return r}var ab=48;function Wc(){let e=eb(null),[t,o]=tb(Vc);return Zg(()=>{let r=Yg(()=>{let i=e.current;if(!i)throw new Error("Toolbar not found");let a=nb(i);for(let l=0;l<je.length-1;l++)if(ib(je[l],a.button,a.divider)<a.toolbar-ab){o(je[l]);return}o(je[je.length-1])},100,{trailing:!0}),n=setTimeout(r,0);return window.addEventListener("resize",r),()=>{clearTimeout(n),window.removeEventListener("resize",r)}},[]),Xe(zi,{ref:e,children:Xe(Ni,{children:t.map((r,n)=>Xe(rb,{item:r},typeof r=="string"?n:r.title))})})}import{jsx as Mr,jsxs as hb}from"react/jsx-runtime";function _c({attributes:e,Editable:t}){let o=mb(null),r=fb(),n=ub(),i=sb(a=>{a.target===a.currentTarget&&(pb.select(r,cb.end(r,[])),db.focus(r))},[r]);return Mr(Ei,{children:hb(Si,{ref:o,className:lb({"--focused":n}),style:{height:r.toolbar.height,minHeight:r.toolbar.minHeight,maxHeight:r.toolbar.maxHeight},onClick:i,children:[Mr(Wc,{}),Mr(t,{as:Ci,...e,style:{overflowY:"auto"}})]})})}var Gc=x((e,t)=>(e.toolbar={height:t.toolbar?.height,minHeight:t.toolbar?.minHeight,maxHeight:t.toolbar?.maxHeight,showUploadButtons:t.toolbar?.showUploadButtons??!0},{name:"toolbar",editor:{},renderEditable:_c,editableProps:{}}));import{Editor as Pr,Node as gb,Path as bb,Transforms as Eb}from"slate";var qc=x(e=>(e.allowTrailingBlock=!0,{name:"trailing-block",editor:{normalizeNode:t=>{if(!Pr.isEditor(t[0]))return!1;let o=[e.children.length-1],r=gb.child(e,e.children.length-1);return(Pr.hasBlocks(e,r)||Pr.isVoid(e,r))&&Eb.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:bb.next(o)}),!0}}}));import{Transforms as xb}from"slate";function yb(e,t){let o=de(t),r=fe(o);xb.insertNodes(e,r)}function Qc(e){return{pasteMarkdown:u(yb,e)}}var jc=x(e=>(e.pasteMarkdown=Qc(e),{name:"paste-markdown",editor:{},editableProps:{onPaste(t){let{types:o}=t.clipboardData;if(o.length!==1||o[0]!=="text/plain")return!1;let r=t.clipboardData.getData("text/plain");return e.pasteMarkdown.pasteMarkdown(r),ye(t),!0}}}));import{jsx as Tb}from"react/jsx-runtime";function kb(e){let t={...e.attributes,style:{...e.attributes.style,width:void 0,maxWidth:void 0}};return Tb("span",{...t,children:e.children})}var Xc=x((e,t,{createPolicy:o})=>(e.placeholder={},o({name:"placeholder",editableProps:{renderPlaceholder:kb}})));var Jc=[jc,Kl,ea,Zl,Fs,ss,el,kl,Pl,Wm,ns,qc,$s,na,Ws,$l,qm,Gc,Ja,Xc];var{withSink:Yc,SinkEditable:Zc}=Wn(Jc);import{useState as vb}from"react";import{createEditor as wb,Editor as Ib,Transforms as Mb}from"slate";import{withHistory as Pb}from"slate-history";import{withReact as Cb}from"slate-react";function Cr({authToken:e,height:t,minHeight:o,maxHeight:r,disableRawMode:n,disableTaskList:i,disableCodeBlock:a,disableHighlight:l}={}){let[s]=vb(()=>{let c=wb(),m=Yc(Cb(Pb(c)),{toolbar:{height:t,minHeight:o,maxHeight:r,showUploadButtons:!!e},image:{}});return m.convertElement.addConvertElementType("paragraph"),c.wysimark={disableRawMode:n??!0,disableTaskList:i,disableCodeBlock:a,disableHighlight:l??!0},c.getMarkdown=()=>et(c.children),c.setMarkdown=d=>{let p=de(d),g=fe(p);c.children=g,c.selection=null,Mb.select(c,Ib.start(c,[0]))},m});return s}import{jsx as re,jsxs as Db}from"react/jsx-runtime";function Nb({children:e,attributes:t}){return re("span",{...t,children:e})}function tp({editor:e,value:t,onChange:o,throttleInMs:r=1e3,placeholder:n,className:i,style:a,onImageChange:l}){let[s,c]=ep(!1),[m,d]=ep(t),p=uo(!1),g=uo(void 0),E=uo(void 0),T=uo(void 0),M=Pe(Sb(()=>{let P=Ce(et(e.children));e.wysimark.prevValue={markdown:P,children:e.children},T.current=P,o(P)},r,{leading:!1,trailing:!0}),[e,o,r]),I=Pe(P=>{if(p.current){p.current=!1,E.current=P;return}E.current=P,M()},[M]);if(e.wysimark.prevValue==null||g.current==null){p.current=!0;let P=s?t:de(t),L=fe(P);e.children=L,E.current=g.current=L,e.wysimark.prevValue={markdown:t,children:L},T.current=t}else if(s)e.wysimark.prevValue.markdown=t,T.current=t;else{let P=t!==e.wysimark.prevValue.markdown,L=t!==T.current;if(P&&L){p.current=!0;let U=de(t),G=fe(U);e.children=G,e.selection=null,Lb.select(e,Rb.start(e,[0]))}}let v=Pe(()=>{navigator.userAgent.toLowerCase().includes("firefox")&&Bb.focus(e)},[e]),k=Pe(()=>{M.flush()},[M]),w=P=>{let L=P.target.value;d(L),o(L)},D=Pe(()=>{m!==e.getMarkdown()&&e.setMarkdown(m)},[e,m]),H=Pe(()=>{d(t)},[t]),ne=Pe(()=>{s?D():H(),c(!s)},[s,D,H]);return e.wysimark.isRawMode=s,e.wysimark.disableRawMode||(e.wysimark.toggleRawMode=ne),e.wysimark.onImageChange=l,Db("div",{style:{position:"relative"},children:[s&&re("div",{style:{position:"absolute",top:"5px",right:"25px",zIndex:10},children:re("div",{onClick:ne,style:{background:"none",border:"1px solid #4a90e2",cursor:"pointer",padding:"6px",borderRadius:"4px",backgroundColor:"rgba(74, 144, 226, 0.1)",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)",transition:"all 0.2s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center"},title:f("switchToVisualEditor"),role:"button",tabIndex:0,onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(ne(),P.preventDefault())},children:re("span",{style:{color:"#4a90e2",fontSize:"1.25em"},children:re(io,{})})})}),re("div",{style:{display:s?"block":"none",textAlign:"center"},children:re("textarea",{value:Ce(m).replace(/&nbsp;/g,""),onChange:w,placeholder:n,className:i,style:{width:"calc(100% - 60px)",margin:"0 auto",minHeight:"200px",padding:"20px",fontFamily:"monospace",fontSize:"14px",color:"#333",lineHeight:"1.5",backgroundColor:"#fff",border:"1px solid #ddd",borderRadius:"4px",...a}})}),re("div",{style:{display:s?"none":"block"},children:re(zb,{editor:e,initialValue:g.current??e.children,onChange:I,children:re(Zc,{renderLeaf:Nb,onMouseDown:v,onBlur:k,placeholder:n,className:i,style:a})})})]})}import{jsx as op}from"react/jsx-runtime";function Vb({standaloneOptions:{onChange:e,placeholder:t,className:o,...r},standaloneMethodsRef:n}){let[i,a]=Ub(r.initialMarkdown||""),l=Ob(i),s=Cr(r);l.current=i,Ab(n,()=>({getMarkdown(){return l.current},setMarkdown(m){l.current=m,a(m)}}),[l,a]);let c=Hb(m=>{l.current=m,a(m),e?.(m)},[s]);return op(tp,{editor:s,value:i,className:o||"",onChange:c,placeholder:t})}function BH(e,t){let o=$b(),r=Fb(e);return r.render(op(Vb,{standaloneMethodsRef:o,standaloneOptions:t})),{unmount(){try{r.unmount()}catch{}},getMarkdown(){return o.current?.getMarkdown()||""},setMarkdown(n){o.current?.setMarkdown(n)}}}export{tp as Editable,BH as createWysimark,Cr as useEditor};