1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2903b473-8cfc-48a8-9286-1dd837d524a7",e._sentryDebugIdIdentifier="sentry-dbid-2903b473-8cfc-48a8-9286-1dd837d524a7")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4398],{75725:(e,t,n)=>{n.d(t,{LF:()=>eW,Og:()=>oE,pq:()=>oB,v$:()=>eG,zz:()=>oS});var o=n(95155),i=n(11748),r=n(31061),a=n(12115),l=n(63941),s=n(13227),c=n(64681),d=n(60392),p=n(3283),u=n(3254),h=n(91550),f=n(3318),y=n(19273),g=n(40609),m=n(15770),k=n(80032),v=n(61206),b=n(57433),x=n(84258),_=n(1180),E=n(77765),w=n(69254),S=n(70421),B=n(4159),K=n(79998),O=n(70469),A=n(31536);let T="sanity-pte:";function N(e){let t=`${T}${e}`;return c&&c.enabled(t)?c(t):c(T)}function D(e,t,n){if(!t||!n)return t===n;if(t.length!==n.length)return!1;for(let o=0;o<t.length;o++){let i=t.at(o),r=n.at(o);if(!i||!r||!P(e,i,r))return!1}return!0}function P(e,t,n){var o,i,r,a,l;return t._type===n._type&&(t._type===e.schema.block.name&&n._type===e.schema.block.name?(o=e,i=t,r=n,!!(0,u.zS)(o,i)&&!!(0,u.zS)(o,r)&&i._key===r._key&&i.style===r.style&&i.listItem===r.listItem&&i.level===r.level&&(!("markDefs"in i)||!("markDefs"in r)||!!Array.isArray(i.markDefs)&&!!Array.isArray(r.markDefs)&&!!I(i.markDefs,r.markDefs))&&!!M(i.children,r.children)&&j(i,r,["_key","_type","style","listItem","level","markDefs","children"])):(a=t,l=n,a._key===l._key&&a._type===l._type&&j(a,l,["_key","_type"])))}function j(e,t,n){let o=Object.keys(e).filter(e=>!n.includes(e)),i=Object.keys(t).filter(e=>!n.includes(e));if(o.length!==i.length)return!1;for(let n of o){if(!(n in e)||!(n in t))return!1;let o=e[n],i=t[n];if(o!==i&&!R(o,i))return!1}return!0}function C(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 I(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let o=e.at(n),i=t.at(n);if(!o||!i||!R(o,i))return!1}return!0}function M(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let o=e.at(n),i=t.at(n);if(!o||!i||!z(o,i))return!1}return!0}function z(e,t){return"span"===e._type&&"span"===t._type?e._key===t._key&&e._type===t._type&&e.text===t.text&&!!C(e.marks,t.marks)&&j(e,t,["_key","_type","text","marks"]):e._key===t._key&&e._type===t._type&&j(e,t,["_key","_type"])}c(T);function R(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,o=t;if(n.length!==o.length)return!1;for(let[e,t]of n.entries())if(!R(t,o[e]))return!1;return!0}if(e instanceof Map){var i=e,r=t;if(i.size!==r.size)return!1;for(let[e,t]of i.entries())if(!r.has(e)||!R(t,r.get(e)))return!1;return!0}if(e instanceof Set){var a=e,l=t;if(a.size!==l.size)return!1;let n=[...l];for(let e of a){let t=!1;for(let[o,i]of n.entries())if(R(e,i)){t=!0,n.splice(o,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,o]of Object.entries(e))if(!(n in t)||!R(o,t[n]))return!1;return!0}let $="void-child";function L(e,{schemaTypes:t}){let{_type:n,_key:o,...i}=e;if(e&&e._type===t.block.name){let r=!1,a=typeof e.markDefs>"u",s=typeof e.children>"u",c=(e.children||[]).map(e=>{let{_type:n,_key:o,...i}=e,a=Object.keys(i);return void 0===n&&1===a.length&&"text"===a.at(0)?{_key:o,_type:t.span.name,text:i.text}:n!==t.span.name?(r=!0,{_type:n,_key:o,children:[{_key:$,_type:t.span.name,text:"",marks:[]}],value:i,__inline:!0}):e});return!a&&!s&&!r&&l.Hg.isElement(e)?e:{_type:n,_key:o,...i,children:c}}return{_type:n,_key:o,children:[{_key:$,_type:"span",text:"",marks:[]}],value:i}}function V(e,t){let{_key:n,_type:o}=e;if(!n||!o)throw Error("Not a valid block");if(o===t&&"children"in e&&Array.isArray(e.children)&&n){let t=!1,i=e.children.map(e=>{let{_type:n}=e;if("value"in e&&"span"!==n){t=!0;let{value:n,_key:o,_type:i,__inline:r,children:a,...l}=e;
1return{...l,...n,_key:o,_type:i}}return e});return t?{...e,children:i,_key:n,_type:o}:e}let i="value"in e&&e.value;return{_key:n,_type:o,..."object"==typeof i?i:{}}}function U(e,t,n){if(!t||1!==t.length)return!1;let o=t.at(0);if(!o)return!0;if(!l.Hg.isElement(o)||o._type!==n.block.name||"listItem"in o||!("style"in o)||o.style!==n.styles.at(0)?.name||!Array.isArray(o.children)||1!==o.children.length)return!1;let i=o.children.at(0);return!(!i||!l.EY.isText(i)||!("_type"in i)||i._type!==n.span.name||""!==i.text||i.marks?.join("")||Object.keys(o).some(e=>"_type"!==e&&"_key"!==e&&"children"!==e&&"markDefs"!==e&&"style"!==e)||D({schema:n},e,[o]))}function G({editor:e}){if(!e.selection)return[void 0,void 0];try{return l.KE.node(e,e.selection.focus.path.slice(0,1))??[void 0,void 0]}catch{return[void 0,void 0]}}function H({editor:e}){if(!e.selection)return[void 0,void 0];try{let[t]=G({editor:e});if(!t||!e.isTextBlock(t))return[void 0,void 0];let[n,o]=l.KE.node(e,e.selection.focus.path.slice(0,2));if(e.isTextSpan(n))return[n,o]}catch{}return[void 0,void 0]}function Q({editor:e,point:t}){try{let[n]=l.KE.node(e,t.path.slice(0,1))??[void 0,void 0];return n?[n,t.path.slice(0,1)]:[void 0,void 0]}catch{return[void 0,void 0]}}function F({editor:e,point:t}){let[n,o]=Q({editor:e,point:t}),i=t.path.at(1);if(!n||!o||void 0===i)return[void 0,void 0];try{let e=l.bP.child(n,i);return e?[e,[...o,i]]:[void 0,void 0]}catch{return[void 0,void 0]}}function J({schema:e,element:t}){return V(t,e.block.name)}function Y({editor:e,schema:t},n){return l.Hg.isElement(n)&&!e.isInline(n)&&(t.block.name===n._type||t.blockObjects.some(e=>e.name===n._type))}function W({schema:e,editor:t,range:n}){let[o]=Q({editor:t,point:n.anchor}),[i]=Q({editor:t,point:n.focus});if(!o||!i)return null;let[r]=o._type===e.block.name?F({editor:t,point:n.anchor}):[void 0,void 0],[a]=i._type===e.block.name?F({editor:t,point:n.focus}):[void 0,void 0],s={anchor:{path:[{_key:o._key}],offset:n.anchor.offset},focus:{path:[{_key:i._key}],offset:n.focus.offset},backward:l.Q6.isBackward(n)};return r&&(s.anchor.path.push("children"),s.anchor.path.push({_key:r._key})),a&&(s.focus.path.push("children"),s.focus.path.push({_key:a._key})),s}function q({schema:e,editor:t,point:n}){let[o]=Q({editor:t,point:n});if(!o)return;let[i]=o._type===e.block.name?F({editor:t,point:n}):[void 0,void 0];return i?{path:[{_key:o._key},"children",{_key:i._key}],offset:n.offset}:{path:[{_key:o._key}],offset:n.offset}}function Z({editorActor:e,slateEditor:t,event:n}){if(e.getSnapshot().matches({setup:"setting up"}))return;let o=function({slateEditor:e,event:t}){let n;if(d.wE.hasTarget(e,t.target)){try{n=d.wE.toSlateNode(e,t.target)}catch(e){console.error(e)}return n}}({slateEditor:t,event:n});if(!o)return;let i=function({editor:e,schema:t,node:n}){if(l.KE.isEditor(n))return;if(Y({editor:e,schema:t},n))return J({schema:t,element:n});let o=Array.from(l.KE.nodes(e,{mode:"highest",at:[],match:o=>Y({editor:e,schema:t},o)&&o.children.some(e=>e._key===n._key)})).at(0)?.at(0);return l.Hg.isElement(o)?J({schema:t,element:o}):void 0}({editor:t,schema:e.getSnapshot().context.schema,node:o}),r=function({node:e,slateEditor:t,event:n}){let o,i,r,[a]=function({editor:e}){if(0===e.children.length)return[void 0,void 0];let t=l.KE.start(e,[]).path.at(0);try{return void 0!==t?l.KE.node(e,[t])??[void 0,void 0]:[void 0,void 0]}catch{return[void 0,void 0]}}({editor:t});if(!a)return;try{o=d.wE.toDOMNode(t,a)}catch(e){console.error(e)}if(!o)return;let s=o.getBoundingClientRect();if(n.pageY<s.top)return"start";let[c]=function({editor:e}){if(0===e.children.length)return[void 0,void 0];let t=l.KE.end(e,[]).path.at(0);try{return void 0!==t?l.KE.node(e,[t])??[void 0,void 0]:[void 0,void 0]}catch{return[void 0,void 0]}}({editor:t});if(!c)return;try{i=d.wE.toDOMNode(t,c)}catch(e){console.error(e)}if(!i)return;let p=i.getBoundingClientRect();if(n.pageY>p.bottom)return"end";try{r=d.wE.toDOMNode(t,e)}catch(e){console.error(e)}if(!r)return;let u=r.getBoundingClientRect(),h=u.top,f=u.height;return Math.abs(h-n.pageY)<f/2?"start":"end"}({node:o,slateEditor:t,event:n}),a=function({schema:e,slateEditor:t,event:n}){let o=function(e,t){let n,o;
1if(!t.target||!(0,d.vA)(t.target))return;let i=d.wE.getWindow(e);if(void 0!==i.document.caretPositionFromPoint){let e=i.document.caretPositionFromPoint(t.clientX,t.clientY);if(e)try{(n=i.document.createRange()).setStart(e.offsetNode,e.offset),n.setEnd(e.offsetNode,e.offset)}catch{}}else{if(void 0===i.document.caretRangeFromPoint)return void console.warn("Neither caretPositionFromPoint nor caretRangeFromPoint is supported");n=i.document.caretRangeFromPoint(t.clientX,t.clientY)??void 0}if(n){try{o=d.wE.toSlateRange(e,n,{exactMatch:!1,suppressThrow:!1})}catch{}return o}}(t,n);return o?W({schema:e,editor:t,range:o}):null}({schema:e.getSnapshot().context.schema,slateEditor:t,event:n});if(i&&r&&!a&&!l.KE.isEditor(o))return{block:r,isEditor:!1,selection:{anchor:(0,p.u3)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}}),focus:(0,p.J8)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}})}};if(!r||!a)return;let s=(0,p.XE)(a.focus);if(void 0!==s)return(0,p.WV)(a)&&i&&s!==i._key?{block:r,isEditor:!1,selection:{anchor:(0,p.u3)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}}),focus:(0,p.J8)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}})}}:{block:r,isEditor:l.KE.isEditor(o),selection:a}}function X(e,t){if(!e||!t)return null;let n=[],o=e.offset||0,i="object"==typeof e.path[0]&&"_key"in e.path[0]&&e.path[0]._key,r="object"==typeof e.path[2]&&"_key"in e.path[2]&&e.path[2]._key,a=t.find(e=>e._key===i);if(!a)return null;if(n.push({_key:a._key}),a&&"children"===e.path[1]){if(!a.children||Array.isArray(a.children)&&0===a.children.length)return null;let t=Array.isArray(a.children)&&a.children.find(e=>e._key===r);if(!t)return null;n.push("children"),n.push({_key:t._key}),o=t.text&&t.text.length>=e.offset?e.offset:t.text&&t.text.length||0}return{path:n,offset:o}}function ee(e){if(!e.context.selection)return null;if((0,p._Q)(e.context.selection.anchor,e.context.selection.focus)){let t=et(e,e.context.selection.anchor,e.context.selection.backward?"backward":"forward");return t?{anchor:t,focus:t}:null}let t=et(e,e.context.selection.anchor,e.context.selection.backward?"forward":"backward"),n=et(e,e.context.selection.focus,e.context.selection.backward?"backward":"forward");return t&&n?{anchor:t,focus:n}:null}function et(e,t,n){let o=(0,p.XE)(t);if(!o)return;let i=e.blockIndexMap.get(o);if(void 0===i)return;let r=e.context.value.at(i);if(!r)return;if(!(0,u.zS)(e.context,r))return{path:[i,0],offset:0};let a=(0,p.qX)({path:t.path}),l=a?void 0:(0,p.m4)({context:{schema:e.context.schema,value:[r]},blockOffset:{path:[{_key:o}],offset:t.offset},direction:n});if(!(a=l?(0,p.qX)(l):a))return{path:[i,0],offset:0};let s=l?.offset??t.offset,c=[],d=-1,h;for(let t of r.children)if(d++,t._key===a){h=t,(0,u.bl)(e.context,t)?c=[d]:(c=[d,0],s=0);break}return 0===c.length?{path:[i,0],offset:0}:{path:[i].concat(c),offset:(0,u.bl)(e.context,h)?Math.min(h.text.length,s):s}}let en=(0,a.createContext)({}),eo=(0,f.mj)({types:{context:{},input:{},events:{}},actions:{"update pending range decorations":(0,y.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 o=ee({context:{schema:e.schema,value:e.slateEditor.value,selection:n.selection},blockIndexMap:e.slateEditor.blockIndexMap});if(!l.Q6.isRange(o)){n.onMoved?.({newSelection:null,rangeDecoration:n,origin:"local"});continue}t.push({rangeDecoration:n,...o})}e.slateEditor.decoratedRanges=t},"update range decorations":({context:e,event:t})=>{if("range decorations updated"!==t.type)return;let n=[];for(let o of t.rangeDecorations){let t=ee({context:{schema:e.schema,value:e.slateEditor.value,selection:o.selection},blockIndexMap:e.slateEditor.blockIndexMap});if(!l.Q6.isRange(t)){o.onMoved?.({newSelection:null,rangeDecoration:o,origin:"local"});continue}n.push({rangeDecoration:o,...t})}e.slateEditor.decoratedRanges=n},"move range decorations":({context:e,event:t})=>{if("slate operation"!==t.type)return;let n=[];for(let o of e.slateEditor.decoratedRanges){let i,r=ee({context:{schema:e.schema,value:e.slateEditor.value,selection:o.rangeDecoration.selection},blockIndexMap:e.slateEditor.blockIndexMap});if(!l.Q6.isRange(r)){o.rangeDecoration.onMoved?.({newSelection:null,rangeDecoration:o.rangeDecoration,origin:"local"});continue}if((i=function(e,t){let n=l.bR.transform(e.anchor,t),o=l.bR.transform(e.focus,t);return null===n||null===o?null:l.bR.equals(n,e.anchor)&&l.bR.equals(o,e.focus)?e:{anchor:n,focus:o}}(r,t.operation))&&i!==r||null===i&&r){let t=i?W({schema:e.schema,editor:e.slateEditor,range:i}):null;o.rangeDecoration.onMoved?.({newSelection:t,rangeDecoration:o.rangeDecoration,origin:"local"})}null!==i&&n.push({...i||r,rangeDecoration:{...o.rangeDecoration,selection:W({schema:e.schema,editor:e.slateEditor,range:i})}})}e.slateEditor.decoratedRanges=n},"assign readOnly":(0,y.a)({readOnly:({context:e,event:t})=>"update read only"!==t.type?e.readOnly:t.readOnly}),"update decorate":(0,y.a)({decorate:({context:e})=>({fn:ei(e.schema,e.slateEditor)})})},actors:{"slate operation listener":(0,g.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&&!R(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})=>
1({readOnly:e.readOnly,pendingRangeDecorations:e.rangeDecorations,decoratedRanges:[],skipSetup:e.skipSetup,schema:e.schema,slateEditor:e.slateEditor,decorate:{fn:ei(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,m.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,m.j)(["has range decorations","not read only"])}}},"moving range decorations":{entry:["move range decorations"],always:{target:"idle"}}}}}});function ei(e,t){return function([n,o]){let i=e.styles.at(0)?.name;if(1===t.value.length&&(0,h.wm)({schema:e},t.value[0])&&(!t.value[0].style||t.value[0].style===i)&&!t.value[0].listItem)return[{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0},placeholder:!0}];if(0===o.length||!l.Hg.isElement(n)||0===n.children.length)return[];let r=o.at(0);return void 0===r?[]:t.decoratedRanges.filter(e=>l.Q6.isCollapsed(e)?n.children.some((t,n)=>l.wA.equals(e.anchor.path,[r,n])&&l.wA.equals(e.focus.path,[r,n])):l.Q6.intersection(e,{anchor:{path:o,offset:0},focus:{path:o,offset:0}})||l.Q6.includes(e,o))}}let er=(0,a.createContext)({});function ea(e){let t,n,r=(0,i.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,o.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 el(e){let t,n,r=(0,i.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,o.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 es(){let e,t=(0,i.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,o.jsx)("div",{contentEditable:!1,className:"pt-drop-indicator",style:{position:"absolute",width:"100%",height:1,borderBottom:"1px solid currentColor",zIndex:5},children:(0,o.jsx)("span",{})}),t[0]=e):e=t[0],e}function ec(e){return{id:(0,p.OL)(),name:e?.name,reference:e?.reference}}let ed=ec({name:"core"});function ep({eventSelection:e,snapshot:t}){let n=e;if((0,v.Rt)({...t,context:{...t.context,selection:e}}))return n;let o=(0,v.WV)({context:{...t.context,selection:e}}),i=(0,v.hH)({...t,context:{...t.context,selection:e}}),r=(0,v.d2)({...t,context:{...t.context,selection:e}});o&&i&&r&&(n={anchor:(0,p.u3)({context:t.context,block:i}),focus:(0,p.J8)({context:t.context,block:i})});let a=(0,v.wx)(t);if(t.context.selection&&(0,v.gR)(t)&&a.length>1){let o=(0,v.GB)(t),i=(0,v.P$)(t);if(!o||!i)return n;let r=(0,p.u3)({context:t.context,block:o}),a=(0,p.J8)({context:t.context,block:i});(0,v.Q)(e)({...t,context:{...t.context,selection:{anchor:r,focus:a}}})&&(n={anchor:r,focus:a})}return n}function eu(e){let t,n,o=(0,i.c)(5),{key:r,onSetDragPositionBlock:l}=e,s=(0,a.useContext)(en);o[0]!==s||o[1]!==r||o[2]!==l?(t=()=>{let e=function({key:e,onSetDragPositionBlock:t}){return[{behavior:(0,b.Ke)({on:"drag.dragover",guard:({snapshot:t,event:n})=>{let o=(0,v.gU)({...t,context:{...t.context,selection:n.position.selection}});if(!o||o.node._key!==e)return!1;let i=n.dragOrigin;if(!i)return!1;let r=ep({eventSelection:i.selection,snapshot:t});return!(0,v.wx)({...t,context:{...t.context,selection:r}}).some(t=>t.node._key===e)&&(0,v.iE)({...t,context:{...t.context,selection:r}})},actions:[({event:e})=>[{type:"effect",effect:()=>{t(e.position.block)}}]]}),priority:ec({reference:{priority:ed,importance:"lower"}})},{behavior:(0,b.Ke)({on:"drag.*",guard:({event:e})=>"drag.dragover"!==e.type,actions:[({event:e})=>[{type:"effect",effect:()=>{t(void 0)}},(0,b.sY)(e)]]}),priority:ec({reference:{priority:ed,importance:"lower"}})}]}({key:r,onSetDragPositionBlock:l});for(let t of e)s.send({type:"add behavior",behaviorConfig:t});return()=>{for(let t of e)s.send({type:"remove behavior",behaviorConfig:t})}},n=[s,r,l],o[0]=s,o[1]=r,o[2]=l,o[3]=t,o[4]=n):(t=o[3],n=o[4]),(0,a.useEffect)(t,n)}function eh(e){let t,n,r,c,d,p,u,h,f,y=(0,i.c)(35),[g,m]=(0,a.useState)(),k=(0,a.useRef)(null),v=(0,s.f7)();y[0]!==v?(t=e=>v&&null!==e.selection&&l.Q6.isCollapsed(e.selection),y[0]=v,y[1]=t):t=y[1];let b=(0,s.s1)(t);if(y[2]!==e.element._key?(n={key:e.element._key,onSetDragPositionBlock:m},y[2]=e.element._key,y[3]=n):n=y[3],eu(n),y[4]!==e.element._type||y[5]!==e.legacySchema.blockObjects){let t;y[7]!==e.element._type?(t=t=>
1t.name===e.element._type,y[7]=e.element._type,y[8]=t):t=y[8],r=e.legacySchema.blockObjects.find(t),y[4]=e.element._type,y[5]=e.legacySchema.blockObjects,y[6]=r}else r=y[6];let x=r;x||console.error(`Unable to find Block Object "${e.element._type}" in Schema`),y[9]!==e.blockObject||y[10]!==e.element._key||y[11]!==e.element._type?(c=e.blockObject??{_key:e.element._key,_type:e.element._type},y[9]=e.blockObject,y[10]=e.element._key,y[11]=e.element._type,y[12]=c):c=y[12];let _=c;y[13]!==g?(d="start"===g?(0,o.jsx)(es,{}):null,y[13]=g,y[14]=d):d=y[14];let E=!e.readOnly;return y[15]!==_||y[16]!==b||y[17]!==x||y[18]!==e.element._key||y[19]!==e.renderBlock||y[20]!==v?(p=e.renderBlock&&x?(0,o.jsx)(ef,{renderBlock:e.renderBlock,editorElementRef:k,focused:b,path:[{_key:e.element._key}],schemaType:x,selected:v,type:x,value:_,children:(0,o.jsx)(ea,{blockObject:_})}):(0,o.jsx)(ea,{blockObject:_}),y[15]=_,y[16]=b,y[17]=x,y[18]=e.element._key,y[19]=e.renderBlock,y[20]=v,y[21]=p):p=y[21],y[22]!==E||y[23]!==p?(u=(0,o.jsx)("div",{ref:k,contentEditable:!1,draggable:E,children:p}),y[22]=E,y[23]=p,y[24]=u):u=y[24],y[25]!==g?(h="end"===g?(0,o.jsx)(es,{}):null,y[25]=g,y[26]=h):h=y[26],y[27]!==e.attributes||y[28]!==e.children||y[29]!==e.element._key||y[30]!==e.element._type||y[31]!==d||y[32]!==u||y[33]!==h?(f=(0,o.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:[d,e.children,u,h]}),y[27]=e.attributes,y[28]=e.children,y[29]=e.element._key,y[30]=e.element._type,y[31]=d,y[32]=u,y[33]=h,y[34]=f):f=y[34],f}function ef({renderBlock:e,children:t,editorElementRef:n,focused:o,path:i,schemaType:r,selected:a,type:l,value:s}){return e({children:t,editorElementRef:n,focused:o,path:i,schemaType:r,selected:a,type:l,value:s})}function ey(e){let t,n,r,c,p,u,h,f,y=(0,i.c)(32),g=(0,a.useRef)(null),m=(0,s.RV)(),k=(0,s.f7)();y[0]!==k?(t=e=>k&&null!==e.selection&&l.Q6.isCollapsed(e.selection),y[0]=k,y[1]=t):t=y[1];let v=(0,s.s1)(t);if(y[2]!==e.element._type||y[3]!==e.legacySchema.inlineObjects){let t;y[5]!==e.element._type?(t=t=>t.name===e.element._type,y[5]=e.element._type,y[6]=t):t=y[6],n=e.legacySchema.inlineObjects.find(t),y[2]=e.element._type,y[3]=e.legacySchema.inlineObjects,y[4]=n}else n=y[4];let b=n;if(b||console.error(`Unable to find Inline Object "${e.element._type}" in Schema`),y[7]!==e.element||y[8]!==m){let t=d.wE.findPath(m,e.element);r=Q({editor:m,point:{path:t,offset:0}}),y[7]=e.element,y[8]=m,y[9]=r}else r=y[9];let[x]=r;x||console.error(`Unable to find parent block of inline object ${e.element._key}`),y[10]!==e.element?(c="value"in e.element&&"object"==typeof e.element.value?e.element.value:{},y[10]=e.element,y[11]=c):c=y[11],y[12]!==e.element._key||y[13]!==e.element._type||y[14]!==c?(p={_key:e.element._key,_type:e.element._type,...c},y[12]=e.element._key,y[13]=e.element._type,y[14]=c,y[15]=p):p=y[15];let _=p,E=!e.readOnly;return y[16]===Symbol.for("react.memo_cache_sentinel")?(u={display:"inline-block"},y[16]=u):u=y[16],y[17]!==x||y[18]!==v||y[19]!==_||y[20]!==b||y[21]!==e.element._key||y[22]!==e.renderChild||y[23]!==k?(h=(0,o.jsx)("span",{ref:g,style:u,children:e.renderChild&&x&&b?(0,o.jsx)(eg,{renderChild:e.renderChild,annotations:[],editorElementRef:g,selected:k,focused:v,path:[{_key:x._key},"children",{_key:e.element._key}],schemaType:b,value:_,type:b,children:(0,o.jsx)(el,{inlineObject:_})}):(0,o.jsx)(el,{inlineObject:_})}),y[17]=x,y[18]=v,y[19]=_,y[20]=b,y[21]=e.element._key,y[22]=e.renderChild,y[23]=k,y[24]=h):h=y[24],y[25]!==_._key||y[26]!==_._type||y[27]!==e.attributes||y[28]!==e.children||y[29]!==E||y[30]!==h?(f=(0,o.jsxs)("span",{...e.attributes,draggable:E,className:"pt-inline-object","data-child-key":_._key,"data-child-name":_._type,"data-child-type":"object",children:[e.children,h]}),y[25]=_._key,y[26]=_._type,y[27]=e.attributes,y[28]=e.children,y[29]=E,y[30]=h,y[31]=f):f=y[31],f}function eg({renderChild:e,annotations:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s,type:c}){return e({annotations:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s,type:c})}
1function em(e){let t,n,r,c,d,p,u,h,f,y,g,m,k,v,b,x=(0,i.c)(77),[_,E]=(0,a.useState)(),w=(0,a.useRef)(null),S=(0,s.f7)();x[0]!==S?(t=e=>S&&null!==e.selection&&l.Q6.isCollapsed(e.selection),x[0]=S,x[1]=t):t=x[1];let B=(0,s.s1)(t);x[2]!==e.element._key?(n={key:e.element._key,onSetDragPositionBlock:E},x[2]=e.element._key,x[3]=n):n=x[3],eu(n),x[4]!==e.textBlock._key?(r=t=>t.listIndexMap.get(e.textBlock._key),x[4]=e.textBlock._key,x[5]=r):r=x[5];let K=(0,s.s1)(r),O=e.children;if(e.renderStyle&&e.textBlock.style){let t;x[6]!==e.legacySchema||x[7]!==e.textBlock.style?(t=void 0!==e.textBlock.style?e.legacySchema.styles.find(t=>t.value===e.textBlock.style):void 0,x[6]=e.legacySchema,x[7]=e.textBlock.style,x[8]=t):t=x[8];let n=t;if(n){let t,i;x[9]!==e.textBlock._key?(t=[{_key:e.textBlock._key}],x[9]=e.textBlock._key,x[10]=t):t=x[10],x[11]!==O||x[12]!==B||x[13]!==n||x[14]!==e.renderStyle||x[15]!==e.textBlock||x[16]!==S||x[17]!==t?(i=(0,o.jsx)(eb,{renderStyle:e.renderStyle,block:e.textBlock,editorElementRef:w,focused:B,path:t,schemaType:n,selected:S,value:e.textBlock.style,children:O}),x[11]=O,x[12]=B,x[13]=n,x[14]=e.renderStyle,x[15]=e.textBlock,x[16]=S,x[17]=t,x[18]=i):i=x[18],O=i}else console.error(`Unable to find Schema type for text block style ${e.textBlock.style}`)}if(e.renderListItem&&e.textBlock.listItem){let t;if(x[19]!==e.legacySchema.lists||x[20]!==e.textBlock.listItem){let n;x[22]!==e.textBlock.listItem?(n=t=>t.value===e.textBlock.listItem,x[22]=e.textBlock.listItem,x[23]=n):n=x[23],t=e.legacySchema.lists.find(n),x[19]=e.legacySchema.lists,x[20]=e.textBlock.listItem,x[21]=t}else t=x[21];let n=t;if(n){let t,i,r=e.textBlock.level??1;x[24]!==e.textBlock._key?(t=[{_key:e.textBlock._key}],x[24]=e.textBlock._key,x[25]=t):t=x[25],x[26]!==O||x[27]!==B||x[28]!==n||x[29]!==e.renderListItem||x[30]!==e.textBlock||x[31]!==S||x[32]!==r||x[33]!==t?(i=(0,o.jsx)(ev,{renderListItem:e.renderListItem,block:e.textBlock,editorElementRef:w,focused:B,level:r,path:t,selected:S,value:e.textBlock.listItem,schemaType:n,children:O}),x[26]=O,x[27]=B,x[28]=n,x[29]=e.renderListItem,x[30]=e.textBlock,x[31]=S,x[32]=r,x[33]=t,x[34]=i):i=x[34],O=i}else console.error(`Unable to find Schema type for text block list item ${e.textBlock.listItem}`)}let A=e.attributes;x[35]!==e.textBlock.style?(c=e.textBlock.style?[`pt-text-block-style-${e.textBlock.style}`]:[],x[35]=e.textBlock.style,x[36]=c):c=x[36],x[37]!==e.textBlock.level||x[38]!==e.textBlock.listItem?(d=e.textBlock.listItem?["pt-list-item",`pt-list-item-${e.textBlock.listItem}`,`pt-list-item-level-${e.textBlock.level??1}`]:[],x[37]=e.textBlock.level,x[38]=e.textBlock.listItem,x[39]=d):d=x[39],x[40]!==c||x[41]!==d?(p=["pt-block","pt-text-block",...c,...d],x[40]=c,x[41]=d,x[42]=p):p=x[42];let T=p.join(" ");return x[43]!==e.textBlock.listItem?(u=void 0!==e.textBlock.listItem?{"data-list-item":e.textBlock.listItem}:{},x[43]=e.textBlock.listItem,x[44]=u):u=x[44],x[45]!==e.textBlock.level?(h=void 0!==e.textBlock.level?{"data-level":e.textBlock.level}:{},x[45]=e.textBlock.level,x[46]=h):h=x[46],x[47]!==e.textBlock.style?(f=void 0!==e.textBlock.style?{"data-style":e.textBlock.style}:{},x[47]=e.textBlock.style,x[48]=f):f=x[48],x[49]!==K?(y=void 0!==K?{"data-list-index":K}:{},x[49]=K,x[50]=y):y=x[50],x[51]!==_?(g="start"===_?(0,o.jsx)(es,{}):null,x[51]=_,x[52]=g):g=x[52],x[53]!==O||x[54]!==B||x[55]!==e.legacySchema||x[56]!==e.renderBlock||x[57]!==e.textBlock||x[58]!==S?(m=e.renderBlock?(0,o.jsx)(ek,{renderBlock:e.renderBlock,editorElementRef:w,focused:B,level:e.textBlock.level,listItem:e.textBlock.listItem,path:[{_key:e.textBlock._key}],selected:S,schemaType:e.legacySchema.block,style:e.textBlock.style,type:e.legacySchema.block,value:e.textBlock,children:O}):O,x[53]=O,x[54]=B,x[55]=e.legacySchema,x[56]=e.renderBlock,x[57]=e.textBlock,x[58]=S,x[59]=m):m=x[59],x[60]!==m?(k=(0,o.jsx)("div",{ref:w,children:m}),x[60]=m,x[61]=k):k=x[61],x[62]!==_?(v="end"===_?(0,o.jsx)(es,{}):null,x[62]=_,x[63]=v):v=x[63],x[64]!==e.attributes||x[65]!==e.spellCheck||x[66]!==e.textBlock._key||x[67]!==e.textBlock._type||x[68]!==f||x[69]!==y||x[70]!==g||x[71]!==k||x[72]!==v||x[73]!==T||x[74]!==u||x[75]!==h?(b=(0,o.jsxs)("div",{...A,className:T,spellCheck:e.spellCheck,"data-block-key":e.textBlock._key,"data-block-name":e.textBlock._type,"data-block-type":"text",...u,...h,...f,...y,children:[g,k,v]}),x[64]=e.attributes,x[65]=e.spellCheck,x[66]=e.textBlock._key,x[67]=e.textBlock._type,x[68]=f,x[69]=y,x[70]=g,x[71]=k,x[72]=v,x[73]=T,x[74]=u,x[75]=h,x[76]=b):b=x[76],b}function ek({renderBlock:e,children:t,editorElementRef:n,focused:o,level:i,listItem:r,path:a,selected:l,style:s,schemaType:c,type:d,value:p}){return e({children:t,editorElementRef:n,focused:o,level:i,listItem:r,path:a,selected:l,style:s,schemaType:c,type:d,value:p})}function ev({renderListItem:e,block:t,children:n,editorElementRef:o,focused:i,level:r,path:a,schemaType:l,selected:s,value:c}){return e({block:t,children:n,editorElementRef:o,focused:i,level:r,path:a,schemaType:l,selected:s,value:c})}
1function eb({renderStyle:e,block:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s}){return e({block:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s})}function ex(e){let t,n,l,c=(0,i.c)(34),d=(0,a.useContext)(en),p=(0,r.d4)(d,eE),h=(0,r.d4)(d,e_),f=(0,s.RV)();if("__inline"in e.element&&!0===e.element.__inline){let t;return c[0]!==h||c[1]!==e.attributes||c[2]!==e.children||c[3]!==e.element||c[4]!==e.readOnly||c[5]!==e.renderChild||c[6]!==p?(t=(0,o.jsx)(ey,{attributes:e.attributes,element:e.element,legacySchema:h,readOnly:e.readOnly,renderChild:e.renderChild,schema:p,children:e.children}),c[0]=h,c[1]=e.attributes,c[2]=e.children,c[3]=e.element,c[4]=e.readOnly,c[5]=e.renderChild,c[6]=p,c[7]=t):t=c[7],t}if(c[8]!==e.element._key||c[9]!==p||c[10]!==f.blockIndexMap||c[11]!==f.value){let o=f.blockIndexMap.get(e.element._key);t=void 0!==o?f.value.at(o):void 0,n=(0,u.zS)({schema:p},t),c[8]=e.element._key,c[9]=p,c[10]=f.blockIndexMap,c[11]=f.value,c[12]=t,c[13]=n}else t=c[12],n=c[13];if(n){let n;return c[14]!==t||c[15]!==h||c[16]!==e.attributes||c[17]!==e.children||c[18]!==e.element||c[19]!==e.readOnly||c[20]!==e.renderBlock||c[21]!==e.renderListItem||c[22]!==e.renderStyle||c[23]!==e.spellCheck?(n=(0,o.jsx)(em,{attributes:e.attributes,element:e.element,legacySchema:h,readOnly:e.readOnly,renderBlock:e.renderBlock,renderListItem:e.renderListItem,renderStyle:e.renderStyle,spellCheck:e.spellCheck,textBlock:t,children:e.children}),c[14]=t,c[15]=h,c[16]=e.attributes,c[17]=e.children,c[18]=e.element,c[19]=e.readOnly,c[20]=e.renderBlock,c[21]=e.renderListItem,c[22]=e.renderStyle,c[23]=e.spellCheck,c[24]=n):n=c[24],n}return c[25]!==t||c[26]!==h||c[27]!==e.attributes||c[28]!==e.children||c[29]!==e.element||c[30]!==e.readOnly||c[31]!==e.renderBlock||c[32]!==p?(l=(0,o.jsx)(eh,{attributes:e.attributes,blockObject:t,element:e.element,legacySchema:h,readOnly:e.readOnly,renderBlock:e.renderBlock,schema:p,children:e.children}),c[25]=t,c[26]=h,c[27]=e.attributes,c[28]=e.children,c[29]=e.element,c[30]=e.readOnly,c[31]=e.renderBlock,c[32]=p,c[33]=l):l=c[33],l}function e_(e){return e.context.getLegacySchema()}function eE(e){return e.context.schema}function ew({editorActorSnapshot:e,slateEditorInstance:t}){let n=t.selection?W({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.value},decoratorState:t.decoratorState}}function eS(e){let t,n,l,c,d,p,h=(0,i.c)(40),f=(0,s.RV)(),y=(0,a.useContext)(en),g=(0,r.d4)(y,eK),m=(0,a.useRef)(null);h[0]!==e.leaf._key||h[1]!==f?(t=t=>{let n=ew({editorActorSnapshot:t,slateEditorInstance:f});if(!n.context.selection||!(0,v.WV)(n))return!1;let o=(0,v.d2)(n);return!!o&&o.node._key===e.leaf._key},h[0]=e.leaf._key,h[1]=f,h[2]=t):t=h[2];let k=(0,r.d4)(y,t);h[3]!==e.children.props.parent||h[4]!==e.leaf._key||h[5]!==e.leaf.text||h[6]!==f?(n=t=>{let n=ew({editorActorSnapshot:t,slateEditorInstance:f});if(!n.context.selection)return!1;let o=e.children.props.parent,i=o&&(0,u.zS)(n.context,o)?o:void 0,r=i?{anchor:{path:[{_key:i._key},"children",{_key:e.leaf._key}],offset:0},focus:{path:[{_key:i._key},"children",{_key:e.leaf._key}],offset:e.leaf.text.length}}:null;return(0,v.Q)(r)(n)},h[3]=e.children.props.parent,h[4]=e.leaf._key,h[5]=e.leaf.text,h[6]=f,h[7]=n):n=h[7];let b=(0,r.d4)(y,n),x=e.children.props.parent,_=x&&f.isTextBlock(x)?x:void 0;h[8]!==_||h[9]!==e.leaf._key?(l=_?[{_key:_._key},"children",{_key:e.leaf._key}]:void 0,h[8]=_,h[9]=e.leaf._key,h[10]=l):l=h[10];let E=l;if(h[11]!==_||h[12]!==y||h[13]!==k||h[14]!==g||h[15]!==E||h[16]!==e.children||h[17]!==e.leaf.marks||h[18]!==e.renderAnnotation||h[19]!==e.renderDecorator||h[20]!==b){let t=y.getSnapshot().context.schema.decorators.map(eB),n=[...new Set((e.leaf.marks??[]).filter(e=>t.includes(e)))];for(let i of(c=(e.leaf.marks??[]).flatMap(e=>{if(t.includes(e))return[];let n=_?.markDefs?.find(t=>t._key===e);return n?[n]:[]}),d=e.children,n)){let t=g.decorators.find(e=>e.value===i);E&&t&&e.renderDecorator&&(d=(0,o.jsx)(eA,{renderDecorator:e.renderDecorator,editorElementRef:m,focused:k,path:E,selected:b,schemaType:t,value:i,type:t,children:d}))}for(let t of c){let n=g.annotations.find(e=>e.name===t._type);n&&(d=_&&E&&e.renderAnnotation?(0,o.jsx)("span",{ref:m,children:(0,o.jsx)(eO,{renderAnnotation:e.renderAnnotation,block:_,editorElementRef:m,focused:k,path:E,selected:b,schemaType:n,value:t,type:n,children:d})}):(0,o.jsx)("span",{ref:m,children:d}))}h[11]=_,h[12]=y,h[13]=k,h[14]=g,h[15]=E,h[16]=e.children,h[17]=e.leaf.marks,h[18]=e.renderAnnotation,h[19]=e.renderDecorator,h[20]=b,h[21]=c,h[22]=d}else c=h[21],d=h[22];if(_&&E&&e.renderChild){let t;if(h[23]!==_.children||h[24]!==e.leaf){let n;h[26]!==e.leaf?(n=t=>t._key===e.leaf._key,h[26]=e.leaf,h[27]=n):n=h[27],t=_.children.find(n),h[23]=_.children,h[24]=e.leaf,h[25]=t}else t=h[25];let n=t;if(n){let t;h[28]!==c||h[29]!==n||h[30]!==d||h[31]!==k||h[32]!==g.span||h[33]!==E||h[34]!==e.renderChild||h[35]!==b?(t=(0,o.jsx)(eT,{renderChild:e.renderChild,annotations:c,editorElementRef:m,focused:k,path:E,schemaType:g.span,selected:b,value:n,type:g.span,children:d}),h[28]=c,h[29]=n,h[30]=d,h[31]=k,h[32]=g.span,h[33]=E,h[34]=e.renderChild,h[35]=b,h[36]=t):t=h[36],d=t}}return h[37]!==d||h[38]!==e.attributes?(p=(0,o.jsx)("span",{...e.attributes,ref:m,children:d}),h[37]=d,h[38]=e.attributes,h[39]=p):p=h[39],p}function eB(e){return e.name}function eK(e){return e.context.getLegacySchema()}function eO({renderAnnotation:e,block:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s,type:c}){return e({block:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s,type:c})}function eA({renderDecorator:e,children:t,editorElementRef:n,focused:o,path:i,schemaType:r,selected:a,value:l,type:s}){return e({children:t,editorElementRef:n,focused:o,path:i,schemaType:r,selected:a,value:l,type:s})}function eT({renderChild:e,annotations:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s,type:c}){return e({annotations:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s,type:c})}let eN={position:"absolute",userSelect:"none",pointerEvents:"none",left:0,right:0};function eD(e){let t,n=(0,i.c)(12),l=(0,a.useContext)(en),s=(0,r.d4)(l,eP);if(e.leaf._type!==s.span.name)return e.children;n[0]!==e?(t=(0,o.jsx)(eS,{...e}),n[0]=e,n[1]=t):t=n[1];let c=t;if(e.renderPlaceholder&&e.leaf.placeholder&&""===e.text.text){let t,i,r;return n[2]!==e.renderPlaceholder?(t=e.renderPlaceholder(),n[2]=e.renderPlaceholder,n[3]=t):t=n[3],n[4]!==t?(i=(0,o.jsx)("span",{style:eN,contentEditable:!1,
1children:t}),n[4]=t,n[5]=i):i=n[5],n[6]!==c||n[7]!==i?(r=(0,o.jsxs)(o.Fragment,{children:[i,c]}),n[6]=c,n[7]=i,n[8]=r):r=n[8],r}let d=e.leaf.rangeDecoration;if(d){let e;n[9]!==d||n[10]!==c?(e=d.component({children:c}),n[9]=d,n[10]=c,n[11]=e):e=n[11],c=e}return c}function eP(e){return e.context.schema}function ej(e){let t,n=(0,i.c)(5);return n[0]!==e.attributes||n[1]!==e.children||n[2]!==e.text._key||n[3]!==e.text._type?(t=(0,o.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}let eC="u">typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent),eI={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},eM={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:eC?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},ez={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 eR(e){let t={altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1},n=e.replace("++","+add").split("+");for(let e of n){let o=e.endsWith("?")&&e.length>1,i=o?e.slice(0,-1):e,r=eL(i),a=eI[r],l=eM[i],s=ez[r];if(i.length>1&&void 0===a&&void 0===l&&void 0===s)throw TypeError(`Unknown modifier: "${i}"`);(1===n.length||void 0===a)&&(t.key=r,t.keyCode=function(e){let t=eL(e);return ez[t]??t.toUpperCase().charCodeAt(0)}(i)),void 0!==a&&(t[a]=!o||null)}return t}function e$(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
1yCode&&void 0!==t.keyCode?91===e.keyCode&&93===t.keyCode||e.keyCode===t.keyCode:e.keyCode===t.keyCode||e.key===t.key.toLowerCase())}function eL(e){let t=e.toLowerCase();return eM[t]??t}let eV=N("plugin:withHotKeys"),eU=(0,a.createContext)(null),eG=()=>{let e=(0,a.useContext)(eU);if(!e)throw Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");return e},eH=N("validate selection machine"),eQ=(0,f.mj)({types:{context:{},input:{},events:{}},guards:{"pending operations":({context:e})=>e.slateEditor.operations.length>0}}),eF=eQ.createAction(({context:e,event:t})=>{!function(e,t){let n;if(!e.selection)return;try{n=s.rL.findDocumentOrShadowRoot(e)}catch{}if(!n||t!==n.activeElement)return;let o=s.rL.getWindow(e).getSelection();if(!o||0===o.rangeCount)return;let i=o.getRangeAt(0);try{let t=s.rL.toDOMRange(e,e.selection);(t.startOffset!==i.startOffset||t.endOffset!==i.endOffset)&&(eH("DOM range out of sync, validating selection"),o?.removeAllRanges(),o.addRange(t))}catch{eH("Could not resolve selection, selecting top document"),l.gB.deselect(e),e.children.length>0&&l.gB.select(e,l.KE.start(e,[])),e.onChange()}}(e.slateEditor,t.editorElement)}),eJ=eQ.createMachine({id:"validate selection",context:({input:e})=>({slateEditor:e.slateEditor}),initial:"idle",states:{idle:{on:{"validate selection":[{guard:"pending operations",target:"waiting"},{actions:[eF],target:"idle"}]}},waiting:{after:{0:[{guard:"pending operations",target:".",reenter:!0},{target:"idle",actions:[eF]}]},on:{"validate selection":{target:".",reenter:!0}}}}}),eY=N("component:Editable"),eW=(0,a.forwardRef)(function(e,t){let n,c,d,u,f,y,g,m,k,v,b,x,_,E,w,S,B,K,O,A,T,N,D,P,j,C,I,M,z,R,$,L,V,U,G,H,Q,F,J,Y,q,et,ei,ea,el,es,ec,ed,ep,eu,eh,ef,ey,eg,em,ek,ev,eb,e_,eE,ew,eS,eB,eK,eO=(0,i.c)(176);eO[0]!==e?({hotkeys:n,onBlur:d,onFocus:E,onBeforeInput:c,onPaste:w,onCopy:f,onCut:y,onClick:u,onDragStart:x,onDrag:g,onDragEnd:m,onDragEnter:k,onDragOver:b,onDrop:_,onDragLeave:v,rangeDecorations:B,renderAnnotation:K,renderBlock:O,renderChild:A,renderDecorator:T,renderListItem:N,renderPlaceholder:D,renderStyle:P,selection:S,scrollSelectionIntoView:C,spellCheck:I,...j}=e,eO[0]=e,eO[1]=n,eO[2]=c,eO[3]=d,eO[4]=u,eO[5]=f,eO[6]=y,eO[7]=g,eO[8]=m,eO[9]=k,eO[10]=v,eO[11]=b,eO[12]=x,eO[13]=_,eO[14]=E,eO[15]=w,eO[16]=S,eO[17]=B,eO[18]=K,eO[19]=O,eO[20]=A,eO[21]=T,eO[22]=N,eO[23]=D,eO[24]=P,eO[25]=j,eO[26]=C,eO[27]=I):(n=eO[1],c=eO[2],d=eO[3],u=eO[4],f=eO[5],y=eO[6],g=eO[7],m=eO[8],k=eO[9],v=eO[10],b=eO[11],x=eO[12],_=eO[13],E=eO[14],w=eO[15],S=eO[16],B=eO[17],K=eO[18],O=eO[19],A=eO[20],T=eO[21],N=eO[22],D=eO[23],P=eO[24],j=eO[25],C=eO[26],I=eO[27]);let eA=eG(),[eT,eN]=(0,a.useState)(!1),eP=(0,a.useContext)(en),ej=(0,a.useContext)(er),eC=(0,r.d4)(eP,eZ),eI=(0,s.Zi)();eO[28]!==eI?(M={input:{slateEditor:eI}},eO[28]=eI,eO[29]=M):M=eO[29];let eM=(0,r.qf)(eJ,M);eO[30]!==B?(z=B??[],eO[30]=B,eO[31]=z):z=eO[31],eO[32]!==eP?(R=eP.getSnapshot(),eO[32]=eP,eO[33]=R):R=eO[33];let ez=R.context.schema;eO[34]!==eP?($=eP.getSnapshot().matches({setup:"setting up"}),eO[34]=eP,eO[35]=$):$=eO[35];let eL=!$;eO[36]!==eC||eO[37]!==eI||eO[38]!==z||eO[39]!==R.context.schema||eO[40]!==eL?(L={input:{rangeDecorations:z,readOnly:eC,schema:ez,slateEditor:eI,skipSetup:eL}},eO[36]=eC,eO[37]=eI,eO[38]=z,eO[39]=R.context.schema,eO[40]=eL,eO[41]=L):L=eO[41];let eU=(0,r.qf)(eo,L),eH=(0,r.d4)(eU,eX);eO[42]!==eU||eO[43]!==eC?(V=()=>{eU.send({type:"update read only",readOnly:eC})},U=[eU,eC],eO[42]=eU,eO[43]=eC,eO[44]=V,eO[45]=U):(V=eO[44],U=eO[45]),(0,a.useEffect)(V,U),eO[46]!==B||eO[47]!==eU?(H=()=>{eU.send({type:"range decorations updated",rangeDecorations:B??[]})},G=[eU,B],eO[46]=B,eO[47]=eU,eO[48]=G,eO[49]=H):(G=eO[48],H=eO[49]),(0,a.useEffect)(H,G),eC||(function(e,t,n){let o=["enter","tab","shift","delete","end"],i=n??{};return function(n){return n.pteWithHotKeys=r=>
1{Object.keys(i).forEach(a=>{var l,s;if("marks"===a)for(let t in i[a]){if(o.includes(t))throw Error(`The hotkey ${t} is reserved!`);if(l=r.nativeEvent,e$(eR(t),l)){r.preventDefault();let o=i[a];if(o){let i=o[t];eV(`HotKey ${t} to toggle ${i}`),e.send({type:"behavior event",behaviorEvent:{type:"decorator.toggle",decorator:i},editor:n})}}}if("custom"===a)for(let e in i[a]){if(o.includes(e))throw Error(`The hotkey ${e} is reserved!`);if(s=r.nativeEvent,e$(eR(e),s)){let n=i[a];n&&(0,n[e])(r,t)}}})},n}})(eP,eA,n)(eI),eO[50]!==eC||eO[51]!==O||eO[52]!==A||eO[53]!==N||eO[54]!==P||eO[55]!==I?(Q=e=>(0,o.jsx)(ex,{...e,readOnly:eC,renderBlock:O,renderChild:A,renderListItem:N,renderStyle:P,spellCheck:I}),eO[50]=eC,eO[51]=O,eO[52]=A,eO[53]=N,eO[54]=P,eO[55]=I,eO[56]=Q):Q=eO[56];let eQ=Q;eO[57]!==eC||eO[58]!==K||eO[59]!==A||eO[60]!==T||eO[61]!==D?(F=e=>(0,o.jsx)(eD,{...e,readOnly:eC,renderAnnotation:K,renderChild:A,renderDecorator:T,renderPlaceholder:D}),eO[57]=eC,eO[58]=K,eO[59]=A,eO[60]=T,eO[61]=D,eO[62]=F):F=eO[62];let eF=F;eO[63]!==eP||eO[64]!==S||eO[65]!==eI?(J=()=>{if(S){eY(`Selection from props ${JSON.stringify(S)}`);let e=function(e,t){if(!e||!t||0===t.length)return null;let n=null,o=null,{anchor:i,focus:r}=e;return i&&t.find(e=>(0,p.wE)(i.path[0])&&e._key===i.path[0]._key)&&(n=X(i,t)),r&&t.find(e=>(0,p.wE)(r.path[0])&&e._key===r.path[0]._key)&&(o=X(r,t)),n&&o?{anchor:n,focus:o,backward:e.backward}:null}(S,eI.value);if(null!==e){eY(`Normalized selection from props ${JSON.stringify(e)}`);let t=ee({context:{schema:eP.getSnapshot().context.schema,value:eI.value,selection:e},blockIndexMap:eI.blockIndexMap});t&&(l.gB.select(eI,t),eI.operations.some(e1)||eP.send({type:"update selection",selection:e}),eI.onChange())}}},eO[63]=eP,eO[64]=S,eO[65]=eI,eO[66]=J):J=eO[66];let eW=J;eO[67]!==eP||eO[68]!==eU||eO[69]!==eW?(Y=()=>{let e=eP.on("ready",()=>{eU.send({type:"ready"}),eW()}),t=eP.on("invalid value",()=>{eN(!0)}),n=eP.on("value changed",()=>{eN(!1)});return()=>{e.unsubscribe(),t.unsubscribe(),n.unsubscribe()}},q=[eU,eP,eW],eO[67]=eP,eO[68]=eU,eO[69]=eW,eO[70]=Y,eO[71]=q):(Y=eO[70],q=eO[71]),(0,a.useEffect)(Y,q),eO[72]!==eT||eO[73]!==S||eO[74]!==eW?(et=()=>{S&&!eT&&eW()},ei=[eT,S,eW],eO[72]=eT,eO[73]=S,eO[74]=eW,eO[75]=et,eO[76]=ei):(et=eO[75],ei=eO[76]),(0,a.useEffect)(et,ei),eO[77]!==eP||eO[78]!==f||eO[79]!==eI?(ea=e=>{if(f)void 0!==f(e)&&e.preventDefault();else if(e.nativeEvent.clipboardData){e.stopPropagation(),e.preventDefault();let t=eI.selection?W({schema:eP.getSnapshot().context.schema,editor:eI,range:eI.selection}):void 0,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for copy event");eP.send({type:"behavior event",behaviorEvent:{type:"clipboard.copy",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:eI,nativeEvent:e})}},eO[77]=eP,eO[78]=f,eO[79]=eI,eO[80]=ea):ea=eO[80];let e3=ea;eO[81]!==eP||eO[82]!==y||eO[83]!==eI?(el=e=>{if(y)void 0!==y(e)&&e.preventDefault();else if(e.nativeEvent.clipboardData){e.stopPropagation(),e.preventDefault();let t=eP.getSnapshot().context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for cut event");eP.send({type:"behavior event",behaviorEvent:{type:"clipboard.cut",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:eI,nativeEvent:e})}},eO[81]=eP,eO[82]=y,eO[83]=eI,eO[84]=el):el=eO[84];let e4=el;eO[85]!==eP||eO[86]!==w||eO[87]!==eA||eO[88]!==ej||eO[89]!==eI?(es=e=>{let t=eI.value,n=(eI.selection?W({schema:eP.getSnapshot().context.schema,editor:eI,range:eI.selection}):null)?.focus.path||[],o=w?.({event:e,value:t,path:n,schemaTypes:eA.schemaTypes});if(o||!eI.selection)e.preventDefault(),ej.send({type:"loading"}),Promise.resolve(o).then(t=>{if(eY("Custom paste function from client resolved",t),t&&t.insert)t.insert?eP.send({type:"behavior event",behaviorEvent:{type:"insert.blocks",blocks:(0,p.SV)({context:{keyGenerator:eP.getSnapshot().context.keyGenerator,schema:eP.getSnapshot().context.schema},blocks:t.insert,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}}),placement:"auto"},editor:eI}):console.warn("Your onPaste function returned something unexpected:",t);else{eY("No result from custom paste handler, pasting normally");let t=eP.getSnapshot().context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for paste event");eP.send({type:"behavior event",behaviorEvent:{type:"clipboard.paste",originEvent:{dataTransfer:e.clipboardData},position:n},editor:eI,nativeEvent:e})}}).catch(e2).finally(()=>{ej.send({type:"done loading"})});else if(e.nativeEvent.clipboardData){e.preventDefault(),e.stopPropagation();let t=eP.getSnapshot().context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for paste event");eP.send({type:"behavior event",behaviorEvent:{type:"clipboard.paste",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:eI,nativeEvent:e})}eY("No result from custom paste handler, pasting normally")},eO[85]=eP,eO[86]=w,eO[87]=eA,eO[88]=ej,eO[89]=eI,eO[90]=es):es=eO[90];let e6=es;eO[91]!==eP||eO[92]!==E||eO[93]!==ej||eO[94]!==eI?(ec=e=>{E&&E(e),e.isDefaultPrevented()||(ej.send({type:"focused",event:e}),!eI.selection&&1===eI.children.length&&(0,h.wm)(eP.getSnapshot().context,eI.value.at(0))&&(l.gB.select(eI,l.KE.start(eI,[])),eI.onChange()))},eO[91]=eP,eO[92]=E,eO[93]=ej,eO[94]=eI,eO[95]=ec):ec=eO[95];let e8=ec;eO[96]!==eP||eO[97]!==u||eO[98]!==eI?(ed=e=>{if(u&&u(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=Z({editorActor:eP,slateEditor:eI,event:e.nativeEvent});t&&eP.send({type:"behavior event",behaviorEvent:{type:"mouse.click",position:t},editor:eI,nativeEvent:e})},eO[96]=eP,eO[97]=u,eO[98]=eI,eO[99]=ed):ed=eO[99];let e5=ed;eO[100]!==d||eO[101]!==ej?(ep=e=>{d&&d(e),e.isPropagationStopped()||ej.send({type:"blurred",event:e})},eO[100]=d,eO[101]=ej,eO[102]=ep):ep=eO[102];let e7=ep;eO[103]!==c?(eu=e=>{c&&c(e)},eO[103]=c,eO[104]=eu):eu=eO[104];let e9=eu;eO[105]!==eP||eO[106]!==e||eO[107]!==eI?(eh=t=>{e.onKeyDown&&e.onKeyDown(t),t.isDefaultPrevented()||eI.pteWithHotKeys(t),t.isDefaultPrevented()||eP.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:eI,nativeEvent:t})},eO[105]=eP,eO[106]=e,eO[107]=eI,eO[108]=eh):eh=eO[108];let te=eh;eO[109]!==eP||eO[110]!==e||eO[111]!==eI?(ef=t=>{e.onKeyUp&&e.onKeyUp(t),t.isDefaultPrevented()||eP.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:eI,nativeEvent:t})},eO[109]=eP,eO[110]=e,eO[111]=eI,eO[112]=ef):ef=eO[112];let tt=ef;e:{let e;if(void 0===C){ey=void 0;break e}if(null===C){ey=eq;break e}eO[113]!==eA||eO[114]!==C?(e=(e,t)=>{C(eA,t)},eO[113]=eA,eO[114]=C,eO[115]=e):e=eO[115],ey=e}let tn=ey;eO[116]!==eP||eO[117]!==eI?(eg=()=>{let e=s.rL.getWindow(eI),t=()=>{eP.send({type:"dragend"})},n=()=>{eP.send({type:"drop"})};return e.document.addEventListener("dragend",t),e.document.addEventListener("drop",n),()=>{e.document.removeEventListener("dragend",t),e.document.removeEventListener("drop",n)}},em=[eI,eP],eO[116]=eP,eO[117]=eI,eO[118]=eg,eO[119]=em):(eg=eO[118],em=eO[119]),(0,a.useEffect)(eg,em),eO[120]!==eP||eO[121]!==x||eO[122]!==eI?(ek=e=>{if(x?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=Z({editorActor:eP,slateEditor:eI,event:e.nativeEvent});return t?(eP.send({type:"dragstart",origin:t}),eP.send({type:"behavior event",behaviorEvent:{type:"drag.dragstart",originEvent:{clientX:e.clientX,clientY:e.clientY,dataTransfer:e.dataTransfer},position:t},editor:eI}),!0):void console.warn("Could not find position for dragstart event")},eO[120]=eP,eO[121]=x,eO[122]=eI,eO[123]=ek):ek=eO[123];let to=ek;eO[124]!==eP||eO[125]!==g||eO[126]!==eI?(ev=e=>{if(g?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()||!Z({editorActor:eP,slateEditor:eI,event:e.nativeEvent})))return eP.send({type:"behavior event",behaviorEvent:{type:"drag.drag",originEvent:{dataTransfer:e.dataTransfer}},editor:eI}),!0},eO[124]=eP,eO[125]=g,eO[126]=eI,eO[127]=ev):ev=eO[127];let ti=ev;eO[128]!==eP||eO[129]!==m||eO[130]!==eI?(eb=e=>{if(m?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()))return eP.send({type:"behavior event",behaviorEvent:{type:"drag.dragend",originEvent:{dataTransfer:e.dataTransfer}},editor:eI}),!0},eO[128]=eP,eO[129]=m,eO[130]=eI,eO[131]=eb):eb=eO[131];let tr=eb;eO[132]!==eP||eO[133]!==k||eO[134]!==eI?(e_=e=>{if(k?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=Z({editorActor:eP,slateEditor:eI,event:e.nativeEvent});if(t)return eP.send({type:"behavior event",behaviorEvent:{type:"drag.dragenter",originEvent:{dataTransfer:e.dataTransfer},position:t},editor:eI}),!0},eO[132]=eP,eO[133]=k,eO[134]=eI,eO[135]=e_):e_=eO[135];let ta=e_;eO[136]!==eP||eO[137]!==b||eO[138]!==eI?(eE=e=>{if(b?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=Z({editorActor:eP,slateEditor:eI,event:e.nativeEvent});if(t)return eP.send({type:"behavior event",behaviorEvent:{type:"drag.dragover",originEvent:{dataTransfer:e.dataTransfer}
1,dragOrigin:eP.getSnapshot().context.internalDrag?.origin,position:t},editor:eI,nativeEvent:e}),!0},eO[136]=eP,eO[137]=b,eO[138]=eI,eO[139]=eE):eE=eO[139];let tl=eE;eO[140]!==eP||eO[141]!==_||eO[142]!==eI?(ew=e=>{if(_?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=Z({editorActor:eP,slateEditor:eI,event:e.nativeEvent});return t?(eP.send({type:"behavior event",behaviorEvent:{type:"drag.drop",originEvent:{dataTransfer:e.dataTransfer},dragOrigin:eP.getSnapshot().context.internalDrag?.origin,position:t},editor:eI,nativeEvent:e}),!0):void console.warn("Could not find position for drop event")},eO[140]=eP,eO[141]=_,eO[142]=eI,eO[143]=ew):ew=eO[143];let ts=ew;eO[144]!==eP||eO[145]!==v||eO[146]!==eI?(eS=e=>{if(v?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()||!Z({editorActor:eP,slateEditor:eI,event:e.nativeEvent})))return eP.send({type:"behavior event",behaviorEvent:{type:"drag.dragleave",originEvent:{dataTransfer:e.dataTransfer}},editor:eI}),!0},eO[144]=eP,eO[145]=v,eO[146]=eI,eO[147]=eS):eS=eO[147];let tc=eS;eO[148]!==t||eO[149]!==eM?(eB=e=>{if("function"==typeof t?t(e):t&&(t.current=e),e){let t=new MutationObserver(()=>{eM.send({type:"validate selection",editorElement:e})});return t.observe(e,{attributeOldValue:!1,attributes:!1,characterData:!1,childList:!0,subtree:!0}),()=>{t.disconnect()}}},eO[148]=t,eO[149]=eM,eO[150]=eB):eB=eO[150];let td=eB;return eA?(eO[151]!==td||eO[152]!==eH||eO[153]!==e5||eO[154]!==e3||eO[155]!==e4||eO[156]!==ti||eO[157]!==tr||eO[158]!==ta||eO[159]!==tc||eO[160]!==tl||eO[161]!==to||eO[162]!==ts||eO[163]!==te||eO[164]!==tt||eO[165]!==e9||eO[166]!==e7||eO[167]!==e8||eO[168]!==e6||eO[169]!==eT||eO[170]!==eC||eO[171]!==eQ||eO[172]!==eF||eO[173]!==j||eO[174]!==tn?(eK=eT?null:(0,o.jsx)(s.Fo,{...j,ref:td,"data-read-only":eC,autoFocus:!1,className:j.className||"pt-editable",decorate:eH,onBlur:e7,onCopy:e3,onCut:e4,onClick:e5,onDOMBeforeInput:e9,onDragStart:to,onDrag:ti,onDragEnd:tr,onDragEnter:ta,onDragOver:tl,onDrop:ts,onDragLeave:tc,onFocus:e8,onKeyDown:te,onKeyUp:tt,onPaste:e6,readOnly:eC,renderPlaceholder:void 0,renderElement:eQ,renderLeaf:eF,renderText:e0,scrollSelectionIntoView:tn}),eO[151]=td,eO[152]=eH,eO[153]=e5,eO[154]=e3,eO[155]=e4,eO[156]=ti,eO[157]=tr,eO[158]=ta,eO[159]=tc,eO[160]=tl,eO[161]=to,eO[162]=ts,eO[163]=te,eO[164]=tt,eO[165]=e9,eO[166]=e7,eO[167]=e8,eO[168]=e6,eO[169]=eT,eO[170]=eC,eO[171]=eQ,eO[172]=eF,eO[173]=j,eO[174]=tn,eO[175]=eK):eK=eO[175],eK):null});function eq(){}function eZ(e){return e.matches({"edit mode":"read only"})}function eX(e){return e.context.decorate?.fn}function e0(e){return(0,o.jsx)(ej,{...e})}function e1(e){return"set_selection"===e.type}function e2(e){return console.warn(e),e}eW.displayName="ForwardRef(PortableTextEditable)";let e3=(e,t)=>{t(e);let n=e.getSnapshot().children;n&&Object.values(n).forEach(e=>{e3(e,t)})};function e4(e){let t=[];e3(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 e6={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"}}},e8={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,v.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:JSON.stringify(n),mimeType:"application/x-portable-text",originEvent:t.originEvent}},deserialize:({snapshot:e,event:t})=>{let n=JSON.parse(t.data);if(!Array.isArray(n))return{type:"deserialization.failure",mimeType:"application/x-portable-text",reason:"Data is not an array"};let o=n.flatMap(t=>{let n=(0,p.rT)({context:e.context,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return n?[n]:[]});return 0===o.length&&n.length>0?{type:"deserialization.failure",mimeType:"application/x-portable-text",reason:"No blocks were parsed"}:{type:"deserialization.success",data:o,mimeType:"application/x-portable-text"}}},e5={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,v.lN)(e);return{type:"serialization.success",data:(0,w.xk)(n),mimeType:"text/markdown",originEvent:t.originEvent}},deserialize:({snapshot:e,event:t})=>{let n=(0,w.XB)(t.data,{keyGenerator:e.context.keyGenerator,schema:e.context.schema}).flatMap(t=>{let n=(0,p.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
1serialized"}:{type:"deserialization.success",data:n,mimeType:"text/markdown"}}},e7={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},e9=new Map;function te(e,{blockIndexMap:t,listIndexMap:n}){let o;t.clear(),n.clear(),e9.clear();for(let i=0;i<e.value.length;i++){let r=e.value.at(i);if(void 0===r)continue;if(t.set(r._key,i),!(0,u.zS)(e,r)||void 0===r.listItem||void 0===r.level){e9.clear(),o=void 0;continue}if(!o||o.listItem===r.listItem&&o.level<r.level){let e=e9.get(r.listItem)??new Map;e.set(r.level,1),e9.set(r.listItem,e),n.set(r._key,1),o={listItem:r.listItem,level:r.level};continue}e9.forEach((e,t)=>{if(t===r.listItem)return;let n=[];e.forEach((e,t)=>{t>=r.level&&n.push(t)}),n.forEach(t=>{e.delete(t)})});let a=e9.get(r.listItem)??new Map,l=a.get(r.level)??0;a.set(r.level,l+1),e9.set(r.listItem,a),n.set(r._key,l+1),o={listItem:r.listItem,level:r.level}}}function tt(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 tn(e,t,n){let o=d.wE.toDOMRange(e,t).getBoundingClientRect(),i=d.wE.toDOMRange(e,n).getBoundingClientRect();return to(o,i)&&to(i,o)}function to(e,t){let n=(t.top+t.bottom)/2;return e.top<=n&&e.bottom>=n}function ti(e,t){let n=e.withHistory;e.withHistory=!1,t(),e.withHistory=n}function tr(e){let[t,n]=e;return[t,n]}function ta(e,t){let n=e,o=t,i=n.length,r=o.length;if(0===i||0===r)return 0;i>r?n=n.substring(i-r):i<r&&(o=o.substring(0,i));let a=Math.min(i,r);if(n===o)return a;let l=0,s=1;for(let e=0;-1!==e;){let t=n.substring(a-s);if(-1===(e=o.indexOf(t)))break;s+=e,(0===e||n.substring(a-s)===o.substring(0,s))&&(l=s,s++)}return l}function tl(e,t){if(!e||!t||e[0]!==t[0])return 0;let n=0,o=Math.min(e.length,t.length),i=o,r=0;for(;n<i;)e.substring(r,i)===t.substring(r,i)?r=n=i:o=i,i=Math.floor((o-n)/2+n);return i}function ts(e,t){if(!e||!t||e[e.length-1]!==t[t.length-1])return 0;let n=0,o=Math.min(e.length,t.length),i=o,r=0;for(;n<i;)e.substring(e.length-i,e.length-r)===t.substring(t.length-i,t.length-r)?r=n=i:o=i,i=Math.floor((o-n)/2+n);return i}function tc(e,t,n,o,i){let r=e.substring(0,n),a=t.substring(0,o),l=e.substring(n),s=t.substring(o),c=tm(r,a,{checkLines:!1,deadline:i}),d=tm(l,s,{checkLines:!1,deadline:i});return c.concat(d)}function td(e,t,n){let o=e.slice(n,n+Math.floor(e.length/4)),i=-1,r="",a,l,s,c;for(;-1!==(i=t.indexOf(o,i+1));){let o=tl(e.slice(n),t.slice(i)),d=ts(e.slice(0,n),t.slice(0,i));r.length<d+o&&(r=t.slice(i-d,i)+t.slice(i,i+o),a=e.slice(0,n-d),l=e.slice(n+o),s=t.slice(0,i-d),c=t.slice(i+o))}return 2*r.length>=e.length?[a||"",l||"",s||"",c||"",r||""]:null}var tp=Object.defineProperty,tu=Object.getOwnPropertySymbols,th=Object.prototype.hasOwnProperty,tf=Object.prototype.propertyIsEnumerable,ty=(e,t,n)=>t in e?tp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function tg(e,t,n){if(null===e||null===t)throw Error("Null input. (diff)");let o=tm(e,t,function(e){let t;var n,o={checkLines:!0,deadline:(n=e.timeout||1,t=1,"u">typeof n&&(t=n<=0?Number.MAX_VALUE:n),Date.now()+1e3*t)},i=e;for(var r in i||(i={}))th.call(i,r)&&ty(o,r,i[r]);if(tu)for(var r of tu(i))tf.call(i,r)&&ty(o,r,i[r]);return o}(n||{}));return function(e){for(let t=0;t<e.length;t++){let[n,o]=e[t];if(0===o.length)continue;let i=o[0];(function(e){let t=e.charCodeAt(0);return t>=55296&&t<=56319})(o[o.length-1])&&0===n&&tb(e,t,1),function(e){let t=e.charCodeAt(0);return t>=56320&&t<=57343}(i)&&0===n&&tb(e,t,-1)}for(let t=0;t<e.length;t++)0===e[t][1].length&&e.splice(t,1)}(o),o}function tm(e,t,n){let o=e,i=t;if(o===i)return o?[[0,o]]:[];let r=tl(o,i),a=o.substring(0,r);r=ts(o=o.substring(r),i=i.substring(r));let l=o.substring(o.length-r),s=function(e,t,n){let o;if(!e)return[[1,t]];if(!t)return[[-1,e]];let i=e.length>t.length?e:t,r=e.length>t.length?t:e,a=i.indexOf(r);if(-1!==a)return o=[[1,i.substring(0,a)],[0,r],[1,i.substring(a+r.length)]],e.length>t.length&&(o[0][0]=-1,o[2][0]=-1),o;if(1===r.length)return[[-1,e],[1,t]];let l=function(e,t,n=1){let o,i,r,a,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 d=td(s,c,Math.ceil(s.length/4)),p=td(s,c,Math.ceil(s.length/2));if(d&&p)o=d[4].length>p[4].length?d:p;else{if(!d&&!p)return null;p?d||(o=p):o=d}if(!o)throw Error("Unable to find a half match.");return e.length>t.length?(i=o[0],r=o[1],a=o[2],l=o[3]):(a=o[0],l=o[1],i=o[2],r=o[3]),[i,r,a,l,o[4]]}(e,t);if(l){let e=l[0],t=l[1],o=l[2],i=l[3],r=l[4],a=tm(e,o,n),s=tm(t,i,n);return a.concat([[0,r]],s)}return n.checkLines&&e.length>100&&t.length>100?function(e,t,n){let o=e,i=t,r=function(e,t){let n=[],o={};function i(e){let t="",i=0,a=-1,l=n.length;for(;a<e.length-1;){-1===(a=e.indexOf(`
2`,i))&&(a=e.length-1);let s=e.slice(i,a+1);(o.hasOwnProperty?o.hasOwnProperty(s):void 0!==o[s])?t+=String.fromCharCode(o[s]):(l===r&&(s=e.slice(i),a=e.length),t+=String.fromCharCode(l),o[s]=l,n[l++]=s),i=a+1}return t}n[0]="";let r=4e4,a=i(e);return r=65535,{chars1:a,chars2:i(t),lineArray:n}}(o,i);o=r.chars1,i=r.chars2;let a=r.lineArray,l=tm(o,i,{checkLines:!1,deadline:n.deadline});(function(e,t){for(let n=0;n<e.length;n++){let o=e[n][1],i=[];for(let e=0;e<o.length;e++)i[e]=t[o.charCodeAt(e)];e[n][1]=i.join("")}})(l,a),(l=function(e){let t=e.map(e=>tr(e)),n=!1,o=[],i=0,r=null,a=0,l=0,s=0,c=0,d=0;for(;a<t.length;)0===t[a][0]?(o[i++]=a,l=c,s=d,c=0,d=0,r=t[a][1]):(1===t[a][0]?c+=t[a][1].length:d+=t[a][1].length,r&&r.length<=Math.max(l,s)&&r.length<=Math.max(c,d)&&(t.splice(o[i-1],0,[-1,r]),t[o[i-1]+1][0]=1,i--,a=--i>0?o[i-1]:-1,l=0,s=0,c=0,d=0,r=null,n=!0)),a++;for(n&&(t=tK(t)),t=tB(t),a=1;a<t.length;){if(-1===t[a-1][0]&&1===t[a][0]){let e=t[a-1][1],n=t[a][1],o=ta(e,n),i=ta(n,e);o>=i?(o>=e.length/2||o>=n.length/2)&&(t.splice(a,0,[0,n.substring(0,o)]),t[a-1][1]=e.substring(0,e.length-o),t[a+1][1]=n.substring(o),a++):(i>=e.length/2||i>=n.length/2)&&(t.splice(a,0,[0,e.substring(0,i)]),t[a-1][0]=1,t[a-1][1]=n.substring(0,n.length-i),t[a+1][0]=-1,t[a+1][1]=e.substring(i),a++),a++}a++}return t}(l)).push([0,""]);let s=0,c=0,d=0,p="",u="";for(;s<l.length;){switch(l[s][0]){case 1:d++,u+=l[s][1];break;case -1:c++,p+=l[s][1];break;case 0:if(c>=1&&d>=1){l.splice(s-c-d,c+d),s=s-c-d;let e=tm(p,u,{checkLines:!1,deadline:n.deadline});for(let t=e.length-1;t>=0;t--)l.splice(s,0,e[t]);s+=e.length}d=0,c=0,p="",u="";break;default:throw Error("Unknown diff operation.")}s++}return l.pop(),l}(e,t,n):function(e,t,n){let o=e.length,i=t.length,r=Math.ceil((o+i)/2),a=2*r,l=Array(a),s=Array(a);for(let e=0;e<a;e++)l[e]=-1,s[e]=-1;l[r+1]=0,s[r+1]=0;let c=o-i,d=c%2!=0,p=0,u=0,h=0,f=0;for(let y=0;y<r&&!(Date.now()>n);y++){for(let h=-y+p;h<=y-u;h+=2){let f,g=r+h,m=(f=h===-y||h!==y&&l[g-1]<l[g+1]?l[g+1]:l[g-1]+1)-h;for(;f<o&&m<i&&e.charAt(f)===t.charAt(m);)f++,m++;if(l[g]=f,f>o)u+=2;else if(m>i)p+=2;else if(d){let i=r+c-h;if(i>=0&&i<a&&-1!==s[i]&&f>=o-s[i])return tc(e,t,f,m,n)}}for(let p=-y+h;p<=y-f;p+=2){let u,g=r+p,m=(u=p===-y||p!==y&&s[g-1]<s[g+1]?s[g+1]:s[g-1]+1)-p;for(;u<o&&m<i&&e.charAt(o-u-1)===t.charAt(i-m-1);)u++,m++;if(s[g]=u,u>o)f+=2;else if(m>i)h+=2;else if(!d){let i=r+c-p;if(i>=0&&i<a&&-1!==l[i]){let a=l[i],s=r+a-i;if(a>=(u=o-u))return tc(e,t,a,s,n)}}}}return[[-1,e],[1,t]]}(e,t,n.deadline)}(o=o.substring(0,o.length-r),i=i.substring(0,i.length-r),n);return a&&s.unshift([0,a]),l&&s.push([0,l]),s=tK(s)}function tk(e,t,n){return 1===n?e+t:t+e}function tv(e,t){return 1===t?[e.substring(0,e.length-1),e[e.length-1]]:[e.substring(1),e[0]]}function tb(e,t,n){var o,i;let r=1===n?-1:1,a=null,l=null,s=t+n;for(;s>=0&&s<e.length&&(null===a||null===l);s+=n){let[o,i]=e[s];if(0!==i.length){if(1===o){null===a&&(a=s);continue}else if(-1===o){null===l&&(l=s);continue}else if(0===o){if(null===a&&null===l){let[o,i]=tv(e[t][1],n);e[t][1]=o,e[s][1]=tk(e[s][1],i,r);return}break}}}if(null!==a&&null!==l&&(o=a,i=l,1===n?e[o][1][e[o][1].length-1]===e[i][1][e[i][1].length-1]:e[o][1][0]===e[i][1][0])){let[o,i]=tv(e[a][1],r),[s]=tv(e[l][1],r);e[a][1]=o,e[l][1]=s,e[t][1]=tk(e[t][1],i,n);return}let[c,d]=tv(e[t][1],n);e[t][1]=c,null===a?(e.splice(s,0,[1,d]),null!==l&&l>=s&&l++):e[a][1]=tk(e[a][1],d,r),null===l?e.splice(s,0,[-1,d]):e[l][1]=tk(e[l][1],d,r)}let tx=/[^a-zA-Z0-9]/,t_=/\s/,tE=/[\r\n]/,tw=/\n\r?\n$/,tS=/^\r?\n\r?\n/;function tB(e){let t=e.map(e=>tr(e));function n(e,t){if(!e||!t)return 6;let n=e.charAt(e.length-1),o=t.charAt(0),i=n.match(tx),r=o.match(tx),a=i&&n.match(t_),l=r&&o.match(t_),s=a&&n.match(tE),c=l&&o.match(tE),d=s&&e.match(tw),p=c&&t.match(tS);return d||p?5:s||c?4:i&&!a&&l?3:a||l?2:i||r?1:0}let o=1;for(;o<t.length-1;){if(0===t[o-1][0]&&0===t[o+1][0]){let e=t[o-1][1],i=t[o][1],r=t[o+1][1],a=ts(e,i);if(a){let t=i.substring(i.length-a);e=e.substring(0,e.length-a),i=t+i.substring(0,i.length-a),r=t+r}let l=e,s=i,c=r,d=n(e,i)+n(i,r);for(;i.charAt(0)===r.charAt(0);){e+=i.charAt(0),i=i.substring(1)+r.charAt(0),r=r.substring(1);let t=n(e,i)+n(i,r);t>=d&&(d=t,l=e,s=i,c=r)}t[o-1][1]!==l&&(l?t[o-1][1]=l:(t.splice(o-1,1),o--),t[o][1]=s,c?t[o+1][1]=c:(t.splice(o+1,1),o--))}o++}return t}function tK(e){let t=e.map(e=>tr(e));t.push([0,""]);let n=0,o=0,i=0,r="",a="",l;for(;n<t.length;)switch(t[n][0]){case 1:i++,a+=t[n][1],n++;break;case -1:o++,r+=t[n][1],n++;break;case 0:o+i>1?(0!==o&&0!==i&&(0!==(l=tl(a,r))&&(n-o-i>0&&0===t[n-o-i-1][0]?t[n-o-i-1][1]+=a.substring(0,l):(t.splice(0,0,[0,a.substring(0,l)]),n++),a=a.substring(l),r=r.substring(l)),0!==(l=ts(a,r))&&(t[n][1]=a.substring(a.length-l)+t[n][1],a=a.substring(0,a.length-l),r=r.substring(0,r.length-l))),n-=o+i,t.splice(n,o+i),r.length&&(t.splice(n,0,[-1,r]),n++),a.length&&(t.splice(n,0,[1,a]),n++),n++):0!==n&&0===t[n-1][0]?(t[n-1][1]+=t[n][1],t.splice(n,1)):n++,i=0,o=0,r="",a="";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=tK(t)),t}var tO=Object.defineProperty,tA=Object.getOwnPropertySymbols,tT=Object.prototype.hasOwnProperty,tN=Object.prototype.propertyIsEnumerable,tD=(e,t,n)=>t in e?tO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,tP=(e,t)=>{for(var n in t||(t={}))tT.call(t,n)&&tD(e,n,t[n]);if(tA)for(var n of tA(t))tN.call(t,n)&&tD(e,n,t[n]);return e};let tj={threshold:.5,distance:1e3};function tC(e,t,n,o={}){if(null===e||null===t||null===n)throw Error("Null input. (match())");let i=Math.max(0,Math.min(n,e.length));return e===t?0:e.length?e.substring(i,i+t.length)===t?i:function(e,t,n,o={}){if(t.length>32)throw Error("Pattern too long for this browser.");let i=tP(tP({},tj),o),r=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 a(e,o){let r=e/t.length,a=Math.abs(n-o);return i.distance?r+a/i.distance:a?1:r}let l=i.threshold,s=e.indexOf(t,n);-1!==s&&(l=Math.min(a(0,s),l),-1!==(s=e.lastIndexOf(t,n+t.length))&&(l=Math.min(a(0,s),l)));let c=1<<t.length-1;s=-1;let d,p,u=t.length+e.length,h=[];for(let o=0;o<t.length;o++){for(d=0,p=u;d<p;)a(o,n+p)<=l?d=p:u=p,p=Math.floor((u-d)/2+d);u=p;let i=Math.max(1,n-p+1),f=Math.min(n+p,e.length)+t.length,y=Array(f+2);y[f+1]=(1<<o)-1;for(let t=f;t>=i;t--){let d=r[e.charAt(t-1)];if(0===o?y[t]=(y[t+1]<<1|1)&d:y[t]=(y[t+1]<<1|1)&d|((h[t+1]|h[t])<<1|1)|h[t+1],y[t]&c){let e=a(o,t-1);if(e<=l)if(l=e,(s=t-1)>n)i=Math.max(1,2*n-s);else break}}if(a(o+1,n)>l)break;h=y}return s}(e,t,i,o):-1}function tI(e){let t=[];for(let n=0;n<e.length;n++)1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")}function tM(e){let t=[];for(let n=0;n<e.length;n++)-1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")}function tz(e,t){let n=0,o=0,i=0,r=0,a;for(a=0;a<e.length&&(1!==e[a][0]&&(n+=e[a][1].length),-1!==e[a][0]&&(o+=e[a][1].length),!(n>t));a++)i=n,r=o;return e.length!==a&&-1===e[a][0]?r:r+(t-i)}function tR(e){let t=0;for(let n=0;n<e.length;n++){let o=e.codePointAt(n);if(typeof o>"u")throw Error("Failed to get codepoint");t+=t$(o)}return t}function t$(e){return e<=127?1:e<=2047?2:e<=65535?3:4}function tL(e,t){return{diffs:[],start1:e,start2:t,utf8Start1:e,utf8Start2:t,length1:0,length2:0,utf8Length1:0,utf8Length2:0}}let tV=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;function tU(e){if(!e)return[];let t=[],n=e.split(` 3`),o=0;for(;o<n.length;){let e=n[o].match(tV);if(!e)throw Error(`Invalid patch string: ${n[o]}`);let i=tL(tG(e[1]),tG(e[3]));for(t.push(i),""===e[2]?(i.start1--,i.utf8Start1--,i.length1=1,i.utf8Length1=1):"0"===e[2]?(i.length1=0,i.utf8Length1=0):(i.start1--,i.utf8Start1--,i.utf8Length1=tG(e[2]),i.length1=i.utf8Length1),""===e[4]?(i.start2--,i.utf8Start2--,i.length2=1,i.utf8Length2=1):"0"===e[4]?(i.length2=0,i.utf8Length2=0):(i.start2--,i.utf8Start2--,i.utf8Length2=tG(e[4]),i.length2=i.utf8Length2),o++;o<n.length;){let e,t=n[o],r=t.charAt(0);if("@"===r)break;
3if(""===r){o++;continue}try{e=decodeURI(t.slice(1))}catch{throw Error(`Illegal escape in parse: ${t}`)}let a=tR(e)-e.length;if("-"===r)i.diffs.push([-1,e]),i.length1-=a;else if("+"===r)i.diffs.push([1,e]),i.length2-=a;else if(" "===r)i.diffs.push([0,e]),i.length1-=a,i.length2-=a;else throw Error(`Invalid patch mode "${r}" in: ${e}`);o++}}return t}function tG(e){return parseInt(e,10)}let tH=N("transformOperation");function tQ(e,t,n,o,i){let r={...n};if("insert"===t.type&&1===t.path.length){let e=t.path[0],n=(o||[]).findIndex(t=>(0,p.wE)(e)&&t._key===e._key);return tH(`Adjusting block path (+${t.items.length}) for '${r.type}' operation and patch '${t.type}'`),[tF(r,t.items.length,n)]}if("unset"===t.type&&1===t.path.length){let e=t.path[0],n=(i||[]).findIndex(t=>(0,p.wE)(e)&&t._key===e._key);return"path"in r&&Array.isArray(r.path)&&r.path[0]===n?(tH("Skipping transformation that targeted removed block"),[]):[tF(r,-1,n)]}if("unset"===t.type&&0===t.path.length)return tH(`Adjusting selection for unset everything patch and ${n.type} operation`),[];if("diffMatchPatch"===t.type){var a,l;let n,o=(a=e,"set_selection"===(l=r).type&&a.selection?n=a.children[a.selection.focus.path[0]]:"path"in l&&(n=a.children[l.path[0]]),n),i=t.path[0];return o&&(0,p.wE)(i)&&o._key===i._key&&tU(t.value).forEach(e=>{let t=0,n=e.utf8Start1,{diffs:o}=e;if(o.forEach((e,i)=>{let[r,a]=e;1===r?(t+=a.length,n+=a.length):-1===r?(t-=a.length,n-=a.length):0===r&&(o.slice(i).every(([e])=>0===e)||(n+=a.length))}),"insert_text"===r.type&&n<r.offset&&(r.offset+=t),"remove_text"===r.type&&n<=r.offset-r.text.length&&(r.offset+=t),"set_selection"===r.type){let e=r.properties?.focus?{...r.properties.focus}:void 0,o=r?.properties?.anchor?{...r.properties.anchor}:void 0,i=r?.newProperties?.focus?{...r.newProperties.focus}:void 0,a=r?.newProperties?.anchor?{...r.newProperties.anchor}:void 0;(e&&o||i&&a)&&([e,o,i,a].forEach(e=>{e&&n<e.offset&&(e.offset+=t)}),e&&o&&(r.properties={focus:e,anchor:o}),i&&a&&(r.newProperties={focus:i,anchor:a}))}}),[r]}return[r]}function tF(e,t,n){let o={...e};if(n>=0&&"set_selection"!==o.type&&Array.isArray(o.path)&&o.path[0]>=n+t&&o.path[0]+t>-1){let e=[o.path[0]+t,...o.path.slice(1)];o.path=e}if("set_selection"===o.type){let e=o.properties?.focus?{...o.properties.focus}:void 0,i=o?.properties?.anchor?{...o.properties.anchor}:void 0,r=o?.newProperties?.focus?{...o.newProperties.focus}:void 0,a=o?.newProperties?.anchor?{...o.newProperties.anchor}:void 0;(e&&i||r&&a)&&([e,i,r,a].forEach(e=>{e&&e.path[0]>=n+t&&e.path[0]+t>-1&&(e.path=[e.path[0]+t,...e.path.slice(1)])}),e&&i&&(o.properties={focus:e,anchor:i}),r&&a&&(o.newProperties={focus:r,anchor:a}))}return o}let tJ=N("behavior.operation.history.redo"),tY=N("behavior.operation.history.undo"),tW={"annotation.add":({context:e,operation:t})=>{let n=(0,p.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 ${JSON.stringify(t.annotation)}`);let o=t.editor;if(!o.selection||l.Q6.isCollapsed(o.selection))return;let i=l.KE.nodes(o,{at:o.selection,match:e=>o.isTextBlock(e),reverse:l.Q6.isBackward(o.selection)}),r=0;for(let[t,a]of i){if(0===t.children.length||1===t.children.length&&""===t.children[0].text)continue;let i=0===r?n._key:e.keyGenerator(),s=t.markDefs??[];for(let[e,t]of(void 0===s.find(e=>e._type===n._type&&e._key===i)&&l.gB.setNodes(o,{markDefs:[...s,{...n,_key:i}]},{at:a}),l.gB.setNodes(o,{},{match:l.EY.isText,split:!0}),l.bP.children(o,a))){if(!o.isTextSpan(e)||!l.Q6.includes(o.selection,t))continue;let n=e.marks??[];l.gB.setNodes(o,{marks:[...n,i]},{at:t})}r++}},"annotation.remove":({operation:e})=>{let t=e.editor;if(t.selection)if(l.Q6.isCollapsed(t.selection)){let[n,o]=l.KE.node(t,t.selection,{depth:1});if(!t.isTextBlock(n))return;let i=(n.markDefs??[]).filter(t=>t._type===e.annotation.name),[r,a]=l.KE.node(t,t.selection,{depth:2});if(!t.isTextSpan(r))return;let s=r.marks?.find(e=>i.some(t=>t._key===e));if(!s)return;let c=[];for(let[e,n]of l.bP.children(t,o,{reverse:!0}))if(t.isTextSpan(e)&&l.wA.isBefore(n,a))if(e.marks?.includes(s))c.push([e,n]);else break;let d=[];for(let[e,n]of l.bP.children(t,o))if(t.isTextSpan(e)&&l.wA.isAfter(n,a))if(e.marks?.includes(s))d.push([e,n]);else break;for(let[e,n]of[...c,[r,a],...d])l.gB.setNodes(t,{marks:e.marks?.f
3ilter(e=>e!==s)},{at:n})}else for(let[n,o]of(l.gB.setNodes(t,{},{match:e=>t.isTextSpan(e),split:!0,hanging:!0}),l.KE.nodes(t,{at:t.selection,match:e=>t.isTextBlock(e)})))for(let[i,r]of l.bP.children(t,o)){if(!t.isTextSpan(i)||!l.Q6.includes(t.selection,r))continue;let o=n.markDefs??[],a=i.marks??[],s=a.filter(t=>o.find(e=>e._key===t)?._type!==e.annotation.name);s.length!==a.length&&l.gB.setNodes(t,{marks:s},{at:r})}},"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 ${JSON.stringify(t.at)}`);let o=t.editor.children.at(n);if(!o)throw Error(`Unable to find block at ${JSON.stringify(t.at)}`);if((0,u.zS)(e,o)){let o={};for(let n of Object.keys(t.props))if("_type"!==n&&"children"!==n){if("style"===n){e.schema.styles.some(e=>e.name===t.props[n])&&(o[n]=t.props[n]);continue}if("listItem"===n){e.schema.lists.some(e=>e.name===t.props[n])&&(o[n]=t.props[n]);continue}if("level"===n){o[n]=t.props[n];continue}if("markDefs"===n){let{markDefs:i}=(0,p.Hj)({context:e,markDefs:t.props[n],options:{validateFields:!0}});o[n]=i;continue}e.schema.block.fields?.some(e=>e.name===n)&&(o[n]=t.props[n])}l.gB.setNodes(t.editor,o,{at:[n]})}else{let i=e.schema.blockObjects.find(e=>e.name===o._type),r={};for(let e of Object.keys(t.props))if("_type"!==e){if("_key"===e){r[e]=t.props[e];continue}i?.fields.some(t=>t.name===e)&&(r[e]=t.props[e])}let a=Object.entries(r).map(([e,t])=>"_key"===e?(0,B.hZ)(t,["_key"]):(0,B.hZ)(t,["value",e])),s=(0,B.yl)(o,a);l.gB.setNodes(t.editor,s,{at:[n]})}},"block.unset":({context:e,operation:t})=>{let n=t.at[0]._key,o=t.editor.blockIndexMap.get(n);if(void 0===o)throw Error(`Unable to find block index for block key ${n}`);let i=void 0!==o?t.editor.children.at(o):void 0;if(!i)throw Error(`Unable to find block at ${JSON.stringify(t.at)}`);if((0,u.zS)(e,i)){let n=t.props.filter(e=>"_type"!==e&&"_key"!==e&&"children"!==e);l.gB.unsetNodes(t.editor,n,{at:[o]}),t.props.includes("_key")&&l.gB.setNodes(t.editor,{_key:e.keyGenerator()},{at:[o]});return}let r=t.props.flatMap(t=>"_type"===t?[]:"_key"===t?(0,B.hZ)(e.keyGenerator(),["_key"]):(0,B.wC)(["value",t])),a=(0,B.yl)(i,r);l.gB.setNodes(t.editor,a,{at:[o]})},"child.set":({context:e,operation:t})=>{let n=ee({context:{schema:e.schema,value:t.editor.value,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}},blockIndexMap:t.editor.blockIndexMap});if(!n)throw Error(`Unable to convert ${JSON.stringify(t.at)} into a Slate Range`);let o=l.KE.node(t.editor,n,{depth:2}),i=o?.[0],r=o?.[1];if(!i||!r)throw Error(`Unable to find child at ${JSON.stringify(t.at)}`);if(t.editor.isTextSpan(i)){let{_type:e,text:n,...o}=t.props;l.gB.setNodes(t.editor,{...i,...o},{at:r}),"string"==typeof n&&i.text!==n&&(t.editor.apply({type:"remove_text",path:r,offset:0,text:i.text}),t.editor.apply({type:"insert_text",path:r,offset:0,text:n}));return}if(l.Hg.isElement(i)){let n=e.schema.inlineObjects.find(e=>e.name===i._type);if(!n)throw Error(`Unable to find schema definition for Inline Object type ${i._type}`);let o="value"in i&&"object"==typeof i.value?i.value:{},{_type:a,_key:s,...c}=t.props;for(let e in c)n.fields.some(t=>t.name===e)||delete c[e];l.gB.setNodes(t.editor,{...i,_key:"string"==typeof s?s:i._key,value:{...o,...c}},{at:r});return}throw Error(`Unable to determine the type of child at ${JSON.stringify(t.at)}`)},"child.unset":({context:e,operation:t})=>{let n=t.at[0]._key,o=t.editor.blockIndexMap.get(n);if(void 0===o)throw Error(`Unable to find block index for block key ${n}`);let i=void 0!==o?t.editor.value.at(o):void 0;if(!i)throw Error(`Unable to find block at ${JSON.stringify(t.at)}`);if(!(0,u.zS)(e,i))throw Error(`Block ${JSON.stringify(n)} is not a text block`);let r=t.at[2]._key;if(!r)throw Error(`Unable to find child key at ${JSON.stringify(t.at)}`);let a=i.children.findIndex(e=>e._key===r);if(-1===a)throw Error(`Unable to find child at ${JSON.stringify(t.at)}`);let s=l.KE.node(t.editor,[o,a],{depth:2}),c=s?.[0],d=s?.[1];if(!c||!d)throw Error(`Unable to find child at ${JSON.stringify(t.at)}`);if(t.editor.isTextSpan(c)){let n={};for(let o of t.props)if("text"!==o&&"_type"!==o){if("_key"===o){n._key=e.keyGenerator();continue}n[o]=null}l.gB.setNodes(t.editor,n,{at:d}),t.props.includes("text")&&t.editor.apply({type:"remove_text",path:d,offset:0,text:c.text});return}if(l.Hg.isElement(c)){let n="value"in c&&"object"==typeof c.value?c.value:{},o=t.props.map(e=>({type:"unset",path:[e]})),i=(0,B.yl)(n,o);l.gB.setNodes(t.editor,{...c,_key:t.props.includes("_key")?e.keyGenerator():c._key,value:i},{at:d});return}throw Error(`Unable to determine the type of child at ${JSON.stringify(t.at)}`)},"decorator.add":({context:e,operation:t})=>{let n=t.editor,o=t.decorator,i=t.at?ee({context:{schema:e.schema,value:t.editor.value,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):t.editor.selection;if(!i)throw Error("Unable to add decorator without a selection");if(l.Q6.isExpanded(i)){let e=l.KE.rangeRef(n,i,{affinity:"inward"}),[r,a]=l.Q6.edges(i),s=l.KE.isEnd(n,a,a.path);l.gB.splitNodes(n,{at:a,match:l.EY.isText,mode:"lowest",voids:!1,always:!s});let c=l.KE.isStart(n,r,r.path);if(l.gB.splitNodes(n,{at:r,match:l.EY.isText,mode:"lowest",voids:!1,always:!c}),!(i=e.unref()))throw Error("Unable to add decorator without a selection");for(let[e,r]of(t.at||l.gB.select(n,i),l.KE.nodes(n,{at:i,match:l.EY.isText}))){let t=[...(Array.isArray(e.marks)?e.marks:[]).filter(e=>e!==o),o];l.gB.setNodes(n,{marks:t},{at:r,match:l.EY.isText,split:!0,hanging:!0})}}else{if(!Array.from(l.KE.nodes(n,{at:i,match:e=>n.isTextSpan(e)}))?.at(0))return;let[e,t]=l.KE.node(n,i,{depth:1}),r=n.isTextBlock(e)&&1===e.children.length&&n.isTextSpan(e.children[0])&&""===e.children[0].text?e.children[0]:void 0;if(r){let e=r.marks??[],i=e.filter(e=>e!==o);l.gB.setNodes(n,{marks:e.length===i.length?[...e,o]:i},{at:t,match:e=>n.isTextSpan(e)})}else n.decoratorState[o]=!0}if(n.selection){let e=n.selection;n.selection={...e}}},"decorator.remove":({operation:e})=>{let t=e.editor,n=e.decorator,{selection:o}=t;if(o){if(l.Q6.isExpanded(o))l.gB.setNodes(t,{},{match:l.EY.isText,split:!0,hanging:!0}),t.selection&&[...l.KE.nodes(t,{at:t.selection,match:l.EY.isText}
3)].forEach(([e,o])=>{let i=t.children[o[0]];l.Hg.isElement(i)&&i.children.includes(e)&&l.gB.setNodes(t,{marks:(Array.isArray(e.marks)?e.marks:[]).filter(e=>e!==n),_type:"span"},{at:o})});else{let[e,i]=l.KE.node(t,o,{depth:1}),r=t.isTextBlock(e)&&1===e.children.length&&t.isTextSpan(e.children[0])&&""===e.children[0].text?e.children[0]:void 0;if(r){let e=(r.marks??[]).filter(e=>e!==n);l.gB.setNodes(t,{marks:e},{at:i,match:e=>t.isTextSpan(e)})}else t.decoratorState[n]=!1}if(t.selection){let e=t.selection;t.selection={...e}}}},delete:({context:e,operation:t})=>{let n,o=t.at?ee({context:{schema:e.schema,value:t.editor.value,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):t.editor.selection;if(!o)throw Error("Unable to delete without a selection");let[i,r]=l.Q6.edges(o);if("block"===t.unit){let e=i.path.at(0),n=r.path.at(0);if(void 0===e||void 0===n)throw Error("Failed to get start or end block index");l.gB.removeNodes(t.editor,{at:{anchor:{path:[e],offset:0},focus:{path:[n],offset:0}},mode:"highest"});return}if("child"===t.unit)return void l.gB.removeNodes(t.editor,{at:o,match:t=>(0,u.bl)(e,t)&&t._key!==$||"__inline"in t&&!0===t.__inline});if("backward"===t.direction&&"line"===t.unit){let e=l.KE.above(t.editor,{match:e=>l.Hg.isElement(e)&&l.KE.isBlock(t.editor,e),at:o});if(e){let[,n]=e,i=l.KE.range(t.editor,n,o.anchor),r=function(e,t){let n=l.KE.range(e,l.Q6.end(t)),o=Array.from(l.KE.positions(e,{at:t})),i=0,r=o.length,a=Math.floor(r/2);if(tn(e,l.KE.range(e,o[i]),n))return l.KE.range(e,o[i],n);if(o.length<2)return l.KE.range(e,o[o.length-1],n);for(;a!==o.length&&a!==i;)tn(e,l.KE.range(e,o[a]),n)?r=a:i=a,a=Math.floor((i+r)/2);return l.KE.range(e,o[i],n)}(t.editor,i);if(!l.Q6.isCollapsed(r))return void l.gB.delete(t.editor,{at:r})}}if("word"===t.unit&&l.Q6.isCollapsed(o))return void(0,l.JG)(t.editor,{at:o,unit:"word",reverse:"backward"===t.direction});let a=l.KE.above(t.editor,{match:e=>l.Hg.isElement(e)&&l.KE.isBlock(t.editor,e),at:i,voids:!1}),s=l.KE.above(t.editor,{match:e=>l.Hg.isElement(e)&&l.KE.isBlock(t.editor,e),at:r,voids:!1}),c=a&&s&&!l.wA.equals(a[1],s[1]),d=l.KE.void(t.editor,{at:i,mode:"highest"})??l.KE.elementReadOnly(t.editor,{at:i,mode:"highest"}),p=l.KE.void(t.editor,{at:r,mode:"highest"})??l.KE.elementReadOnly(t.editor,{at:r,mode:"highest"}),h=[];for(let e of l.KE.nodes(t.editor,{at:o,voids:!1})){let[o,a]=e;n&&0===l.wA.compare(a,n)||(l.Hg.isElement(o)&&(l.KE.isVoid(t.editor,o)||l.KE.isElementReadOnly(t.editor,o))||!l.wA.isCommon(a,i.path)&&!l.wA.isCommon(a,r.path))&&(h.push(e),n=a)}let f=Array.from(h,([,e])=>l.KE.pathRef(t.editor,e)),y=l.KE.pointRef(t.editor,i),g=l.KE.pointRef(t.editor,r);
3if(a&&s&&l.bR.equals(i,l.KE.start(t.editor,a[1]))&&l.bR.equals(r,l.KE.end(t.editor,s[1]))&&c&&!d&&!p){if(!d){let e=y.current,[n]=l.KE.leaf(t.editor,e);n.text.length>0&&t.editor.apply({type:"remove_text",path:e.path,offset:0,text:n.text})}for(let e of f.reverse()){let n=e.unref();n&&l.gB.removeNodes(t.editor,{at:n,voids:!1})}if(!p){let e=g.current,[n]=l.KE.leaf(t.editor,e),{path:o}=e,i=n.text.slice(0,r.offset);i.length>0&&t.editor.apply({type:"remove_text",path:o,offset:0,text:i})}g.current&&y.current&&l.gB.removeNodes(t.editor,{at:g.current,voids:!1});return}let m="backward"===t.direction,k=m?!!r&&(!(0,u.zS)(e,s)||0===r.offset):!!i&&(!(0,u.zS)(e,a)||0===i.offset);t.at?(0,l.JG)(t.editor,{at:o,hanging:k,reverse:m}):(0,l.JG)(t.editor,{hanging:k,reverse:m})},"history.redo":({operation:e})=>{let t=e.editor,{redos:n}=t.history;if(n.length>0){let e=n[n.length-1];if(tJ("Redoing",e),e.operations.length>0){let n=t.remotePatches.filter(t=>t.time>=e.timestamp),o=e.operations;n.forEach(e=>{o=o.flatMap(n=>tQ(t,e.patch,n,e.snapshot,e.previousSnapshot))});try{l.KE.withoutNormalizing(t,()=>{!function(e,t){let n=e.isRedoing;e.isRedoing=!0,t(),e.isRedoing=n}(t,()=>{ti(t,()=>{o.forEach(e=>{t.apply(e)})})})})}catch(e){tJ("Could not perform redo step",e),t.remotePatches.splice(0,t.remotePatches.length),l.gB.deselect(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(tY("Undoing",e),e.operations.length>0){let n=t.remotePatches.filter(t=>t.time>=e.timestamp),o=e.operations;n.forEach(e=>{o=o.flatMap(n=>tQ(t,e.patch,n,e.snapshot,e.previousSnapshot))});let i=o.map(l.I.inverse).reverse();try{l.KE.withoutNormalizing(t,()=>{!function(e,t){let n=e.isUndoing;e.isUndoing=!0,t(),e.isUndoing=n}(t,()=>{ti(t,()=>{i.forEach(e=>{t.apply(e)})})})})}catch(e){tY("Could not perform undo step",e),t.remotePatches.splice(0,t.remotePatches.length),l.gB.deselect(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,p.rT)({block:t.block,context:e,options:{normalize:!0,removeUnusedMarkDefs:!0,validateFields:!0}});if(!n)throw Error(`Failed to parse block ${JSON.stringify(t.block)}`);let o=L(n,{schemaTypes:e.schema});!function(e){let{context:t,block:n,placement:o,select:i,editor:r}=e,a=e.at?ee({context:{schema:t.schema,value:r.value,selection:e.at},blockIndexMap:r.blockIndexMap}):r.selection;0===r.children.length&&l.gB.insertNodes(r,tt(t),{at:[0]});let s=a?l.Q6.start(a):l.KE.start(r,[]),c=a?l.Q6.end(a):l.KE.end(r,[]),[p,f]=Array.from(l.KE.nodes(r,{at:s,mode:"lowest",match:(e,t)=>l.Hg.isElement(e)&&t.length<=s.path.length})).at(0)??[void 0,void 0],[y,g]=Array.from(l.KE.nodes(r,{at:c,mode:"lowest",match:(e,t)=>l.Hg.isElement(e)&&t.length<=c.path.length})).at(0)??[void 0,void 0];if(!p||!f||!y||!g)throw Error("Unable to insert block without a start and end block");if(r.selection||"none"===i||d.wE.focus(r),!a){if("before"===o)l.gB.insertNodes(r,[n],{at:[0]}),"start"===i?l.gB.select(r,l.KE.start(r,[0])):"end"===i&&l.gB.select(r,l.KE.end(r,[0]));else if("after"===o){let e=l.wA.next(g);l.gB.insertNodes(r,[n],{at:e}),"start"===i?l.gB.select(r,l.KE.start(r,e)):"end"===i&&l.gB.select(r,l.KE.end(r,e))}else{if((0,h.wm)(t,y)){l.gB.insertNodes(r,[n],{at:g,select:!1}),l.gB.removeNodes(r,{at:l.wA.next(g)}),l.gB.deselect(r),"start"===i?l.gB.select(r,l.KE.start(r,g)):"end"===i&&l.gB.select(r,l.KE.end(r,g));return}if(r.isTextBlock(n)&&y&&r.isTextBlock(y)){let e=l.KE.end(r,g);l.gB.insertFragment(r,[n],{at:l.KE.end(r,g)}),"start"===i?l.gB.select(r,e):"none"===i&&l.gB.deselect(r);return}let e=l.wA.next(g);l.gB.insertNodes(r,[n],{at:e,select:!1}),"start"===i?l.gB.select(r,l.KE.start(r,e)):"end"===i&&l.gB.select(r,l.KE.end(r,e))}return}if(!a)throw Error("Unable to insert block without a selection");if("before"===o)l.gB.insertNodes(r,[n],{at:f,select:!1}),"start"===i?l.gB.select(r,l.KE.start(r,f)):"end"===i&&l.gB.select(r,l.KE.end(r,f));else if("after"===o){let e=l.wA.next(g);l.gB.insertNodes(r,[n],{at:e,select:!1}),"start"===i?l.gB.select(r,l.KE.start(r,e)):"end"===i&&l.gB.select(r,l.KE.end(r,e))}else{let e=l.KE.start(r,g);if(l.Q6.isExpanded(a)&&!r.isTextBlock(n)){let e=l.KE.rangeRef(r,a,{affinity:"inward"});l.gB.delete(r,{at:a});let[o,s]=G({editor:r}),c=e.unref()??r.selection,d=c?l.KE.rangeRef(r,c,{affinity:"inward"}):void 0;l.gB.insertNodes(r,[n],{voids:!0,at:c??void 0,select:"none"!==i});let p=d?.unref()??r.selection;"none"===i&&p&&l.gB.select(r,p),(0,h.wm)(t,o)&&l.gB.removeNodes(r,{at:s});return}if(r.isTextBlock(y)&&r.isTextBlock(n)){let o=l.Q6.start(a);
3if((0,h.wm)(t,y)){l.gB.insertNodes(r,[n],{at:g,select:!1}),l.gB.removeNodes(r,{at:l.wA.next(g)}),"start"===i?l.gB.select(r,o):"end"===i?l.gB.select(r,l.KE.end(r,g)):l.gB.select(r,a);return}let s=y.children.map(e=>e._key),c=y.markDefs?.map(e=>e._key)??[],d=new Map,p=n.markDefs?.map(e=>{if(c.includes(e._key)){let n=t.keyGenerator();return d.set(e._key,n),{...e,_key:n}}return e}),f=n.children.map(e=>{if((0,u.bl)(t,e)){let n=e.marks?.map(e=>d.get(e)||e)??[];if(!C(e.marks,n))return{...e,_key:s.includes(e._key)?t.keyGenerator():e._key,marks:n}}return s.includes(e._key)?{...e,_key:t.keyGenerator()}:e});l.gB.setNodes(r,{markDefs:[...y.markDefs??[],...p??[]]},{at:g});let m=M(n.children,f)?n:{...n,children:f};if("end"===i)return l.gB.insertFragment(r,[m],{voids:!0});l.gB.insertFragment(r,[m],{at:a,voids:!0}),"start"===i?l.gB.select(r,o):l.bR.equals(o,e)||l.gB.select(r,o)}else if(r.isTextBlock(y)){let e=l.KE.start(r,g),o=l.KE.end(r,g),s=l.Q6.start(a),c=l.Q6.end(a);if(l.Q6.isCollapsed(a)&&l.bR.equals(s,e))l.gB.insertNodes(r,[n],{at:g,select:!1}),("start"===i||"end"===i)&&l.gB.select(r,l.KE.start(r,g)),(0,h.wm)(t,y)&&l.gB.removeNodes(r,{at:l.wA.next(g)});else if(l.Q6.isCollapsed(a)&&l.bR.equals(c,o)){let e=[g[0]+1];l.gB.insertNodes(r,[n],{at:e,select:!1}),("start"===i||"end"===i)&&l.gB.select(r,l.KE.start(r,e))}else if(l.Q6.isExpanded(a)&&l.bR.equals(s,e)&&l.bR.equals(c,o))l.gB.insertFragment(r,[n],{at:a}),"start"===i?l.gB.select(r,l.KE.start(r,g)):"end"===i&&l.gB.select(r,l.KE.end(r,g));else if(l.Q6.isExpanded(a)&&l.bR.equals(s,e))l.gB.insertFragment(r,[n],{at:a}),"start"===i?l.gB.select(r,l.KE.start(r,g)):"end"===i&&l.gB.select(r,l.KE.end(r,g));else if(l.Q6.isExpanded(a)&&l.bR.equals(c,o))l.gB.insertFragment(r,[n],{at:a}),"start"===i?l.gB.select(r,l.KE.start(r,l.wA.next(g))):"end"===i&&l.gB.select(r,l.KE.end(r,l.wA.next(g)));else{let[e]=function({editor:e}){let[t,n]=G({editor:e}),o=e.selection?.focus.path.at(1);if(!t||!n||void 0===o)return[void 0,void 0];try{let e=l.bP.child(t,o);return e?[e,[...n,o]]:[void 0,void 0]}catch{return[void 0,void 0]}}({editor:r});if(e&&r.isTextSpan(e))l.gB.splitNodes(r,{at:a}),l.gB.insertFragment(r,[n],{at:a}),"start"===i||"end"===i?l.gB.select(r,[g[0]+1]):l.gB.select(r,a);else{let e=[g[0]+1];l.gB.insertNodes(r,[n],{at:e,select:!1}),l.gB.select(r,a),"start"===i?l.gB.select(r,l.KE.start(r,e)):"end"===i&&l.gB.select(r,l.KE.end(r,e))}}}else{l.gB.insertNodes(r,[n],{select:!1});let e=[g[0]+1];"start"===i?l.gB.select(r,l.KE.start(r,e)):"end"===i&&l.gB.select(r,l.KE.end(r,e))}}}({context:e,block:o,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,o=n?.path.at(0),i=n?.path.at(1);if(void 0===o||void 0===i)throw Error("Unable to insert child without a focus");let[r,a]=G({editor:t.editor});if(!n||!r||!a)throw Error("Unable to insert child without a focus block");if(!(0,u.zS)(e,r))throw Error("Unable to insert child into a non-text block");let s=r.markDefs??[],c=new Map;for(let e of s)c.set(e._key,e._key);let h=(0,p.wr)({span:t.child,context:e,markDefKeyMap:c,options:{validateFields:!0}});if(h){let[e]=H({editor:t.editor});e?l.gB.insertNodes(t.editor,h,{at:n,select:!0}):l.gB.insertNodes(t.editor,h,{at:[o,i+1],select:!0}),d.hK.set(t.editor,t.editor.selection);return}let f=(0,p.lV)({inlineObject:t.child,context:e,options:{validateFields:!0}});if(f){let{_key:e,_type:r,...a}=f,[s]=H({editor:t.editor});s?l.gB.insertNodes(t.editor,{_key:e,_type:r,children:[{_key:$,_type:"span",text:"",marks:[]}],value:a,__inline:!0},{at:n,select:!0}):l.gB.insertNodes(t.editor,{_key:e,_type:r,children:[{_key:$,_type:"span",text:"",marks:[]}],value:a,__inline:!0},{at:[o,i+1],select:!0});return}throw Error("Unable to parse child")},"insert.text":({operation:e})=>{l.gB.insertText(e.editor,e.text)},"move.backward":({operation:e})=>{l.gB.move(e.editor,{unit:"character",distance:e.distance,reverse:!0})},"move.block":({operation:e})=>{let t=(0,p.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 o=(0,p.XE)({path:e.to});if(!o)throw Error("Failed to get block key from selection point");let i=e.editor.blockIndexMap.get(o);if(void 0===i)throw Error("Failed to get block index from block key");l.gB.moveNodes(e.editor,{at:[n],to:[i],mode:"highest"})},"move.forward":({operation:e})=>{l.gB.move(e.editor,{unit:"character",distance:e.distance})},select:({context:e,operation:t})=>{let n=ee({context:{schema:e.schema,value:t.editor.value,selection:t.at},blockIndexMap:t.editor.blockIndexMap});n?l.gB.select(t.editor,n):l.gB.deselect(t.editor),d.Rf.get(t.editor)&&d.dY.get(t.editor)&&d.Rf.set(t.editor,!1)}};function tq({context:e,operation:t}){l.KE.withoutNormalizing(t.editor,()=>{try{switch(t.type){case"annotation.add":tW["annotation.add"]({context:e,operation:t});break;case"annotation.remove":tW["annotation.remove"]({context:e,operation:t});break;case"block.set":tW["block.set"]({context:e,operation:t});break;case"block.unset":tW["block.unset"]({context:e,operation:t});break;case"child.set":tW["child.set"]({context:e,operation:t});break;case"child.unset":tW["child.unset"]({context:e,operation:t});break;case"decorator.add":tW["decorator.add"]({context:e,operation:t});break;case"decorator.remove":tW["decorator.remove"]({context:e,operation:t});break;case"delete":tW.delete({context:e,operation:t});break;case"history.redo":tW["history.redo"]({context:e,operation:t});break;case"history.undo":tW["history.undo"]({context:e,operation:t});break;case"insert.block":tW["insert.block"]({context:e,operation:t});break;case"insert.child":tW["insert.child"]({context:e,operation:t});break;case"insert.text":tW["insert.text"]({context:e,operation:t});break;case"move.backward":tW["move.backward"]({context:e,operation:t});break;case"move.block":tW["move.block"]({context:e,operation:t});break;case"move.forward":tW["move.forward"]({context:e,operation:t});break;default:tW.select({context:e,operation:t})}}catch(e){console.error(Error(`Executing "${t.type}" failed due to: ${e.message}`))}})}function tZ(e,t,n){return[...e,{operations:null===n.selection?[t]:[{type:"set_selection",properties:{...n.selection},newProperties:{...n.selection}},t],timestamp:new Date}]}
3function tX(e,t,n){return[...e.slice(0,-1),{timestamp:t.timestamp,operations:[...t.operations,n]}]}let t0=N("plugin:history");function t1(e,t){let n=e.isNormalizingNode;e.isNormalizingNode=!0,t(),e.isNormalizingNode=n}function t2(e,t){let n=e.isPatching;e.isPatching=!1,t(),e.isPatching=n}let t3=N("plugin:withPortableTextMarkModel");function t4(e,t){let n=-1,o=e.find((e,o)=>{let i=(0,p.wE)(t[0])?e._key===t[0]._key:o===t[0];return i&&(n=o),i});if(o)return{node:o,index:n}}function t6(e,t){let n=e.node;if(!l.Hg.isElement(n)||"children"!==t[1])return;let o=-1,i=n.children.find((e,n)=>{let i=(0,p.wE)(t[2])?e._key===t[2]._key:n===t[2];return i&&(o=n),i});if(i)return{node:i,index:o}}function t8(e,t){let n=e.isProcessingRemoteChanges;e.isProcessingRemoteChanges=!0,t(),e.isProcessingRemoteChanges=n}let t5=N("plugin:withPatches"),t7=N("plugin:withSchemaTypes");function t9(e){return"object"==typeof e&&null!==e&&!("_type"in e)&&"children"in e&&Array.isArray(e.children)}function ne(e,t){return(0,p.Kk)(t)&&t._type===e.schema.block.name}function nt(e,t){return"object"==typeof t&&null!==t&&!("children"in t)&&("_type"in t?t._type===e.schema.span.name:"text"in t)}function nn(e,t){return!("object"!=typeof t||null===t||!("text"in t)||"string"!=typeof t.text||"_type"in t&&t._type!==e.schema.span.name)}function no(e,t){let n=t.at(0);if(void 0!==n&&1===t.length)return e.children.at(n)}function ni(e,t,n){if(0===n.length)return t;if(1===n.length)return no(t,n);if(2===n.length){let o=no(t,n.slice(0,1));return o&&ne(e,o)&&o.children.at(n[1])||void 0}}function nr(e,t,n){let o=ni(e,t,n);if(o&&nt(e,o))return o}function na(e,t,n){if(0===n.length)return;let o=n.slice(0,-1);if(0===o.length)return t;let i=o.at(0);if(void 0===i||1!==o.length)return;let r=t.children.at(i);if(r&&ne(e,r))return r}function nl(e,t,...n){return[...e.slice(0,t),...n,...e.slice(t)]}function ns(e,t,n=1){return[...e.slice(0,t),...e.slice(t+n)]}function nc(e,t,n){return[...e.slice(0,t),n,...e.slice(t+1)]}function nd(e,t,n,o){let i=t.children.at(n);if(!i||!ne(e,i))return t;let r=o(i);return{...t,children:nc(t.children,n,r)}}let np=N("setup");function nu(e,t){return{getBlockNodes:e=>nh(t,e),getChildNodes:e=>(function(e,t){if(!t.context.selection)return[];let n=ee(t);if(!n)return[];try{return Array.from(l.KE.nodes(e,{at:n,mode:"lowest",match:e=>!l.KE.isEditor(e)})).map(([t])=>d.wE.toDOMNode(e,t))}catch{return[]}})(t,e),getEditorElement:()=>(function(e){try{return d.wE.toDOMNode(e,e)}catch{return}})(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,v.GB)(t);if(!n)return null;let o=nh(e,{...t,context:{...t.context,selection:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}}})?.at(0);return o&&o instanceof Element?o:null})(t,e),getEndBlockElement:e=>(function(e,t){let n=(0,v.P$)(t);if(!n)return null;let o=nh(e,{...t,context:{...t.context,selection:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}}})?.at(0);return o&&o instanceof Element?o: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 nh(e,t){if(!t.context.selection)return[];let n=ee(t);if(!n)return[];try{return Array.from(l.KE.nodes(e,{at:n,mode:"highest",match:e=>!l.KE.isEditor(e)})).map(([t])=>d.wE.toDOMNode(e,t))}catch{return[]}}let nf=(0,b.Ke)({on:"annotation.add",guard:({snapshot:e})=>{if(!(0,v.WV)(e))return!1;let t=(0,v.UH)(e);return!!t&&!!(0,v.gR)({context:{...e.context,selection:t}})&&{caretWordSelection:t}},actions:[({event:e},{caretWordSelection:t})=>[(0,b.xl)({type:"select",at:t}),(0,b.xl)({type:"annotation.add",annotation:e.annotation})]]}),ny=(0,b.Ke)({on:"annotation.add",guard:({snapshot:e,event:t})=>(0,v.kK)(t.annotation.name,{mode:"partial"})(e),actions:[({event:e})=>[(0,b.xl)({type:"annotation.remove",annotation:e.annotation}),(0,b.xl)(e)]]}),ng=(0,b.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{let n={...e,context:{...e.context,selection:t.at??e.context.selection}};if(!(0,v.gR)(n))return!1;let o=(0,v.dO)(n),i=(0,v.Jo)(n),r=(0,v.yh)(n),a=(0,v.aR)(n);if(!o||!r||!i||!a||o.path[2]._key!==r.path[2]._key||!(0,u.bl)(e.context,o.node)||0!==i.offset||a.offset!==o.node.text.length)return!1;let l=e.context.schema.decorators.map(e=>e.name),s=o.node.marks??[];if(!s.some(e=>!l.includes(e)))return!1;let c=(0,v.A_)(n),d=(0,v.eb)(n),p=!!c&&c.node.marks?.some(e=>!l.includes(e)&&s.includes(e)),h=!!d&&d.node.marks?.some(e=>!l.includes(e)&&s.includes(e));if(p||h)return!1;let f=(0,v.rm)(n);return{spanPath:o.path,activeDecorators:f}},actions:[({event:e},{spanPath:t,activeDecorators:n}
3)=>[(0,b.xl)({type:"child.set",at:t,props:{marks:n}}),(0,b.sY)(e)]]}),nm={arrowDown:(0,K.mn)({default:[{key:"ArrowDown",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),arrowUp:(0,K.mn)({default:[{key:"ArrowUp",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),backspace:(0,K.mn)({default:[{key:"Backspace",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),break:(0,K.mn)({default:[{key:"Enter",shift:!1}]}),lineBreak:(0,K.mn)({default:[{key:"Enter",shift:!0}]}),decorators:{strong:K.Cr,em:K.TN,underline:K.V1,code:K.aY},delete:(0,K.mn)({default:[{key:"Delete",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),deleteWord:{backward:(0,K.mn)({default:[{key:"Backspace",alt:!1,ctrl:!0,meta:!1}],apple:[{key:"Backspace",alt:!0,ctrl:!1,meta:!1}]}),forward:(0,K.mn)({default:[{key:"Delete",alt:!1,ctrl:!0,meta:!1}],apple:[{key:"Delete",alt:!0,ctrl:!1,meta:!1}]})},history:{undo:K.tN,redo:K.ZS},tab:(0,K.mn)({default:[{key:"Tab",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),shiftTab:(0,K.mn)({default:[{key:"Tab",alt:!1,ctrl:!1,meta:!1,shift:!0}]})},nk=(0,b.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!nm.arrowDown.guard(t.originEvent)||!(0,v.WV)(e))return!1;let n=(0,v.lA)(e),o=(0,v.RL)(e);return n&&!o},actions:[({snapshot:e})=>[(0,b.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after"})]]}),nv=(0,b.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!nm.arrowUp.guard(t.originEvent)||!(0,v.WV)(e))return!1;let n=(0,v.lA)(e),o=(0,v.HA)(e);return n&&!o},actions:[({snapshot:e})=>[(0,b.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"before"})]]}),nb=(0,b.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,v.lA)(e);return(0,v.WV)(e)&&void 0!==t},actions:[({snapshot:e})=>[(0,b.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after"})]]}),nx=(0,b.Ke)({on:"mouse.click",guard:({snapshot:e,event:t})=>{if(e.context.readOnly||e.context.selection&&!(0,v.WV)(e))return!1;let n=(0,v.lA)({...e,context:{...e.context,selection:t.position.selection}}),o=(0,v.HA)({...e,context:{...e.context,selection:t.position.selection}});return t.position.isEditor&&"start"===t.position.block&&n&&!o},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"})]]}),n_=(0,b.Ke)({on:"mouse.click",guard:({snapshot:e,event:t})=>{if(e.context.readOnly||e.context.selection&&!(0,v.WV)(e))return!1;let n=(0,v.lA)({...e,context:{...e.context,selection:t.position.selection}}),o=(0,v.RL)({...e,context:{...e.context,selection:t.position.selection}});return t.position.isEditor&&"end"===t.position.block&&n&&!o},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"})]]}),nE={arrowDownOnLonelyBlockObject:nk,arrowUpOnLonelyBlockObject:nv,breakingBlockObject:nb,clickingAboveLonelyBlockObject:nx,clickingBelowLonelyBlockObject:n_,deletingEmptyTextBlockAfterBlockObject:(0,b.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,v.hH)(e),n=(0,v.WV)(e),o=(0,v.HA)(e);return!!t&&!!n&&!!o&&!(!(0,h.wm)(e.context,t.node)||(0,u.zS)(e.context,o.node))&&{focusTextBlock:t,previousBlock:o}},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}}})]]}),deletingEmptyTextBlockBeforeBlockObject:(0,b.Ke)({on:"delete.forward",guard:({snapshot:e})=>{let t=(0,v.hH)(e),n=(0,v.WV)(e),o=(0,v.RL)(e);return!!t&&!!n&&!!o&&!(!(0,h.wm)(e.context,t.node)||(0,u.zS)(e.context,o.node))&&{focusTextBlock:t,nextBlock:o}},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}}})]]})},nw={strongShortcut:(0,b.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nm.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})=>nm.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})=>nm.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})=>nm.decorators.code.guard(t.originEvent)&&e.context.schema.decorators.some(e=>
3"code"===e.name),actions:[()=>[(0,b.xl)({type:"decorator.toggle",decorator:"code"})]]})};function nS(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 o=n.left,i=n.top,r=n.right,a=n.bottom;for(let e=1;e<t.length;e++){let n=t[e].getBoundingClientRect();o=Math.min(o,n.left),i=Math.min(i,n.top),r=Math.max(r,n.right),a=Math.max(a,n.bottom)}return new DOMRect(o,i,r-o,a-i)}let nB=[(0,b.Ke)({on:"drag.dragstart",guard:({snapshot:e,dom:t,event:n})=>{let o=ep({snapshot:e,eventSelection:n.position.selection}),i=(0,v.iE)({...e,context:{...e.context,selection:o}}),r={blockNodes:t.getBlockNodes({...e,context:{...e.context,selection:o}}),childNodes:t.getChildNodes({...e,context:{...e.context,selection:o}})};return{dragSelection:o,draggedDomNodes:r,selectingEntireBlocks:i}},actions:[({dom:e,event:t},{dragSelection:n,draggedDomNodes:o,selectingEntireBlocks:i})=>{let r=document.createElement("div");if(i){for(let e of o.blockNodes.map(e=>e.cloneNode(!0)))e instanceof HTMLElement&&(e.style.position="relative"),r.appendChild(e);let i=r.querySelector("[data-pt-drag-ghost-element]");if(i&&r.replaceChildren(i),r.setAttribute("data-dragged",""),r.style.position="absolute",r.style.left="-99999px",r.style.boxSizing="border-box",document.body.appendChild(r),i){let o=i.getBoundingClientRect(),a=t.originEvent.clientX-o.left,l=t.originEvent.clientY-o.top;return r.style.width=`${o.width}px`,r.style.height=`${o.height}px`,[(0,b.xl)({type:"select",at:n}),(0,b.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:r,x:a,y:l}})}),(0,b.sY)(t)]}{let i=nS(o.blockNodes),a=t.originEvent.clientX-i.left,l=t.originEvent.clientY-i.top;return r.style.width=`${i.width}px`,r.style.height=`${i.height}px`,[(0,b.xl)({type:"select",at:n}),(0,b.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:r,x:a,y:l}})}),(0,b.sY)(t)]}}{for(let e of o.childNodes.map(e=>e.cloneNode(!0)))r.appendChild(e);r.style.position="absolute",r.style.left="-99999px",r.style.boxSizing="border-box",document.body.appendChild(r);let i=nS(o.childNodes),a=t.originEvent.clientX-i.left,l=t.originEvent.clientY-i.top;return r.style.width=`${i.width}px`,r.style.height=`${i.height}px`,[(0,b.xl)({type:"select",at:n}),(0,b.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:r,x:a,y:l}})}),(0,b.sY)(t)]}}]}),(0,b.Ke)({on:"drag.dragover",guard:({snapshot:e,event:t})=>{let n=t.dragOrigin;return!!n&&(0,v.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,o=t.position.selection;return!!n&&(0,v.Q)(o)({...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,o=ep({eventSelection:n.selection,snapshot:e}),i=t.originEvent.position.selection,r=!!n&&(0,v.Q)(i)({...e,context:{...e.context,selection:o}}),a=(0,v.iE)({...e,context:{...e.context,selection:o}}),l=(0,v.wx)({...e,context:{...e.context,selection:o}});return!r&&{dropPosition:i,draggingEntireBlocks:a,draggedBlocks:l,dragOrigin:n,originEvent:t.originEvent}},actions:[({event:e},{draggingEntireBlocks:t,draggedBlocks:n,dragOrigin:o,dropPosition:i,originEvent:r})=>[(0,b.xl)({type:"select",at:i}),...t?n.map(e=>(0,b.xl)({type:"delete.block",at:e.path})):[(0,b.xl)({type:"delete",at:o.selection})],(0,b.xl)({type:"insert.blocks",blocks:e.data,placement:t?"start"===r.position.block?"before":"end"===r.position.block?"after":"auto":"auto"})]]})],nK=[(0,b.Ke)({on:"insert.text",guard:({snapshot:e})=>{if(!(0,v.d2)(e))return!1;let t=(0,v.JB)(e),n=(0,v.rm)(e),o=(0,v.N2)(e);if(t&&"unchanged"===t.state){let o=(t.marks??[]).filter(t=>e.context.schema.decorators.map(e=>e.name).includes(t));if(o.length===n.length&&o.every(e=>n.includes(e)))return!1}return{activeDecorators:n,activeAnnotations:o}},actions:[({snapshot:e,event:t},{activeDecorators:n,activeAnnotations:o})=>[(0,b.xl)({type:"insert.child",child:{_type:e.context.schema.span.name,text:t.text,marks:[...n,...o]}})]]})],nO=(0,b.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,v.hH)(e),n=(0,v.WV)(e);if(!e.context.selection||!t||!n)return!1;let o=(0,v.Qm)(t)(e),i=t.node.listItem,r=t.node.level;return!!o&&{focusListItem:i,focusLevel:r}},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
3ame},placement:"after"})]]}),nA=(0,b.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,v.hH)(e),n=(0,v.WV)(e);if(!e.context.selection||!t||!n)return!1;let o=(0,v.d2)(e),i=o?.node.marks?.filter(t=>e.context.schema.decorators.some(e=>e.name===t)??[]),r=o?.node.marks?.filter(t=>!e.context.schema.decorators.some(e=>e.name===t))??[],a=t.node.listItem,l=t.node.level;return!!(0,v.HX)(t)(e)&&{focusAnnotations:r,focusDecorators:i,focusListItem:a,focusLevel:l}},actions:[({snapshot:e},{focusAnnotations:t,focusDecorators:n,focusListItem:o,focusLevel:i})=>[(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:o,level:i,style:e.context.schema.styles[0]?.name},placement:"before",select:"none"})]]}),nT={breakingAtTheEndOfTextBlock:nO,breakingAtTheStartOfTextBlock:nA,breakingEntireBlocks:(0,b.Ke)({on:"insert.break",guard:({snapshot:e})=>{if(!e.context.selection||!(0,v.gR)(e))return!1;let t=(0,v.wx)(e),n=(0,v.GB)(e),o=(0,v.P$)(e);if(!n||!o)return!1;let i=(0,p.u3)({context:e.context,block:n}),r=(0,p.Jo)(e.context.selection),a=(0,p.J8)({context:e.context,block:o}),l=(0,p.aR)(e.context.selection);return!!((0,p._Q)(r,i)&&(0,p._Q)(l,a))&&{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}))]]}),breakingInlineObject:(0,b.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,v.WV)(e),n=(0,v.Rt)(e);return t&&n},actions:[()=>[(0,b.xl)({type:"move.forward",distance:1}),(0,b.xl)({type:"split"})]]})};function nN({context:e,block:t}){return!!(0,u.zS)(e,t)&&!!e.selection&&!!(0,p.WV)(e.selection)&&(0,p.qX)(e.selection.focus)===t.children[0]._key&&0===e.selection.focus.offset}let nD=(0,b.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,v.hH)(e);return!!t&&1===t.node.level&&!!nN({context:e.context,block:t.node})&&{focusTextBlock:t}},actions:[(e,{focusTextBlock:t})=>[(0,b.xl)({type:"block.unset",props:["listItem","level"],at:t.path})]]}),nP=(0,b.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,v.WV)(e),n=(0,v.hH)(e),o=(0,v.d2)(e);return!!t&&!!n&&!!o&&n.node.children[0]._key===o.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})]]}),nj=(0,b.Ke)({on:"delete.forward",guard:({snapshot:e})=>{let t=(0,v.iL)(e),n=(0,v.RL)(e);return!!t&&!!n&&!!(0,u.zS)(e.context,n.node)&&!!(0,h.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})]]}),nC=(0,b.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,v.hH)(e),n=(0,v.HA)(e);return!!t&&!!n&&!!nN({context:e.context,block:t.node})&&!!(0,p.Eg)(e.context,n.node)&&!!(0,h.wm)(e.context,n.node)&&{focusTextBlock:t,previousBlockEndPoint:(0,p.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})]]}),nI=(0,b.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let o=(0,v.wx)({...e,context:{...e.context,selection:n}});if(o.length<2)return!1;let i=o.at(0)?.node,r=o.slice(1,-1),a=o.at(-1)?.node;if(!(0,p.Eg)(e.context,i)||!(0,p.Eg)(e.context,a))return!1;let l=(0,v.Jo)({context:{...e.context,selection:n}}),s=(0,v.aR)({context:{...e.context,selection:n}});if(!l||!s)return!1;let c=(0,p.u3)({context:e.context,block:{node:i,path:[{_key:i._key}]}});if(!(0,p._Q)(l,c))return!1;let d=(0,p.J8)({context:e.context,block:{node:i,path:[{_key:i._key}]}}),u=(0,p.J8)({context:e.context,block:{node:a,path:[{_key:a._key}]}}),f=(0,h.Bh)({context:{schema:e.context.schema,selection:{anchor:s,focus:u}},block:a});return{startBlockStartPoint:c,startBlockEndPoint:d,middleBlocks:r,endBlock:a,slicedEndBlock:f}},actions:[(e,{startBlockStartPoint:t,startBlockEndPoint:n,middleBlocks:o,endBlock:i,slicedEndBlock:r})=>[...o.map(e=>(0,b.xl)({type:"delete.block",at:e.path})),(0,b.xl)({type:"delete.block",at:[{_key:i._key}]}),(0,b.xl)({type:"select",at:{anchor:n,focus:n}}),(0,b.xl)({type:"insert.block",block:r,placement:"auto",select:"none"}),(0,b.xl)({type:"delete",at:{anchor:t,focus:n}})]]}),nM=(0,b.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,v.WV)(e),n=(0,v.iL)(e);return!!t&&!!n&&!!(0,h.wm)(e.context,n.node)&&{focusListBlock:n}},actions:[(e,{focusListBlock:t})=>[(0,b.xl)({type:"block.unset",props:["listItem","level"],at:t.path})]]}),nz=(0,b.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!nm.tab.guard(t.originEvent))return!1;let n=(0,v.wx)(e),o=n.flatMap(t=>(0,p.Eg)(e.context,t.node)?[{node:t.node,path:t.path}]:[]);return o.length===n.length&&{selectedListBlocks:o}},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}))]}),nR=(0,b.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!nm.shiftTab.guard(t.originEvent))return!1;let n=(0,v.wx)(e),o=n.flatMap(t=>(0,p.Eg)(e.context,t.node)?[{node:t.node,path:t.path}]:[]);return o.length===n.length&&{selectedListBlocks:o}},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}))]}),n$=(0,b.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{let n=(0,v.iL)(e);if(!n)return!1;let o=t.blocks.at(0),i=t.blocks.at(1),r=(0,p.Eg)(e.context,o)?o:(0,p.Eg)(e.context,i)?i:void 0;if(!r)return!1;let a=n.node.level-r.level;return 0!==a&&{levelDifference:a,insertedListBlock:r}},actions:[({snapshot:e,event:t},{levelDifference:n,insertedListBlock:o})=>{let i=!0,r=!1;return[(0,b.xl)({...t,blocks:t.blocks.map(t=>(t._key===o._key&&(r=!0),i?r&&i&&(0,p.Eg)(e.context,t)?{...t,level:Math.min(10,Math.max(1,t.level+n))}:(r&&(i=!1),t):t))})]}]}),nL={clearListOnBackspace:nD,unindentListOnBackspace:nP,mergeTextIntoListOnDelete:nj,mergeTextIntoListOnBackspace:nC,deletingListFromStart:nI,clearListOnEnter:nM,indentListOnTab:nz,unindentListOnShiftTab:nR,inheritListLevel:n$,inheritListItem:(0,b.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{let n=(0,v.iL)(e);if(!n||(0,h.wm)(e.context,n.node))return!1;let o=t.blocks.at(0),i=t.blocks.at(1),r=(0,p.Eg)(e.context,o)?o:(0,p.Eg)(e.context,i)?i:void 0;return!!r&&n.node.level===r.level&&n.node.listItem!==r.listItem&&{listItem:n.node.listItem,insertedListBlock:r}},actions:[({snapshot:e,event:t},{listItem:n,insertedListBlock:o})=>{let i=!0,r=!1;return[(0,b.xl)({...t,blocks:t.blocks.map(t=>(t._key===o._key&&(r=!0),i?r&&i&&(0,p.Eg)(e.context,t)?{...t,listItem:t.level===o.level?n:t.listItem}:(r&&(i=!1),t):t))})]}]}),inheritListProperties:(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=(0,v.iL)(e);return!!n&&!!(0,h.wm)(e.context,n.node)&&{level:n.node.level,listItem:n.node.listItem}},actions:[({event:e},{level:t,listItem:n})=>[(0,b.xl)({...e,block:{...e.block,level:t,listItem:n}})]]})},nV=[nf,ny,ng,nw.strongShortcut,nw.emShortcut,nw.underlineShortcut,nw.codeShortcut,...nB,nE.clickingAboveLonelyBlockObject,nE.clickingBelowLonelyBlockObject,nE.arrowDownOnLonelyBlockObject,nE.arrowUpOnLonelyBlockObject,nE.breakingBlockObject,nE.deletingEmptyTextBlockAfterBlockObject,nE.deletingEmptyTextBlockBeforeBlockObject,...nK,nL.clearListOnBackspace,nL.unindentListOnBackspace,nL.mergeTextIntoListOnDelete,nL.mergeTextIntoListOnBackspace,nL.deletingListFromStart,nL.clearListOnEnter,nL.indentListOnTab,nL.unindentListOnShiftTab,nL.inheritListLevel,nL.inheritListItem,nL.inheritListProperties,nT.breakingAtTheEndOfTextBlock,nT.breakingAtTheStartOfTextBlock,nT.breakingEntireBlocks,nT.breakingInlineObject].map(e=>({behavior:e,priority:ed}));function nU(e,t){let n=e.isPerformingBehaviorOperation;e.isPerformingBehaviorOperation=!0,t(),e.isPerformingBehaviorOperation=n}let nG=[(0,b.Ke)({on:"annotation.set",guard:({snapshot:e,event:t})=>{let n=t.at[0]._key,o=t.at[2]._key,i=(0,v.hH)({...e,context:{...e.context,selection:{anchor:{path:[{_key:n}],offset:0},focus:{path:[{_key:n}],offset:0}}}});return!!i&&{blockKey:n,updatedMarkDefs:i.node.markDefs?.map(e=>e._key===o?{...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})=>(0,v.kK)(t.annotation.name)(e),actions:[({event:e})=>[(0,b.xl)({type:"annotation.remove",annotation:e.annotation})]]}),(0,b.Ke)({on:"annotation.toggle",guard:({snapshot:e,event:t})=>!(0,v.kK)(t.annotation.name)(e),actions:[({event:e})=>[(0,b.xl)({type:"annotation.add",annotation:e.annotation})]]})],nH=[(0,b.Ke)({on:"decorator.toggle",guard:({snapshot:e,event:t})=>(0,v.Y1)(t.decorator)(e),actions:[({event:e})=>[(0,b.xl)({type:"decorator.remove",decorator:e.decorator})]]}),(0,b.Ke)({on:"decorator.toggle",guard:({snapshot:e,event:t})=>t.at?!(0,v.Y1)(t.decorator)({...e,context:{...e.context,selection:t.at}}):!(0,v.Y1)(t.decorator)(e),actions:[({event:e})=>[(0,b.xl)({...e,type:"decorator.add"})]]})],nQ=[(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=(0,v.HA)(e),o=(0,v.hH)(e);if(!n||!o||!(0,v.HX)(o)(e))return!1;let i=(0,p.J8)({context:e.context,block:n});return!!(0,u.zS)(e.context,n.node)&&{previousBlockEndPoint:i,focusTextBlock:o}},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 o=(0,v.RL)({...e,context:{...e.context,selection:n}}),i=(0,v.hH)({...e,context:{...e.context,selection:n}});return!!o&&!!i&&!!(0,h.wm)(e.context,i.node)&&{focusTextBlock:i,nextBlockStartPoint:(0,p.u3)({context:e.context,block:o})}},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=(0,v.RL)(e),o=(0,v.hH)(e);return!!n&&!!o&&!!(0,v.Qm)(o)(e)&&!!(0,u.zS)(e.context,n.node)&&{nextBlock:n}},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,v.jR)({...e,context:{...e.context,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}}});return!!n&&((0,u.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"})]]})],nF=["application/x-portable-text","application/json","text/markdown","text/html","text/plain"];function nJ({dataTransfer:e,startAfter:t}){let n=t?nF.indexOf(t)+1:0;for(let t=n;t<nF.length;t++){let n=nF.at(t);if(!n)continue;let o=e.getData(n);if(o)return{mimeType:n,data:o}}}let nY=[(0,b.Ke)({on:"deserialize",guard:({event:e})=>{let t=nJ({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})=>
3{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})=>{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",guard:({snapshot:e,event:t})=>{if((0,v.hH)(e)&&"text/plain"===t.mimeType&&"drag.drop"!==t.originEvent.type){let n=(0,v.rm)(e);return{activeAnnotations:(0,v.Bg)(e),activeDecorators:n,textRuns:t.data.flatMap(t=>(0,u.zS)(e.context,t)?[(0,h.so)(t)]:[])}}return!1},actions:[(e,{activeAnnotations:t,activeDecorators:n,textRuns:o})=>o.flatMap((e,i)=>i!==o.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:"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=nJ({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}"`)}}]]})],nW=[(0,b.Ke)({on:"input.*",guard:({snapshot:e})=>(0,v.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"),o=e.originEvent.dataTransfer.types;return!(!t||t.includes(` 4`))&&(1===o.length?{text:t}:!(o.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})]]})],nq=[(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"})]]}),(0,b.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>"before"===t.placement&&{firstBlockKey:t.blocks.at(0)?._key??e.context.keyGenerator(),lastBlockKey:t.blocks.at(-1)?._key??e.context.keyGenerator()},actions:[({snapshot:e,event:t},{firstBlockKey:n,lastBlockKey:o})=>[...t.blocks.map((e,n)=>(0,b.xl)({type:"insert.block",block:e,placement:0===n?"before":"after",select:n!==t.blocks.length-1?"end":"none"})),..."none"===t.select?[(0,b.xl)({type:"select",at:e.context.selection})]:"start"===t.select?[(0,b.xl)({type:"select.block",at:[{_key:n}],select:"start"})]:[(0,b.xl)({type:"select.block",at:[{_key:o}],select:"end"})]]]}),(0,b.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>"after"===t.placement&&{firstBlockKey:t.blocks.at(0)?._key??e.context.keyGenerator(),lastBlockKey:t.blocks.at(-1)?._key??e.context.keyGenerator()},actions:[({snapshot:e,event:t},{firstBlockKey:n,lastBlockKey:o})=>[...t.blocks.map((e,n)=>(0,b.xl)({type:"insert.block",block:e,placement:"after",select:n!==t.blocks.length-1?"end":"none"})),..."none"===t.select?[(0,b.xl)({type:"select",at:e.context.selection})]:"start"===t.select?[(0,b.xl)({type:"select.block",at:[{_key:n}],select:"start"})]:[(0,b.xl)({type:"select.block",at:[{_key:o}],select:"end"})]]]}),(0,b.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{if("auto"!==t.placement)return!1;let n=(0,v.hH)(e);return!!n&&!!(0,h.wm)(e.context,n.node)&&{focusTextBlock:n,firstBlockKey:t.blocks.at(0)?._key??e.context.keyGenerator(),lastBlockKey:t.blocks.at(-1)?._key??e.context.keyGenerator()}},actions:[({event:e},{firstBlockKey:t,lastBlockKey:n})=>[...e.blocks.map((t,n)=>(0,b.xl)({type:"insert.block",block:t,placement:0===n?"auto":"after",select:n!==e.blocks.length-1?"end":"none"})),..."none"===e.select||"start"===e.select?[(0,b.xl)({type:"select.block",at:[{_key:t}],select:"start"})]:[(0,b.xl)({type:"select.block",at:[{_key:n}],select:"end"})]]]}),(0,b.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{if("auto"!==t.placement)return!1;let n=(0,v.hH)(e);if(!n||!e.context.selection)return!1;let o=(0,p.u3)({context:e.context,block:n}),i=(0,p.J8)({context:e.context,block:n}),r=(0,h.Bh)({context:{schema:e.context.schema,selection:{anchor:e.context.selection.focus,focus:i}},block:n.node});return{firstBlockKey:t.blocks.at(0)?._key??e.context.keyGenerator(),focusBlockStartPoint:o,focusBlockEndPoint:i,focusTextBlockAfter:r,selection:e.context.selection}},actions:[({event:e},{focusBlockEndPoint:t,focusTextBlockAfter:n,selection:o,firstBlockKey:i,focusBlockStartPoint:r})=>[...e.blocks.flatMap((i,r)=>0===r?[...(0,p._Q)(o.focus,t)?[]:[(0,b.xl)({type:"delete",at:{anchor:o.focus,focus:t}})],(0,b.xl)({type:"insert.block",block:i,placement:"auto",select:"end"})]:r===e.blocks.length-1?[(0,b.xl)({type:"insert.block",block:i,placement:"after",select:"end"}),(0,b.xl)({type:"insert.block",block:n,placement:"auto",select:"end"===e.select?"none":"end"})]:[(0,b.xl)({type:"insert.block",block:i,placement:"after",select:"end"})]),..."none"===e.select?[(0,b.xl)({type:"select",at:o})]:"start"===e.select?[(0,p._Q)(o.focus,r)?(0,b.xl)({type:"select.block",at:[{_key:i}],select:"start"}):(0,b.xl)({type:"select",at:{anchor:o.focus,focus:o.focus}})]:[]]]}),(0,b.Ke)({on:"insert.blocks",guard:({event:e})=>"auto"===e.placement,actions:[({event:e})=>e.blocks.map((t,n)=>(0,b.xl)({type:"insert.block",block:t,placement:0===n?"auto":"after",select:e.select??"end"}))]}),(0,b.Ke)({on:"insert.break",actions:[()=>[(0,b.xl)({type:"split"})]]}),(0,b.Ke)({on:"insert.child",guard:({snapshot:e})=>{let t=(0,v.qm)(e);return!!t&&!e.context.selection&&{lastBlockEndPoint:(0,p.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,v.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:` 5`})]]}),(0,b.Ke)({on:"insert.span",guard:({snapshot:e})=>!(0,v.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,v.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:o})=>[...o?[(0,b.xl)({type:"block.set",at:o.path,props:{markDefs:[...o.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,v.gR)(e),actions:[({event:e})=>[(0,b.xl)({type:"delete"}),(0,b.xl)(e)]]}),(0,b.Ke)({on:"insert.text",guard:({snapshot:e})=>
5{if(e.context.selection)return!1;let t=(0,v.qm)(e);return!!t&&{endPoint:(0,p.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)]]})],nZ=(0,K.mn)({default:[{key:"ArrowLeft",shift:!0,meta:!1,ctrl:!1,alt:!1}]}),nX=[(0,b.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nm.backspace.guard(t.originEvent)&&(0,v.WV)(e)&&(0,v.Rt)(e),actions:[()=>[(0,b.xl)({type:"delete.backward",unit:"character"})]]}),(0,b.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nm.delete.guard(t.originEvent)&&(0,v.WV)(e)&&(0,v.Rt)(e),actions:[()=>[(0,b.xl)({type:"delete.forward",unit:"character"})]]}),(0,b.Ke)({on:"keyboard.keydown",guard:({event:e})=>nm.deleteWord.backward.guard(e.originEvent),actions:[()=>[(0,b.xl)({type:"delete.backward",unit:"word"})]]}),(0,b.Ke)({on:"keyboard.keydown",guard:({event:e})=>nm.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})=>nm.break.guard(t.originEvent)&&(0,v.WV)(e)&&(0,v.Rt)(e),actions:[()=>[(0,b.xl)({type:"insert.break"})]]}),(0,b.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nm.break.guard(t.originEvent)&&(0,v.gR)(e),actions:[()=>[(0,b.xl)({type:"insert.break"})]]}),(0,b.Ke)({on:"keyboard.keydown",guard:({event:e})=>nm.lineBreak.guard(e.originEvent),actions:[()=>[(0,b.xl)({type:"insert.soft break"})]]}),(0,b.Ke)({on:"keyboard.keydown",guard:({event:e})=>nm.history.undo.guard(e.originEvent),actions:[()=>[(0,b.xl)({type:"history.undo"})]]}),(0,b.Ke)({on:"keyboard.keydown",guard:({event:e})=>nm.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||!nZ.guard(t.originEvent))return!1;let n=(0,v.gU)(e);if(!n)return!1;let o=(0,v.HA)({...e,context:{...e.context,selection:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}}});return!!(o&&(0,u.zS)(e.context,n.node)&&0===e.context.selection.focus.offset&&(0,h.wm)(e.context,n.node))&&{previousBlock:o,selection:e.context.selection}},actions:[({snapshot:e},{previousBlock:t,selection:n})=>[(0,b.xl)({type:"select",at:{anchor:n.anchor,focus:(0,p.J8)({context:e.context,block:t})}})]]})],n0=[(0,b.Ke)({on:"list item.add",guard:({snapshot:e,event:t})=>!!e.context.schema.lists.some(e=>e.name===t.listItem)&&{selectedTextBlocks:(0,v.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,v.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,v.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,v.oZ)(t.listItem)(e),actions:[({event:e})=>[(0,b.xl)({type:"list item.add",listItem:e.listItem})]]})],n1=[(0,b.Ke)({on:"move.block up",guard:({snapshot:e,event:t})=>{let n=(0,v.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,v.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})]]})],n2=[(0,b.Ke)({on:"select.block",guard:({snapshot:e,event:t})=>{if("end"!==t.select)return!1;let n=(0,v.gU)({...e,context:{...e.context,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}}});return!!n&&{blockEndPoint:(0,p.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,v.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,v.RL)(e);return!!t&&{nextBlock:t}},actions:[({event:e},{nextBlock:t})=>[(0,b.xl)({type:"select.block",at:t.path,select:e.select})]]})],n3=[(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}"`)}}]]})],n4=[(0,b.Ke)({on:"split",guard:({snapshot:e})=>(0,p.WV)(e.context.selection)&&(0,v.Rt)(e),actions:[]}),(0,b.Ke)({on:"split",guard:({snapshot:e})=>(0,p.WV)(e.context.selection)&&(0,v.lA)(e),actions:[]}),(0,b.Ke)({on:"split",guard:({snapshot:e})=>{let t=e.context.selection;if(!t||(0,p.WV)(t))return!1;let n=(0,p.Jo)(t),o=(0,p.aR)(t);if(!n||!o)return!1;let i=(0,v.GB)(e),r=(0,v.P$)(e);if(!i||!r)return!1;let a=(0,p.u3)({context:e.context,block:i}),l=(0,p.J8)({context:e.context,block:r});return!!((0,u.zS)(e.context,i.node)&&(0,u.zS)(e.context,r.node)&&!(0,p._Q)(n,a)&&!(0,p._Q)(o,l))},actions:[()=>[(0,b.xl)({type:"delete"}),(0,b.xl)({type:"split"})]]}),(0,b.Ke)({on:"split",guard:({snapshot:e})=>(0,v.gR)(e),actions:[()=>[(0,b.xl)({type:"delete"})]]}),(0,b.Ke)({on:"split",guard:({snapshot:e})=>{let t=e.context.selection;if(!t||!(0,p.WV)(t))return!1;let n=(0,p.Jo)(t),o=(0,v.hH)(e);if(!o)return!1;let i={anchor:n,focus:(0,p.J8)({context:e.context,block:o})},r=(0,p.rT)({block:(0,h.Bh)({context:{...e.context,selection:i},block:o.node}),context:e.context,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return!!r&&{newTextBlock:r,newTextBlockSelection:i}},actions:[(e,{newTextBlock:t,newTextBlockSelection:n})=>(0,p.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"})]]})],n6=[(0,b.Ke)({on:"style.add",guard:({snapshot:e})=>({selectedTextBlocks:(0,v.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,v.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,v.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})=>!(0,v.ER)(t.style)(e),actions:[({event:e})=>[(0,b.xl)({type:"style.add",style:e.style})]]})],n8=[(0,b.Ke)({on:"clipboard.copy",guard:({snapshot:e})=>{let t=(0,v.d2)(e),n=(0,v.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,v.d2)(e),n=(0,v.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,v.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})]]}),...nG,...nH,...nQ,...nY,...nW,...nq,...nX,...n0,...n1,...n6,...n2,...n3,...n4];function n5(e){return!on(e)&&!ot(e)&&!n9(e)}let n7=["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 n9(e){return n7.includes(e.type)}let oe=["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 ot(e){return oe.includes(e.type)}function on(e){return e.type.startsWith("custom.")}let oo=N("behaviors:event");function oi(e){return ot(e)?"native":n9(e)?"synthetic":on(e)?"custom"
5:"synthetic"}let or=N("editor machine");function oa({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 ol=(0,f.mj)({types:{context:{},events:{},emitted:{},input:{},tags:{}},actions:{"add behavior to context":(0,y.a)({behaviors:({context:e,event:t})=>((0,f.DT)(t,"add behavior"),new Set([...e.behaviors,t.behaviorConfig])),behaviorsSorted:!1}),"remove behavior from context":(0,y.a)({behaviors:({context:e,event:t})=>((0,f.DT)(t,"remove behavior"),e.behaviors.delete(t.behaviorConfig),new Set([...e.behaviors]))}),"add slate editor to context":(0,y.a)({slateEditor:({context:e,event:t})=>"add slate editor"===t.type?t.editor:e.slateEditor}),"emit patch event":(0,k.a)(({event:e})=>((0,f.DT)(e,"internal.patch"),e)),"emit mutation event":(0,k.a)(({event:e})=>((0,f.DT)(e,"mutation"),e)),"emit read only":(0,k.a)({type:"read only"}),"emit editable":(0,k.a)({type:"editable"}),"defer event":(0,y.a)({pendingEvents:({context:e,event:t})=>((0,f.DT)(t,["internal.patch","mutation"]),[...e.pendingEvents,t])}),"emit pending events":(0,k.e)(({context:e,enqueue:t})=>{for(let n of e.pendingEvents)t.emit(n)}),"emit ready":(0,k.a)({type:"ready"}),"clear pending events":(0,y.a)({pendingEvents:[]}),"defer incoming patches":(0,y.a)({pendingIncomingPatchesEvents:({context:e,event:t})=>"patches"===t.type?[...e.pendingIncomingPatchesEvents,t]:e.pendingIncomingPatchesEvents}),"emit pending incoming patches":(0,k.e)(({context:e,enqueue:t})=>{for(let n of e.pendingIncomingPatchesEvents)t.emit(n)}),"clear pending incoming patches":(0,y.a)({pendingIncomingPatchesEvents:[]}),"handle blur":({event:e})=>{(0,f.DT)(e,"blur");try{s.rL.blur(e.editor)}catch(e){console.error(Error(`Failed to blur editor: ${e.message}`))}},"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;s.rL.focus(t),e&&(l.gB.select(t,e),d.hK.set(t,t.selection),t.onChange())}catch(e){console.error(Error(`Failed to focus editor: ${e.message}`))}},"handle behavior event":({context:e,event:t,self:n})=>{(0,f.DT)(t,["behavior event"]);try{let o=[...e.behaviors.values()].map(e=>e.behavior);!function e({mode:t,behaviors:n,remainingEventBehaviors:o,event:i,editor:r,keyGenerator:a,schema:s,getSnapshot:c,nativeEvent:d,sendBack:u}){"send"!==t||ot(i)||(r.undoStepId=(0,p.OL)()),oo(`(${t}:${oi(i)})`,JSON.stringify(i,null,2));let h=[...o,...n8].filter(e=>{if("*"===e.on)return!0;let[t]=e.on.includes("*")&&e.on.includes(".")?e.on.split("."):[void 0],[n]=i.type.includes(".")?i.type.split("."):[void 0];return void 0!==t&&void 0!==n&&t===n||void 0!==t&&void 0===n&&t===i.type||e.on===i.type});if(0===h.length&&n5(i)){d?.preventDefault(),"send"===t&&(r.undoStepId=void 0),nU(r,()=>{oo(`(execute:${oi(i)})`,JSON.stringify(i,null,2)),tq({context:{keyGenerator:a,schema:s},operation:{...i,editor:r}})}),r.onChange();return}let f=c(),y=!1,g=!1,m=-1;for(let b of h){m++;let x=!1;try{x=void 0===b.guard||b.guard({snapshot:f,event:i,dom:nu(u,r)})}catch(e){console.error(Error(`Evaluating guard for "${i.type}" failed due to: ${e.message}`))}if(!x)continue;g=!0,0===b.actions.length&&(y=!0);let _=-1;for(let f of b.actions){var k,v;_++;let g=c(),b=[];try{b=f({snapshot:g,event:i,dom:nu(u,r)},x)}catch(e){console.error(Error(`Evaluating actions for "${i.type}" failed due to: ${e.message}`))}if(0===b.length)continue;y=b.some(e=>"raise"===e.type||"execute"===e.type)||!b.some(e=>"forward"===e.type);let E=!1;_>0&&(r.undoStepId=(0,p.OL)(),E=!0),!E&&b.some(e=>"execute"===e.type)&&(r.undoStepId=(0,p.OL)(),E=!0);let w=b.map(e=>e.type),S=new Set(w),B=w.length>1&&1===S.size&&S.has("raise"),K=w.length>1&&1===S.size&&S.has("execute");k=()=>B||K,v=()=>{for(let l of b){if("effect"===l.type){try{l.effect({send:u})}catch(e){console.error(Error(`Executing effect as a result of "${i.type}" failed due to: ${e.message}`))}continue}if("forward"===l.type){e({mode:"execute"===t?"execute":"forward",behaviors:n,remainingEventBehaviors:h.slice(m+1),event:l.event,editor:r,keyGenerator:a,schema:s,getSnapshot:c,nativeEvent:d,sendBack:u});continue}if("raise"===l.type){e({mode:"execute"===t?"execute":"raise",behaviors:n,remainingEventBehaviors:"execute"===t?o:n,event:l.event,editor:r,keyGenerator:a,schema:s,getSnapshot:c,nativeEvent:d,sendBack:u});continue}e({mode:"execute",behaviors:n,remainingEventBehaviors:[],event:l.event,editor:r,keyGenerator:a,schema:s,getSnapshot:c,nativeEvent:void 0,sendBack:u})}},k()?l.KE.withoutNormalizing(r,v):v(),E&&(r.undoStepId=void 0)}break}!g&&n5(i)?(d?.preventDefault(),"send"===t&&(r.undoStepId=void 0),nU(r,()=>{oo(`(execute:${oi(i)})`,JSON.stringify(i,null,2)),tq({context:{keyGenerator:a,schema:s},operation:{...i,editor:r}})}),r.onChange()):y&&d?.preventDefault()}({mode:"send",behaviors:o,remainingEventBehaviors:o,event:t.behaviorEvent,editor:t.editor,keyGenerator:e.keyGenerator,schema:e.schema,getSnapshot:()=>(function({converters:e,editor:t,keyGenerator:n,readOnly:o,schema:i}){let r=t.selection?W({schema:i,editor:t,range:t.selection}):null,a={converters:e,keyGenerator:n,readOnly:o,schema:i,selection:r,value:t.value};return{blockIndexMap:t.blockIndexMap,context:a,decoratorState:t.decoratorState}})({converters:[...e.converters],editor:t.editor,keyGenerator:e.keyGenerator,readOnly:n.getSnapshot().matches({"edit mode":"read only"}),schema:e.schema}),nativeEvent:t.nativeEvent,sendBack:e=>{if("set drag ghost"===e.type)return void n.send(e);n.send(oa({event:e,slateEditor:t.editor}))}})}catch(e){console.error(Error(`Raising "${t.behaviorEvent.type}" failed due to: ${e.message}`))}},"sort behaviors":(0,y.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 o=new Map(t.map(e=>[e.priority.id,e])),i=new Map,r=new Map;function a(e){i.has(e)||(i.set(e,new Set),r.set(e,0))}for(let e of t)a(e.priority.id);function l(e,t){i.has(e)&&i.has(t)&&(i.get(e)?.add(t),r.set(t,(r.get(t)??0)+1))}for(let e of t){let t=e.priority.id,n=new Set,o=e.priority.reference;for(;o;){let e=o.priority.id;if(a(e),n.has(e))throw Error("Circular dependency detected in priorities");n.add(e),"higher"===o.importance?l(t,e):l(e,t),o=o.priority.reference}}let s=[];for(let[e,t]of r)0===t&&s.push(e);let c=[];for(;s.length>0;){let e=s.shift(),t=o.get(e);
5for(let n of(t&&c.push(t),i.get(e)??[])){let e=(r.get(n)??0)-1;r.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})},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(nV),behaviorsSorted:!1,converters:new Set(e.converters??[]),getLegacySchema:e.getLegacySchema,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,y.a)({selection:({event:e})=>e.selection}),(0,k.a)(({event:e})=>({...e,type:"selection"}))]},"set drag ghost":{actions:(0,y.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:[()=>{or("entry: edit mode->read only->determine initial edit mode")}],exit:[()=>{or("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:[()=>{or("entry: edit mode->read only->read only")}],exit:[()=>{or("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,y.a)({slateEditor:({event:e})=>e.editor})]}},initial:"idle",states:{idle:{entry:[()=>{or("entry: edit mode->editable->idle")}],exit:[()=>{or("exit: edit mode->editable-idle")}],on:{dragstart:{actions:[(0,y.a)({internalDrag:({event:e})=>({origin:e.origin})})],target:"dragging internally"}}},focusing:{initial:"checking if busy",states:{"checking if busy":{entry:[()=>{or("entry: edit mode->editable->focusing->checking if busy")}],exit:[()=>{or("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:[()=>{or("entry: edit mode->editable->focusing-busy")}],exit:[()=>{or("exit: edit mode->editable->focusing->busy")}],after:{10:{target:"checking if busy"}}}}},"dragging internally":{entry:[()=>{or("entry: edit mode->editable->dragging internally")}],exit:[()=>{or("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.message}`))}},(0,y.a)({dragGhost:void 0}),(0,y.a)({internalDrag:void 0})],tags:["dragging internally"],on:{dragend:{target:"idle"},drop:{target:"idle"}}}}}}},setup:{initial:"setting up",states:{"setting up":{entry:[()=>{or("entry: setup->setting up")}],exit:[()=>{or("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:[()=>{or("entry: setup->set up->value sync->idle")}],exit:[()=>{or("exit: setup->set up->value sync->idle")}],on:{patches:{actions:[(0,k.a)(({event:e})=>e)]},"syncing value":{target:"syncing value"}}},"syncing value":{entry:[()=>{or("entry: setup->set up->value sync->syncing value")}],exit:[()=>{or("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:[()=>{or("entry: setup->set up->writing->pristine->idle")}],exit:[()=>{or("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"}]}}}},dirty:{entry:[()=>{or("entry: setup->set up->writing->dirty")},"emit pending events","clear pending events"],exit:[()=>{or("exit: setup->set up->writing->dirty")}],on:{"internal.patch":{actions:"emit patch event"},mutation:{actions:"emit mutation event"}}}}}}}}}}}),os=N("mutation-machine"),oc=(0,f.mj)({types:{context:{},events:{},input:{},emitted:{}},actions:{"assign readOnly":(0,y.a)({readOnly:({context:e,event:t})=>"update readOnly"===t.type?t.readOnly:e.readOnly}),"emit patch":(0,k.a)(({event:e})=>((0,f.DT)(e,"patch"),{type:"patch",patch:e.patch})),"emit has pending mutations":(0,k.a)({type:"has pending mutations"}),"emit mutations":(0,k.e)(({context:e,enqueue:t})=>{for(let n of e.pendingMutations)t.emit({type:"mutation",patches:n.patches,snapshot:n.value})}),"clear pending mutations":(0,y.a)({pendingMutations:[]}),"defer mutation":(0,y.a)({pendingMutations:({context:e,event:t})=>{if((0,f.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,y.a)({pendingPatchEvents:[]}),"defer patch":(0,y.a)({pendingPatchEvents:({context:e,event:t})=>"patch"===t.type?[...e.pendingPatchEvents,t]:e.pendingPatchEvents}),"emit pending patch events":(0,k.e)(({context:e,enqueue:t})=>{for(let n of e.pendingPatchEvents)t.emit(n)})},actors:{"type listener":(0,g.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,g.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})=>l.KE.isNormalizing(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:[()=>{os("entry: typing->idle")}],exit:[()=>{os("exit: typing->idle"),os("entry: typing->typing")}],on:{typing:{target:"typing"}}},typing:{after:{"type debounce":{target:"idle",actions:[(0,m.r)({type:"emit changes"}),()=>{os("exit: typing->typing")}]}},on:{"not typing":{target:"idle",actions:[(0,m.r)({type:"emit changes"})]}
5,typing:{target:"typing",reenter:!0}}}}},mutations:{initial:"idle",states:{idle:{entry:[()=>{os("entry: mutations->idle")}],exit:[()=>{os("exit: mutations->idle")}],on:{patch:[{guard:"is read-only",actions:["defer patch","defer mutation"],target:"has pending mutations"},{actions:["emit patch","defer mutation"],target:"has pending mutations"}]}},"has pending mutations":{entry:[()=>{os("entry: mutations->has pending mutations")},"emit has pending mutations"],exit:[()=>{os("exit: mutations->has pending mutations")}],invoke:{src:"mutation interval"},on:{"emit changes":{guard:(0,m.j)([(0,m.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"]}]}}}}}}),od=(0,f.mj)({types:{context:{},events:{},emitted:{}}}).createMachine({id:"relay",context:{prevSelection:null,lastEventWasFocused:!1},on:{focused:{actions:[(0,y.a)({lastEventWasFocused:!0}),(0,k.a)(({event:e})=>e)]},selection:[{guard:({context:e})=>e.lastEventWasFocused,actions:[(0,y.a)({prevSelection:({event:e})=>e.selection}),(0,k.a)(({event:e})=>e),(0,y.a)({lastEventWasFocused:!1})]},{guard:({context:e,event:t})=>e.prevSelection!==t.selection,actions:[(0,y.a)({prevSelection:({event:e})=>e.selection}),(0,k.a)(({event:e})=>e),(0,y.a)({lastEventWasFocused:!1})]}],"*":{actions:[(0,k.a)(({event:e})=>e),(0,y.a)({lastEventWasFocused:!1})]}}});function op(e,t,n){let o=null,i=!0,r=[t.span.name,...t.inlineObjects.map(e=>e.name)],a=[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 o={patches:[(0,B.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 o={patches:[(0,B.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||!a.includes(e._type)){if("block"===e._type){let n=t.block.name;return o={patches:[(0,B.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 o=!e._type&&(0,u.zS)({schema:t},{...e,_type:t.block.name})?{patches:[(0,B.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,B.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,B.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.invalid-value.missing-type.action",values:{key:e._key}}},!0}if(e._type===t.block.name){if(e.children&&!Array.isArray(e.children))return o={patches:[(0,B.hZ)({children:[]},[{_key:e._key}])],description:`Text block with _key '${e._key}
5' 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 i={_type:t.span.name,_key:n(),text:"",marks:[]};return o={autoResolve:!0,patches:[(0,B.Wm)([],[{_key:e._key},"children"]),(0,B.Yr)([i],"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 a=[...new Set(e.children.filter(e=>(0,u.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=>!a.includes(e)))];if(t.length>0)return o={autoResolve:!0,patches:t.map(t=>(0,B.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=a.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 o={autoResolve:!0,patches:n.map(t=>(0,B.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((i,a)=>{if("object"!=typeof i||null===i)return o={patches:[(0,B.wC)([{_key:e._key},"children",a])],description:`Child at index '${a}' 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:a}}},!0;if(!i._key||"string"!=typeof i._key){let t={...i,_key:n()};return o={autoResolve:!0,patches:[(0,B.hZ)(t,[{_key:e._key},"children",a])],description:`Child at index ${a} 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:a}}},!0}return i._type?r.includes(i._type)?i._type===t.span.name&&"string"!=typeof i.text&&(o={patches:[(0,B.hZ)({...i,text:""},[{_key:e._key},"children",{_key:i._key}])],description:`Child with _key '${i._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
5d-span-text.description",action:"inputs.portable-text.invalid-value.invalid-span-text.action",values:{key:e._key,childKey:i._key}}},!0):(o={patches:[(0,B.wC)([{_key:e._key},"children",{_key:i._key}])],description:`Child with _key '${i._key}' in block with key '${e._key}' has invalid '_type' property (${i._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:i._key,childType:i._type}}},!0):(o={patches:[(0,B.wC)([{_key:e._key},"children",{_key:i._key}])],description:`Child with _key '${i._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:i._key}}},!0)})&&(i=!1)}return!1})&&(i=!1),{valid:i,resolution:o,value:e}):{valid:!1,resolution:{patches:[(0,B.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 ou=N("sync machine"),oh=(0,g.SP)(({sendBack:e,input:t})=>{oy({context:t.context,sendBack:e,slateEditor:t.slateEditor,value:t.value,streamBlocks:t.streamBlocks})}),of=(0,f.mj)({types:{context:{},input:{},events:{},emitted:{}},actions:{"assign initial value synced":(0,y.a)({initialValueSynced:!0}),"assign readOnly":(0,y.a)({readOnly:({event:e})=>((0,f.DT)(e,"update readOnly"),e.readOnly)}),"assign pending value":(0,y.a)({pendingValue:({event:e})=>((0,f.DT)(e,"update value"),e.value)}),"clear pending value":(0,y.a)({pendingValue:void 0}),"assign previous value":(0,y.a)({previousValue:({event:e})=>((0,f.DT)(e,"done syncing"),e.value)}),"emit done syncing value":(0,k.a)({type:"done syncing value"}),"emit syncing value":(0,k.a)({type:"syncing value"})},guards:{"initial value synced":({context:e})=>e.initialValueSynced,"is busy":({context:e})=>{let t=e.isProcessingLocalChanges,n=e.slateEditor.isProcessingRemoteChanges??!1,o=t||n;return ou("isBusy",{isBusy:o,isProcessingLocalChanges:t,isChanging:n}),o},"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,"value changed while syncing":({context:e,event:t})=>((0,f.DT)(t,"done syncing"),e.pendingValue!==t.value),"pending value equals previous value":({context:e})=>D({schema:e.schema},e.pendingValue,e.previousValue)},actors:{"sync value":oh}}).createMachine({id:"sync",context:({input:e})=>({initialValue:e.initialValue,initialValueSynced:!1,isProcessingLocalChanges:!1,keyGenerator:e.keyGenerator,schema:e.schema,readOnly:e.readOnly,slateEditor:e.slateEditor,pendingValue:void 0,previousValue:void 0}),entry:[(0,m.r)(({context:e})=>({type:"update value",value:e.initialValue}))],on:{"has pending mutations":{actions:(0,y.a)({isProcessingLocalChanges:!0})},mutation:{actions:(0,y.a)({isProcessingLocalChanges:!1})},"update readOnly":{actions:["assign readOnly"]}},initial:"idle",states:{idle:{entry:[()=>{ou("entry: syncing->idle")}],exit:[()=>{ou("exit: syncing->idle")}],on:{"update value":[{guard:(0,m.j)(["is empty value",(0,m.n)("initial value synced")]),actions:["assign initial value synced","emit done syncing value"]},{guard:(0,m.j)(["is empty array",(0,m.n)("initial value synced")]),actions:["assign initial value synced",(0,k.a)({type:"value changed",value:[]}),"emit done syncing value"]},{guard:(0,m.j)(["is busy","is new value"]),target:"busy",actions:["assign pending value"]},{guard:"is new value",target:"syncing",actions:["assign pending value"]},{guard:(0,m.n)("initial value synced"),actions:[()=>{ou("no new value – setting initial value as synced")},"assign initial value synced","emit done syncing value"]},{actions:[()=>{ou("no new value and initial value already synced")}]}]}},busy:{entry:[()=>{ou("entry: syncing->busy")}],exit:[()=>{ou("exit: syncing->busy")}
5],after:{1e3:[{guard:"is busy",target:".",reenter:!0,actions:[()=>{ou("reenter: syncing->busy")}]},{target:"syncing"}]},on:{"update value":[{guard:"is new value",actions:["assign pending value"]}]}},syncing:{entry:[()=>{ou("entry: syncing->syncing")},"emit syncing value"],exit:[()=>{ou("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,k.a)(({event:e})=>e)]},"invalid value":{actions:[(0,k.a)(({event:e})=>e)]},"value changed":{actions:[(0,k.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 oy({context:e,sendBack:t,slateEditor:n,streamBlocks:o,value:i}){let r=!1,a=!1,s=!0,c=!!n.selection;if(i&&0!==i.length||(ou("Value is empty"),function({slateEditor:e,doneSyncing:t}){l.KE.withoutNormalizing(e,()=>{ti(e,()=>{t8(e,()=>{t2(e,()=>{if(t)return;let n=e.children.length;e.children.forEach((t,o)=>{l.gB.removeNodes(e,{at:[n-1-o]})})})})})})}({slateEditor:n,doneSyncing:r}),a=!0),i&&i.length>0)if(o)await new Promise(o=>{if(r)return void o();a=om({slateEditor:n,value:i}),(async()=>{for await(let[o,r]of og({value:i})){let{blockChanged:l,blockValid:c}=ok({context:e,sendBack:t,block:o,index:r,slateEditor:n,value:i});if(a=l||a,!(s=s&&c))break}o()})()});else{if(r)return;a=om({slateEditor:n,value:i});let o=0;for(let r of i){let{blockChanged:l,blockValid:c}=ok({context:e,sendBack:t,block:r,index:o,slateEditor:n,value:i});if(a=l||a,s=s&&c,!c)break;o++}}if(!s){ou("Invalid value, returning"),r=!0,t({type:"done syncing",value:i});return}if(a){ou("Server value changed, syncing editor");try{n.onChange()}catch(e){console.error(e),t({type:"invalid value",resolution:null,value:i}),r=!0,t({type:"done syncing",value:i});return}c&&!n.selection&&(l.gB.select(n,{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0}}),n.onChange()),t({type:"value changed",value:i})}else ou("Server value and editor value is equal, no need to sync.");r=!0,t({type:"done syncing",value:i})}async function*og({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 om({slateEditor:e,value:t}){let n=!1;return l.KE.withoutNormalizing(e,()=>{t8(e,()=>{t2(e,()=>{let o=e.children.length;if(t.length<o){for(let n=o-1;n>t.length-1;n--)l.gB.removeNodes(e,{at:[n]});n=!0}})})}),n}function ok({context:e,sendBack:t,block:n,index:o,slateEditor:i,value:r}){let a=i.children.at(o);if(!a){let a=op([n],e.schema,e.keyGenerator);if(ou.enabled&&ou("Validating and inserting new block in the end of the value",n),a.valid||a.resolution?.autoResolve){let t=L(n,{schemaTypes:e.schema});return l.KE.withoutNormalizing(i,()=>{t8(i,()=>{t2(i,()=>{l.gB.insertNodes(i,t,{at:[o]})})})}),{blockChanged:!0,blockValid:!0}}return ou("Invalid",a),t({type:"invalid value",resolution:a.resolution,value:r}),{blockChanged:!1,blockValid:!1}}if(P(e,n,a))return{blockChanged:!1,blockValid:!0};let s=[r[o]],c=op(s,e.schema,e.keyGenerator);return!c.valid&&c.resolution?.autoResolve&&c.resolution?.patches.length>0&&!e.readOnly&&e.previousValue&&e.previousValue!==r&&(console.warn(`${c.resolution.action} for block with _key '${s[0]._key}'. ${c.resolution?.description}`),c.resolution.patches.forEach(e=>{t({type:"patch",patch:e})})),c.valid||c.resolution?.autoResolve?(a._key===n._key&&a._type===n._type?(ou.enabled&&ou("Updating block",a,n),l.KE.withoutNormalizing(i,()=>{t8(i,()=>{t2(i,()=>{!function({context:e,slateEditor:t,oldBlock:n,block:o,index:i}){let r=L(o,{schemaTypes:e.schema});if(l.gB.setNodes(t,r,{at:[i]}),t.isTextBlock(r)&&t.isTextBlock(n)){let o=n.children.length;r.children.length<o&&Array.from(Array(o-r.children.length)).forEac
5h((e,n)=>{let i=o-1-n;i>0&&(ou("Removing child"),l.gB.removeNodes(t,{at:[n,i]}))}),r.children.forEach((o,r)=>{let a=n.children.at(r),s=!a||!z(o,a),c=a&&l.EY.isText(a)&&o.text!==a.text,d=[i,r];if(s)if(o._key===a?._key&&o._type===a?._type){ou("Updating changed child",o,a),l.gB.setNodes(t,o,{at:d});let n=(0,u.bl)({schema:e.schema},o)&&(0,u.bl)({schema:e.schema},a);n&&c?(a.text.length>0&&(0,l.JG)(t,{at:{focus:{path:d,offset:0},anchor:{path:d,offset:a.text.length}}}),l.gB.insertText(t,o.text,{at:d}),t.onChange()):n||(ou("Updating changed inline object child",o),l.gB.setNodes(t,{_key:$},{at:[...d,0],voids:!0}))}else a?(ou("Replacing child",o),l.gB.removeNodes(t,{at:[i,r]}),l.gB.insertNodes(t,o,{at:[i,r]}),t.onChange()):a||(ou("Inserting new child",o),l.gB.insertNodes(t,o,{at:[i,r]}),t.onChange())})}}({context:e,slateEditor:i,oldBlock:a,block:n,index:o})})})})):(ou.enabled&&ou("Replacing block",a,n),l.KE.withoutNormalizing(i,()=>{t8(i,()=>{t2(i,()=>{!function({context:e,slateEditor:t,block:n,index:o}){let i=L(n,{schemaTypes:e.schema}),r=t.selection,a=r&&r.focus.path[0]===o;a&&l.gB.deselect(t),l.gB.removeNodes(t,{at:[o]}),l.gB.insertNodes(t,i,{at:[o]}),t.onChange(),a&&l.gB.select(t,r)}({context:e,slateEditor:i,block:n,index:o})})})})),{blockChanged:!0,blockValid:!0}):(t({type:"invalid value",resolution:c.resolution,value:r}),{blockChanged:!1,blockValid:!1})}let ov=N("setup");function ob(e){ov("Creating new Editor instance");let t=[],n=(0,m.c)(ol,{input:function(e){let{legacySchema:t,schema:n}=function(e){var t;let n=e.schemaDefinition?(0,x.P$)(e.schemaDefinition):(0,x.rV)(e.schema.hasOwnProperty("jsonType")?e.schema:(t=e.schema,S.Sj.compile({name:"blockTypeSchema",types:[t]}).get(t.name))),o=e.schemaDefinition?(0,u.Fc)(e.schemaDefinition):(0,x.LI)(n);return{legacySchema:n,schema:o}}(e);return{converters:[e6,e8,e5,{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,v.lN)(e),o=(0,E.FE)(n,{onMissingComponent:!1,components:{unknownType:({children:e})=>void 0!==e?`${e}`:""}});return""===o?{type:"serialization.failure",mimeType:"text/html",originEvent:t.originEvent,reason:"Serialized HTML is empty"}:{type:"serialization.success",data:o,mimeType:"text/html",originEvent:t.originEvent}},deserialize:({snapshot:e,event:n})=>{let o=(0,_.l$)(n.data,t.portableText,{keyGenerator:e.context.keyGenerator,unstable_whitespaceOnPasteMode:t.block.options.unstable_whitespaceOnPasteMode}).flatMap(t=>{let n=(0,p.rT)({context:e.context,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return n?[n]:[]});return 0===o.length?{type:"deserialization.failure",mimeType:"text/html",reason:"No blocks deserialized"}:{type:"deserialization.success",data:o,mimeType:"text/html"}}},{mimeType:"text/plain",serialize:({snapshot:e,event:t})=>e.context.selection?{type:"serialization.success",data:(0,v.lN)(e).map(n=>(0,u.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(` 6 7`),mimeType:"text/plain",originEvent:t.originEvent}:{type:"serialization.failure",mimeType:"text/plain",originEvent:t.originEvent,reason:"No selection"},deserialize:({snapshot:e,event:n})=>{let o=`<html><body>${String(n.data).replace(/[&<>"'`=/]/g,e=>e7[e]).split(/\n{2,}/).map(e=>e?`<p>${e.replace(/(?:\r\n|\r|\n)/g,"<br/>")}</p>`:"<p></p>").join("")}</body></html>`,i=(0,_.l$)(o,t.portableText,{keyGenerator:e.context.keyGenerator}).flatMap(t=>{let n=(0,p.rT)({context:e.context,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return n?[n]:[]});return 0===i.length?{type:"deserialization.failure",mimeType:"text/plain",reason:"No blocks deserialized"}:{type:"deserialization.success",data:i,mimeType:"text/plain"}}}],getLegacySchema:()=>t,keyGenerator:e.keyGenerator??p.OL,readOnly:e.readOnly,schema:n,initialValue:e.initialValue}}(e)}),o=(0,m.c)(od),i=function(e){np("Creating new Slate editor instance");let t=tt(e.editorActor.getSnapshot().context),n=(0,l.ie)();n.decoratedRanges=[],n.decoratorState={},n.blockIndexMap=new Map,n.history={undos:[],redos:[]},n.lastSelection=null,n.lastSlateSelection=null,n.listIndexMap=new Map,n.remotePatches=[],n.undoStepId=void 0,n.value=[t],n.isNormalizingNode=!1,n.isPatching=!0,n.isPerformingBehaviorOperation=!1,n.isProcessingRemoteChanges=!1,n.isRedoing=!1,n.isUndoing=!1,n.withHistory=!0;let o=((e,t)=>{var n,o,i;let{editorActor:r,relayActor:a}=t,s=(n=r,function(e){let{apply:t,normalizeNode:o}=e;return e.apply=o=>
7{if(e.isProcessingRemoteChanges||e.isUndoing||e.isRedoing)return void t(o);if("split_node"===o.type){let i=[...l.bP.descendants(e)].map(([e])=>e._key);t({...o,properties:{...o.properties,_key:void 0===o.properties._key||i.includes(o.properties._key)?n.getSnapshot().context.keyGenerator():o.properties._key}});return}if("insert_node"===o.type&&!l.KE.isEditor(o.node)){let i=[...l.bP.descendants(e)].map(([e])=>e._key);t({...o,node:{...o.node,_key:void 0===o.node._key||i.includes(o.node._key)?n.getSnapshot().context.keyGenerator():o.node._key}});return}if("merge_node"===o.type){let i=o.path[o.path.length-1],r=l.wA.previous(o.path),a=r[r.length-1];if(1!==o.path.length||1!==r.length)return void t(o);let s=e.value.at(i),c=e.value.at(a);if(!s||!c||!(0,u.zS)(n.getSnapshot().context,s)||!(0,u.zS)(n.getSnapshot().context,c))return void t(o);let d=c.children.map(e=>e._key),p=c.markDefs?.map(e=>e._key)??[],h=new Map,f=s.markDefs?.map(e=>{if(p.includes(e._key)){let t=n.getSnapshot().context.keyGenerator();return h.set(e._key,t),{...e,_key:t}}return e}),y=0;for(let t of s.children){if((0,u.bl)(n.getSnapshot().context,t)){let n=t.marks?.map(e=>h.get(e)||e)??[];C(t.marks,n)||l.gB.setNodes(e,{marks:n},{at:[i,y]})}d.includes(t._key)&&l.gB.setNodes(e,{_key:n.getSnapshot().context.keyGenerator()},{at:[i,y]}),y++}return void t({...o,properties:{...o.properties,markDefs:f}})}t(o)},e.normalizeNode=t=>{let[i,r]=t;if(l.Hg.isElement(i)){let[t]=l.KE.parent(e,r);if(t&&l.KE.isEditor(t)){let o=new Set;for(let i of t.children){if(i._key&&o.has(i._key)||!i._key){let t=n.getSnapshot().context.keyGenerator();o.add(t),t1(e,()=>{l.gB.setNodes(e,{_key:t},{at:r})});return}o.add(i._key)}}}if(l.Hg.isElement(i)&&i._type===n.getSnapshot().context.schema.block.name){if(!i._key)return void t1(e,()=>{l.gB.setNodes(e,{_key:n.getSnapshot().context.keyGenerator()},{at:r})});let t=new Set;for(let[o,i]of l.bP.children(e,r)){if(o._key&&t.has(o._key)||!o._key){let o=n.getSnapshot().context.keyGenerator();t.add(o),t1(e,()=>{l.gB.setNodes(e,{_key:o},{at:i})});return}t.add(o._key)}}t1(e,()=>{o(t)})},e}),c=function({editorActor:e}){return function(t){t.isTextBlock=t=>!l.KE.isEditor(t)&&(0,u.zS)(e.getSnapshot().context,t),t.isTextSpan=t=>!l.KE.isEditor(t)&&(0,u.bl)(e.getSnapshot().context,t),t.isListBlock=t=>!l.KE.isEditor(t)&&(0,p.Eg)(e.getSnapshot().context,t),t.isVoid=t=>!l.KE.isEditor(t)&&e.getSnapshot().context.schema.block.name!==t._type&&(e.getSnapshot().context.schema.blockObjects.map(e=>e.name).includes(t._type)||e.getSnapshot().context.schema.inlineObjects.map(e=>e.name).includes(t._type)),t.isInline=t=>!l.KE.isEditor(t)&&e.getSnapshot().context.schema.inlineObjects.map(e=>e.name).includes(t._type)&&"__inline"in t&&!0===t.__inline;let{normalizeNode:n}=t;return t.normalizeNode=o=>{let[i,r]=o;if(void 0===i._type&&2===r.length){t7("Setting span type on text node without a type");let n=i._key||e.getSnapshot().context.keyGenerator();t1(t,()=>{l.gB.setNodes(t,{...i,_type:e.getSnapshot().context.schema.span.name,_key:n},{at:r})});return}if(void 0===i._key&&(1===r.length||2===r.length)){t7("Setting missing key on child node without a key");let n=e.getSnapshot().context.keyGenerator();t1(t,()=>{l.gB.setNodes(t,{_key:n},{at:r})});return}t1(t,()=>{n(o)})},t}}({editorActor:r}),d=function({editorActor:e,relayActor:t,subscriptions:n}){var o;let i,r=(o=e.getSnapshot().context,(e,t)=>{let n=!1;try{switch(t.type){case"insert":n=function(e,t,n){let o=t4(t.children,n.path);if(!o){if(1===n.path.length&&0===n.path[0]){let o=n.items.map(t=>L(t,{schemaTypes:e.schema}));return l.gB.insertNodes(t,o,{at:[0]}),!0}return!1}if(n.path.length>1&&"children"!==n.path[1])return!1;if(1===n.path.length){let{items:i,position:r}=n,a=i.map(t=>L(t,{schemaTypes:e.schema})),s=o.index,c="after"===r?s+1:s,d=U(e.initialValue,t.value,e.schema);return l.gB.insertNodes(t,a,{at:[c]}),d&&"number"==typeof n.path[0]&&0===n.path[0]&&l.gB.removeNodes(t,{at:["before"===r?s+a.length:s]}),!0}let{items:i,position:r}=n,a=t6(o,n.path);if(!a)return!1;let s=L({...o.node,children:i},{schemaTypes:e.schema}),c="after"===r?a.index+1:a.index,d=[o.index,c];return s&&l.Hg.isElement(s)&&l.gB.insertNodes(t,s.children,{at:d}),!0}(o,e,t);break;case"unset":n=function(e,t){if(0===t.path.length){for(let[t,n]of(l.gB.deselect(e),l.bP.children(e,[],{reverse:!0})))l.gB.removeNodes(e,{at:n});return!0}let n=t4(e.children,t.path);if(!n)return!1;if(1===t.path.length)return l.gB.removeNodes(e,{at:[n.index]}),!0;let o=t6(n,t.path);if(e.isTextBlock(n.node)&&o&&"children"===t.path[1]&&3===t.path.length)return l.gB.removeNodes(e,{at:[n.index,o.index]}),!0;if(o&&!l.EY.isText(o.node)){let i=t.path.slice(3).at(0);if(void 0===i||"string"==typeof i&&["_key","_type","children","__inline"].includes(i))return!1;let r="value"in o.node&&"object"==typeof o.node.value?o.node.value:{},a=(0,B.yl)(r,[{...t,path:t.path.slice(3)}]);return l.gB.setNodes(e,{...o.node,value:a},{at:[n.index,o.index]}),!0}if(o&&l.EY.isText(o.node)){let i=t.path.slice(3),r=i.at(0);if(void 0===r||"string"==typeof r&&["_key","_type"].includes(r))return!1;if("string"==typeof r&&"text"===r)return e.apply({type:"remove_text",path:[n.index,o.index],offset:0,text:o.node.text}),!0;let a=Object.keys((0,B.yl)(o.node,[{...t,path:i}])),s=Object.keys(o.node).filter(e=>!a.includes(e));return l.gB.unsetNodes(e,s,{at:[n.index,o.index]}),!0}if(!o&&"value"in n.node){let o=(0,B.yl)(n.node.value,[{...t,path:t.path.slice(1)}]);return l.gB.setNodes(e,{...n.node,value:o},{at:[n.index]}),!0}return!1}(e,t);break;case"set":n=function(e,t){let n=t.value;"string"==typeof t.path[3]&&((n={})[t.path[3]]=t.value);let o=t4(e.children,t.path);if(!o)return!1;let i=e.isTextBlock(o.node);
7if(1===t.path.length){let n=(0,B.yl)(o.node,[{...t,path:t.path.slice(1)}]);if(!(e.isTextBlock(o.node)&&l.Hg.isElement(n)))return l.gB.setNodes(e,n,{at:[o.index]}),!0;{l.gB.setNodes(e,n,{at:[o.index]});let t=e.selection;for(let[t,n]of l.KE.nodes(e,{at:[o.index],reverse:!0,mode:"lowest"}))l.gB.removeNodes(e,{at:n});return l.gB.insertNodes(e,n.children,{at:[o.index,0]}),t&&(l.gB.setSelection(e,t),l.gB.select(e,t)),!0}}if(i&&"children"!==t.path[1]){let n=(0,B.yl)(o.node,[{...t,path:t.path.slice(1)}]);return l.gB.setNodes(e,n,{at:[o.index]}),!0}let r=t6(o,t.path);if(i&&r)if(l.EY.isText(r.node))if(l.EY.isText(n)){let t=r.node.text,i=n.text;t!==i&&(e.apply({type:"remove_text",path:[o.index,r.index],offset:0,text:t}),e.apply({type:"insert_text",path:[o.index,r.index],offset:0,text:i}),e.onChange())}else{let n=t.path.slice(3),i=n.at(0);if(void 0===i||"string"==typeof i&&["_key","_type","text"].includes(i))return!1;let a=(0,B.yl)(r.node,[{...t,path:n}]);l.gB.setNodes(e,a,{at:[o.index,r.index]})}else{let n=t.path.slice(3).at(0);if(void 0===n||"string"==typeof n&&["_key","_type","children","__inline"].includes(n))return!1;let i="value"in r.node&&"object"==typeof r.node.value?r.node.value:{},a=(0,B.yl)(i,[{...t,path:t.path.slice(3)}]);l.gB.setNodes(e,{...r.node,value:a},{at:[o.index,r.index]})}else if(l.Hg.isElement(o.node)&&1===t.path.length){let{children:t,...i}=n,{children:r,...a}=o.node||{children:void 0};e.apply({type:"set_node",path:[o.index],properties:{...a},newProperties:i});let l=o.node;l.children.forEach((t,n)=>{e.apply({type:"remove_node",path:[o.index,l.children.length-1-n],node:t})}),Array.isArray(t)&&t.forEach((t,n)=>{e.apply({type:"insert_node",path:[o.index,n],node:t})})}else if(o&&"value"in o.node)if(!(t.path.length>1)||"children"===t.path[1])return!1;else{let n=(0,B.yl)(o.node.value,[{...t,path:t.path.slice(1)}]);l.gB.setNodes(e,{...o.node,value:n},{at:[o.index]})}return!0}(e,t);break;case"diffMatchPatch":n=function(e,t){let n=t4(e.children,t.path);if(!n)return!1;let o=t6(n,t.path);if(!o||!(n&&e.isTextBlock(n.node)&&4===t.path.length&&"children"===t.path[1]&&"text"===t.path[3])||!l.EY.isText(o.node))return!1;let[i]=function(e,t,n={}){if("string"==typeof e)throw Error("Patches must be an array - pass the patch to `parsePatch()` first");let o=t;if(0===e.length)return[o,[]];let i=function(e,t,n={}){let o=0,i=0;function r(e){for(;o<e;){let e=t.codePointAt(i);if(typeof e>"u")return i;o+=t$(e),e>65535?i+=2:i+=1}if(!n.allowExceedingIndices&&o!==e)throw Error("Failed to determine byte offset");return i}let a=[];for(let t of e)a.push({diffs:t.diffs.map(e=>tr(e)),start1:r(t.start1),start2:r(t.start2),utf8Start1:t.utf8Start1,utf8Start2:t.utf8Start2,length1:t.length1,length2:t.length2,utf8Length1:t.utf8Length1,utf8Length2:t.utf8Length2});return a}(e,o,{allowExceedingIndices:n.allowExceedingIndices}),r=n.margin||4,a=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 o=e[0],i=o.diffs;if(0===i.length||0!==i[0][0])i.unshift([0,n]),o.start1-=t,o.start2-=t,o.utf8Start1-=t,o.utf8Start2-=t,o.length1+=t,o.length2+=t,o.utf8Length1+=t,o.utf8Length2+=t;else if(t>i[0][1].length){let e=i[0][1].length,r=t-e;i[0][1]=n.substring(e)+i[0][1],o.start1-=r,o.start2-=r,o.utf8Start1-=r,o.utf8Start2-=r,o.length1+=r,o.length2+=r,o.utf8Length1+=r,o.utf8Length2+=r}if(0===(i=(o=e[e.length-1]).diffs).length||0!==i[i.length-1][0])i.push([0,n]),o.length1+=t,o.length2+=t,o.utf8Length1+=t,o.utf8Length2+=t;else if(t>i[i.length-1][1].length){let e=t-i[i.length-1][1].length;i[i.length-1][1]+=n.substring(0,e),o.length1+=e,o.length2+=e,o.utf8Length1+=e,o.utf8Length2+=e}return n}(i,r);o=l+o+l,function(e,t=4){for(let n=0;n<e.length;n++){if(e[n].length1<=32)continue;let o=e[n];e.splice(n--,1);let i=o.start1,r=o.start2,a="";for(;0!==o.diffs.length;){let l=tL(i-a.length,r-a.length),s=!0;if(""!==a){let e=tR(a);l.length1=a.length,l.utf8Length1=e,l.length2=a.length,l.utf8Length2=e,l.diffs.push([0,a])}for(;0!==o.diffs.length&&l.length1<32-t;){let e=o.diffs[0][0],n=o.diffs[0][1],a=tR(n);if(1===e){l.length2+=n.length,l.utf8Length2+=a,r+=n.length;let e=o.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+=a,i+=n.length,s=!1,l.diffs.push([e,n]),o.diffs.shift()):(a=tR(n=n.substring(0,32-l.length1-t)),l.length1+=n.length,l.utf8Length1+=a,i+=n.length,0===e?(l.length2+=n.length,l.utf8Length2+=a,r+=n.length):s=!1,l.diffs.push([e,n]),n===o.diffs[0][1]?o.diffs.shift():o.diffs[0][1]=o.diffs[0][1].substring(n.length))}a=(a=tM(l.diffs)).substring(a.length-t);let c=tI(o.diffs).substring(0,t),d=tR(c);""!==c&&(l.length1+=c.length,l.length2+=c.length,l.utf8Length1+=d,l.utf8Length2+=d,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)}}}(i,r);let s=0,c=[];for(let e=0;e<i.length;e++){let t=i[e].start2+s,n=tI(i[e].diffs),r,l=-1;if(n.length>32?-1!==(r=tC(o,n.substring(0,32),t))&&(-1===(l=tC(o,n.substring(n.length-32),t+n.length-32))||r>=l)&&(r=-1):r=tC(o,n,t),-1===r)c[e]=!1,s-=i[e].length2-i[e].length1;else{let d;if(c[e]=!0,s=r-t,d=-1===l?o.substring(r,r+n.length):o.substring(r,l+32),n===d)o=o.substring(0,r)+tM(i[e].diffs)+o.substring(r+n.length);else{let t=tg(n,d,{checkLines:!1});if(n.length>32&&function(e){let t=0,n=0,o=0;for(let i=0;i<e.length;i++){let r=e[i][0],a=e[i][1];switch(r){case 1:n+=a.length;break;case -1:o+=a.length;break;case 0:t+=Math.max(n,o),n=0,o=0;break;default:throw Error("Unknown diff operation.")}}return t+Math.max(n,o)}(t)/n.length>a)c[e]=!1;else{t=tB(t);let n=0,a=0;for(let l=0;l<i[e].diffs.length;l++){let s=i[e].diffs[l];0!==s[0]&&(a=tz(t,n)),1===s[0]?o=o.substring(0,r+a)+s[1]+o.substring(r+a):-1===s[0]&&(o=o.substring(0,r+a)+o.substring(r+tz(t,n+s[1].length))),-1!==s[0]&&(n+=s[1].length)}}}}}return[o=o.substring(l.length,o.length-l.length),c]}(tU(t.value),o.node.text,{allowExceedingIndices:!0}),r=function(e,t=4){let n=e.map(e=>tr(e)),o=!1,i=[],r=0,a=null,l=0,s=!1,c=!1,d=!1,p=!1;for(;l<n.length;)0===n[l][0]?(n[l][1].length<t&&(d||p)?(i[r++]=l,s=d,c=p,a=n[l][1]):(r=0,a=null),d=!1,p=!1):(-1===n[l][0]?p=!0:d=!0,a&&(s&&c&&d&&p||a.length<t/2&&3===function(...e){return e.reduce((e,t)=>
7e+ +!!t,0)}(s,c,d,p))&&(n.splice(i[r-1],0,[-1,a]),n[i[r-1]+1][0]=1,r--,a=null,s&&c?(d=!0,p=!0,r=0):(l=--r>0?i[r-1]:-1,d=!1,p=!1),o=!0)),l++;return o&&(n=tK(n)),n}(tg(o.node.text,i),5),a=0;for(let[t,i]of r)1===t?(e.apply({type:"insert_text",path:[n.index,o.index],offset:a,text:i}),a+=i.length):-1===t?e.apply({type:"remove_text",path:[n.index,o.index],offset:a,text:i}):0===t&&(a+=i.length);return!0}(e,t)}}catch(e){console.error(e)}return n});return function(o){i=[...o.value];let{apply:a}=o,s=[],c=({patches:e})=>{let t=e.filter(e=>"local"!==e.origin);0!==t.length&&(s=s.concat(t),(()=>{if(0===s.length)return;let e=s;s=[];let t=!1;t8(o,()=>{l.KE.withoutNormalizing(o,()=>{t2(o,()=>{ti(o,()=>{for(let n of e){t5.enabled&&t5(`Handling remote patch ${JSON.stringify(n)}`);try{t=r(o,n)}catch(e){console.error(`Applying patch ${JSON.stringify(n)} failed due to: ${e.message}`)}}})})}),t&&(o.normalize(),o.onChange())})})())};return n.push(()=>{t5("Subscribing to remote patches");let t=e.on("patches",c);return()=>{t5("Unsubscribing to remote patches"),t.unsubscribe()}}),o.apply=n=>{let r=[];i=o.value;let s=U(e.getSnapshot().context.initialValue,i,e.getSnapshot().context.schema);a(n);let c=U(e.getSnapshot().context.initialValue,o.value,e.getSnapshot().context.schema);if(!o.isPatching)return o;switch(s&&!c&&"set_selection"!==n.type&&r.push((0,B.Yr)(i,"before",[0])),n.type){case"insert_text":r=[...r,...function(e,t,n,o){let i=(0,u.zS)({schema:e},t[n.path[0]])&&t[n.path[0]];if(!i)throw Error("Could not find block");let r=(0,u.zS)({schema:e},i)&&(0,u.bl)({schema:e},i.children[n.path[1]])&&i.children[n.path[1]];if(!r)throw Error("Could not find child");let a=[{_key:i._key},"children",{_key:r._key},"text"],l=o[n.path[0]],s=(0,u.zS)({schema:e},l)&&l.children[n.path[1]],c=(0,u.bl)({schema:e},s)?s.text:"",d=(0,B.jo)(c,r.text,a);return d.value.length?[d]:[]}(e.getSnapshot().context.schema,o.children,n,i)];break;case"remove_text":r=[...r,...function(e,t,n,o){let i=t[n.path[0]];if(!i)throw Error("Could not find block");let r=(0,u.zS)({schema:e},i)&&i.children[n.path[1]]||void 0,a=(0,u.bl)({schema:e},r)?r:void 0;if(r&&!a)throw Error("Expected span");if(!a)throw Error("Could not find child");let l=[{_key:i._key},"children",{_key:a._key},"text"],s=o[n.path[0]],c=(0,u.zS)({schema:e},s)&&s.children[n.path[1]],d=(0,u.bl)({schema:e},c)&&c.text,p=(0,B.jo)(d||"",a.text,l);return p.value?[p]:[]}(e.getSnapshot().context.schema,o.children,n,i)];break;case"remove_node":r=[...r,...function(e,t,n){let o=t[n.path[0]];if(1===n.path.length){if(o&&o._key)return[(0,B.wC)([{_key:o._key}])];throw Error("Block not found")}if(!(0,u.zS)({schema:e},o)||2!==n.path.length)return[];{let e=o.children[n.path[1]];return e?o.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.`,JSON.stringify(o,null,2)),[]):[(0,B.wC)([{_key:o._key},"children",{_key:e._key}])]:[]}}(e.getSnapshot().context.schema,i,n)];break;case"split_node":r=[...r,...function(e,t,n,o){let i=[],r=t[n.path[0]];if(!(0,u.zS)({schema:e},r))throw Error(`Block with path ${JSON.stringify(n.path[0])} is not a text block and can't be split`);if(1===n.path.length){let a=o[n.path[0]];if((0,u.zS)({schema:e},a)){let o=V(t[n.path[0]+1],e.block.name);o&&(i.push((0,B.Yr)([o],"after",[{_key:r._key}])),a.children.slice(n.position).forEach(e=>{let t=[{_key:a._key},"children",{_key:e._key}];i.push((0,B.wC)(t))}))}return i}if(2===n.path.length){let t=r.children[n.path[1]];if((0,u.bl)({schema:e},t)){let o=V({...r,children:r.children.slice(n.path[1]+1,n.path[1]+2)},e.block.name).children;i.push((0,B.Wm)([],[{_key:r._key},"children"])),i.push((0,B.Yr)(o,"after",[{_key:r._key},"children",{_key:t._key}])),i.push((0,B.hZ)(t.text,[{_key:r._key},"children",{_key:t._key},"text"]))}}return i}(e.getSnapshot().context.schema,o.children,n,i)];break;case"insert_node":r=[...r,...function(e,t,n,o){let i=o[n.path[0]];if(1===n.path.length){let t=0===n.path[0]?"before":"after",r=o[n.path[0]-1],a=0===n.path[0]?i?._key:r?._key;return a?[(0,B.Yr)([V(n.node,e.block.name)],t,[{_key:a}])]:[(0,B.Wm)(o,[]),(0,B.Yr)([V(n.node,e.block.name)],"before",[n.path[0]])]}if((0,u.zS)({schema:e},i)&&2===n.path.length&&t[n.path[0]]){let e=0!==i.children.length&&i.children[n.path[1]-1]?"after":"before",t=i.children.length<=1||!i.children[n.path[1]-1]?[{_key:i._key},"children",0]:[{_key:i._key},"children",{_key:i.children[n.path[1]-1]._key}],o=(0,B.Wm)([],[{_key:i._key},"children"]);if(l.EY.isText(n.node))return[o,(0,B.Yr)([n.node],e,t)];let r=n.node._type,a=n.node._key,s="value"in n.node&&"object"==typeof n.node.value?n.node.value:{};return[o,(0,B.Yr)([{_type:r,_key:a,...s}],e,t)]}return[]}(e.getSnapshot().context.schema,o.children,n,i)];break;case"set_node":r=[...r,...function(e,t,n){let o=n.path.at(0);if(void 0!==o&&1===n.path.length){let i=t.at(o);if(!i)return console.error("Could not find block at index",o),[];if((0,u.zS)({schema:e},i)){let e=[];for(let t of Object.keys(n.newProperties)){let r=n.newProperties[t];"_key"===t?e.push((0,B.hZ)(r,[o,"_key"])):e.push((0,B.hZ)(r,[{_key:i._key},t]))}for(let t of Object.keys(n.properties))t in n.newProperties||e.push((0,B.wC)([{_key:i._key},t]));return e}{let e=[],t=n.newProperties._key;void 0!==t&&e.push((0,B.hZ)(t,[o,"_key"]));let r="value"in n.newProperties&&"object"==typeof n.newProperties.value?n.newProperties.value:{};for(let t of Object.keys(r)){let n=r[t];e.push((0,B.hZ)(n,[{_key:i._key},t]))}for(let t of Object.keys("value"in n.properties&&"object"==typeof n.properties.value?n.properties.value:{}))t in r||e.push((0,B.wC)([{_key:i._key},t]));return e}}if(2===n.path.length){let o=t[n.path[0]];if((0,u.zS)({schema:e},o)){let e=o.children[n.path[1]];if(e){let t=o._key,i=e._key,r=[];if(l.Hg.isElement(e)){let a=n.newProperties._key;
7void 0!==a&&r.push((0,B.hZ)(a,[{_key:t},"children",o.children.indexOf(e),"_key"]));let l="value"in n.newProperties&&"object"==typeof n.newProperties.value?n.newProperties.value:{};for(let e of Object.keys(l)){let n=l[e];r.push((0,B.hZ)(n,[{_key:t},"children",{_key:i},e]))}return r}for(let a of Object.keys(n.newProperties)){let l=n.newProperties[a];if("_key"===a){r.push((0,B.hZ)(l,[{_key:t},"children",o.children.indexOf(e),a]));continue}r.push((0,B.hZ)(l,[{_key:t},"children",{_key:i},a]))}for(let e of Object.keys(n.properties))e in n.newProperties||r.push((0,B.wC)([{_key:t},"children",{_key:i},e]));return r}throw Error("Could not find a valid child")}throw Error("Could not find a valid block")}throw Error(`Unexpected path encountered: ${JSON.stringify(n.path)}`)}(e.getSnapshot().context.schema,o.children,n)];break;case"merge_node":r=[...r,...function(e,t,n,o){let i=[],r=o[n.path[0]],a=t[n.path[0]];if(1===n.path.length)if(r?._key){let o=V(t[n.path[0]-1],e.block.name);i.push((0,B.hZ)(o,[{_key:o._key}])),i.push((0,B.wC)([{_key:r._key}]))}else throw Error("Target key not found!");else if((0,u.zS)({schema:e},r)&&(0,u.zS)({schema:e},a)&&2===n.path.length){let t=a.children[n.path[1]-1]&&(0,u.bl)({schema:e},a.children[n.path[1]-1])?a.children[n.path[1]-1]:void 0,o=r.children[n.path[1]]&&(0,u.bl)({schema:e},r.children[n.path[1]])?r.children[n.path[1]]:void 0;t&&(1===r.children.filter(e=>e._key===t._key).length?i.push((0,B.hZ)(t.text,[{_key:r._key},"children",{_key:t._key},"text"])):console.warn(`Multiple spans have \`_key\` ${t._key}. It's ambiguous which one to update.`,JSON.stringify(r,null,2))),o&&(1===r.children.filter(e=>e._key===o._key).length?i.push((0,B.wC)([{_key:r._key},"children",{_key:o._key}])):console.warn(`Multiple spans have \`_key\` ${o._key}. It's ambiguous which one to remove.`,JSON.stringify(r,null,2)))}return i}(e.getSnapshot().context.schema,o.children,n,i)];break;case"move_node":r=[...r,...function(e,t,n){let o=[],i=t[n.path[0]],r=t[n.newPath[0]];if(!r)return o;if(1===n.path.length){let e=n.path[0]>n.newPath[0]?"before":"after";o.push((0,B.wC)([{_key:i._key}])),o.push((0,B.Yr)([i],e,[{_key:r._key}]))}else if(2===n.path.length&&(0,u.zS)({schema:e},i)&&(0,u.zS)({schema:e},r)){let e=i.children[n.path[1]],t=r.children[n.newPath[1]],a=n.newPath[1]===r.children.length?"after":"before",l=i.children[n.path[1]];o.push((0,B.wC)([{_key:i._key},"children",{_key:e._key}])),o.push((0,B.Wm)([],[{_key:r._key},"children"])),o.push((0,B.Yr)([l],a,[{_key:r._key},"children",{_key:t._key}]))}return o}(e.getSnapshot().context.schema,i,n)]}if(!s&&c&&["merge_node","set_node","remove_text","remove_node"].includes(n.type)&&(r=[...r,(0,B.wC)([])],t.send({type:"unset",previousValue:i})),s&&r.length>0&&(r=[(0,B.Wm)([],[]),...r]),r.length>0)for(let t of r)e.send({type:"internal.patch",patch:{...t,origin:"local"},operationId:o.undoStepId,value:o.value});return o},o}}({editorActor:r,relayActor:a,subscriptions:t.subscriptions}),h=function({editorActor:e,subscriptions:t}){return n=>{let o=n.value,i=n.undoStepId;t.push(()=>{let t=e.on("patches",({patches:e,snapshot:t})=>{let i=!1;for(let r of e)if(!i&&"local"!==r.origin){if("unset"===r.type&&0===r.path.length){t0("Someone else cleared the content, resetting undo/redo history"),n.history={undos:[],redos:[]},n.remotePatches.splice(0,n.remotePatches.length),n.withHistory=!0,i=!0;return}n.remotePatches.push({patch:r,time:new Date,snapshot:t,previousSnapshot:o})}o=t});return()=>{t.unsubscribe()}});let{apply:r}=n;return n.apply=t=>{if(e.getSnapshot().matches({"edit mode":"read only"})||n.isProcessingRemoteChanges||n.isUndoing||n.isRedoing)return void r(t);let o=n.withHistory,a=n.undoStepId;if(!o){i=a,r(t);return}for("set_selection"!==t.type&&(n.history.redos=[]),n.history.undos=function({steps:e,op:t,editor:n,currentUndoStepId:o,previousUndoStepId:i}){let r=e.at(-1);if(!r)return tZ(e,t,n);if(n.operations.length>0)return o===i||n.isNormalizingNode?tX(e,r,t):tZ(e,t,n);if("set_selection"===t.type&&void 0===o&&void 0!==i||"set_selection"===t.type&&void 0!==o&&void 0!==i&&i!==o)return tX(e,r,t);if(void 0===o&&void 0===i){if("set_selection"===t.type)return tX(e,r,t);let o=r.operations.at(-1);return o&&"insert_text"===t.type&&"insert_text"===o.type&&t.offset===o.offset+o.text.length&&l.wA.equals(t.path,o.path)&&" "!==t.text||o&&"remove_text"===t.type&&"remove_text"===o.type&&t.offset+t.text.length===o.offset&&l.wA.equals(t.path,o.path)?tX(e,r,t):tZ(e,t,n)}return tZ(e,t,n)}({steps:n.history.undos,op:t,editor:n,currentUndoStepId:a,previousUndoStepId:i});n.history.undos.length>1e3;)n.history.undos.shift();i=a,r(t)},n}}({editorActor:r,subscriptions:t.subscriptions}),f=(o=r,function(e){let{apply:t,normalizeNode:n}=e,i=o.getSnapshot().context.schema.styles.at(0)?.name;return e.normalizeNode=t=>{let[r,a]=t;if(l.KE.isEditor(r)&&0===r.children.length&&t2(e,()=>{t1(e,()=>{l.gB.insertNodes(e,tt(o.getSnapshot().context),{at:[0],select:!0})})}),e.isTextBlock(r))for(let[t,n]of l.bP.children(e,a)){let o=r.children[n[1]+1];if(e.isTextSpan(t)&&e.isTextSpan(o)&&t.marks?.every(e=>o.marks?.includes(e))&&o.marks?.every(e=>t.marks?.includes(e))){t3("Merging spans",JSON.stringify(t,null,2),JSON.stringify(o,null,2)),t1(e,()=>{l.gB.mergeNodes(e,{at:[n[0],n[1]+1],voids:!0})});return}}if(e.isTextBlock(r)&&!Array.isArray(r.markDefs)){t3("Adding .markDefs to block node"),t1(e,()=>{l.gB.setNodes(e,{markDefs:[]},{at:a})});return}if(i&&e.isTextBlock(r)&&typeof r.style>
7"u"){t3("Adding .style to block node"),t1(e,()=>{l.gB.setNodes(e,{style:i},{at:a})});return}if(e.isTextSpan(r)&&!Array.isArray(r.marks)){t3("Adding .marks to span node"),t1(e,()=>{l.gB.setNodes(e,{marks:[]},{at:a})});return}if(e.isTextSpan(r)){let t=l.wA.parent(a),[n]=l.KE.node(e,t),i=o.getSnapshot().context.schema.decorators.map(e=>e.name),s=r.marks?.filter(e=>!i.includes(e));if(e.isTextBlock(n)&&""===r.text&&s&&s.length>0){t3("Removing annotations from empty span node"),t1(e,()=>{l.gB.setNodes(e,{marks:r.marks?.filter(e=>i.includes(e))},{at:a})});return}}if(e.isTextBlock(r)){let t=o.getSnapshot().context.schema.decorators.map(e=>e.name);for(let[n,o]of l.bP.children(e,a))if(e.isTextSpan(n)){let i=n.marks??[],a=i.filter(e=>!t.includes(e)&&!r.markDefs?.find(t=>t._key===e));if(a.length>0){t3("Removing orphaned annotations from span node"),t1(e,()=>{l.gB.setNodes(e,{marks:i.filter(e=>!a.includes(e))},{at:o})});return}}}if(e.isTextSpan(r)){let t=l.wA.parent(a),[n]=l.KE.node(e,t);if(e.isTextBlock(n)){let t=o.getSnapshot().context.schema.decorators.map(e=>e.name),i=r.marks??[],s=i.filter(e=>!t.includes(e)&&!n.markDefs?.find(t=>t._key===e));if(s.length>0){t3("Removing orphaned annotations from span node"),t1(e,()=>{l.gB.setNodes(e,{marks:i.filter(e=>!s.includes(e))},{at:a})});return}}}if(e.isTextBlock(r)){let t=r.markDefs??[],n=new Set,o=[];for(let e of t)n.has(e._key)||(n.add(e._key),o.push(e));if(t.length!==o.length){t3("Removing duplicate markDefs"),t1(e,()=>{l.gB.setNodes(e,{markDefs:o},{at:a})});return}}if(e.isTextBlock(r)&&!e.operations.some(e=>"merge_node"===e.type&&"markDefs"in e.properties&&1===e.path.length)){let t=(r.markDefs||[]).filter(e=>r.children.find(t=>l.EY.isText(t)&&Array.isArray(t.marks)&&t.marks.includes(e._key)));if(r.markDefs&&!I(t,r.markDefs)){t3("Removing markDef not in use"),t1(e,()=>{l.gB.setNodes(e,{markDefs:t},{at:a})});return}}t1(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=l.Q6.isCollapsed({anchor:n.properties.anchor,focus:n.properties.focus}),o=l.Q6.isCollapsed({anchor:n.newProperties.anchor,focus:n.newProperties.focus});if(t&&o){let t=Array.from(l.KE.nodes(e,{mode:"lowest",at:n.properties.focus,match:t=>e.isTextSpan(t),voids:!1}))[0]?.[0],o=Array.from(l.KE.nodes(e,{mode:"lowest",at:n.newProperties.focus,match:t=>e.isTextSpan(t),voids:!1}))[0]?.[0],i=t&&o&&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,r=t&&o&&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&&o.text.length===n.newProperties.focus.offset;i||r||(e.decoratorState={})}}else e.decoratorState={};if("merge_node"===n.type&&1===n.path.length&&"markDefs"in n.properties&&n.properties._type===o.getSnapshot().context.schema.block.name&&Array.isArray(n.properties.markDefs)&&n.properties.markDefs.length>0&&n.path[0]-1>=0){let[o,i]=l.KE.node(e,[n.path[0]-1]);if(e.isTextBlock(o)){let r=[...new Map([...Array.isArray(o.markDefs)&&o.markDefs||[],...n.properties.markDefs].map(e=>[e._key,e])).values()];t3("Copying markDefs over to merged block",n),l.gB.setNodes(e,{markDefs:r},{at:i,voids:!1}),t(n);return}}t(n)},e});return(i=r,function(e){let{delete:t,insertNodes:n,select:o,setSelection:r}=e;return e.delete=n=>{if(e.isPerformingBehaviorOperation)return void t(n);let o=n?.at?l.KE.range(e,n.at):void 0,r=o?W({schema:i.getSnapshot().context.schema,editor:e,range:o}):void 0;r?i.send({type:"behavior event",behaviorEvent:{type:"delete",at:r,direction:n?.reverse?"backward":"forward",unit:n?.unit},editor:e}):i.send({type:"behavior event",behaviorEvent:{type:"delete",direction:n?.reverse?"backward":"forward",unit:n?.unit},editor:e})},e.deleteBackward=t=>{if(e.isPerformingBehaviorOperation)return void console.error("Unexpected call to .deleteBackward(...)");
7i.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:t},editor:e})},e.deleteForward=t=>{if(e.isPerformingBehaviorOperation)return void console.error("Unexpected call to .deleteForward(...)");i.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:t},editor:e})},e.insertBreak=()=>{if(e.isPerformingBehaviorOperation)return void console.error("Unexpected call to .insertBreak(...)");i.send({type:"behavior event",behaviorEvent:{type:"insert.break"},editor:e})},e.insertData=t=>{if(e.isPerformingBehaviorOperation)return void console.error("Unexpected call to .insertData(...)");i.send({type:"behavior event",behaviorEvent:{type:"input.*",originEvent:{dataTransfer:t}},editor:e})},e.insertNodes=(t,o)=>{if(e.isNormalizingNode)return void n((l.bP.isNode(t)?[t]:t).map(e=>l.EY.isText(e)&&"string"!=typeof e._type?{...e,_type:i.getSnapshot().context.schema.span.name}:e),o);n(t,o)},e.insertSoftBreak=()=>{if(e.isPerformingBehaviorOperation)return void tq({context:{keyGenerator:i.getSnapshot().context.keyGenerator,schema:i.getSnapshot().context.schema},operation:{type:"insert.text",text:` 8`,editor:e}});i.send({type:"behavior event",behaviorEvent:{type:"insert.soft break"},editor:e})},e.insertText=t=>{if(e.isPerformingBehaviorOperation)return void tq({context:{keyGenerator:i.getSnapshot().context.keyGenerator,schema:i.getSnapshot().context.schema},operation:{type:"insert.text",text:t,editor:e}});i.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:t},editor:e})},e.redo=()=>{if(e.isPerformingBehaviorOperation)return void tq({context:{keyGenerator:i.getSnapshot().context.keyGenerator,schema:i.getSnapshot().context.schema},operation:{type:"history.redo",editor:e}});i.send({type:"behavior event",behaviorEvent:{type:"history.redo"},editor:e})},e.select=t=>{if(e.isPerformingBehaviorOperation||e.selection)return void o(t);let n=l.KE.range(e,t);i.send({type:"behavior event",behaviorEvent:{type:"select",at:W({schema:i.getSnapshot().context.schema,editor:e,range:n})},editor:e})},e.setSelection=t=>{if(e.isPerformingBehaviorOperation)return void r(t);let n=t.anchor?q({schema:i.getSnapshot().context.schema,editor:e,point:t.anchor}):void 0,o=t.focus?q({schema:i.getSnapshot().context.schema,editor:e,point:t.focus}):void 0,a=e.selection?l.Q6.isBackward({anchor:t.anchor??e.selection.anchor,focus:t.focus??e.selection.focus}):t.anchor&&t.focus?l.Q6.isBackward({anchor:t.anchor,focus:t.focus}):void 0;if(e.selection){let n=t.anchor??e.selection.anchor,o=t.focus??e.selection.focus;if(l.bR.equals(n,e.selection.anchor)&&l.bR.equals(o,e.selection.focus))return void r(t)}if(!n||!o)return void r(t);i.send({type:"behavior event",behaviorEvent:{type:"select",at:{anchor:n,focus:o,backward:a}},editor:e})},e.setFragmentData=()=>{console.error("Unexpected call to .setFragmentData(...)")},e.undo=()=>{if(e.isPerformingBehaviorOperation)return void tq({context:{keyGenerator:i.getSnapshot().context.keyGenerator,schema:i.getSnapshot().context.schema},operation:{type:"history.undo",editor:e}});i.send({type:"behavior event",behaviorEvent:{type:"history.undo"},editor:e})},e})(c(s(f(h(d(function(e,t){let{apply:n}=t;return t.apply=o=>
8{if("set_selection"===o.type||(t.value=function(e,t,n){try{return function(e,t,n){switch(n.type){case"insert_node":{let{path:o,node:i}=n,r=na(e,t,o),a=o[o.length-1];if(!r||a>r.children.length)return t;if(1===o.length){if(ne(e,i)){let e={...i,children:i.children.map(e=>"__inline"in e?{_key:e._key,_type:e._type,..."value"in e&&"object"==typeof e.value?e.value:{}}:e)};return{...t,children:nl(t.children,a,e)}}if(l.Hg.isElement(i)&&!("__inline"in i)){let e={_key:i._key,_type:i._type,..."value"in i&&"object"==typeof i.value?i.value:{}};return{...t,children:nl(t.children,a,e)}}}if(2===o.length){let n,l=o[0];if(!ne(e,r))return t;if(nn(e,i))n=i;else{if(!("__inline"in i))return t;n={_key:i._key,_type:i._type,..."value"in i&&"object"==typeof i.value?i.value:{}}}return nd(e,t,l,e=>({...e,children:nl(e.children,a,n)}))}return t}case"insert_text":{let{path:o,offset:i,text:r}=n;if(0===r.length)return t;let a=nr(e,t,o);if(!a)return t;let l=o[0],s=o[1],c=a.text.slice(0,i),d=a.text.slice(i),p={...a,text:c+r+d};return nd(e,t,l,e=>({...e,children:nc(e.children,s,p)}))}case"merge_node":{let{path:o}=n;if(0===o.at(-1))return t;let i=ni(e,t,o),r=ni(e,t,l.wA.previous(o)),a=na(e,t,o);if(!i||!r||!a)return t;let s=o[o.length-1];if(nn(e,i)&&nn(e,r)){let n=o[0],a={...r,text:r.text+i.text};return nd(e,t,n,e=>{let t=nc(e.children,s-1,a);return{...e,children:ns(t,s)}})}if(ne(e,i)&&ne(e,r)){let e={...r,children:[...r.children,...i.children]},n=nc(t.children,s-1,e);return{...t,children:ns(n,s)}}return t}case"move_node":{let o,{path:i,newPath:r}=n;if(l.wA.isAncestor(i,r))return t;let a=ni(e,t,i),s=na(e,t,i),c=i[i.length-1];if(!a||!s)return t;if(1===i.length)o={...t,children:ns(t.children,c)};else{if(2!==i.length)return t;o=nd(e,t,i[0],e=>({...e,children:ns(e.children,c)}))}let d=l.wA.transform(i,n),p=d[d.length-1];if(1===d.length)return{...o,children:nl(o.children,p,a)};if(2===d.length){let n=d[0],i=o.children[n];return i&&ne(e,i)?nd(e,o,n,e=>({...e,children:nl(e.children,p,a)})):t}return t}case"remove_node":{let{path:o}=n,i=o[o.length-1];if(!na(e,t,o))return t;if(1===o.length)return{...t,children:ns(t.children,i)};if(2===o.length)return nd(e,t,o[0],e=>({...e,children:ns(e.children,i)}));return t}case"remove_text":{let{path:o,offset:i,text:r}=n;if(0===r.length)return t;let a=nr(e,t,o);if(!a)return t;let l=o[0],s=o[1],c=a.text.slice(0,i),d=a.text.slice(i+r.length),p={...a,text:c+d};return nd(e,t,l,e=>({...e,children:nc(e.children,s,p)}))}case"set_node":{let{path:o,properties:i,newProperties:r}=n,a=ni(e,t,o);if(!a||t9(a))return t;if(!t9(a)&&!ne(e,a)&&!nt(e,a)&&!nn(e,a)){let n="value"in i&&"object"==typeof i.value?i.value:{},l="value"in r&&"object"==typeof r.value?r.value:{},s={...a};for(let e in r){if("value"===e)continue;let t=r[e];null==t?delete s[e]:s[e]=t}for(let e in i)"value"!==e&&(r.hasOwnProperty(e)||delete s[e]);for(let e in l){let t=l[e];null==t?delete s[e]:s[e]=t}for(let e in n)l.hasOwnProperty(e)||delete s[e];return 1===o.length?{...t,children:nc(t.children,o[0],s)}:2===o.length?nd(e,t,o[0],e=>({...e,children:nc(e.children,o[1],s)})):t}if(ne(e,a)){let e={...a};for(let t in r){if("children"===t||"text"===t)continue;let n=r[t];null==n?delete e[t]:e[t]=n}for(let t in i)r.hasOwnProperty(t)||delete e[t];return{...t,children:nc(t.children,o[0],e)}}if(nn(e,a)){let n={...a};for(let e in r){if("text"===e)continue;let t=r[e];null==t?delete n[e]:n[e]=t}for(let e in i)r.hasOwnProperty(e)||delete n[e];return nd(e,t,o[0],e=>({...e,children:nc(e.children,o[1],n)}))}return t}case"split_node":{let{path:o,position:i,properties:r}=n;if(0===o.length)return t;let a=na(e,t,o),l=o[o.length-1];if(!a)return t;if(t9(a)){let n=no(t,o);if(!n||!ne(e,n))return t;let a=n.children.slice(0,i),s=n.children.slice(i),c={...n,children:a},d={...r,children:s,_type:e.schema.block.name};return{...t,children:nl(nc(t.children,l,c),l+1,d)}}if(ne(e,a)){let n=ni(e,t,o);if(!n||!nt(e,n))return t;let a=o[0],s=n.text.slice(0,i),c=n.text.slice(i),d={...n,text:s},p={...r,text:c};return nd(e,t,a,e=>({...e,children:nl(nc(e.children,l,d),l+1,p)}))}return t}}}(e,{children:t},n).children}catch(e){return console.error(e),t}}(e,t.value,o),"insert_text"===o.type||"remove_text"===o.type))return void n(o);te({schema:e.schema,value:t.value},{blockIndexMap:t.blockIndexMap,listIndexMap:t.listIndexMap}),n(o)},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=W({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}))))))))})((0,s.o$)(n),{editorActor:e.editorActor,relayActor:e.relayActor,subscriptions:e.subscriptions});return te({schema:e.editorActor.getSnapshot().context.schema,value:o.value},{blockIndexMap:o.blockIndexMap,listIndexMap:o.listIndexMap}),{instance:o,initialValue:[t]}}({editorActor:n,relayActor:o,subscriptions:t}),r=function(e,t){let n=t.getSnapshot().context.schema;return{focus:()=>{t.send({type:"focus",editor:e})},blur:()=>{t.send({type:"blur",editor:e})},toggleMark:n=>{t.send({type:"behavior event",behaviorEvent:{type:"decorator.toggle",decorator:n},editor:e})},toggleList:n=>{t.send({type:"behavior event",behaviorEvent:{type:"list item.toggle",listItem:n},editor:e})},toggleBlockStyle:n=>{t.send({type:"behavior event",behaviorEvent:{type:"style.toggle",style:n},editor:e})},isMarkActive:n=>{let o=ew({editorActorSnapshot:t.getSnapshot(),slateEditorInstance:e});return(0,v.rm)(o).includes(n)},marks:()=>{let n=ew({editorActorSnapshot:t.getSnapshot(),slateEditorInstance:e});return[...(0,v.N2)(n),...(0,v.rm)(n)]},undo:()=>{t.send({type:"behavior event",behaviorEvent:{type:"history.undo"},editor:e})},redo:()=>{t.send({type:"behavior event",behaviorEvent:{type:"history.redo"},editor:e})},select:n=>{let o=ee({context:{schema:t.getSnapshot().context.schema,value:e.value,selection:n},blockIndexMap:e.blockIndexMap});o?l.gB.select(e,o):l.gB.deselect(e),e.onChange()},focusBlock:()=>
8{if(!e.selection)return;let t=e.selection.focus.path.at(0);if(void 0!==t)return e.value.at(t)},focusChild:()=>{if(!e.selection)return;let n=e.selection.focus.path.at(0),o=e.selection.focus.path.at(1),i=void 0!==n?e.value.at(n):void 0;if(i&&(0,u.zS)(t.getSnapshot().context,i))return void 0===o?void 0:i.children.at(o)},insertChild:(n,o)=>(t.send({type:"behavior event",behaviorEvent:{type:"insert.child",child:{_type:n.name,...o||{}}},editor:e}),e.selection?W({schema:t.getSnapshot().context.schema,editor:e,range:e.selection})?.focus.path??[]:[]),insertBlock:(n,o)=>(t.send({type:"behavior event",behaviorEvent:{type:"insert.block",block:{_type:n.name,...o||{}},placement:"auto"},editor:e}),e.selection?W({schema:t.getSnapshot().context.schema,editor:e,range:e.selection})?.focus.path??[]:[]),hasBlockStyle:t=>{try{return function({editor:e,style:t}){if(!e.selection)return!1;let n=[...l.KE.nodes(e,{at:e.selection,match:t=>e.isTextBlock(t)})];return n.length>0&&n.every(([e])=>e.style===t)}({editor:e,style:t})}catch{return!1}},hasListStyle:t=>{try{return function({editor:e,listItem:t}){if(!e.selection)return!1;let n=[...l.KE.nodes(e,{at:e.selection,match:t=>e.isTextBlock(t)})];return n.length>0&&n.every(([n])=>e.isListBlock(n)&&n.listItem===t)}({editor:e,listItem:t})}catch{return!1}},isVoid:e=>![n.block.name,n.span.name].includes(e._type),findByPath:n=>{let o=(0,p.XE)({path:n});if(!o)return[void 0,void 0];let i=e.blockIndexMap.get(o);if(void 0===i)return[void 0,void 0];let r=e.value.at(i);if(!r)return[void 0,void 0];let a=(0,p.qX)({path:n});if(1===n.length&&!a)return[r,[{_key:r._key}]];if((0,u.zS)(t.getSnapshot().context,r)&&a){let e=r.children.find(e=>e._key===a);if(e)return[e,[{_key:r._key},"children",{_key:e._key}]]}return[void 0,void 0]},findDOMNode:t=>{let n;try{let[o]=Array.from(l.KE.nodes(e,{at:[],match:e=>e._key===t._key})||[])[0]||[void 0];n=s.rL.toDOMNode(e,o)}catch{}return n},activeAnnotations:()=>{if(!e.selection||e.selection.focus.path.length<2)return[];try{let t=[];for(let[n,o]of l.KE.nodes(e,{at:e.selection,match:e=>l.EY.isText(e)&&void 0!==e.marks&&Array.isArray(e.marks)&&e.marks.length>0})){let[i]=l.KE.node(e,o,{depth:1});e.isTextBlock(i)&&i.markDefs?.forEach(e=>{l.EY.isText(n)&&n.marks&&Array.isArray(n.marks)&&n.marks.includes(e._key)&&t.push(e)})}return t}catch{return[]}},isAnnotationActive:n=>{let o=ew({editorActorSnapshot:t.getSnapshot(),slateEditorInstance:e});return(0,v.kK)(n)(o)},addAnnotation:(n,o)=>{let i=ew({editorActorSnapshot:t.getSnapshot(),slateEditorInstance:e}),r=(0,v.lN)(i),a=(0,v.d2)(i),l=r.flatMap(e=>(0,u.zS)(i.context,e)?e.markDefs??[]:[]);t.send({type:"behavior event",behaviorEvent:{type:"annotation.add",annotation:{name:n.name,value:o??{}}},editor:e});let s=ew({editorActorSnapshot:t.getSnapshot(),slateEditorInstance:e}),c=(0,v.lN)(s),d=(0,v.gU)(s),p=(0,v.d2)(s),h=p?.node.marks?.filter(e=>!a?.node.marks?.includes(e)&&!s.context.schema.decorators.map(e=>e.name).includes(e)),f=c.flatMap(e=>(0,u.zS)(s.context,e)?e.markDefs?.map(t=>({markDef:t,path:[{_key:e._key},"markDefs",{_key:t._key}]}))??[]:[]).filter(e=>!l.some(t=>t._key===e.markDef._key)),y=p?.path,g=f.find(e=>h?.some(t=>t===e.markDef._key));if(d&&y&&g)return{markDefPath:g.path,markDefPaths:f.map(e=>e.path),spanPath:y}},delete:(n,o)=>{n&&t.send({type:"behavior event",behaviorEvent:{type:"delete",at:n,unit:o?.mode==="blocks"?"block":o?.mode==="children"?"child":void 0},editor:e})},removeAnnotation:n=>{t.send({type:"behavior event",behaviorEvent:{type:"annotation.remove",annotation:{name:n.name}},editor:e})},getSelection:()=>{if(!e.selection)return null;if(e.selection===e.lastSlateSelection)return e.lastSelection;let n=W({schema:t.getSnapshot().context.schema,editor:e,range:e.selection});return e.lastSlateSelection=e.selection,e.lastSelection=n,n},getValue:()=>e.value,isCollapsedSelection:()=>!!e.selection&&l.Q6.isCollapsed(e.selection),isExpandedSelection:()=>!!e.selection&&l.Q6.isExpanded(e.selection),insertBreak:()=>{e.insertBreak(),e.onChange()},getFragment:()=>{let n=ew({editorActorSnapshot:t.getSnapshot(),slateEditorInstance:e});return(0,v.lN)(n)},isSelectionsOverlapping:(n,o)=>{let i=ee({context:{schema:t.getSnapshot().context.schema,value:e.value,selection:n},blockIndexMap:e.blockIndexMap}),r=ee({context:{schema:t.getSnapshot().context.schema,value:e.value,selection:o},blockIndexMap:e.blockIndexMap});return l.Q6.isRange(i)&&l.Q6.isRange(r)&&l.Q6.includes(i,r)}}}(i.instance,n),{mutationActor:a,syncActor:c}=function(e){ov("Creating new Actors");let t=(0,m.c)(oc,{input:{readOnly:e.editorActor.getSnapshot().matches({"edit mode":"read only"}),schema:e.editorActor.getSnapshot().context.schema,slateEditor:e.slateEditor}}),n=(0,m.c)(of,{input:{initialValue:e.editorActor.getSnapshot().context.
8initialValue,keyGenerator:e.editorActor.getSnapshot().context.keyGenerator,readOnly:e.editorActor.getSnapshot().matches({"edit mode":"read only"}),schema:e.editorActor.getSnapshot().context.schema,slateEditor:e.slateEditor}});return e.subscriptions.push(()=>{let o=t.on("*",t=>{"has pending mutations"===t.type&&n.send({type:"has pending mutations"}),"mutation"===t.type&&(n.send({type:"mutation"}),e.editorActor.send({type:"mutation",patches:t.patches,value:t.snapshot})),"patch"===t.type&&e.relayActor.send(t)});return()=>{t.send({type:"emit changes"}),o.unsubscribe()}}),e.subscriptions.push(()=>{let t=n.on("*",t=>{switch(t.type){case"invalid value":case"value changed":e.relayActor.send(t);break;case"patch":e.editorActor.send({...t,type:"internal.patch",value:e.slateEditor.value});break;default:e.editorActor.send(t)}});return()=>{t.unsubscribe()}}),e.subscriptions.push(()=>{let o=e.editorActor.subscribe(e=>{e.matches({"edit mode":"read only"})?(t.send({type:"update readOnly",readOnly:!0}),n.send({type:"update readOnly",readOnly:!0})):(t.send({type:"update readOnly",readOnly:!1}),n.send({type:"update readOnly",readOnly:!1}))});return()=>{o.unsubscribe()}}),e.subscriptions.push(()=>{let n=e.editorActor.on("*",n=>{switch(n.type){case"editable":case"mutation":case"ready":case"read only":case"selection":e.relayActor.send(n);break;case"internal.patch":t.send({...n,type:"patch"})}});return()=>{n.unsubscribe()}}),{mutationActor:t,syncActor:n}}({editorActor:n,relayActor:o,slateEditor:i.instance,subscriptions:t}),d={dom:nu(e=>n.send(e),i.instance),getSnapshot:()=>ew({editorActorSnapshot:n.getSnapshot(),slateEditorInstance:i.instance}),registerBehavior:e=>{let t=ec({name:"custom",reference:{priority:ed,importance:"higher"}}),o={...e,priority:t};return n.send({type:"add behavior",behaviorConfig:o}),()=>{n.send({type:"remove behavior",behaviorConfig:o})}},send:e=>{switch(e.type){case"update value":c.send(e);break;case"update readOnly":case"patches":n.send(e);break;default:n.send(oa({event:e,slateEditor:i.instance}))}},on:(e,t)=>o.on(e,e=>{switch(e.type){case"blurred":case"done loading":case"editable":case"focused":case"invalid value":case"loading":case"mutation":case"patch":case"read only":case"ready":case"selection":case"value changed":t(e)}}),_internal:{editable:r,editorActor:n,slateEditor:i}};return{actors:{editorActor:n,mutationActor:a,relayActor:o,syncActor:c},editor:d,subscriptions:t}}function ox(e){switch(e.type){case"blurred":return{type:"blur",event:e.event};case"patch":case"ready":case"selection":case"unset":return e;case"loading":return{type:"loading",isLoading:!0};case"done loading":return{type:"loading",isLoading:!1};case"focused":return{type:"focus",event:e.event};case"value changed":return{type:"value",value:e.value};case"invalid value":return{type:"invalidValue",resolution:e.resolution,value:e.value};case"mutation":return{type:"mutation",patches:e.patches,snapshot:e.value}}}let o_=N("component:PortableTextEditor");class oE extends a.Component{static displayName="PortableTextEditor";change$=new A.B;subscriptions=[];unsubscribers=[];constructor(e){if(super(e),e.editor)this.editor=e.editor,this.schemaTypes=this.editor._internal.editorActor.getSnapshot().context.getLegacySchema();else{let{actors:t,editor:n,subscriptions:o}=ob({initialValue:e.value,keyGenerator:e.keyGenerator,readOnly:e.readOnly,schema:e.schemaType});this.subscriptions=o,this.actors=t,this.editor=n,this.schemaTypes=t.editorActor.getSnapshot().context.getLegacySchema()}this.editable=this.editor._internal.editable}componentDidMount(){if(!this.actors)return;for(let e of this.subscriptions)this.unsubscribers.push(e());let e=this.actors.relayActor.on("*",e=>{let t=ox(e);t&&(this.props.editor||this.props.onChange(t),this.change$.next(t))});this.unsubscribers.push(e.unsubscribe),this.actors.editorActor.start(),this.actors.mutationActor.start(),this.actors.relayActor.start(),this.actors.syncActor.start()}componentDidUpdate(e){this.props.editor||e.editor||this.props.schemaType===e.schemaType||console.warn("Updating schema type is no longer supported"),this.props.editor||e.editor||(this.props.readOnly!==e.readOnly&&this.editor._internal.editorActor.send({type:"update readOnly",readOnly:this.props.readOnly??!1}),this.props.value!==e.value&&this.editor.send({type:"update value",value:this.props.value}),this.props.editorRef!==e.editorRef&&this.props.editorRef&&(this.props.editorRef.current=this))}componentWillUnmount(){for(let e of this.unsubscribers)e();this.actors&&(e4(this.actors.editorActor),e4(this.actors.mutationActor),e4(this.actors.relayActor),e4(this.actors.syncActor))}setEditable=e=>{this.editor._internal.editable={...this.editor._internal.editable,...e}};render(){let e=this.props.editor?void 0:this.props.incomingPatches$??this.props.patches$;return(0,o.jsxs)(o.Fragment,{children:[e?(0,o.jsx)(ow,{editorActor:this.editor._internal.editorActor,patches$:e}):null,(0,o.jsx)(en.Provider,{value:this.editor._internal.editorActor,children:(0,o.jsx)(er.Provider,{value:this.actors.relayActor,children:(0,o.jsx)(s.A,{editor:this.editor._internal.slateEditor.instance,initialValue:this.editor._internal.slateEditor.initialValue,children:(0,o.jsx)(eU.Provider,{value:this,children:this.props.children})})})})]})}static activeAnnotations=e=>e&&e.editable?e.editable.activeAnnotations():[];static isAnnotationActive=(e,t)=>
8!!e&&!!e.editable&&e.editable.isAnnotationActive(t);static addAnnotation=(e,t,n)=>e.editable?.addAnnotation(t,n);static blur=e=>{o_("Host blurred"),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=>{o_("Host requesting focus"),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)=>(o_("Host inserting child"),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)=>{o_("Host setting selection",t),e.editable?.select(t)};static removeAnnotation=(e,t)=>e.editable?.removeAnnotation(t);static toggleBlockStyle=(e,t)=>(o_("Host is toggling block style"),e.editable?.toggleBlockStyle(t));static toggleList=(e,t)=>e.editable?.toggleList(t);static toggleMark=(e,t)=>{o_("Host toggling mark",t),e.editable?.toggleMark(t)};static getFragment=e=>e.editable?.getFragment();static undo=e=>{o_("Host undoing"),e.editable?.undo()};static redo=e=>{o_("Host redoing"),e.editable?.redo()};static isSelectionsOverlapping=(e,t,n)=>e.editable?.isSelectionsOverlapping(t,n)}function ow(e){let t,n,o=(0,i.c)(4);return o[0]!==e.editorActor||o[1]!==e.patches$?(t=()=>{let t=e.patches$.subscribe(t=>{e.editorActor.send({type:"patches",...t})});return()=>{t.unsubscribe()}},n=[e.editorActor,e.patches$],o[0]=e.editorActor,o[1]=e.patches$,o[2]=t,o[3]=n):(t=o[2],n=o[3]),(0,a.useEffect)(t,n),null}function oS(e){let t,n,r,l,c,d,p,u,h=(0,i.c)(29);h[0]!==e.initialConfig?(t=()=>{let t=ob(e.initialConfig),n=new oE({editor:t.editor});return{internalEditor:t,portableTextEditor:n}},h[0]=e.initialConfig,h[1]=t):t=h[1];let[f]=(0,a.useState)(t),{internalEditor:y,portableTextEditor:g}=f;return h[2]!==y.actors.editorActor||h[3]!==y.actors.mutationActor||h[4]!==y.actors.relayActor||h[5]!==y.actors.syncActor||h[6]!==y.editor._internal.slateEditor.instance||h[7]!==y.subscriptions||h[8]!==g?(n=()=>{let e=[];for(let t of y.subscriptions)e.push(t());let t=y.actors.relayActor.on("*",e=>{let t=ox(e);t&&g.change$.next(t)});return e.push(t.unsubscribe),y.actors.editorActor.start(),y.actors.editorActor.send({type:"add slate editor",editor:y.editor._internal.slateEditor.instance}),y.actors.mutationActor.start(),y.actors.relayActor.start(),y.actors.syncActor.start(),()=>{for(let t of e)t();e4(y.actors.editorActor),e4(y.actors.mutationActor),e4(y.actors.relayActor),e4(y.actors.syncActor)}},h[2]=y.actors.editorActor,h[3]=y.actors.mutationActor,h[4]=y.actors.relayActor,h[5]=y.actors.syncActor,h[6]=y.editor._internal.slateEditor.instance,h[7]=y.subscriptions,h[8]=g,h[9]=n):n=h[9],h[10]!==y||h[11]!==g?(r=[y,g],h[10]=y,h[11]=g,h[12]=r):r=h[12],(0,a.useEffect)(n,r),h[13]!==g||h[14]!==e.children?(l=(0,o.jsx)(eU.Provider,{value:g,children:e.children}),h[13]=g,h[14]=e.children,h[15]=l):l=h[15],h[16]!==y.editor._internal.slateEditor.initialValue||h[17]!==y.editor._internal.slateEditor.instance||h[18]!==l?(c=(0,o.jsx)(s.A,{editor:y.editor._internal.slateEditor.instance,initialValue:y.editor._internal.slateEditor.initialValue,children:l}),h[16]=y.editor._internal.slateEditor.initialValue,h[17]=y.editor._internal.slateEditor.instance,h[18]=l,h[19]=c):c=h[19],h[20]!==y.actors.relayActor||h[21]!==c?(d=(0,o.jsx)(er.Provider,{value:y.actors.relayActor,children:c}),h[20]=y.actors.relayActor,h[21]=c,h[22]=d):d=h[22],h[23]!==y.actors.editorActor||h[24]!==d?(p=(0,o.jsx)(en.Provider,{value:y.actors.editorActor,children:d}),h[23]=y.actors.editorActor,h[24]=d,h[25]=p):p=h[25],h[26]!==y.editor||h[27]!==
8p?(u=(0,o.jsx)(O.p.Provider,{value:y.editor,children:p}),h[26]=y.editor,h[27]=p,h[28]=u):u=h[28],u}let oB=()=>{let e,t,n,o=(0,i.c)(5),r=(0,a.useContext)(en);o[0]!==r?(e=r.getSnapshot(),o[0]=r,o[1]=e):e=o[1];let[l,s]=(0,a.useState)(e.context.selection);return o[2]!==r?(t=()=>{let e=r.on("selection",e=>{(0,a.startTransition)(()=>{s(e.selection)})});return()=>{e.unsubscribe()}},n=[r],o[2]=r,o[3]=t,o[4]=n):(t=o[3],n=o[4]),(0,a.useEffect)(t,n),l}}}]);
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.