1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4398],{85948:(e,t,n)=>{n.d(t,{LF:()=>ot,Og:()=>ls,pq:()=>lu,v$:()=>r8,zz:()=>lc});var r,o,a,i=n(95155),l=n(19749),s=n(42444),c=n(12115),u=n(88010),d=n(66161),h=n(55876),p=n(37758),f=n(40546),y=n(23929),m=n(19144),g=n(65621),v=n(89149),k=n(27603),b=n(68004),x=n(39890),C=n(93434),B=n(21728),E=n(24611),D=n(791),_=n(91996),w=n(97973),A=n(44416);let S="pte:";function F(e){let t=`${S}${e}`;return u&&u.enabled(t)?u(t):u(S)}let P={behaviors:F("behaviors"),history:F("history"),mutation:F("mutation"),normalization:F("normalization"),operation:F("operation"),selection:F("selection"),setup:F("setup"),state:F("state"),syncValue:F("sync:value"),syncPatch:F("sync:patch")};function O(e,t){let n=e.scope?.find(e=>e.type===t._type&&"fields"in e&&e.fields),r=n&&"fields"in n?n.fields:e.schema.blockObjects.find(e=>e.name===t._type)?.fields;if(r)return r.find(M)}function M(e){return"array"===e.type&&"of"in e}function T(e,t){return(0,h.Kk)(t)&&t._type!==e.schema.block.name&&t._type!==e.schema.span.name}function R(e){return e.reduce((e,t,n)=>(0,h.wE)(t)?`${e}[_key=="${t._key}"]`:`${e}${0===n?"":"."}${t}`,"")}function z(e,t){let n=e.domElement;if(!n)return;if(0===t.length)return n;let r=function(e,t,n){if(0===t.length)return[];let r=[],o=e.children,a;for(let e=0;e<t.length;e++){let i=t[e];if(void 0===i)return;let l=o[i];if(!l||!l._key)return;if(r.push({_key:l._key}),e<t.length-1){if((0,d.zS)({schema:n},l))r.push("children"),o=l.children,a=void 0;else if(T({schema:n},l)){let e=O({schema:n,scope:a},l);if(!e)return;r.push(e.name),o=l[e.name],a=e.of}}}return r}(e,t,e.schema);if(!r)return;let o=R(r),a=t.at(0);if(void 0===a)return;let i=n.children[a];if(!(i instanceof HTMLElement))return;if(i.matches(`[data-pt-path="${CSS.escape(o)}"]`))return i.closest("[data-slate-editor]")!==n?void 0:i;
1let l=i.querySelector(`[data-pt-path="${CSS.escape(o)}"]`);if(l instanceof HTMLElement&&l.closest("[data-slate-editor]")===n)return l}let I=/\[_key=="(.+?)"\]/;function j(e,t){try{return JSON.stringify(e,null,t)}catch(e){return console.error(e),"JSON.stringify failed"}}function N(e,t){return $({schema:e.schema,editableTypes:e.editableTypes},{value:e.value},t)}function $(e,t,n){let r=V(e,t,void 0,"");if(!r)return[];let o=r.children,a=r.scope,i=r.scopePath,l=[];for(let t of n){let n=o[t];if(!n)return[];l=[...l,t];let r=V(e,n,a,i);if(!r)return[];o=r.children,a=r.scope,i=r.scopePath}return o.map((e,t)=>({node:e,path:[...l,t]}))}let K={children:[],scope:void 0,scopePath:""},L={children:[],scope:void 0,scopePath:""};function V(e,t,n,r){if((0,d.zS)(e,t))return K.children=t.children,K;if(T(e,t)){let o=r?`${r}.${t._type}`:t._type;if(!e.editableTypes.has(o))return;let a=O({schema:e.schema,scope:n},t);return a?{children:t[a.name],scope:a.of,scopePath:o}:void 0}if("value"in t&&Array.isArray(t.value)&&!("_key"in t)&&!("_type"in t))return L.children=t.value,L}function U(e,t){if(0===t.length)return;let n=e.value,r,o="",a;for(let i=0;i<t.length;i++){if(!(a=n.at(t.at(i))))return;if(i<t.length-1){let t=V(e,a,r,o);if(!t)return;n=t.children,r=t.scope,o=t.scopePath}}if(a)return{node:a,path:t}}function W(e,t){if(t.length<=1)return[];let n=[];for(let r=t.length-1;r>=1;r--){let o=U(e,t.slice(0,r));o&&n.push(o)}return n}function H(e,t,n){for(let r of W(e,t))if(n(r.node,r.path))return r}function G(e,t){let n=H(e,t,t=>T({schema:e.schema},t));if(n&&T({schema:e.schema},n.node))return{node:n.node,path:n.path}}function J(e,t){let n=W(e,t);for(let t=n.length-1;t>=0;t--){let r=n.at(t);if(T({schema:e.schema},r.node))return{node:r.node,path:r.path}}let r=U(e,t);if(r&&T({schema:e.schema},r.node))return{node:r.node,path:r.path}}function Z(e,t){return void 0!==U(e,t)}function Y(e,t,n){if(0===t.length)return[];let r=t[0];if(!r||!(0,h.wE)(r))return;let o=n.get(r._key);if(void 0===o)return;let a=e.children[o];if(!a)return;let i=function e(t,n){let r=n[0];if(!r)return[];if((0,h.wE)(r)){let o=t.children;if(!o)return;let a=0;for(let t of o){if(t._key===r._key){let r=e(t,n.slice(1));return r?[a,...r]:void 0}a++}return}if("string"!=typeof r||!(r in t))return;let o=t[r];if(Array.isArray(o))return e({children:o},n.slice(1))}(a,t.slice(1));if(i)return[o,...i]}function q(e,t,n){let{edge:r}=n,o=t;if(0===o.length){let t=N(e,[]);if(0===t.length)return;let n="end"===r?t.at(-1):t.at(0);if(0===N(e,n.path).length)return n;o=n.path}else{let t=U(e,o);if(!t)return;if(0===N(e,o).length)return t}for(;;){let t=N(e,o);if(0===t.length)return U(e,o)??void 0;o=("end"===r?t.at(-1):t.at(0)).path}}function X(e,t){let n=[];for(let r=0;r<e.length&&r<t.length;r++){let o=e[r];if(o!==t[r])break;n.push(o)}return n}function Q(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}let ee=e=>"object"==typeof e&&null!==e;function et(e){return ee(e)&&"number"==typeof e.offset&&Q(e.path)}function en(e){return ee(e)&&et(e.anchor)&&et(e.focus)}function er(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){if(e[r]<t[r])return -1;if(e[r]>t[r])return 1}return 0}function eo(e,t){let n=er(e.path,t.path);return 0===n?e.offset<t.offset?-1:+(e.offset>t.offset):n}function ea(e){let{anchor:t,focus:n}=e;return 1===eo(t,n)}function ei(e,t={}){let{reverse:n=!1}=t,{anchor:r,focus:o}=e;return ea(e)===n?[r,o]:[o,r]}function el(e){let[,t]=ei(e);return t}function es(e){let[t]=ei(e);return t}function ec(e,t,n={}){let{depth:r,edge:o}=n;if(Q(t)&&("start"===o||"end"===o)){let n=q(e,t,{edge:o});n&&(t=n.path)}return en(t)&&(t="start"===o?es(t):"end"===o?el(t):X(t.anchor.path,t.focus.path)),et(t)&&(t=t.path),null!=r&&(t=t.slice(0,r)),t}let eu=Symbol.for("slate-editor");function ed(e){return ee(e)&&!0===e[eu]}function eh(e,t,n={}){let{edge:r="start"}=n;if(Q(t)){let n=q(e,t,{edge:"end"===r?"end":"start"});if(!n)throw Error(`Cannot get the ${r} point in the node at path [${t}] because it has no ${r} text node.`);let{node:o,path:a}=n;if(!(0,d.bl)({schema:e.schema},o)&&!(0,p.xN)({schema:e.schema},o)&&!ed(o))return{path:a,offset:0};if(!(0,d.bl)({schema:e.schema},o))throw Error(`Cannot get the ${r} point in the node at path [${t}] because it has no ${r} text node.`);return{path:a,offset:"end"===r?o.text.length:0}}if(en(t)){let[e,n]=ei(t);return"start"===r?e:n}return t}function ep(e,t){return eh(e,t,{edge:"start"})}function ef(e,t){let n=H(e,t,t=>(0,d.zS)({schema:e.schema},t));if(n&&(0,d.zS)({schema:e.schema},n.node))return{node:n.node,path:n.path}}function*ey(e,t={}){let{at:n=[],from:r,to:o,match:a,reverse:i=!1}=t,l={schema:e.schema,editableTypes:e.editableTypes},s={value:e.value};void 0===r&&void 0===o?yield*eg(l,s,n,{match:a,reverse:i}
1):yield*function* e(t,n,r,o){let{from:a,to:i,match:l,reverse:s=!1}=o,c=$(t,n,r);for(let r of s?[...c].reverse():c){var u,d,h,p,f,y;if(u=r.path,d=a,h=i,s?void 0!==d&&-1===ev(u,d)&&!ek(u,d):void 0!==h&&1===ev(u,h))return;p=r.path,(eb(p,f=a,y=i)||void 0!==f&&ek(p,f)||void 0!==y&&ek(p,y))&&(eb(r.path,a,i)&&(!l||l(r.node,r.path))&&(yield r),yield*e(t,n,r.path,o))}}(l,s,n,{from:r,to:o,match:a,reverse:i})}function*em(e,t){yield*eg(e,t,[],{})}function*eg(e,t,n,r){let{match:o,reverse:a=!1}=r,i=$(e,t,n);for(let n of a?[...i].reverse():i)(!o||o(n.node,n.path))&&(yield n),yield*eg(e,t,n.path,r)}function ev(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],o=t[r];if(n<o)return -1;if(n>o)return 1}return e.length<t.length?-1:+(e.length>t.length)}function ek(e,t){if(e.length>=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function eb(e,t,n){return!(void 0!==t&&-1===ev(e,t)&&!ek(e,t)||void 0!==n&&1===ev(e,n)&&!ek(e,n))}function ex(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function eC(e,t){return e.offset===t.offset&&ex(e.path,t.path)}function eB(e){let{anchor:t,focus:n}=e;return eC(t,n)}function eE(e,t){var n;let[r,o]=ei(t);if(0!==r.offset||0!==o.offset||eB(t)||(n=o.path)[n.length-1]>0)return t;let a=ef(e,o.path),i=a?a.path:[],[l,s]=ei({anchor:ep(e,r),focus:o}),c=!0;for(let{node:t,path:n}of ey(e,{from:l.path,to:s.path,match:t=>(0,d.bl)({schema:e.schema},t),reverse:!0})){if(c){c=!1;continue}if((0,d.bl)({schema:e.schema},t)&&(""!==t.text||-1===er(n,i))){o={path:n,offset:t.text.length};break}}return{anchor:r,focus:o}}function eD(e){return!eB(e)}let e_="u">typeof navigator&&"u">typeof window&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,ew="u">typeof navigator&&/Android/.test(navigator.userAgent),eA="u">typeof navigator&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),eS="u">typeof navigator&&/AppleWebKit(?!.*Chrome)/i.test(navigator.userAgent),eF="u">typeof navigator&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent),eP="u">typeof navigator&&/Chrome/i.test(navigator.userAgent),eO="u">typeof navigator&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])(?:\.)/i.test(navigator.userAgent),eM=ew&&"u">typeof navigator&&/Chrome?\/(?:[0-5]?\d)(?:\.)/i.test(navigator.userAgent),eT="u">typeof navigator&&/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent),eR="u">typeof navigator&&/.*UCBrowser/.test(navigator.userAgent),ez="u">typeof navigator&&/.*Wechat/.test(navigator.userAgent)&&!/.*MacWechat/.test(navigator.userAgent)&&(!eP||eO),eI="u">typeof window&&"u">typeof window.document&&"u">typeof window.document.createElement,ej=(!eO||!eM)&&!eF&&"u">typeof globalThis&&globalThis.InputEvent&&"function"==typeof globalThis.InputEvent.prototype.getTargetRanges,eN={blur:e=>{let t=z(e,[]),n=eN.findDocumentOrShadowRoot(e);e.focused=!1,n.activeElement===t&&t.blur()},findDocumentOrShadowRoot:e=>{let t=z(e,[]);if(!t)throw Error("Cannot resolve a DOM node: editor is not mounted");let n=t.getRootNode();return n instanceof Document||n instanceof ShadowRoot?n:t.ownerDocument},focus:(e,t={retries:5})=>{if(e.focused||!e.domElement)return;if(t.retries<=0)throw Error("Could not set focus, editor seems stuck with pending operations");if(e.operations.length>0)return void setTimeout(()=>{eN.focus(e,{retries:t.retries-1})},10);let n=z(e,[]);if(!n)throw Error("Cannot resolve a DOM node: editor is not mounted");let r=eN.findDocumentOrShadowRoot(e);if(r.activeElement!==n){if(e.selection&&r instanceof Document){let t=eY(r),n=eN.toDOMRange(e,e.selection);t?.removeAllRanges(),t?.addRange(n)}e.selection||e.select(ep(e,[])),e.focused=!0,n.focus({preventScroll:!0})}},getWindow:e=>{let t=e.domWindow;if(!t)throw Error("Unable to find a host window element for this editor");return t},hasDOMNode:(e,t,n={})=>{let{editable:r=!1}=n,o=z(e,[]);if(!o)return!1;let a=null;try{a=eV(t)?t:t.parentElement}catch(e){if(e instanceof Error&&!e.message.includes('Permission denied to access property "nodeType"'))throw e}return!!a&&e0(a,"[data-slate-editor]")===o&&(!r||!!a.isContentEditable||"boolean"==typeof a.isContentEditable&&e0(a,'[contenteditable="false"]')===o||!!a.getAttribute("data-slate-zero-width"))},hasEditableTarget:(e,t)=>eU(t)&&eN.hasDOMNode(e,t,{editable:!0}),hasRange:(e,t)=>
1{let{anchor:n,focus:r}=t;return Z(e,n.path)&&Z(e,r.path)},hasSelectableTarget:(e,t)=>eN.hasEditableTarget(e,t)||eN.isTargetInsideNonReadonlyVoid(e,t),hasTarget:(e,t)=>eU(t)&&eN.hasDOMNode(e,t),isComposing:e=>!!e.composing,isFocused:e=>!!e.focused,isTargetInsideNonReadonlyVoid:(e,t)=>!e.readOnly&&!!eN.hasTarget(e,t)&&!!(eV(t)?t:t.parentElement)?.closest("[data-slate-void]"),toDOMPoint:(e,t)=>{let n,r=U(e,t.path),o=z(e,t.path);if(!o)throw Error(`Cannot resolve a DOM node from path: ${t.path}`);if(r&&T({schema:e.schema},r.node)){let e=o.querySelector("[data-slate-zero-width]");if(e){let t=e.childNodes[0];if(t)return[t,0]}let t=o.parentNode;if(t){let e=Array.from(t.childNodes).indexOf(o);if(-1!==e)return[t,e]}return[o,0]}let a=ec(e,t),i=U(e,a);(i&&T({schema:e.schema},i.node)?i:G(e,t.path))&&(t={path:t.path,offset:0});let l=Array.from(o.querySelectorAll("[data-slate-string], [data-slate-zero-width]")),s=0;for(let e=0;e<l.length;e++){let r=l[e],o=r.childNodes[0];if(null==o||null==o.textContent)continue;let{length:a}=o.textContent,i=r.getAttribute("data-slate-length"),c=s+(null==i?a:parseInt(i,10)),u=l[e+1];if(t.offset===c&&u?.hasAttribute("data-slate-mark-placeholder")){let e=u.childNodes[0];n=[e instanceof e$?e:u,+!!u.textContent?.startsWith("\uFEFF")];break}if(t.offset<=c){n=[o,Math.min(a,Math.max(0,t.offset-s))];break}s=c}if(!n)throw Error(`Cannot resolve a DOM point from Slate point: ${j(t)}`);return n},toDOMRange:(e,t)=>
1{let{anchor:n,focus:r}=t,o=ea(t),a=eN.toDOMPoint(e,n),i=eB(t)?a:eN.toDOMPoint(e,r),l=eN.getWindow(e).document.createRange(),[s,c]=o?i:a,[u,d]=o?a:i,h=!!(eV(s)?s:s.parentElement).getAttribute("data-slate-zero-width"),p=!!(eV(u)?u:u.parentElement).getAttribute("data-slate-zero-width");return l.setStart(s,h?1:c),l.setEnd(u,p?1:d),l},toSlatePoint:(e,t,n)=>{let{exactMatch:r,suppressThrow:o,searchDirection:a}=n,[i,l]=r?t:eH(t),s=i.parentNode,c=null,u=0;if(s){let t=z(e,[]);if(!t)throw Error("Cannot resolve a DOM node: editor is not mounted");let n=s.closest('[data-slate-void="true"]'),o=n&&e1(t,n)?n:null,d=s.closest('[contenteditable="false"]'),h=d&&e1(t,d)?d:null,p=s.closest("[data-slate-leaf]"),f=null;if(p){if(c=p.closest('[data-slate-node="text"]')){let t=eN.getWindow(e).document.createRange();t.setStart(c,0),t.setEnd(i,l);let n=t.cloneContents();[...Array.prototype.slice.call(n.querySelectorAll("[data-slate-zero-width]")),...Array.prototype.slice.call(n.querySelectorAll("[contenteditable=false]"))].forEach(e=>{if(ew&&!r&&e.hasAttribute("data-slate-zero-width")&&e.textContent.length>0&&"\uFEFF"!==e.textContext){e.textContent.startsWith("\uFEFF")&&(e.textContent=e.textContent.slice(1));return}e.parentNode.removeChild(e)}),u=n.textContent.length,f=c}}else if(o){let t=o.querySelectorAll("[data-slate-leaf]");for(let n=0;n<t.length;n++){let r=t[n];if(eN.hasDOMNode(e,r)){p=r;break}}p?(c=p.closest('[data-slate-node="text"]'),u=(f=p).textContent.length,f.querySelectorAll("[data-slate-zero-width]").forEach(e=>{u-=e.textContent.length})):u=1}else if(h){let e=e=>e?e.querySelectorAll("[data-slate-leaf]:not(:scope [data-slate-editor] [data-slate-leaf])"):[],t=h.closest('[data-slate-node="element"]');"backward"!==a&&a||(p=[...e(t?.previousElementSibling),...e(t)].findLast(e=>eX(h,e))??null),"forward"!==a&&a||(p=[...e(t),...e(t?.nextElementSibling)].find(e=>eQ(h,e))??null),p&&(c=p.closest('[data-slate-node="text"]'),f=p,"forward"===a?u=0:(u=f.textContent.length,f.querySelectorAll("[data-slate-zero-width]").forEach(e=>{u-=e.textContent.length})))}f&&u===f.textContent.length&&ew&&"z"===f.getAttribute("data-slate-zero-width")&&f.textContent?.startsWith("\uFEFF")&&(s.hasAttribute("data-slate-zero-width")||eA&&f.textContent?.endsWith(` 2 3`))&&u--}
3if(ew&&!c&&!r){let n=s.hasAttribute("data-slate-node")?s:s.closest("[data-slate-node]");if(n&&eN.hasDOMNode(e,n,{editable:!0})){let r=e2(n),a=r?Y(e,r,e.blockIndexMap):void 0;if(!a){if(o)return null;throw Error(`Cannot resolve a Slate point from DOM point: ${t}`)}let{path:i,offset:s}=ep(e,a);return n.querySelector("[data-slate-leaf]")||(s=l),{path:i,offset:s}}}if(!c&&s){if(i instanceof HTMLElement&&i.hasAttribute("data-slate-node")){let t=i.childNodes[l];if(t instanceof HTMLElement&&eN.hasDOMNode(e,t)){let n=t.closest("[data-slate-void]");if(n){let t=e2(n),r=t?Y(e,t,e.blockIndexMap):void 0;if(r)return{path:r,offset:0}}}}let t=s.closest('[data-slate-node="element"]')??(s.hasAttribute("data-slate-node")?s:null);if(t&&eN.hasDOMNode(e,t)){let n=t.closest("[data-slate-void]");if(n){let t=e2(n),r=t?Y(e,t,e.blockIndexMap):void 0;if(r)return{path:r,offset:0}}}}if(!c){if(o)return null;throw Error(`Cannot resolve a Slate point from DOM point: ${t}`)}let d=e2(c),h=d?Y(e,d,e.blockIndexMap):void 0;if(!h){if(o)return null;throw Error(`Cannot resolve a Slate point from DOM point: ${t}`)}if(h.length>1){let t=h.slice(0,-1),n=U(e,t);if(n&&T({schema:e.schema},n.node))return{path:t,offset:0}}return{path:h,offset:u}},toSlateRange:(e,t,n)=>{let{exactMatch:r,suppressThrow:o}=n,a=eW(t)?t.anchorNode:t.startContainer,i=null,l=0,s=null,c=0,u=!1;if(a)if(eW(t)){if(eA&&t.rangeCount>1){s=t.focusNode;let e=t.getRangeAt(0),n=t.getRangeAt(t.rangeCount-1);if(s instanceof HTMLTableRowElement&&e.startContainer instanceof HTMLTableRowElement&&n.startContainer instanceof HTMLTableRowElement){let t=function(e){return e.childElementCount>0?t(e.children[0]):e},r=e.startContainer,o=n.startContainer,a=t(r.children[e.startOffset]),u=t(o.children[n.startOffset]);c=0,i=u.childNodes.length>0?u.childNodes[0]??null:u,s=a.childNodes.length>0?a.childNodes[0]??null:a,l=u instanceof HTMLElement?u.innerHTML.length:0}else e.startContainer===s?(i=n.endContainer,l=n.endOffset,c=e.startOffset):(i=e.startContainer,l=e.endOffset,c=n.startOffset)}else i=t.anchorNode,l=t.anchorOffset,s=t.focusNode,c=t.focusOffset;u=eP&&eG(i)||eA?t.anchorNode===t.focusNode&&t.anchorOffset===t.focusOffset:t.isCollapsed}else i=t.startContainer,l=t.startOffset,s=t.endContainer,c=t.endOffset,u=t.collapsed;if(null==i||null==s||null==l||null==c){if(o)return null;throw Error(`Cannot resolve a Slate range from DOM range: ${t}`)}eA&&s.textContent?.endsWith(` 4 5`)&&c===s.textContent.length&&c--;let d=eN.toSlatePoint(e,[i,l],{exactMatch:r,suppressThrow:o});if(!d)return null;let h=eX(i,s)||i===s&&c<l,p=u?d:eN.toSlatePoint(e,[s,c],{exactMatch:r,suppressThrow:o,searchDirection:h?"forward":"backward"});if(!p)return null;let f={anchor:d,focus:p};return eD(f)&&!ea(f)&&eV(s)&&J(e,f.focus.path)&&(f=eE(e,f)),f}},e$=globalThis.Text,eK=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView||null,eL=e=>eU(e)&&8===e.nodeType,eV=e=>eU(e)&&1===e.nodeType,eU=e=>{let t=eK(e);return!!t&&e instanceof t.Node},eW=e=>{let t=e&&e.anchorNode&&eK(e.anchorNode);return!!t&&e instanceof t.Selection},eH=e=>{let[t,n]=e;if(eV(t)&&t.childNodes.length){let e=n===t.childNodes.length,r=e?n-1:n;for([t,r]=eJ(t,r,e?"backward":"forward"),e=r<n;eV(t)&&t.childNodes.length;){let n=e?t.childNodes.length-1:0;t=eZ(t,n,e?"backward":"forward")}n=e&&null!=t.textContent?t.textContent.length:0}return[t,n]},eG=e=>{let t=e&&e.parentNode;for(;t;){if("[object ShadowRoot]"===t.toString())return!0;t=t.parentNode}return!1},eJ=(e,t,n)=>{let{childNodes:r}=e,o=r[t],a=t,i=!1,l=!1;for(;(eL(o)||eV(o)&&0===o.childNodes.length||eV(o)&&"false"===o.getAttribute("contenteditable"))&&!(i&&l);){if(a>=r.length){i=!0,a=t-1,n="backward";continue}if(a<0){l=!0,a=t+1,n="forward";continue}o=r[a],t=a,a+="forward"===n?1:-1}return[o,t]},eZ=(e,t,n)=>{let[r]=eJ(e,t,n);return r},eY=e=>"getSelection"in e&&"function"==typeof e.getSelection?e.getSelection():document.getSelection(),eq=(e,t,n)=>{let{target:r}=t;if(eV(r)&&r.matches('[contentEditable="false"]'))return!1;let{document:o}=eN.getWindow(e);if(e1(o,r))return eN.hasDOMNode(e,r,{editable:!0});let a=n.find(({addedNodes:e,removedNodes:t})=>{for(let t of e)if(t===r||e1(t,r))return!0;for(let e of t)if(e===r||e1(e,r))return!0;return!1});return!!a&&a!==t&&eq(e,a,n)},eX=(e,t)=>!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING),eQ=(e,t)=>!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING),e0=(e,t)=>{if(!e)return null;let n=e;for(;n;){if(n.matches&&n.matches(t))return n;if(n.parentElement)n=n.parentElement;else if(n.parentNode&&"host"in n.parentNode)n=n.parentNode.host;else break}return null},e1=(e,t)=>{if(!e||!t)return!1;if(e.contains(t))return!0;let n=t;for(;n;){if(n===e)return!0;
5if(n.parentNode)n="host"in n.parentNode?n.parentNode.host:n.parentNode;else break}return!1};function e2(e){let t=eV(e)?e:e.parentElement;if(t&&!t.hasAttribute("data-pt-path")&&(t=t.closest("[data-pt-path]")),!t)return;let n=t.getAttribute("data-pt-path");if(null!==n)return""===n?[]:function(e){let t=[],n=e;for(;n.length>0;){let e;n.startsWith(".")&&(n=n.slice(1));let r=n.match(I);if(r?.[1]&&n.startsWith("[")){t.push({_key:r[1]}),n=n.slice(r[0].length);continue}let o=n.indexOf("["),a=n.indexOf(".");e=-1===o&&-1===a?n.length:-1===o?a:-1===a?o:Math.min(o,a);let i=n.slice(0,e);i&&t.push(i),n=n.slice(e)}return t}(n)}function e3(e,t){if(!(t.length<=1))return U(e,t.slice(0,-1))}function e4(e,t){let n=e3(e,t);return!n||!(0,p.xN)({schema:e.schema},n.node)}function e8({editor:e,point:t}){let n=U(e,t.path.slice(0,1)),r=t.path.at(1);if(!n||void 0===r)return[void 0,void 0];let o=N(e,n.path).at(r);return o?[o.node,o.path]:[void 0,void 0]}function e5({schema:e,editor:t,range:n}){let r=U(t,n.anchor.path.slice(0,1)),o=U(t,n.focus.path.slice(0,1)),a=r?.node,i=o?.node;if(!a||!i)return null;let[l]=a._type===e.block.name?e8({editor:t,point:n.anchor}):[void 0,void 0],[s]=i._type===e.block.name?e8({editor:t,point:n.focus}):[void 0,void 0],c={anchor:{path:[{_key:a._key}],offset:n.anchor.offset},focus:{path:[{_key:i._key}],offset:n.focus.offset},backward:ea(n)};return l&&(c.anchor.path.push("children"),c.anchor.path.push({_key:l._key})),s&&(c.focus.path.push("children"),c.focus.path.push({_key:s._key})),c}function e7({schema:e,editor:t,point:n}){let r=U(t,n.path.slice(0,1))?.node;if(!r)return;let[o]=r._type===e.block.name?e8({editor:t,point:n}):[void 0,void 0];return o?{path:[{_key:r._key},"children",{_key:o._key}],offset:n.offset}:{path:[{_key:r._key}],offset:n.offset}}function e9({editorActor:e,slateEditor:t,event:n}){if(e.getSnapshot().matches({setup:"setting up"}))return;let r=function({slateEditor:e,event:t}){if(eN.hasTarget(e,t.target))try{let n=e2(t.target),r=n?Y(e,n,e.blockIndexMap):void 0;if(r){if(0===r.length)return{node:e,path:r};{let t=U(e,r);if(t)return{node:t.node,path:r}}}}catch(e){console.error(e)}}({slateEditor:t,event:n});if(!r)return;let{node:o,path:a}=r,i=function(e,t){let n=U(e,t);if(n&&e4(e,t)&&!(0,p.JS)({schema:e.schema},n.node))return{node:n.node,path:n.path}}(t,a.slice(0,1))?.node,l=function({nodePath:e,slateEditor:t,event:n}){let r=U(t,[0]);if(!r)return;let o=z(t,r.path);if(!o)return;let a=o.getBoundingClientRect();if(n.pageY<a.top)return"start";let i=t.children.length-1,l=i>=0?U(t,[i]):void 0;if(!l)return;let s=z(t,l.path);if(!s)return;let c=s.getBoundingClientRect();if(n.pageY>c.bottom)return"end";let u=z(t,e);if(!u)return;let d=u.getBoundingClientRect(),h=d.top,p=d.height;return Math.abs(h-n.pageY)<p/2?"start":"end"}({nodePath:a,slateEditor:t,event:n}),s=function({schema:e,slateEditor:t,event:n}){let r=function(e,t){let n,r;if(!t.target||!eU(t.target))return;let o=eN.getWindow(e);if(void 0!==o.document.caretPositionFromPoint){let e=o.document.caretPositionFromPoint(t.clientX,t.clientY);if(e)try{(n=o.document.createRange()).setStart(e.offsetNode,e.offset),n.setEnd(e.offsetNode,e.offset)}catch{}}else{if(void 0===o.document.caretRangeFromPoint)return void console.warn("Neither caretPositionFromPoint nor caretRangeFromPoint is supported");n=o.document.caretRangeFromPoint(t.clientX,t.clientY)??void 0}if(n){try{r=eN.toSlateRange(e,n,{exactMatch:!1,suppressThrow:!1})}catch{}return r}}(t,n);return r?e5({schema:e,editor:t,range:r}):null}({schema:e.getSnapshot().context.schema,slateEditor:t,event:n});if(i&&l&&!s&&!ed(o))return{block:l,isEditor:!1,selection:{anchor:(0,h.u3)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}}),focus:(0,h.J8)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}})}};if(!l||!s)return;let c=(0,h.XE)(s.focus);if(void 0!==c)return(0,h.WV)(s)&&i&&c!==i._key?{block:l,isEditor:!1,selection:{anchor:(0,h.u3)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}}),focus:(0,h.J8)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}})}}:{block:l,isEditor:ed(o),selection:s}}function e6(e,t){if(!e||!t)return null;let n=[],r=e.offset||0,o="object"==typeof e.path[0]&&"_key"in e.path[0]&&e.path[0]._key,a="object"==typeof e.path[2]&&"_key"in e.path[2]&&e.path[2]._key,i=t.find(e=>e._key===o);if(!i)return null;if(n.push({_key:i._key}),i&&"children"===e.path[1]){if(!i.children||Array.isArray(i.children)&&0===i.children.length)return null;let t=Array.isArray(i.children)&&i.children.find(e=>e._key===a);if(!t)return null;n.push("children"),n.push({_key:t._key}),r=t.text&&t.text.length>=e.offset?e.offset:t.text&&t.text.length||0}return{path:n,offset:r}}function te(e){if(!e.context.selection)return null;if((0,h._Q)(e.context.selection.anchor,e.context.selection.focus)){let t=tt(e,e.context.selection.anchor,e.context.selection.backward?"backward":"forward");return t?{anchor:t,focus:t}:null}let t=tt(e,e.context.selection.anchor,e.context.selection.backward?"forward":"backward"),n=tt(e,e.context.selection.focus,e.context.selection.backward?"backward":"forward");return t&&n?{anchor:t,focus:n}:null}function tt(e,t,n){let r=(0,h.XE)(t);if(!r)return;let o=e.blockIndexMap.get(r);if(void 0===o)return;let a=e.context.value.at(o);if(!a)return;if(!(0,d.zS)(e.context,a))return{path:[o],offset:0};let i=(0,h.qX)({path:t.path}),l=i?void 0:(0,h.m4)({context:{schema:e.context.schema,value:[a]},blockOffset:{path:[{_key:r}],offset:t.offset},direction:n});if(!(i=l?(0,h.qX)(l):i))return{path:[o,0],offset:0};let s=l?.offset??t.offset,c=[],u=-1,p;for(let t of a.children)if(u++,t._key===i){p=t,(0,d.bl)(e.context,t)?c=[u]:(c=[u],s=0);break}return 0===c.length?{path:[o,0],offset:0}:{path:[o].concat(c),offset:(0,d.bl)(e.context,p)?Math.min(p.text.length,s):s}}function tn(e,t){let n=U(e,t);if(!n)return;if((0,d.bl)({schema:e.schema},n.node))return n.node.text;let r="";for(let n of ey(e,{at:t}))(0,d.bl)({schema:e.schema},n.node)&&(r+=n.node.text);return r}function tr(e,t={}){let{edge:n="anchor"}=t,{selection:r}=e;if(r){if("anchor"===n)e.select(r.anchor);else if("focus"===n)e.select(r.focus);else if("start"===n){let[t]=ei(r);e.select(t)}else if("end"===n){let[,t]=ei(r);e.select(t)}}}function to(e){let{selection:t}=e;t&&e.apply({type:"set_selection",properties:t,newProperties:null})}function ta(e,t){return eh(e,t,{edge:"end"})}function ti(e,t){return e.length<t.length&&0===er(e,t)}let tl=(e,t=!1)=>{let n=!t,r=t?tp(e):e,o=tm.None,a=tm.None,i=0,l=null;for(let t of r){let r=t.codePointAt(0);if(!r)break;let s=t_(t,r);
5if([o,a]=n?[a,s]:[s,o],(o&tm.ZWJ)!=0&&(a&tm.ExtPict)!=0&&!(n?tS(e.substring(0,i)):tS(e.substring(0,e.length-i)))||(o&tm.RI)!=0&&(a&tm.RI)!=0&&!(l=null!==l?!l:!!n||tP(e.substring(0,e.length-i)))||o!==tm.None&&a!==tm.None&&function(e,t){return -1===tw.findIndex(n=>(e&n[0])!=0&&(t&n[1])!=0)}(o,a))break;i+=t.length}return i||1},ts=/\s/,tc=/[\u002B\u0021-\u0023\u0025-\u002A\u002C-\u002F\u003A\u003B\u003F\u0040\u005B-\u005D\u005F\u007B\u007D\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/,tu=/['\u2018\u2019]/,td=(e,t,n)=>{if(n){let n=e.length-t;return[e.slice(n,e.length),e.slice(0,n)]}return[e.slice(0,t),e.slice(t)]},th=(e,t,n=!1)=>
5{if(ts.test(e))return!1;if(tu.test(e)){let e=tl(t,n),[r,o]=td(t,e,n);if(th(r,o,n))return!0}return!tc.test(e)},tp=function*(e){let t=e.length-1;for(let n=0;n<e.length;n++){let r=e.charAt(t-n);if(ty(r.charCodeAt(0))){let o=e.charAt(t-n-1);if(tf(o.charCodeAt(0))){yield o+r,n++;continue}}yield r}},tf=e=>e>=55296&&e<=56319,ty=e=>e>=56320&&e<=57343,tm={None:0,Extend:1,ZWJ:2,RI:4,Prepend:8,SpacingMark:16,L:32,V:64,T:128,LV:256,LVT:512,ExtPict:1024,Any:2048},tg=/^[\p{Gr_Ext}\p{EMod}]$/u,tv=/^[\u0600-\u0605\u06DD\u070F\u0890-\u0891\u08E2\u0D4E\u{110BD}\u{110CD}\u{111C2}-\u{111C3}\u{1193F}\u{11941}\u{11A3A}\u{11A84}-\u{11A89}\u{11D46}]$/u,tk=/^[\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0982-\u0983\u09BF-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0B02-\u0B03\u0B40\u0B47-\u0B48\u0B4B-\u0B4C\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0C01-\u0C03\u0C41-\u0C44\u0C82-\u0C83\u0CBE\u0CC0-\u0CC1\u0CC3-\u0CC4\u0CC7-\u0CC8\u0CCA-\u0CCB\u0D02-\u0D03\u0D3F-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D82-\u0D83\u0DD0-\u0DD1\u0DD8-\u0DDE\u0DF2-\u0DF3\u0E33\u0EB3\u0F3E-\u0F3F\u0F7F\u1031\u103B-\u103C\u1056-\u1057\u1084\u1715\u1734\u17B6\u17BE-\u17C5\u17C7-\u17C8\u1923-\u1926\u1929-\u192B\u1930-\u1931\u1933-\u1938\u1A19-\u1A1A\u1A55\u1A57\u1A6D-\u1A72\u1B04\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B82\u1BA1\u1BA6-\u1BA7\u1BAA\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1C24-\u1C2B\u1C34-\u1C35\u1CE1\u1CF7\uA823-\uA824\uA827\uA880-\uA881\uA8B4-\uA8C3\uA952-\uA953\uA983\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BE-\uA9C0\uAA2F-\uAA30\uAA33-\uAA34\uAA4D\uAAEB\uAAEE-\uAAEF\uAAF5\uABE3-\uABE4\uABE6-\uABE7\uABE9-\uABEA\uABEC\u{11000}\u{11002}\u{11082}\u{110B0}-\u{110B2}\u{110B7}-\u{110B8}\u{1112C}\u{11145}-\u{11146}\u{11182}\u{111B3}-\u{111B5}\u{111BF}-\u{111C0}\u{111CE}\u{1122C}-\u{1122E}\u{11232}-\u{11233}\u{11235}\u{112E0}-\u{112E2}\u{11302}-\u{11303}\u{1133F}\u{11341}-\u{11344}\u{11347}-\u{11348}\u{1134B}-\u{1134D}\u{11362}-\u{11363}\u{11435}-\u{11437}\u{11440}-\u{11441}\u{11445}\u{114B1}-\u{114B2}\u{114B9}\u{114BB}-\u{114BC}\u{114BE}\u{114C1}\u{115B0}-\u{115B1}\u{115B8}-\u{115BB}\u{115BE}\u{11630}-\u{11632}\u{1163B}-\u{1163C}\u{1163E}\u{116AC}\u{116AE}-\u{116AF}\u{116B6}\u{11726}\u{1182C}-\u{1182E}\u{11838}\u{11931}-\u{11935}\u{11937}-\u{11938}\u{1193D}\u{11940}\u{11942}\u{119D1}-\u{119D3}\u{119DC}-\u{119DF}\u{119E4}\u{11A39}\u{11A57}-\u{11A58}\u{11A97}\u{11C2F}\u{11C3E}\u{11CA9}\u{11CB1}\u{11CB4}\u{11D8A}-\u{11D8E}\u{11D93}-\u{11D94}\u{11D96}\u{11EF5}-\u{11EF6}\u{16F51}-\u{16F87}\u{16FF0}-\u{16FF1}\u{1D166}\u{1D16D}]$/u,tb=/^[\u1100-\u115F\uA960-\uA97C]$/u,tx=/^[\u1160-\u11A7\uD7B0-\uD7C6]$/u,tC=/^[\u11A8-\u11FF\uD7CB-\uD7FB]$/u,tB=/^[\uAC00\uAC1C\uAC38\uAC54\uAC70\uAC8C\uACA8\uACC4\uACE0\uACFC\uAD18\uAD34\uAD50\uAD6C\uAD88\uADA4\uADC0\uADDC\uADF8\uAE14\uAE30\uAE4C\uAE68\uAE84\uAEA0\uAEBC\uAED8\uAEF4\uAF10\uAF2C\uAF48\uAF64\uAF80\uAF9C\uAFB8\uAFD4\uAFF0\uB00C\uB028\uB044\uB060\uB07C\uB098\uB0B4\uB0D0\uB0EC\uB108\uB124\uB140\uB15C\uB178\uB194\uB1B0\uB1CC\uB1E8\uB204\uB220\uB23C\uB258\uB274\uB290\uB2AC\uB2C8\uB2E4\uB300\uB31C\uB338\uB354\uB370\uB38C\uB3A8\uB3C4\uB3E0\uB3FC\uB418\uB434\uB450\uB46C\uB488\uB4A4\uB4C0\uB4DC\uB4F8\uB514\uB530\uB54C\uB568\uB584\uB5A0\uB5BC\uB5D8\uB5F4\uB610\uB62C\uB648\uB664\uB680\uB69C\uB6B8\uB6D4\uB6F0\uB70C\uB728\uB744\uB760\uB77C\uB798\uB7B4\uB7D0\uB7EC\uB808\uB824\uB840\uB85C\uB878\uB894\uB8B0\uB8CC\uB8E8\uB904\uB920\uB93C\uB958\uB974\uB990\uB9AC\uB9C8\uB9E4\uBA00\uBA1C\uBA38\uBA54\uBA70\uBA8C\uBAA8\uBAC4\uBAE0\uBAFC\uBB18\uBB34\uBB50\uBB6C\uBB88\uBBA4\uBBC0\uBBDC\uBBF8\uBC14\uBC30\uBC4C\uBC68\uBC84\uBCA0\uBCBC\uBCD8\uBCF4\uBD10\uBD2C\uBD48\uBD64\uBD80\uBD9C\uBDB8\uBDD4\uBDF0\uBE0C\uBE28\uBE44\uBE60\uBE7C\uBE98\uBEB4\uBED0\uBEEC\uBF08\uBF24\uBF40\uBF5C\uBF78\uBF94\uBFB0\uBFCC\uBFE8\uC004\uC020\uC03C\uC058\uC074\uC090\uC0AC\uC0C8\uC0E4\uC100\uC11C\uC138\uC154\uC170\uC18C\uC1A8\uC1C4\uC1E0\uC1FC\uC218\uC234\uC250\uC26C\uC288\uC2A4\uC2C0\uC2DC\uC2F8\uC314\uC330\uC34C\uC368\uC384\uC3A0\uC3BC\uC3D8\uC3F4\uC410\uC42C\uC448\uC464\uC480\uC49C\uC4B8\uC4D4\uC4F0\uC50C\uC528\uC544\uC560\uC57C\uC598\uC5B4\uC5D0\uC5EC\uC608\uC624\uC640\u
5C65C\uC678\uC694\uC6B0\uC6CC\uC6E8\uC704\uC720\uC73C\uC758\uC774\uC790\uC7AC\uC7C8\uC7E4\uC800\uC81C\uC838\uC854\uC870\uC88C\uC8A8\uC8C4\uC8E0\uC8FC\uC918\uC934\uC950\uC96C\uC988\uC9A4\uC9C0\uC9DC\uC9F8\uCA14\uCA30\uCA4C\uCA68\uCA84\uCAA0\uCABC\uCAD8\uCAF4\uCB10\uCB2C\uCB48\uCB64\uCB80\uCB9C\uCBB8\uCBD4\uCBF0\uCC0C\uCC28\uCC44\uCC60\uCC7C\uCC98\uCCB4\uCCD0\uCCEC\uCD08\uCD24\uCD40\uCD5C\uCD78\uCD94\uCDB0\uCDCC\uCDE8\uCE04\uCE20\uCE3C\uCE58\uCE74\uCE90\uCEAC\uCEC8\uCEE4\uCF00\uCF1C\uCF38\uCF54\uCF70\uCF8C\uCFA8\uCFC4\uCFE0\uCFFC\uD018\uD034\uD050\uD06C\uD088\uD0A4\uD0C0\uD0DC\uD0F8\uD114\uD130\uD14C\uD168\uD184\uD1A0\uD1BC\uD1D8\uD1F4\uD210\uD22C\uD248\uD264\uD280\uD29C\uD2B8\uD2D4\uD2F0\uD30C\uD328\uD344\uD360\uD37C\uD398\uD3B4\uD3D0\uD3EC\uD408\uD424\uD440\uD45C\uD478\uD494\uD4B0\uD4CC\uD4E8\uD504\uD520\uD53C\uD558\uD574\uD590\uD5AC\uD5C8\uD5E4\uD600\uD61C\uD638\uD654\uD670\uD68C\uD6A8\uD6C4\uD6E0\uD6FC\uD718\uD734\uD750\uD76C\uD788]$/u,tE=/^[\uAC01-\uAC1B\uAC1D-\uAC37\uAC39-\uAC53\uAC55-\uAC6F\uAC71-\uAC8B\uAC8D-\uACA7\uACA9-\uACC3\uACC5-\uACDF\uACE1-\uACFB\uACFD-\uAD17\uAD19-\uAD33\uAD35-\uAD4F\uAD51-\uAD6B\uAD6D-\uAD87\uAD89-\uADA3\uADA5-\uADBF\uADC1-\uADDB\uADDD-\uADF7\uADF9-\uAE13\uAE15-\uAE2F\uAE31-\uAE4B\uAE4D-\uAE67\uAE69-\uAE83\uAE85-\uAE9F\uAEA1-\uAEBB\uAEBD-\uAED7\uAED9-\uAEF3\uAEF5-\uAF0F\uAF11-\uAF2B\uAF2D-\uAF47\uAF49-\uAF63\uAF65-\uAF7F\uAF81-\uAF9B\uAF9D-\uAFB7\uAFB9-\uAFD3\uAFD5-\uAFEF\uAFF1-\uB00B\uB00D-\uB027\uB029-\uB043\uB045-\uB05F\uB061-\uB07B\uB07D-\uB097\uB099-\uB0B3\uB0B5-\uB0CF\uB0D1-\uB0EB\uB0ED-\uB107\uB109-\uB123\uB125-\uB13F\uB141-\uB15B\uB15D-\uB177\uB179-\uB193\uB195-\uB1AF\uB1B1-\uB1CB\uB1CD-\uB1E7\uB1E9-\uB203\uB205-\uB21F\uB221-\uB23B\uB23D-\uB257\uB259-\uB273\uB275-\uB28F\uB291-\uB2AB\uB2AD-\uB2C7\uB2C9-\uB2E3\uB2E5-\uB2FF\uB301-\uB31B\uB31D-\uB337\uB339-\uB353\uB355-\uB36F\uB371-\uB38B\uB38D-\uB3A7\uB3A9-\uB3C3\uB3C5-\uB3DF\uB3E1-\uB3FB\uB3FD-\uB417\uB419-\uB433\uB435-\uB44F\uB451-\uB46B\uB46D-\uB487\uB489-\uB4A3\uB4A5-\uB4BF\uB4C1-\uB4DB\uB4DD-\uB4F7\uB4F9-\uB513\uB515-\uB52F\uB531-\uB54B\uB54D-\uB567\uB569-\uB583\uB585-\uB59F\uB5A1-\uB5BB\uB5BD-\uB5D7\uB5D9-\uB5F3\uB5F5-\uB60F\uB611-\uB62B\uB62D-\uB647\uB649-\uB663\uB665-\uB67F\uB681-\uB69B\uB69D-\uB6B7\uB6B9-\uB6D3\uB6D5-\uB6EF\uB6F1-\uB70B\uB70D-\uB727\uB729-\uB743\uB745-\uB75F\uB761-\uB77B\uB77D-\uB797\uB799-\uB7B3\uB7B5-\uB7CF\uB7D1-\uB7EB\uB7ED-\uB807\uB809-\uB823\uB825-\uB83F\uB841-\uB85B\uB85D-\uB877\uB879-\uB893\uB895-\uB8AF\uB8B1-\uB8CB\uB8CD-\uB8E7\uB8E9-\uB903\uB905-\uB91F\uB921-\uB93B\uB93D-\uB957\uB959-\uB973\uB975-\uB98F\uB991-\uB9AB\uB9AD-\uB9C7\uB9C9-\uB9E3\uB9E5-\uB9FF\uBA01-\uBA1B\uBA1D-\uBA37\uBA39-\uBA53\uBA55-\uBA6F\uBA71-\uBA8B\uBA8D-\uBAA7\uBAA9-\uBAC3\uBAC5-\uBADF\uBAE1-\uBAFB\uBAFD-\uBB17\uBB19-\uBB33\uBB35-\uBB4F\uBB51-\uBB6B\uBB6D-\uBB87\uBB89-\uBBA3\uBBA5-\uBBBF\uBBC1-\uBBDB\uBBDD-\uBBF7\uBBF9-\uBC13\uBC15-\uBC2F\uBC31-\uBC4B\uBC4D-\uBC67\uBC69-\uBC83\uBC85-\uBC9F\uBCA1-\uBCBB\uBCBD-\uBCD7\uBCD9-\uBCF3\uBCF5-\uBD0F\uBD11-\uBD2B\uBD2D-\uBD47\uBD49-\uBD63\uBD65-\uBD7F\uBD81-\uBD9B\uBD9D-\uBDB7\uBDB9-\uBDD3\uBDD5-\uBDEF\uBDF1-\uBE0B\uBE0D-\uBE27\uBE29-\uBE43\uBE45-\uBE5F\uBE61-\uBE7B\uBE7D-\uBE97\uBE99-\uBEB3\uBEB5-\uBECF\uBED1-\uBEEB\uBEED-\uBF07\uBF09-\uBF23\uBF25-\uBF3F\uBF41-\uBF5B\uBF5D-\uBF77\uBF79-\uBF93\uBF95-\uBFAF\uBFB1-\uBFCB\uBFCD-\uBFE7\uBFE9-\uC003\uC005-\uC01F\uC021-\uC03B\uC03D-\uC057\uC059-\uC073\uC075-\uC08F\uC091-\uC0AB\uC0AD-\uC0C7\uC0C9-\uC0E3\uC0E5-\uC0FF\uC101-\uC11B\uC11D-\uC137\uC139-\uC153\uC155-\uC16F\uC171-\uC18B\uC18D-\uC1A7\uC1A9-\uC1C3\uC1C5-\uC1DF\uC1E1-\uC1FB\uC1FD-\uC217\uC219-\uC233\uC235-\uC24F\uC251-\uC26B\uC26D-\uC287\uC289-\uC2A3\uC2A5-\uC2BF\uC2C1-\uC2DB\uC2DD-\uC2F7\uC2F9-\uC313\uC315-\uC32F\uC331-\uC34B\uC34D-\uC367\uC369-\uC383\uC385-\uC39F\uC3A1-\uC3BB\uC3BD-\uC3D7\uC3D9-\u
5C3F3\uC3F5-\uC40F\uC411-\uC42B\uC42D-\uC447\uC449-\uC463\uC465-\uC47F\uC481-\uC49B\uC49D-\uC4B7\uC4B9-\uC4D3\uC4D5-\uC4EF\uC4F1-\uC50B\uC50D-\uC527\uC529-\uC543\uC545-\uC55F\uC561-\uC57B\uC57D-\uC597\uC599-\uC5B3\uC5B5-\uC5CF\uC5D1-\uC5EB\uC5ED-\uC607\uC609-\uC623\uC625-\uC63F\uC641-\uC65B\uC65D-\uC677\uC679-\uC693\uC695-\uC6AF\uC6B1-\uC6CB\uC6CD-\uC6E7\uC6E9-\uC703\uC705-\uC71F\uC721-\uC73B\uC73D-\uC757\uC759-\uC773\uC775-\uC78F\uC791-\uC7AB\uC7AD-\uC7C7\uC7C9-\uC7E3\uC7E5-\uC7FF\uC801-\uC81B\uC81D-\uC837\uC839-\uC853\uC855-\uC86F\uC871-\uC88B\uC88D-\uC8A7\uC8A9-\uC8C3\uC8C5-\uC8DF\uC8E1-\uC8FB\uC8FD-\uC917\uC919-\uC933\uC935-\uC94F\uC951-\uC96B\uC96D-\uC987\uC989-\uC9A3\uC9A5-\uC9BF\uC9C1-\uC9DB\uC9DD-\uC9F7\uC9F9-\uCA13\uCA15-\uCA2F\uCA31-\uCA4B\uCA4D-\uCA67\uCA69-\uCA83\uCA85-\uCA9F\uCAA1-\uCABB\uCABD-\uCAD7\uCAD9-\uCAF3\uCAF5-\uCB0F\uCB11-\uCB2B\uCB2D-\uCB47\uCB49-\uCB63\uCB65-\uCB7F\uCB81-\uCB9B\uCB9D-\uCBB7\uCBB9-\uCBD3\uCBD5-\uCBEF\uCBF1-\uCC0B\uCC0D-\uCC27\uCC29-\uCC43\uCC45-\uCC5F\uCC61-\uCC7B\uCC7D-\uCC97\uCC99-\uCCB3\uCCB5-\uCCCF\uCCD1-\uCCEB\uCCED-\uCD07\uCD09-\uCD23\uCD25-\uCD3F\uCD41-\uCD5B\uCD5D-\uCD77\uCD79-\uCD93\uCD95-\uCDAF\uCDB1-\uCDCB\uCDCD-\uCDE7\uCDE9-\uCE03\uCE05-\uCE1F\uCE21-\uCE3B\uCE3D-\uCE57\uCE59-\uCE73\uCE75-\uCE8F\uCE91-\uCEAB\uCEAD-\uCEC7\uCEC9-\uCEE3\uCEE5-\uCEFF\uCF01-\uCF1B\uCF1D-\uCF37\uCF39-\uCF53\uCF55-\uCF6F\uCF71-\uCF8B\uCF8D-\uCFA7\uCFA9-\uCFC3\uCFC5-\uCFDF\uCFE1-\uCFFB\uCFFD-\uD017\uD019-\uD033\uD035-\uD04F\uD051-\uD06B\uD06D-\uD087\uD089-\uD0A3\uD0A5-\uD0BF\uD0C1-\uD0DB\uD0DD-\uD0F7\uD0F9-\uD113\uD115-\uD12F\uD131-\uD14B\uD14D-\uD167\uD169-\uD183\uD185-\uD19F\uD1A1-\uD1BB\uD1BD-\uD1D7\uD1D9-\uD1F3\uD1F5-\uD20F\uD211-\uD22B\uD22D-\uD247\uD249-\uD263\uD265-\uD27F\uD281-\uD29B\uD29D-\uD2B7\uD2B9-\uD2D3\uD2D5-\uD2EF\uD2F1-\uD30B\uD30D-\uD327\uD329-\uD343\uD345-\uD35F\uD361-\uD37B\uD37D-\uD397\uD399-\uD3B3\uD3B5-\uD3CF\uD3D1-\uD3EB\uD3ED-\uD407\uD409-\uD423\uD425-\uD43F\uD441-\uD45B\uD45D-\uD477\uD479-\uD493\uD495-\uD4AF\uD4B1-\uD4CB\uD4CD-\uD4E7\uD4E9-\uD503\uD505-\uD51F\uD521-\uD53B\uD53D-\uD557\uD559-\uD573\uD575-\uD58F\uD591-\uD5AB\uD5AD-\uD5C7\uD5C9-\uD5E3\uD5E5-\uD5FF\uD601-\uD61B\uD61D-\uD637\uD639-\uD653\uD655-\uD66F\uD671-\uD68B\uD68D-\uD6A7\uD6A9-\uD6C3\uD6C5-\uD6DF\uD6E1-\uD6FB\uD6FD-\uD717\uD719-\uD733\uD735-\uD74F\uD751-\uD76B\uD76D-\uD787\uD789-\uD7A3]$/u,tD=RegExp("^\\p{ExtPict}$","u"),t_=(e,t)=>{let n=tm.Any;return -1!==e.search(tg)&&(n|=tm.Extend),8205===t&&(n|=tm.ZWJ),t>=127462&&t<=127487&&(n|=tm.RI),-1!==e.search(tv)&&(n|=tm.Prepend),-1!==e.search(tk)&&(n|=tm.SpacingMark),-1!==e.search(tb)&&(n|=tm.L),-1!==e.search(tx)&&(n|=tm.V),-1!==e.search(t
5C)&&(n|=tm.T),-1!==e.search(tB)&&(n|=tm.LV),-1!==e.search(tE)&&(n|=tm.LVT),-1!==e.search(tD)&&(n|=tm.ExtPict),n},tw=[[tm.L,tm.L|tm.V|tm.LV|tm.LVT],[tm.LV|tm.V,tm.V|tm.T],[tm.LVT|tm.T,tm.T],[tm.Any,tm.Extend|tm.ZWJ],[tm.Any,tm.SpacingMark],[tm.Prepend,tm.Any],[tm.ZWJ,tm.ExtPict],[tm.RI,tm.RI]],tA=RegExp("\\p{ExtPict}[\\p{Gr_Ext}\\p{EMod}]*\\u200D$","u"),tS=e=>-1!==e.search(tA),tF=RegExp("\\p{RI}+$","gu"),tP=e=>{let t=e.match(tF);return null!==t&&t[0].length/2%2==1};function tO(e,t,n){return en(t)&&!n?t:{anchor:ep(e,t),focus:ta(e,n||t)}}function*tM(e,t={}){let{at:n=e.selection,unit:r="offset",reverse:o=!1}=t;if(!n)return;let[a,i]=ei(tO(e,n)),l=o?i:a,s=!1,c="",u=0,h=0,f=0;for(let{node:t,path:n}of ey(e,{from:a.path,to:i.path,reverse:o})){if((0,p.xN)({schema:e.schema},t)){if(e.isInline(t))continue;{let t=ti(n,i.path)?i:ta(e,n),r=ti(n,a.path)?a:ep(e,n);for(let{node:n,path:o}of(c="",ey(e,{from:r.path,to:t.path,match:t=>(0,d.bl)({schema:e.schema},t)}))){if(!(0,d.bl)({schema:e.schema},n))continue;let a=n.text;ex(o,t.path)&&(a=a.slice(0,t.offset)),ex(o,r.path)&&(a=a.slice(r.offset)),c+=a}s=!0}}if(T({schema:e.schema},t)||!(0,p.xN)({schema:e.schema},t)&&!(0,d.bl)({schema:e.schema},t)){yield{path:n,offset:0};continue}if((0,d.bl)({schema:e.schema},t)){let e=ex(n,l.path);for(e?(h=o?l.offset:t.text.length-l.offset,f=l.offset):(h=t.text.length,f=o?h:0),(e||s||"offset"===r)&&(yield{path:n,offset:f},s=!1);;){if(0===u){var y,m,g;if(""===c)break;y=c,m=r,g=o,u="character"===m?tl(y,g):"word"===m?((e,t=!1)=>{let n=0,r=!1;for(;e.length>0;){let o=tl(e,t),[a,i]=td(e,o,t);if(th(a,i,t))r=!0,n+=o;else if(r)break;else n+=o;e=i}return n})(y,g):"line"===m||"block"===m?y.length:1,c=td(c,u,o)[1]}if(f=o?f-u:f+u,(h-=u)<0){u=-h;break}u=0,yield{path:n,offset:f}}}}}function tT(e,t,n={}){let r=eh(e,t,{edge:"end"}),o=ta(e,[]),{distance:a=1}=n,i=0,l;for(let t of tM(e,{...n,at:{anchor:r,focus:o}})){if(i>a)break;0!==i&&(l=t),i++}return l}function tR(e,t,n={}){let r=ep(e,[]),o=eh(e,t,{edge:"start"}),{distance:a=1}=n,i=0,l;for(let t of tM(e,{...n,at:{anchor:r,focus:o},reverse:!0})){if(i>a)break;0!==i&&(l=t),i++}return l}function tz(e,t={}){let{selection:n}=e,{distance:r=1,unit:o="character",reverse:a=!1}=t,{edge:i=null}=t;if(!n)return;"start"===i&&(i=ea(n)?"focus":"anchor"),"end"===i&&(i=ea(n)?"anchor":"focus");let{anchor:l,focus:s}=n,c={distance:r,unit:o},u={};if(null==i||"anchor"===i){let t=a?tR(e,l,c):tT(e,l,c);t&&(u.anchor=t)}if(null==i||"focus"===i){let t=a?tR(e,s,c):tT(e,s,c);t&&(u.focus=t)}e.setSelection(u)}let tI=(0,y.mn)({default:[{key:"B",ctrl:!0,meta:!1,alt:!1,shift:!1}],apple:[{key:"B",ctrl:!1,meta:!0,alt:!1,shift:!1}]}),tj=(0,y.mn)({default:[{key:"ArrowLeft",shift:!1,ctrl:!1,meta:!1,alt:!1}]}),tN=(0,y.mn)({default:[{key:"ArrowRight",shift:!1,ctrl:!1,meta:!1,alt:!1}]}),t$=(0,y.mn)({default:[{key:"ArrowLeft",ctrl:!0,shift:!1,meta:!1,alt:!1}],apple:[{key:"ArrowLeft",ctrl:!0,shift:!1,meta:!1,alt:!1},{key:"ArrowLeft",alt:!0,shift:!1,ctrl:!1,meta:!1}]}),tK=(0,y.mn)({default:[{key:"ArrowRight",ctrl:!0,shift:!1,meta:!1,alt:!1}],apple:[{key:"ArrowRight",ctrl:!0,shift:!1,meta:!1,alt:!1},{key:"ArrowRight",alt:!0,shift:!1,ctrl:!1,meta:!1}]}),tL=(0,y.mn)({default:[{key:"Backspace",ctrl:!1,meta:!1,alt:!1},{key:"Backspace",shift:!0,ctrl:!1,meta:!1,alt:!1}],apple:[{key:"Backspace",ctrl:!1,meta:!1,alt:!1},{key:"Backspace",shift:!0,ctrl:!1,meta:!1,alt:!1},{key:"Backspace",ctrl:!0,shift:!1,meta:!1,alt:!1},{key:"h",ctrl:!0,shift:!1,meta:!1,alt:!1}]}),tV=(0,y.mn)({default:[{key:"Delete",ctrl:!1,meta:!1,alt:!1},{key:"Delete",shift:!0,ctrl:!1,meta:!1,alt:!1}],apple:[{key:"Delete",ctrl:!1,meta:!1,alt:!1},{key:"Delete",shift:!0,ctrl:!1,meta:!1,alt:!1},{key:"Delete",ctrl:!0,shift:!1,meta:!1,alt:!1},{key:"d",ctrl:!0,shift:!1,meta:!1,alt:!1}]}),tU=(0,y.mn)({default:[{key:"I",ctrl:!0,meta:!1,alt:!1,shift:!1}],apple:[{key:"I",ctrl:!1,meta:!0,alt:!1,shift:!1}]}),tW=(0,y.mn)({default:[{key:"Enter",shift:!0,ctrl:!1,meta:!1,alt:!1}]}),tH=(0,y.mn)({default:[{key:"Enter",shift:!1,ctrl:!1,meta:!1,alt:!1}]}),tG=(0,y.mn)({default:[{key:"Z",ctrl:!0,meta:!1,alt:!1,shift:!1}],apple:[{key:"Z",ctrl:!1,meta:!0,alt:!1,shift:!1}]}),tJ=(0,y.mn)({default:[],apple:[{key:"ArrowUp",alt:!0,shift:!1,ctrl:!1,meta:!1}]}),tZ=(0,y.mn)({default:[],apple:[{key:"ArrowDown",alt:!0,shift:!1,ctrl:!1,meta:!1}]}),tY=(0,y.mn)({default:[],apple:[{key:"Backspace",meta:!0,ctrl:!1,alt:!1},{key:"Backspace",meta:!0,shift:!0,ctrl:!1,alt:!1}]}),tq=(0,y.mn)({default:[],apple:[{key:"Delete",meta:!0,ctrl:!1,alt:!1},{key:"Delete",meta:!0,shift:!0,ctrl:!1,alt:!1},{key:"k",ctrl:!0,shift:!1,meta:!1,alt:!1}]}),tX=(0,y.mn)({default:[{key:"Backspace",ctrl:!0,meta:!1,alt:!1},{key:"Backspace",ctrl:!0,shift:!0,meta:!1,alt:!1}],apple:[{key:"Backspace",alt:!0,ctrl:!1,meta:!1},{key:"Backspace",alt:!0,shift:!0,ctrl:!1,meta:!1}]}),tQ=(0,y.mn)({default:[{key:"Delete",ctrl:!0,meta:!1,alt:!1},{key:"Delete",ctrl:!0,shift:!0,meta:!1,alt:!1}],apple:[{key:"Delete",alt:!0,ctrl:!1,meta:!1},{key:"Delete",alt:!0,shift:!0,ctrl:!1,meta:!1}]}),t0=(0,y.mn)({default:[],apple:[{key:"ArrowUp",alt:!0,shift:!0,ctrl:!1,meta:!1}]}),t1=(0,y.mn)({default:[],apple:[{key:"ArrowDown",alt:!0,shift:!0,ctrl:!1,meta:!1}]}),t2=(0,y.mn)({default:[{key:"Y",ctrl:!0,meta:!1,alt:!1,shift:!1},{key:"Z",ctrl:!0,meta:!1,alt:!1,shift:!0}],apple:[{key:"Z",ctrl:!1,meta:!0,alt:!1,shift:!0}]}),t3=(0,y.mn)({default:[],apple:[{key:"t",ctrl:!0,shift:!1,meta:!1,alt:!1}]});var t4={isBold:tI.guard,isMoveBackward:tj.guard,isMoveForward:tN.guard,isDeleteBackward:tL.guard,isDeleteForward:tV.guard,isDeleteLineBackward:tY.guard,isDeleteLineForward:tq.guard,isDeleteWordBackward:tX.guard,isDeleteWord
5Forward:tQ.guard,isExtendLineBackward:t0.guard,isExtendLineForward:t1.guard,isItalic:tU.guard,isMoveLineBackward:tJ.guard,isMoveLineForward:tZ.guard,isMoveWordBackward:t$.guard,isMoveWordForward:tK.guard,isRedo:t2.guard,isSoftBreak:tW.guard,isSplitBlock:tH.guard,isTransposeCharacter:t3.guard,isUndo:tG.guard};let t8=Symbol("placeholder"),t5=Symbol("mark-placeholder");function t7(e,t,n={}){let{affinity:r="forward"}=n,o={current:t,affinity:r,unref(){let{current:t}=o;return e.rangeRefs.delete(o),o.current=null,t}};return e.rangeRefs.add(o),o}function t9(e,t){return eC(e.anchor,t.anchor)&&eC(e.focus,t.focus)}let t6=(e,t)=>{for(let n in e){let r=e[n],o=t[n];if(Array.isArray(r)&&Array.isArray(o)){if(r.length!==o.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==o[e])return!1}else if(ee(r)&&ee(o)){if(!t6(r,o))return!1}else if(r!==o)return!1}for(let n in t)if(void 0===e[n]&&void 0!==t[n])return!1;return!0};function ne(e,t,n={}){let{loose:r=!1}=n;function o(e){let{text:t,...n}=e;return n}return t6(r?o(e):e,r?o(t):t)}let nt=eI?c.useLayoutEffect:c.useEffect,nn=(0,c.createContext)(null),nr=()=>{let e=(0,c.useContext)(nn);if(!e)throw Error("The `useSlateStatic` hook must be used inside the <Slate> component's context.");return e};function no(e,t){let n=U(e,t);if(n&&(0,d.bl)({schema:e.schema},n.node))return{node:n.node,path:n.path}}function na(e){if(0===e.length)throw Error(`Cannot get the next path of a root path [${e}], because it has no next index.`);let t=e[e.length-1];return e.slice(0,-1).concat(t+1)}function ni(e,t){let n=e.length-1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return e[n]<t[n]}function nl(e,t){if(!e)return null;if(0===e.length)return e;switch(t.type){case"insert_node":{let{path:n}=t;if(ex(n,e)||ni(n,e)||ti(n,e)){let t=[...e];return t[n.length-1]=t[n.length-1]+1,t}break}case"remove_node":{let{path:n}=t;if(ex(n,e)||ti(n,e))return null;if(ni(n,e)){let t=[...e];return t[n.length-1]=t[n.length-1]-1,t}}}return e}function ns(e,t,n={}){if(null===e)return null;let{affinity:r="forward"}=n,{path:o,offset:a}=e;switch(t.type){case"insert_node":o=nl(o,t);break;case"insert_text":ex(t.path,o)&&(t.offset<a||t.offset===a&&"forward"===r)&&(a+=t.text.length);break;case"remove_text":ex(t.path,o)&&t.offset<=a&&(a-=Math.min(a-t.offset,t.text.length));break;case"remove_node":if(ex(t.path,o)||ti(t.path,o))return null;o=nl(o,t);break;default:return e}return{path:o,offset:a}}function nc(e,...t){return t.reduce((e,t)=>e.slice(0,t.start)+t.text+e.slice(t.end),e)}function nu(e,t){let{start:n,end:r,text:o}=t,a=e.slice(n,r),i=function(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e.charAt(r)!==t.charAt(r))return r;return n}(a,o),l=Math.min(a.length-i,o.length-i),s=function(e,t,n){let r=Math.min(e.length,t.length,n);for(let n=0;n<r;n++)if(e.charAt(e.length-n-1)!==t.charAt(t.length-n-1))return n;return r}
5(a,o,l),c={start:n+i,end:r-s,text:o.slice(i,o.length-s)};return c.start===c.end&&0===c.text.length?null:c}function nd(e,t){let{path:n,offset:r}=t;if(!Z(e,n))return null;let o=no(e,n);if(!o)return null;let a=o.node,i=ef(e,n);if(!i)return null;for(;r>a.text.length;){var l,s;let t=tT(e,n),[o]=t?ey(e,{from:t.path,match:t=>(0,d.bl)({schema:e.schema},t)}):[];if(!o||!(0,d.bl)({schema:e.schema},o.node)||(l=o.path,s=i.path,!(l.length>s.length)||0!==er(l,s)))return null;r-=a.text.length,a=o.node,n=o.path}return{path:n,offset:r}}function nh(e,t){let n=nd(e,t.anchor);if(!n)return null;if(eB(t))return{anchor:n,focus:n};let r=nd(e,t.focus);return r?{anchor:n,focus:r}:null}function np(e,t,n){let r=e.pendingDiffs?.find(({path:e})=>ex(e,t.path));if(!r||t.offset<=r.diff.start)return ns(t,n,{affinity:"backward"});let{diff:o}=r;if(t.offset<=o.start+o.text.length){let e=ns({path:t.path,offset:o.start},n,{affinity:"backward"});return e?{path:e.path,offset:e.offset+t.offset-o.start}:null}let a=ns({path:t.path,offset:t.offset-o.text.length+o.end-o.start},n,{affinity:"backward"});return a?{path:a.path,offset:a.offset+o.text.length-o.end+o.start}:null}function nf(e,t,n){let r=np(e,t.anchor,n);if(!r)return null;if(eB(t))return{anchor:r,focus:r};let o=np(e,t.focus,n);return o?{anchor:r,focus:o}:null}let ny=(...e)=>{},nm={subtree:!0,childList:!0,characterData:!0},ng=ew?({editorActor:e,node:t,...n})=>{let r;if(!ew)return null;let o=nr(),a=(r=(0,c.useRef)(!1),(0,c.useEffect)(()=>(r.current=!0,()=>{r.current=!1}),[]),r.current),[i]=(0,c.useState)(()=>(function({editor:e,editorActor:t,scheduleOnDOMSelectionChange:n,onDOMSelectionChange:r}){let o=!1,a=null,i=null,l=null,s=0,c=!1,u=()=>{let t=e.pendingSelection;if(e.pendingSelection=null,t){let{selection:n}=e,r=nh(e,t);!r||n&&t9(r,n)||e.select(r)}},h=()=>{if(i&&(clearTimeout(i),i=null),l&&(clearTimeout(l),l=null),!g()&&!m())return void u();o||(o=!0,setTimeout(()=>o=!1)),m()&&(o="action");let a=e.selection&&t7(e,e.selection,{affinity:"forward"});e.userMarks=e.marks;let s=g(),d;for(;d=e.pendingDiffs?.[0];){let i=e.pendingInsertionMarks;void 0!==i&&(e.pendingInsertionMarks=null,e.marks=i),i&&!1===c&&(c=null,ny("insert after mark placeholder"));let l=function(e){let{path:t,diff:n}=e;return{anchor:{path:t,offset:n.start},focus:{path:t,offset:n.end}}}(d);e.selection&&t9(e.selection,l)||e.select(l),d.diff.text?t.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:d.diff.text},editor:e}):t.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:e}),e.pendingDiffs=e.pendingDiffs?.filter(({id:e})=>e!==d.id),function(e,t){let{path:n,diff:r}=t;if(!Z(e,n))return!1;let o=no(e,n);if(!o)return!1;let a=o.node;if(r.start!==a.text.length||0===r.text.length)return a.text.slice(r.start,r.start+r.text.length)===r.text;let i=na(n);if(!Z(e,i))return!1;let l=no(e,i);return!!l&&l.node.text.startsWith(r.text)}(e,d)||(s=!1,e.pendingAction=null,e.userMarks=null,o="action",e.pendingSelection=null,n.cancel(),r.cancel(),a?.unref())}let h=a?.unref();if(!h||e.pendingSelection||e.selection&&t9(h,e.selection)||e.select(h),m())return void(()=>{let t=e.pendingAction;if(e.pendingAction=null,t){if(t.at){let n=et(t.at)?nd(e,t.at):nh(e,t.at);if(!n)return;let r=tO(e,n);e.selection&&t9(e.selection,r)||e.select(n)}t.run()}})();s&&n(),n.flush(),r.flush(),u();let p=e.userMarks;e.userMarks=null,void 0!==p&&(e.marks=p,e.onChange())},p=(t=!1)=>{let n=e.domPlaceholderElement;if(n){if(g()||t){n.style.display="none";return}n.style.removeProperty("display")}},f=(t,n)=>{var r,o;let a,i,l,c,u,d=e.pendingDiffs,h=no(e,t);if(!h)return;let f=h.node,y=d.findIndex(e=>ex(e.path,t));if(y<0){nu(f.text,n)&&d.push({path:t,diff:n,id:s++}),p();return}let m=(r=f.text,o=d[y].diff,a=Math.min(o.start,n.start),i=Math.max(0,Math.min(o.start+o.text.length,n.end)-n.start),l=nc(r,o,n),c=Math.max(n.start+n.text.length,o.start+o.text.length+(o.start+o.text.length>n.start?n.text.length:0)-i),u=l.slice(a,c),nu(r,{start:a,end:Math.max(o.end,n.end-o.text.length+(o.end-o.start)),text:u}));if(!m){d.splice(y,1),p();return}d[y]={...d[y],diff:m}},y=(t,{at:o}={})=>{c=!1,e.pendingSelection=null,n.cancel(),r.cancel(),m()&&h(),e.pendingAction={at:o,run:t},l=setTimeout(h)},m=()=>!!e.pendingAction,g=()=>!!e.pendingDiffs?.length,v=t=>{e.pendingSelection=t,i&&(clearTimeout(i),i=null);let{selection:n}=e;if(!t)return;let r=!n||!ex(n.anchor.path,t.anchor.path),o=!n||!ex(n.anchor.path.slice(0,-1),t.anchor.path.slice(0,-1));(r&&c||o)&&(c=!1),(r||g())&&(i=setTimeout(h,200))},k=()=>
5{m()||(l=setTimeout(h))};return{flush:h,scheduleFlush:k,hasPendingDiffs:g,hasPendingAction:m,hasPendingChanges:()=>m()||g(),isFlushing:()=>o,handleUserSelect:v,handleCompositionEnd:t=>{a&&clearTimeout(a),a=setTimeout(()=>{e.composing=!1,h()},25)},handleCompositionStart:t=>{e.composing=!0,a&&(clearTimeout(a),a=null)},handleDOMBeforeInput:n=>{if(i&&(clearTimeout(i),i=null),e.isNodeMapDirty)return;let{inputType:r}=n,o=null,a=n.dataTransfer||n.data||void 0;!1!==c&&"insertText"!==r&&"insertCompositionText"!==r&&(c=!1);let[l]=n.getTargetRanges();l&&(o=eN.toSlateRange(e,l,{exactMatch:!1,suppressThrow:!0}));let s=eN.getWindow(e).getSelection();if(!o&&s&&(l=s,o=eN.toSlateRange(e,s,{exactMatch:!1,suppressThrow:!0})),!(o=o??e.selection))return;let u=!0;if(r.startsWith("delete")){let n=r.endsWith("Backward")?"backward":"forward",[a,i]=ei(o),l=U(e,a.path),s=l&&((0,d.bl)({schema:e.schema},l.node)||T({schema:e.schema},l.node))?l:void 0;if(!s)return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete",direction:n},editor:e}),{at:o});let c=s.node,h=s.path;if(!(0,d.bl)({schema:e.schema},c))return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete",direction:n},editor:e}),{at:o});if(eD(o)&&c.text.length===a.offset&&0===i.offset){let t=tT(e,a.path),[r]=t?ey(e,{from:t.path,match:t=>(0,d.bl)({schema:e.schema},t)}):[];r&&(0,d.bl)({schema:e.schema},r.node)&&ex(r.path,i.path)&&("backward"===n?(o={anchor:i,focus:i},a=i,c=r.node,h=r.path):(o={anchor:a,focus:a},i=a))}if(!(0,d.bl)({schema:e.schema},c))return;let p={text:"",start:a.offset,end:i.offset},m=e.pendingDiffs?.find(e=>ex(e.path,h)),g=m?[m.diff,p]:[p];if(0===nc(c.text,...g).length&&(u=!1),eD(o)){if(u&&ex(o.anchor.path,o.focus.path)){let t={path:o.anchor.path,offset:a.offset};return v(tO(e,t,t)),f(o.anchor.path,{text:"",end:i.offset,start:a.offset})}return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete",direction:n},editor:e}),{at:o})}}switch(r){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:e}),{at:o});case"deleteContent":case"deleteContentForward":{let{anchor:n}=o;if(u&&eB(o)){let t=no(e,n.path);if(t&&n.offset<t.node.text.length)return f(n.path,{text:"",start:n.offset,end:n.offset+1})}return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"character"},editor:e}),{at:o})}case"deleteContentBackward":{let{anchor:n}=o,r=eW(l)?l.isCollapsed:!!l?.collapsed;return u&&r&&eB(o)&&n.offset>0?f(n.path,{text:"",start:n.offset-1,end:n.offset}):y(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"character"},editor:e}),{at:o})}case"deleteEntireSoftLine":return y(()=>{t.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"line"},editor:e}),t.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"line"},editor:e})},{at:o});case"deleteHardLineBackward":return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"block"},editor:e}),{at:o});case"deleteSoftLineBackward":return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"line"},editor:e}),{at:o});case"deleteHardLineForward":return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"block"},editor:e}),{at:o});case"deleteSoftLineForward":return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"line"},editor:e}),{at:o});case"deleteWordBackward":return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"word"},editor:e}),{at:o});
5case"deleteWordForward":return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"word"},editor:e}),{at:o});case"insertLineBreak":return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"insert.soft break"},editor:e}),{at:o});case"insertParagraph":return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"insert.break"},editor:e}),{at:o});case"insertCompositionText":case"deleteCompositionText":case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":{if(a?.constructor.name==="DataTransfer")return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"input.*",originEvent:{dataTransfer:a}},editor:e}),{at:o});let n=a??"";if(e.pendingInsertionMarks&&(n=n.replace("\uFEFF","")),"insertText"===r&&/.*\n.*\n$/.test(n)&&(n=n.slice(0,-1)),n.includes(` 6`))return y(()=>{let r=n.split(` 7`);r.forEach((n,o)=>{n&&t.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:n},editor:e}),o!==r.length-1&&t.send({type:"behavior event",behaviorEvent:{type:"insert.soft break"},editor:e})})},{at:o});if(ex(o.anchor.path,o.focus.path)){let[t,a]=ei(o),i={start:t.offset,end:a.offset,text:n};if(n&&c&&"insertCompositionText"===r){let e=c.start+c.text.search(/\S|$/);i.start+i.text.search(/\S|$/)===e+1&&i.end===c.start+c.text.length?(i.start-=1,c=null,k()):c=!1}else c="insertText"===r&&(null===c?i:!!(c&&eB(o))&&c.end+c.text.length===t.offset&&{...c,text:c.text+n});if(u){let r=e.selection;if(f(t.path,i),r){let r={path:t.path,offset:t.offset+n.length};y(()=>{e.select({anchor:r,focus:r})},{at:r})}return}}return y(()=>t.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:n},editor:e}),{at:o})}}},handleKeyDown:e=>{g()||(p(!0),setTimeout(p))},handleDomMutations:t=>{g()||m()||t.some(n=>eq(e,n,t))&&e.forceRender?.()},handleInput:()=>{(m()||!g())&&h()}}})({editor:o,editorActor:e,...n}));return function(e,t,n){let[r]=(0,c.useState)(()=>new MutationObserver(t));nt(()=>{r.takeRecords()}),(0,c.useEffect)(()=>{if(!e.current)throw Error("Failed to attach MutationObserver, `node` is undefined");return r.observe(e.current,n),()=>r.disconnect()},[r,e,n])}(t,i.handleDomMutations,nm),o.scheduleFlush=i.scheduleFlush,a&&i.flush(),i}:()=>null;function nv(e,t){return -1===eo(e,t)}function nk(e,t){let{anchor:n,focus:r,...o}=e,[a,i]=ei(e),[l,s]=ei(t),c=nv(a,l)?l:a,u=nv(i,s)?i:s;return nv(u,c)?null:{anchor:c,focus:u,...o}}let nb=(e,t)=>{let{anchor:n,focus:r,...o}=e,{anchor:a,focus:i,...l}=t;return e[t8]===t[t8]&&Object.keys(o).length===Object.keys(l).length&&Object.keys(o).every(e=>l.hasOwnProperty(e)&&o[e]===l[e])},nx=(e,t)=>{if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],o=t[n];if(!t9(r,o)||!nb(r,o))return!1}return!0},nC=(e,t)=>{if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],o=t[n];if(r.anchor.offset!==o.anchor.offset||r.focus.offset!==o.focus.offset||!nb(r,o))return!1}return!0};function nB(e,t){let n,[,r]=(0,c.useReducer)(e=>e+1,0),o=(0,c.useRef)(void 0),a=(0,c.useRef)(()=>null),i=(0,c.useRef)(null);try{if(e!==a.current||o.current){let r=e();n=t(i.current,r)?i.current:r}else n=i.current}catch(e){throw o.current&&e instanceof Error&&(e.message+=` 8The error may be correlated with this previous error: 9${o.current.stack} 10 11`),e}return a.current=e,i.current=n,o.current=void 0,[n,(0,c.useCallback)(()=>{try{let e=a.current();if(t(i.current,e))return;i.current=e}catch(e){e instanceof Error?o.current=e:o.current=Error(String(e))}r()},[])]}let nE=(0,c.createContext)({}),nD=(e,t,n)=>{let r=nr(),{decorate:o,addEventListener:a}=(0,c.useContext)(nE),[i,l]=nB(()=>o([e,t]),(0,d.bl)({schema:r.schema},e)?nC:nx);return nt(()=>{let e=a(l);return l(),e},[a,l]),(0,c.useMemo)(()=>[...i,...n],[i,n])},n_="Ö-ß¿ï¬-﷽ﹰ-ﻼ",nw="A-Za-z\xc0-\xd6\xd8-\xf6\xf8-ʸÌ-Öà -á¿¿ââ°-ï¬ï¸-﹯﻽-ï¿¿",nA=RegExp(`^[^${nw}]*[${n_}]`),nS=RegExp(`^[^${n_}]*[${nw}]`);function nF(e){let t=String(e||"");return nA.test(t)?"rtl":nS.test(t)?"ltr":"neutral"}let nP=e=>(0,i.jsx)(nM,{...e}),nO=c.memo(e=>{let{dataPath:t,decorations:n,element:r,renderElement:o=nP,renderPlaceholder:a,renderLeaf:i,renderText:l}=e,s=nr(),c=s.isInline(r),u=nq({parentDataPath:t,decorations:nD(r,e.indexedPath,n),node:r,indexedPath:e.indexedPath,renderElement:o,renderPlaceholder:a,renderLeaf:i,renderText:l}),d={"data-slate-node":"element","data-pt-path":t};if(c&&(d["data-slate-inline"]=!0),!c&&(0,p.xN)({schema:s.schema},r)){let t=tn(s,e.indexedPath),n=void 0!==t?nF(t):void 0;"rtl"===n&&(d.dir=n)}return o({attributes:d,children:u,element:r,indexedPath:e.indexedPath})},(e,t)=>e.dataPath===t.dataPath&&e.element===t.element&&ex(e.indexedPath,t.indexedPath)&&e.renderElement===t.renderElement&&e.renderText===t.renderText&&e.renderLeaf===t.renderLeaf&&e.renderPlaceholder===t.renderPlaceholder&&nx(e.decorations,t.decorations)),nM=e=>{let{attributes:t,children:n,element:r}=e,o=nr().isInline(r)?"span":"div";return(0,i.jsx)(o,{...t,style:{position:"relative"},children:n})},nT=(0,c.createContext)(!1),nR=e=>{let{attributes:t,children:n}=e;return(0,i.jsx)("div",{...t,style:{position:"relative"},children:n})},nz=c.memo(e=>{let{dataPath:t,objectNode:n,isInline:r,indexedPath:o,renderElement:a=nR}
11=e,l=(0,c.useContext)(nT),s={"data-slate-node":"element","data-slate-void":!0,"data-pt-path":t};return r&&(s["data-slate-inline"]=!0,l||(s.contentEditable=!1)),a({attributes:s,children:(0,i.jsx)(r?"span":"div",{"data-slate-spacer":!0,style:{height:"0",color:"transparent",outline:"none",position:"absolute"},children:(0,i.jsx)("span",{"data-slate-node":"text",children:(0,i.jsx)("span",{"data-slate-leaf":!0,children:(0,i.jsx)("span",{"data-slate-zero-width":"z","data-slate-length":0,children:ew?null:"\uFEFF"})})})}),element:n,indexedPath:o})},(e,t)=>e.dataPath===t.dataPath&&e.objectNode===t.objectNode&&ex(e.indexedPath,t.indexedPath)&&e.renderElement===t.renderElement&&e.isInline===t.isInline&&nx(e.decorations,t.decorations));function nI(e){if(0===e.length)throw Error(`Cannot get the parent path of the root path [${e}].`);return e.slice(0,-1)}let nj=e=>{let{isLast:t,leaf:n,parent:r,indexedPath:o,text:a}=e,l=nr(),s=nI(o),c=!!n[t5];return""===n.text&&(0,d.zS)({schema:l.schema},r)&&r.children[r.children.length-1]===a&&!l.isInline(r)&&""===function(e,t){let n=ep(e,t),r=ta(e,t),o="";for(let{node:t,path:a}of ey(e,{from:n.path,to:r.path,match:t=>(0,d.bl)({schema:e.schema},t)})){if(!(0,d.bl)({schema:e.schema},t))continue;let i=t.text;ex(a,r.path)&&(i=i.slice(0,r.offset)),ex(a,n.path)&&(i=i.slice(n.offset)),o+=i}return o}(l,s)?(0,i.jsx)(nK,{isLineBreak:!0,isMarkPlaceholder:c}):""===n.text?(0,i.jsx)(nK,{isMarkPlaceholder:c}):t&&n.text.slice(-1)===` 12`?(0,i.jsx)(nN,{isTrailing:!0,text:n.text}):(0,i.jsx)(nN,{text:n.text})},nN=e=>{let{text:t,isTrailing:n=!1}=e,r=(0,c.useRef)(null),o=()=>`${t??""}${n?` 13`:""}`,[a]=(0,c.useState)(o);return nt(()=>{let e=o();r.current&&r.current.textContent!==e&&(r.current.textContent=e)}),(0,i.jsx)(n$,{ref:r,children:a})},n$=(0,c.memo)((0,c.forwardRef)((e,t)=>(0,i.jsx)("span",{"data-slate-string":!0,ref:t,children:e.children}))),nK=e=>{let{length:t=0,isLineBreak:n=!1,isMarkPlaceholder:r=!1}=e,o={"data-slate-zero-width":n?"n":"z","data-slate-length":t};return r&&(o["data-slate-mark-placeholder"]=!0),(0,i.jsxs)("span",{...o,children:[ew&&n?null:"\uFEFF",n?(0,i.jsx)("br",{}):null]})},nL=300*!!ew;function nV(e){e.current&&(clearTimeout(e.current),e.current=null)}let nU=e=>(0,i.jsx)(nH,{...e}),nW=c.memo(e=>{let{leaf:t,isLast:n,text:r,indexedPath:o,parent:a,renderPlaceholder:l,renderLeaf:s=nU,leafPosition:u}=e,d=nr(),h=(0,c.useRef)(null),p=(0,c.useRef)(null),[f,y]=(0,c.useState)(!1),g=(0,c.useRef)(null),v=(0,c.useCallback)(e=>{var n;(n=null==e,h.current&&(h.current.disconnect(),n&&(h.current=null)),null==e)?(d.domPlaceholderElement=null,t.onPlaceholderResize?.(null)):(d.domPlaceholderElement=e,h.current||(h.current=new(window.ResizeObserver||m.tb)(()=>{t.onPlaceholderResize?.(e)})),h.current.observe(e),p.current=e)},[p,t,d]),k=(0,i.jsx)(nj,{isLast:n,leaf:t,parent:a,indexedPath:o,text:r}),b=!!t[t8];if((0,c.useEffect)(()=>(b?g.current||(g.current=setTimeout(()=>{y(!0),g.current=null},nL)):(nV(g),y(!1)),()=>nV(g)),[b,y]),b&&f){let e={children:t.placeholder,attributes:{"data-slate-placeholder":!0,style:{position:"absolute",top:0,pointerEvents:"none",width:"100%",maxWidth:"100%",display:"block",opacity:"0.333",userSelect:"none",textDecoration:"none",WebkitUserModify:eS?"inherit":void 0},contentEditable:!1,ref:v}};k=(0,i.jsxs)(c.Fragment,{children:[k,l(e)]})}return s({attributes:{"data-slate-leaf":!0},children:k,leaf:t,text:r,leafPosition:u})},(e,t)=>t.parent===e.parent&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&ne(t.leaf,e.leaf)&&t.leaf[t8]===e.leaf[t8]),nH=e=>{let{attributes:t,children:n}=e;return(0,i.jsx)("span",{...t,children:n})},nG=e=>(0,i.jsx)(nZ,{...e}),nJ=c.memo(e=>{let{dataPath:t,decorations:n,isLast:r,parent:o,indexedPath:a,renderPlaceholder:l,renderLeaf:s,renderText:c=nG,text:u}=e,d=nD(u,a,n),h=function(e,t){let n=[{leaf:{...e}}];for(let e of t){let{anchor:t,focus:r,merge:o,...a}=e,[i,l]=ei(e),s=[],c=0,u=i.offset,d=l.offset,h=o??Object.assign;for(let{leaf:e}of n){let{length:t}=e.text,n=c;if(c+=t,u<=n&&c<=d){h(e,a),s.push({leaf:e});continue}if(u!==d&&(u===c||d===n)||u>c||d<n||d===n&&0!==n){s.push({leaf:e});continue}let r=e,o,i;if(d<c){let e=d-n;i={leaf:{...r,text:r.text.slice(e)}},r={...r,text:r.text.slice(0,e)}}if(u>n){let e=u-n;o={leaf:{...r,text:r.text.slice(0,e)}},r={...r,text:r.text.slice(e)}}h(r,a),o&&s.push(o),s.push({leaf:r}),i&&s.push(i)}n=s}if(n.length>1){let e=0;for(let[t,r]of n.entries()){let o=e,a=o+r.leaf.text.length,i={start:o,end:a};0===t&&(i.isFirst=!0),t===n.length-1&&(i.isLast=!0),r.position=i,e=a}}return n}(u,d),p=[];for(let e=0;e<h.length;e++){let{leaf:t,position:n}=h[e];p.push((0,i.jsx)(nW,{isLast:r&&e===h.length-1,renderPlaceholder:l,leaf:t,leafPosition:n,text:u,indexedPath:a,parent:o,renderLeaf:s},`${u._key}-${e}`))}return c({text:u,children:p,attributes:{"data-slate-node":"text","data-pt-path":t}})},(e,t)=>
13t.parent===e.parent&&t.isLast===e.isLast&&ex(t.indexedPath,e.indexedPath)&&t.renderText===e.renderText&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&nC(t.decorations,e.decorations)),nZ=e=>{let{attributes:t,children:n}=e;return(0,i.jsx)("span",{...t,children:n})},nY=(0,c.createContext)(null),nq=e=>{let{parentDataPath:t,decorations:n,node:r,indexedPath:o,renderElement:a,renderPlaceholder:l,renderText:s,renderLeaf:u}=e,h=nr();h.isNodeMapDirty=!1;let f=ed(r),y=nX(h,r,o,n),m=ed(r)||(0,d.zS)({schema:h.schema},r)?r.children:[],g=(0,c.useCallback)((e,n)=>{let r=""===t?`[_key=="${e._key}"]`:`${t}.children[_key=="${e._key}"]`;return(0,i.jsx)(nY.Provider,{value:e,children:(0,i.jsx)(nO,{dataPath:r,decorations:y[n]??[],element:e,indexedPath:o.concat(n),renderElement:a,renderPlaceholder:l,renderLeaf:u,renderText:s},e._key)},`provider-${e._key}`)},[t,y,o,a,l,u,s]),v=(0,d.zS)({schema:h.schema},r)?r:void 0;return m.map((e,n)=>{if((0,d.zS)({schema:h.schema},e))return g(e,n);if((0,p.xN)({schema:h.schema},e))return null;if(T({schema:h.schema},e)){let r;return r=""===t?`[_key=="${e._key}"]`:`${t}.children[_key=="${e._key}"]`,(0,i.jsx)(nz,{dataPath:r,decorations:y[n]??[],isInline:!f,objectNode:e,indexedPath:o.concat(n),renderElement:a},e._key)}if((0,d.bl)({schema:h.schema},e)){if(!v)throw Error("Cannot render text component without a text block parent");let r=""!==t?`${t}.children[_key=="${e._key}"]`:"";return(0,i.jsx)(nJ,{dataPath:r,decorations:y[n]??[],isLast:n===m.length-1,parent:v,indexedPath:o.concat(n),renderPlaceholder:l,renderLeaf:u,renderText:s,text:e},e._key)}if((0,p.JS)({schema:h.schema},e))return null;throw Error("Unexpected node type")})},nX=(e,t,n,r)=>{let o=((e,t,n,r)=>{let o=ed(t)||(0,d.zS)({schema:e.schema},t)?t.children:[],a=Array.from(o,()=>[]);if(0===r.length)return a;let i=n.length,l=tO(e,n),s=Array(o.length),c=t=>{let r=s[t];if(r)return r;let o=tO(e,[...n,t]);return s[t]=o,o};for(let e of r){let t=nk(l,e);if(!t)continue;let[n,r]=ei(t),o=n.path[i],s=r.path[i];for(let t=o;t<=s;t++){let n=a[t];if(!n)continue;let r=nk(c(t),e);r&&n.push({...e,...r})}}return a})(e,t,n,r),a=(0,c.useRef)(o).current;a.length=o.length;for(let e=0;e<o.length;e++){let t=o[e];nx(a[e]??null,t)||(a[e]=t)}return a},nQ=(0,c.createContext)(!1),n0=(0,c.createContext)({}),n1=()=>{let{addEventListener:e}=(0,c.useContext)(n0),[,t]=(0,c.useReducer)(e=>e+1,0);if(!e)throw Error("The `useSlate` hook must be used inside the <Slate> component's context.");return nt(()=>e(t),[e]),nr()},n2={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0};class n3 extends c.Component{static contextType=nn;context=null;manager=null;mutationObserver=null;observe(){let{node:e}=this.props;if(!e.current)throw Error("Failed to attach MutationObserver, `node` is undefined");this.mutationObserver?.observe(e.current,n2)}componentDidMount(){let e,t,{receivedUserInput:n}=this.props,r=this.context;this.manager=(e=[],{registerMutations:t=>{if(!n.current)return;let o=t.filter(e=>eq(r,e,t));e.push(...o)},restoreDOM:function(){e.length>0&&(e.reverse().forEach(e=>{"characterData"!==e.type&&(e.removedNodes.forEach(t=>{e.target.insertBefore(t,e.nextSibling)}),e.addedNodes.forEach(t=>{e.target.removeChild(t)}))}),t())},clear:t=()=>{e=[]}}),this.mutationObserver=new MutationObserver(this.manager.registerMutations),this.observe()}getSnapshotBeforeUpdate(){let e=this.mutationObserver?.takeRecords();return e?.length&&this.manager?.registerMutations(e),this.mutationObserver?.disconnect(),this.manager?.restoreDOM(),null}componentDidUpdate(){this.manager?.clear(),this.observe()}componentWillUnmount(){this.mutationObserver?.disconnect()}render(){return this.props.children}}let n4=ew?n3:({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),n8=e=>(0,i.jsx)(c.Fragment,{children:nq(e)}),n5=(0,c.forwardRef)((e,t)=>{let n,r,o,a,l,s,u,h,f=(0,c.useCallback)(e=>(0,i.jsx)(n7,{...e}),[]),{autoFocus:y,decorate:m=n9,editorActor:g,onDOMBeforeInput:v,placeholder:k,readOnly:b=!1,renderElement:x,renderLeaf:C,renderText:B,renderPlaceholder:E=f,scrollSelectionIntoView:D=n6,style:_={},as:w="div",disableDefaultStyles:A=!1,...S}=e,F=n1(),[P,O]=(0,c.useState)(!1),M=(0,c.useRef)(null),R=(0,c.useRef)([]),[I,j]=(0,c.useState)(),N=(0,c.useRef)(!1),{onUserInput:$,receivedUserInput:K}=(n=nr(),r=(0,c.useRef)(!1),o=(0,c.useRef)(0),a=(0,c.useCallback)(()=>
13{if(r.current)return;r.current=!0;let e=eN.getWindow(n);e.cancelAnimationFrame(o.current),o.current=e.requestAnimationFrame(()=>{r.current=!1})},[n]),(0,c.useEffect)(()=>()=>cancelAnimationFrame(o.current),[]),{receivedUserInput:r,onUserInput:a}),[,L]=(0,c.useReducer)(e=>e+1,0);F.forceRender=L,F.readOnly=b;let V=(0,c.useMemo)(()=>({isUpdatingSelection:!1,latestElement:null,hasMarkPlaceholder:!1}),[]);(0,c.useEffect)(()=>{M.current&&y&&M.current.focus()},[y]);let W=(0,c.useRef)(void 0),H=(0,c.useMemo)(()=>{var e;let t,n,r,o,a;return e=()=>{if(F.isNodeMapDirty)return void H();let e=z(F,[]);if(!e)return;let t=e.getRootNode();if(!N.current&&eS&&t instanceof ShadowRoot){N.current=!0,(()=>{let e=document.activeElement;for(;e?.shadowRoot&&e.shadowRoot?.activeElement;)e=e?.shadowRoot?.activeElement;return e})()?document.execCommand("indent"):to(F),N.current=!1;return}let n=W.current;if((ew||!eN.isComposing(F))&&(!V.isUpdatingSelection||n?.isFlushing())){let e=eN.findDocumentOrShadowRoot(F),{activeElement:t}=e,r=z(F,[]);if(!r)return;let o=eY(e);if(t===r?(V.latestElement=t,F.focused=!0):F.focused=!1,!o)return to(F);let{anchorNode:a,focusNode:i}=o,l=eN.hasEditableTarget(F,a)||eN.isTargetInsideNonReadonlyVoid(F,a),s=eN.hasTarget(F,i);if(l&&s){let e=eN.toSlateRange(F,o,{exactMatch:!1,suppressThrow:!0});e&&(eN.isComposing(F)||n?.hasPendingChanges()||n?.isFlushing()?n?.handleUserSelect(e):F.select(e))}!b||l&&s||to(F)}},o=()=>{let t=n;n=void 0,r=Date.now(),t&&e(...t)},(a=(...e)=>{let a=Date.now();if(n=e,void 0===r)return void o();let i=a-r;i>=100?(void 0!==t&&(clearTimeout(t),t=void 0),o()):void 0===t&&(t=setTimeout(()=>{t=void 0,n&&o()},100-i))}).cancel=()=>{void 0!==t&&(clearTimeout(t),t=void 0),n=void 0,r=void 0},a.flush=()=>{void 0!==t&&(clearTimeout(t),t=void 0),n&&o()},a},[F,b,V]),J=(0,c.useMemo)(()=>{let e,t,n;return(n=(...n)=>{t=n,void 0!==e&&clearTimeout(e),e=setTimeout(()=>{e=void 0;let n=t;t=void 0,n&&H(...n)},0)}).cancel=()=>{void 0!==e&&(clearTimeout(e),e=void 0),t=void 0},n.flush=()=>
13{if(void 0!==e){clearTimeout(e),e=void 0;let n=t;t=void 0,n&&H(...n)}},n},[H]);W.current=ng({editorActor:g,node:M,onDOMSelectionChange:H,scheduleOnDOMSelectionChange:J}),nt(()=>{let e=null;M.current&&(e=eK(M.current))&&(F.domWindow=e,F.domElement=M.current);let{selection:t}=F,n=eY(eN.findDocumentOrShadowRoot(F));if(!n||!eN.isFocused(F)||W.current?.hasPendingAction())return;let r=e=>{let r="None"!==n.type;if(!t&&!r)return;let o=n.focusNode,a=null;if(eA&&n.rangeCount>1){let e=n.getRangeAt(0),t=n.getRangeAt(n.rangeCount-1);a=e.startContainer===o?t.endContainer:e.startContainer}else a=n.anchorNode;let i=F.domElement,l=!1;if(e1(i,a)&&e1(i,o)&&(l=!0),r&&l&&t&&!e){let e=eN.toSlateRange(F,n,{exactMatch:!0,suppressThrow:!0});if(e&&t9(e,t)&&(!V.hasMarkPlaceholder||a?.parentElement?.hasAttribute("data-slate-mark-placeholder")))return}if(t&&!eN.hasRange(F,t)){F.selection=eN.toSlateRange(F,n,{exactMatch:!1,suppressThrow:!0});return}V.isUpdatingSelection=!0;let s=null;try{s=t&&eN.toDOMRange(F,t)}catch{}return s?(eN.isComposing(F)&&!ew?n.collapseToEnd():ea(t)?n.setBaseAndExtent(s.endContainer,s.endOffset,s.startContainer,s.startOffset):n.setBaseAndExtent(s.startContainer,s.startOffset,s.endContainer,s.endOffset),D(F,s)):n.removeAllRanges(),s};n.rangeCount<=1&&r();let o=W.current?.isFlushing()==="action";if(!ew||!o)return void setTimeout(()=>{V.isUpdatingSelection=!1});let a=null,i=requestAnimationFrame(()=>{if(o){let e=e=>{try{let t=z(F,[]);if(!t)return;t.focus(),r(e)}catch{}};e(),a=setTimeout(()=>{e(!0),V.isUpdatingSelection=!1})}});return()=>{cancelAnimationFrame(i),a&&clearTimeout(a)}});let Z=(0,c.useCallback)(e=>{rr(F,g,e);let t=z(F,[]);if(!t)return;let n=t.getRootNode();if(N?.current&&eS&&n instanceof ShadowRoot){let t=e.getTargetRanges()[0],n=new window.Range;n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset);let r=eN.toSlateRange(F,n,{exactMatch:!1,suppressThrow:!1});F.select(r),e.preventDefault(),e.stopImmediatePropagation();return}if($(),!b&&eN.hasEditableTarget(F,e.target)&&!rn(e,v)){if(W.current)return W.current.handleDOMBeforeInput(e);J.flush(),H.flush();let{selection:t}=F,{inputType:n}=e,r=e.dataTransfer||e.data||void 0,o="insertCompositionText"===n||"deleteCompositionText"===n;if(o&&eN.isComposing(F))return;let a=!1;if("insertText"===n&&t&&eB(t)&&e.data&&1===e.data.length&&/[a-z ]/i.test(e.data)&&0!==t.anchor.offset&&(a=!0,F.marks&&(a=!1),!F.isNodeMapDirty)){let{anchor:e}=t,[n,r]=eN.toDOMPoint(F,e),o=n.parentElement?.closest("a"),i=eN.getWindow(F);if(a&&o&&eN.hasDOMNode(F,o)){let e=i?.document.createTreeWalker(o,NodeFilter.SHOW_TEXT).lastChild();e===n&&e.textContent?.length===r&&(a=!1)}if(a&&n.parentElement&&i?.getComputedStyle(n.parentElement)?.whiteSpace==="pre"){let t=ef(F,e.path);t&&tn(F,t.path)?.includes(" ")&&(a=!1)}}if((!n.startsWith("delete")||n.startsWith("deleteBy"))&&!F.isNodeMapDirty){let[n]=e.getTargetRanges();if(n){let e=eN.toSlateRange(F,n,{exactMatch:!1,suppressThrow:!1});if(!t||!t9(t,e)){a=!1;let t=!o&&F.selection&&t7(F,F.selection);F.select(e),t&&(F.userSelection=t)}}}if(o)return;if(a||e.preventDefault(),t&&eD(t)&&n.startsWith("delete")){let e=n.endsWith("Backward")?"backward":"forward";g.send({type:"behavior event",behaviorEvent:{type:"delete",direction:e},editor:F});return}switch(n){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":g.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:F});break;case"deleteContent":case"deleteContentForward":g.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"character"},editor:F});break;case"deleteContentBackward":g.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"character"},editor:F});break;case"deleteEntireSoftLine":g.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"line"},editor:F}),g.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"line"},editor:F});break;case"deleteHardLineBackward":g.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"block"},editor:F});break;case"deleteSoftLineBackward":g.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"line"},editor:F});break;case"deleteHardLineForward":g.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"block"},editor:F});break;case"deleteSoftLineForward":g.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"line"},editor:F});break;case"deleteWordBackward":g.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"word"},editor:F});break;
13case"deleteWordForward":g.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"word"},editor:F});break;case"insertLineBreak":g.send({type:"behavior event",behaviorEvent:{type:"insert.soft break"},editor:F});break;case"insertParagraph":g.send({type:"behavior event",behaviorEvent:{type:"insert.break"},editor:F});break;case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":"insertFromComposition"===n&&eN.isComposing(F)&&(O(!1),F.composing=!1),r?.constructor.name==="DataTransfer"?g.send({type:"behavior event",behaviorEvent:{type:"input.*",originEvent:{dataTransfer:r}},editor:F}):"string"==typeof r&&(a?R.current.push(()=>g.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:r},editor:F})):g.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:r},editor:F}))}let i=F.userSelection?.unref();F.userSelection=null,!i||F.selection&&t9(F.selection,i)||F.select(i)}},[F,g,H,$,v,b,J]),q=(0,c.useCallback)(e=>{null==e?(H.cancel(),J.cancel(),F.domElement=null,M.current&&ej&&M.current.removeEventListener("beforeinput",Z)):ej&&e.addEventListener("beforeinput",Z),M.current=e,"function"==typeof t?t(e):t&&(t.current=e)},[H,J,F,Z,t]);nt(()=>{let e=eN.getWindow(F),t=({target:e})=>{let t=(e instanceof HTMLElement?e:null)?.tagName;"INPUT"===t||"TEXTAREA"===t||J()};return e.document.addEventListener("selectionchange",t),()=>{e.document.removeEventListener("selectionchange",t)}},[J]);let X=m([F,[]]),Q=(l=(0,c.useRef)(new Set),s=(0,c.useRef)(m),nt(()=>{s.current=m,l.current.forEach(e=>{e()})},[m]),u=(0,c.useCallback)(e=>s.current(e),[]),h=(0,c.useCallback)(e=>(l.current.add(e),()=>{l.current.delete(e)}),[]),(0,c.useMemo)(()=>({decorate:u,addEventListener:h}),[u,h])),ee=k&&1===F.children.length&&(()=>{let e=0;for(let t of ey(F))if((0,d.bl)({schema:F.schema},t.node)&&(++e>1||""!==t.node.text))return!1;return 1===e})()&&!P,et=(0,c.useCallback)(e=>{j(e&&ee?e.getBoundingClientRect()?.height:void 0)},[ee]);if(ee){let e=ep(F,[]);X.push({[t8]:!0,placeholder:k,onPlaceholderResize:et,anchor:e,focus:e})}let{marks:en}=F;if(V.hasMarkPlaceholder=!1,F.selection&&eB(F.selection)&&en){let{anchor:e}=F.selection,t=U(F,e.path),n=t?t.node:void 0;if(n&&(0,d.bl)({schema:F.schema},n)){let{text:t,...r}=n;if(!ne(n,en,{loose:!0})){V.hasMarkPlaceholder=!0;let t=Object.fromEntries(Object.keys(r).map(e=>[e,null]));X.push({[t5]:!0,...t,...en,anchor:e,focus:e})}}}return(0,c.useEffect)(()=>{setTimeout(()=>{let{selection:e}=F;if(e){let{anchor:t}=e,n=U(F,t.path);if(!n||!(0,d.bl)({schema:F.schema},n.node))return;let r=n.node;if(en&&!ne(r,en,{loose:!0})){F.pendingInsertionMarks=en;return}}F.pendingInsertionMarks=null})}),function(){let{flushDeferred:e}=(0,c.useContext)(n0);nt(e)}(),(0,i.jsx)(nT.Provider,{value:b,children:(0,i.jsx)(nQ.Provider,{value:P,children:(0,i.jsx)(nE.Provider,{value:Q,children:(0,i.jsx)(n4,{node:M,receivedUserInput:K,children:(0,i.jsx)(w,{role:b?void 0:"textbox","aria-multiline":!b||void 0,translate:"no",...S,spellCheck:(!!ej||!eI)&&S.spellCheck,autoCorrect:ej||!eI?S.autoCorrect:"false",autoCapitalize:ej||!eI?S.autoCapitalize:"false","data-slate-editor":!0,"data-slate-node":"value","data-pt-path":"",contentEditable:!b,zindex:-1,suppressContentEditableWarning:!0,ref:q,style:{...A?{}:{position:"relative",whiteSpace:"pre-wrap",wordWrap:"break-word",...I?{minHeight:I}:{}},..._},onBeforeInput:(0,c.useCallback)(e=>{if(!ej&&!b&&!re(e,S.onBeforeInput)&&eN.hasSelectableTarget(F,e.target)&&(e.preventDefault(),!eN.isComposing(F))){let t=e.data;g.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:t},editor:F})}},[S.onBeforeInput,F,g,b]),onInput:(0,c.useCallback)(e=>{if(!re(e,S.onInput)){if(W.current)return void W.current.handleInput();for(let e of R.current)e();R.current=[],!eN.isFocused(F)&&eU(e.target)&&eN.hasEditableTarget(F,e.target)&&rr(F,g,e.nativeEvent)}},[S.onInput,F,g]),onBlur:(0,c.useCallback)(e=>{if(b||V.isUpdatingSelection||!eN.hasSelectableTarget(F,e.target)||re(e,S.onBlur))return;let t=eN.findDocumentOrShadowRoot(F);if(V.latestElement===t.activeElement)return;let{relatedTarget:n}=e,r=z(F,[]);if(r&&n!==r&&!(eV(n)&&n.hasAttribute("data-slate-spacer"))){if(null!=n&&eU(n)&&eN.hasDOMNode(F,n)){let e=e2(n),t=e?Y(F,e,F.blockIndexMap):void 0;if(t){let e=U(F,t),n=e?e.node:void 0;if(n&&((0,p.xN)({schema:F.schema},n)||T({schema:F.schema},n)))return}}eS&&eY(t)?.removeAllRanges(),F.focused=!1}},[b,V.isUpdatingSelection,V.latestElement,F,S.onBlur]),onClick:(0,c.useCallback)(e=>
13{if(eN.hasTarget(F,e.target)&&!re(e,S.onClick)&&eU(e.target)){let t=e2(e.target),n=t?Y(F,t,F.blockIndexMap):void 0;if(!n)return;let r=U(F,n);if(!r)return;let o=r.node;if(3===e.detail&&n.length>=1){let e=n;(0,p.xN)({schema:F.schema},o)&&!F.isInline(o)||(e=ef(F,n)?.path??n.slice(0,1));let t=tO(F,e);F.select(t);return}if(b)return;let a=ep(F,n),i=ta(F,n),l=U(F,a.path),s=l&&T({schema:F.schema},l.node)?l:G(F,a.path),c=U(F,i.path),u=c&&T({schema:F.schema},c.node)?c:G(F,i.path);if(s&&u&&ex(s.path,u.path)){let e=tO(F,a);F.select(e)}}},[F,S.onClick,b]),onCompositionEnd:(0,c.useCallback)(e=>{if(!rt(e)&&eN.hasSelectableTarget(F,e.target)&&(eN.isComposing(F)&&Promise.resolve().then(()=>{O(!1),F.composing=!1}),W.current?.handleCompositionEnd(e),!re(e,S.onCompositionEnd)&&!ew&&!eS&&!eT&&!e_&&!ez&&!eR)&&e.data){let t=F.pendingInsertionMarks;F.pendingInsertionMarks=null,void 0!==t&&(F.userMarks=F.marks,F.marks=t),g.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:e.data},editor:F});let n=F.userMarks;F.userMarks=null,void 0!==n&&(F.marks=n)}},[S.onCompositionEnd,F,g]),onCompositionUpdate:(0,c.useCallback)(e=>{eN.hasSelectableTarget(F,e.target)&&!re(e,S.onCompositionUpdate)&&!rt(e)&&(eN.isComposing(F)||(O(!0),F.composing=!0))},[S.onCompositionUpdate,F]),onCompositionStart:(0,c.useCallback)(e=>{if(!rt(e)&&eN.hasSelectableTarget(F,e.target)){if(W.current?.handleCompositionStart(e),re(e,S.onCompositionStart)||ew)return;O(!0);let{selection:t}=F;if(t&&eD(t))return void g.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:F})}},[S.onCompositionStart,F,g]),onCopy:S.onCopy,onCut:S.onCut,onDragOver:S.onDragOver,onDragStart:S.onDragStart,onDrop:S.onDrop,onDragEnd:S.onDragEnd,onFocus:(0,c.useCallback)(e=>{if(!b&&!V.isUpdatingSelection&&eN.hasEditableTarget(F,e.target)&&!re(e,S.onFocus)){let t=z(F,[]);if(t){if(V.latestElement=eN.findDocumentOrShadowRoot(F).activeElement,eA&&e.target!==t)return void t.focus();F.focused=!0}}},[b,V,F,S.onFocus]),onKeyDown:(0,c.useCallback)(e=>{if(!b&&eN.hasEditableTarget(F,e.target)){W.current?.handleKeyDown(e);let{nativeEvent:t}=e;if(eN.isComposing(F)&&!1===t.isComposing&&(F.composing=!1,O(!1)),re(e,S.onKeyDown)||eN.isComposing(F))return;let{selection:n}=F,r=tn(F,[null!==n?n.focus.path[0]:0]),o=void 0!==r&&"rtl"===nF(r);if(t4.isMoveLineBackward(t)){e.preventDefault(),tz(F,{unit:"line",reverse:!0});return}if(t4.isMoveLineForward(t)){e.preventDefault(),tz(F,{unit:"line"});return}if(t4.isExtendLineBackward(t)){e.preventDefault(),tz(F,{unit:"line",edge:"focus",reverse:!0});return}if(t4.isExtendLineForward(t)){e.preventDefault(),tz(F,{unit:"line",edge:"focus"});return}if(t4.isMoveBackward(t)){e.preventDefault(),n&&eB(n)?tz(F,{reverse:!o}):tr(F,{edge:o?"end":"start"});return}if(t4.isMoveForward(t)){e.preventDefault(),n&&eB(n)?tz(F,{reverse:o}):tr(F,{edge:o?"start":"end"});return}if(t4.isMoveWordBackward(t)){e.preventDefault(),n&&eD(n)&&tr(F,{edge:"focus"}),tz(F,{unit:"word",reverse:!o});return}if(t4.isMoveWordForward(t)){e.preventDefault(),n&&eD(n)&&tr(F,{edge:"focus"}),tz(F,{unit:"word",reverse:o});return}if(ej){if((eP||eS)&&n&&(t4.isDeleteBackward(t)||t4.isDeleteForward(t))&&eB(n)){let t=U(F,n.anchor.path);if(t&&T({schema:F.schema},t.node)){e.preventDefault(),g.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"block"},editor:F});return}}}else{if(t4.isBold(t)||t4.isItalic(t)||t4.isTransposeCharacter(t))return void e.preventDefault();if(t4.isSoftBreak(t)){e.preventDefault(),g.send({type:"behavior event",behaviorEvent:{type:"insert.soft break"},editor:F});return}if(t4.isSplitBlock(t)){e.preventDefault(),g.send({type:"behavior event",behaviorEvent:{type:"insert.break"},editor:F});return}if(t4.isDeleteBackward(t)){e.preventDefault(),n&&eD(n)?g.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"backward"},editor:F}):g.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"character"},editor:F});return}if(t4.isDeleteForward(t)){e.preventDefault(),n&&eD(n)?g.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:F}):g.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"character"},editor:F});return}if(t4.isDeleteLineBackward(t)){e.preventDefault(),n&&eD(n)?g.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"backward"},editor:F}):g.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"line"},editor:F});return}if(t4.isDeleteLineForward(t)){e.preventDefault(),n&&eD(n)?g.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:F}):g.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"line"},editor:F});return}if(t4.isDeleteWordBackward(t)){e.preventDefault(),n&&eD(n)?g.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"backward"},editor:F}):g.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"word"},editor:F});return}
13if(t4.isDeleteWordForward(t)){e.preventDefault(),n&&eD(n)?g.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:F}):g.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"word"},editor:F});return}}}},[b,F,g,S.onKeyDown]),onPaste:(0,c.useCallback)(e=>{let t;!b&&eN.hasEditableTarget(F,e.target)&&!re(e,S.onPaste)&&(!ej||(t=e.nativeEvent).clipboardData&&""!==t.clipboardData.getData("text/plain")&&1===t.clipboardData.types.length||eS)&&(e.preventDefault(),g.send({type:"behavior event",behaviorEvent:{type:"input.*",originEvent:{dataTransfer:e.clipboardData}},editor:F}))},[b,F,g,S.onPaste]),children:(0,i.jsx)(n8,{parentDataPath:"",decorations:X,node:F,indexedPath:[],renderElement:x,renderPlaceholder:E,renderLeaf:C,renderText:B})})})})})})}),n7=({attributes:e,children:t})=>(0,i.jsxs)("span",{...e,children:[t,ew&&(0,i.jsx)("br",{})]}),n9=()=>[],n6=(e,t)=>{let n=!!e.selection&&ea(e.selection),r=t.cloneRange();if(r.collapse(n),r.getBoundingClientRect){let e=r.startContainer.parentElement,t=r.getBoundingClientRect();if(0===t.width&&0===t.height&&0===t.x&&0===t.y){let t=e.getBoundingClientRect();if(t.width>0||t.height>0)return}e.getBoundingClientRect=r.getBoundingClientRect.bind(r),(0,f.A)(e,{scrollMode:"if-needed"}),delete e.getBoundingClientRect}},re=(e,t)=>!!t&&(t(e)??(e.isDefaultPrevented()||e.isPropagationStopped())),rt=e=>eU(e.target)&&(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement),rn=(e,t)=>!!t&&(t(e)??e.defaultPrevented),rr=(e,t,n)=>{"historyUndo"===n.inputType?t.send({type:"behavior event",behaviorEvent:{type:"history.undo"},editor:e}):"historyRedo"===n.inputType&&t.send({type:"behavior event",behaviorEvent:{type:"history.redo"},editor:e})},ro=(0,c.createContext)({}),ra="u">typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent),ri={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},rl={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:ra?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},rs={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,f13:124,f14:125,f15:126,f16:127,f17:128,f18:129,f19:130,f20:131};function rc(e){let t={altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1},n=e.replace("++","+add").split("+");for(let e of n){let r=e.endsWith("?")&&e.length>1,o=r?e.slice(0,-1):e,a=rd(o),i=ri[a],l=rl[o],s=rs[a];if(o.length>1&&void 0===i&&void 0===l&&void 0===s)throw TypeError(`Unknown modifier: "${o}"`);(1===n.length||void 0===i)&&(t.key=a,t.keyCode=function(e){let t=rd(e);return rs[t]??t.toUpperCase().charCodeAt(0)}(o)),void 0!==i&&(t[i]=!r||null)}return t}function ru(e,t){return(null==e.altKey||e.altKey===t.altKey)&&(null==e.ctrlKey||e.ctrlKey===t.ctrlKey)&&(null==e.metaKey||e.metaKey===t.metaKey)&&(null==e.shiftKey||e.shiftKey===t.shiftKey)&&(void 0!==e.ke
13yCode&&void 0!==t.keyCode?91===e.keyCode&&93===t.keyCode||e.keyCode===t.keyCode:e.keyCode===t.keyCode||e.key===t.key.toLowerCase())}function rd(e){let t=e.toLowerCase();return rl[t]??t}let rh=["enter","tab","shift","delete","end"];function rp(e,t,n){if(!t||!n)return t===n;if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++){let o=t.at(r),a=n.at(r);if(!o||!a||!rf(e,o,a))return!1}return!0}function rf(e,t,n){var r,o,a,i,l;return t._type===n._type&&(t._type===e.schema.block.name&&n._type===e.schema.block.name?(r=e,o=t,a=n,!!(0,d.zS)(r,o)&&!!(0,d.zS)(r,a)&&o._key===a._key&&o.style===a.style&&o.listItem===a.listItem&&o.level===a.level&&(!("markDefs"in o)||!("markDefs"in a)||!!Array.isArray(o.markDefs)&&!!Array.isArray(a.markDefs)&&!!rg(o.markDefs,a.markDefs))&&!!rv(o.children,a.children,r.schema.span.name)&&ry(o,a,["_key","_type","style","listItem","level","markDefs","children"])):(i=t,l=n,i._key===l._key&&i._type===l._type&&ry(i,l,["_key","_type"])))}function ry(e,t,n){let r=Object.keys(e).filter(e=>!n.includes(e)),o=Object.keys(t).filter(e=>!n.includes(e));if(r.length!==o.length)return!1;for(let n of r){if(!(n in e)||!(n in t))return!1;let r=e[n],o=t[n];if(r!==o&&!rb(r,o))return!1}return!0}function rm(e,t){if(!e||!t)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e.at(n)!==t.at(n))return!1;return!0}function rg(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e.at(n),o=t.at(n);if(!r||!o||!rb(r,o))return!1}return!0}function rv(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){let o=e.at(r),a=t.at(r);if(!o||!a||!rk(o,a,n))return!1}return!0}function rk(e,t,n){return e._type===n&&t._type===n?e._key===t._key&&e._type===t._type&&e.text===t.text&&!!rm(e.marks,t.marks)&&ry(e,t,["_key","_type","text","marks"]):e._key===t._key&&e._type===t._type&&ry(e,t,["_key","_type"])}function rb(e,t){if(e===t||Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(Array.isArray(e)){var n=e,r=t;if(n.length!==r.length)return!1;for(let[e,t]of n.entries())if(!rb(t,r[e]))return!1;return!0}if(e instanceof Map){var o=e,a=t;if(o.size!==a.size)return!1;for(let[e,t]of o.entries())if(!a.has(e)||!rb(t,a.get(e)))return!1;return!0}if(e instanceof Set){var i=e,l=t;if(i.size!==l.size)return!1;let n=[...l];for(let e of i){let t=!1;for(let[r,o]of n.entries())if(rb(e,o)){t=!0,n.splice(r,1);break}if(!t)return!1}return!0}if(e instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp)return e.toString()===t.toString();if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let[n,r]of Object.entries(e))if(!(n in t)||!rb(r,t[n]))return!1;return!0}function rx(e,t){if(en(t)){if(rx(e,t.anchor)||rx(e,t.focus))return!0;let[n,r]=ei(e),[o,a]=ei(t);return nv(n,o)&&1===eo(r,a)}let[n,r]=ei(e),o=!1,a=!1;return et(t)?(o=eo(t,n)>=0,a=0>=eo(t,r)):(o=er(t,n.path)>=0,a=0>=er(t,r.path)),o&&a}let rC=(0,v.mj)({types:{context:{},input:{},events:{}},actions:{"update pending range decorations":(0,k.a)({pendingRangeDecorations:({context:e,event:t})=>"range decorations updated"!==t.type?e.pendingRangeDecorations:t.rangeDecorations}),"set up initial range decorations":({context:e})=>{let t=[];for(let n of e.pendingRangeDecorations){let r=te({context:{schema:e.schema,value:e.slateEditor.children,selection:n.selection},blockIndexMap:e.slateEditor.blockIndexMap});if(!en(r)){n.onMoved?.({newSelection:null,rangeDecoration:n,origin:"local"});continue}t.push({rangeDecoration:n,...r})}e.slateEditor.decoratedRanges=t},"update range decorations":({context:e,event:t})=>{if("range decorations updated"!==t.type)return;let n=[];for(let r of t.rangeDecorations){let t=te({context:{schema:e.schema,value:e.slateEditor.children,selection:r.selection},blockIndexMap:e.slateEditor.blockIndexMap});if(!en(t)){r.onMoved?.({newSelection:null,rangeDecoration:r,origin:"local"});continue}n.push({rangeDecoration:r,...t})}e.slateEditor.decoratedRanges=n},"move range decorations":({context:e,event:t})=>{if("slate operation"!==t.type)return;let n=[];for(let r of e.slateEditor.decoratedRanges){let o,a=te({context:{schema:e.schema,value:e.slateEditor.children,selection:r.rangeDecoration.selection},blockIndexMap:e.slateEditor.blockIndexMap});if(!en(a)){r.rangeDecoration.onMoved?.({newSelection:null,rangeDecoration:r.rangeDecoration,origin:"local"});continue}if((o=function(e,t){let n=ns(e.anchor,t),r=ns(e.focus,t);return null===n||null===r?null:eC(n,e.anchor)&&eC(r,e.focus)?e:{anchor:n,focus:r}}
13(a,t.operation))&&o!==a||null===o&&a){let t=o?e5({schema:e.schema,editor:e.slateEditor,range:o}):null;r.rangeDecoration.onMoved?.({newSelection:t,rangeDecoration:r.rangeDecoration,origin:"local"})}null!==o&&n.push({...o||a,rangeDecoration:{...r.rangeDecoration,selection:e5({schema:e.schema,editor:e.slateEditor,range:o})}})}e.slateEditor.decoratedRanges=n},"assign readOnly":(0,k.a)({readOnly:({context:e,event:t})=>"update read only"!==t.type?e.readOnly:t.readOnly}),"update decorate":(0,k.a)({decorate:({context:e})=>({fn:rB(e.schema,e.slateEditor)})})},actors:{"slate operation listener":(0,b.SP)(({input:e,sendBack:t})=>{let n=e.slateEditor.apply;return e.slateEditor.apply=e=>{"set_selection"!==e.type&&t({type:"slate operation",operation:e}),n(e)},()=>{e.slateEditor.apply=n}})},guards:{"has pending range decorations":({context:e})=>e.pendingRangeDecorations.length>0,"has range decorations":({context:e})=>e.slateEditor.decoratedRanges.length>0,"has different decorations":({context:e,event:t})=>"range decorations updated"===t.type&&!rb(e.slateEditor.decoratedRanges.map(e=>({anchor:e.rangeDecoration.selection?.anchor,focus:e.rangeDecoration.selection?.focus,payload:e.rangeDecoration.payload})),t.rangeDecorations.map(e=>({anchor:e.selection?.anchor,focus:e.selection?.focus,payload:e.payload}))),"not read only":({context:e})=>!e.readOnly,"should skip setup":({context:e})=>e.skipSetup}}).createMachine({id:"range decorations",context:({input:e})=>({readOnly:e.readOnly,pendingRangeDecorations:e.rangeDecorations,decoratedRanges:[],skipSetup:e.skipSetup,schema:e.schema,slateEditor:e.slateEditor,decorate:{fn:rB(e.schema,e.slateEditor)}}),invoke:{src:"slate operation listener",input:({context:e})=>({slateEditor:e.slateEditor})},on:{"update read only":{actions:["assign readOnly"]}},initial:"setting up",states:{"setting up":{always:[{guard:(0,x.j)(["should skip setup","has pending range decorations"]),target:"ready",actions:["set up initial range decorations","update decorate"]},{guard:"should skip setup",target:"ready"}],on:{"range decorations updated":{actions:["update pending range decorations"]},ready:[{target:"ready",guard:"has pending range decorations",actions:["set up initial range decorations","update decorate"]},{target:"ready"}]}},ready:{initial:"idle",on:{"range decorations updated":{target:".idle",guard:"has different decorations",actions:["update range decorations","update decorate"]}},states:{idle:{on:{"slate operation":{target:"moving range decorations",guard:(0,x.j)(["has range decorations","not read only"])}}},"moving range decorations":{entry:["move range decorations"],always:{target:"idle"}}}}}});function rB(e,t){return function([n,r]){let o=e.styles.at(0)?.name,a=t.children[0];if(1===t.children.length&&a&&(0,g.wm)({schema:e},a)&&(!a.style||a.style===o)&&!a.listItem)return[{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0},placeholder:!0}];if(0===r.length||!(0,d.zS)({schema:t.schema},n)||0===n.children.length)return[];let i=r.at(0);return void 0===i?[]:t.decoratedRanges.filter(e=>eB(e)?n.children.some((t,n)=>ex(e.anchor.path,[i,n])&&ex(e.focus.path,[i,n])):nk(e,{anchor:{path:r,offset:0},focus:{path:r,offset:0}})||rx(e,r))}}let rE=(0,c.createContext)({});function rD(e){let t,n,r=(0,l.c)(4);return r[0]===Symbol.for("react.memo_cache_sentinel")?(t={userSelect:"none"},r[0]=t):t=r[0],r[1]!==e.blockObject._key||r[2]!==e.blockObject._type?(n=(0,i.jsxs)("div",{style:t,children:["[",e.blockObject._type,": ",e.blockObject._key,"]"]}),r[1]=e.blockObject._key,r[2]=e.blockObject._type,r[3]=n):n=r[3],n}function r_(e){let t,n,r=(0,l.c)(4);return r[0]===Symbol.for("react.memo_cache_sentinel")?(t={userSelect:"none"},r[0]=t):t=r[0],r[1]!==e.inlineObject._key||r[2]!==e.inlineObject._type?(n=(0,i.jsxs)("span",{style:t,children:["[",e.inlineObject._type,": ",e.inlineObject._key,"]"]}),r[1]=e.inlineObject._key,r[2]=e.inlineObject._type,r[3]=n):n=r[3],n}function rw(){let e,t=(0,l.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,i.jsx)("div",{contentEditable:!1,className:"pt-drop-indicator",style:{position:"absolute",width:"100%",height:1,borderBottom:"1px solid currentColor",zIndex:5},children:(0,i.jsx)("span",{})}),t[0]=e):e=t[0],e}function rA({editorActorSnapshot:e,slateEditorInstance:t}){let n=t.selection?e5({schema:e.context.schema,editor:t,range:t.selection}):null;return{blockIndexMap:t.blockIndexMap,context:{converters:[...e.context.converters],keyGenerator:e.context.keyGenerator,readOnly:e.matches({"edit mode":"read only"}),schema:e.context.schema,selection:n,value:t.children},decoratorState:t.decoratorState}}let rS=new Set,rF={focusedChildPath:void 0,selectedChildPaths:rS,focusedBlockKey:void 0,selectedBlockKeys:rS},rP=(0,c.createContext)(rF);function rO(e){let t,n,r=(0,l.c)(5),{children:o}=e,a=(0,c.useContext)(ro),u=nr();r[0]!==u?(t=e=>{let t,n=rA({editorActorSnapshot:e,slateEditorInstance:u});if(!n.context.selection)return rF;let r=(0,p.WV)(n);if(r){let e=(0,p.jR)(n);e&&(t=R(e.path))}let o=(0,p.Fg)()(n),a=o.length>0?new Set(o.map(rT)):rS;
13r&&t&&!a.has(t)&&(a=new Set(a)).add(t);let i=(0,p.Jo)(n),l=(0,p.aR)(n),s=i?(0,h.XE)(i):void 0,c=l?(0,h.XE)(l):void 0,d=rS;if(s&&c){let e=n.blockIndexMap.get(s),t=n.blockIndexMap.get(c);if(void 0!==e&&void 0!==t){let r=Math.min(e,t),o=Math.max(e,t);for(let[e,t]of(d=new Set,n.blockIndexMap))t>=r&&t<=o&&d.add(e)}}let f=r?s:void 0;return{focusedChildPath:t,selectedChildPaths:a.size>0?a:rS,focusedBlockKey:f,selectedBlockKeys:d.size>0?d:rS}},r[0]=u,r[1]=t):t=r[1];let d=(0,s.d4)(a,t,rM);return r[2]!==o||r[3]!==d?(n=(0,i.jsx)(rP.Provider,{value:d,children:o}),r[2]=o,r[3]=d,r[4]=n):n=r[4],n}function rM(e,t){if(e.focusedChildPath!==t.focusedChildPath)return!1;if(e.selectedChildPaths!==t.selectedChildPaths){if(e.selectedChildPaths.size!==t.selectedChildPaths.size)return!1;for(let n of e.selectedChildPaths)if(!t.selectedChildPaths.has(n))return!1}if(e.focusedBlockKey!==t.focusedBlockKey)return!1;if(e.selectedBlockKeys!==t.selectedBlockKeys){if(e.selectedBlockKeys.size!==t.selectedBlockKeys.size)return!1;for(let n of e.selectedBlockKeys)if(!t.selectedBlockKeys.has(n))return!1}return!0}function rT(e){return R(e.path)}function rR(e){let t,n,r,o,a,s,u,d,h=(0,l.c)(34),p=(0,c.useRef)(null),{selectedBlockKeys:f,focusedBlockKey:y}=(0,c.useContext)(rP);h[0]!==e.element._key||h[1]!==f?(t=f.has(e.element._key),h[0]=e.element._key,h[1]=f,h[2]=t):t=h[2];let m=t,g=y===e.element._key;if(h[3]!==e.element._type||h[4]!==e.schema.blockObjects){let t;h[6]!==e.element._type?(t=t=>t.name===e.element._type,h[6]=e.element._type,h[7]=t):t=h[7],n=e.schema.blockObjects.find(t),h[3]=e.element._type,h[4]=e.schema.blockObjects,h[5]=n}else n=h[5];let v=n;v||console.error(`Unable to find Block Object "${e.element._type}" in Schema`),h[8]!==e.blockObject||h[9]!==e.element._key||h[10]!==e.element._type?(r=e.blockObject??{_key:e.element._key,_type:e.element._type},h[8]=e.blockObject,h[9]=e.element._key,h[10]=e.element._type,h[11]=r):r=h[11];let k=r;h[12]!==e.dropPosition?(o="start"===e.dropPosition?(0,i.jsx)(rw,{}):null,h[12]=e.dropPosition,h[13]=o):o=h[13];let b=!e.readOnly;return h[14]!==k||h[15]!==v||h[16]!==g||h[17]!==e.element._key||h[18]!==e.renderBlock||h[19]!==m?(a=e.renderBlock&&v?(0,i.jsx)(rz,{renderBlock:e.renderBlock,editorElementRef:p,focused:g,path:[{_key:e.element._key}],schemaType:v,selected:m,value:k,children:(0,i.jsx)(rD,{blockObject:k})}):(0,i.jsx)(rD,{blockObject:k}),h[14]=k,h[15]=v,h[16]=g,h[17]=e.element._key,h[18]=e.renderBlock,h[19]=m,h[20]=a):a=h[20],h[21]!==b||h[22]!==a?(s=(0,i.jsx)("div",{ref:p,contentEditable:!1,draggable:b,children:a}),h[21]=b,h[22]=a,h[23]=s):s=h[23],h[24]!==e.dropPosition?(u="end"===e.dropPosition?(0,i.jsx)(rw,{}):null,h[24]=e.dropPosition,h[25]=u):u=h[25],h[26]!==e.attributes||h[27]!==e.children||h[28]!==e.element._key||h[29]!==e.element._type||h[30]!==o||h[31]!==s||h[32]!==u?(d=(0,i.jsxs)("div",{...e.attributes,className:"pt-block pt-object-block","data-block-key":e.element._key,"data-block-name":e.element._type,"data-block-type":"object",children:[o,e.children,s,u]}),h[26]=e.attributes,h[27]=e.children,h[28]=e.element._key,h[29]=e.element._type,h[30]=o,h[31]=s,h[32]=u,h[33]=d):d=h[33],d}function rz({renderBlock:e,children:t,editorElementRef:n,focused:r,path:o,schemaType:a,selected:i,value:l}){return e({children:t,editorElementRef:n,focused:r,path:o,schemaType:a,selected:i,value:l})}function rI(e){let t,n,r,o,a,s=(0,l.c)(22),u=(0,c.useRef)(null),d=nr();if(s[0]!==e.element||s[1]!==e.schema.inlineObjects){let n;s[3]!==e.element?(n=t=>t.name===e.element._type,s[3]=e.element,s[4]=n):n=s[4],t=e.schema.inlineObjects.find(n),s[0]=e.element,s[1]=e.schema.inlineObjects,s[2]=t}else t=s[2];let h=t;h||console.error(`Unable to find Inline Object "${e.element._type}" in Schema`);let p=U(d,e.indexedPath.slice(0,1))?.node;p||console.error(`Unable to find parent block of inline object ${e.element._key}`);let f=p?[{_key:p._key},"children",{_key:e.element._key}]:void 0,y=(0,c.useContext)(rP),m=f?R(f):void 0,g=!!m&&y.selectedChildPaths.has(m),v=!!m&&y.focusedChildPath===m,k=e.element;s[5]===Symbol.for("react.memo_cache_sentinel")?(n={display:"inline-block"},s[5]=n):n=s[5];let b=!e.readOnly;return s[6]!==v||s[7]!==k||s[8]!==h||s[9]!==f||s[10]!==e.renderChild||s[11]!==g?(r=e.renderChild&&f&&h?(0,i.jsx)(rj,{renderChild:e.renderChild,annotations:[],editorElementRef:u,selected:g,focused:v,path:f,schemaType:h,value:k,children:(0,i.jsx)(r_,{inlineObject:k})}):(0,i.jsx)(r_,{inlineObject:k}),s[6]=v,s[7]=k,s[8]=h,s[9]=f,s[10]=e.renderChild,s[11]=g,s[12]=r):r=s[12],s[13]!==b||s[14]!==r?(o=(0,i.jsx)("span",{ref:u,style:n,draggable:b,children:r}),s[13]=b,s[14]=r,s[15]=o):o=s[15],s[16]!==k._key||s[17]!==k._type||s[18]!==e.attributes||s[19]!==e.children||s[20]!==o?(a=(0,i.jsxs)("span",{...e.attributes,className:"pt-inline-object","data-child-key":k._key,"data-child-name":k._type,"data-child-type":"object",children:[e.children,o]}),s[16]=k._key,s[17]=k._type,s[18]=e.attributes,s[19]=e.children,s[20]=o,s[21]=a):a=s[21],a}function rj({renderChild:e,annotations:t,children:n,editorElementRef:r,focused:o,path:a,schemaType:i,selected:l,value:s}){return e({annotations:t,children:n,editorElementRef:r,focused:o,path:a,schemaType:i,selected:l,value:s})}
13function rN(e){let t,n,r,o,a,s,u,d,h,p,f,y,m,g,v,k,b=(0,l.c)(81),x=(0,c.useRef)(null);b[0]!==e.schema.block.fields?(t=e.schema.block.fields??[],b[0]=e.schema.block.fields,b[1]=t):t=b[1],b[2]!==e.schema.block.name||b[3]!==t?(n={name:e.schema.block.name,fields:t},b[2]=e.schema.block.name,b[3]=t,b[4]=n):n=b[4];let C=n,{selectedBlockKeys:B,focusedBlockKey:E}=(0,c.useContext)(rP);b[5]!==e.textBlock._key||b[6]!==B?(r=B.has(e.textBlock._key),b[5]=e.textBlock._key,b[6]=B,b[7]=r):r=b[7];let D=r,_=E===e.textBlock._key;b[8]!==e.textBlock._key?(o=t=>t.listIndexMap.get(e.textBlock._key),b[8]=e.textBlock._key,b[9]=o):o=b[9];let w=function(e,t=(e,t)=>e===t){let n=(0,c.useContext)(n0);if(!n)throw Error("The `useSlateSelector` hook must be used inside the <Slate> component's context.");let{addEventListener:r}=n,o=nr(),[a,i]=nB((0,c.useCallback)(()=>e(o),[o,e]),t);return nt(()=>{let e=r(i);return i(),e},[r,i]),a}(o),A=e.children;if(e.renderStyle&&e.textBlock.style){let t;b[10]!==e.schema.styles||b[11]!==e.textBlock.style?(t=void 0!==e.textBlock.style?e.schema.styles.find(t=>t.value===e.textBlock.style):void 0,b[10]=e.schema.styles,b[11]=e.textBlock.style,b[12]=t):t=b[12];let n=t;if(n){let t,r;b[13]!==e.textBlock._key?(t=[{_key:e.textBlock._key}],b[13]=e.textBlock._key,b[14]=t):t=b[14],b[15]!==A||b[16]!==_||b[17]!==e.renderStyle||b[18]!==e.textBlock||b[19]!==D||b[20]!==n||b[21]!==t?(r=(0,i.jsx)(rL,{renderStyle:e.renderStyle,block:e.textBlock,editorElementRef:x,focused:_,path:t,schemaType:n,selected:D,value:e.textBlock.style,children:A}),b[15]=A,b[16]=_,b[17]=e.renderStyle,b[18]=e.textBlock,b[19]=D,b[20]=n,b[21]=t,b[22]=r):r=b[22],A=r}else console.error(`Unable to find Schema type for text block style ${e.textBlock.style}`)}if(e.renderListItem&&e.textBlock.listItem){let t;if(b[23]!==e.schema.lists||b[24]!==e.textBlock.listItem){let n;b[26]!==e.textBlock.listItem?(n=t=>t.value===e.textBlock.listItem,b[26]=e.textBlock.listItem,b[27]=n):n=b[27],t=e.schema.lists.find(n),b[23]=e.schema.lists,b[24]=e.textBlock.listItem,b[25]=t}else t=b[25];let n=t;if(n){let t,r,o=e.textBlock.level??1;b[28]!==e.textBlock._key?(t=[{_key:e.textBlock._key}],b[28]=e.textBlock._key,b[29]=t):t=b[29],b[30]!==A||b[31]!==_||b[32]!==n||b[33]!==e.renderListItem||b[34]!==e.textBlock||b[35]!==D||b[36]!==o||b[37]!==t?(r=(0,i.jsx)(rK,{renderListItem:e.renderListItem,block:e.textBlock,editorElementRef:x,focused:_,level:o,path:t,selected:D,value:e.textBlock.listItem,schemaType:n,children:A}),b[30]=A,b[31]=_,b[32]=n,b[33]=e.renderListItem,b[34]=e.textBlock,b[35]=D,b[36]=o,b[37]=t,b[38]=r):r=b[38],A=r}else console.error(`Unable to find Schema type for text block list item ${e.textBlock.listItem}`)}let S=e.attributes;b[39]!==e.textBlock.style?(a=e.textBlock.style?[`pt-text-block-style-${e.textBlock.style}`]:[],b[39]=e.textBlock.style,b[40]=a):a=b[40],b[41]!==e.textBlock.level||b[42]!==e.textBlock.listItem?(s=e.textBlock.listItem?["pt-list-item",`pt-list-item-${e.textBlock.listItem}`,`pt-list-item-level-${e.textBlock.level??1}`]:[],b[41]=e.textBlock.level,b[42]=e.textBlock.listItem,b[43]=s):s=b[43],b[44]!==a||b[45]!==s?(u=["pt-block","pt-text-block",...a,...s],b[44]=a,b[45]=s,b[46]=u):u=b[46];let F=u.join(" ");return b[47]!==e.textBlock.listItem?(d=void 0!==e.textBlock.listItem?{"data-list-item":e.textBlock.listItem}:{},b[47]=e.textBlock.listItem,b[48]=d):d=b[48],b[49]!==e.textBlock.level?(h=void 0!==e.textBlock.level?{"data-level":e.textBlock.level}:{},b[49]=e.textBlock.level,b[50]=h):h=b[50],b[51]!==e.textBlock.style?(p=void 0!==e.textBlock.style?{"data-style":e.textBlock.style}:{},b[51]=e.textBlock.style,b[52]=p):p=b[52],b[53]!==w?(f=void 0!==w?{"data-list-index":w}:{},b[53]=w,b[54]=f):f=b[54],b[55]!==e.dropPosition?(y="start"===e.dropPosition?(0,i.jsx)(rw,{}):null,b[55]=e.dropPosition,b[56]=y):y=b[56],b[57]!==A||b[58]!==_||b[59]!==e.renderBlock||b[60]!==e.textBlock||b[61]!==C||b[62]!==D?(m=e.renderBlock?(0,i.jsx)(r$,{renderBlock:e.renderBlock,editorElementRef:x,focused:_,level:e.textBlock.level,listItem:e.textBlock.listItem,path:[{_key:e.textBlock._key}],selected:D,schemaType:C,style:e.textBlock.style,value:e.textBlock,children:A}):A,b[57]=A,b[58]=_,b[59]=e.renderBlock,b[60]=e.textBlock,b[61]=C,b[62]=D,b[63]=m):m=b[63],b[64]!==m?(g=(0,i.jsx)("div",{ref:x,children:m}),b[64]=m,b[65]=g):g=b[65],b[66]!==e.dropPosition?(v="end"===e.dropPosition?(0,i.jsx)(rw,{}):null,b[66]=e.dropPosition,b[67]=v):v=b[67],b[68]!==e.attributes||b[69]!==e.spellCheck||b[70]!==e.textBlock._key||b[71]!==e.textBlock._type||b[72]!==h||b[73]!==p||b[74]!==f||b[75]!==y||b[76]!==g||b[77]!==v||b[78]!==F||b[79]!==d?(k=(0,i.jsxs)("div",{...S,className:F,spellCheck:e.spellCheck,"data-block-key":e.textBlock._key,"data-block-name":e.textBlock._type,"data-block-type":"text",...d,...h,...p,...f,children:[y,g,v]}),b[68]=e.attributes,b[69]=e.spellCheck,b[70]=e.textBlock._key,b[71]=e.textBlock._type,b[72]=h,b[73]=p,b[74]=f,b[75]=y,b[76]=g,b[77]=v,b[78]=F,b[79]=d,b[80]=k):k=b[80],k}function r$({renderBlock:e,children:t,editorElementRef:n,focused:r,level:o,listItem:a,path:i,selected:l,style:s,schemaType:c,value:u}){return e({children:t,editorElementRef:n,focused:r,level:o,listItem:a,path:i,selected:l,style:s,schemaType:c,value:u})}function rK({renderListItem:e,block:t,children:n,editorElementRef:r,focused:o,level:a,path:i,schemaType:l,selected:s,value:c}){return e({block:t,children:n,editorElementRef:r,focused:o,level:a,path:i,schemaType:l,selected:s,value:c})}function rL({renderStyle:e,block:t,children:n,editorElementRef:r,focused:o,path:a,schemaType:i,selected:l,value:s}){return e({block:t,children:n,editorElementRef:r,focused:o,path:a,schemaType:i,selected:l,value:s})}function rV(e){let t,n=(0,l.c)(27),r=(0,c.useContext)(ro),o=(0,s.d4)(r,rU),a=nr();if((0,d.zS)({schema:o},e.element)){let t,r=e.dropPosition?.blockKey===e.element._key?e.dropPosition.positionBlock:void 0;return n[0]!==e.attributes||n[1]!==e.children||n[2]!==e.element||n[3]!==e.readOnly||n[4]!==e.renderBlock||n[5]!==e.renderListItem||n[6]!==e.renderStyle||n[7]!==e.spellCheck||n[8]!==o||n[9]!==r?(t=(0,i.jsx)(rN,{attributes:e.attributes,dropPosition:r,element:e.element,readOnly:e.readOnly,renderBlock:e.renderBlock,renderListItem:e.renderListItem,render
13Style:e.renderStyle,schema:o,spellCheck:e.spellCheck,textBlock:e.element,children:e.children}),n[0]=e.attributes,n[1]=e.children,n[2]=e.element,n[3]=e.readOnly,n[4]=e.renderBlock,n[5]=e.renderListItem,n[6]=e.renderStyle,n[7]=e.spellCheck,n[8]=o,n[9]=r,n[10]=t):t=n[10],t}if(a.isInline(e.element)){let t;return n[11]!==e.attributes||n[12]!==e.children||n[13]!==e.element||n[14]!==e.indexedPath||n[15]!==e.readOnly||n[16]!==e.renderChild||n[17]!==o?(t=(0,i.jsx)(rI,{attributes:e.attributes,element:e.element,indexedPath:e.indexedPath,readOnly:e.readOnly,renderChild:e.renderChild,schema:o,children:e.children}),n[11]=e.attributes,n[12]=e.children,n[13]=e.element,n[14]=e.indexedPath,n[15]=e.readOnly,n[16]=e.renderChild,n[17]=o,n[18]=t):t=n[18],t}let u=e.dropPosition?.blockKey===e.element._key?e.dropPosition.positionBlock:void 0;return n[19]!==e.attributes||n[20]!==e.children||n[21]!==e.element||n[22]!==e.readOnly||n[23]!==e.renderBlock||n[24]!==o||n[25]!==u?(t=(0,i.jsx)(rR,{attributes:e.attributes,blockObject:e.element,dropPosition:u,element:e.element,readOnly:e.readOnly,renderBlock:e.renderBlock,schema:o,children:e.children}),n[19]=e.attributes,n[20]=e.children,n[21]=e.element,n[22]=e.readOnly,n[23]=e.renderBlock,n[24]=o,n[25]=u,n[26]=t):t=n[26],t}function rU(e){return e.context.schema}function rW(e){let t,n,r,o,a,u,h,p,f=(0,l.c)(40),y=nr(),m=(0,c.useContext)(ro),g=(0,s.d4)(m,rG),v=(0,c.useRef)(null);f[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],f[0]=t):t=f[0],f[1]!==g.span.name?(n={name:g.span.name,fields:t},f[1]=g.span.name,f[2]=n):n=f[2];let k=n,b=e.children.props.parent,x=b&&(0,d.zS)({schema:y.schema},b)?b:void 0;f[3]!==x||f[4]!==e.leaf._key?(r=x?[{_key:x._key},"children",{_key:e.leaf._key}]:void 0,f[3]=x,f[4]=e.leaf._key,f[5]=r):r=f[5];let C=r,B=(0,c.useContext)(rP);if(f[6]!==C||f[7]!==B){let e=C?R(C):void 0;o=!!e&&B.focusedChildPath===e,a=!!e&&B.selectedChildPaths.has(e),f[6]=C,f[7]=B,f[8]=o,f[9]=a}else o=f[8],a=f[9];let E=a;if(f[10]!==x||f[11]!==m||f[12]!==o||f[13]!==C||f[14]!==e.children||f[15]!==e.leaf.marks||f[16]!==e.renderAnnotation||f[17]!==e.renderDecorator||f[18]!==g.annotations||f[19]!==g.decorators||f[20]!==E){let t=m.getSnapshot().context.schema.decorators.map(rH),n=[...new Set((e.leaf.marks??[]).filter(e=>t.includes(e)))];for(let r of(u=(e.leaf.marks??[]).flatMap(e=>{if(t.includes(e))return[];let n=x?.markDefs?.find(t=>t._key===e);return n?[n]:[]}),h=e.children,n)){let t=g.decorators.find(e=>e.name===r);C&&t&&e.renderDecorator&&(h=(0,i.jsx)(rZ,{renderDecorator:e.renderDecorator,editorElementRef:v,focused:o,path:C,selected:E,schemaType:t,value:r,children:h}))}for(let t of u){let n=g.annotations.find(e=>e.name===t._type);n&&(h=x&&C&&e.renderAnnotation?(0,i.jsx)("span",{ref:v,children:(0,i.jsx)(rJ,{renderAnnotation:e.renderAnnotation,block:x,editorElementRef:v,focused:o,path:C,selected:E,schemaType:n,value:t,children:h})}):(0,i.jsx)("span",{ref:v,children:h}))}f[10]=x,f[11]=m,f[12]=o,f[13]=C,f[14]=e.children,f[15]=e.leaf.marks,f[16]=e.renderAnnotation,f[17]=e.renderDecorator,f[18]=g.annotations,f[19]=g.decorators,f[20]=E,f[21]=u,f[22]=h}else u=f[21],h=f[22];if(x&&C&&e.renderChild){let t;if(f[23]!==x.children||f[24]!==e.leaf){let n;f[26]!==e.leaf?(n=t=>t._key===e.leaf._key,f[26]=e.leaf,f[27]=n):n=f[27],t=x.children.find(n),f[23]=x.children,f[24]=e.leaf,f[25]=t}else t=f[25];let n=t;if(n){let t;f[28]!==u||f[29]!==n||f[30]!==h||f[31]!==o||f[32]!==C||f[33]!==e.renderChild||f[34]!==k||f[35]!==E?(t=(0,i.jsx)(rY,{renderChild:e.renderChild,annotations:u,editorElementRef:v,focused:o,path:C,schemaType:k,selected:E,value:n,children:h}),f[28]=u,f[29]=n,f[30]=h,f[31]=o,f[32]=C,f[33]=e.renderChild,f[34]=k,f[35]=E,f[36]=t):t=f[36],h=t}}return f[37]!==h||f[38]!==e.attributes?(p=(0,i.jsx)("span",{...e.attributes,ref:v,children:h}),f[37]=h,f[38]=e.attributes,f[39]=p):p=f[39],p}function rH(e){return e.name}function rG(e){return e.context.schema}function rJ({renderAnnotation:e,block:t,children:n,editorElementRef:r,focused:o,path:a,schemaType:i,selected:l,value:s}){return e({block:t,children:n,editorElementRef:r,focused:o,path:a,schemaType:i,selected:l,value:s})}function rZ({renderDecorator:e,children:t,editorElementRef:n,focused:r,path:o,schemaType:a,selected:i,value:l}){return e({children:t,editorElementRef:n,focused:r,path:o,schemaType:a,selected:i,value:l})}function rY({renderChild:e,annotations:t,children:n,editorElementRef:r,focused:o,path:a,schemaType:i,selected:l,value:s}){return e({annotations:t,children:n,editorElementRef:r,focused:o,path:a,schemaType:i,selected:l,value:s})}let rq={position:"absolute",userSelect:"none",pointerEvents:"none",left:0,right:0};function rX(e){let t,n=(0,l.c)(12),r=(0,c.useContext)(ro),o=(0,s.d4)(r,rQ);if(e.leaf._type!==o.span.name)return e.children;n[0]!==e?(t=(0,i.jsx)(rW,{...e}),n[0]=e,n[1]=t):t=n[1];let a=t;if(e.renderPlaceholder&&e.leaf.placeholder&&""===e.text.text){let t,r,o;return n[2]!==e.renderPlaceholder?(t=e.renderPlaceholder(),n[2]=e.renderPlaceholder,n[3]=t):t=n[3],n[4]!==t?(r=(0,i.jsx)("span",{style:rq,contentEditable:!1,
13children:t}),n[4]=t,n[5]=r):r=n[5],n[6]!==a||n[7]!==r?(o=(0,i.jsxs)(i.Fragment,{children:[r,a]}),n[6]=a,n[7]=r,n[8]=o):o=n[8],o}let u=e.leaf.rangeDecoration;if(u){let e;n[9]!==u||n[10]!==a?(e=u.component({children:a}),n[9]=u,n[10]=a,n[11]=e):e=n[11],a=e}return a}function rQ(e){return e.context.schema}function r0(e){let t,n=(0,l.c)(5);return n[0]!==e.attributes||n[1]!==e.children||n[2]!==e.text._key||n[3]!==e.text._type?(t=(0,i.jsx)("span",{...e.attributes,"data-child-key":e.text._key,"data-child-name":e.text._type,"data-child-type":"span",children:e.children}),n[0]=e.attributes,n[1]=e.children,n[2]=e.text._key,n[3]=e.text._type,n[4]=t):t=n[4],t}function r1(e){return{id:(0,h.OL)(),name:e?.name,reference:e?.reference}}let r2=r1({name:"core"});function r3({eventSelection:e,snapshot:t}){let n=e;if((0,p.Rt)({...t,context:{...t.context,selection:e}}))return n;let r=(0,p.WV)({context:{...t.context,selection:e}}),o=(0,p.hH)({...t,context:{...t.context,selection:e}}),a=(0,p.d2)({...t,context:{...t.context,selection:e}});r&&o&&a&&(n={anchor:(0,h.u3)({context:t.context,block:o}),focus:(0,h.J8)({context:t.context,block:o})});let i=(0,p.wx)(t);if(t.context.selection&&(0,p.gR)(t)&&i.length>1){let r=(0,p.GB)(t),o=(0,p.P$)(t);if(!r||!o)return n;let a=(0,h.u3)({context:t.context,block:r}),i=(0,h.J8)({context:t.context,block:o});(0,p.Q)(e)({...t,context:{...t.context,selection:{anchor:a,focus:i}}})&&(n={anchor:a,focus:i})}return n}let r4=(0,c.createContext)(null),r8=()=>{let e=(0,c.useContext)(r4);if(!e)throw Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");return e};function r5(e,t){var n,r;let o=(n=e,en(r=t)?r:et(r)?{anchor:r,focus:r}:{anchor:ep(n,r),focus:ta(n,r)}),{selection:a}=e;if(a){let t={},n={};null==o.anchor||eC(o.anchor,a.anchor)||(t.anchor=a.anchor,n.anchor=o.anchor),null==o.focus||eC(o.focus,a.focus)||(t.focus=a.focus,n.focus=o.focus),Object.keys(t).length>0&&e.apply({type:"set_selection",properties:t,newProperties:n})}else e.apply({type:"set_selection",properties:null,newProperties:o})}function r7(e){let{selection:t}=e;t&&e.apply({type:"set_selection",properties:t,newProperties:null})}let r9=(0,v.mj)({types:{context:{},input:{},events:{}},guards:{"pending operations":({context:e})=>e.slateEditor.operations.length>0}}),r6=r9.createAction(({context:e,event:t})=>{!function(e,t){let n;if(!e.selection)return;try{n=eN.findDocumentOrShadowRoot(e)}catch{}if(!n||t!==n.activeElement)return;let r=eN.getWindow(e).getSelection();if(!r||0===r.rangeCount)return;let o=r.getRangeAt(0);try{let t=eN.toDOMRange(e,e.selection);(t.startOffset!==o.startOffset||t.endOffset!==o.endOffset)&&(P.selection("DOM range out of sync, validating selection"),r?.removeAllRanges(),r.addRange(t))}catch{P.selection("Could not resolve selection, selecting top document"),r7(e),e.children.length>0&&r5(e,ep(e,[])),e.onChange()}}(e.slateEditor,t.editorElement)}),oe=r9.createMachine({id:"validate selection",context:({input:e})=>({slateEditor:e.slateEditor}),initial:"idle",states:{idle:{on:{"validate selection":[{guard:"pending operations",target:"waiting"},{actions:[r6],target:"idle"}]}},waiting:{after:{0:[{guard:"pending operations",target:".",reenter:!0},{target:"idle",actions:[r6]}]},on:{"validate selection":{target:".",reenter:!0}}}}}),ot=(0,c.forwardRef)(function(e,t){let n,r,o,a,u,d,f,y,m,v,k,b,x,C,E,D,_,w,A,S,F,O,M,T,R,z,I,N,$,K,L,V,U,W,H,G,J,Z,Y,q,X,Q,ee,et,en,er,eo,ea,ei,el,es,ec,eu,ed,eh,ef,ey,em,eg,ev,ek,eb,ex,eC,eB=(0,l.c)(181);eB[0]!==e?({hotkeys:n,onBlur:o,onFocus:C,onBeforeInput:r,onPaste:E,onCopy:u,onCut:d,onClick:a,onDragStart:b,onDrag:f,onDragEnd:y,onDragEnter:m,onDragOver:k,onDrop:x,onDragLeave:v,rangeDecorations:_,renderAnnotation:w,renderBlock:A,renderChild:S,renderDecorator:F,renderListItem:O,renderPlaceholder:M,renderStyle:T,selection:D,scrollSelectionIntoView:z,spellCheck:I,...R}=e,eB[0]=e,eB[1]=n,eB[2]=r,eB[3]=o,eB[4]=a,eB[5]=u,eB[6]=d,eB[7]=f,eB[8]=y,eB[9]=m,eB[10]=v,eB[11]=k,eB[12]=b,eB[13]=x,eB[14]=C,eB[15]=E,eB[16]=D,eB[17]=_,eB[18]=w,eB[19]=A,eB[20]=S,eB[21]=F,eB[22]=O,eB[23]=M,eB[24]=T,eB[25]=R,eB[26]=z,eB[27]=I):(n=eB[1],r=eB[2],o=eB[3],a=eB[4],u=eB[5],d=eB[6],f=eB[7],y=eB[8],m=eB[9],v=eB[10],k=eB[11],b=eB[12],x=eB[13],C=eB[14],E=eB[15],D=eB[16],_=eB[17],w=eB[18],A=eB[19],S=eB[20],F=eB[21],O=eB[22],M=eB[23],T=eB[24],R=eB[25],z=eB[26],I=eB[27]);let eE=r8(),[eD,e_]=(0,c.useState)(!1),ew=(0,c.useContext)(ro),eA=(0,c.useContext)(rE),eS=(0,s.d4)(ew,or),eF=n1();eB[28]!==eF?(N={input:{slateEditor:eF}},eB[28]=eF,eB[29]=N):N=eB[29];let eP=(0,s.qf)(oe,N);eB[30]!==_?($=_??[],eB[30]=_,eB[31]=$):$=eB[31],eB[32]!==ew?(K=ew.getSnapshot(),eB[32]=ew,eB[33]=K):K=eB[33];let eO=K.context.schema;eB[34]!==ew?(L=ew.getSnapshot().matches({setup:"setting up"}),eB[34]=ew,eB[35]=L):L=eB[35];let eM=!L;eB[36]!==eS||eB[37]!==eF||eB[38]!==$||eB[39]!==K.context.schema||eB[40]!==eM?(V={input:{rangeDecorations:$,readOnly:eS,schema:eO,slateEditor:eF,skipSetup:eM}},eB[36]=eS,eB[37]=eF,eB[38]=$,eB[39]=K.context.schema,eB[40]=eM,eB[41]=V):V=eB[41];let eT=(0,s.qf)(rC,V),eR=(0,s.d4)(eT,oo),ez=function(){let e,t,n=(0,l.c)(3),r=(0,c.useContext)(ro),[o,a]=(0,c.useState)();return n[0]!==r?(e=()=>{let e=function({setDropPosition:e}){return[{behavior:(0,B.Ke)({on:"drag.dragover",guard:({snapshot:e,event:t})=>{let n=(0,p.gU)({...e,context:{...e.context,selection:t.position.selection}});if(!n)return!1;let r=t.dragOrigin;if(!r)return!1;let o=r3({eventSelection:r.selection,snapshot:e});return!(0,p.wx)({...e,context:{...e.context,selection:o}}).some(e=>e.node._key===n.node._key)&&!!(0,p.iE)({...e,context:{...e.context,selection:o}})&&{dropFocusBlock:n}},actions:[({event:t},{dropFocusBlock:n})=>[{type:"effect",effect:()=>{e({blockKey:n.node._key,positionBlock:t.position.block})}}]]}),priority:r1({reference:{priority:r2,importance:"lower"}})},{behavior:(0,B.Ke)({on:"drag.*",guard:({event:e})=>"drag.dragover"!==e.type,actions:[({event:t})=>[{type:"effect",effect:()=>{e(void 0)}},(0,B.sY)(t)]]}),priority:r1({reference:{priority:r2,importance:"lower"}})}]}({setDropPosition:a});for(let t of e)r.send({type:"add behavior",behaviorConfig:t});return()=>{for(let t of e)r.send({type:"remove behavior",behaviorConfig:t})}}
13,t=[r,a],n[0]=r,n[1]=e,n[2]=t):(e=n[1],t=n[2]),(0,c.useEffect)(e,t),o}();eB[42]!==eT||eB[43]!==eS?(U=()=>{eT.send({type:"update read only",readOnly:eS})},W=[eT,eS],eB[42]=eT,eB[43]=eS,eB[44]=U,eB[45]=W):(U=eB[44],W=eB[45]),(0,c.useEffect)(U,W),eB[46]!==_||eB[47]!==eT?(G=()=>{eT.send({type:"range decorations updated",rangeDecorations:_??[]})},H=[eT,_],eB[46]=_,eB[47]=eT,eB[48]=H,eB[49]=G):(H=eB[48],G=eB[49]),(0,c.useEffect)(G,H),eB[50]!==ez||eB[51]!==eS||eB[52]!==A||eB[53]!==S||eB[54]!==O||eB[55]!==T||eB[56]!==I?(J=e=>(0,i.jsx)(rV,{...e,dropPosition:ez,readOnly:eS,renderBlock:A,renderChild:S,renderListItem:O,renderStyle:T,spellCheck:I}),eB[50]=ez,eB[51]=eS,eB[52]=A,eB[53]=S,eB[54]=O,eB[55]=T,eB[56]=I,eB[57]=J):J=eB[57];let eI=J;eB[58]!==eS||eB[59]!==w||eB[60]!==S||eB[61]!==F||eB[62]!==M?(Z=e=>(0,i.jsx)(rX,{...e,readOnly:eS,renderAnnotation:w,renderChild:S,renderDecorator:F,renderPlaceholder:M}),eB[58]=eS,eB[59]=w,eB[60]=S,eB[61]=F,eB[62]=M,eB[63]=Z):Z=eB[63];let ej=Z;eB[64]!==ew||eB[65]!==D||eB[66]!==eF?(Y=()=>{if(D){P.selection(`Selection from props ${j(D)}`);let e=function(e,t){if(!e||!t||0===t.length)return null;let n=null,r=null,{anchor:o,focus:a}=e;return o&&t.find(e=>(0,h.wE)(o.path[0])&&e._key===o.path[0]._key)&&(n=e6(o,t)),a&&t.find(e=>(0,h.wE)(a.path[0])&&e._key===a.path[0]._key)&&(r=e6(a,t)),n&&r?{anchor:n,focus:r,backward:e.backward}:null}(D,eF.children);if(null!==e){P.selection(`Normalized selection from props ${j(e)}`);let t=te({context:{schema:ew.getSnapshot().context.schema,value:eF.children,selection:e},blockIndexMap:eF.blockIndexMap});t&&(eF.select(t),eF.operations.some(oi)||ew.send({type:"update selection",selection:e}),eF.onChange())}}},eB[64]=ew,eB[65]=D,eB[66]=eF,eB[67]=Y):Y=eB[67];let e$=Y;eB[68]!==ew||eB[69]!==eT||eB[70]!==e$?(q=()=>{let e=ew.on("ready",()=>{eT.send({type:"ready"}),e$()}),t=ew.on("invalid value",()=>{e_(!0)}),n=ew.on("value changed",()=>{e_(!1)});return()=>{e.unsubscribe(),t.unsubscribe(),n.unsubscribe()}},X=[eT,ew,e$],eB[68]=ew,eB[69]=eT,eB[70]=e$,eB[71]=q,eB[72]=X):(q=eB[71],X=eB[72]),(0,c.useEffect)(q,X),eB[73]!==eD||eB[74]!==D||eB[75]!==e$?(Q=()=>{D&&!eD&&e$()},ee=[eD,D,e$],eB[73]=eD,eB[74]=D,eB[75]=e$,eB[76]=Q,eB[77]=ee):(Q=eB[76],ee=eB[77]),(0,c.useEffect)(Q,ee),eB[78]!==ew||eB[79]!==u||eB[80]!==eF?(et=e=>{if(eN.hasSelectableTarget(eF,e.target)){if(u)void 0!==u(e)&&e.preventDefault();else if(e.nativeEvent.clipboardData){e.stopPropagation(),e.preventDefault();let t=eF.selection?e5({schema:ew.getSnapshot().context.schema,editor:eF,range:eF.selection}):void 0,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for copy event");ew.send({type:"behavior event",behaviorEvent:{type:"clipboard.copy",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:eF,nativeEvent:e})}}},eB[78]=ew,eB[79]=u,eB[80]=eF,eB[81]=et):et=eB[81];let eK=et;eB[82]!==ew||eB[83]!==d||eB[84]!==eF?(en=e=>{if(eN.hasSelectableTarget(eF,e.target)){if(d)void 0!==d(e)&&e.preventDefault();else if(e.nativeEvent.clipboardData){e.stopPropagation(),e.preventDefault();let t=ew.getSnapshot().context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for cut event");ew.send({type:"behavior event",behaviorEvent:{type:"clipboard.cut",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:eF,nativeEvent:e})}}},eB[82]=ew,eB[83]=d,eB[84]=eF,eB[85]=en):en=eB[85];let eL=en;eB[86]!==ew||eB[87]!==E||eB[88]!==eE||eB[89]!==eA||eB[90]!==eF?(er=e=>{let t=eF.children,n=(eF.selection?e5({schema:ew.getSnapshot().context.schema,editor:eF,range:eF.selection}):null)?.focus.path||[],r=E?.({event:e,value:t,path:n,schemaTypes:eE.schemaTypes});if(r||!eF.selection)e.preventDefault(),eA.send({type:"loading"}),Promise.resolve(r).then(t=>{if(P.behaviors("Custom paste function from client resolved",t),t&&t.insert)t.insert?ew.send({type:"behavior event",behaviorEvent:{type:"insert.blocks",blocks:(0,h.SV)({context:{keyGenerator:ew.getSnapshot().context.keyGenerator,schema:ew.getSnapshot().context.schema},blocks:t.insert,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}}),placement:"auto"},editor:eF}):console.warn("Your onPaste function returned something unexpected:",t);else{P.behaviors("No result from custom paste handler, pasting normally");let t=ew.getSnapshot().context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for paste event");ew.send({type:"behavior event",behaviorEvent:{type:"clipboard.paste",originEvent:{dataTransfer:e.clipboardData},position:n},editor:eF,nativeEvent:e})}}).catch(ol).finally(()=>{eA.send({type:"done loading"})});else if(e.nativeEvent.clipboardData){e.preventDefault(),e.stopPropagation();let t=ew.getSnapshot().context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for paste event");ew.send({type:"behavior event",behaviorEvent:{type:"clipboard.paste",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:eF,nativeEvent:e})}P.behaviors("No result from custom paste handler, pasting normally")},eB[86]=ew,eB[87]=E,eB[88]=eE,eB[89]=eA,eB[90]=eF,eB[91]=er):er=eB[91];let eV=er;eB[92]!==ew||eB[93]!==C||eB[94]!==eA||eB[95]!==eF?(eo=e=>{C&&C(e),e.isDefaultPrevented()||(eA.send({type:"focused",event:e}
13),!eF.selection&&1===eF.children.length&&(0,g.wm)(ew.getSnapshot().context,eF.children.at(0))&&(eF.select(ep(eF,[])),eF.onChange()))},eB[92]=ew,eB[93]=C,eB[94]=eA,eB[95]=eF,eB[96]=eo):eo=eB[96];let eU=eo;eB[97]!==ew||eB[98]!==a||eB[99]!==eF?(ea=e=>{if(a&&a(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=e9({editorActor:ew,slateEditor:eF,event:e.nativeEvent});t&&ew.send({type:"behavior event",behaviorEvent:{type:"mouse.click",position:t},editor:eF,nativeEvent:e})},eB[97]=ew,eB[98]=a,eB[99]=eF,eB[100]=ea):ea=eB[100];let eW=ea;eB[101]!==o||eB[102]!==eA?(ei=e=>{o&&o(e),e.isPropagationStopped()||eA.send({type:"blurred",event:e})},eB[101]=o,eB[102]=eA,eB[103]=ei):ei=eB[103];let eH=ei;eB[104]!==r?(el=e=>{r&&r(e)},eB[104]=r,eB[105]=el):el=eB[105];let eG=el;eB[106]!==ew||eB[107]!==n||eB[108]!==eE||eB[109]!==e||eB[110]!==eF?(es=t=>{e.onKeyDown&&e.onKeyDown(t),t.isDefaultPrevented()||function({editorActor:e,editor:t,portableTextEditor:n,hotkeys:r,event:o}){e.getSnapshot().matches({"edit mode":"read only"})||Object.keys(r).forEach(a=>{var i,l;if("marks"===a)for(let n in r[a]){if(rh.includes(n))throw Error(`The hotkey ${n} is reserved!`);if(i=o.nativeEvent,ru(rc(n),i)){o.preventDefault();let i=r[a];if(i){let r=i[n];r&&e.send({type:"behavior event",behaviorEvent:{type:"decorator.toggle",decorator:r},editor:t})}}}if("custom"===a)for(let e in r[a]){if(rh.includes(e))throw Error(`The hotkey ${e} is reserved!`);if(l=o.nativeEvent,ru(rc(e),l)){let t=r[a];if(t){let r=t[e];r&&r(o,n)}}}})}({editorActor:ew,editor:eF,portableTextEditor:eE,hotkeys:n??{},event:t}),t.isDefaultPrevented()||ew.send({type:"behavior event",behaviorEvent:{type:"keyboard.keydown",originEvent:{key:t.key,code:t.code,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey}},editor:eF,nativeEvent:t})},eB[106]=ew,eB[107]=n,eB[108]=eE,eB[109]=e,eB[110]=eF,eB[111]=es):es=eB[111];let eJ=es;eB[112]!==ew||eB[113]!==e||eB[114]!==eF?(ec=t=>{e.onKeyUp&&e.onKeyUp(t),t.isDefaultPrevented()||ew.send({type:"behavior event",behaviorEvent:{type:"keyboard.keyup",originEvent:{key:t.key,code:t.code,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey}},editor:eF,nativeEvent:t})},eB[112]=ew,eB[113]=e,eB[114]=eF,eB[115]=ec):ec=eB[115];let eZ=ec;e:{let e;if(void 0===z){eu=void 0;break e}if(null===z){eu=on;break e}eB[116]!==eE||eB[117]!==z?(e=(e,t)=>{z(eE,t)},eB[116]=eE,eB[117]=z,eB[118]=e):e=eB[118],eu=e}let eY=eu;eB[119]!==ew||eB[120]!==eF?(ed=()=>{let e=eN.getWindow(eF),t=()=>{ew.send({type:"dragend"})},n=()=>{ew.send({type:"drop"})};return e.document.addEventListener("dragend",t),e.document.addEventListener("drop",n),()=>{e.document.removeEventListener("dragend",t),e.document.removeEventListener("drop",n)}},eh=[eF,ew],eB[119]=ew,eB[120]=eF,eB[121]=ed,eB[122]=eh):(ed=eB[121],eh=eB[122]),(0,c.useEffect)(ed,eh),eB[123]!==ew||eB[124]!==b||eB[125]!==eS||eB[126]!==eF?(ef=e=>{if(eS||!eN.hasTarget(eF,e.target)||(b?.(e),e.isDefaultPrevented()||e.isPropagationStopped()))return;let t=e9({editorActor:ew,slateEditor:eF,event:e.nativeEvent});return t?(ew.send({type:"dragstart",origin:t}),ew.send({type:"behavior event",behaviorEvent:{type:"drag.dragstart",originEvent:{clientX:e.clientX,clientY:e.clientY,dataTransfer:e.dataTransfer},position:t},editor:eF}),!0):void console.warn("Could not find position for dragstart event")},eB[123]=ew,eB[124]=b,eB[125]=eS,eB[126]=eF,eB[127]=ef):ef=eB[127];let eq=ef;eB[128]!==ew||eB[129]!==f||eB[130]!==eF?(ey=e=>{if(f?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()||!e9({editorActor:ew,slateEditor:eF,event:e.nativeEvent})))return ew.send({type:"behavior event",behaviorEvent:{type:"drag.drag",originEvent:{dataTransfer:e.dataTransfer}},editor:eF}),!0},eB[128]=ew,eB[129]=f,eB[130]=eF,eB[131]=ey):ey=eB[131];let eX=ey;eB[132]!==ew||eB[133]!==y||eB[134]!==eF?(em=e=>{if(y?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()))return ew.send({type:"behavior event",behaviorEvent:{type:"drag.dragend",originEvent:{dataTransfer:e.dataTransfer}},editor:eF}),!0},eB[132]=ew,eB[133]=y,eB[134]=eF,eB[135]=em):em=eB[135];let eQ=em;eB[136]!==ew||eB[137]!==m||eB[138]!==eF?(eg=e=>{if(m?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=e9({editorActor:ew,slateEditor:eF,event:e.nativeEvent});if(t)return ew.send({type:"behavior event",behaviorEvent:{type:"drag.dragenter",originEvent:{dataTransfer:e.dataTransfer},position:t},editor:eF}),!0},eB[136]=ew,eB[137]=m,eB[138]=eF,eB[139]=eg):eg=eB[139];let e0=eg;eB[140]!==ew||eB[141]!==k||eB[142]!==eF?(ev=e=>{if(k?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=e9({editorActor:ew,slateEditor:eF,event:e.nativeEvent});if(t)return ew.send({type:"behavior event",behaviorEvent:{type:"drag.dragover",originEvent:{dataTransfer:e.dataTransfer}
13,dragOrigin:ew.getSnapshot().context.internalDrag?.origin,position:t},editor:eF,nativeEvent:e}),!0},eB[140]=ew,eB[141]=k,eB[142]=eF,eB[143]=ev):ev=eB[143];let e1=ev;eB[144]!==ew||eB[145]!==x||eB[146]!==eF?(ek=e=>{if(x?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=e9({editorActor:ew,slateEditor:eF,event:e.nativeEvent});return t?(ew.send({type:"behavior event",behaviorEvent:{type:"drag.drop",originEvent:{dataTransfer:e.dataTransfer},dragOrigin:ew.getSnapshot().context.internalDrag?.origin,position:t},editor:eF,nativeEvent:e}),!0):void console.warn("Could not find position for drop event")},eB[144]=ew,eB[145]=x,eB[146]=eF,eB[147]=ek):ek=eB[147];let e2=ek;eB[148]!==ew||eB[149]!==v||eB[150]!==eF?(eb=e=>{if(v?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()||!e9({editorActor:ew,slateEditor:eF,event:e.nativeEvent})))return ew.send({type:"behavior event",behaviorEvent:{type:"drag.dragleave",originEvent:{dataTransfer:e.dataTransfer}},editor:eF}),!0},eB[148]=ew,eB[149]=v,eB[150]=eF,eB[151]=eb):eb=eB[151];let e3=eb;eB[152]!==t||eB[153]!==eP?(ex=e=>{if("function"==typeof t?t(e):t&&(t.current=e),e){let t=new MutationObserver(()=>{eP.send({type:"validate selection",editorElement:e})});return t.observe(e,{attributeOldValue:!1,attributes:!1,characterData:!1,childList:!0,subtree:!0}),()=>{t.disconnect()}}},eB[152]=t,eB[153]=eP,eB[154]=ex):ex=eB[154];let e4=ex;return eE?(eB[155]!==e4||eB[156]!==eR||eB[157]!==ew||eB[158]!==eW||eB[159]!==eK||eB[160]!==eL||eB[161]!==eX||eB[162]!==eQ||eB[163]!==e0||eB[164]!==e3||eB[165]!==e1||eB[166]!==eq||eB[167]!==e2||eB[168]!==eJ||eB[169]!==eZ||eB[170]!==eG||eB[171]!==eH||eB[172]!==eU||eB[173]!==eV||eB[174]!==eD||eB[175]!==eS||eB[176]!==eI||eB[177]!==ej||eB[178]!==R||eB[179]!==eY?(eC=eD?null:(0,i.jsx)(rO,{children:(0,i.jsx)(n5,{...R,ref:e4,editorActor:ew,"data-read-only":eS,autoFocus:!1,className:R.className||"pt-editable",decorate:eR,onBlur:eH,onCopy:eK,onCut:eL,onClick:eW,onDOMBeforeInput:eG,onDragStart:eq,onDrag:eX,onDragEnd:eQ,onDragEnter:e0,onDragOver:e1,onDrop:e2,onDragLeave:e3,onFocus:eU,onKeyDown:eJ,onKeyUp:eZ,onPaste:eV,readOnly:eS,renderPlaceholder:void 0,renderElement:eI,renderLeaf:ej,renderText:oa,scrollSelectionIntoView:eY})}),eB[155]=e4,eB[156]=eR,eB[157]=ew,eB[158]=eW,eB[159]=eK,eB[160]=eL,eB[161]=eX,eB[162]=eQ,eB[163]=e0,eB[164]=e3,eB[165]=e1,eB[166]=eq,eB[167]=e2,eB[168]=eJ,eB[169]=eZ,eB[170]=eG,eB[171]=eH,eB[172]=eU,eB[173]=eV,eB[174]=eD,eB[175]=eS,eB[176]=eI,eB[177]=ej,eB[178]=R,eB[179]=eY,eB[180]=eC):eC=eB[180],eC):null});function on(){}function or(e){return e.matches({"edit mode":"read only"})}function oo(e){return e.context.decorate?.fn}function oa(e){return(0,i.jsx)(r0,{...e})}function oi(e){return"set_selection"===e.type}function ol(e){return console.warn(e),e}ot.displayName="ForwardRef(PortableTextEditable)";let os=(e,t)=>{t(e);let n=e.getSnapshot().children;n&&Object.values(n).forEach(e=>{os(e,t)})};function oc(e){let t=[];os(e,e=>{t.push([e,e.getSnapshot()]),e.observers=new Set});let n=e.system.getSnapshot?.();e.stop(),e.system._snapshot=n,t.forEach(([e,t])=>{e._processingStatus=0,e._snapshot=t})}let ou=e=>{let t,n,r,o,a,{editor:l,children:s}=e,{selectorContext:u,onChange:d}=(t=(0,c.useRef)(new Set),n=(0,c.useRef)(new Set),r=(0,c.useCallback)(()=>{t.current.forEach(e=>{e()})},[]),o=(0,c.useCallback)(()=>{n.current.forEach(e=>{e()}),n.current.clear()},[]),a=(0,c.useCallback)(e=>(t.current.add(e),()=>{t.current.delete(e)}),[]),{selectorContext:(0,c.useMemo)(()=>({addEventListener:a,flushDeferred:o}),[a,o]),onChange:r}),h=(0,c.useCallback)(()=>{d()},[l,d]);return(0,c.useEffect)(()=>(l.onContextChange=h,()=>{l.onContextChange=()=>{}}),[l,h]),(0,i.jsx)(n0.Provider,{value:u,children:(0,i.jsx)(nn.Provider,{value:l,children:s})})},od={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},oh=[{mimeType:"application/json",serialize:({snapshot:e,event:t})=>{let n=e.context.converters.find(e=>"application/x-portable-text"===e.mimeType);return n?{...n.serialize({snapshot:e,event:t}),mimeType:"application/json",originEvent:t.originEvent}:{type:"serialization.failure",mimeType:"application/json",originEvent:t.originEvent,reason:"No application/x-portable-text Converter found"}},deserialize:({snapshot:e,event:t})=>{let n=e.context.converters.find(e=>"application/x-portable-text"===e.mimeType);return n?{...n.deserialize({snapshot:e,event:t}),mimeType:"application/json"}:{type:"deserialization.failure",mimeType:"application/json",reason:"No application/x-portable-text Converter found"}}},{mimeType:"application/x-portable-text",serialize:({snapshot:e,event:t})=>{if(!e.context.selection)return{type:"serialization.failure",mimeType:"application/x-portable-text",originEvent:t.originEvent,reason:"No selection"};let n=(0,p.lN)(e);return 0===n.length?{type:"serialization.failure",mimeType:"application/x-portable-text",reason:"No blocks serialized",originEvent:t.originEvent}:{type:"serialization.success",data:j(n),mimeType:"application/x-portable-text",originEvent:t.originEvent}},deserialize:({snapshot:e,event:t})=>{let n=function(e){try{return JSON.parse(e)}catch(e){return console.error(e),"JSON.parse failed"}}(t.data);if(!Array.isArray(n))return{type:"deserialization.failure",mimeType:"application/x-portable-text",reason:"Data is not an array"};let r=n.flatMap(t=>{let n=(0,h.rT)({context:e.context,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return n?[n]:[]});return 0===r.length&&n.length>0?{type:"deserialization.failure",mimeType:"application/x-portable-text",reason:"No blocks were parsed"}:{type:"deserialization.success",data:r,mimeType:"application/x-portable-text"}}},{mimeType:"text/markdown",serialize:({snapshot:e,event:t})=>{if(!e.context.selection)return{type:"serialization.failure",mimeType:"text/markdown",reason:"No selection",originEvent:t.originEvent};let n=(0,p.lN)(e);return{type:"serialization.success",data:(0,_.xk)(n),mimeType:"text/markdown",originEvent:t.originEvent}},deserialize:({snapshot:e,event:t})=>{let n=(0,_.XB)(t.data,{keyGenerator:e.context.keyGenerator,schema:e.context.schema}).flatMap(t=>{let n=(0,h.rT)({context:e.context,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return n?[n]:[]});return 0===n.length?{type:"deserialization.failure",mimeType:"text/markdown",reason:"No blocks de
13serialized"}:{type:"deserialization.success",data:n,mimeType:"text/markdown"}}},{mimeType:"text/html",serialize:({snapshot:e,event:t})=>{if(!e.context.selection)return{type:"serialization.failure",mimeType:"text/html",originEvent:t.originEvent,reason:"No selection"};let n=(0,p.lN)(e),r=(0,D.FE)(n,{onMissingComponent:!1,components:{unknownType:({children:e})=>void 0!==e?`${e}`:""}});return""===r?{type:"serialization.failure",mimeType:"text/html",originEvent:t.originEvent,reason:"Serialized HTML is empty"}:{type:"serialization.success",data:r,mimeType:"text/html",originEvent:t.originEvent}},deserialize:({snapshot:e,event:t})=>{let n=(0,E.$R)(t.data,{schema:e.context.schema,keyGenerator:e.context.keyGenerator}).flatMap(t=>{let n=(0,h.rT)({context:e.context,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return n?[n]:[]});return 0===n.length?{type:"deserialization.failure",mimeType:"text/html",reason:"No blocks deserialized"}:{type:"deserialization.success",data:n,mimeType:"text/html"}}},{mimeType:"text/plain",serialize:({snapshot:e,event:t})=>e.context.selection?{type:"serialization.success",data:(0,p.lN)(e).map(n=>(0,d.zS)(e.context,n)?n.children.map(n=>n._type===e.context.schema.span.name?n.text:"drag.dragstart"===t.originEvent?`[${e.context.schema.inlineObjects.find(e=>e.name===n._type)?.title??"Object"}]`:"").join(""):"drag.dragstart"===t.originEvent?`[${e.context.schema.blockObjects.find(e=>e.name===n._type)?.title??"Object"}]`:"").filter(e=>""!==e).join(` 14 15`),mimeType:"text/plain",originEvent:t.originEvent}:{type:"serialization.failure",mimeType:"text/plain",originEvent:t.originEvent,reason:"No selection"},deserialize:({snapshot:e,event:t})=>{let n=`<html><body>${String(t.data).replace(/[&<>"'`=/]/g,e=>od[e]??e).split(/\n{2,}/).map(e=>e?`<p>${e.replace(/(?:\r\n|\r|\n)/g,"<br/>")}</p>`:"<p></p>").join("")}</body></html>`,r=(0,E.$R)(n,{schema:e.context.schema,keyGenerator:e.context.keyGenerator}).flatMap(t=>{let n=(0,h.rT)({context:e.context,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return n?[n]:[]});return 0===r.length?{type:"deserialization.failure",mimeType:"text/plain",reason:"No blocks deserialized"}:{type:"deserialization.success",data:r,mimeType:"text/plain"}}}];function op(e,t){let n=U(e,t);if(n&&(0,d.zS)({schema:e.schema},n.node))return{node:n.node,path:n.path}}let of=new Map;function oy(e,{blockIndexMap:t,listIndexMap:n}){let r;t.clear(),n.clear(),of.clear();for(let o=0;o<e.value.length;o++){let a=e.value.at(o);if(void 0===a)continue;if(t.set(a._key,o),!(0,p.xN)(e,a)||void 0===a.listItem||void 0===a.level){of.clear(),r=void 0;continue}if(!r||r.listItem===a.listItem&&r.level<a.level){let e=of.get(a.listItem)??new Map;e.set(a.level,1),of.set(a.listItem,e),n.set(a._key,1),r={listItem:a.listItem,level:a.level};continue}of.forEach((e,t)=>{if(t===a.listItem)return;let n=[];e.forEach((e,t)=>{t>=a.level&&n.push(t)}),n.forEach(t=>{e.delete(t)})});let i=of.get(a.listItem)??new Map,l=i.get(a.level)??0;i.set(a.level,l+1),of.set(a.listItem,i),n.set(a._key,l+1),r={listItem:a.listItem,level:a.level}}}function om(e){return{_type:e.schema.block.name,_key:e.keyGenerator(),style:e.schema.styles[0]?.name??"normal",markDefs:[],children:[{_type:e.schema.span.name,_key:e.keyGenerator(),text:"",marks:[]}]}}function og(e,t,n){let r=null===n.selection?[t]:[{type:"set_selection",properties:{...n.selection},newProperties:{...n.selection}},t];return e.push({operations:r,timestamp:new Date}),e}function ov(e,t,n){return t.operations.push(n),e}function ok(e,t,n){return eC(t,ta(e,n))}function ob(e,t,n){return 0===t.offset&&eC(t,ep(e,n))}function ox(e,t,n){return ob(e,t,n)||ok(e,t,n)}function oC(e,t,n={}){let{affinity:r="forward"}=n,o={current:t,affinity:r,unref(){let{current:t}=o;return e.pathRefs.delete(o),o.current=null,t}};return e.pathRefs.add(o),o}function oB(e){return e.normalizing}function oE(e,t={}){let{force:n=!1,operation:r}=t,o=e=>e.dirtyPaths,a=e=>{let t=o(e).pop(),n=1===t.length?String(t[0]):2===t.length?`${t[0]},${t[1]}`:t.join(",");return e.dirtyPathKeys.delete(n),t};if(oB(e)){if(n){let t=Array.from(ey(e),e=>e.path),n=new Set(t.map(e=>e.join(",")));e.dirtyPaths=t,e.dirtyPathKeys=n}0!==o(e).length&&o_(e,()=>{for(let t of o(e))if(0!==t.length&&Z(e,t)){let n=U(e,t);if(!n)continue;let o=n.node;(0,d.zS)({schema:e.schema},o)&&0===o.children.length&&e.normalizeNode([n.node,n.path],{operation:r})}let t=o(e),n=t.length,i=0;for(;0!==t.length;){if(!e.shouldNormalize({dirtyPaths:t,iteration:i,initialDirtyPathsLength:n,operation:r}))return;let l=a(e);if(0===l.length)e.normalizeNode([e,l],{operation:r});else if(Z(e,l)){let t=U(e,l);t&&e.normalizeNode([t.node,t.path],{operation:r})}i++,t=o(e)}})}}function oD(e,t){e.normalizing=t}function o_(e,t){let n=oB(e);oD(e,!1);try{t()}finally{oD(e,n)}oE(e)}function ow(e,t,n){let r=U(e,t);if(!r)return;let o=r.node;for(let r of e.pathRefs){let e=r.current;e&&(r.current=oA(e,t,n,r.affinity??"forward"))}for(let r of e.pointRefs){let e=r.current;e&&(r.current=oS(e,t,n,r.affinity??"forward"))}for(let r of e.rangeRefs){let e=r.current;if(e){let[o,a]=function(e,t){if("inward"===t){let t=eB(e);if(ea(e)){let e="backward";return[e,t?e:"forward"]}{let e="forward";return[e,t?e:"backward"]}}return"outward"===t?ea(e)?["forward","backward"]:["backward","forward"]:[t,t]}(e,r.affinity),i=oS(e.anchor,t,n,o??"forward"),l=oS(e.focus,t,n,a??"forward");i&&l?r.current={anchor:i,focus:l}:(r.current=null,r.unref())}}if(e.selection){let r=oS(e.selection.anchor,t,n,"forward"),o=oS(e.selection.focus,t,n,"forward");r&&o&&(e.selection={anchor:r,focus:o})}let a=new Set(e.pathRefs),i=new Set(e.pointRefs),l=new Set(e.rangeRefs);e.pathRefs.clear(),e.pointRefs.clear(),e.rangeRefs.clear();let s=e.selection;try{o_(e,()=>{if((0,d.bl)({schema:e.schema},o)){let{text:r,...a}=o,i=o.text.slice(n),l={...a,text:i};e.apply({type:"remove_text",path:t,offset:n,text:i}),e.apply({type:"insert_node",path:na(t),node:l})}else if((0,d.zS)({schema:e.schema},o)){let{children:r,...a}=o,i=o.children,l=i.slice(n),s={...a,children:l};for(let r=i.length-1;r>=n;r--)e.apply({type:"remove_node",path:[...t,r],node:i[r]});e.apply({type:"insert_node",path:na(t),node:s})}})}finally{for(let t of(e.selection=s,a))e.pathRefs.add(t);for(let t of i)e.pointRefs.add(t);for(let t of l)e.rangeRefs.add(t)}}function oA(e,t,n,r="forward"){let o=[...e];return ex(t,o)?"forward"===r&&(o[o.length-1]=o[o.length-1]+1):ni(t,o)?o[t.length-1]=o[t.length-1]+1:ti(t,o)&&e[t.length]>=n&&(o[t.length-1]=o[t.length-1]+1,o[t.length]=o[t.length]-n),o}function oS(e,t,n,r="forward"){let{path:o,offset:a}=e;return ex(t,o)?(n<a||n===a&&"forward"===r)&&(a-=n,o=oA(o,t,n,"forward")):o=oA(o,t,n,r),{path:o,offset:a}}function oF(e,t,n){e.apply({type:"insert_node",path:n,node:t});let r=ta(e,n);r&&r5(e,r)}function oP(e,t,n){o_(e,()=>{let r=(0,d.bl)({schema:e.schema},t)?t=>(0,d.bl)({schema:e.schema},t):t=>(0,d.bl)({schema:e.schema},t)||T({schema:e.schema},t),o=U(e,n.path),a=o&&r(o.node)?o:void 0;if(!a)return;let i=a.path,l=oC(e,i),s=ok(e,n,i);ox(e,n,i)||ow(e,n.path,n.offset);let c=l.unref(),u=s?na(c):c;e.apply({type:"insert_node",path:u,node:t});let h=ta(e,u);h&&r5(e,h)})}function oO(e){if(0===e.length)throw Error(`Cannot get the previous path of a root path [${e}], because it has no previous index.`);let t=e[e.length-1];if(t<=0)throw Error(`Cannot get the previous path of a first child path [${e}
15] because it would result in a negative index.`);return e.slice(0,-1).concat(t-1)}function oM(e,t,n){let r=U(e,t);if(!r)return;let o=r.node,a=oO(t);for(let r of e.pathRefs){let e=r.current;e&&(r.current=oT(e,t,n))}for(let r of e.pointRefs){let e=r.current;e&&(r.current=oR(e,t,n))}for(let r of e.rangeRefs){let e=r.current;if(e){let o=oR(e.anchor,t,n),a=oR(e.focus,t,n);o&&a?r.current={anchor:o,focus:a}:(r.current=null,r.unref())}}if(e.selection){let r=oR(e.selection.anchor,t,n),o=oR(e.selection.focus,t,n);r&&o&&(e.selection={anchor:r,focus:o})}let i=new Set(e.pathRefs),l=new Set(e.pointRefs),s=new Set(e.rangeRefs);e.pathRefs.clear(),e.pointRefs.clear(),e.rangeRefs.clear();let c=e.selection,u=e.pendingDiffs,h=e.pendingSelection,p=e.pendingAction;if(Array.isArray(u)&&u.length>0&&(e.pendingDiffs=u.map(e=>(function(e,t,n){let{path:r,diff:o,id:a}=e;if(!ex(t,r)){let e=oT(r,t,n);return e?{diff:o,id:a,path:e}:null}return{diff:{start:o.start+n,end:o.end+n,text:o.text},id:a,path:oT(r,t,n)}})(e,t,n)).filter(Boolean)),h&&"object"==typeof h&&"anchor"in h&&"focus"in h){let r=oR(h.anchor,t,n),o=oR(h.focus,t,n);e.pendingSelection=r&&o?{anchor:r,focus:o}:null}if(p&&"object"==typeof p&&"at"in p){if("offset"in p.at&&"number"==typeof p.at.offset){let r=oR(p.at,t,n);e.pendingAction=r?{...p,at:r}:null}else if(en(p.at)){let r=oR(p.at.anchor,t,n),o=oR(p.at.focus,t,n);e.pendingAction=r&&o?{...p,at:{anchor:r,focus:o}}:null}}let f=e.pendingDiffs,y=e.pendingSelection,m=e.pendingAction;e.pendingDiffs=[],e.pendingSelection=null,e.pendingAction=null;try{o_(e,()=>{if((0,d.bl)({schema:e.schema},o))o.text.length>0&&e.apply({type:"insert_text",path:a,offset:n,text:o.text}),e.apply({type:"remove_node",path:t,node:o});else if((0,d.zS)({schema:e.schema},o)){for(let t=0;t<o.children.length;t++)e.apply({type:"insert_node",path:[...a,n+t],node:o.children[t]});e.apply({type:"remove_node",path:t,node:o})}})}finally{for(let t of(e.selection=c,i))e.pathRefs.add(t);for(let t of l)e.pointRefs.add(t);for(let t of s)e.rangeRefs.add(t);e.pendingDiffs=f,e.pendingSelection=y,e.pendingAction=m}}function oT(e,t,n){let r=[...e];return ex(t,r)||ni(t,r)?r[t.length-1]=r[t.length-1]-1:ti(t,r)&&(r[t.length-1]=r[t.length-1]-1,r[t.length]=r[t.length]+n),r}function oR(e,t,n){let{path:r,offset:o}=e;return ex(t,r)&&(o+=n),{path:r=oT(r,t,n),offset:o}}function oz(e,t,n){let r=U(e,n);if(!r)return;let o=r.node,a={},i={};for(let n of Object.keys(t))"children"!==n&&("text"===n&&(0,p.JS)({schema:e.schema},o)||t[n]!==o[n]&&(o.hasOwnProperty(n)&&(a[n]=o[n]),null!=t[n]&&(i[n]=t[n])));(Object.keys(i).length>0||Object.keys(a).length>0)&&e.apply({type:"set_node",path:n,properties:a,newProperties:i})}function oI(e,t){let n=e.isNormalizingNode;e.isNormalizingNode=!0,t(),e.isNormalizingNode=n}function oj(e,t){let n=e.isPatching;e.isPatching=!1,t(),e.isPatching=n}function oN(e){let[t,n]=e;return[t,n]}function o$(e,t){let n=e,r=t,o=n.length,a=r.length;if(0===o||0===a)return 0;o>a?n=n.substring(o-a):o<a&&(r=r.substring(0,o));let i=Math.min(o,a);if(n===r)return i;let l=0,s=1;for(let e=0;-1!==e;){let t=n.substring(i-s);if(-1===(e=r.indexOf(t)))break;s+=e,(0===e||n.substring(i-s)===r.substring(0,s))&&(l=s,s++)}return l}function oK(e,t){if(!e||!t||e[0]!==t[0])return 0;let n=0,r=Math.min(e.length,t.length),o=r,a=0;for(;n<o;)e.substring(a,o)===t.substring(a,o)?a=n=o:r=o,o=Math.floor((r-n)/2+n);return o}function oL(e,t){if(!e||!t||e[e.length-1]!==t[t.length-1])return 0;let n=0,r=Math.min(e.length,t.length),o=r,a=0;for(;n<o;)e.substring(e.length-o,e.length-a)===t.substring(t.length-o,t.length-a)?a=n=o:r=o,o=Math.floor((r-n)/2+n);return o}function oV(e,t,n,r,o){let a=e.substring(0,n),i=t.substring(0,r),l=e.substring(n),s=t.substring(r),c=oq(a,i,{checkLines:!1,deadline:o}),u=oq(l,s,{checkLines:!1,deadline:o});return c.concat(u)}function oU(e,t,n){let r=e.slice(n,n+Math.floor(e.length/4)),o=-1,a="",i,l,s,c;for(;-1!==(o=t.indexOf(r,o+1));){let r=oK(e.slice(n),t.slice(o)),u=oL(e.slice(0,n),t.slice(0,o));a.length<u+r&&(a=t.slice(o-u,o)+t.slice(o,o+r),i=e.slice(0,n-u),l=e.slice(n+r),s=t.slice(0,o-u),c=t.slice(o+r))}return 2*a.length>=e.length?[i||"",l||"",s||"",c||"",a||""]:null}var oW=Object.defineProperty,oH=Object.getOwnPropertySymbols,oG=Object.prototype.hasOwnProperty,oJ=Object.prototype.propertyIsEnumerable,oZ=(e,t,n)=>t in e?oW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function oY(e,t,n){if(null===e||null===t)throw Error("Null input. (diff)");let r=oq(e,t,function(e){let t;var n,r={checkLines:!0,deadline:(n=e.timeout||1,t=1,"u">typeof n&&(t=n<=0?Number.MAX_VALUE:n),Date.now()+1e3*t)},o=e;for(var a in o||(o={}))oG.call(o,a)&&oZ(r,a,o[a]);if(oH)for(var a of oH(o))oJ.call(o,a)&&oZ(r,a,o[a]);return r}(n||{}));return function(e){for(let t=0;t<e.length;t++){let[n,r]=e[t];if(0===r.length)continue;let o=r[0];(function(e){let t=e.charCodeAt(0);return t>=55296&&t<=56319})(r[r.length-1])&&0===n&&o0(e,t,1),function(e){let t=e.charCodeAt(0);return t>=56320&&t<=57343}(o)&&0===n&&o0(e,t,-1)}for(let t=0;t<e.length;t++)0===e[t][1].length&&e.splice(t,1)}(r),r}function oq(e,t,n){let r=e,o=t;if(r===o)return r?[[0,r]]:[];let a=oK(r,o),i=r.substring(0,a);a=oL(r=r.substring(a),o=o.substring(a));let l=r.substring(r.length-a),s=function(e,t,n){let r;if(!e)return[[1,t]];if(!t)return[[-1,e]];let o=e.length>t.length?e:t,a=e.length>t.length?t:e,i=o.indexOf(a);if(-1!==i)return r=[[1,o.substring(0,i)],[0,a],[1,o.substring(i+a.length)]],e.length>t.length&&(r[0][0]=-1,r[2][0]=-1),r;if(1===a.length)return[[-1,e],[1,t]];let l=function(e,t,n=1){let r,o,a,i,l;if(n<=0)return null;let s=e.length>t.length?e:t,c=e.length>t.length?t:e;if(s.length<4||2*c.length<s.length)return null;let u=oU(s,c,Math.ceil(s.length/4)),d=oU(s,c,Math.ceil(s.length/2));if(u&&d)r=u[4].length>d[4].length?u:d;else{if(!u&&!d)return null;d?u||(r=d):r=u}if(!r)throw Error("Unable to find a half match.");return e.length>t.length?(o=r[0],a=r[1],i=r[2],l=r[3]):(i=r[0],l=r[1],o=r[2],a=r[3]),[o,a,i,l,r[4]]}(e,t);if(l){let e=l[0],t=l[1],r=l[2],o=l[3],a=l[4],i=oq(e,r,n),s=oq(t,o,n);return i.concat([[0,a]],s)}return n.checkLines&&e.length>100&&t.length>100?function(e,t,n){let r=e,o=t,a=function(e,t){let n=[],r={};function o(e){let t="",o=0,i=-1,l=n.length;for(;i<e.length-1;){-1===(i=e.indexOf(` 16`,o))&&(i=e.length-1);let s=e.slice(o,i+1);(r.hasOwnProperty?r.hasOwnProperty(s):void 0!==r[s])?t+=String.fromCharCode(r[s]):(l===a&&(s=e.slice(o),i=e.length),t+=String.fromCharCode(l),r[s]=l,n[l++]=s),o=i+1}return t}n[0]="";let a=4e4,i=o(e);return a=65535,{chars1:i,chars2:o(t),lineArray:n}}(r,o);r=a.chars1,o=a.chars2;let i=a.lineArray,l=oq(r,o,{checkLines:!1,deadline:n.deadline});(function(e,t){for(let n=0;n<e.length;n++){let r=e[n][1],o=[];for(let e=0;e<r.length;e++)o[e]=t[r.charCodeAt(e)];e[n][1]=o.join("")}})(l,i),(l=function(e){let t=e.map(e=>oN(e)),n=!1,r=[],o=0,a=null,i=0,l=0,s=0,c=0,u=0;for(;i<t.length;)0===t[i][0]?(r[o++]=i,l=c,s=u,c=0,u=0,a=t[i][1]):(1===t[i][0]?c+=t[i][1].length:u+=t[i][1].length,a&&a.length<=Math.max(l,s)&&a.length<=Math.max(c,u)&&(t.splice(r[o-1],0,[-1,a]),t[r[o-1]+1][0]=1,o--,i=--o>0?r[o-1]:-1,l=0,s=0,c=0,u=0,a=null,n=!0)),i++;for(n&&(t=o7(t)),t=o5(t),i=1;i<t.length;){if(-1===t[i-1][0]&&1===t[i][0]){let e=t[i-1][1],n=t[i][1],r=o$(e,n),o=o$(n,e);r>=o?(r>=e.length/2||r>=n.length/2)&&(t.splice(i,0,[0,n.substring(0,r)]),t[i-1][1]=e.substring(0,e.length-r),t[i+1][1]=n.substring(r),i++):(o>=e.length/2||o>=n.length/2)&&(t.splice(i,0,[0,e.substring(0,o)]),t[i-1][0]=1,t[i-1][1]=n.substring(0,n.length-o),t[i+1][0]=-1,t[i+1][1]=e.substring(o),i++),i++}i++}return t}(l)).push([0,""]);let s=0,c=0,u=0,d="",h="";for(;s<l.length;){switch(l[s][0]){case 1:u++,h+=l[s][1];break;case -1:c++,d+=l[s][1];break;case 0:if(c>=1&&u>=1){l.splice(s-c-u,c+u),s=s-c-u;let e=oq(d,h,{checkLines:!1,deadline:n.deadline});for(let t=e.length-1;t>=0;t--)l.splice(s,0,e[t]);s+=e.length}u=0,c=0,d="",h="";break;default:throw Error("Unknown diff operation.")}s++}return l.pop(),l}(e,t,n):function(e,t,n){let r=e.length,o=t.length,a=Math.ceil((r+o)/2),i=2*a,l=Array(i),s=Array(i);for(let e=0;e<i;e++)l[e]=-1,s[e]=-1;l[a+1]=0,s[a+1]=0;let c=r-o,u=c%2!=0,d=0,h=0,p=0,f=0;for(let y=0;y<a&&!(Date.now()>n);y++){for(let p=-y+d;p<=y-h;p+=2){let f,m=a+p,g=(f=p===-y||p!==y&&l[m-1]<l[m+1]?l[m+1]:l[m-1]+1)-p;for(;f<r&&g<o&&e.charAt(f)===t.charAt(g);)f++,g++;if(l[m]=f,f>r)h+=2;else if(g>o)d+=2;else if(u){let o=a+c-p;if(o>=0&&o<i&&-1!==s[o]&&f>=r-s[o])return oV(e,t,f,g,n)}}for(let d=-y+p;d<=y-f;d+=2){let h,m=a+d,g=(h=d===-y||d!==y&&s[m-1]<s[m+1]?s[m+1]:s[m-1]+1)-d;for(;h<r&&g<o&&e.charAt(r-h-1)===t.charAt(o-g-1);)h++,g++;if(s[m]=h,h>r)f+=2;else if(g>o)p+=2;else if(!u){let o=a+c-d;if(o>=0&&o<i&&-1!==l[o]){let i=l[o],s=a+i-o;if(i>=(h=r-h))return oV(e,t,i,s,n)}}}}return[[-1,e],[1,t]]}(e,t,n.deadline)}(r=r.substring(0,r.length-a),o=o.substring(0,o.length-a),n);return i&&s.unshift([0,i]),l&&s.push([0,l]),s=o7(s)}function oX(e,t,n){return 1===n?e+t:t+e}function oQ(e,t){return 1===t?[e.substring(0,e.length-1),e[e.length-1]]:[e.substring(1),e[0]]}function o0(e,t,n){var r,o;let a=1===n?-1:1,i=null,l=null,s=t+n;for(;s>=0&&s<e.length&&(null===i||null===l);s+=n){let[r,o]=e[s];if(0!==o.length){if(1===r){null===i&&(i=s);continue}else if(-1===r){null===l&&(l=s);continue}else if(0===r){if(null===i&&null===l){let[r,o]=oQ(e[t][1],n);e[t][1]=r,e[s][1]=oX(e[s][1],o,a);return}break}}}if(null!==i&&null!==l&&(r=i,o=l,1===n?e[r][1][e[r][1].length-1]===e[o][1][e[o][1].length-1]:e[r][1][0]===e[o][1][0])){let[r,o]=oQ(e[i][1],a),[s]=oQ(e[l][1],a);e[i][1]=r,e[l][1]=s,e[t][1]=oX(e[t][1],o,n);return}let[c,u]=oQ(e[t][1],n);e[t][1]=c,null===i?(e.splice(s,0,[1,u]),null!==l&&l>=s&&l++):e[i][1]=oX(e[i][1],u,a),null===l?e.splice(s,0,[-1,u]):e[l][1]=oX(e[l][1],u,a)}let o1=/[^a-zA-Z0-9]/,o2=/\s/,o3=/[\r\n]/,o4=/\n\r?\n$/,o8=/^\r?\n\r?\n/;function o5(e){let t=e.map(e=>oN(e));function n(e,t){if(!e||!t)return 6;let n=e.charAt(e.length-1),r=t.charAt(0),o=n.match(o1),a=r.match(o1),i=o&&n.match(o2),l=a&&r.match(o2),s=i&&n.match(o3),c=l&&r.match(o3),u=s&&e.match(o4),d=c&&t.match(o8);return u||d?5:s||c?4:o&&!i&&l?3:i||l?2:o||a?1:0}let r=1;for(;r<t.length-1;){if(0===t[r-1][0]&&0===t[r+1][0]){let e=t[r-1][1],o=t[r][1],a=t[r+1][1],i=oL(e,o);
16if(i){let t=o.substring(o.length-i);e=e.substring(0,e.length-i),o=t+o.substring(0,o.length-i),a=t+a}let l=e,s=o,c=a,u=n(e,o)+n(o,a);for(;o.charAt(0)===a.charAt(0);){e+=o.charAt(0),o=o.substring(1)+a.charAt(0),a=a.substring(1);let t=n(e,o)+n(o,a);t>=u&&(u=t,l=e,s=o,c=a)}t[r-1][1]!==l&&(l?t[r-1][1]=l:(t.splice(r-1,1),r--),t[r][1]=s,c?t[r+1][1]=c:(t.splice(r+1,1),r--))}r++}return t}function o7(e){let t=e.map(e=>oN(e));t.push([0,""]);let n=0,r=0,o=0,a="",i="",l;for(;n<t.length;)switch(t[n][0]){case 1:o++,i+=t[n][1],n++;break;case -1:r++,a+=t[n][1],n++;break;case 0:r+o>1?(0!==r&&0!==o&&(0!==(l=oK(i,a))&&(n-r-o>0&&0===t[n-r-o-1][0]?t[n-r-o-1][1]+=i.substring(0,l):(t.splice(0,0,[0,i.substring(0,l)]),n++),i=i.substring(l),a=a.substring(l)),0!==(l=oL(i,a))&&(t[n][1]=i.substring(i.length-l)+t[n][1],i=i.substring(0,i.length-l),a=a.substring(0,a.length-l))),n-=r+o,t.splice(n,r+o),a.length&&(t.splice(n,0,[-1,a]),n++),i.length&&(t.splice(n,0,[1,i]),n++),n++):0!==n&&0===t[n-1][0]?(t[n-1][1]+=t[n][1],t.splice(n,1)):n++,o=0,r=0,a="",i="";break;default:throw Error("Unknown diff operation")}""===t[t.length-1][1]&&t.pop();let s=!1;for(n=1;n<t.length-1;)0===t[n-1][0]&&0===t[n+1][0]&&(t[n][1].substring(t[n][1].length-t[n-1][1].length)===t[n-1][1]?(t[n][1]=t[n-1][1]+t[n][1].substring(0,t[n][1].length-t[n-1][1].length),t[n+1][1]=t[n-1][1]+t[n+1][1],t.splice(n-1,1),s=!0):t[n][1].substring(0,t[n+1][1].length)===t[n+1][1]&&(t[n-1][1]+=t[n+1][1],t[n][1]=t[n][1].substring(t[n+1][1].length)+t[n+1][1],t.splice(n+1,1),s=!0)),n++;return s&&(t=o7(t)),t}var o9=Object.defineProperty,o6=Object.getOwnPropertySymbols,ae=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable,an=(e,t,n)=>t in e?o9(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ar=(e,t)=>{for(var n in t||(t={}))ae.call(t,n)&&an(e,n,t[n]);if(o6)for(var n of o6(t))at.call(t,n)&&an(e,n,t[n]);return e};let ao={threshold:.5,distance:1e3};function aa(e,t,n,r={}){if(null===e||null===t||null===n)throw Error("Null input. (match())");let o=Math.max(0,Math.min(n,e.length));return e===t?0:e.length?e.substring(o,o+t.length)===t?o:function(e,t,n,r={}){if(t.length>32)throw Error("Pattern too long for this browser.");let o=ar(ar({},ao),r),a=function(e){let t={};for(let n=0;n<e.length;n++)t[e.charAt(n)]=0;for(let n=0;n<e.length;n++)t[e.charAt(n)]|=1<<e.length-n-1;return t}(t);function i(e,r){let a=e/t.length,i=Math.abs(n-r);return o.distance?a+i/o.distance:i?1:a}let l=o.threshold,s=e.indexOf(t,n);-1!==s&&(l=Math.min(i(0,s),l),-1!==(s=e.lastIndexOf(t,n+t.length))&&(l=Math.min(i(0,s),l)));let c=1<<t.length-1;s=-1;let u,d,h=t.length+e.length,p=[];for(let r=0;r<t.length;r++){for(u=0,d=h;u<d;)i(r,n+d)<=l?u=d:h=d,d=Math.floor((h-u)/2+u);h=d;let o=Math.max(1,n-d+1),f=Math.min(n+d,e.length)+t.length,y=Array(f+2);y[f+1]=(1<<r)-1;for(let t=f;t>=o;t--){let u=a[e.charAt(t-1)];if(0===r?y[t]=(y[t+1]<<1|1)&u:y[t]=(y[t+1]<<1|1)&u|((p[t+1]|p[t])<<1|1)|p[t+1],y[t]&c){let e=i(r,t-1);if(e<=l)if(l=e,(s=t-1)>n)o=Math.max(1,2*n-s);else break}}if(i(r+1,n)>l)break;p=y}return s}(e,t,o,r):-1}function ai(e){let t=[];for(let n=0;n<e.length;n++)1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")}function al(e){let t=[];for(let n=0;n<e.length;n++)-1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")}function as(e,t){let n=0,r=0,o=0,a=0,i;for(i=0;i<e.length&&(1!==e[i][0]&&(n+=e[i][1].length),-1!==e[i][0]&&(r+=e[i][1].length),!(n>t));i++)o=n,a=r;return e.length!==i&&-1===e[i][0]?a:a+(t-o)}function ac(e){let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);if(typeof r>"u")throw Error("Failed to get codepoint");t+=au(r)}return t}function au(e){return e<=127?1:e<=2047?2:e<=65535?3:4}function ad(e,t){return{diffs:[],start1:e,start2:t,utf8Start1:e,utf8Start2:t,length1:0,length2:0,utf8Length1:0,utf8Length2:0}}let ah=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;function ap(e){if(!e)return[];let t=[],n=e.split(` 17`),r=0;for(;r<n.length;){let e=n[r].match(ah);if(!e)throw Error(`Invalid patch string: ${n[r]}`);let o=ad(af(e[1]),af(e[3]));for(t.push(o),""===e[2]?(o.start1--,o.utf8Start1--,o.length1=1,o.utf8Length1=1):"0"===e[2]?(o.length1=0,o.utf8Length1=0):(o.start1--,o.utf8Start1--,o.utf8Length1=af(e[2]),o.length1=o.utf8Length1),""===e[4]?(o.start2--,o.utf8Start2--,o.length2=1,o.utf8Length2=1):"0"===e[4]?(o.length2=0,o.utf8Length2=0):(o.start2--,o.utf8Start2--,o.utf8Length2=af(e[4]),o.length2=o.utf8Length2),r++;r<n.length;){let e,t=n[r],a=t.charAt(0);if("@"===a)break;if(""===a){r++;continue}try{e=decodeURI(t.slice(1))}catch{throw Error(`Illegal escape in parse: ${t}`)}let i=ac(e)-e.length;if("-"===a)o.diffs.push([-1,e]),o.length1-=i;else if("+"===a)o.diffs.push([1,e]),o.length2-=i;else if(" "===a)o.diffs.push([0,e]),o.length1-=i,o.length2-=i;else throw Error(`Invalid patch mode "${a}" in: ${e}`);r++}}return t}function af(e){return parseInt(e,10)}function ay(e,{schemaTypes:t}){let{_type:n,_key:r,...o}=e;if(e&&e._type===t.block.name){let a=!1,i=typeof e.markDefs>"u",l=typeof e.children>"u",s=(e.children||[]).map(e=>{let{_type:n,_key:r,...o}=e,i=Object.keys(o);return void 0===n&&1===i.length&&"text"===i.at(0)?{_key:r,_type:t.span.name,text:o.text}:n!==t.span.name?(a=!0,{_type:n,_key:r,...o}
17):e});return!i&&!l&&!a&&(0,d.zS)({schema:t},e)?e:{_type:n,_key:r,...o,children:s}}let{children:a,...i}=o;return{_type:n,_key:r,...i}}function am(e,t,n){if(!t||1!==t.length)return!1;let r=t.at(0);if(!r)return!0;if(!(0,d.zS)({schema:n},r)||r._type!==n.block.name||"listItem"in r||!("style"in r)||r.style!==n.styles.at(0)?.name||!Array.isArray(r.children)||1!==r.children.length)return!1;let o=r.children.at(0);return!(!o||!(0,d.bl)({schema:n},o)||!("_type"in o)||o._type!==n.span.name||""!==o.text||o.marks?.join("")||"markDefs"in r&&Array.isArray(r.markDefs)&&r.markDefs.length>0||Object.keys(r).some(e=>"_type"!==e&&"_key"!==e&&"children"!==e&&"markDefs"!==e&&"style"!==e)||rp({schema:n},e,[r]))}function ag(e,t){let n=-1,r=e.find((e,r)=>{let o=(0,h.wE)(t[0])?e._key===t[0]._key:r===t[0];return o&&(n=r),o});if(r)return{node:r,index:n}}function av(e,t,n){let r=e.node;if(!(0,d.zS)({schema:n},r)||"children"!==t[1])return;let o=-1,a=r.children.find((e,n)=>{let r=(0,h.wE)(t[2])?e._key===t[2]._key:n===t[2];return r&&(o=n),r});if(a)return{node:a,index:o}}function ak(e,t){let n=e.isProcessingRemoteChanges;e.isProcessingRemoteChanges=!0,t(),e.isProcessingRemoteChanges=n}function ab(e,t){let n=e.withHistory;e.withHistory=!1,t(),e.withHistory=n}let ax={transform(e,t){let{current:n}=e;if(null==n)return;let r=nl(n,t);e.current=r,null==r&&e.unref()}},aC={transform(e,t){let{current:n,affinity:r}=e;if(null==n)return;let o=ns(n,t,{affinity:r});e.current=o,null==o&&e.unref()}};function aB(e){switch(e.type){case"insert_node":case"remove_node":return!0;default:return!1}}function aE(e,t){if(e.length!==t.length)return!1;let n=e.slice(0,-1),r=t.slice(0,-1);return e[e.length-1]!==t[t.length-1]&&ex(n,r)}function*aD(e){yield[e.anchor,"anchor"],yield[e.focus,"focus"]}function a_(e,t,n,...r){let o=e.slice();return o.splice(t,n,...r),o}let aw=(e,t,n,r)=>{if(0===t.length)throw Error("Cannot modify the editor");let o={schema:n,editableTypes:ed(e)?e.editableTypes:new Set},a=ed(e)||(0,d.zS)({schema:n},e)?e:void 0;if(!a)throw Error("Cannot modify descendant: root has no children");let i=U({...o,value:a.children},t);
17if(!i)throw Error(`Cannot find a descendant at path [${t}]`);let l=i.node,s=t.slice(),c=r(l);for(;s.length>1;){let e=s.pop(),t=U({...o,value:a.children},s);if(!t)throw Error(`Cannot find ancestor at path [${s}]`);let r=t.node;c={...r,children:a_((0,d.zS)({schema:n},r)?r.children:[],e,1,c)}}let u=s.pop(),h=a_(ed(e)||(0,d.zS)({schema:n},e)?e.children:[],u,1,c);e.children=h},aA=(e,t,n,r)=>{0===t.length?e.children=r(ed(e)||(0,d.zS)({schema:n},e)?e.children:[]):aw(e,t,n,e=>{if((0,d.bl)({schema:n},e)||T({schema:n},e))throw Error(`Cannot get the element at path [${t}] because it refers to a leaf node: ${j(e)}`);return{...e,children:r((0,d.zS)({schema:n},e)?e.children:[])}})},aS=(e,t,n,r)=>aw(e,t,n,e=>{if(!(0,d.bl)({schema:n},e))throw Error(`Cannot get the leaf node at path [${t}] because it refers to a non-leaf node: ${j(e)}`);return r(e)});function aF(e,t,n){let r,o,a=e.dirtyPaths,i=e.dirtyPathKeys,l=e=>{if(e){let t=1===e.length?String(e[0]):2===e.length?`${e[0]},${e[1]}`:e.join(",");o.has(t)||(o.add(t),r.push(e))}};if(n)for(let e of(r=[],o=new Set,a))l(n(e));else r=a,o=i;for(let e of t)l(e);e.dirtyPaths=r,e.dirtyPathKeys=o}function aP(e,t={}){let{reverse:n=!1}=t,r=[];for(let t=0;t<=e.length;t++)r.push(e.slice(0,t));return n&&r.reverse(),r}function aO(e,t,n={}){let{affinity:r="forward"}=n,o={current:t,affinity:r,unref(){let{current:t}=o;return e.pointRefs.delete(o),o.current=null,t}};return e.pointRefs.add(o),o}let aM=e=>e.selection?e.selection:e.children.length>0?ta(e,[]):[0];function aT(e,t){return e.length<=t.length&&0===er(e,t)}function aR(e,t={}){o_(e,()=>{let n,r,o,{hanging:a=!1,mode:i="lowest"}=t,{at:l=e.selection,match:s}=t;if(!l)return;if(null==s&&(s=Q(l)?((e,t)=>{let n=U(e,t);if(!n)return()=>!1;let r=n.node;return e=>e===r})(e,l):t=>(0,p.xN)({schema:e.schema},t)),!a&&en(l)&&(l=eE(e,l)),en(l)){let[e,t]=ei(l);n=e.path,r=t.path}else Q(l)?(n=ec(e,l,{edge:"start"}),r=ec(e,l,{edge:"end"})):(n=l.path,r=l.path);let c=[];for(let{node:t,path:a}of ey(e,{from:n,to:r,match:(e,t)=>s(e,t)})){let e=o&&0===er(a,o[1]);if("highest"===i&&e)continue;if("lowest"===i&&e){o=[t,a];continue}let n="lowest"===i?o:[t,a];n&&c.push(n),o=[t,a]}for(let t of("lowest"===i&&o&&c.push(o),Array.from(c,([,t])=>oC(e,t)))){let n=t.unref();if(n){let t=U(e,n);if(t){let r=t.node;e.apply({type:"remove_node",path:n,node:r})}}}})}function az(e,t={}){o_(e,()=>{let n,{reverse:r=!1,unit:o="character",distance:a=1,includeObjectNodes:i=!1}=t,{at:l=e.selection,hanging:s=!1}=t;if(!l)return;let c=!1;if(en(l)&&eB(l)&&(c=!0,l=l.anchor),et(l)){let t=J(e,l.path);if(!i&&t)l=t.path;else{let t={unit:o,distance:a},n=r?tR(e,l,t)||ep(e,[]):tT(e,l,t)||ta(e,[]);l={anchor:l,focus:n},s=!0}}if(Q(l))return void aR(e,{at:l,includeObjectNodes:i});if(eB(l))return;if(!s){let[,t]=ei(l);eC(t,ta(e,[]))||(l=eE(e,l))}let[u,h]=ei(l),p=ef(e,u.path),f=ef(e,h.path),y=p&&f&&!ex(p.path,f.path),m=ex(u.path,h.path),g=i?null:J(e,u.path),v=i?null:J(e,h.path);if(g){let t=tR(e,u);t&&p&&ti(p.path,t.path)&&(u=t)}if(v){let t=tT(e,h);t&&f&&ti(f.path,t.path)&&(h=t)}let k=[];for(let t of ey(e,{from:u.path,to:h.path})){let{node:r,path:o}=t;n&&0===er(o,n)||(!i&&T({schema:e.schema},r)||!aT(o,u.path)&&!aT(o,h.path))&&(k.push(t),n=o)}let b=Array.from(k,t=>oC(e,t.path)),x=aO(e,u),C=aO(e,h),B="";if(!m&&!g){let t=x.current,n=no(e,t.path);if(n){let r=n.node,{path:o}=t,{offset:a}=u,i=r.text.slice(a);i.length>0&&(e.apply({type:"remove_text",path:o,offset:a,text:i}),B=i)}}if(b.reverse().map(e=>e.unref()).filter(e=>null!==e).forEach(t=>{aR(e,{at:t,includeObjectNodes:i})}),!v){let t=C.current,n=no(e,t.path);if(n){let r=n.node,{path:o}=t,a=m?u.offset:0,i=r.text.slice(a,h.offset);i.length>0&&(e.apply({type:"remove_text",path:o,offset:a,text:i}),B=i)}}if(!m&&y&&C.current&&x.current){let t=C.current,n=t=>(0,d.zS)({schema:e.schema},t),r=H(e,t.path,n),o=tR(e,t),a=o?ey(e,{to:o.path,match:n,reverse:!0}).next().value:void 0;if(r&&a){let{node:t,path:n}=r,{node:o,path:l}=a;if(0!==n.length&&0!==l.length){let r,a=na(l),s=X(n,l),c=aE(n,l),u=aP(n).filter(e=>e.length>0).map(t=>U(e,t)).filter(e=>void 0!==e).map(e=>e.node).slice(Math.max(0,s.length-1)).slice(0,-1),h=t=>{if(!(0,d.zS)({schema:e.schema},t))return!ed(t);{let e=t.children;return 1===e.length&&h(e[0])}},p=W(e,n).reverse().find(e=>u.includes(e.node)&&h(e.node)),f=p&&oC(e,p.path);if((0,d.bl)({schema:e.schema},t)&&(0,d.bl)({schema:e.schema},o))r=o.text.length;else if((0,d.zS)({schema:e.schema},t)&&(0,d.zS)({schema:e.schema},o))r=o.children.length;else throw Error(`Cannot merge the node at path [${n}] with the previous sibling because it is not the same kind: ${j(t)} ${j(o)}`);if(!c){let t=U(e,n);if(t){let r=t.node;e.apply({type:"remove_node",path:n,node:r}),e.apply({type:"insert_node",path:a,node:r})}}if(f&&aR(e,{at:f.current,includeObjectNodes:i}),function(e,t){let n=!1;if((0,d.zS)({schema:e.schema},t.node)){let r=t.node.children;n=0===r.length||1===r.length&&(0,d.bl)({schema:e.schema},r[0])&&""===r[0].text}return n||(0,d.bl)({schema:e.schema},t.node)&&""===t.node.text&&0!==t.path[t.path.length-1]}(e,{node:o,path:l}))aR(e,{at:l,includeObjectNodes:i});else{if((0,d.zS)({schema:e.schema},t)&&(0,d.zS)({schema:e.schema},o)&&Array.isArray(t.markDefs)&&t.markDefs.length>0){let n=c?l:oO(a);oz(e,{markDefs:[...new Map([...Array.isArray(o.markDefs)&&o.markDefs||[],...t.markDefs].map(e=>[e._key,e])).values()]},n)}oM(e,a,r)}f&&f.unref()}}}c&&r&&"character"===o&&B.length>1&&B.match(/[\u0980-\u09FF\u0E00-\u0E7F\u1000-\u109F\u0900-\u097F\u1780-\u17FF\u0D00-\u0D7F\u0B00-\u0B7F\u0A00-\u0A7F\u0B80-\u0BFF\u0C00-\u0C7F]+/)&&function(e,t,n={}){o_(e,()=>{let{includeObjectNodes:r=!1}=n,{at:o=aM(e)}=n;if(Q(o)&&(o=tO(e,o)),en(o))if(eB(o))o=o.anchor;else{let t=el(o);if(!r){let n=ec(e,t),r=U(e,n);if(r&&T({schema:e.schema},r.node)?r:G(e,t.path))return}let n=aO(e,es(o)),a=aO(e,t);az(e,{at:o,includeObjectNodes:r});let i=n.unref(),l=a.unref();o=i||l,e.setSelection({anchor:o,focus:o})}if(!r){let t=ec(e,o),n=U(e,t);if(n&&T({schema:e.schema},n.node)?n:G(e,o.path))return}let{path:a,offset:i}=o;t.length>
170&&e.apply({type:"insert_text",path:a,offset:i,text:t})})}(e,B.slice(0,B.length-a));let E=x.unref(),D=C.unref(),_=r?E||D:D||E;null==t.at&&_&&e.select(_)})}function aI(e,t,n={}){o_(e,()=>{let{hanging:r=!1,includeObjectNodes:o=!1,mode:a="lowest",batchDirty:i=!0}=n,{at:l,match:s,select:c}=n;if(0===t.length)return;let u=t[0];if(l||(l=aM(e),!1!==c&&(c=!0)),null==c&&(c=!1),en(l))if(r||(l=eE(e,l)),eB(l))l=l.anchor;else{let[,t]=ei(l),n=aO(e,t);az(e,{at:l}),l=n.unref()}if(et(l)){null==s&&(s=(0,d.bl)({schema:e.schema},u)?t=>(0,d.bl)({schema:e.schema},t):e.isInline(u)?t=>(0,d.bl)({schema:e.schema},t)||e.isInline(t):t=>(0,p.xN)({schema:e.schema},t));let t=aj(e,{from:ec(e,l.path,{edge:"start"}),to:ec(e,l.path,{edge:"end"}),match:s,mode:a});if(!t)return;{let n=t.path,r=oC(e,n),o=ok(e,l,n);{let t,n=l,r=aO(e,n,{affinity:"backward"});try{let o=aj(e,{from:n.path,to:n.path,match:s,mode:a});if(o){t=aO(e,n);let a=n.path.length,i=o.path,l=n.path.slice(0,a),s=n.offset;for(let{path:t}of aP(l).filter(e=>e.length>0).map(t=>U(e,t)).filter(e=>void 0!==e).reverse()){let n=!1;if(t.length<i.length||0===t.length)break;let o=r.current,a=ok(e,o,t);ox(e,o,t)||(n=!0,ow(e,t,s)),s=t[t.length-1]+(n||a?1:0)}}}finally{r.unref(),t?.unref()}}let i=r.unref();l=o?na(i):i}}let h=nI(l),f=l[l.length-1];if(!o){let t=ec(e,h),n=U(e,t);if(n&&T({schema:e.schema},n.node)?n:G(e,h))return}if(i){let n=[],r=aP(h);
17((e,t,n)=>{let r=e.batchingDirtyPaths;e.batchingDirtyPaths=!0;try{t(),n()}finally{e.batchingDirtyPaths=r}})(e,()=>{for(let o of t){let t=h.concat(f);f++;let a={type:"insert_node",path:t,node:o};if(e.apply(a),l=na(l),n.push(a),!(0,d.bl)(e,o))for(let{path:n}of em(e,o))r.push(t.concat(n))}},()=>{aF(e,r,e=>{let t=e;for(let e of n)if(aB(e)&&!(t=nl(t,e)))return null;return t})})}else for(let n of t){let t=h.concat(f);f++,e.apply({type:"insert_node",path:t,node:n}),l=na(l)}if(l=oO(l),c){let t=ta(e,l);t&&e.select(t)}})}function aj(e,t){let n,{from:r,to:o,match:a,mode:i}=t;for(let{node:t,path:l}of ey(e,{from:r,to:o,match:a})){let e={node:t,path:l},r=n&&0===er(l,n.path);if("highest"===i&&r)continue;if("lowest"===i&&r){n=e;continue}let o="lowest"===i?n:e;if(o)return o;n=e}return n}var aN={exports:{}},a$={},aK=(a||(a=1,function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||"function"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),aN.exports=function(){if(o)return a$;function e(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function t(){}o=1;var n={d:{f:t,r:function(){throw Error(e(522))},D:t,C:t,L:t,m:t,X:t,S:t,M:t},p:0,findDOMNode:null},r=Symbol.for("react.portal"),a=c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function i(e,t){return"font"===e?"":"string"==typeof t?"use-credentials"===t?t:"":void 0}return a$.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=n,a$.createPortal=function(t,n){var o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!n||1!==n.nodeType&&9!==n.nodeType&&11!==n.nodeType)throw Error(e(299));return function(e,t,n){var o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:r,key:null==o?null:""+o,children:e,containerInfo:t,implementation:n}}(t,n,null,o)},a$.flushSync=function(e){var t=a.T,r=n.p;try{if(a.T=null,n.p=2,e)return e()}finally{a.T=t,n.p=r,n.d.f()}},a$.preconnect=function(e,t){"string"==typeof e&&(t=t?"string"==typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:null,n.d.C(e,t))},a$.prefetchDNS=function(e){"string"==typeof e&&n.d.D(e)},a$.preinit=function(e,t){if("string"==typeof e&&t&&"string"==typeof t.as){var r=t.as,o=i(r,t.crossOrigin),a="string"==typeof t.integrity?t.integrity:void 0,l="string"==typeof t.fetchPriority?t.fetchPriority:void 0;"style"===r?n.d.S(e,"string"==typeof t.precedence?t.precedence:void 0,{crossOrigin:o,integrity:a,fetchPriority:l}):"script"===r&&n.d.X(e,{crossOrigin:o,integrity:a,fetchPriority:l,nonce:"string"==typeof t.nonce?t.nonce:void 0})}},a$.preinitModule=function(e,t){if("string"==typeof e)if("object"==typeof t&&null!==t){if(null==t.as||"script"===t.as){var r=i(t.as,t.crossOrigin);n.d.M(e,{crossOrigin:r,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0})}}else null==t&&n.d.M(e)},a$.preload=function(e,t){if("string"==typeof e&&"object"==typeof t&&null!==t&&"string"==typeof t.as){var r=t.as,o=i(r,t.crossOrigin);n.d.L(e,r,{crossOrigin:o,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0,type:"string"==typeof t.type?t.type:void 0,fetchPriority:"string"==typeof t.fetchPriority?t.fetchPriority:void 0,referrerPolicy:"string"==typeof t.referrerPolicy?t.referrerPolicy:void 0,imageSrcSet:"string"==typeof t.imageSrcSet?t.imageSrcSet:void 0,imageSizes:"string"==typeof t.imageSizes?t.imageSizes:void 0,media:"string"==typeof t.media?t.media:void 0})}},a$.preloadModule=function(e,t){if("string"==typeof e)if(t){var r=i(t.as,t.crossOrigin);n.d.m(e,{as:"string"==typeof t.as&&"script"!==t.as?t.as:void 0,crossOrigin:r,integrity:"string"==typeof t.integrity?t.integrity:void 0})}else n.d.m(e)},a$.requestFormReset=function(e){n.d.r(e)},a$.unstable_batchedUpdates=function(e,t){return e(t)},a$.useFormState=function(e,t,n){return a.H.useFormState(e,t,n)},a$.useFormStatus=function(){return a.H.useHostTransitionStatus()}
17,a$.version="19.2.3",a$}()),(r=aN.exports)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default"))?r.default:r;let aL=parseInt(c.version.split(".")[0],10);function aV(e,t){return{getBlockNodes:e=>aU(t,e),getChildNodes:e=>(function(e,t){if(!t.context.selection)return[];let n=te(t);if(!n)return[];try{let t,[r,o]=ei(n),a=[];for(let n of ey(e,{from:r.path,to:o.path})){let e=n.path;if(t){if(ti(t.path,e)){t=n;continue}a.push(t)}t=n}return t&&a.push(t),a.flatMap(t=>z(e,t.path)||[])}catch{return[]}})(t,e),getEditorElement:()=>z(t,[]),getSelectionRect:e=>(function(e){if(!e.context.selection)return null;try{let e=window.getSelection();return e?e.getRangeAt(0).getBoundingClientRect():null}catch{return null}})(e),getStartBlockElement:e=>(function(e,t){let n=(0,p.GB)(t);if(!n)return null;let r=aU(e,{...t,context:{...t.context,selection:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}}})?.at(0);return r&&r instanceof Element?r:null})(t,e),getEndBlockElement:e=>(function(e,t){let n=(0,p.P$)(t);if(!n)return null;let r=aU(e,{...t,context:{...t.context,selection:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}}})?.at(0);return r&&r instanceof Element?r:null})(t,e),setDragGhost:({event:t,ghost:n})=>(function({sendBack:e,event:t,ghost:n}){t.originEvent.dataTransfer.setDragImage(n.element,n.x,n.y),e({type:"set drag ghost",ghost:n.element})})({sendBack:e,event:t,ghost:n})}}function aU(e,t){if(!t.context.selection)return[];let n=te(t);if(!n)return[];try{let t,[r,o]=ei(n),a=[];for(let n of ey(e,{from:r.path,to:o.path})){let e=n.path;t&&ti(t,e)||(t=e,a.push(n))}return a.flatMap(t=>z(e,t.path)||[])}catch{return[]}}let aW=(0,B.Ke)({on:"annotation.add",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let r={...e,context:{...e.context,selection:n}};if(!(0,p.WV)(r))return!1;let o=(0,p.UH)(r);return!!o&&!!(0,p.gR)({context:{...r.context,selection:o}})&&{caretWordSelection:o}},actions:[({event:e},{caretWordSelection:t})=>[(0,B.xl)({type:"select",at:t}),(0,B.xl)({type:"annotation.add",annotation:e.annotation})]]}),aH=(0,B.Ke)({on:"annotation.add",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let r={...e,context:{...e.context,selection:n}};return(0,p.kK)(t.annotation.name,{mode:"partial"})(r)},actions:[({event:e})=>[(0,B.xl)({type:"annotation.remove",annotation:e.annotation,at:e.at}),(0,B.xl)(e)]]}),aG=(0,B.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{let n={...e,context:{...e.context,selection:t.at??e.context.selection}};if(!(0,p.gR)(n))return!1;let r=(0,p.dO)(n),o=(0,p.Jo)(n),a=(0,p.yh)(n),i=(0,p.aR)(n);if(!r||!a||!o||!i||r.path[2]._key!==a.path[2]._key||!(0,d.bl)(e.context,r.node)||0!==o.offset||i.offset!==r.node.text.length)return!1;let l=e.context.schema.decorators.map(e=>
17e.name),s=r.node.marks??[];if(!s.some(e=>!l.includes(e)))return!1;let c=(0,p.A_)(n),u=(0,p.eb)(n),h=!!c&&c.node.marks?.some(e=>!l.includes(e)&&s.includes(e)),f=!!u&&u.node.marks?.some(e=>!l.includes(e)&&s.includes(e));if(h||f)return!1;let y=(0,p.rm)(n);return{spanPath:r.path,activeDecorators:y}},actions:[({event:e},{spanPath:t,activeDecorators:n})=>[(0,B.xl)({type:"child.set",at:t,props:{marks:n}}),(0,B.sY)(e)]]}),aJ={arrowDown:(0,y.mn)({default:[{key:"ArrowDown",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),arrowUp:(0,y.mn)({default:[{key:"ArrowUp",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),backspace:(0,y.mn)({default:[{key:"Backspace",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),break:(0,y.mn)({default:[{key:"Enter",shift:!1}]}),lineBreak:(0,y.mn)({default:[{key:"Enter",shift:!0}]}),decorators:{strong:y.Cr,em:y.TN,underline:y.V1,code:y.aY},delete:(0,y.mn)({default:[{key:"Delete",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),deleteWord:{backward:(0,y.mn)({default:[{key:"Backspace",alt:!1,ctrl:!0,meta:!1}],apple:[{key:"Backspace",alt:!0,ctrl:!1,meta:!1}]}),forward:(0,y.mn)({default:[{key:"Delete",alt:!1,ctrl:!0,meta:!1}],apple:[{key:"Delete",alt:!0,ctrl:!1,meta:!1}]})},history:{undo:y.tN,redo:y.ZS},tab:(0,y.mn)({default:[{key:"Tab",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),shiftTab:(0,y.mn)({default:[{key:"Tab",alt:!1,ctrl:!1,meta:!1,shift:!0}]})},aZ=(0,B.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!aJ.arrowDown.guard(t.originEvent)||!(0,p.WV)(e))return!1;let n=(0,p.lA)(e),r=(0,p.RL)(e);return n&&!r},actions:[({snapshot:e})=>[(0,B.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after"})]]}),aY=(0,B.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!aJ.arrowUp.guard(t.originEvent)||!(0,p.WV)(e))return!1;let n=(0,p.lA)(e),r=(0,p.HA)(e);return n&&!r},actions:[({snapshot:e})=>[(0,B.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"before"})]]}),aq=(0,B.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,p.lA)(e);return(0,p.WV)(e)&&void 0!==t},actions:[({snapshot:e})=>[(0,B.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after"})]]}),aX=(0,B.Ke)({on:"mouse.click",guard:({snapshot:e,event:t})=>{if(e.context.readOnly||e.context.selection&&!(0,p.WV)(e))return!1;let n=(0,p.lA)({...e,context:{...e.context,selection:t.position.selection}}),r=(0,p.HA)({...e,context:{...e.context,selection:t.position.selection}});return t.position.isEditor&&"start"===t.position.block&&n&&!r},actions:[({snapshot:e,event:t})=>[(0,B.xl)({type:"select",at:t.position.selection}),(0,B.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"before",select:"start"})]]}),aQ=(0,B.Ke)({on:"mouse.click",guard:({snapshot:e,event:t})=>{if(e.context.readOnly||e.context.selection&&!(0,p.WV)(e))return!1;let n=(0,p.lA)({...e,context:{...e.context,selection:t.position.selection}}),r=(0,p.RL)({...e,context:{...e.context,selection:t.position.selection}});return t.position.isEditor&&"end"===t.position.block&&n&&!r},actions:[({snapshot:e,event:t})=>[(0,B.xl)({type:"select",at:t.position.selection}),(0,B.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after",select:"start"})]]}),a0=(0,B.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,p.hH)(e),n=(0,p.WV)(e),r=(0,p.HA)(e);return!(!t||!n||!r||(0,h.Eg)(e.context,t.node))&&!(!(0,g.wm)(e.context,t.node)||(0,p.xN)(e.context,r.node))&&{focusTextBlock:t,previousBlock:r}},actions:[(e,{focusTextBlock:t,previousBlock:n})=>[(0,B.xl)({type:"delete.block",at:t.path}),(0,B.xl)({type:"select",at:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}})]]}),a1=(0,B.Ke)({on:"delete.forward",guard:({snapshot:e})=>{let t=(0,p.hH)(e),n=(0,p.WV)(e),r=(0,p.RL)(e);return!!t&&!!n&&!!r&&!(!(0,g.wm)(e.context,t.node)||(0,p.xN)(e.context,r.node))&&{focusTextBlock:t,nextBlock:r}},actions:[(e,{focusTextBlock:t,nextBlock:n})=>[(0,B.xl)({type:"delete.block",at:t.path}),(0,B.xl)({type:"select",at:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}})]]}),a2={strongShortcut:(0,B.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>aJ.decorators.strong.guard(t.originEvent)&&e.context.schema.decorators.some(e=>"strong"===e.name),actions:[()=>[(0,B.xl)({type:"decorator.toggle",decorator:"strong"})]]}),emShortcut:(0,B.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>aJ.decorators.em.guard(t.originEvent)&&e.context.schema.decorators.some(e=>"em"===e.name),actions:[()=>[(0,B.xl)({type:"decorator.toggle",decorator:"em"})]]}),underlineShortcut:(0,B.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>aJ.decorators.underline.guard(t.originEvent)&&e.context.schema.decorators.some(e=>"underline"===e.name),actions:[()=>[(0,B.xl)({type:"decorator.toggle",decorator:"underline"})]]}),codeShortcut:(0,B.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>aJ.decorators.code.guard(t.originEvent)&&e.context.schema.decorators.some(e=>
17"code"===e.name),actions:[()=>[(0,B.xl)({type:"decorator.toggle",decorator:"code"})]]})};function a3(e){if(0===e.length)return new DOMRect(0,0,0,0);let t=e.filter(e=>e instanceof Element),n=t.at(0)?.getBoundingClientRect();if(!n)return new DOMRect(0,0,0,0);let r=n.left,o=n.top,a=n.right,i=n.bottom;for(let e=1;e<t.length;e++){let n=t[e].getBoundingClientRect();r=Math.min(r,n.left),o=Math.min(o,n.top),a=Math.max(a,n.right),i=Math.max(i,n.bottom)}return new DOMRect(r,o,a-r,i-o)}let a4=[(0,B.Ke)({on:"drag.dragstart",guard:({snapshot:e,dom:t,event:n})=>{let r=r3({snapshot:e,eventSelection:n.position.selection}),o=(0,p.iE)({...e,context:{...e.context,selection:r}}),a={blockNodes:t.getBlockNodes({...e,context:{...e.context,selection:r}}),childNodes:t.getChildNodes({...e,context:{...e.context,selection:r}})};return{dragSelection:r,draggedDomNodes:a,selectingEntireBlocks:o}},actions:[({dom:e,event:t},{dragSelection:n,draggedDomNodes:r,selectingEntireBlocks:o})=>{let a=document.createElement("div");if(o){for(let e of r.blockNodes.map(e=>e.cloneNode(!0)))e instanceof HTMLElement&&(e.style.position="relative"),a.appendChild(e);let o=a.querySelector("[data-pt-drag-ghost-element]");if(o&&a.replaceChildren(o),a.setAttribute("data-dragged",""),a.style.position="absolute",a.style.left="-99999px",a.style.boxSizing="border-box",document.body.appendChild(a),o){let r=o.getBoundingClientRect(),i=t.originEvent.clientX-r.left,l=t.originEvent.clientY-r.top;return a.style.width=`${r.width}px`,a.style.height=`${r.height}px`,[(0,B.xl)({type:"select",at:n}),(0,B.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:a,x:i,y:l}})}),(0,B.sY)(t)]}{let o=a3(r.blockNodes),i=t.originEvent.clientX-o.left,l=t.originEvent.clientY-o.top;return a.style.width=`${o.width}px`,a.style.height=`${o.height}px`,[(0,B.xl)({type:"select",at:n}),(0,B.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:a,x:i,y:l}})}),(0,B.sY)(t)]}}{for(let e of r.childNodes.map(e=>e.cloneNode(!0)))a.appendChild(e);a.style.position="absolute",a.style.left="-99999px",a.style.boxSizing="border-box",document.body.appendChild(a);let o=a3(r.childNodes),i=t.originEvent.clientX-o.left,l=t.originEvent.clientY-o.top;return a.style.width=`${o.width}px`,a.style.height=`${o.height}px`,[(0,B.xl)({type:"select",at:n}),(0,B.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:a,x:i,y:l}})}),(0,B.sY)(t)]}}]}),(0,B.Ke)({on:"drag.dragover",guard:({snapshot:e,event:t})=>{let n=t.dragOrigin;return!!n&&(0,p.Q)(t.position.selection)({...e,context:{...e.context,selection:n.selection}})},actions:[]}),(0,B.Ke)({on:"drag.drop",guard:({snapshot:e,event:t})=>{let n=t.dragOrigin,r=t.position.selection;return!!n&&(0,p.Q)(r)({...e,context:{...e.context,selection:n.selection}})},actions:[]}),(0,B.Ke)({on:"drag.drop",guard:({event:e})=>void 0!==e.dragOrigin,actions:[({event:e})=>[(0,B.xl)({type:"deserialize",originEvent:e})]]}),(0,B.Ke)({on:"drag.drop",actions:[({event:e})=>[(0,B.xl)({type:"select",at:e.position.selection}),(0,B.xl)({type:"deserialize",originEvent:e})]]}),(0,B.Ke)({on:"deserialization.success",guard:({snapshot:e,event:t})=>{if("drag.drop"!==t.originEvent.type||void 0===t.originEvent.dragOrigin)return!1;let n=t.originEvent.dragOrigin,r=r3({eventSelection:n.selection,snapshot:e}),o=t.originEvent.position.selection,a=!!n&&(0,p.Q)(o)({...e,context:{...e.context,selection:r}}),i=(0,p.iE)({...e,context:{...e.context,selection:r}}),l=(0,p.wx)({...e,context:{...e.context,selection:r}});return!a&&{dropPosition:o,draggingEntireBlocks:i,draggedBlocks:l,dragOrigin:n,originEvent:t.originEvent}},actions:[({event:e},{draggingEntireBlocks:t,draggedBlocks:n,dragOrigin:r,dropPosition:o,originEvent:a})=>[(0,B.xl)({type:"select",at:o}),...t?n.map(e=>(0,B.xl)({type:"delete.block",at:e.path})):[(0,B.xl)({type:"delete",at:r.selection})],(0,B.xl)({type:"insert.blocks",blocks:e.data,placement:t?"start"===a.position.block?"before":"end"===a.position.block?"after":"auto":"auto"})]]})],a8=[(0,B.Ke)({on:"insert.text",guard:({snapshot:e})=>{if(!(0,p.d2)(e))return!1;let t=(0,p.JB)(e),n=(0,p.rm)(e),r=(0,p.N2)(e);if(t&&"unchanged"===t.state){let r=(t.marks??[]).filter(t=>e.context.schema.decorators.map(e=>e.name).includes(t));if(r.length===n.length&&r.every(e=>n.includes(e)))return!1}return{activeDecorators:n,activeAnnotations:r}},actions:[({snapshot:e,event:t},{activeDecorators:n,activeAnnotations:r})=>[(0,B.xl)({type:"insert.child",child:{_type:e.context.schema.span.name,text:t.text,marks:[...n,...r]}})]]})],a5=(0,B.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,p.hH)(e),n=(0,p.WV)(e);if(!e.context.selection||!t||!n)return!1;let r=(0,p.Qm)(t)(e),o=t.node.listItem,a=t.node.level;return!!r&&{focusListItem:o,focusLevel:a}},actions:[({snapshot:e},{focusListItem:t,focusLevel:n})=>[(0,B.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,text:"",marks:[]}],markDefs:[],listItem:t,level:n,style:e.context.schema.styles[0]?.n
17ame},placement:"after"})]]}),a7=(0,B.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,p.hH)(e),n=(0,p.WV)(e);if(!e.context.selection||!t||!n)return!1;let r=(0,p.d2)(e),o=r?.node.marks?.filter(t=>e.context.schema.decorators.some(e=>e.name===t)??[]),a=r?.node.marks?.filter(t=>!e.context.schema.decorators.some(e=>e.name===t))??[],i=t.node.listItem,l=t.node.level;return!!(0,p.HX)(t)(e)&&{focusAnnotations:a,focusDecorators:o,focusListItem:i,focusLevel:l}},actions:[({snapshot:e},{focusAnnotations:t,focusDecorators:n,focusListItem:r,focusLevel:o})=>[(0,B.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,marks:0===t.length?n:[],text:""}],listItem:r,level:o,style:e.context.schema.styles[0]?.name},placement:"before",select:"none"})]]}),a9=(0,B.Ke)({on:"insert.break",guard:({snapshot:e})=>{if(!e.context.selection||!(0,p.gR)(e))return!1;let t=(0,p.wx)(e),n=(0,p.GB)(e),r=(0,p.P$)(e);if(!n||!r)return!1;let o=(0,h.u3)({context:e.context,block:n}),a=(0,h.Jo)(e.context.selection),i=(0,h.J8)({context:e.context,block:r}),l=(0,h.aR)(e.context.selection);return!!((0,h._Q)(a,o)&&(0,h._Q)(l,i))&&{selectedBlocks:t}},actions:[({snapshot:e},{selectedBlocks:t})=>[(0,B.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,text:"",marks:[]}]},placement:"before",select:"start"}),...t.map(e=>(0,B.xl)({type:"delete.block",at:e.path}))]]}),a6=(0,B.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,p.WV)(e),n=(0,p.Rt)(e);return t&&n},actions:[()=>[(0,B.xl)({type:"move.forward",distance:1}),(0,B.xl)({type:"split"})]]});function ie({context:e,block:t}){return!!(0,d.zS)(e,t)&&!!e.selection&&!!(0,h.WV)(e.selection)&&(0,h.qX)(e.selection.focus)===t.children[0]?._key&&0===e.selection.focus.offset}let it=(0,B.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,p.hH)(e);return!!t&&1===t.node.level&&!!ie({context:e.context,block:t.node})&&{focusTextBlock:t}},actions:[(e,{focusTextBlock:t})=>[(0,B.xl)({type:"block.unset",props:["listItem","level"],at:t.path})]]}),ir=(0,B.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,p.WV)(e),n=(0,p.hH)(e),r=(0,p.d2)(e);return!!t&&!!n&&!!r&&n.node.children[0]?._key===r.node._key&&e.context.selection?.focus.offset===0&&void 0!==n.node.level&&n.node.level>1&&{focusTextBlock:n,level:n.node.level-1}},actions:[(e,{focusTextBlock:t,level:n})=>[(0,B.xl)({type:"block.set",props:{level:n},at:t.path})]]}),io=(0,B.Ke)({on:"delete.forward",guard:({snapshot:e})=>{let t=(0,p.iL)(e),n=(0,p.RL)(e);return!!t&&!!n&&!!(0,p.xN)(e.context,n.node)&&!!(0,g.wm)(e.context,t.node)&&{focusListBlock:t,nextBlock:n}},actions:[(e,{nextBlock:t})=>[(0,B.xl)({type:"insert.block",block:t.node,placement:"auto",select:"start"}),(0,B.xl)({type:"delete.block",at:t.path})]]}),ia=(0,B.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,p.hH)(e),n=(0,p.HA)(e);return!!t&&!!n&&!!ie({context:e.context,block:t.node})&&!!(0,h.Eg)(e.context,n.node)&&!!(0,g.wm)(e.context,n.node)&&{focusTextBlock:t,previousBlockEndPoint:(0,h.J8)({context:e.context,block:n})}},actions:[(e,{focusTextBlock:t,previousBlockEndPoint:n})=>[(0,B.xl)({type:"select",at:{anchor:n,focus:n}}),(0,B.xl)({type:"insert.block",block:t.node,placement:"auto",select:"start"}),(0,B.xl)({type:"delete.block",at:t.path})]]}),ii=(0,B.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let r=(0,p.wx)({...e,context:{...e.context,selection:n}});if(r.length<2)return!1;let o=r.at(0)?.node,a=r.slice(1,-1),i=r.at(-1)?.node;if(!(0,h.Eg)(e.context,o)||!(0,h.Eg)(e.context,i))return!1;let l=(0,p.Jo)({context:{...e.context,selection:n}}),s=(0,p.aR)({context:{...e.context,selection:n}});if(!l||!s)return!1;let c=(0,h.u3)({context:e.context,block:{node:o,path:[{_key:o._key}]}});if(!(0,h._Q)(l,c))return!1;let u=(0,h.J8)({context:e.context,block:{node:o,path:[{_key:o._key}]}}),d=(0,h.J8)({context:e.context,block:{node:i,path:[{_key:i._key}]}}),f=(0,g.Bh)({context:{schema:e.context.schema,selection:{anchor:s,focus:d}},block:i});return{startBlockStartPoint:c,startBlockEndPoint:u,middleBlocks:a,endBlock:i,slicedEndBlock:f}},actions:[(e,{startBlockStartPoint:t,startBlockEndPoint:n,middleBlocks:r,endBlock:o,slicedEndBlock:a})=>[...r.map(e=>(0,B.xl)({type:"delete.block",at:e.path})),(0,B.xl)({type:"delete.block",at:[{_key:o._key}]}),(0,B.xl)({type:"select",at:{anchor:n,focus:n}}),(0,B.xl)({type:"insert.block",block:a,placement:"auto",select:"none"}),(0,B.xl)({type:"delete",at:{anchor:t,focus:n}})]]}),il=(0,B.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,p.WV)(e),n=(0,p.iL)(e);return!!t&&!!n&&!!(0,g.wm)(e.context,n.node)&&{focusListBlock:n}},actions:[(e,{focusListBlock:t})=>[(0,B.xl)({type:"block.unset",props:["listItem","level"],at:t.path})]]}),is=(0,B.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!aJ.tab.guard(t.originEvent))return!1;let n=(0,p.wx)(e),r=n.flatMap(t=>(0,h.Eg)(e.context,t.node)?[{node:t.node,path:t.path}]:[]);return r.length===n.length&&{selectedListBlocks:r}},actions:[(e,{selectedListBlocks:t})=>t.map(e=>(0,B.xl)({type:"block.set",props:{level:Math.min(10,Math.max(1,e.node.level+1))},at:e.path}))]}),ic=(0,B.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!aJ.shiftTab.guard(t.originEvent))return!1;let n=(0,p.wx)(e),r=n.flatMap(t=>(0,h.Eg)(e.context,t.node)?[{node:t.node,path:t.path}]:[]);return r.length===n.length&&{selectedListBlocks:r}},actions:[(e,{selectedListBlocks:t})=>t.map(e=>(0,B.xl)({type:"block.set",props:{level:Math.min(10,Math.max(1,e.node.level-1))},at:e.path}))]}),iu=(0,B.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{let n={...e,context:{...e.context,selection:t.at??e.context.selection}},r=(0,p.iL)(n);if(!r)return!1;let o=t.blocks.at(0),a=t.blocks.at(1),i=(0,h.Eg)(e.context,o)?o:(0,h.Eg)(e.context,a)?a:void 0;if(!i)return!1;let l=r.node.level-i.level;return 0!==l&&{levelDifference:l,insertedListBlock:i}},actions:[({snapshot:e,event:t},{levelDifference:n,insertedListBlock:r})=>{let o=!0,a=!1;return[(0,B.xl)({...t,blocks:t.blocks.map(t=>
17(t._key===r._key&&(a=!0),o?a&&o&&(0,h.Eg)(e.context,t)?{...t,level:Math.min(10,Math.max(1,t.level+n))}:(a&&(o=!1),t):t))})]}]}),id=(0,B.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{let n={...e,context:{...e.context,selection:t.at??e.context.selection}},r=(0,p.iL)(n);if(!r||(0,g.wm)(e.context,r.node))return!1;let o=t.blocks.at(0),a=t.blocks.at(1),i=(0,h.Eg)(e.context,o)?o:(0,h.Eg)(e.context,a)?a:void 0;return!!i&&r.node.level===i.level&&r.node.listItem!==i.listItem&&{listItem:r.node.listItem,insertedListBlock:i}},actions:[({snapshot:e,event:t},{listItem:n,insertedListBlock:r})=>{let o=!0,a=!1;return[(0,B.xl)({...t,blocks:t.blocks.map(t=>(t._key===r._key&&(a=!0),o?a&&o&&(0,h.Eg)(e.context,t)?{...t,listItem:t.level===r.level?n:t.listItem}:(a&&(o=!1),t):t))})]}]}),ih=(0,B.Ke)({on:"insert.block",guard:({snapshot:e,event:t})=>{if("auto"!==t.placement||t.block._type!==e.context.schema.block.name||void 0!==t.block.listItem)return!1;let n={...e,context:{...e.context,selection:t.at??e.context.selection}},r=(0,p.iL)(n);return!!r&&!!(0,g.wm)(e.context,r.node)&&{level:r.node.level,listItem:r.node.listItem}},actions:[({event:e},{level:t,listItem:n})=>[(0,B.xl)({...e,block:{...e.block,level:t,listItem:n}})]]}),ip=[aW,aH,aG,a2.strongShortcut,a2.emShortcut,a2.underlineShortcut,a2.codeShortcut,...a4,aX,aQ,aZ,aY,aq,a0,a1,...a8,it,ir,io,ia,ii,il,is,ic,iu,id,ih,a5,a7,a9,a6],iy=r2,im=[];for(let e of ip){let t=r1({name:"core",reference:{priority:iy,importance:"lower"}});im.push({behavior:e,priority:t}),iy=t}function ig({converters:e,editor:t,keyGenerator:n,readOnly:r,schema:o}){let a=t.selection?e5({schema:o,editor:t,range:t.selection}):null,i={converters:e,keyGenerator:n,readOnly:r,schema:o,selection:a,value:t.children};return{blockIndexMap:t.blockIndexMap,context:i,decoratorState:t.decoratorState}}function iv(e,t){if(0===t.length)return!1;let n={schema:e.schema,editableTypes:e.editableTypes},r=e.value,o,a="";for(let e=0;e<t.length;e++){let i=r[t[e]];if(!i)break;let l=V(n,i,o,a);if(e===t.length-1)return void 0===l;if(!l)break;r=l.children,o=l.scope,a=l.scopePath}return!1}function ik(e,t,n){let r=eN.toDOMRange(e,t).getBoundingClientRect(),o=eN.toDOMRange(e,n).getBoundingClientRect();return ib(r,o)&&ib(o,r)}function ib(e,t){let n=(t.top+t.bottom)/2;return e.top<=n&&e.bottom>=n}function ix(e,t,n,r,o){let a={...n};if("insert"===t.type&&1===t.path.length){let e=t.path[0],n=(r||[]).findIndex(t=>(0,h.wE)(e)&&t._key===e._key);return P.history(`Adjusting block path (+${t.items.length}) for '${a.type}' operation and patch '${t.type}'`),[iC(a,t.items.length,n)]}if("unset"===t.type&&1===t.path.length){let e=t.path[0],n=(o||[]).findIndex(t=>(0,h.wE)(e)&&t._key===e._key);return"path"in a&&Array.isArray(a.path)&&a.path[0]===n?(P.history("Skipping transformation that targeted removed block"),[]):[iC(a,-1,n)]}if("unset"===t.type&&0===t.path.length)return P.history(`Adjusting selection for unset everything patch and ${n.type} operation`),[];if("diffMatchPatch"===t.type){var i,l;let n,r=(i=e,"set_selection"===(l=a).type&&i.selection?n=i.children[i.selection.focus.path[0]]:"path"in l&&(n=i.children[l.path[0]]),n),o=t.path[0];return r&&(0,h.wE)(o)&&r._key===o._key&&ap(t.value).forEach(e=>{let t=0,n=e.utf8Start1,{diffs:r}=e;if(r.forEach((e,o)=>{let[a,i]=e;1===a?(t+=i.length,n+=i.length):-1===a?(t-=i.length,n-=i.length):0===a&&(r.slice(o).every(([e])=>0===e)||(n+=i.length))}),"insert_text"===a.type&&n<a.offset&&(a.offset+=t),"remove_text"===a.type&&n<=a.offset-a.text.length&&(a.offset+=t),"set_selection"===a.type){let e=a.properties?.focus?{...a.properties.focus}:void 0,r=a?.properties?.anchor?{...a.properties.anchor}:void 0,o=a?.newProperties?.focus?{...a.newProperties.focus}:void 0,i=a?.newProperties?.anchor?{...a.newProperties.anchor}:void 0;(e&&r||o&&i)&&([e,r,o,i].forEach(e=>{e&&n<e.offset&&(e.offset+=t)}),e&&r&&(a.properties={focus:e,anchor:r}),o&&i&&(a.newProperties={focus:o,anchor:i}))}}),[a]}return[a]}function iC(e,t,n){let r={...e};if(n>=0&&"set_selection"!==r.type&&Array.isArray(r.path)&&r.path[0]>=n+t&&r.path[0]+t>-1){let e=[r.path[0]+t,...r.path.slice(1)];r.path=e}if("set_selection"===r.type){let e=r.properties?.focus?{...r.properties.focus}:void 0,o=r?.properties?.anchor?{...r.properties.anchor}:void 0,a=r?.newProperties?.focus?{...r.newProperties.focus}:void 0,i=r?.newProperties?.anchor?{...r.newProperties.anchor}:void 0;
17(e&&o||a&&i)&&([e,o,a,i].forEach(e=>{e&&e.path[0]>=n+t&&e.path[0]+t>-1&&(e.path=[e.path[0]+t,...e.path.slice(1)])}),e&&o&&(r.properties={focus:e,anchor:o}),a&&i&&(r.newProperties={focus:a,anchor:i}))}return r}function iB(e){switch(e.type){case"insert_node":return{...e,type:"remove_node"};case"insert_text":return{...e,type:"remove_text"};case"remove_node":return{...e,type:"insert_node"};case"remove_text":return{...e,type:"insert_text"};case"set_node":{let{properties:t,newProperties:n}=e;return{...e,properties:n,newProperties:t}}case"set_selection":{let{properties:t,newProperties:n}=e;return null==t?{...e,properties:n,newProperties:null}:null==n?{...e,properties:null,newProperties:t}:{...e,properties:n,newProperties:t}}}}function iE(e,t,n){let r="start"===n?ep(e,t):ta(e,t);e.apply({type:"set_selection",properties:e.selection,newProperties:{anchor:r,focus:r}})}function iD(e){e.selection&&e.apply({type:"set_selection",properties:e.selection,newProperties:null})}function i_(e,t){e.apply({type:"set_selection",properties:e.selection,newProperties:{anchor:t,focus:t}})}function iw(e,t){e.apply({type:"set_selection",properties:e.selection,newProperties:t})}function iA(e,t,n,r){e.apply({type:"insert_node",path:t,node:n}),"none"!==r&&iE(e,t,r)}function iS(e,t){let n=U(e,t);if(!n)return;let{node:r,path:o}=n;e.apply({type:"remove_node",path:o,node:r})}function iF(e,t,n,r){let o=null!==e.selection;if(e.apply({type:"insert_node",path:t,node:n}),iS(e,na(t)),"none"===r&&!o)return;let a="end"===r?ta(e,t):ep(e,t);iD(e),e.apply({type:"set_selection",properties:null,newProperties:{anchor:a,focus:a}})}function iP(e,t){let[n,r]=ei(t);n.path[0]===r.path[0]?function(e,t,n){let r=[t.path[0]];if(ex(t.path,n.path)){let r=no(e,t.path);if(!r)return;let o=r.node.text.slice(t.offset,n.offset);e.apply({type:"remove_text",path:t.path,offset:t.offset,text:o});return}let o=no(e,t.path);if(o&&t.offset<o.node.text.length){let n=o.node.text.slice(t.offset);e.apply({type:"remove_text",path:t.path,offset:t.offset,text:n})}for(let o=n.path[1]-1;o>t.path[1];o--)iS(e,[...r,o]);let a=[...r,t.path[1]+1],i=no(e,a);if(i&&n.offset>0){let t=i.node.text.slice(0,n.offset);e.apply({type:"remove_text",path:a,offset:0,text:t})}let l=no(e,t.path),s=no(e,a);l&&s&&oM(e,a,l.node.text.length)}(e,n,r):function(e,t,n){let r=[t.path[0]];if(t.path.length>1){let n=no(e,t.path);if(n&&t.offset<n.node.text.length){let r=n.node.text.slice(t.offset);e.apply({type:"remove_text",path:t.path,offset:t.offset,text:r})}let o=op(e,r);if(o)for(let n=o.node.children.length-1;n>t.path[1];n--)iS(e,[...r,n])}for(let r=n.path[0]-1;r>t.path[0];r--)iS(e,[r]);let o=[t.path[0]+1];if(n.path.length>1){for(let t=0;t<n.path[1];t++)iS(e,[...o,0]);let t=[...o,0],r=no(e,t);if(r&&n.offset>0){let o=r.node.text.slice(0,n.offset);e.apply({type:"remove_text",path:t,offset:0,text:o})}}let a=op(e,r),i=op(e,o);if(a&&i){let t=a.node,n=i.node;o_(e,()=>{Array.isArray(n.markDefs)&&n.markDefs.length>0&&oz(e,{markDefs:[...new Map([...Array.isArray(t.markDefs)&&t.markDefs||[],...n.markDefs].map(e=>[e._key,e])).values()]},r),oM(e,o,t.children.length)})}}(e,n,r)}function iO(e,t,n){if(!(0,d.zS)({schema:e.schema},t))return;n.offset>0&&no(e,n.path)&&ow(e,n.path,n.offset);let r=nI(n.path),o=n.path[n.path.length-1]+ +(n.offset>0);for(let n of t.children){let t=[...r,o];e.apply({type:"insert_node",path:t,node:n}),o++}}function iM(e,t={}){let{selection:n}=e;if(!n)return;let{distance:r=1,unit:o="character",reverse:a=!1}=t,{anchor:i,focus:l}=n,s={distance:r,unit:o},c=a?tR(e,i,s):tT(e,i,s),u=a?tR(e,l,s):tT(e,l,s),d={};c&&(d.anchor=c),u&&(d.focus=u),(d.anchor||d.focus)&&r5(e,{...n,...d})}let iT={"annotation.add":({context:e,operation:t})=>{let n=(0,h.fr)({annotation:{_type:t.annotation.name,_key:t.annotation._key,...t.annotation.value},context:e,options:{validateFields:!0}});if(!n)throw Error(`Failed to parse annotation ${j(t.annotation)}`);let r=t.editor,o=t.at?te({context:{schema:e.schema,value:t.editor.children,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):null,a=o??r.selection;if(!a||eB(a))return;let i=o?t7(r,o,{affinity:"inward"}):null,l=Array.from(ey(r,{from:es(a).path,to:el(a).path,match:e=>(0,d.zS)({schema:r.schema},e),reverse:ea(a)})),s=0;for(let{node:t,path:a}of l){if(!(0,d.zS)({schema:r.schema},t)||0===t.children.length||1===t.children.length&&t.children[0]?.text==="")continue;let l=0===s?n._key:e.keyGenerator(),c=t.markDefs??[];void 0===c.find(e=>e._type===n._type&&e._key===l)&&oz(r,{markDefs:[...c,{...n,_key:l}]},a);let u=o??r.selection;if(u&&en(u)){let e=U(r,u.anchor.path),t=e&&iv(r,e.path)?e.node:void 0;if(!(t&&eB(u)&&(0,d.bl)({schema:r.schema},t)&&t.text.length>0)){let e=t7(r,u,{affinity:"inward"}),[t,n]=ei(u);ok(r,n,n.path)&&ox(r,n,n.path)||ow(r,n.path,n.offset),ob(r,t,t.path)&&ox(r,t,t.path)||ow(r,t.path,t.offset);let a=e.unref();!o&&a&&r5(r,a)}}let h=N(r,a),p=i?.current??r.selection;for(let{node:e,path:t}of h)(0,d.bl)({schema:r.schema},e)&&p&&rx(p,t)&&oz(r,{marks:[...e.marks??[],l]},t);s++}i?.unref()},"annotation.remove":({context:e,operation:t})=>{let n=t.editor,r=t.at?te({context:{schema:e.schema,value:t.editor.children,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):null,o=r??n.selection;if(o)if(eB(o)){let e=U(n,ec(n,o,{depth:1}));if(!e)return;let{node:r,path:a}=e;if(!(0,d.zS)({schema:n.schema},r))return;let i=(r.markDefs??[]).filter(e=>e._type===t.annotation.name),l=U(n,ec(n,o,{depth:2}));if(!l)return;let{node:s,path:c}=l;if(!(0,d.bl)({schema:n.schema},s))return;
17let u=s.marks?.find(e=>i.some(t=>t._key===e));if(!u)return;let h=[],p=N(n,a);for(let e=p.length-1;e>=0;e--){let t=p[e];if(!t)continue;let{node:r,path:o}=t;if((0,d.bl)({schema:n.schema},r)&&-1===er(o,c))if(r.marks?.includes(u))h.push([r,o]);else break}let f=[];for(let{node:e,path:t}of N(n,a))if((0,d.bl)({schema:n.schema},e)&&1===er(t,c))if(e.marks?.includes(u))f.push([e,t]);else break;for(let[e,t]of[...h,[s,c],...f])oz(n,{marks:e.marks?.filter(e=>e!==u)},t)}else{let e=r?t7(n,r,{affinity:"inward"}):null,a=r??n.selection;if(a&&en(a)){let e=U(n,a.anchor.path),t=e&&iv(n,e.path)?e.node:void 0;if(!(t&&eB(a)&&(0,d.bl)({schema:n.schema},t)&&t.text.length>0)){let e=t7(n,a,{affinity:"inward"}),[t,o]=ei(a);ok(n,o,o.path)&&ox(n,o,o.path)||ow(n,o.path,o.offset),ob(n,t,t.path)&&ox(n,t,t.path)||ow(n,t.path,t.offset);let i=e.unref();!r&&i&&r5(n,i)}}let i=Array.from(ey(n,{from:es(o).path,to:el(o).path,match:e=>(0,d.zS)({schema:n.schema},e)})),l=e?.current??n.selection;for(let{node:e,path:r}of i)if((0,d.zS)({schema:n.schema},e))for(let{node:o,path:a}of N(n,r)){if(!(0,d.bl)({schema:n.schema},o)||!l||!rx(l,a))continue;let r=e.markDefs??[],i=o.marks??[],s=i.filter(e=>r.find(t=>t._key===e)?._type!==t.annotation.name);s.length!==i.length&&oz(n,{marks:s},a)}e?.unref()}},"block.set":({context:e,operation:t})=>{let n=t.editor.blockIndexMap.get(t.at[0]._key);if(void 0===n)throw Error(`Unable to find block index for block at ${j(t.at)}`);let r=t.editor.children.at(n);if(!r)throw Error(`Unable to find block at ${j(t.at)}`);if((0,p.xN)(e,r)){let r={};for(let n of Object.keys(t.props))if("_type"!==n&&"children"!==n){if("_key"===n){r[n]=t.props[n];continue}if("style"===n){e.schema.styles.some(e=>e.name===t.props[n])&&(r[n]=t.props[n]);continue}if("listItem"===n){e.schema.lists.some(e=>e.name===t.props[n])&&(r[n]=t.props[n]);continue}if("level"===n){r[n]=t.props[n];continue}if("markDefs"===n){let{markDefs:o}=(0,h.Hj)({context:e,markDefs:t.props[n],options:{validateFields:!0}});r[n]=o;continue}e.schema.block.fields?.some(e=>e.name===n)&&(r[n]=t.props[n])}oz(t.editor,r,[n])}else{let o=e.schema.blockObjects.find(e=>e.name===r._type),a={};for(let e of Object.keys(t.props))if("_type"!==e){if("_key"===e){a[e]=t.props[e];continue}o?.fields.some(t=>t.name===e)&&(a[e]=t.props[e])}let i=Object.entries(a).map(([e,t])=>(0,w.hZ)(t,[e])),l=(0,w.yl)(r,i);oz(t.editor,l,[n])}},"block.unset":({context:e,operation:t})=>{let n=t.at[0]._key,r=t.editor.blockIndexMap.get(n);if(void 0===r)throw Error(`Unable to find block index for block key ${n}`);let o=void 0!==r?t.editor.children.at(r):void 0;if(!o)throw Error(`Unable to find block at ${j(t.at)}`);if((0,p.xN)(e,o)){let n=t.props.filter(e=>"_type"!==e&&"_key"!==e&&"children"!==e),o={};for(let e of n)o[e]=null;oz(t.editor,o,[r]),t.props.includes("_key")&&oz(t.editor,{_key:e.keyGenerator()},[r]);return}let a={};for(let n of t.props)"_type"!==n&&("_key"===n?a._key=e.keyGenerator():a[n]=null);oz(t.editor,a,[r])},"child.set":({context:e,operation:t})=>{let n=te({context:{schema:e.schema,value:t.editor.children,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}},blockIndexMap:t.editor.blockIndexMap});if(!n)throw Error(`Unable to convert ${j(t.at)} into a Slate Range`);let r=ec(t.editor,n,{depth:2}),o=U(t.editor,r);
17if(!o)throw Error(`Unable to find child at ${j(t.at)}`);let{node:a,path:i}=o;if((0,d.bl)({schema:t.editor.schema},a)){let{_type:e,text:n,...r}=t.props;oz(t.editor,{...a,...r},i),"string"==typeof n&&a.text!==n&&(t.editor.apply({type:"remove_text",path:i,offset:0,text:a.text}),t.editor.apply({type:"insert_text",path:i,offset:0,text:n}));return}if(T({schema:t.editor.schema},a)){let n=e.schema.inlineObjects.find(e=>e.name===a._type);if(!n)throw Error(`Unable to find schema definition for Inline Object type ${a._type}`);let{_type:r,_key:o,...l}=t.props;for(let e in l)n.fields.some(t=>t.name===e)||delete l[e];oz(t.editor,{...a,_key:"string"==typeof o?o:a._key,...l},i);return}throw Error(`Unable to determine the type of child at ${j(t.at)}`)},"child.unset":({context:e,operation:t})=>{let n=t.at[0]._key,r=t.editor.blockIndexMap.get(n);if(void 0===r)throw Error(`Unable to find block index for block key ${n}`);let o=void 0!==r?t.editor.children.at(r):void 0;if(!o)throw Error(`Unable to find block at ${j(t.at)}`);if(!(0,d.zS)(e,o))throw Error(`Block ${j(n)} is not a text block`);let a=t.at[2]._key;if(!a)throw Error(`Unable to find child key at ${j(t.at)}`);let i=o.children.findIndex(e=>e._key===a);if(-1===i)throw Error(`Unable to find child at ${j(t.at)}`);let l=U(t.editor,[r,i]);if(!l)throw Error(`Unable to find child at ${j(t.at)}`);let{node:s,path:c}=l;if((0,d.bl)({schema:t.editor.schema},s)){let n={};for(let r of t.props)if("text"!==r&&"_type"!==r){if("_key"===r){n._key=e.keyGenerator();continue}n[r]=null}oz(t.editor,n,c),t.props.includes("text")&&t.editor.apply({type:"remove_text",path:c,offset:0,text:s.text});return}if(T({schema:t.editor.schema},s)){let n={};for(let r of t.props)"_type"!==r&&("_key"===r?n._key=e.keyGenerator():n[r]=null);oz(t.editor,n,c);return}throw Error(`Unable to determine the type of child at ${j(t.at)}`)},"decorator.add":({context:e,operation:t})=>{let n=t.editor,r=t.decorator,o=t.at?te({context:{schema:e.schema,value:t.editor.children,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):t.editor.selection;if(o){if(eD(o)){let e=t7(n,o,{affinity:"inward"}),[a,i]=ei(o);if(ok(n,i,i.path)&&ox(n,i,i.path)||ow(n,i.path,i.offset),ob(n,a,a.path)&&ox(n,a,a.path)||ow(n,a.path,a.offset),!(o=e.unref()))throw Error("Unable to add decorator without a selection");for(let{node:e,path:a}of(t.at||r5(n,o),Array.from(ey(n,{from:es(o).path,to:el(o).path,match:e=>(0,d.bl)({schema:n.schema},e)}))))(0,d.bl)({schema:n.schema},e)&&oz(n,{marks:[...(Array.isArray(e.marks)?e.marks:[]).filter(e=>e!==r),r]},a)}else{if(!Array.from(ey(n,{from:es(o).path,to:el(o).path,match:e=>(0,d.bl)({schema:n.schema},e)}))?.at(0))return;let e=U(n,ec(n,o,{depth:1}));if(!e)return;let{node:t,path:a}=e,i=(0,d.zS)({schema:n.schema},t)&&1===t.children.length&&(0,d.bl)({schema:n.schema},t.children[0])&&""===t.children[0].text?t.children[0]:void 0;if(i){let e=i.marks??[],t=e.filter(e=>e!==r),o=e.length===t.length?[...e,r]:t;for(let{path:e}of Array.from(ey(n,{at:a,match:e=>(0,d.bl)({schema:n.schema},e)})))oz(n,{marks:o},e)}else n.decoratorState[r]=!0}if(n.selection){let e=n.selection;n.selection={...e}}}},"decorator.remove":({context:e,operation:t})=>{let n=t.editor,r=t.decorator,o=t.at?te({context:{schema:e.schema,value:t.editor.children,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):n.selection;if(o){if(eD(o)){let t=t7(n,o,{affinity:"inward"}),a=U(n,o.anchor.path),i=a&&iv(n,a.path)?a.node:void 0;if(!(i&&eB(o)&&(0,d.bl)({schema:n.schema},i)&&i.text.length>0)){let[e,t]=ei(o);ok(n,t,t.path)&&ox(n,t,t.path)||ow(n,t.path,t.offset),ob(n,e,e.path)&&ox(n,e,e.path)||ow(n,e.path,e.offset)}let l=t.unref();if(l)for(let{node:t,path:o}of[...ey(n,{from:es(l).path,to:el(l).path,match:e=>(0,d.bl)({schema:n.schema},e)})]){if(!(0,d.bl)({schema:n.schema},t))continue;let a=n.children[o[0]];(0,d.zS)({schema:n.schema},a)&&a.children.includes(t)&&oz(n,{marks:(Array.isArray(t.marks)?t.marks:[]).filter(e=>e!==r),_type:e.schema.span.name},o)}}else{let e=U(n,ec(n,o,{depth:1}));if(!e)return;let{node:t,path:a}=e,i=(0,d.zS)({schema:n.schema},t)&&1===t.children.length&&(0,d.bl)({schema:n.schema},t.children[0])&&""===t.children[0].text?t.children[0]:void 0;if(i){let e=(i.marks??[]).filter(e=>e!==r);for(let{path:t}of Array.from(ey(n,{at:a,match:e=>(0,d.bl)({schema:n.schema},e)})))oz(n,{marks:e},t)}else n.decoratorState[r]=!1}if(n.selection){let e=n.selection;n.selection={...e}}}},delete:({context:e,operation:t})=>{let n,r=t.at?te({context:{schema:e.schema,value:t.editor.children,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):t.editor.selection;if(!r)throw Error("Unable to delete without a selection");let[o,a]=ei(r);if("block"===t.unit){let e,n=o.path.at(0),r=a.path.at(0);if(void 0===n||void 0===r)throw Error("Failed to get start or end block
17index");let i=ei({anchor:{path:[n],offset:0},focus:{path:[r],offset:0}}),l=[];for(let n of ey(t.editor,{from:i[0].path,to:i[1].path})){let{path:r}=n;e&&ti(e,r)||e4(t.editor,r)&&(e=r,l.push(n))}for(let e of Array.from(l,e=>oC(t.editor,e.path))){let n=e.unref();if(n){let e=U(t.editor,n);if(e){let r=e.node;t.editor.apply({type:"remove_node",path:n,node:r})}}}return}if("child"===t.unit){for(let e of Array.from(ey(t.editor,{from:o.path,to:a.path,match:(e,n)=>!e4(t.editor,n)}),e=>oC(t.editor,e.path))){let n=e.unref();if(n){let e=U(t.editor,n);if(e){let r=e.node;t.editor.apply({type:"remove_node",path:n,node:r})}}}return}if("backward"===t.direction&&"line"===t.unit){let e,n,o=ex(r.anchor.path,r.focus.path)?ef(t.editor,r.anchor.path):(e=X(r.anchor.path,r.focus.path),(n=U(t.editor,e))&&(0,p.xN)({schema:t.editor.schema},n.node)?n:ef(t.editor,e));if(o){let e=o.path,n=tO(t.editor,e,r.anchor),a=function(e,t){let n=tO(e,el(t)),r=Array.from(tM(e,{at:t})),o=0,a=r.length,i=Math.floor(a/2);if(ik(e,tO(e,r[o]),n))return tO(e,r[o],n);if(r.length<2)return tO(e,r[r.length-1],n);for(;i!==r.length&&i!==o;)ik(e,tO(e,r[i]),n)?a=i:o=i,i=Math.floor((o+a)/2);return tO(e,r[o],n)}(t.editor,n);if(!eB(a))return void az(t.editor,{at:a})}}if("word"===t.unit&&eB(r))return void az(t.editor,{at:r,unit:"word",reverse:"backward"===t.direction});if(eB(r)&&o.path.length>=2){let e=U(t.editor,o.path);if(e){let{node:n,path:r}=e;if(T({schema:t.editor.schema},n))return void t.editor.apply({type:"remove_node",path:r,node:n})}}let i=(()=>{let e=o.path.at(0);if(void 0!==e){let n=U(t.editor,[e]);if(n&&T({schema:t.editor.schema},n.node))return n}})(),l=(()=>{let e=a.path.at(0);if(void 0!==e){let n=U(t.editor,[e]);if(n&&T({schema:t.editor.schema},n.node))return n}})(),s=i??e3(t.editor,o.path),c=l??e3(t.editor,a.path),u=s&&c&&!ex(s.path,c.path),d=s&&T({schema:t.editor.schema},s.node)?s:void 0,h=c&&T({schema:t.editor.schema},c.node)?c:void 0,f=d??J(t.editor,o.path),y=h??J(t.editor,a.path),m=[];for(let e of ey(t.editor,{from:o.path,to:a.path})){let{node:r,path:i}=e;n&&0===er(i,n)||!T({schema:t.editor.schema},r)&&(aT(i,o.path)||aT(i,a.path))||(m.push(e),n=i)}let g=Array.from(m,e=>oC(t.editor,e.path)),v=aO(t.editor,o),k=aO(t.editor,a);if(s&&c&&eC(o,ep(t.editor,s.path))&&eC(a,ta(t.editor,c.path))&&u){if(!f){let e=v.current,n=no(t.editor,e.path);if(n){let r=n.node;r.text.length>0&&t.editor.apply({type:"remove_text",path:e.path,offset:0,text:r.text})}}for(let e of g.reverse()){let n=e.unref();if(n){let e=U(t.editor,n);if(e){let r=e.node;t.editor.apply({type:"remove_node",path:n,node:r})}}}if(!y){let e=k.current,n=no(t.editor,e.path);if(n){let r=n.node,{path:o}=e,i=r.text.slice(0,a.offset);i.length>0&&t.editor.apply({type:"remove_text",path:o,offset:0,text:i})}}if(k.current&&v.current)for(let e of Array.from(ey(t.editor,{from:k.current.path,to:k.current.path,match:(e,n)=>e4(t.editor,n)}),e=>oC(t.editor,e.path))){let n=e.unref();if(n){let e=U(t.editor,n);if(e){let r=e.node;t.editor.apply({type:"remove_node",path:n,node:r})}}}v.current&&t.editor.selection&&t.editor.apply({type:"set_selection",properties:t.editor.selection,newProperties:{anchor:v.current,focus:v.current}});return}if(f&&s&&c&&ex(s.path,c.path)&&T({schema:t.editor.schema},s.node)){let e=s.path;t.editor.apply({type:"remove_node",path:e,node:s.node});return}let b=!1;for(let e of[...g].reverse()){let n=e.current;if(n){let r=U(t.editor,n);if(r&&T({schema:t.editor.schema},r.node)){let n=e.unref();n&&(h&&ex(n,h.path)&&(b=!0),t.editor.apply({type:"remove_node",path:n,node:r.node}))}}}let x=v.current,C=k.current,B=(()=>{if(!x)return r;if(b&&(!C||x.path.at(0)!==C.path.at(0))){let e=ta(t.editor,[x.path.at(0)]);return{anchor:x,focus:e}}return C?{anchor:x,focus:C}:r})(),E="backward"===t.direction,D=E?!!a&&(!(0,p.xN)(e,c?.node)||0===a.offset):!!o&&(!(0,p.xN)(e,s?.node)||0===o.offset);b?(az(t.editor,{at:B,reverse:E}),t.editor.selection&&v.current&&t.editor.apply({type:"set_selection",properties:t.editor.selection,newProperties:{anchor:v.current,focus:v.current}})):t.at?az(t.editor,{at:B,hanging:D,reverse:E}):az(t.editor,{hanging:D,reverse:E})},"history.redo":({operation:e})=>{let t=e.editor,{redos:n}=t.history;if(n.length>0){let e=n[n.length-1];if(e.operations.length>0){let n=t.remotePatches.filter(t=>t.time>=e.timestamp),r=e.operations;
17n.forEach(e=>{r=r.flatMap(n=>ix(t,e.patch,n,e.snapshot,e.previousSnapshot))});try{o_(t,()=>{let e;e=t.isRedoing,t.isRedoing=!0,(()=>{ab(t,()=>{r.forEach(e=>{t.apply(e)})})})(),t.isRedoing=e})}catch(e){console.error(`Could not perform 'history.redo' operation: ${e instanceof Error?e.message:e}`),t.remotePatches.splice(0,t.remotePatches.length),r7(t),t.history={undos:[],redos:[]},t.withHistory=!0,t.isRedoing=!1,t.onChange();return}t.history.undos.push(e),t.history.redos.pop()}}},"history.undo":({operation:e})=>{let t=e.editor,{undos:n}=t.history;if(n.length>0){let e=n[n.length-1];if(e.operations.length>0){let n=t.remotePatches.filter(t=>t.time>=e.timestamp),r=e.operations;n.forEach(e=>{r=r.flatMap(n=>ix(t,e.patch,n,e.snapshot,e.previousSnapshot))});let o=r.map(iB).reverse();try{o_(t,()=>{let e;e=t.isUndoing,t.isUndoing=!0,(()=>{ab(t,()=>{o.forEach(e=>{t.apply(e)})})})(),t.isUndoing=e})}catch(e){console.error(`Could not perform 'history.undo' operation: ${e instanceof Error?e.message:e}`),t.remotePatches.splice(0,t.remotePatches.length),r7(t),t.history={undos:[],redos:[]},t.withHistory=!0,t.isUndoing=!1,t.onChange();return}t.history.redos.push(e),t.history.undos.pop()}}},"insert.block":({context:e,operation:t})=>{let n=(0,h.rT)({block:t.block,context:e,options:{normalize:!0,removeUnusedMarkDefs:!0,validateFields:!0}});if(!n)throw Error(`Failed to parse block ${j(t.block)}`);let r=ay(n,{schemaTypes:e.schema});!function(e){let{context:t,block:n,placement:r,select:o,editor:a}=e,i=e.at?te({context:{schema:t.schema,value:a.children,selection:e.at},blockIndexMap:a.blockIndexMap}):a.selection;if(0===a.children.length)return iA(a,[0],n,o);let l=i?es(i):ep(a,[]),s=i?el(i):ta(a,[]),c=e=>{for(let t=e.length;t>=1;t--){let n=e.slice(0,t),r=U(a,n);if(r&&e4(a,n))return r}},u=c(l.path),h=u?.node,p=u?.path,f=c(s.path),y=f?.node,m=f?.path;if(!h||!p||!y||!m)throw Error("Unable to insert block without a start and end block");if("before"===r)return iA(a,p,n,o);if("after"===r)return iA(a,na(m),n,o);if(!i){if((0,g.wm)(t,y))return iF(a,m,n,o);if((0,d.zS)({schema:a.schema},n)&&(0,d.zS)({schema:a.schema},y)){let e=ta(a,m);iO(a,n,e),"start"===o?i_(a,e):"none"===o&&iD(a);return}return iA(a,na(m),n,o)}if(eD(i)&&!(0,d.zS)({schema:a.schema},n)){let e=t7(a,i,{affinity:"inward"}),r=es(i),l=op(a,[r.path[0]]),s=ep(a,[r.path[0]]),c=void 0!==l&&eC(r,s);iP(a,i);let u=e.unref()??a.selection,h=u?t7(a,u,{affinity:"inward"}):void 0;if(u){let e=c?[u.anchor.path[0]]:[u.anchor.path[0]+1];if(a.apply({type:"insert_node",path:e,node:n}),"none"!==o){let t=ep(a,e);a.apply({type:"set_selection",properties:a.selection,newProperties:{anchor:t,focus:t}})}}let p=h?.unref()??a.selection;if("none"===o&&p&&a.apply({type:"set_selection",properties:a.selection,newProperties:p}),!(0,d.zS)({schema:a.schema},n)&&u){let e=op(a,c?[u.anchor.path[0]+1]:[u.anchor.path[0]]);e&&(0,g.wm)(t,e.node)&&a.apply({type:"remove_node",path:e.path,node:e.node})}return}if(!(0,d.zS)({schema:a.schema},n)&&(0,d.zS)({schema:a.schema},y)&&!eD(i)){let e=es(i),t=[e.path[0]],r=ep(a,t),l=ta(a,t),s=eC(e,r),c=eC(e,l);if(!s&&!c){if(!op(a,t))return;let r=e.path[1],i=e.offset;if(i>0){let t=no(a,e.path);t&&i<t.node.text.length&&ow(a,e.path,i)}ow(a,t,i>0?r+1:r);let l=[t[0]+1];if(a.apply({type:"insert_node",path:l,node:n}),"none"===o){let e=ta(a,t);a.apply({type:"set_selection",properties:a.selection,newProperties:{anchor:e,focus:e}})}else if("start"===o){let e=ep(a,l);a.apply({type:"set_selection",properties:a.selection,newProperties:{anchor:e,focus:e}})}else if("end"===o){let e=ta(a,l);a.apply({type:"set_selection",properties:a.selection,newProperties:{anchor:e,focus:e}})}return}}if((0,d.zS)({schema:a.schema},y)&&(0,d.zS)({schema:a.schema},n)){let e=es(i),r=!1;if(eD(i)){let[t,n]=ei(i),o=t.path[0]!==n.path[0];if(iP(a,i),o){r=!0;let n=[t.path[0]];if(op(a,n)){let r={path:[...n,t.path[1]],offset:t.offset};i_(a,r),e=r}}let l=a.children.length-1,s=l>=0?U(a,[l]):void 0,c=s?.node,u=s?.path;c&&u&&((0,d.zS)({schema:a.schema},c)||T({schema:a.schema},c))&&(y=c,m=u)}if(!(0,d.zS)({schema:a.schema},y))return;if((0,g.wm)(t,y))return iF(a,m,n,o);let l=y.children.map(e=>e._key),s=y.markDefs?.map(e=>e._key)??[],c=new Map,u=n.markDefs?.map(e=>{if(s.includes(e._key)){let n=t.keyGenerator();return c.set(e._key,n),{...e,_key:n}}return e}),h=n.children.map(e=>{if((0,d.bl)(t,e)){let n=e.marks?.map(e=>c.get(e)||e)??[];
17if(!rm(e.marks,n))return{...e,_key:l.includes(e._key)?t.keyGenerator():e._key,marks:n}}return l.includes(e._key)?{...e,_key:t.keyGenerator()}:e}),p=op(a,m);if(p){let e={markDefs:p.node.markDefs},t={markDefs:[...y.markDefs??[],...u??[]]};a.apply({type:"set_node",path:m,properties:e,newProperties:t})}let f=rv(n.children,h,t.schema.span.name)?n:{...n,children:h};if("end"===o){let e=a.selection?el(a.selection):ta(a,m);iO(a,f,e);return}(iO(a,f,e),"start"===o)?i_(a,e):"none"===o&&(r?i_(a,e):eC(e,ep(a,m))||i_(a,e))}else{if(!(0,d.zS)({schema:a.schema},y))return iA(a,[m[0]+1],n,o);let e=ep(a,m),r=ta(a,m),l=es(i),s=el(i);if(eB(i)&&eC(l,e)){a.apply({type:"insert_node",path:m,node:n}),"none"!==o&&iE(a,m,"start"),(0,g.wm)(t,y)&&iS(a,na(m));return}if(eB(i)&&eC(s,r)){let e=[m[0]+1];a.apply({type:"insert_node",path:e,node:n}),"none"!==o&&iE(a,e,"start");return}if(eD(i)&&eC(l,e)&&eC(s,r)){a.apply({type:"insert_node",path:m,node:n}),iS(a,na(m)),"none"!==o&&iE(a,m,o);return}if(eD(i)&&eC(l,e)){let[,e]=ei(i),t=no(a,e.path);t&&e.offset>0&&a.apply({type:"remove_text",path:e.path,offset:0,text:t.node.text.slice(0,e.offset)});for(let t=e.path[1]-1;t>=0;t--)iS(a,[...m,t]);iO(a,n,ep(a,m)),"none"!==o&&iE(a,m,o);return}if(eD(i)&&eC(s,r)){let[e]=ei(i),t=op(a,m);if(!t)return;for(let n=t.node.children.length-1;n>e.path[1];n--)iS(a,[...m,n]);let r=no(a,e.path);r&&e.offset<r.node.text.length&&a.apply({type:"remove_text",path:e.path,offset:e.offset,text:r.node.text.slice(e.offset)}),iO(a,n,e),"none"!==o&&iE(a,na(m),o);return}let c=a.selection?.focus.path.at(1),u=a.selection?.focus.path.slice(0,1),h=void 0!==c&&u?N(a,u).at(c)?.node:void 0;if(h&&(0,d.bl)({schema:a.schema},h)){let e=es(i);if((0,d.zS)({schema:a.schema},n))no(a,e.path)&&ow(a,e.path,e.offset),iO(a,n,e),"none"===o?iw(a,i):iE(a,[m[0]+1],"start");else{let t=e.path,r=e.offset,i=aO(a,e,{affinity:"backward"}),l=[t[0]],s=oC(a,l),c=no(a,t);c&&r>0&&r<c.node.text.length&&(ow(a,t,r),t=na(t),r=0);let u=r>0?t[1]+1:t[1],d=op(a,l);d&&u<d.node.children.length&&ow(a,l,u);let h=s.unref(),p=h?[h[0]+1]:[l[0]+1];if(a.apply({type:"insert_node",path:p,node:n}),"start"===o||"end"===o){let e=ep(a,p);a.apply({type:"set_selection",properties:a.selection,newProperties:{anchor:e,focus:e}})}else{let e=i.unref();e&&a.apply({type:"set_selection",properties:a.selection,newProperties:{anchor:e,focus:e}})}}}else{let e=[m[0]+1];a.apply({type:"insert_node",path:e,node:n}),"none"===o?iw(a,i):iE(a,e,o)}}}({context:e,block:r,placement:t.placement,select:t.select??"start",at:t.at,editor:t.editor})},"insert.child":({context:e,operation:t})=>{let n=t.editor.selection?.focus,r=n?.path.at(0),o=n?.path.at(1);if(void 0===r||void 0===o)throw Error("Unable to insert child without a focus");let a=n?U(t.editor,n.path.slice(0,1)):void 0,i=a?.node,l=a?.path;if(!n||!i||!l)throw Error("Unable to insert child without a focus block");if(!(0,p.xN)(e,i))throw Error("Unable to insert child into a non-text block");let s=i.markDefs??[],c=new Map;for(let e of s)c.set(e._key,e._key);let u=(0,h.wr)({span:t.child,context:e,markDefKeyMap:c,options:{validateFields:!0}});if(u){let e=U(t.editor,n.path.slice(0,2));e&&(0,d.bl)({schema:t.editor.schema},e.node)&&e.node?oP(t.editor,u,n):oF(t.editor,u,[r,o+1]),t.editor.pendingSelection=t.editor.selection;return}let f=(0,h.lV)({inlineObject:t.child,context:e,options:{validateFields:!0}});if(f){let{_key:e,_type:a,...i}=f,l={_key:e,_type:a,...i},s=U(t.editor,n.path.slice(0,2));s&&(0,d.bl)({schema:t.editor.schema},s.node)&&s.node?oP(t.editor,l,n):oF(t.editor,l,[r,o+1]);return}throw Error("Unable to parse child")},"insert.text":({operation:e})=>{let{editor:t}=e,{selection:n}=t;if(!n||!eB(n))return;let{path:r,offset:o}=n.anchor,a=U(t,r);if(!a)return;let i=a.node;if(iv(t,a.path)&&!(0,d.bl)({schema:t.schema},i)){let e=na(r);if(!Z(t,e))return;if(!no(t,e))return;o=0,r5(t,{path:r=e,offset:o})}e.text.length>0&&t.apply({type:"insert_text",path:r,offset:o,text:e.text})},"move.backward":({operation:e})=>{iM(e.editor,{unit:"character",distance:e.distance,reverse:!0})},"move.block":({operation:e})=>{let t=(0,h.XE)({path:e.at});if(!t)throw Error("Failed to get block key from selection point");let n=e.editor.blockIndexMap.get(t);if(void 0===n)throw Error("Failed to get block index from block key");let r=(0,h.XE)({path:e.to});if(!r)throw Error("Failed to get block key from selection point");let o=e.editor.blockIndexMap.get(r);if(void 0===o)throw Error("Failed to get block index from block key");let a=e.editor,i=U(a,[n]);if(!i)return;let l=i.node,s=a.selection?{anchor:{...a.selection.anchor},focus:{...a.selection.focus}}:null;if(o_(a,()=>{a.apply({type:"remove_node",path:[n],node:l}),a.apply({type:"insert_node",path:[o],node:l})}),s){let e=e=>e.path[0]===n?{...e,path:[o,...e.path.slice(1)]}:e;
17a.selection={anchor:e(s.anchor),focus:e(s.focus)}}},"move.forward":({operation:e})=>{iM(e.editor,{unit:"character",distance:e.distance})},select:({context:e,operation:t})=>{let n=te({context:{schema:e.schema,value:t.editor.children,selection:t.at},blockIndexMap:t.editor.blockIndexMap});n?r5(t.editor,n):r7(t.editor),t.editor.focused&&t.editor.readOnly&&(t.editor.focused=!1)}};function iR({context:e,operation:t}){let n=()=>{try{(0,iT[t.type])({context:e,operation:t})}catch(e){console.error(Error(`Performing "${t.type}" failed due to: ${e instanceof Error?e.message:e}`))}};oB(t.editor)?o_(t.editor,n):n()}function iz(e,t){let n=e.isPerformingBehaviorOperation;e.isPerformingBehaviorOperation=!0,t(),e.isPerformingBehaviorOperation=n}let iI=[(0,B.Ke)({on:"annotation.set",guard:({snapshot:e,event:t})=>{let n=t.at[0]._key,r=t.at[2]._key,o=(0,p.hH)({...e,context:{...e.context,selection:{anchor:{path:[{_key:n}],offset:0},focus:{path:[{_key:n}],offset:0}}}});return!!o&&{blockKey:n,updatedMarkDefs:o.node.markDefs?.map(e=>e._key===r?{...e,...t.props}:e)}},actions:[(e,{blockKey:t,updatedMarkDefs:n})=>[(0,B.xl)({type:"block.set",at:[{_key:t}],props:{markDefs:n}})]]}),(0,B.Ke)({on:"annotation.toggle",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let r={...e,context:{...e.context,selection:n}};return(0,p.kK)(t.annotation.name)(r)},actions:[({event:e})=>[(0,B.xl)({type:"annotation.remove",annotation:e.annotation,at:e.at})]]}),(0,B.Ke)({on:"annotation.toggle",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let r={...e,context:{...e.context,selection:n}};return!(0,p.kK)(t.annotation.name)(r)},actions:[({event:e})=>[(0,B.xl)({type:"annotation.add",annotation:e.annotation,at:e.at})]]})],ij=[(0,B.Ke)({on:"decorator.toggle",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let r={...e,context:{...e.context,selection:n}};return(0,p.Y1)(t.decorator)(r)},actions:[({event:e})=>[(0,B.xl)({type:"decorator.remove",decorator:e.decorator,at:e.at})]]}),(0,B.Ke)({on:"decorator.toggle",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let r={...e,context:{...e.context,selection:n}};return!(0,p.Y1)(t.decorator)(r)},actions:[({event:e})=>[(0,B.xl)({...e,type:"decorator.add"})]]})],iN=[(0,B.Ke)({on:"delete.backward",guard:({snapshot:e})=>e.context.selection,actions:[({event:e})=>[(0,B.xl)({type:"delete",direction:"backward",unit:e.unit})]]}),(0,B.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{if("backward"!==t.direction)return!1;let n=t.at??e.context.selection;if(!n)return!1;let r={...e,context:{...e.context,selection:n}},o=(0,p.HA)(r),a=(0,p.hH)(r);if(!o||!a||!(0,p.HX)(a)(r))return!1;let i=(0,h.J8)({context:e.context,block:o});return!!(0,p.xN)(e.context,o.node)&&{previousBlockEndPoint:i,focusTextBlock:a}},actions:[(e,{previousBlockEndPoint:t,focusTextBlock:n})=>[(0,B.xl)({type:"delete.block",at:n.path}),(0,B.xl)({type:"select",at:{anchor:t,focus:t}}),(0,B.xl)({type:"insert.block",block:n.node,placement:"auto",select:"start"})]]}),(0,B.Ke)({on:"delete.forward",guard:({snapshot:e})=>e.context.selection,actions:[({event:e})=>[(0,B.xl)({type:"delete",direction:"forward",unit:e.unit})]]}),(0,B.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{if("forward"!==t.direction)return!1;let n=t.at??e.context.selection;if(!n)return!1;let r=(0,p.RL)({...e,context:{...e.context,selection:n}}),o=(0,p.hH)({...e,context:{...e.context,selection:n}});return!!r&&!!o&&!!(0,g.wm)(e.context,o.node)&&{focusTextBlock:o,nextBlockStartPoint:(0,h.u3)({context:e.context,block:r})}},actions:[(e,{focusTextBlock:t,nextBlockStartPoint:n})=>[(0,B.xl)({type:"delete.block",at:t.path}),(0,B.xl)({type:"select",at:{anchor:n,focus:n}})]]}),(0,B.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{if("forward"!==t.direction)return!1;let n=t.at??e.context.selection;if(!n)return!1;let r={...e,context:{...e.context,selection:n}},o=(0,p.RL)(r),a=(0,p.hH)(r);return!!o&&!!a&&!!(0,p.Qm)(a)(r)&&!!(0,p.xN)(e.context,o.node)&&{nextBlock:o}},actions:[(e,{nextBlock:t})=>[(0,B.xl)({type:"delete.block",at:t.path}),(0,B.xl)({type:"insert.block",block:t.node,placement:"auto",select:"none"})]]}),(0,B.Ke)({on:"delete.block",actions:[({event:e})=>[(0,B.xl)({type:"delete",at:{anchor:{path:e.at,offset:0},focus:{path:e.at,offset:0}},unit:"block"})]]}),(0,B.Ke)({on:"delete.child",guard:({snapshot:e,event:t})=>{let n=(0,p.jR)({...e,context:{...e.context,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}}});return!!n&&((0,d.bl)(e.context,n.node)?{selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:n.node.text.length}}}:{selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}})},actions:[(e,{selection:t})=>[(0,B.xl)({type:"delete",at:t})]]}),(0,B.Ke)({on:"delete.text",actions:[({event:e})=>[(0,B.xl)({...e,type:"delete"})]]})],i$=["application/x-portable-text","application/json","text/markdown","text/html","text/plain"];function iK({dataTransfer:e,startAfter:t}){let n=t?i$.indexOf(t)+1:0;for(let t=n;t<i$.length;t++){let n=i$.at(t);if(!n)continue;let r=e.getData(n);if(r)return{mimeType:n,data:r}}}let iL=[(0,B.Ke)({on:"deserialize",guard:({event:e})=>{let t=iK({dataTransfer:e.originEvent.originEvent.dataTransfer});return!!t&&{type:"deserialize.data",mimeType:t.mimeType,data:t.data,originEvent:e.originEvent}},actions:[(e,t)=>[(0,B.xl)(t)]]}),(0,B.Ke)({on:"deserialize",actions:[({event:e})=>[(0,B.xl)({type:"deserialization.failure",mimeType:"*/*",reason:"No Behavior was able to handle the incoming data",originEvent:e.originEvent})]]}),(0,B.Ke)({on:"deserialize.data",guard:({event:e})=>
17{if("text/html"!==e.mimeType)return!1;let t=e.originEvent.originEvent.dataTransfer.getData("text/plain");return e.data===t&&{type:"deserialize.data",mimeType:"text/plain",data:t,originEvent:e.originEvent}},actions:[(e,t)=>[(0,B.xl)(t)]]}),(0,B.Ke)({on:"deserialize.data",guard:({snapshot:e,event:t})=>{if("text/plain"!==t.mimeType||"drag.drop"===t.originEvent.type||!(0,p.hH)(e))return!1;let n=e.context.converters.find(e=>e.mimeType===t.mimeType);if(!n)return!1;let r=n.deserialize({snapshot:e,event:{type:"deserialize",data:t.data}});if("deserialization.success"!==r.type)return!1;let o=(0,p.rm)(e);return{activeAnnotations:(0,p.Bg)(e),activeDecorators:o,textRuns:r.data.flatMap(t=>(0,d.zS)(e.context,t)?[(0,g.so)(t)]:[])}},actions:[(e,{activeAnnotations:t,activeDecorators:n,textRuns:r})=>r.flatMap((e,o)=>o!==r.length-1?[(0,B.xl)({type:"insert.span",text:e,decorators:n,annotations:t.map(({_key:e,_type:t,...n})=>({name:t,value:n}))}),(0,B.xl)({type:"insert.break"})]:[(0,B.xl)({type:"insert.span",text:e,decorators:n,annotations:t.map(({_key:e,_type:t,...n})=>({name:t,value:n}))})])]}),(0,B.Ke)({on:"deserialize.data",guard:({snapshot:e,event:t})=>{let n=e.context.converters.find(e=>e.mimeType===t.mimeType);return!!n&&n.deserialize({snapshot:e,event:{type:"deserialize",data:t.data}})},actions:[({event:e},t)=>[(0,B.xl)({...t,originEvent:e.originEvent})]]}),(0,B.Ke)({on:"deserialization.success",actions:[({event:e})=>[(0,B.xl)({type:"insert.blocks",blocks:e.data,placement:"auto"})]]}),(0,B.Ke)({on:"deserialization.failure",guard:({event:e})=>{if("*/*"===e.mimeType)return!1;let t=iK({dataTransfer:e.originEvent.originEvent.dataTransfer,startAfter:e.mimeType});return!!t&&{type:"deserialize.data",mimeType:t.mimeType,data:t.data,originEvent:e.originEvent}},actions:[(e,t)=>[(0,B.xl)(t)]]}),(0,B.Ke)({on:"deserialization.failure",actions:[({event:e})=>[{type:"effect",effect:()=>{console.warn(`Deserialization of ${e.mimeType} failed with reason "${e.reason}"`)}}]]})],iV=[(0,B.Ke)({on:"input.*",guard:({snapshot:e})=>(0,p.gR)(e),actions:[({event:e})=>[(0,B.xl)({type:"delete"}),(0,B.sY)(e)]]}),(0,B.Ke)({on:"input.*",guard:({event:e})=>{let t=e.originEvent.dataTransfer.getData("text/plain"),n=e.originEvent.dataTransfer.getData("text/html"),r=e.originEvent.dataTransfer.types;return!(!t||t.includes(` 18`))&&(1===r.length?{text:t}:!(r.length>2)&&!!n&&t===n&&{text:t})},actions:[(e,{text:t})=>[(0,B.xl)({type:"insert.text",text:t})]]}),(0,B.Ke)({on:"input.*",actions:[({event:e})=>[(0,B.xl)({type:"deserialize",originEvent:e})]]})];function iU(e){return t=>!e||t.blockIndexMap.has(e)?t.context.keyGenerator():e}let iW=[(0,B.Ke)({on:"insert.blocks",guard:({event:e})=>{let t=1===e.blocks.length?e.blocks.at(0):void 0;return!!t&&{onlyBlock:t}},actions:[({event:e},{onlyBlock:t})=>[(0,B.xl)({type:"insert.block",block:t,placement:e.placement,select:e.select??"end",...e.at?{at:e.at}:{}})]]}),(0,B.Ke)({on:"insert.blocks",guard:({event:e})=>"before"===e.placement||"after"===e.placement,actions:[({snapshot:e,event:t})=>{let n,r,o,a=[],i=-1;for(let l of t.blocks){i++;let s=iU(l._key)(e);0===i&&(n=s),i===t.blocks.length-1&&(r=s),a.push((0,B.xl)({type:"insert.block",block:s!==l._key?{...l,_key:s}:l,placement:"after"===t.placement?"after":0===i?"before":"after",select:"none",...o?{at:{anchor:{path:[{_key:o}],offset:0},focus:{path:[{_key:o}],offset:0}}}:t.at?{at:t.at}:{}})),o=s}let l=t.select??"end";return"start"===l&&n&&a.push((0,B.xl)({type:"select.block",at:[{_key:n}],select:"start"})),"end"===l&&r&&a.push((0,B.xl)({type:"select.block",at:[{_key:r}],select:"end"})),a}]}),(0,B.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{if("auto"!==t.placement)return!1;let n=t.at??e.context.selection;if(!n)return!1;let r={...e,context:{...e.context,selection:n}},o=(0,p.hH)(r);if(!o||(0,g.wm)(e.context,o.node))return!1;let a=(0,h.u3)({context:e.context,block:o}),i=(0,h.J8)({context:e.context,block:o}),l=(0,g.Bh)({context:{schema:e.context.schema,selection:{anchor:n.focus,focus:i}},block:o.node}),s=(0,p.xN)(e.context,t.blocks.at(0));return{focusTextBlock:o,focusBlockStartPoint:a,focusBlockEndPoint:i,focusTextBlockAfter:l,at:n,originalSelection:e.context.selection,isFirstBlockTextBlock:s}},actions:[({snapshot:e,event:t},{focusTextBlock:n,focusBlockEndPoint:r,focusTextBlockAfter:o,at:a,focusBlockStartPoint:i,isFirstBlockTextBlock:l,originalSelection:s})=>{let c,u,d=[],f=-1;for(let o of t.blocks){if(0==++f){(0,h._Q)(a.focus,r)||d.push((0,B.xl)({type:"delete",at:{anchor:a.focus,focus:r}}));let l=iU(o._key)(e),s=(0,h._Q)(a.focus,i);(0,p.xN)(e.context,o)&&!s?(u=n.node._key,c=n.node._key):(u=l,c=l),d.push((0,B.xl)({type:"insert.block",block:l!==o._key?{...o,_key:l}:o,placement:"auto",select:"end",...t.at?{at:t.at}:{}}));continue}if(f===t.blocks.length-1){d.push((0,B.xl)({type:"insert.block",block:o,placement:"after",select:"end",at:c?{anchor:{path:[{_key:c}],offset:0},focus:{path:[{_key:c}],offset:0}}:void 0}));continue}let l=iU(o._key)(e);d.push((0,B.xl)({type:"insert.block",block:l!==o._key?{...o,_key:l}
18:o,placement:"after",select:c?"none":"end",at:c?{anchor:{path:[{_key:c}],offset:0},focus:{path:[{_key:c}],offset:0}}:void 0})),c=l}return(0,g.wm)(e.context,o)||d.push((0,B.xl)({type:"insert.block",block:o,placement:"auto",select:"end"===t.select?"none":"end"})),"none"===t.select&&d.push((0,B.xl)({type:"select",at:s})),"start"===t.select&&(((0,h._Q)(a.focus,i)||!l)&&u?d.push((0,B.xl)({type:"select.block",at:[{_key:u}],select:"start"})):d.push((0,B.xl)({type:"select",at:{anchor:a.focus,focus:a.focus}}))),d}]}),(0,B.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>"auto"===t.placement&&{originalSelection:e.context.selection},actions:[({snapshot:e,event:t},{originalSelection:n})=>{let r,o,a,i=[],l=-1;for(let n of t.blocks){l++;let s=iU(n._key)(e);0===l&&(r=s),l===t.blocks.length-1&&(o=s),i.push((0,B.xl)({type:"insert.block",block:s!==n._key?{...n,_key:s}:n,placement:0===l?"auto":"after",select:"none",...a?{at:{anchor:{path:[{_key:a}],offset:0},focus:{path:[{_key:a}],offset:0}}}:t.at?{at:t.at}:{}})),a=s}let s=t.select??"end";return"none"===s?i.push((0,B.xl)({type:"select",at:n})):"start"===s&&r?i.push((0,B.xl)({type:"select.block",at:[{_key:r}],select:"start"})):o&&i.push((0,B.xl)({type:"select.block",at:[{_key:o}],select:"end"})),i}]}),(0,B.Ke)({on:"insert.break",actions:[()=>[(0,B.xl)({type:"split"})]]}),(0,B.Ke)({on:"insert.child",guard:({snapshot:e})=>{let t=(0,p.qm)(e);return!!t&&!e.context.selection&&{lastBlockEndPoint:(0,h.J8)({context:e.context,block:t})}},actions:[({event:e},{lastBlockEndPoint:t})=>[(0,B.xl)({type:"select",at:{anchor:t,focus:t}}),(0,B.xl)(e)]]}),(0,B.Ke)({on:"insert.child",guard:({snapshot:e})=>{let t=(0,p.hH)(e);return e.context.selection&&!t},actions:[({snapshot:e,event:t})=>[(0,B.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,text:"",marks:[]}]},placement:"auto",select:"end"}),(0,B.xl)(t)]]}),(0,B.Ke)({on:"insert.inline object",actions:[({event:e})=>[(0,B.xl)({type:"insert.child",child:{_type:e.inlineObject.name,...e.inlineObject.value}})]]}),(0,B.Ke)({on:"insert.soft break",actions:[()=>[(0,B.xl)({type:"insert.text",text:` 19`})]]}),(0,B.Ke)({on:"insert.span",guard:({snapshot:e})=>!(0,p.hH)(e),actions:[({snapshot:e,event:t})=>[(0,B.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,text:"",marks:[]}]},placement:"auto",select:"end"}),(0,B.xl)(t)]]}),(0,B.Ke)({on:"insert.span",guard:({snapshot:e,event:t})=>{let n=(0,p.hH)(e);return{markDefs:t.annotations?.map(t=>({_type:t.name,_key:e.context.keyGenerator(),...t.value}))??[],focusTextBlock:n}},actions:[({snapshot:e,event:t},{markDefs:n,focusTextBlock:r})=>[...r?[(0,B.xl)({type:"block.set",at:r.path,props:{markDefs:[...r.node.markDefs??[],...n]}})]:[],(0,B.xl)({type:"insert.child",child:{_type:e.context.schema.span.name,text:t.text,marks:[...t.decorators??[],...n.map(e=>e._key)]}})]]}),(0,B.Ke)({on:"insert.text",guard:({snapshot:e})=>(0,p.WV)(e)&&(0,p.Rt)(e),actions:[({event:e})=>[(0,B.xl)({type:"move.forward",distance:1}),(0,B.xl)(e)]]}),(0,B.Ke)({on:"insert.text",guard:({snapshot:e})=>(0,p.gR)(e),actions:[({event:e})=>[(0,B.xl)({type:"delete"}),(0,B.xl)(e)]]}),(0,B.Ke)({on:"insert.text",guard:({snapshot:e})=>{if(e.context.selection)return!1;let t=(0,p.qm)(e);return!!t&&{endPoint:(0,h.J8)({context:e.context,block:t})}},actions:[({event:e},{endPoint:t})=>[(0,B.xl)({type:"select",at:{anchor:t,focus:t}}),(0,B.xl)(e)]]})],iH=(0,y.mn)({default:[{key:"ArrowLeft",shift:!0,meta:!1,ctrl:!1,alt:!1}]}),iG=[(0,B.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>aJ.backspace.guard(t.originEvent)&&(0,p.WV)(e)&&(0,p.Rt)(e),actions:[()=>[(0,B.xl)({type:"delete.backward",unit:"character"})]]}),(0,B.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>aJ.delete.guard(t.originEvent)&&(0,p.WV)(e)&&(0,p.Rt)(e),actions:[()=>[(0,B.xl)({type:"delete.forward",unit:"character"})]]}),(0,B.Ke)({on:"keyboard.keydown",guard:({event:e})=>aJ.deleteWord.backward.guard(e.originEvent),actions:[()=>[(0,B.xl)({type:"delete.backward",unit:"word"})]]}),(0,B.Ke)({on:"keyboard.keydown",guard:({event:e})=>aJ.deleteWord.forward.guard(e.originEvent),actions:[()=>[(0,B.xl)({type:"delete.forward",unit:"word"})]]}),(0,B.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>aJ.break.guard(t.originEvent)&&(0,p.WV)(e)&&(0,p.Rt)(e),actions:[()=>[(0,B.xl)({type:"insert.break"})]]}),(0,B.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>aJ.break.guard(t.originEvent)&&(0,p.gR)(e),actions:[()=>[(0,B.xl)({type:"insert.break"})]]}),(0,B.Ke)({on:"keyboard.keydown",guard:({event:e})=>aJ.lineBreak.guard(e.originEvent),actions:[()=>[(0,B.xl)({type:"insert.soft break"})]]}),(0,B.Ke)({on:"keyboard.keydown",guard:({event:e})=>aJ.history.undo.guard(e.originEvent),actions:[()=>[(0,B.xl)({type:"history.undo"})]]}),(0,B.Ke)({on:"keyboard.keydown",guard:({event:e})=>aJ.history.redo.guard(e.originEvent),actions:[()=>[(0,B.xl)({type:"history.redo"})]]}),(0,B.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!e.context.selection||!iH.guard(t.originEvent))return!1;let n=(0,p.gU)(e);if(!n)return!1;let r=(0,p.HA)({...e,context:{...e.context,selection:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}}});return!!(r&&(0,p.xN)(e.context,n.node)&&0===e.context.selection.focus.offset&&(0,g.wm)(e.context,n.node))&&{previousBlock:r,selection:e.context.selection}},actions:[({snapshot:e},{previousBlock:t,selection:n})=>
19[(0,B.xl)({type:"select",at:{anchor:n.anchor,focus:(0,h.J8)({context:e.context,block:t})}})]]})],iJ=[(0,B.Ke)({on:"list item.add",guard:({snapshot:e,event:t})=>!!e.context.schema.lists.some(e=>e.name===t.listItem)&&{selectedTextBlocks:(0,p.Lw)(e)},actions:[({event:e},{selectedTextBlocks:t})=>t.map(t=>(0,B.xl)({type:"block.set",at:t.path,props:{level:t.node.level??1,listItem:e.listItem}}))]}),(0,B.Ke)({on:"list item.remove",guard:({snapshot:e})=>({selectedTextBlocks:(0,p.Lw)(e)}),actions:[(e,{selectedTextBlocks:t})=>t.map(e=>(0,B.xl)({type:"block.unset",at:e.path,props:["level","listItem"]}))]}),(0,B.Ke)({on:"list item.toggle",guard:({snapshot:e,event:t})=>(0,p.oZ)(t.listItem)(e),actions:[({event:e})=>[(0,B.xl)({type:"list item.remove",listItem:e.listItem})]]}),(0,B.Ke)({on:"list item.toggle",guard:({snapshot:e,event:t})=>!(0,p.oZ)(t.listItem)(e),actions:[({event:e})=>[(0,B.xl)({type:"list item.add",listItem:e.listItem})]]})],iZ=[(0,B.Ke)({on:"move.block up",guard:({snapshot:e,event:t})=>{let n=(0,p.HA)({...e,context:{...e.context,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}}});return!!n&&{previousBlock:n}},actions:[({event:e},{previousBlock:t})=>[(0,B.xl)({type:"move.block",at:e.at,to:t.path})]]}),(0,B.Ke)({on:"move.block down",guard:({snapshot:e,event:t})=>{let n=(0,p.RL)({...e,context:{...e.context,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}}});return!!n&&{nextBlock:n}},actions:[({event:e},{nextBlock:t})=>[(0,B.xl)({type:"move.block",at:e.at,to:t.path})]]})],iY=[(0,B.Ke)({on:"select.block",guard:({snapshot:e,event:t})=>{if("end"!==t.select)return!1;let n=(0,p.gU)({...e,context:{...e.context,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}}});return!!n&&{blockEndPoint:(0,h.J8)({context:e.context,block:n})}},actions:[(e,{blockEndPoint:t})=>[(0,B.xl)({type:"select",at:{anchor:t,focus:t}})]]}),(0,B.Ke)({on:"select.block",actions:[({event:e})=>[(0,B.xl)({type:"select",at:{anchor:{path:e.at,offset:0},focus:{path:e.at,offset:0}}})]]}),(0,B.Ke)({on:"select.previous block",guard:({snapshot:e})=>{let t=(0,p.HA)(e);return!!t&&{previousBlock:t}},actions:[({event:e},{previousBlock:t})=>[(0,B.xl)({type:"select.block",at:t.path,select:e.select})]]}),(0,B.Ke)({on:"select.next block",guard:({snapshot:e})=>{let t=(0,p.RL)(e);return!!t&&{nextBlock:t}},actions:[({event:e},{nextBlock:t})=>[(0,B.xl)({type:"select.block",at:t.path,select:e.select})]]})],iq=[(0,B.Ke)({on:"serialize",actions:[({event:e})=>[(0,B.xl)({type:"serialize.data",mimeType:"application/x-portable-text",originEvent:e.originEvent}),(0,B.xl)({type:"serialize.data",mimeType:"application/json",originEvent:e.originEvent}),(0,B.xl)({type:"serialize.data",mimeType:"text/markdown",originEvent:e.originEvent}),(0,B.xl)({type:"serialize.data",mimeType:"text/html",originEvent:e.originEvent}),(0,B.xl)({type:"serialize.data",mimeType:"text/plain",originEvent:e.originEvent})]]}),(0,B.Ke)({on:"serialize.data",guard:({snapshot:e,event:t})=>{let n=e.context.converters.find(e=>e.mimeType===t.mimeType);return!!n&&n.serialize({snapshot:e,event:{type:"serialize",originEvent:t.originEvent.type}})},actions:[({event:e},t)=>[(0,B.xl)({...t,originEvent:e.originEvent})]]}),(0,B.Ke)({on:"serialization.success",actions:[({event:e})=>[{type:"effect",effect:()=>{e.originEvent.originEvent.dataTransfer.setData(e.mimeType,e.data)}}]]}),(0,B.Ke)({on:"serialization.failure",actions:[({event:e})=>[{type:"effect",effect:()=>{console.warn(`Serialization of ${e.mimeType} failed with reason "${e.reason}"`)}}]]})],iX=[(0,B.Ke)({on:"split",guard:({snapshot:e})=>(0,h.WV)(e.context.selection)&&(0,p.Rt)(e),actions:[]}),(0,B.Ke)({on:"split",guard:({snapshot:e})=>(0,h.WV)(e.context.selection)&&(0,p.lA)(e),actions:[]}),(0,B.Ke)({on:"split",guard:({snapshot:e})=>{let t=e.context.selection;if(!t||(0,h.WV)(t))return!1;let n=(0,h.Jo)(t),r=(0,h.aR)(t);if(!n||!r)return!1;let o=(0,p.GB)(e),a=(0,p.P$)(e);if(!o||!a)return!1;let i=(0,h.u3)({context:e.context,block:o}),l=(0,h.J8)({context:e.context,block:a});return!!((0,p.xN)(e.context,o.node)&&(0,p.xN)(e.context,a.node)&&!(0,h._Q)(n,i)&&!(0,h._Q)(r,l))},actions:[()=>[(0,B.xl)({type:"delete"}),(0,B.xl)({type:"split"})]]}),(0,B.Ke)({on:"split",guard:({snapshot:e})=>(0,p.gR)(e),actions:[()=>[(0,B.xl)({type:"delete"})]]}),(0,B.Ke)({on:"split",guard:({snapshot:e})=>{let t=e.context.selection;if(!t||!(0,h.WV)(t))return!1;let n=(0,h.Jo)(t),r=(0,p.hH)(e);if(!r)return!1;let o={anchor:n,focus:(0,h.J8)({context:e.context,block:r})},a=(0,h.rT)({block:(0,g.Bh)({context:{...e.context,selection:o},block:r.node}),context:e.context,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return!!a&&{newTextBlock:a,newTextBlockSelection:o}},actions:[(e,{newTextBlock:t,newTextBlockSelection:n})=>(0,h.WV)(n)?[(0,B.xl)({type:"insert.block",block:t,placement:"after",select:"start"})]:[(0,B.xl)({type:"delete",at:n}),(0,B.xl)({type:"insert.block",block:t,placement:"after",select:"start"})]]})],iQ=[(0,B.Ke)({on:"style.add",guard:({snapshot:e})=>({selectedTextBlocks:(0,p.Lw)(e)}),actions:[({event:e},{selectedTextBlocks:t})=>t.map(t=>(0,B.xl)({type:"block.set",at:t.path,props:{style:e.style}}))]}),(0,B.Ke)({on:"style.remove",guard:({snapshot:e})=>({selectedTextBlocks:(0,p.Lw)(e)}),actions:[(e,{selectedTextBlocks:t})=>t.map(e=>(0,B.xl)({type:"block.unset",at:e.path,props:["style"]}))]}),(0,B.Ke)({on:"style.toggle",guard:({snapshot:e,event:t})=>(0,p.ER)(t.style)(e),actions:[({event:e})=>[(0,B.xl)({type:"style.remove",style:e.style})]]}),(0,B.Ke)({on:"style.toggle",guard:({snapshot:e,event:t})=>
19!(0,p.ER)(t.style)(e),actions:[({event:e})=>[(0,B.xl)({type:"style.add",style:e.style})]]})],i0=[(0,B.Ke)({on:"clipboard.copy",guard:({snapshot:e})=>{let t=(0,p.d2)(e),n=(0,p.WV)(e);return t&&n},actions:[]}),(0,B.Ke)({on:"clipboard.copy",actions:[({event:e})=>[(0,B.xl)({type:"serialize",originEvent:e})]]}),(0,B.Ke)({on:"clipboard.cut",guard:({snapshot:e})=>{let t=(0,p.d2)(e),n=(0,p.WV)(e);return t&&n},actions:[]}),(0,B.Ke)({on:"clipboard.cut",guard:({snapshot:e})=>e.context.selection,actions:[({event:e})=>[(0,B.xl)({type:"serialize",originEvent:e}),(0,B.xl)({type:"delete"})]]}),(0,B.Ke)({on:"drag.dragstart",actions:[({event:e})=>[(0,B.xl)({type:"serialize",originEvent:e})]]}),(0,B.Ke)({on:"clipboard.paste",guard:({snapshot:e})=>(0,p.gR)(e),actions:[({event:e})=>[(0,B.xl)({type:"delete"}),(0,B.sY)(e)]]}),(0,B.Ke)({on:"clipboard.paste",actions:[({event:e})=>[(0,B.xl)({type:"deserialize",originEvent:e})]]}),...iI,...ij,...iN,...iL,...iV,...iW,...iG,...iJ,...iZ,...iQ,...iY,...iq,...iX];function i1(e){return!i5(e)&&!i8(e)&&!i3(e)}let i2=["annotation.set","annotation.toggle","decorator.toggle","delete.backward","delete.block","delete.child","delete.forward","delete.text","deserialize","deserialize.data","deserialization.success","deserialization.failure","insert.blocks","insert.break","insert.inline object","insert.soft break","insert.span","list item.add","list item.remove","list item.toggle","move.block down","move.block up","select.block","select.previous block","select.next block","serialize","serialize.data","serialization.success","serialization.failure","split","style.add","style.remove","style.toggle"];function i3(e){return i2.includes(e.type)}let i4=["clipboard.copy","clipboard.cut","clipboard.paste","drag.dragstart","drag.drag","drag.dragend","drag.dragenter","drag.dragover","drag.dragleave","drag.drop","input.*","keyboard.keydown","keyboard.keyup","mouse.click"];function i8(e){return i4.includes(e.type)}function i5(e){return e.type.startsWith("custom.")}function i7({event:e,slateEditor:t}){switch(e.type){case"blur":return{type:"blur",editor:t};case"focus":return{type:"focus",editor:t};case"insert.block object":return{type:"behavior event",behaviorEvent:{type:"insert.block",block:{_type:e.blockObject.name,...e.blockObject.value??{}},placement:e.placement},editor:t};default:return{type:"behavior event",behaviorEvent:e,editor:t}}}let i9=(0,v.mj)({types:{context:{},events:{},emitted:{},input:{},tags:{}},actions:{"add behavior to context":(0,k.a)({behaviors:({context:e,event:t})=>((0,v.DT)(t,"add behavior"),new Set([...e.behaviors,t.behaviorConfig])),behaviorsSorted:!1}),"remove behavior from context":(0,k.a)({behaviors:({context:e,event:t})=>((0,v.DT)(t,"remove behavior"),e.behaviors.delete(t.behaviorConfig),new Set([...e.behaviors]))}),"add slate editor to context":(0,k.a)({slateEditor:({context:e,event:t})=>"add slate editor"===t.type?t.editor:e.slateEditor}),"emit patch event":(0,C.a)(({event:e})=>((0,v.DT)(e,"internal.patch"),e)),"emit mutation event":(0,C.a)(({event:e})=>((0,v.DT)(e,"mutation"),e)),"emit read only":(0,C.a)({type:"read only"}),"emit editable":(0,C.a)({type:"editable"}),"defer event":(0,k.a)({pendingEvents:({context:e,event:t})=>((0,v.DT)(t,["internal.patch","mutation"]),[...e.pendingEvents,t])}),"emit pending events":(0,C.e)(({context:e,enqueue:t})=>{for(let n of e.pendingEvents)t.emit(n)}),"emit ready":(0,C.a)({type:"ready"}),"clear pending events":(0,k.a)({pendingEvents:[]}),"discard conflicting pending patches":(0,k.a)({pendingEvents:({context:e,event:t})=>{if("patches"!==t.type)return e.pendingEvents;let n=t.patches.map(e=>e.path);return e.pendingEvents.filter(e=>"internal.patch"!==e.type||!n.some(t=>(function(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(!(0,h.eX)(e[r],t[r]))return!1;return!0})(e.patch.path,t)))}}),"discard all pending events":(0,k.a)({pendingEvents:[]}),"defer incoming patches":(0,k.a)({pendingIncomingPatchesEvents:({context:e,event:t})=>"patches"===t.type?[...e.pendingIncomingPatchesEvents,t]:e.pendingIncomingPatchesEvents}),"emit pending incoming patches":(0,C.e)(({context:e,enqueue:t})=>{for(let n of e.pendingIncomingPatchesEvents)t.emit(n)}),"clear pending incoming patches":(0,k.a)({pendingIncomingPatchesEvents:[]}),"handle blur":({event:e})=>{(0,v.DT)(e,"blur");try{eN.blur(e.editor)}catch(e){console.error(Error(`Failed to blur editor: ${e instanceof Error?e.message:e}`))}},"handle focus":({context:e})=>{let t=e.slateEditor;if(!t)return void console.error("No Slate editor found to focus");try{let e=t.selection;eN.focus(t),e&&(t.select(e),t.pendingSelection=t.selection,t.onChange())}catch(e){console.error(Error(`Failed to focus editor: ${e instanceof Error?e.message:e}`))}},"handle behavior event":({context:e,event:t,self:n})=>{(0,v.DT)(t,["behavior event"]);try{let r=[...e.behaviors.values()].map(e=>e.behavior);!function e({mode:t,behaviors:n,remainingEventBehaviors:r,event:o,editor:a,converters:i,keyGenerator:l,readOnly:s,schema:c,nativeEvent:u,sendBack:d}){var p,f;"send"!==t||i8(o)||(a.undoStepId=(0,h.OL)()),P.behaviors(`(${t}
19:${i8(o)?"native":i3(o)?"synthetic":i5(o)?"custom":"synthetic"})`,j(o,2));let y=[...r,...i0].filter(e=>{if("*"===e.on)return!0;let[t]=e.on.includes("*")&&e.on.includes(".")?e.on.split("."):[void 0],[n]=o.type.includes(".")?o.type.split("."):[void 0];return void 0!==t&&void 0!==n&&t===n||void 0!==t&&void 0===n&&t===o.type||e.on===o.type});if(0===y.length&&i1(o)){u?.preventDefault(),"send"===t&&(a.undoStepId=void 0),iz(a,()=>{P.operation(j(o,2)),iR({context:{keyGenerator:l,schema:c},operation:{...o,editor:a}})}),"send"===t&&a.onChange();return}let m=ig({converters:i,editor:a,keyGenerator:l,readOnly:s,schema:c}),g=!1,v=!1,k=-1;for(let b of y){k++;let x=!1;try{x=void 0===b.guard||b.guard({snapshot:m,event:o,dom:aV(d,a)})}catch(e){console.error(Error(`Evaluating guard for "${o.type}" failed due to: ${e instanceof Error?e.message:e}`))}if(!x)continue;v=!0,0===b.actions.length&&(g=!0);let C=-1;for(let v of b.actions){let b=0==++C?m:ig({converters:i,editor:a,keyGenerator:l,readOnly:s,schema:c}),B=[];try{B=v({snapshot:b,event:o,dom:aV(d,a)},x)}catch(e){console.error(Error(`Evaluating actions for "${o.type}" failed due to: ${e instanceof Error?e.message:e}`))}if(0===B.length)continue;g=B.some(e=>"raise"===e.type||"execute"===e.type)||!B.some(e=>"forward"===e.type);let E=!1;C>0&&(a.undoStepId=(0,h.OL)(),E=!0),!E&&B.some(e=>"execute"===e.type)&&(a.undoStepId=(0,h.OL)(),E=!0);let D=B.map(e=>e.type),_=new Set(D),w=D.length>1&&1===_.size&&_.has("raise"),A=D.length>1&&1===_.size&&_.has("execute");p=()=>w||A,f=()=>{for(let h of B){if("effect"===h.type){try{h.effect({send:d})}catch(e){console.error(Error(`Executing effect as a result of "${o.type}" failed due to: ${e instanceof Error?e.message:e}`))}continue}if("forward"===h.type){e({mode:"execute"===t?"execute":"forward",behaviors:n,remainingEventBehaviors:y.slice(k+1),event:h.event,editor:a,converters:i,keyGenerator:l,readOnly:s,schema:c,nativeEvent:u,sendBack:d});continue}if("raise"===h.type){e({mode:"execute"===t?"execute":"raise",behaviors:n,remainingEventBehaviors:"execute"===t?r:n,event:h.event,editor:a,converters:i,keyGenerator:l,readOnly:s,schema:c,nativeEvent:u,sendBack:d});continue}e({mode:"execute",behaviors:n,remainingEventBehaviors:[],event:h.event,editor:a,converters:i,keyGenerator:l,readOnly:s,schema:c,nativeEvent:void 0,sendBack:d})}},p()?o_(a,f):f(),E&&(a.undoStepId=void 0)}break}!v&&i1(o)?(u?.preventDefault(),"send"===t&&(a.undoStepId=void 0),iz(a,()=>{P.operation(j(o,2)),iR({context:{keyGenerator:l,schema:c},operation:{...o,editor:a}})}),"send"===t&&a.onChange()):g&&(u?.preventDefault(),"send"===t&&a.onChange())}({mode:"send",behaviors:r,remainingEventBehaviors:r,event:t.behaviorEvent,editor:t.editor,converters:[...e.converters],keyGenerator:e.keyGenerator,schema:e.schema,readOnly:n.getSnapshot().matches({"edit mode":"read only"}),nativeEvent:t.nativeEvent,sendBack:e=>{"set drag ghost"===e.type?n.send(e):n.send(i7({event:e,slateEditor:t.editor}))}})}catch(e){console.error(Error(`Raising "${t.behaviorEvent.type}" failed due to: ${e instanceof Error?e.message:e}`))}},"sort behaviors":(0,k.a)({behaviors:({context:e})=>e.behaviorsSorted?e.behaviors:new Set(function(e){if(0===e.length)return[];let t=e.filter(e=>void 0!==e.priority),n=e.filter(e=>void 0===e.priority);if(0===t.length)return e;let r=new Map(t.map(e=>[e.priority.id,e])),o=new Map,a=new Map;function i(e){o.has(e)||(o.set(e,new Set),a.set(e,0))}for(let e of t)i(e.priority.id);function l(e,t){o.has(e)&&o.has(t)&&(o.get(e)?.add(t),a.set(t,(a.get(t)??0)+1))}for(let e of t){let t=e.priority.id,n=new Set,r=e.priority.reference;for(;r;){let e=r.priority.id;if(i(e),n.has(e))throw Error("Circular dependency detected in priorities");n.add(e),"higher"===r.importance?l(t,e):l(e,t),r=r.priority.reference}}let s=[];for(let[e,t]of a)0===t&&s.push(e);let c=[];for(;s.length>0;){let e=s.shift(),t=r.get(e);for(let n of(t&&c.push(t),o.get(e)??[])){let e=(a.get(n)??0)-1;a.set(n,e),0===e&&s.push(n)}}for(let e of t)c.includes(e)||c.push(e);return[...c,...n]}([...e.behaviors.values()])),behaviorsSorted:!0}
19)},guards:{"slate is busy":({context:e})=>!!e.slateEditor&&e.slateEditor.operations.length>0,"slate is normalizing node":({context:e})=>!!e.slateEditor&&e.slateEditor.isNormalizingNode}}).createMachine({id:"editor",context:({input:e})=>({behaviors:new Set(im),behaviorsSorted:!1,converters:new Set(e.converters??[]),keyGenerator:e.keyGenerator,pendingEvents:[],pendingIncomingPatchesEvents:[],schema:e.schema,selection:null,initialReadOnly:e.readOnly??!1,initialValue:e.initialValue}),on:{"add behavior":{actions:"add behavior to context"},"remove behavior":{actions:"remove behavior from context"},"add slate editor":{actions:"add slate editor to context"},"update selection":{actions:[(0,k.a)({selection:({event:e})=>e.selection}),(0,C.a)(({event:e})=>({...e,type:"selection"}))]},"set drag ghost":{actions:(0,k.a)({dragGhost:({event:e})=>e.ghost})}},type:"parallel",states:{"edit mode":{initial:"read only",states:{"read only":{initial:"determine initial edit mode",on:{"behavior event":{actions:["sort behaviors","handle behavior event"],guard:({event:e})=>"clipboard.copy"===e.behaviorEvent.type||"mouse.click"===e.behaviorEvent.type||"serialize"===e.behaviorEvent.type||"serialization.failure"===e.behaviorEvent.type||"serialization.success"===e.behaviorEvent.type||"select"===e.behaviorEvent.type}},states:{"determine initial edit mode":{entry:[()=>{P.state("entry: edit mode->read only->determine initial edit mode")}],exit:[()=>{P.state("exit: edit mode->read only->determine initial edit mode")}],on:{"done syncing value":[{target:"#editor.edit mode.read only.read only",guard:({context:e})=>e.initialReadOnly},{target:"#editor.edit mode.editable"}]}},"read only":{entry:[()=>{P.state("entry: edit mode->read only->read only")}],exit:[()=>{P.state("exit: edit mode->read only->read only")}],on:{"update readOnly":{guard:({event:e})=>!e.readOnly,target:"#editor.edit mode.editable",actions:["emit editable"]}}}}},editable:{on:{"update readOnly":{guard:({event:e})=>e.readOnly,target:"#editor.edit mode.read only.read only",actions:["emit read only"]},"behavior event":{actions:["sort behaviors","handle behavior event"]},blur:{actions:"handle blur"},focus:{target:".focusing",actions:[(0,k.a)({slateEditor:({event:e})=>e.editor})]}},initial:"idle",states:{idle:{entry:[()=>{P.state("entry: edit mode->editable->idle")}],exit:[()=>{P.state("exit: edit mode->editable-idle")}],on:{dragstart:{actions:[(0,k.a)({internalDrag:({event:e})=>({origin:e.origin})})],target:"dragging internally"}}},focusing:{initial:"checking if busy",states:{"checking if busy":{entry:[()=>{P.state("entry: edit mode->editable->focusing->checking if busy")}],exit:[()=>{P.state("exit: edit mode->editable->focusing->checking if busy")}],always:[{guard:"slate is busy",target:"busy"},{target:"#editor.edit mode.editable.idle",actions:["handle focus"]}]},busy:{entry:[()=>{P.state("entry: edit mode->editable->focusing-busy")}],exit:[()=>{P.state("exit: edit mode->editable->focusing->busy")}],after:{10:{target:"checking if busy"}}}}},"dragging internally":{entry:[()=>{P.state("entry: edit mode->editable->dragging internally")}],exit:[()=>{P.state("exit: edit mode->editable->dragging internally")},({context:e})=>{if(e.dragGhost)try{e.dragGhost.parentNode?.removeChild(e.dragGhost)}catch(e){console.error(Error(`Removing the drag ghost failed due to: ${e instanceof Error?e.message:e}`))}},(0,k.a)({dragGhost:void 0}),(0,k.a)({internalDrag:void 0})],tags:["dragging internally"],on:{dragend:{target:"idle"},drop:{target:"idle"}}}}}}},setup:{initial:"setting up",states:{"setting up":{entry:[()=>{P.state("entry: setup->setting up")}],exit:[()=>{P.state("exit: setup->setting up")},"emit ready","emit pending incoming patches","clear pending incoming patches"],on:{"internal.patch":{actions:"defer event"},mutation:{actions:"defer event"},"done syncing value":{target:"set up"},patches:{actions:["defer incoming patches"]}}},"set up":{type:"parallel",states:{"value sync":{initial:"idle",states:{idle:{entry:[()=>{P.state("entry: setup->set up->value sync->idle")}],exit:[()=>{P.state("exit: setup->set up->value sync->idle")}],on:{patches:{actions:[(0,C.a)(({event:e})=>e)]},"syncing value":{target:"syncing value"}}},"syncing value":{entry:[()=>{P.state("entry: setup->set up->value sync->syncing value")}],exit:[()=>{P.state("exit: setup->set up->value sync->syncing value")},"emit pending incoming patches","clear pending incoming patches"],on:{patches:{actions:["defer incoming patches"]},"done syncing value":{target:"idle"}}}}},writing:{initial:"pristine",states:{pristine:{initial:"idle",states:{idle:{entry:[()=>{P.state("entry: setup->set up->writing->pristine->idle")}],exit:[()=>{P.state("exit: setup->set up->writing->pristine->idle")}],on:{"internal.patch":[{guard:"slate is normalizing node",actions:"defer event"},{actions:"defer event",target:"#editor.setup.set up.writing.dirty"}],mutation:[{guard:"slate is normalizing node",actions:"defer event"},{actions:"defer event",target:"#editor.setup.set up.writing.dirty"}],patches:{actions:"discard conflicting pending patches"},"syncing value":{actions:"discard all pending events"}}}}},dirty:{entry:[()=>{P.state("entry: setup->set up->writing->dirty")},"emit pending events","clear pending events"],exit:[()=>{P.state("exit: setup->set up->writing->dirty")}],on:{"internal.patch":{actions:"emit patch event"},mutation:{actions:"emit mutation event"}}}}}}}}}}}),i6=(0,v.mj)({types:{context:{},events:{},input:{},emitted:{}},actions:{"assign readOnly":(0,k.a)({readOnly:({context:e,event:t})=>"update readOnly"===t.type?t.readOnly:e.readOnly}),"emit patch":(0,C.a)(({event:e})=>((0,v.DT)(e,"patch"),{type:"patch",patch:e.patch})),"set is deferring mutations":({context:e})=>{e.slateEditor.isDeferringMutations=!0},"emit mutations":(0,C.e)(({context:e,enqueue:t})=>{for(let n of e.pendingMutations)t.emit({type:"mutation",patches:n.patches,snapshot:n.value});e.slateEditor.isDeferringMutations=!1}),"clear pending mutations":(0,k.a)({pendingMutations:[]}),"defer mutation":(0,k.a)({pendingMutations:({context:e,event:t})=>{if((0,v.DT)(t,"patch"),0===e.pendingMutations.length)return[{operationId:t.operationId,value:t.value,patches:[t.patch]}];let n=e.pendingMutations.at(-1);return n&&n.operationId===t.operationId?e.pendingMutations.slice(0,-1).concat({value:t.value,operationId:n.operationId,patches:[...n.patches,t.patch]}):e.pendingMutations.concat({value:t.value,operationId:t.operationId,patches:[t.patch]})}}),"clear pending patch events":(0,k.a)({pendingPatchEvents:[]}),"defer patch":(0,k.a)({pendingPatchEvents:({context:e,event:t})=>"patch"===t.type?[...e.pendingPatchEvents,t]:e.pendingPatchEvents}),"emit pending patch events":(0,C.e)(({context:e,enqueue:t})=>{for(let n of e.pendingPatchEvents)t.emit(n)})},actors:{"type listener":(0,b.SP)(({input:e,sendBack:t})=>{let n=e.slateEditor.apply;return e.slateEditor.apply=e=>{"insert_text"===e.type||"remove_text"===e.type?t({type:"typing"}):t({type:"not typing"}),n(e)},()=>{e.slateEditor.apply=n}}),"mutation interval":(0,b.SP)(({sendBack:e})=>{let t=setInterval(()=>{e({type:"emit changes"})},1e3);return()=>{clearInterval(t)}})},guards:{"is read-only":({context:e})=>e.readOnly,"slate is normalizing":({context:e})=>oB(e.slateEditor)},delays:{"type debounce":250}}).createMachine({id:"mutation",context:({input:e})=>({pendingMutations:[],pendingPatchEvents:[],readOnly:e.readOnly,schema:e.schema,slateEditor:e.slateEditor}),on:{"update readOnly":{actions:["assign readOnly"]}},type:"parallel",states:{typing:{initial:"idle",invoke:{src:"type listener",input:({context:e})=>({slateEditor:e.slateEditor})},states:{idle:{entry:[()=>{P.mutation("entry: typing->idle")}],exit:[()=>{P.mutation("exit: typing->idle"),P.mutation("entry: typing->typing")}],on:{typing:{target:"typing"}}},typing:{after:{"type debounce":{target:"idle",actions:[(0,x.r)({type:"emit changes"}),()=>{P.mutation("exit: typing->typing")}]}},on:{"not typing":{target:"idle",actions:[(0,x.r)({type:"emit changes"})]}
19,typing:{target:"typing",reenter:!0}}}}},mutations:{initial:"idle",states:{idle:{entry:[()=>{P.mutation("entry: mutations->idle")}],exit:[()=>{P.mutation("exit: mutations->idle")}],on:{patch:[{guard:"is read-only",actions:["set is deferring mutations","defer patch","defer mutation"],target:"has pending mutations"},{actions:["set is deferring mutations","emit patch","defer mutation"],target:"has pending mutations"}]}},"has pending mutations":{entry:[()=>{P.mutation("entry: mutations->has pending mutations")}],exit:[()=>{P.mutation("exit: mutations->has pending mutations")}],invoke:{src:"mutation interval"},on:{"emit changes":{guard:(0,x.j)([(0,x.n)("is read-only"),"slate is normalizing"]),target:"idle",actions:["emit pending patch events","clear pending patch events","emit mutations","clear pending mutations"]},patch:[{guard:"is read-only",actions:["defer patch","defer mutation"]},{actions:["emit patch","defer mutation"]}]}}}}}}),le=(0,v.mj)({types:{context:{},events:{},emitted:{}}}).createMachine({id:"relay",context:{prevSelection:null,lastEventWasFocused:!1},on:{focused:{actions:[(0,k.a)({lastEventWasFocused:!0}),(0,C.a)(({event:e})=>e)]},selection:[{guard:({context:e})=>e.lastEventWasFocused,actions:[(0,k.a)({prevSelection:({event:e})=>e.selection}),(0,C.a)(({event:e})=>e),(0,k.a)({lastEventWasFocused:!1})]},{guard:({context:e,event:t})=>e.prevSelection!==t.selection,actions:[(0,k.a)({prevSelection:({event:e})=>e.selection}),(0,C.a)(({event:e})=>e),(0,k.a)({lastEventWasFocused:!1})]}],"*":{actions:[(0,C.a)(({event:e})=>e),(0,k.a)({lastEventWasFocused:!1})]}}});function lt(e,t,n){let r=null,o=!0,a=[t.span.name,...t.inlineObjects.map(e=>e.name)],i=[t.block.name,...t.blockObjects.map(e=>e.name)];return void 0===e?{valid:!0,resolution:null,value:e}:Array.isArray(e)&&0!==e.length?(e.some((e,l)=>{if("object"!=typeof e||null===e)return r={patches:[(0,w.wC)([l])],description:`Block must be an object, got ${String(e)}`,action:"Unset invalid item",item:e,i18n:{description:"inputs.portable-text.invalid-value.not-an-object.description",action:"inputs.portable-text.invalid-value.not-an-object.action",values:{index:l}}},!0;if(!e._key||"string"!=typeof e._key)return r={patches:[(0,w.hZ)({...e,_key:n()},[l])],description:`Block at index ${l} is missing required _key.`,action:"Set the block with a random _key value",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-key.description",action:"inputs.portable-text.invalid-value.missing-key.action",values:{index:l}}},!0;if(!e._type||!i.includes(e._type)){if("block"===e._type){let n=t.block.name;return r={patches:[(0,w.hZ)({...e,_type:n},[{_key:e._key}])],description:`Block with _key '${e._key}' has invalid type name '${e._type}'. According to the schema, the block type name is '${n}'`,action:`Use type '${n}'`,item:e,i18n:{description:"inputs.portable-text.invalid-value.incorrect-block-type.description",action:"inputs.portable-text.invalid-value.incorrect-block-type.action",values:{key:e._key,expectedTypeName:n}}},!0}return r=!e._type&&(0,d.zS)({schema:t},{...e,_type:t.block.name})?{patches:[(0,w.hZ)({...e,_type:t.block.name},[{_key:e._key}])],description:`Block with _key '${e._key}' is missing a type name. According to the schema, the block type name is '${t.block.name}'`,action:`Use type '${t.block.name}'`,item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-block-type.description",action:"inputs.portable-text.invalid-value.missing-block-type.action",values:{key:e._key,expectedTypeName:t.block.name}}}:e._type?{patches:[(0,w.wC)([{_key:e._key}])],description:`Block with _key '${e._key}' has invalid _type '${e._type}'`,action:"Remove the block",item:e,i18n:{description:"inputs.portable-text.invalid-value.disallowed-type.description",action:"inputs.portable-text.invalid-value.disallowed-type.action",values:{key:e._key,typeName:e._type}}}:{patches:[(0,w.wC)([{_key:e._key}])],description:`Block with _key '${e._key}' is missing an _type property`,action:"Remove the block",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-type.description",action:"inputs.portable-text.invali
19d-value.missing-type.action",values:{key:e._key}}},!0}if(e._type===t.block.name){if(e.children&&!Array.isArray(e.children))return r={patches:[(0,w.hZ)({children:[]},[{_key:e._key}])],description:`Text block with _key '${e._key}' has a invalid required property 'children'.`,action:"Reset the children property",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-or-invalid-children.description",action:"inputs.portable-text.invalid-value.missing-or-invalid-children.action",values:{key:e._key}}},!0;if(void 0===e.children||Array.isArray(e.children)&&0===e.children.length){let o={_type:t.span.name,_key:n(),text:"",marks:[]};return r={autoResolve:!0,patches:[(0,w.Wm)([],[{_key:e._key},"children"]),(0,w.Yr)([o],"after",[{_key:e._key},"children",0])],description:`Children for text block with _key '${e._key}' is empty.`,action:"Insert an empty text",item:e,i18n:{description:"inputs.portable-text.invalid-value.empty-children.description",action:"inputs.portable-text.invalid-value.empty-children.action",values:{key:e._key}}},!0}let i=[...new Set(e.children.filter(e=>(0,d.bl)({schema:t},e)).flatMap(e=>e.marks||[]))];if(Array.isArray(e.markDefs)&&e.markDefs.length>0){let t=[...new Set(e.markDefs.map(e=>e._key).filter(e=>!i.includes(e)))];if(t.length>0)return r={autoResolve:!0,patches:t.map(t=>(0,w.wC)([{_key:e._key},"markDefs",{_key:t}])),description:`Block contains orphaned data (unused mark definitions): ${t.join(", ")}.`,action:"Remove unused mark definition item",item:e,i18n:{description:"inputs.portable-text.invalid-value.orphaned-mark-defs.description",action:"inputs.portable-text.invalid-value.orphaned-mark-defs.action",values:{key:e._key,unusedMarkDefs:t.map(e=>e.toString())}}},!0}let l=i.filter(e=>!t.decorators.map(e=>e.name).includes(e)).filter(t=>void 0===e.markDefs||!e.markDefs.find(e=>e._key===t));if(l.length>0){let n=e.children.filter(e=>e._type===t.span.name&&Array.isArray(e.marks)&&e.marks.some(e=>l.includes(e)));if(n){let t=l.join(", ");return r={autoResolve:!0,patches:n.map(t=>(0,w.hZ)((t.marks||[]).filter(e=>!l.includes(e)),[{_key:e._key},"children",{_key:t._key},"marks"])),description:`Block with _key '${e._key}' contains marks (${t}) not supported by the current content model.`,action:"Remove invalid marks",item:e,i18n:{description:"inputs.portable-text.invalid-value.orphaned-marks.description",action:"inputs.portable-text.invalid-value.orphaned-marks.action",values:{key:e._key,orphanedMarks:l.map(e=>e.toString())}}},!0}}e.children.some((o,i)=>{if("object"!=typeof o||null===o)return r={patches:[(0,w.wC)([{_key:e._key},"children",i])],description:`Child at index '${i}' in block with key '${e._key}' is not an object.`,action:"Remove the item",item:e,i18n:{description:"inputs.portable-text.invalid-value.non-object-child.description",action:"inputs.portable-text.invalid-value.non-object-child.action",values:{key:e._key,index:i}}},!0;if(!o._key||"string"!=typeof o._key){let t={...o,_key:n()};return r={autoResolve:!0,patches:[(0,w.hZ)(t,[{_key:e._key},"children",i])],description:`Child at index ${i} is missing required _key in block with _key ${e._key}.`,action:"Set a new random _key on the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-child-key.description",action:"inputs.portable-text.invalid-value.missing-child-key.action",values:{key:e._key,index:i}}},!0}return o._type?a.includes(o._type)?o._type===t.span.name&&"string"!=typeof o.text&&(r={patches:[(0,w.hZ)({...o,text:""},[{_key:e._key},"children",{_key:o._key}])],description:`Child with _key '${o._key}' in block with key '${e._key}' has missing or invalid text property!`,action:"Write an empty text property to the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.invali
19d-span-text.description",action:"inputs.portable-text.invalid-value.invalid-span-text.action",values:{key:e._key,childKey:o._key}}},!0):(r={patches:[(0,w.wC)([{_key:e._key},"children",{_key:o._key}])],description:`Child with _key '${o._key}' in block with key '${e._key}' has invalid '_type' property (${o._type}).`,action:"Remove the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.disallowed-child-type.description",action:"inputs.portable-text.invalid-value.disallowed-child-type.action",values:{key:e._key,childKey:o._key,childType:o._type}}},!0):(r={patches:[(0,w.wC)([{_key:e._key},"children",{_key:o._key}])],description:`Child with _key '${o._key}' in block with key '${e._key}' is missing '_type' property.`,action:"Remove the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-child-type.description",action:"inputs.portable-text.invalid-value.missing-child-type.action",values:{key:e._key,childKey:o._key}}},!0)})&&(o=!1)}return!1})&&(o=!1),{valid:o,resolution:r,value:e}):{valid:!1,resolution:{patches:[(0,w.wC)([])],description:"Editor value must be an array of Portable Text blocks, or undefined.",action:"Unset the value",item:e,i18n:{description:"inputs.portable-text.invalid-value.not-an-array.description",action:"inputs.portable-text.invalid-value.not-an-array.action"}},value:e}}let ln=(0,b.SP)(({sendBack:e,input:t})=>{lo({context:t.context,sendBack:e,slateEditor:t.slateEditor,value:t.value,streamBlocks:t.streamBlocks})}),lr=(0,v.mj)({types:{context:{},input:{},events:{},emitted:{}},actions:{"assign initial value synced":(0,k.a)({initialValueSynced:!0}),"assign readOnly":(0,k.a)({readOnly:({event:e})=>((0,v.DT)(e,"update readOnly"),e.readOnly)}),"assign pending value":(0,k.a)({pendingValue:({event:e})=>((0,v.DT)(e,"update value"),e.value)}),"clear pending value":(0,k.a)({pendingValue:void 0}),"assign previous value":(0,k.a)({previousValue:({event:e})=>((0,v.DT)(e,"done syncing"),e.value)}),"emit done syncing value":(0,C.a)({type:"done syncing value"}),"emit syncing value":(0,C.a)({type:"syncing value"})},guards:{"initial value synced":({context:e})=>e.initialValueSynced,"is busy":({context:e})=>{let t=e.slateEditor.isDeferringMutations||e.slateEditor.isProcessingRemoteChanges;return P.syncValue(j({isBusy:t,isDeferringMutations:e.slateEditor.isDeferringMutations,isProcessingRemoteChanges:e.slateEditor.isProcessingRemoteChanges})),t},"is empty value":({event:e})=>"update value"===e.type&&void 0===e.value,"is empty array":({event:e})=>"update value"===e.type&&Array.isArray(e.value)&&0===e.value.length,"is new value":({context:e,event:t})=>"update value"===t.type&&e.previousValue!==t.value&&!rp({schema:e.schema},e.previousValue,t.value),"value changed while syncing":({context:e,event:t})=>"done syncing"===t.type&&e.pendingValue!==t.value&&!rp({schema:e.schema},e.pendingValue,t.value),"pending value equals previous value":({context:e})=>rp({schema:e.schema},e.pendingValue,e.previousValue)},actors:{"sync value":ln}}).createMachine({id:"sync",context:({input:e})=>({initialValue:e.initialValue,initialValueSynced:!1,keyGenerator:e.keyGenerator,schema:e.schema,readOnly:e.readOnly,slateEditor:e.slateEditor,pendingValue:void 0,previousValue:void 0}),entry:[(0,x.r)(({context:e})=>({type:"update value",value:e.initialValue}))],on:{"update readOnly":{actions:["assign readOnly"]}},initial:"idle",states:{idle:{entry:[()=>{P.syncValue("entry: syncing->idle")}],exit:[()=>{P.syncValue("exit: syncing->idle")}],on:{"update value":[{guard:(0,x.j)(["is empty value",(0,x.n)("initial value synced")]),actions:["assign initial value synced","emit done syncing value"]},{guard:(0,x.j)(["is empty array",(0,x.n)("initial value synced")]),actions:["assign initial value synced",(0,C.a)({type:"value changed",value:[]}),"emit done syncing value"]},{guard:(0,x.j)(["is busy","is new value"]),target:"busy",actions:["assign pending value"]},{guard:"is new value",target:"syncing",actions:["assign pending value"]},{guard:(0,x.n)("initial value synced"),actions:[()=>{P.syncValue("no new value â setting initial value as synced")},"assign initial value synced","emit done syncing value"]},{actions:[()=>{P.syncValue("no new value and initial value already synced")}]}]}},busy:{entry:[()=>{P.syncValue("entry: syncing->busy")}],exit:[()=>{P.syncValue("exit: syncing->busy")}
19],after:{1e3:[{guard:"is busy",target:".",reenter:!0,actions:[()=>{P.syncValue("reenter: syncing->busy")}]},{target:"syncing"}]},on:{"update value":[{guard:"is new value",actions:["assign pending value"]}]}},syncing:{entry:[()=>{P.syncValue("entry: syncing->syncing")},"emit syncing value"],exit:[()=>{P.syncValue("exit: syncing->syncing")},"emit done syncing value"],invoke:{src:"sync value",id:"sync value",input:({context:e})=>({context:{keyGenerator:e.keyGenerator,previousValue:e.previousValue,readOnly:e.readOnly,schema:e.schema},slateEditor:e.slateEditor,streamBlocks:!e.initialValueSynced,value:e.pendingValue})},on:{"update value":{guard:"is new value",actions:["assign pending value"]},patch:{actions:[(0,C.a)(({event:e})=>e)]},"invalid value":{actions:[(0,C.a)(({event:e})=>e)]},"value changed":{actions:[(0,C.a)(({event:e})=>e)]},"done syncing":[{guard:"value changed while syncing",actions:["assign previous value","assign initial value synced"],target:"syncing",reenter:!0},{target:"idle",actions:["clear pending value","assign previous value","assign initial value synced"]}]}}}});async function lo({context:e,sendBack:t,slateEditor:n,streamBlocks:r,value:o}){let a=!1,i=!1,l=!0,s=!!n.selection;if(o&&0!==o.length||(function({slateEditor:e,doneSyncing:t}){o_(e,()=>{ab(e,()=>{ak(e,()=>{oj(e,()=>{if(t)return;let n=e.children.length;e.children.forEach((t,r)=>{let o=[n-1-r],a=U(e,o);if(!a)return;let i=a.node;e.apply({type:"remove_node",path:o,node:i})})})})})})}({slateEditor:n,doneSyncing:a}),i=!0),o&&o.length>0)if(r)await new Promise(r=>{a?r():(i=li({slateEditor:n,value:o}),(async()=>{for await(let[r,a]of la({value:o})){let{blockChanged:s,blockValid:c}=ll({context:e,sendBack:t,block:r,index:a,slateEditor:n,value:o});if(i=s||i,!(l=l&&c))break}r()})())});else{if(a)return;i=li({slateEditor:n,value:o});let r=0;for(let a of o){let{blockChanged:s,blockValid:c}=ll({context:e,sendBack:t,block:a,index:r,slateEditor:n,value:o});if(i=s||i,l=l&&c,!c)break;r++}}if(!l){P.syncValue("Invalid value, returning"),a=!0,t({type:"done syncing",value:o});return}if(i){P.syncValue("remote value changed, syncing local value");try{n.onChange()}catch(e){console.error(e),t({type:"invalid value",resolution:null,value:o}),a=!0,t({type:"done syncing",value:o});return}s&&!n.selection&&n.children.length>0&&(r5(n,ep(n,[])),n.onChange()),t({type:"value changed",value:o})}else P.syncValue("remote value and local value are equal, no need to sync");a=!0,t({type:"done syncing",value:o})}async function*la({value:e}){let t=0;for await(let n of e)t%10==0&&await new Promise(e=>setTimeout(e,0)),yield[n,t],t++}function li({slateEditor:e,value:t}){let n=!1;return o_(e,()=>{ak(e,()=>{oj(e,()=>{let r=e.children.length;if(t.length<r){for(let n=r-1;n>t.length-1;n--){let t=U(e,[n]);if(!t)continue;let r=t.node;e.apply({type:"remove_node",path:[n],node:r})}n=!0}})})}),n}function ll({context:e,sendBack:t,block:n,index:r,slateEditor:o,value:a}){let i=o.children.at(r),l=o.children.at(r);if(!i||!l){let i=lt([n],e.schema,e.keyGenerator);if(P.syncValue("Validating and inserting new block in the end of the value",n),i.valid||i.resolution?.autoResolve){let t=ay(n,{schemaTypes:e.schema});return o_(o,()=>{ak(o,()=>{oj(o,()=>{o.apply({type:"insert_node",path:[r],node:t})})})}),{blockChanged:!0,blockValid:!0}}return P.syncValue("Invalid",i),t({type:"invalid value",resolution:i.resolution,value:a}),{blockChanged:!1,blockValid:!1}}if(rf(e,n,l))return{blockChanged:!1,blockValid:!0};let s=a[r];if(!s)return{blockChanged:!1,blockValid:!0};let c=lt([s],e.schema,e.keyGenerator);return!c.valid&&c.resolution?.autoResolve&&c.resolution?.patches.length>0&&!e.readOnly&&e.previousValue&&e.previousValue!==a&&(console.warn(`${c.resolution.action} for block with _key '${s._key}'. ${c.resolution?.description}`),c.resolution.patches.forEach(e=>{t({type:"patch",patch:e})})),c.valid||c.resolution?.autoResolve?(l._key===n._key&&l._type===n._type?(P.syncValue("Updating block",l,n),o_(o,()=>{ak(o,()=>{oj(o,()=>{!function({context:e,slateEditor:t,oldSlateBlock:n,block:r,index:o}){let a=ay(r,{schemaTypes:e.schema});oz(t,a,[o]);let i={};for(let e of Object.keys(n))"children"===e||"text"===e||a.hasOwnProperty(e)||(i[e]=n[e]);if(Object.keys(i).length>0&&t.apply({type:"set_node",path:[o],properties:i,newProperties:{}}),(0,d.zS)({schema:t.schema},a)&&(0,d.zS)({schema:t.schema},n)){let r=n.children.length;a.children.length<r&&Array.from(Array(r-a.children.length)).forEac
19h((e,n)=>{let a=r-1-n;if(a>0){P.syncValue("Removing child");let e=U(t,[o,a]);if(!e)return;let n=e.node;t.apply({type:"remove_node",path:[o,a],node:n})}}),a.children.forEach((r,a)=>{let i=n.children.at(a),l=!i||!rk(r,i,t.schema.span.name),s=i&&(0,d.bl)({schema:t.schema},i)&&r.text!==i.text,c=[o,a];if(l)if(r._key===i?._key&&r._type===i?._type){P.syncValue("Updating changed child",r,i),oz(t,r,c);let n=(0,d.bl)({schema:e.schema},r)&&(0,d.bl)({schema:e.schema},i);n&&s?(i.text.length>0&&az(t,{at:{focus:{path:c,offset:0},anchor:{path:c,offset:i.text.length}}}),t.apply({type:"insert_text",path:c,offset:0,text:r.text}),t.onChange()):n||P.syncValue("Updating changed inline object child",r)}else if(i){P.syncValue("Replacing child",r);let e=U(t,[o,a]);if(!e)return;let n=e.node;t.apply({type:"remove_node",path:[o,a],node:n}),t.apply({type:"insert_node",path:[o,a],node:r}),t.onChange()}else i||(P.syncValue("Inserting new child",r),t.apply({type:"insert_node",path:[o,a],node:r}),t.onChange())})}}({context:e,slateEditor:o,oldSlateBlock:i,block:n,index:r})})})})):(P.syncValue("Replacing block",l,n),o_(o,()=>{ak(o,()=>{oj(o,()=>{!function({context:e,slateEditor:t,block:n,index:r}){let o=ay(n,{schemaTypes:e.schema}),a=t.selection,i=a&&a.focus.path[0]===r;i&&r7(t);let l=U(t,[r]);if(!l)return;let s=l.node;t.apply({type:"remove_node",path:[r],node:s}),t.apply({type:"insert_node",path:[r],node:o}),t.onChange(),i&&Z(t,a.anchor.path)&&Z(t,a.focus.path)&&r5(t,a)}({context:e,slateEditor:o,block:n,index:r})})})})),{blockChanged:!0,blockValid:!0}):(t({type:"invalid value",resolution:c.resolution,value:a}),{blockChanged:!1,blockValid:!1})}class ls{constructor(e){this.editor=e.editor,this.schemaTypes=e.editor._internal.editorActor.getSnapshot().context.schema,this.editable=e.editor._internal.editable}setEditable=e=>{this.editor._internal.editable={...this.editor._internal.editable,...e}};static activeAnnotations=e=>e&&e.editable?e.editable.activeAnnotations():[];static isAnnotationActive=(e,t)=>!!e&&!!e.editable&&e.editable.isAnnotationActive(t);static addAnnotation=(e,t,n)=>e.editable?.addAnnotation(t,n);static blur=e=>{e.editable?.blur()};static delete=(e,t,n)=>e.editable?.delete(t,n);static findDOMNode=(e,t)=>e.editable?.findDOMNode(t);static findByPath=(e,t)=>e.editable?.findByPath(t)||[];static focus=e=>{e.editable?.focus()};static focusBlock=e=>e.editable?.focusBlock();static focusChild=e=>e.editable?.focusChild();static getSelection=e=>e.editable?e.editable.getSelection():null;static getValue=e=>e.editable?.getValue();static hasBlockStyle=(e,t)=>e.editable?.hasBlockStyle(t);static hasListStyle=(e,t)=>e.editable?.hasListStyle(t);static isCollapsedSelection=e=>e.editable?.isCollapsedSelection();static isExpandedSelection=e=>e.editable?.isExpandedSelection();static isMarkActive=(e,t)=>e.editable?.isMarkActive(t);static insertChild=(e,t,n)=>e.editable?.insertChild(t,n);static insertBlock=(e,t,n)=>e.editable?.insertBlock(t,n);static insertBreak=e=>e.editable?.insertBreak();static isVoid=(e,t)=>e.editable?.isVoid(t);static isObjectPath=(e,t)=>{if(!t||!Array.isArray(t))return!1;let n=t.length>3&&"children"===t[1];return t.length>1&&"children"!==t[1]||n};static marks=e=>e.editable?.marks();static select=(e,t)=>{e.editable?.select(t)};static removeAnnotation=(e,t)=>e.editable?.removeAnnotation(t);static toggleBlockStyle=(e,t)=>e.editable?.toggleBlockStyle(t);static toggleList=(e,t)=>e.editable?.toggleList(t);static toggleMark=(e,t)=>{e.editable?.toggleMark(t)};static getFragment=e=>e.editable?.getFragment();static undo=e=>{e.editable?.undo()};static redo=e=>{e.editable?.redo()};static isSelectionsOverlapping=(e,t,n)=>e.editable?.isSelectionsOverlapping(t,n)}function lc(e){let t,n,r,o,a,s,u,f,y=(0,l.c)(26);y[0]!==e.initialConfig?(t=()=>{let t=function(e){var t,n,r,o;let a,i,l,s,c,u,f,y;P.setup("creating new editor instance");let m=[],g=(0,x.c)(i9,{input:(r=e,u=(0,d.Fc)(r.schemaDefinition),{converters:oh,keyGenerator:r.keyGenerator??h.OL,readOnly:r.readOnly,schema:u,initialValue:r.initialValue})}),v=(0,x.c)(le),k=(t={editorActor:g,relayActor:v,subscriptions:m},P.setup("creating new slate editor instance"),l=om(i=t.editorActor.getSnapshot().context),n={schema:i.schema,keyGenerator:i.keyGenerator},(s=a={[eu]:!0,children:[],get value(){return this.children},operations:[],selection:null,marks:null,dirtyPaths:[],dirtyPathKeys:new Set,flushing:!1,normalizing:!0,batchingDirtyPaths:!1,pathRefs:new Set,pointRefs:new Set,rangeRefs:new Set,createSpan:()=>({_type:n.schema.span.name,_key:n.keyGenerator(),text:"",marks:[]}),isInline:()=>!1,onChange:()=>{},apply:(...e)=>((e,t)=>{for(let n of e.pathRefs)ax.transform(n,t);for(let n of e.pointRefs)aC.transform(n,t);for(let n of e.rangeRefs)!function(e,t){let{current:n,affinity:r}=e;if(null==n)return;let o=function(e,t,n={}){let r,o;if(null===e)return null;let{affinity:a="inward"}=n;if("inward"===a){let t=eB(e);ea(e)?(r="backward",o=t?r:"forward"):(r="forward",o=t?r:"backward")}else"outward"===a?ea(e)?(r="forward",o="backward"):(r="backward",o="forward"):(r=a,o=a);let i=ns(e.anchor,t,{affinity:r}),l=ns(e.focus,t,{affinity:o});return i&&l?{anchor:i,focus:l}:null}(n,t,{affinity:r});e.current=o,null==o&&e.unref()}(n,t);if(!e.batchingDirtyPaths){let n=aB(t)?e=>nl(e,t):void 0;aF(e,e.getDirtyPaths(t),n)}(function(e,t){let n=!1;switch(t.type){case"insert_node":{let{path:r,node:o}=t;aA(e,nI(r),e.schema,e=>{let t=r[r.length-1];if(t>e.length)throw Error(`Cannot apply an "insert_node" operation at path [${r}] because the destination is past the end of the node.`);return function(e,t,...n){let r=e.slice();return r.splice(t,0,...n),r}(e,t,o)}),n=!0;break}case"insert_text":{let{path:r,offset:o,text:a}=t;if(0===a.length)break;aS(e,r,e.schema,e=>{let t=e.text.slice(0,o),n=e.text.slice(o);return{...e,text:t+a+n}}),n=!0;break}case"remove_node":{let{path:n}=t,r=n[n.length-1];if(aA(e,nI(n),e.schema,e=>a_(e,r,1)),e.selection){let r={...e.selection};
19for(let[o,a]of aD(r)){let i=ns(o,t);if(null!=r&&null!=i)r[a]=i;else{let t,o;for(let{node:r,path:a}of ey(e))if((0,d.bl)({schema:e.schema},r))if(-1===er(a,n))t=[r,a];else{o=[r,a];break}let i=!1;t&&o&&(i=!aE(t[1],n)&&(!!ex(o[1],n)||X(t[1],n).length<X(o[1],n).length)),t&&!i?r[a]={path:t[1],offset:t[0].text.length}:o?r[a]={path:o[1],offset:0}:r=null}}r&&t9(r,e.selection)||(e.selection=r)}break}case"remove_text":{let{path:r,offset:o,text:a}=t;if(0===a.length)break;aS(e,r,e.schema,e=>{let t=e.text.slice(0,o),n=e.text.slice(o+a.length);return{...e,text:t+n}}),n=!0;break}case"set_node":{let{path:n,properties:r,newProperties:o}=t;if(0===n.length)throw Error("Cannot set properties on the root node!");aw(e,n,e.schema,e=>{let t={...e};for(let e in o){if("children"===e)throw Error(`Cannot set the "${e}" property of nodes!`);let n=o[e];null==n?delete t[e]:t[e]=n}for(let e in r)o.hasOwnProperty(e)||delete t[e];return t});break}case"set_selection":{let{newProperties:n}=t;if(null==n){e.selection=null;break}if(null==e.selection){if(!en(n))throw Error(`Cannot apply an incomplete "set_selection" operation properties ${j(n)} when there is no current selection.`);e.selection={...n};break}let r={...e.selection};for(let e in n){let t=n[e];if(null==t){if("anchor"===e||"focus"===e)throw Error(`Cannot remove the "${e}" selection property`);delete r[e]}else r[e]=t}e.selection=r}}if(n&&e.selection){let n={...e.selection};for(let[e,r]of aD(n))n[r]=ns(e,t);t9(n,e.selection)||(e.selection=n)}})(e,t),e.operations.push(t),oE(e,{operation:t}),"set_selection"===t.type&&(e.marks=null),e.flushing||(e.flushing=!0,Promise.resolve().then(()=>{e.flushing=!1,e.onChange({operation:t}),e.operations=[]}))})(a,...e),normalizeNode:(...e)=>((e,t)=>{let[n,r]=t;if((0,d.bl)({schema:e.schema},n)||T({schema:e.schema},n))return;n.children??=[];let o=n;if(o!==e&&0===o.children.length){let t=e.createSpan();aI(e,[t],{at:r.concat(0),includeObjectNodes:!0});let n=op(e,r)?.node;if(!n)return;o=n}let a=o.children[0];if(!ed(o)&&(e.isInline(o)||(0,d.bl)({schema:e.schema},a)||T({schema:e.schema},a)||(0,d.zS)({schema:e.schema},a)&&e.isInline(a)))for(let t=0;t<o.children.length;t++){let n=o.children[t],a=o.children[t-1];if((0,d.bl)({schema:e.schema},n)){if(null!=a&&(0,d.bl)({schema:e.schema},a)){if(""===n.text){aR(e,{at:r.concat(t),includeObjectNodes:!0});let n=op(e,r)?.node;if(!n)return;o=n,t--}else if(""===a.text){aR(e,{at:r.concat(t-1),includeObjectNodes:!0});let n=op(e,r)?.node;if(!n)return;o=n,t--}else if(ne(n,a,{loose:!0})){oM(e,r.concat(t),a.text.length);let n=op(e,r)?.node;if(!n)return;o=n,t--}}}else if((0,d.zS)({schema:e.schema},n))if(e.isInline(n)){if(null==a||!(0,d.bl)({schema:e.schema},a)){let n=e.createSpan();aI(e,[n],{at:r.concat(t),includeObjectNodes:!0});let a=op(e,r)?.node;if(!a)return;o=a,t++}if(t===o.children.length-1){let n=e.createSpan();aI(e,[n],{at:r.concat(t+1),includeObjectNodes:!0});let a=op(e,r)?.node;if(!a)return;o=a,t++}}else{aR(e,{at:r.concat(t),includeObjectNodes:!0});let n=op(e,r)?.node;if(!n)return;o=n,t--}else if(T({schema:e.schema},n)){if(null==a||!(0,d.bl)({schema:e.schema},a)){let n=e.createSpan();aI(e,[n],{at:r.concat(t),includeObjectNodes:!0});let a=op(e,r)?.node;if(!a)return;o=a,t++}if(t===o.children.length-1){let n=e.createSpan();aI(e,[n],{at:r.concat(t+1),includeObjectNodes:!0});let a=op(e,r)?.node;if(!a)return;o=a,t++}}}else for(let t=0;t<o.children.length;t++){let n=o.children[t];if((0,d.bl)({schema:e.schema},n)||(0,d.zS)({schema:e.schema},n)&&e.isInline(n)){if(aR(e,{at:r.concat(t),includeObjectNodes:!0}),0===r.length)o=e;else{let t=op(e,r)?.node;if(!t)return;o=t}t--}}})(a,...e),getDirtyPaths:(...e)=>((e,t)=>{switch(t.type){case"insert_text":case"remove_text":case"set_node":{let{path:e}=t;return aP(e)}case"insert_node":{let{node:n,path:r}=t,o=aP(r);if((0,d.bl)(e,n))return o;for(let t of em(e,n))o.push(r.concat(t.path));return o}case"remove_node":{let{path:e}=t;return[...function(e,t={}){let{reverse:n=!1}=t,r=aP(e,t);return n?r.slice(1):r.slice(0,-1)}(e)]}default:return[]}})(a,...e),shouldNormalize:(...e)=>((e,{iteration:t,initialDirtyPathsLength:n})=>{let r=42*n;if(t>r)throw Error(`Could not completely normalize the editor after ${r} iterations! This is usually due to incorrect normalization logic that leaves a no
19de in an invalid state.`);return!0})(0,...e),select:(...e)=>(function(e,t){let{selection:n}=e;if(t=tO(e,t),n)return void e.setSelection(t);if(!en(t))throw Error(`When setting the selection and the current selection is \`null\` you must provide at least an \`anchor\` and \`focus\`, but you passed: ${j(t)}`);e.apply({type:"set_selection",properties:n,newProperties:t})})(a,...e),setSelection:(...e)=>(function(e,t){let{selection:n}=e,r={},o={};if(n){for(let e in t)("anchor"!==e||null==t.anchor||eC(t.anchor,n.anchor))&&("focus"!==e||null==t.focus||eC(t.focus,n.focus))&&("anchor"===e||"focus"===e||t[e]===n[e])||(r[e]=n[e],o[e]=t[e]);Object.keys(r).length>0&&e.apply({type:"set_selection",properties:r,newProperties:o})}})(a,...e)}).editableTypes=new Set,s.decoratedRanges=[],s.decoratorState={},s.blockIndexMap=new Map,s.history={undos:[],redos:[]},s.lastSelection=null,s.lastSlateSelection=null,s.listIndexMap=new Map,s.remotePatches=[],s.undoStepId=void 0,s.children=[l],s.isDeferringMutations=!1,s.isNormalizingNode=!1,s.isPatching=!0,s.isPerformingBehaviorOperation=!1,s.isProcessingRemoteChanges=!1,s.isRedoing=!1,s.isUndoing=!1,s.withHistory=!0,c=((e,t)=>{let n,{editorActor:r,relayActor:o}=t,a=(n=r.getSnapshot().context,function(e){let{apply:t,normalizeNode:o}=e;return e.apply=o=>
19{if(e.isProcessingRemoteChanges||e.isUndoing||e.isRedoing)return void t(o);if("insert_node"===o.type&&!ed(o.node)){let a=o.node._key&&function(e,t,n){if(1===t.length)return e.blockIndexMap.has(n);if(t.length>2)return!1;let r=t.at(0),o=void 0!==r?e.context.value.at(r):void 0;return!!o&&!!(0,d.zS)(e.context,o)&&o.children.some(e=>e._key===n)}({blockIndexMap:e.blockIndexMap,context:{schema:n.schema,value:e.children}},o.path,o.node._key)?void 0:o.node._key;t({...o,node:{...o.node,_key:void 0===a?r.getSnapshot().context.keyGenerator():a}});return}t(o)},e.normalizeNode=t=>{let[n,a]=t,i=e3(e,a),l=i?N(e,i.path):e.children.map((e,t)=>({node:e,path:[t]})),s=new Set;for(let t of l){if(t.node._key&&s.has(t.node._key)||!t.node._key){let t=r.getSnapshot().context.keyGenerator();s.add(t),oI(e,()=>{oz(e,{_key:t},a)});return}s.add(t.node._key)}oI(e,()=>{o(t)})},e}),i=function({editorActor:e}){return function(t){t.schema=e.getSnapshot().context.schema,t.isInline=n=>{if(ed(n))return!1;let r=e.getSnapshot();if(!r.context.schema.inlineObjects.map(e=>e.name).includes(n._type))return!1;if(r.context.schema.blockObjects.map(e=>e.name).includes(n._type)){for(let e of t.children)if(e===n)return!1}return!0};let{normalizeNode:n}=t;return t.normalizeNode=r=>{let[o,a]=r;if(ed(o))return void n(r);if(void 0===o._type&&2===a.length){P.normalization("Setting span type on text node without a type");let n=o._key||e.getSnapshot().context.keyGenerator();oI(t,()=>{oz(t,{...o,_type:e.getSnapshot().context.schema.span.name,_key:n},a)});return}if(void 0===o._key&&(1===a.length||2===a.length)){P.normalization("Setting missing key on child node without a key");let n=e.getSnapshot().context.keyGenerator();oI(t,()=>{oz(t,{_key:n},a)});return}oI(t,()=>{n(r)})},t}}({editorActor:r}),l=function({editorActor:e,relayActor:t,subscriptions:n}){var r;let o,a=(r=e.getSnapshot().context,(e,t)=>{let n=!1;try{switch(t.type){case"insert":n=function(e,t,n){let r=ag(t.children,n.path);if(!r)return 1===n.path.length&&0===n.path[0]&&(n.items.map(t=>ay(t,{schemaTypes:e.schema})).forEach((e,n)=>{t.apply({type:"insert_node",path:[n],node:e})}),!0);if(n.path.length>1&&"children"!==n.path[1])return!1;if(1===n.path.length){let{items:o,position:a}=n,i=o.map(t=>ay(t,{schemaTypes:e.schema})),l=r.index,s="after"===a?l+1:l,c=am(e.initialValue,t.children,e.schema);if(i.forEach((e,n)=>{t.apply({type:"insert_node",path:[s+n],node:e})}),c&&"number"==typeof n.path[0]&&0===n.path[0]){let e="before"===a?l+i.length:l,n=U(t,[e]);if(!n)return!1;t.apply({type:"remove_node",path:[e],node:n.node})}return!0}let{items:o,position:a}=n,i=av(r,n.path,t.schema);if(!i)return!1;let l=ay({...r.node,children:o},{schemaTypes:e.schema}),s="after"===a?i.index+1:i.index,c=[r.index,s];return l&&(0,d.zS)({schema:t.schema},l)&&l.children.forEach((e,n)=>{t.apply({type:"insert_node",path:[c[0],c[1]+n],node:e})}),!0}(r,e,t);break;case"unset":n=function(e,t){if(0===t.path.length){r7(e);let t=N(e,[]);for(let n=t.length-1;n>=0;n--){let r=t[n];if(!r)continue;let{node:o,path:a}=r;e.apply({type:"remove_node",path:a,node:o})}return!0}let n=ag(e.children,t.path);if(!n)return!1;if(1===t.path.length){let t=U(e,[n.index]);return!!t&&(e.apply({type:"remove_node",path:[n.index],node:t.node}),!0)}let r=av(n,t.path,e.schema);if((0,d.zS)({schema:e.schema},n.node)&&r&&"children"===t.path[1]&&3===t.path.length){let t=U(e,[n.index,r.index]);return!!t&&(e.apply({type:"remove_node",path:[n.index,r.index],node:t.node}),!0)}if(r&&((0,d.zS)({schema:e.schema},r.node)||T({schema:e.schema},r.node))){let o=t.path.slice(3).at(0);if(void 0===o||"string"==typeof o&&["_key","_type","children"].includes(o))return!1;let a=(0,w.yl)(r.node,[{...t,path:t.path.slice(3)}]),i=Object.keys(a),l=Object.keys(r.node).filter(e=>!i.includes(e));if(l.length>0){let t={};for(let e of l)t[e]=null;oz(e,t,[n.index,r.index])}else oz(e,a,[n.index,r.index]);return!0}if(r&&(0,d.bl)({schema:e.schema},r.node)){let o=t.path.slice(3),a=o.at(0);if(void 0===a||"string"==typeof a&&["_key","_type"].includes(a))return!1;if("string"==typeof a&&"text"===a)return e.apply({type:"remove_text",path:[n.index,r.index],offset:0,text:r.node.text}),!0;
19let i=Object.keys((0,w.yl)(r.node,[{...t,path:o}])),l=Object.keys(r.node).filter(e=>!i.includes(e)),s={};for(let e of l)s[e]=null;return oz(e,s,[n.index,r.index]),!0}if(!r){if(!(0,d.zS)({schema:e.schema},n.node)){let r=(0,w.yl)(n.node,[{...t,path:t.path.slice(1)}]),o=Object.keys(r),a=Object.keys(n.node).filter(e=>!o.includes(e));if(a.length>0){let t={};for(let e of a)t[e]=null;oz(e,t,[n.index])}else oz(e,r,[n.index]);return!0}if((0,d.zS)({schema:e.schema},n.node)){let r=t.path.slice(1),o=r.at(0);return!(void 0===o||"string"!=typeof o||["_key","_type","children"].includes(o))&&(1===r.length?oz(e,{[o]:null},[n.index]):oz(e,{[o]:(0,w.yl)(n.node,[{...t,path:r}])[o]},[n.index]),!0)}}return!1}(e,t);break;case"set":case"setIfMissing":n=function(e,t){let n=t.value;if(0===t.path.length){if(!Array.isArray(n)||"setIfMissing"===t.type&&e.children.length>0)return!1;let r=e.selection;for(let t=e.children.length-1;t>=0;t--){let n=e.children[t];n&&e.apply({type:"remove_node",path:[t],node:n})}let o=0;for(let t of n)e.apply({type:"insert_node",path:[o],node:t}),o++;return r&&r5(e,r),!0}"string"==typeof t.path[3]&&((n={})[t.path[3]]=t.value);let r=ag(e.children,t.path);if(!r)return!1;let o=(0,d.zS)({schema:e.schema},r.node);if(1===t.path.length){let n=(0,w.yl)(r.node,[{...t,path:t.path.slice(1)}]);if(!((0,d.zS)({schema:e.schema},r.node)&&(0,d.zS)({schema:e.schema},n)))return oz(e,n,[r.index]),!0;{oz(e,n,[r.index]);let t=e.selection;for(let t of Array.from(N(e,[r.index]).reverse(),t=>oC(e,t.path))){let n=t.unref();if(n){let t=U(e,n);if(!t)continue;e.apply({type:"remove_node",path:n,node:t.node})}}return n.children.forEach((t,n)=>{e.apply({type:"insert_node",path:[r.index,n],node:t})}),t&&r5(e,t),!0}}if(o&&"children"!==t.path[1])return oz(e,(0,w.yl)(r.node,[{...t,path:t.path.slice(1)}]),[r.index]),!0;let a=av(r,t.path,e.schema);if(o&&a)if((0,d.bl)({schema:e.schema},a.node))if(null!==n&&"object"==typeof n&&"text"in n&&"string"==typeof n.text){if("setIfMissing"===t.type)return!1;let o=a.node.text,i=n.text;o!==i&&(e.apply({type:"remove_text",path:[r.index,a.index],offset:0,text:o}),e.apply({type:"insert_text",path:[r.index,a.index],offset:0,text:i}),e.onChange())}else{let n=t.path.slice(3),o=n.at(0);if(void 0===o||"string"==typeof o&&["_key","_type","text"].includes(o))return!1;oz(e,(0,w.yl)(a.node,[{...t,path:n}]),[r.index,a.index])}else{let n=t.path.slice(3).at(0);if(void 0===n||"string"==typeof n&&["_key","_type","children"].includes(n))return!1;oz(e,(0,w.yl)(a.node,[{...t,path:t.path.slice(3)}]),[r.index,a.index])}else if(r&&!o)if(!(t.path.length>1)||"children"===t.path[1])return!1;else oz(e,(0,w.yl)(r.node,[{...t,path:t.path.slice(1)}]),[r.index]);return!0}(e,t);break;case"diffMatchPatch":n=function(e,t){let n=ag(e.children,t.path);if(!n)return!1;let r=av(n,t.path,e.schema);if(!r||!(n&&(0,d.zS)({schema:e.schema},n.node)&&4===t.path.length&&"children"===t.path[1]&&"text"===t.path[3])||!(0,d.bl)({schema:e.schema},r.node))return!1;let[o]=function(e,t,n={}){if("string"==typeof e)throw Error("Patches must be an array - pass the patch to `parsePatch()` first");let r=t;if(0===e.length)return[r,[]];let o=function(e,t,n={}){let r=0,o=0;function a(e){for(;r<e;){let e=t.codePointAt(o);if(typeof e>"u")return o;r+=au(e),e>65535?o+=2:o+=1}if(!n.allowExceedingIndices&&r!==e)throw Error("Failed to determine byte offset");return o}let i=[];for(let t of e)i.push({diffs:t.diffs.map(e=>oN(e)),start1:a(t.start1),start2:a(t.start2),utf8Start1:t.utf8Start1,utf8Start2:t.utf8Start2,length1:t.length1,length2:t.length2,utf8Length1:t.utf8Length1,utf8Length2:t.utf8Length2});return i}(e,r,{allowExceedingIndices:n.allowExceedingIndices}),a=n.margin||4,i=n.deleteThreshold||.4,l=function(e,t=4){let n="";for(let e=1;e<=t;e++)n+=String.fromCharCode(e);for(let n of e)n.start1+=t,n.start2+=t,n.utf8Start1+=t,n.utf8Start2+=t;let r=e[0],o=r.diffs;if(0===o.length||0!==o[0][0])o.unshift([0,n]),r.start1-=t,r.start2-=t,r.utf8Start1-=t,r.utf8Start2-=t,r.length1+=t,r.length2+=t,r.utf8Length1+=t,r.utf8Length2+=t;else if(t>o[0][1].length){let e=o[0][1].length,a=t-e;o[0][1]=n.substring(e)+o[0][1],r.start1-=a,r.start2-=a,r.utf8Start1-=a,r.utf8Start2-=a,r.length1+=a,r.length2+=a,r.utf8Length1+=a,r.utf8Length2+=a}if(0===(o=(r=e[e.length-1]).diffs).length||0!==o[o.length-1][0])o.push([0,n]),r.length1+=t,r.length2+=t,r.utf8Length1+=t,r.utf8Length2+=t;else if(t>o[o.length-1][1].length){let e=t-o[o.length-1][1].length;o[o.length-1][1]+=n.substring(0,e),r.length1+=e,r.length2+=e,r.utf8Length1+=e,r.utf8Length2+=e}return n}(o,a);r=l+r+l,function(e,t=4){for(let n=0;n<e.length;n++){if(e[n].length1<=32)continue;let r=e[n];e.splice(n--,1);let o=r.start1,a=r.start2,i="";for(;0!==r.diffs.length;){let l=ad(o-i.length,a-i.length),s=!0;if(""!==i){let e=ac(i);l.length1=i.length,l.utf8Length1=e,l.length2=i.length,l.utf8Length2=e,l.diffs.push([0,i])}for(;0!==r.diffs.length&&l.length1<32-t;){let e=r.diffs[0][0],n=r.diffs[0][1],i=ac(n);if(1===e){l.length2+=n.length,l.utf8Length2+=i,a+=n.length;let e=r.diffs.shift();e&&l.diffs.push(e),s=!1}else -1===e&&1===l.diffs.length&&0===l.diffs[0][0]&&n.length>64?(l.length1+=n.length,l.utf8Length1+=i,o+=n.length,s=!1,l.diffs.push([e,n]),r.diffs.shift()):(i=ac(n=n.substring(0,32-l.length1-t)),l.length1+=n.length,l.utf8Length1+=i,o+=n.length,0===e?(l.length2+=n.length,l.utf8Length2+=i,a+=n.length):s=!1,l.diffs.push([e,n]),n===r.diffs[0][1]?r.diffs.shift():r.diffs[0][1]=r.diffs[0][1].substring(n.length))}i=(i=al(l.diffs)).substring(i.length-t);let c=ai(r.diffs).substring(0,t),u=ac(c);""!==c&&(l.length1+=c.length,l.length2+=c.length,l.utf8Length1+=u,l.utf8Length2+=u,0!==l.diffs.length&&0===l.diffs[l.diffs.length-1][0]?l.diffs[l.diffs.length-1][1]+=c:l.diffs.push([0,c])),s||e.splice(++n,0,l)}}}(o,a);let s=0,c=[];for(let e=0;e<o.length;
19e++){let t=o[e].start2+s,n=ai(o[e].diffs),a,l=-1;if(n.length>32?-1!==(a=aa(r,n.substring(0,32),t))&&(-1===(l=aa(r,n.substring(n.length-32),t+n.length-32))||a>=l)&&(a=-1):a=aa(r,n,t),-1===a)c[e]=!1,s-=o[e].length2-o[e].length1;else{let u;if(c[e]=!0,s=a-t,u=-1===l?r.substring(a,a+n.length):r.substring(a,l+32),n===u)r=r.substring(0,a)+al(o[e].diffs)+r.substring(a+n.length);else{let t=oY(n,u,{checkLines:!1});if(n.length>32&&function(e){let t=0,n=0,r=0;for(let o=0;o<e.length;o++){let a=e[o][0],i=e[o][1];switch(a){case 1:n+=i.length;break;case -1:r+=i.length;break;case 0:t+=Math.max(n,r),n=0,r=0;break;default:throw Error("Unknown diff operation.")}}return t+Math.max(n,r)}(t)/n.length>i)c[e]=!1;else{t=o5(t);let n=0,i=0;for(let l=0;l<o[e].diffs.length;l++){let s=o[e].diffs[l];0!==s[0]&&(i=as(t,n)),1===s[0]?r=r.substring(0,a+i)+s[1]+r.substring(a+i):-1===s[0]&&(r=r.substring(0,a+i)+r.substring(a+as(t,n+s[1].length))),-1!==s[0]&&(n+=s[1].length)}}}}}return[r=r.substring(l.length,r.length-l.length),c]}(ap(t.value),r.node.text,{allowExceedingIndices:!0}),a=function(e,t=4){let n=e.map(e=>oN(e)),r=!1,o=[],a=0,i=null,l=0,s=!1,c=!1,u=!1,d=!1;for(;l<n.length;)0===n[l][0]?(n[l][1].length<t&&(u||d)?(o[a++]=l,s=u,c=d,i=n[l][1]):(a=0,i=null),u=!1,d=!1):(-1===n[l][0]?d=!0:u=!0,i&&(s&&c&&u&&d||i.length<t/2&&3===function(...e){return e.reduce((e,t)=>e+ +!!t,0)}(s,c,u,d))&&(n.splice(o[a-1],0,[-1,i]),n[o[a-1]+1][0]=1,a--,i=null,s&&c?(u=!0,d=!0,a=0):(l=--a>0?o[a-1]:-1,u=!1,d=!1),r=!0)),l++;return r&&(n=o7(n)),n}(oY(r.node.text,o),5),i=0;for(let[t,o]of a)1===t?(e.apply({type:"insert_text",path:[n.index,r.index],offset:i,text:o}),i+=o.length):-1===t?e.apply({type:"remove_text",path:[n.index,r.index],offset:i,text:o}):0===t&&(i+=o.length);return!0}(e,t)}}catch(e){console.error(e)}return n});return function(r){o=[...r.children];let{apply:i}=r,l=[],s=({patches:e})=>{let t=e.filter(e=>"local"!==e.origin);0!==t.length&&(l=l.concat(t),(()=>{if(0===l.length)return;let e=l;l=[];let t=!1;ak(r,()=>{o_(r,()=>{oj(r,()=>{ab(r,()=>{for(let n of e)try{(t=a(r,n))?P.syncPatch(`(applied) ${j(n,2)}`):P.syncPatch(`(ignored) ${j(n,2)}`)}catch(e){console.error(`Applying patch ${j(n)} failed due to: ${e instanceof Error?e.message:e}`)}})})}),t&&(oE(r),r.onChange())})})())};return n.push(()=>{P.syncPatch("subscribing to remote patches");let t=e.on("patches",s);return()=>{P.syncPatch("unsubscribing to remote patches"),t.unsubscribe()}}),r.apply=n=>{let a=[];o=r.children;let{initialValue:l,schema:s}=e.getSnapshot().context,c=1===o.length&&am(l,o,s);i(n);let u=1===r.children.length&&am(l,r.children,s);if(!r.isPatching)return r;switch(c&&!u&&"set_selection"!==n.type&&a.push((0,w.Yr)(o,"before",[0])),n.type){case"insert_text":a=[...a,...function(e,t,n,r){let o=(0,d.zS)({schema:e},t[n.path[0]])&&t[n.path[0]];if(!o)return[];let a=(0,d.zS)({schema:e},o)&&(0,d.bl)({schema:e},o.children[n.path[1]])&&o.children[n.path[1]];if(!a)throw Error("Could not find child");let i=[{_key:o._key},"children",{_key:a._key},"text"],l=r[n.path[0]],s=(0,d.zS)({schema:e},l)&&l.children[n.path[1]],c=(0,d.bl)({schema:e},s)?s.text:"",u=(0,w.jo)(c,a.text,i);return u.value.length?[u]:[]}(s,r.children,n,o)];break;case"remove_text":a=[...a,...function(e,t,n,r){let o=t[n.path[0]];if(!o||!(0,d.zS)({schema:e},o))return[];let a=o.children[n.path[1]]||void 0,i=(0,d.bl)({schema:e},a)?a:void 0;if(a&&!i)throw Error("Expected span");if(!i)throw Error("Could not find child");let l=[{_key:o._key},"children",{_key:i._key},"text"],s=r[n.path[0]],c=(0,d.zS)({schema:e},s)&&s.children[n.path[1]],u=(0,d.bl)({schema:e},c)&&c.text,h=(0,w.jo)(u||"",i.text,l);return h.value?[h]:[]}(s,r.children,n,o)];break;case"remove_node":a=[...a,...function(e,t,n){let r=t[n.path[0]];if(1===n.path.length){if(r&&r._key)return[(0,w.wC)([{_key:r._key}])];throw Error("Block not found")}if(!(0,d.zS)({schema:e},r)||2!==n.path.length)return[];{let e=r.children[n.path[1]];return e?r.children.filter(e=>e._key===n.node._key).length>1?(console.warn(`Multiple spans have \`_key\` ${n.node._key}. It's ambiguous which one to remove.`,j(r,2)),[]):[(0,w.wC)([{_key:r._key},"children",{_key:e._key}])]:[]}}(s,o,n)];break;case"insert_node":a=[...a,...function(e,t,n,r){let o=r[n.path[0]];if(1===n.path.length){let e=0===n.path[0]?"before":"after",t=r[n.path[0]-1],a=0===n.path[0]?o?._key:t?._key;return a?[(0,w.Yr)([n.node],e,[{_key:a}])]:[(0,w.Wm)(r,[]),(0,w.Yr)([n.node],"before",[n.path[0]])]}if((0,d.zS)({schema:e},o)&&2===n.path.length&&t[n.path[0]]){let t=0!==o.children.length&&o.children[n.path[1]-1]?"after":"before",r=o.children.length<=1||!o.children[n.path[1]-1]?[{_key:o._key},"children",0]:[{_key:o._key},"children",{_key:o.children[n.path[1]-1]._key}],a=(0,w.Wm)([],[{_key:o._key},"children"]);return(0,d.bl)({schema:e},n.node),[a,(0,w.Yr)([n.node],t,r)]}return[]}(s,r.children,n,o)];break;case"set_node":a=[...a,...function(e,t,n){let r=n.path.at(0);if(void 0!==r&&1===n.path.length){let o=t.at(r);if(!o)return console.error("Could not find block at index",r),[];if((0,d.zS)({schema:e},o)){let e=[];for(let[t,a]of Object.entries(n.newProperties))"_key"===t?e.push((0,w.hZ)(a,[r,"_key"])):e.push((0,w.hZ)(a,[{_
19key:o._key},t]));for(let t of Object.keys(n.properties))t in n.newProperties||e.push((0,w.wC)([{_key:o._key},t]));return e}{let e=[],t=n.newProperties._key;for(let[a,i]of(void 0!==t&&e.push((0,w.hZ)(t,[r,"_key"])),Object.entries(n.newProperties)))"_key"===a||"children"===a||e.push((0,w.hZ)(i,[{_key:o._key},a]));for(let t of Object.keys(n.properties))"_key"===t||"children"===t||t in n.newProperties||e.push((0,w.wC)([{_key:o._key},t]));return e}}if(2===n.path.length){let r=t[n.path[0]];if((0,d.zS)({schema:e},r)){let t=r.children[n.path[1]];if(t){let o=r._key,a=t._key,i=[];if((0,d.zS)({schema:e},t)){let e=n.newProperties._key;for(let[l,s]of(void 0!==e&&i.push((0,w.hZ)(e,[{_key:o},"children",r.children.indexOf(t),"_key"])),Object.entries(n.newProperties)))"_key"===l||"children"===l||i.push((0,w.hZ)(s,[{_key:o},"children",{_key:a},l]));return i}for(let[e,l]of Object.entries(n.newProperties)){if("_key"===e){i.push((0,w.hZ)(l,[{_key:o},"children",r.children.indexOf(t),e]));continue}i.push((0,w.hZ)(l,[{_key:o},"children",{_key:a},e]))}for(let e of Object.keys(n.properties))e in n.newProperties||i.push((0,w.wC)([{_key:o},"children",{_key:a},e]));return i}throw Error("Could not find a valid child")}throw Error("Could not find a valid block")}throw Error(`Unexpected path encountered: ${j(n.path)}`)}(s,r.children,n)]}if(!c&&u&&["set_node","remove_text","remove_node"].includes(n.type)&&(a=[...a,(0,w.wC)([])],t.send({type:"unset",previousValue:o})),c&&a.length>0&&(a=[(0,w.Wm)([],[]),...a]),a.length>0)for(let t of a)e.send({type:"internal.patch",patch:{...t,origin:"local"},operationId:r.undoStepId,value:r.children});return r},r}}({editorActor:r,relayActor:o,subscriptions:t.subscriptions}),s=function({editorActor:e,subscriptions:t}){return function(n){let r=n.children,o=n.undoStepId;t.push(()=>{let t=e.on("patches",({patches:e,snapshot:t})=>{let o=!1;for(let a of e)if(!o&&"local"!==a.origin){if("unset"===a.type&&0===a.path.length){n.history={undos:[],redos:[]},n.remotePatches.splice(0,n.remotePatches.length),n.withHistory=!0,o=!0;return}n.remotePatches.push({patch:a,time:new Date,snapshot:t,previousSnapshot:r})}r=t});return()=>{t.unsubscribe()}});let{apply:a}=n;return n.apply=t=>{if(e.getSnapshot().matches({"edit mode":"read only"})||n.isProcessingRemoteChanges||n.isUndoing||n.isRedoing)return void a(t);let r=n.withHistory,i=n.undoStepId;if(!r){o=i,a(t);return}for("set_selection"!==t.type&&n.history.redos.length>0&&(n.history.redos=[]),n.history.undos=function({steps:e,op:t,editor:n,currentUndoStepId:r,previousUndoStepId:o}){let a=e.at(-1);if(!a)return og(e,t,n);if(n.operations.length>0)return r===o||n.isNormalizingNode?ov(e,a,t):og(e,t,n);if("set_selection"===t.type&&void 0===r&&void 0!==o||"set_selection"===t.type&&void 0!==r&&void 0!==o&&o!==r)return ov(e,a,t);if(void 0===r&&void 0===o){if("set_selection"===t.type)return ov(e,a,t);let r=a.operations.at(-1);return r&&"insert_text"===t.type&&"insert_text"===r.type&&t.offset===r.offset+r.text.length&&ex(t.path,r.path)&&" "!==t.text||r&&"remove_text"===t.type&&"remove_text"===r.type&&t.offset+t.text.length===r.offset&&ex(t.path,r.path)?ov(e,a,t):og(e,t,n)}if(void 0!==r&&void 0!==o&&r!==o){let n=a.operations.at(-1);if(n&&"insert_text"===t.type&&"insert_text"===n.type&&t.offset===n.offset+n.text.length&&ex(t.path,n.path)&&" "!==t.text||n&&"remove_text"===t.type&&"remove_text"===n.type&&t.offset+t.text.length===n.offset&&ex(t.path,n.path))return ov(e,a,t)}return og(e,t,n)}({steps:n.history.undos,op:t,editor:n,currentUndoStepId:i,previousUndoStepId:o});n.history.undos.length>1e3;)n.history.undos.shift();o=i,a(t)},n}}({editorActor:r,subscriptions:t.subscriptions}),c=function(e){let{apply:t,normalizeNode:n}=e,o=r.getSnapshot().context.schema.styles.at(0)?.name;return e.normalizeNode=t=>{let[a,i]=t;if(ed(a)&&0===a.children.length&&oj(e,()=>{oI(e,()=>{oF(e,om(r.getSnapshot().context),[0])})}),(0,d.zS)({schema:e.schema},a))for(let{node:t,path:n}of N(e,i)){let r=n[n.length-1],o=a.children[r+1];if((0,d.bl)({schema:e.schema},t)&&(0,d.bl)({schema:e.schema},o)&&t.marks?.every(e=>o.marks?.includes(e))&&o.marks?.every(e=>t.marks?.includes(e))){P.normalization("merging spans with same marks"),oI(e,()=>
19{oM(e,[n[0],n[1]+1],t.text.length)});return}}if((0,p.xN)({schema:e.schema},a)&&!Array.isArray(a.markDefs)){P.normalization("adding .markDefs to block node"),oI(e,()=>{oz(e,{markDefs:[]},i)});return}if(o&&(0,p.xN)({schema:e.schema},a)&&typeof a.style>"u"){P.normalization("adding .style to block node"),oI(e,()=>{oz(e,{style:o},i)});return}if((0,p.JS)({schema:e.schema},a)&&"string"!=typeof a.text){P.normalization("Adding .text to span node"),oI(e,()=>{e.apply({type:"set_node",path:i,properties:{},newProperties:{text:""}})});return}if((0,d.bl)({schema:e.schema},a)&&!Array.isArray(a.marks)){P.normalization("Adding .marks to span node"),oI(e,()=>{oz(e,{marks:[]},i)});return}if((0,d.bl)({schema:e.schema},a)){if(!op(e,nI(i)))return;let t=r.getSnapshot().context.schema.decorators.map(e=>e.name),n=a.marks?.filter(e=>!t.includes(e));if(""===a.text&&n&&n.length>0){P.normalization("removing annotations from empty span node"),oI(e,()=>{oz(e,{marks:a.marks?.filter(e=>t.includes(e))},i)});return}}if((0,d.zS)({schema:e.schema},a)){let t=r.getSnapshot().context.schema.decorators.map(e=>e.name);for(let{node:n,path:r}of N(e,i))if((0,d.bl)({schema:e.schema},n)){let o=n.marks??[],i=o.filter(e=>!t.includes(e)&&!a.markDefs?.find(t=>t._key===e));if(i.length>0){P.normalization("removing orphaned annotations from span node"),oI(e,()=>{oz(e,{marks:o.filter(e=>!i.includes(e))},r)});return}}}if((0,d.bl)({schema:e.schema},a)){let t=op(e,nI(i));if(t){let n=t.node,o=r.getSnapshot().context.schema.decorators.map(e=>e.name),l=a.marks??[],s=l.filter(e=>!o.includes(e)&&!n.markDefs?.find(t=>t._key===e));if(s.length>0){P.normalization("removing orphaned annotations from span node"),oI(e,()=>{oz(e,{marks:l.filter(e=>!s.includes(e))},i)});return}}}if((0,d.zS)({schema:e.schema},a)){let t=a.markDefs??[],n=new Set,r=[];for(let e of t)n.has(e._key)||(n.add(e._key),r.push(e));if(t.length!==r.length){P.normalization("removing duplicate markDefs"),oI(e,()=>{oz(e,{markDefs:r},i)});return}}if((0,d.zS)({schema:e.schema},a)){let t=(a.markDefs||[]).filter(t=>a.children.find(n=>(0,d.bl)({schema:e.schema},n)&&Array.isArray(n.marks)&&n.marks.includes(t._key)));if(a.markDefs&&!rg(t,a.markDefs)){P.normalization("removing markDef not in use"),oI(e,()=>{oz(e,{markDefs:t},i)});return}}oI(e,()=>{n(t)})},e.apply=n=>{if(e.isProcessingRemoteChanges||e.isUndoing||e.isRedoing)return void t(n);if("set_selection"===n.type)if(n.properties&&n.newProperties&&n.properties.anchor&&n.properties.focus&&n.newProperties.anchor&&n.newProperties.focus){let t=eB({anchor:n.properties.anchor,focus:n.properties.focus}),r=eB({anchor:n.newProperties.anchor,focus:n.newProperties.focus});if(t&&r){let t=no(e,n.properties.focus.path)?.node,r=no(e,n.newProperties.focus.path)?.node,o=t&&r&&n.newProperties.focus.path[0]===n.properties.focus.path[0]&&n.newProperties.focus.path[1]===n.properties.focus.path[1]+1&&t.text.length===n.properties.focus.offset&&0===n.newProperties.focus.offset,a=t&&r&&n.newProperties.focus.path[0]===n.properties.focus.path[0]&&n.newProperties.focus.path[1]===n.properties.focus.path[1]-1&&0===n.properties.focus.offset&&r.text.length===n.newProperties.focus.offset;o||a||(e.decoratorState={})}}else e.decoratorState={};t(n)},e};return function(e){let{select:t,setSelection:n}=e;return e.select=n=>{if(e.isNormalizingNode||e.isPerformingBehaviorOperation||e.selection)return void t(n);let o=tO(e,n);r.send({type:"behavior event",behaviorEvent:{type:"select",at:e5({schema:r.getSnapshot().context.schema,editor:e,range:o})},editor:e})},e.setSelection=t=>{if(e.isNormalizingNode||e.isPerformingBehaviorOperation)return void n(t);let o=t.anchor?e7({schema:r.getSnapshot().context.schema,editor:e,point:t.anchor}):void 0,a=t.focus?e7({schema:r.getSnapshot().context.schema,editor:e,point:t.focus}):void 0,i=e.selection?ea({anchor:t.anchor??e.selection.anchor,focus:t.focus??e.selection.focus}):t.anchor&&t.focus?ea({anchor:t.anchor,focus:t.focus}):void 0;if(e.selection){let r=t.anchor??e.selection.anchor,o=t.focus??e.selection.focus;if(eC(r,e.selection.anchor)&&eC(o,e.selection.focus))return void n(t)}o&&a?r.send({type:"behavior event",behaviorEvent:{type:"select",at:{anchor:o,focus:a,backward:i}},editor:e}):n(t)},e}(i(a(c(s(l(function(e,t){let{apply:n}=t;return t.apply=r=>{(t.isNormalizingNode&&P.normalization(`(slate operation) 20${j(r,2)}`),"set_selection"===r.type||"insert_text"===r.type||"remove_text"===r.type)?n(r):(n(r),oy({schema:e.schema,value:t.children},{blockIndexMap:t.blockIndexMap,listIndexMap:t.listIndexMap}))},t}(r.getSnapshot().context,function({editor:e,editorActor:t}){let{onChange:n}=e;return e.onChange=()=>{n(),t.getSnapshot().matches({setup:"setting up"})||(()=>{if(e.selection)if(e.selection===e.lastSlateSelection)t.send({type:"update selection",selection:e.lastSelection});else{let n=e5({schema:t.getSnapshot().context.schema,editor:e,range:e.selection});e.lastSlateSelection=e.selection,e.lastSelection=n,t.send({type:"update selection",selection:n})}else t.send({type:"update selection",selection:null})})()},e}({editorActor:r,editor:e}))))))))})((e=>{let t=e,{onChange:n,apply:r}=t=(e=>{let{apply:t,onChange:n}=e;return e.isNodeMapDirty=!1,e.domWindow=null,e.domElement=null,e.domPlaceholder="",e.domPlaceholderElement=null,e.readOnly=!1,e.focused=!1,e.composing=!1,e.userSelection=null,e.onContextChange=null,e.scheduleFlush=null,e.pendingInsertionMarks=null,e.userMarks=null,e.pendingDiffs=[],e.pendingAction=null,e.pendingSelection=null,e.forceRender=null,e.apply=n=>{let r=e.pendingDiffs;r?.length&&(e.pendingDiffs=r.map(e=>(function(e,t){let{path:n,diff:r,id:o}=e;switch(t.type){case"insert_text":return!ex(t.path,n)||t.offset>=r.end?e:t.offset<=r.start?{diff:{start:t.text.length+r.start,end:t.text.length+r.end,text:r.text},id:o,path:n}:{diff:{start:r.start,end:r.end+t.text.length,text:r.text},id:o,path:n};case"remove_text":return!ex(t.path,n)||t.offset>=r.end?e:t.offset+t.text.length<=r.start?{diff:{start:r.start-t.text.length,end:r.end-t.text.length,text:r.text},id:o,path:n}:{diff:{start:r.start,end:r.end-t.text.length,text:r.text},id:o,path:n}}let a=nl(n,t);return a?{diff:r,path:a,id:o}:null}
20)(e,n)).filter(Boolean));let o=e.pendingSelection;o&&(e.pendingSelection=nf(e,o,n));let a=e.pendingAction;if(a?.at){let t=et(a?.at)?np(e,a.at,n):nf(e,a.at,n);e.pendingAction=t?{...a,at:t}:null}switch("set_selection"===n.type&&(e.userSelection?.unref(),e.userSelection=null),t(n),n.type){case"insert_node":case"remove_node":case"insert_text":case"remove_text":case"set_selection":e.isNodeMapDirty=!0}},e.onChange=t=>{let r=e.onContextChange;r&&r(t),n(t)},e})(t);return t.onChange=e=>{(aL<18?aK.unstable_batchedUpdates:e=>e())(()=>{n(e)})},t.apply=e=>{r(e)},t})(s),{editorActor:t.editorActor,relayActor:t.relayActor,subscriptions:t.subscriptions}),oy({schema:i.schema,value:c.children},{blockIndexMap:c.blockIndexMap,listIndexMap:c.listIndexMap}),c),b={focus:()=>{g.send({type:"focus",editor:k})},blur:()=>{g.send({type:"blur",editor:k})},toggleMark:e=>{g.send({type:"behavior event",behaviorEvent:{type:"decorator.toggle",decorator:e},editor:k})},toggleList:e=>{g.send({type:"behavior event",behaviorEvent:{type:"list item.toggle",listItem:e},editor:k})},toggleBlockStyle:e=>{g.send({type:"behavior event",behaviorEvent:{type:"style.toggle",style:e},editor:k})},isMarkActive:e=>{let t=rA({editorActorSnapshot:g.getSnapshot(),slateEditorInstance:k});return(0,p.rm)(t).includes(e)},marks:()=>{let e=rA({editorActorSnapshot:g.getSnapshot(),slateEditorInstance:k});return[...(0,p.N2)(e),...(0,p.rm)(e)]},undo:()=>{g.send({type:"behavior event",behaviorEvent:{type:"history.undo"},editor:k})},redo:()=>{g.send({type:"behavior event",behaviorEvent:{type:"history.redo"},editor:k})},select:e=>{g.send({type:"behavior event",behaviorEvent:{type:"select",at:e},editor:k})},focusBlock:()=>{if(!k.selection)return;let e=k.selection.focus.path.at(0);if(void 0!==e)return k.children.at(e)},focusChild:()=>{if(!k.selection)return;let e=k.selection.focus.path.at(0),t=k.selection.focus.path.at(1),n=void 0!==e?k.children.at(e):void 0;if(n&&(0,d.zS)(g.getSnapshot().context,n))return void 0===t?void 0:n.children.at(t)},insertChild:(e,t)=>(g.send({type:"behavior event",behaviorEvent:{type:"insert.child",child:{_type:e.name,...t||{}}},editor:k}),k.selection?e5({schema:g.getSnapshot().context.schema,editor:k,range:k.selection})?.focus.path??[]:[]),insertBlock:(e,t)=>(g.send({type:"behavior event",behaviorEvent:{type:"insert.block",block:{_type:e.name,...t||{}},placement:"auto"},editor:k}),k.selection?e5({schema:g.getSnapshot().context.schema,editor:k,range:k.selection})?.focus.path??[]:[]),hasBlockStyle:e=>{try{return function({editor:e,style:t}){if(!e.selection)return!1;let[n,r]=ei(e.selection),o=[...ey(e,{from:n.path,to:r.path,match:t=>(0,d.zS)({schema:e.schema},t)})];return o.length>0&&o.every(n=>(0,d.zS)({schema:e.schema},n.node)&&n.node.style===t)}({editor:k,style:e})}catch{return!1}},hasListStyle:e=>{try{return function({editor:e,listItem:t}){if(!e.selection)return!1;let[n,r]=ei(e.selection),o=[...ey(e,{from:n.path,to:r.path,match:t=>(0,d.zS)({schema:e.schema},t)})];return o.length>0&&o.every(n=>(0,h.Eg)({schema:e.schema},n.node)&&n.node.listItem===t)}({editor:k,listItem:e})}catch{return!1}},isVoid:e=>{let t=g.getSnapshot().context.schema;return![t.block.name,t.span.name].includes(e._type)}
20,findByPath:e=>{let t=(0,h.XE)({path:e});if(!t)return[void 0,void 0];let n=k.blockIndexMap.get(t);if(void 0===n)return[void 0,void 0];let r=k.children.at(n);if(!r)return[void 0,void 0];let o=(0,h.qX)({path:e});if(1===e.length&&!o)return[r,[{_key:r._key}]];if((0,d.zS)(g.getSnapshot().context,r)&&o){let e=r.children.find(e=>e._key===o);if(e)return[e,[{_key:r._key},"children",{_key:e._key}]]}return[void 0,void 0]},findDOMNode:e=>{let t;try{let n=Array.from(ey(k,{match:t=>t._key===e._key}))[0];if(n){let e=n.path;t=z(k,e)}}catch{}return t},activeAnnotations:()=>{if(!k.selection||k.selection.focus.path.length<2)return[];try{let e=[];for(let{node:t,path:n}of ey(k,{from:es(k.selection).path,to:el(k.selection).path,match:e=>(0,d.bl)({schema:k.schema},e)&&void 0!==e.marks&&Array.isArray(e.marks)&&e.marks.length>0})){let r=op(k,ec(k,n,{depth:1}));r&&r.node.markDefs?.forEach(n=>{(0,d.bl)({schema:k.schema},t)&&t.marks&&Array.isArray(t.marks)&&t.marks.includes(n._key)&&e.push(n)})}return e}catch{return[]}},isAnnotationActive:e=>{let t=rA({editorActorSnapshot:g.getSnapshot(),slateEditorInstance:k});return(0,p.kK)(e)(t)},addAnnotation:(e,t)=>{let n=rA({editorActorSnapshot:g.getSnapshot(),slateEditorInstance:k}),r=(0,p.lN)(n),o=(0,p.d2)(n),a=r.flatMap(e=>(0,d.zS)(n.context,e)?e.markDefs??[]:[]);g.send({type:"behavior event",behaviorEvent:{type:"annotation.add",annotation:{name:e.name,value:t??{}}},editor:k});let i=rA({editorActorSnapshot:g.getSnapshot(),slateEditorInstance:k}),l=(0,p.lN)(i),s=(0,p.gU)(i),c=(0,p.d2)(i),u=c?.node.marks?.filter(e=>!o?.node.marks?.includes(e)&&!i.context.schema.decorators.map(e=>e.name).includes(e)),h=l.flatMap(e=>(0,d.zS)(i.context,e)?e.markDefs?.map(t=>({markDef:t,path:[{_key:e._key},"markDefs",{_key:t._key}]}))??[]:[]).filter(e=>!a.some(t=>t._key===e.markDef._key)),f=c?.path,y=h.find(e=>u?.some(t=>t===e.markDef._key));if(s&&f&&y)return{markDefPath:y.path,markDefPaths:h.map(e=>e.path),spanPath:f}},delete:(e,t)=>{e&&g.send({type:"behavior event",behaviorEvent:{type:"delete",at:e,unit:t?.mode==="blocks"?"block":t?.mode==="children"?"child":void 0},editor:k})},removeAnnotation:e=>{g.send({type:"behavior event",behaviorEvent:{type:"annotation.remove",annotation:{name:e.name}},editor:k})},getSelection:()=>{if(!k.selection)return null;if(k.selection===k.lastSlateSelection)return k.lastSelection;let e=e5({schema:g.getSnapshot().context.schema,editor:k,range:k.selection});return k.lastSlateSelection=k.selection,k.lastSelection=e,e},getValue:()=>k.children,isCollapsedSelection:()=>!!k.selection&&eB(k.selection),isExpandedSelection:()=>!!k.selection&&eD(k.selection),insertBreak:()=>{g.send({type:"behavior event",behaviorEvent:{type:"insert.break"},editor:k})},getFragment:()=>{let e=rA({editorActorSnapshot:g.getSnapshot(),slateEditorInstance:k});return(0,p.lN)(e)},isSelectionsOverlapping:(e,t)=>{let n=te({context:{schema:g.getSnapshot().context.schema,value:k.children,selection:e},blockIndexMap:k.blockIndexMap}),r=te({context:{schema:g.getSnapshot().context.schema,value:k.children,selection:t},blockIndexMap:k.blockIndexMap});return en(n)&&en(r)&&rx(n,r)}},{mutationActor:C,syncActor:B}=(o={editorActor:g,relayActor:v,slateEditor:k,subscriptions:m},P.setup("creating new actors"),f=(0,x.c)(i6,{input:{readOnly:o.editorActor.getSnapshot().matches({"edit mode":"read only"}),schema:o.editorActor.getSnapshot().context.schema,slateEditor:o.slateEditor}}),y=(0,x.c)(lr,{input:{initialValue:o.editorActor.getSnapshot().context.initialValue,keyGenerator:o.editorActor.getSnapshot().context.keyGenerator,readOnly:o.editorActor.getSnapshot().matches({"edit mode":"read only"}),schema:o.editorActor.getSnapshot().context.schema,slateEditor:o.slateEditor}}),o.subscriptions.push(()=>{let e=f.on("*",e=>{"mutation"===e.type&&o.editorActor.send({type:"mutation",patches:e.patches,value:e.snapshot}),"patch"===e.type&&o.relayActor.send(e)});return()=>{f.send({type:"emit changes"}),e.unsubscribe()}}),o.subscriptions.push(()=>{let e=y.on("*",e=>{switch(e.type){case"invalid value":case"value changed":o.relayActor.send(e);break;case"patch":o.editorActor.send({...e,type:"internal.patch",value:o.slateEditor.children});break;default:o.editorActor.send(e)}});return()=>{e.unsubscribe()}}),o.subscriptions.push(()=>{let e=o.editorActor.subscribe(e=>{e.matches({"edit mode":"read only"})?(f.send({type:"update readOnly",readOnly:!0}),y.send({type:"update readOnly",readOnly:!0})):(f.send({type:"update readOnly",readOnly:!1}),y.send({type:"update readOnly",readOnly:!1}))});return()=>{e.unsubscribe()}}),o.subscriptions.push(()=>{let e=o.editorActor.on("*",e=>{switch(e.type){case"editable":case"mutation":case"ready":case"read only":case"selection":o.relayActor.send(e);break;case"internal.patch":f.send({...e,type:"patch"})}});return()=>{e.unsubscribe()}}),{mutationActor:f,syncActor:y}),E={dom:aV(e=>g.send(e),k),getSnapshot:()=>rA({editorActorSnapshot:g.getSnapshot(),slateEditorInstance:k}),registerBehavior:e=>{let t=r1({name:"custom",reference:{priority:r2,importance:"higher"}}),n={...e,priority:t};return g.send({type:"add behavior",behaviorConfig:n}),()=>{g.send({type:"remove behavior",behaviorConfig:n})}},send:e=>{switch(e.type){case"update value":B.send(e);break;case"update readOnly":case"patches":g.send(e);break;default:g.send(i7({event:e,slateEditor:k}))}},on:(e,t)=>v.on(e,e=>{switch(e.type){case"blurred":case"done loading":case"editable":case"focused":case"invali
20d value":case"loading":case"mutation":case"patch":case"read only":case"ready":case"selection":case"value changed":t(e)}}),_internal:{editable:b,editorActor:g,slateEditor:k}};return{actors:{editorActor:g,mutationActor:C,relayActor:v,syncActor:B},editor:E,subscriptions:m}}(e.initialConfig),n=new ls({editor:t.editor});return{internalEditor:t,portableTextEditor:n}},y[0]=e.initialConfig,y[1]=t):t=y[1];let[m]=(0,c.useState)(t),{internalEditor:g,portableTextEditor:v}=m;return y[2]!==g.actors.editorActor||y[3]!==g.actors.mutationActor||y[4]!==g.actors.relayActor||y[5]!==g.actors.syncActor||y[6]!==g.editor._internal.slateEditor||y[7]!==g.subscriptions?(n=()=>{let e=[];for(let t of g.subscriptions)e.push(t());return g.actors.editorActor.start(),g.actors.editorActor.send({type:"add slate editor",editor:g.editor._internal.slateEditor}),g.actors.mutationActor.start(),g.actors.relayActor.start(),g.actors.syncActor.start(),()=>{for(let t of e)t();oc(g.actors.editorActor),oc(g.actors.mutationActor),oc(g.actors.relayActor),oc(g.actors.syncActor)}},y[2]=g.actors.editorActor,y[3]=g.actors.mutationActor,y[4]=g.actors.relayActor,y[5]=g.actors.syncActor,y[6]=g.editor._internal.slateEditor,y[7]=g.subscriptions,y[8]=n):n=y[8],y[9]!==g?(r=[g],y[9]=g,y[10]=r):r=y[10],(0,c.useEffect)(n,r),y[11]!==v||y[12]!==e.children?(o=(0,i.jsx)(r4.Provider,{value:v,children:e.children}),y[11]=v,y[12]=e.children,y[13]=o):o=y[13],y[14]!==g.editor._internal.slateEditor||y[15]!==o?(a=(0,i.jsx)(ou,{editor:g.editor._internal.slateEditor,children:o}),y[14]=g.editor._internal.slateEditor,y[15]=o,y[16]=a):a=y[16],y[17]!==g.actors.relayActor||y[18]!==a?(s=(0,i.jsx)(rE.Provider,{value:g.actors.relayActor,children:a}),y[17]=g.actors.relayActor,y[18]=a,y[19]=s):s=y[19],y[20]!==g.actors.editorActor||y[21]!==s?(u=(0,i.jsx)(ro.Provider,{value:g.actors.editorActor,children:s}),y[20]=g.actors.editorActor,y[21]=s,y[22]=u):u=y[22],y[23]!==g.editor||y[24]!==u?(f=(0,i.jsx)(A.p.Provider,{value:g.editor,children:u}),y[23]=g.editor,y[24]=u,y[25]=f):f=y[25],f}let lu=()=>{let e,t,n,r=(0,l.c)(5),o=(0,c.useContext)(ro);r[0]!==o?(e=o.getSnapshot(),r[0]=o,r[1]=e):e=r[1];let[a,i]=(0,c.useState)(e.context.selection);return r[2]!==o?(t=()=>{let e=o.on("selection",e=>{(0,c.startTransition)(()=>{i(e.selection)})});return()=>{e.unsubscribe()}},n=[o],r[2]=o,r[3]=t,r[4]=n):(t=r[3],n=r[4]),(0,c.useEffect)(t,n),a}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.