1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4988],{47325:(e,t,n)=>{n.d(t,{LF:()=>tQ,Og:()=>tR,l0:()=>t_,pq:()=>tL,v$:()=>ea});var i=n(37876),r=n(41946),l=n(57410),o=n(14232),s=n(91805),a=n(82767),c=n(71673),h=n(27278),d=n(98047),u=n(44239),p=n(97871),f=n(39777),g=n(65159),m=n(99026),y=n(11367),k=n(77050),b=n(40487),v=n(7766),x=n(99342),_=n(87278),E=n(7344),w=n(58465),N=n(48388),B=n(11565),T=n(80782),A=n(58656),S=n(4917);let C="sanity-pte:";function D(e){let t=`${C}${e}`;return c&&c.enabled(t)?c(t):c(C)}function P(e,t,n){let i,r=[e.path[0]];if(!t)return null;let l=t[r[0]];if(!l)return null;let o=[{_key:l._key}];if(l._type!==n.block.name)return o;let s=e.path.slice(0,2),a=Array.isArray(l.children)&&l.children[s[1]];return a&&(i=["children",{_key:a._key}]),i?[...o,...i]:o}function M(e,t){if(!t)return[];let[n,i]=Array.from(s.KE.nodes(t,{at:[],match:t=>(0,h.tA)(e.path[0])&&t._key===e.path[0]._key}))[0]||[void 0,void 0];if(!n||!s.Hg.isElement(n))return[];if(t.isVoid(n))return[i[0],0];let l=[e.path[2]],o=n.children.findIndex(e=>r([{_key:e._key}],l));if(o>=0&&n.children[o]){let e=n.children[o];return s.Hg.isElement(e)&&t.isVoid(e)?i.concat(o).concat(0):i.concat(o)}return i}function $(e,t,n){if(!t)return null;let i=null,r=null,l=t.anchor&&P(t.anchor,e,n);l&&t.anchor&&(i={path:l,offset:t.anchor.offset});let o=t.focus&&P(t.focus,e,n);o&&t.focus&&(r={path:o,offset:t.focus.offset});let a=!!(s.Q6.isRange(t)&&s.Q6.isBackward(t));return i&&r?{anchor:i,focus:r,backward:a}:null}function L(e,t){if(!e||!t)return null;let n={path:M(e.anchor,t),offset:e.anchor.offset},i={path:M(e.focus,t),offset:e.focus.offset};return 0===i.path.length||0===n.path.length?null:n&&i?{anchor:n,focus:i}:null}function I(e,t){if(!e||!t)return null;let n=[],i=e.offset||0,r="object"==typeof e.path[0]&&"_key"in e.path[0]&&e.path[0]._key,l="object"==typeof e.path[2]&&"_key"in e.path[2]&&e.path[2]._key,o=t.find(e=>e._key===r);if(!o)return null;if(n.push({_key:o._key}),o&&"children"===e.path[1]){if(!o.children||Array.isArray(o.children)&&0===o.children.length)return null;let t=Array.isArray(o.children)&&o.children.find(e=>e._key===l);if(!t)return null;n.push("children"),n.push({_key:t._key}),i=t.text&&t.text.length>=e.offset?e.offset:t.text&&t.text.length||0}return{path:n,offset:i}}c(C);let j="void-child";function O(e,t){let n=t[e._key];return n&&r(e,n)?n:(t[e._key]=e,e)}function K(e,{schemaTypes:t},n={}){return e&&Array.isArray(e)?e.map(e=>{let{_type:i,_key:r,...l}=e,o=[{_key:j,_type:"span",text:"",marks:[]}];if(e&&e._type===t.block.name){let a=!1,c=typeof e.style>"u",h=typeof e.markDefs>"u",d=typeof e.children>"u",u=(e.children||[]).map(e=>{let{_type:t,_key:i,...r}=e;return"span"!==t?(a=!0,O({_type:t,_key:i,children:o,value:r,__inline:!0},n)):e});return!(!c&&!h&&!d&&!a&&s.Hg.isElement(e))?(c&&(l.style=t.styles[0].value),O({_type:i,_key:r,...l,children:u},n)):e}return O({_type:i,_key:r,children:o,value:l},n)}):[]}function R(e,t,n={}){return e.map(e=>{let{_key:i,_type:r}=e;if(!i||!r)throw Error("Not a valid block");if(r===t&&"children"in e&&Array.isArray(e.children)&&i){let t=!1,l=e.children.map(e=>{let{_type:i}=e;if("value"in e&&"span"!==i){t=!0;let{value:i,_key:r,_type:l,__inline:o,children:s,...a}=e;return O({...a,...i,_key:r,_type:l},n)}return e});return t?O({...e,children:l,_key:i,_type:r},n):e}let l="value"in e&&e.value;return O({_key:i,_type:r,..."object"==typeof l?l:{}},n)})}function z(e,t){return void 0===e||e&&Array.isArray(e)&&0===e.length||e&&Array.isArray(e)&&1===e.length&&s.Hg.isElement(e[0])&&e[0]._type===t.block.name&&"style"in e[0]&&e[0].style===t.styles[0].value&&!("listItem"in e[0])&&Array.isArray(e[0].children)&&1===e[0].children.length&&s.EY.isText(e[0].children[0])&&"span"===e[0].children[0]._type&&!e[0].children[0].marks?.join("")&&""===e[0].children[0].text}let H=new WeakMap,V=new WeakMap,Y=new WeakMap,J=new WeakMap,Q=new WeakMap,U=new WeakMap,W=new WeakMap,q=new WeakMap,F=new WeakMap,Z=e=>(0,i.jsx)("div",{children:(0,i.jsx)("pre",{children:JSON.stringify(e.value,null,2)})}),X=d.I4.div` 2 user-select: none; 3 border: ${e=>e.selected?"1px solid blue":"1px solid transparent"}; 4`;d.I4.span` 5 background: #999; 6 border: ${e=>e.selected?"1px solid blue":"1px solid transparent"}; 7`;let G=d.I4.div` 8 &.pt-list-item { 9 width: fit-content; 10 position: relative; 11 display: block; 12 13 /* Important 'transform' in order to force refresh the ::before and ::after rules 14 in Webkit: https://stackoverflow.com/a/21947628/831480 15 */ 16 transform: translateZ(0); 17 margin-left: ${e=>(function(e){switch(Number(e)){case 1:return"1.5em";case 2:return"3em";case 3:return"4.5em";case 4:return"6em";
17case 5:return"7.5em";case 6:return"9em";case 7:return"10.5em";case 8:return"12em";case 9:return"13.5em";case 10:return"15em";default:return"0em"}})(e.listLevel)}; 18 } 19 &.pt-list-item > .pt-list-item-inner { 20 display: flex; 21 margin: 0; 22 padding: 0; 23 &:before { 24 justify-content: flex-start; 25 vertical-align: top; 26 } 27 } 28 &.pt-list-item-bullet > .pt-list-item-inner:before { 29 content: '${e=>{var t;return t=e.listLevel,"bullet"===e.listStyle?et[(t-1)%3]:"*"}}'; 30 font-size: 0.4375rem; /* 7px */ 31 line-height: 1.5rem; /* Same as body text */ 32 /* Optical alignment */ 33 position: relative; 34 } 35 } 36 &.pt-list-item-bullet > .pt-list-item-inner { 37 &:before { 38 min-width: 1.5rem; /* Make sure space between bullet and text never shrinks */ 39 } 40 } 41 &.pt-list-item-number { 42 counter-increment: ${e=>(function(e){switch(e){case 1:return"listItemNumber";case 2:return"listItemAlpha";case 3:return"listItemRoman";case 4:return"listItemNumberNext";case 5:return"listItemLetterNext";case 6:return"listItemRomanNext";case 7:return"listItemNumberNextNext";case 8:return"listItemAlphaNextNext";case 9:return"listItemRomanNextNext";default:return"listItemNumberNextNextNext"}})(e.listLevel)}; 43 counter-reset: ${e=>(function(e){switch(e){case 1:return"listItemAlpha";case 2:return"listItemRoman";case 3:return"listItemNumberNext";case 4:return"listItemLetterNext";case 5:return"listItemRomanNext";case 6:return"listItemNumberNextNext";case 7:return"listItemAlphaNextNext";case 8:return"listItemRomanNextNext";default:return"listItemNumberNextNextNext"}})(e.listLevel)}; 44 } 45 & + :not(.pt-list-item-number) { 46 counter-reset: listItemNumber; 47 } 48 &.pt-list-item-number > .pt-list-item-inner:before { 49 content: ${e=>(function(e){switch(e){case 1:return"counter(listItemNumber) '. '";case 2:return"counter(listItemAlpha, lower-alpha) '. '";case 3:return"counter(listItemRoman, lower-roman) '. '";case 4:return"counter(listItemNumberNext) '. '";case 5:return"counter(listItemLetterNext, lower-alpha) '. '";case 6:return"counter(listItemRomanNext, lower-roman) '. '";case 7:return"counter(listItemNumberNextNext) '. '";case 8:return"counter(listItemAlphaNextNext, lower-alpha) '. '";case 9:return"counter(listItemRomanNextNext, lower-roman) '. '";default:return"counter(listItemNumberNextNextNext) '. '"}})(e.listLevel)}; 50 min-width: 1.5rem; /* Make sure space between number and text never shrinks */ 51 /* Optical alignment */ 52 position: relative; 53 top: 1px; 54 } 55`,ee=d.I4.div``,et=["â","â","â "],en=D("components:DraggableBlock"),ei=({children:e,element:t,readOnly:n,blockRef:r})=>{let l=(0,a.RV)(),c=(0,o.useRef)(),[h,d]=(0,o.useState)(!1),u=(0,o.useMemo)(()=>s.KE.isVoid(l,t),[l,t]),p=(0,o.useMemo)(()=>s.KE.isInline(l,t),[l,t]),[f,g]=(0,o.useState)(null);(0,o.useEffect)(()=>g(r?r.current:a.rL.toDOMNode(l,t)),[l,t,r]);let m=(0,o.useCallback)(e=>{let n=J.get(l);if(!n||!f)return;e.preventDefault(),e.dataTransfer.dropEffect="move",Q.set(l,t);let i=f.getBoundingClientRect(),r=i.top,o=i.height,s=Math.abs(r-e.pageY),a="bottom";if(t===l.children[0]?a="top":(a=s<o/2?"top":"bottom",U.set(l,a)),n===t){e.dataTransfer.dropEffect="none";return}d(!0)},[f,l,t]),y=(0,o.useCallback)(()=>{d(!1)},[]),k=(0,o.useCallback)(e=>{let n=Q.get(l);if(n){Y.set(l,!1),e.preventDefault(),e.stopPropagation(),Q.delete(l),c.current&&(en("Removing drag ghost"),document.body.removeChild(c.current));let i=U.get(l);U.delete(l);let r=a.rL.findPath(l,n),o=a.rL.findPath(l,t),h=s.wA.isBefore(o,r);if("bottom"===i&&!h){if(r[0]>=l.children.length-1)return void en("target is already at the bottom, not moving");let e=r;r=s.wA.next(r),en(`Adjusting targetPath from ${JSON.stringify(e)} to ${JSON.stringify(r)}`)}if("top"===i&&h&&r[0]!==l.children.length-1){let e=r;r=s.wA.previous(r),en(`Adjusting targetPath from ${JSON.stringify(e)} to ${JSON.stringify(r)}`)}if(s.wA.equals(r,o)){e.preventDefault(),en("targetPath and myPath is the same, not moving");return}en(`Moving element ${t._key} from path ${JSON.stringify(o)} to ${JSON.stringify(r)} (${i})`),s.gB.moveNodes(l,{at:o,to:r}),l.onChange();return}en("No target element, not doing anything")},[l,t]),b=(0,o.useCallback)(e=>{J.get(l)&&(en("On drop (prevented)",t),e.preventDefault(),e.stopPropagation(),d(!1))},[l,t]),v=(0,o.useCallback)(e=>{if(!u)return void J.delete(l);Y.set(l,!0),J.set(l,t),e.stopPropagation();let n=e.target;n instanceof HTMLElement&&(n.style.opacity="1")},[l,t,u]),x=(0,o.useCallback)(e=>{if(!u||p){en("Not dragging block"),J.delete(l),Y.set(l,!1);return}if(en("Drag start"),Y.set(l,!0),e.dataTransfer&&(e.dataTransfer.setData("application/portable-text","something"),e.dataTransfer.effectAllowed="move"),f&&f instanceof HTMLElement){let t=f.cloneNode(!0),n=t.querySelector("[data-pt-drag-ghost-element]");if(n&&(t=n),t.setAttribute("data-dragged",""),document.body){c.current=t,t.style.position="absolute",t.style.left="-99999px",t.style.boxSizing="border-box",document.body.appendChild(t);let n=f.getBoundingClientRect(),i=e.clientX-n.left,r=e.clientY-n.top;t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,e.dataTransfer.setDragImage(t,i,r)}}v(e)},[f,l,v,p,u]),_=h&&l.children[0]===Q.get(l),E=h&&l.children[l.children.length-1]===Q.get(l),w=U.get(l),N=_||h&&!_&&!E&&"top"===w,B=E||h&&!_&&!E&&"bottom"===w,T=(0,o.useMemo)(()=>(0,i.jsx)("div",{className:"pt-drop-indicator",style:{position:"absolute",width:"100%",height:1,borderBottom:"1px solid currentColor",zIndex:5}}),[]);return n?(0,i.jsx)(i.Fragment,{children:e}):(0,i.jsxs)("div",{draggable:u,onDragStart:x,onDrag:v,onDragOver:m,onDragLeave:y,onDragEnd:k,onDrop:b,children:[N&&T,e,B&&T]})};D("components:Element");let er=[],el={display:"inline-block"},eo=({attributes:e,children:t,element:n,schemaTypes:r,readOnly:l,renderBlock:c,renderChild:h,renderListItem:d,renderStyle:u,spellCheck:p})=>{let f,g=(0,a.RV)(),m=(0,a.f7)(),y=(0,o.useRef)(null),k=(0,o.useRef)(null),b=m&&g.selection&&s.Q6.isCollapsed(g.selection)||!1,v=(0,o.useMemo)(()=>R([n],r.block.name,q.get(g))[0],[g,n,r.block.name]),x=t,_,E=(0,o.useMemo)(()=>[{_key:n._key}],[n]);if("string"!=typeof n._type)throw Error("Expected element to have a _type property");if("string"!=typeof n._key)throw Error("Expected element to have a _key property");if(g.isInline(n)){let o=a.rL.findPath(g,n),[c]=s.KE.node(g,o,{depth:1}),d=r.inlineObjects.find(e=>e.name===n._type);if(!d)throw Error("Could not find type for inline block element");
55if(s.Hg.isElement(c)){let r=[{_key:c._key},"children",{_key:n._key}];return(0,i.jsxs)("span",{...e,children:[t,(0,i.jsxs)("span",{draggable:!l,className:"pt-inline-object","data-testid":"pt-inline-object",ref:k,style:el,contentEditable:!1,children:[h&&h({annotations:er,children:(0,i.jsx)(Z,{value:v}),editorElementRef:k,focused:b,path:r,schemaType:d,selected:m,type:d,value:v}),!h&&(0,i.jsx)(Z,{value:v})]},n._key)]})}throw Error("Block not found!")}if(n._type===r.block.name){let o;_="pt-block pt-text-block";let s="listItem"in n,a="style"in n&&n.style||"normal";_=`pt-block pt-text-block pt-text-block-style-${a}`;let h=r.styles.find(e=>e.value===a);if(u&&h&&(x=u({block:n,children:t,focused:b,selected:m,value:a,path:E,schemaType:h,editorElementRef:y})),s&&("number"==typeof n.level&&(o=n.level),_+=` pt-list-item pt-list-item-${n.listItem} pt-list-item-level-${o||1}`),g.isListBlock(v)&&s&&n.listItem){let e=r.lists.find(e=>e.value===n.listItem);x=d&&e?d({block:v,children:x,focused:b,selected:m,value:n.listItem,path:E,schemaType:e,level:v.level||1,editorElementRef:y}):(0,i.jsx)(G,{listStyle:v.listItem||r.lists[0].value,listLevel:v.level||1,children:(0,i.jsx)(ee,{children:x})})}let f=Object.defineProperty({children:x,editorElementRef:y,focused:b,level:o,listItem:s?n.listItem:void 0,path:E,selected:m,style:a,schemaType:r.block,value:v},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),r.block)}),k=c?c(f):t;return(0,i.jsx)("div",{...e,className:_,spellCheck:p,children:(0,i.jsx)(ei,{element:n,readOnly:l,blockRef:y,children:(0,i.jsx)("div",{ref:y,children:k})})},n._key)}let w=r.blockObjects.find(e=>e.name===n._type);if(!w)throw Error(`Could not find schema type for block element of _type ${n._type}`);_="pt-block pt-object-block";let N=R([n],r.block.name,q.get(g))[0];return c&&(f=c(Object.defineProperty({children:(0,i.jsx)(Z,{value:v}),editorElementRef:y,focused:b,path:E,schemaType:w,selected:m,value:N},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),w)}))),(0,i.jsxs)("div",{...e,className:_,children:[t,(0,i.jsxs)(ei,{element:n,readOnly:l,blockRef:y,children:[f&&(0,i.jsx)("div",{ref:y,contentEditable:!1,children:f}),!f&&(0,i.jsx)(X,{selected:m,children:(0,i.jsx)(Z,{value:v})})]})]},n._key)},es=(0,o.createContext)(null),ea=()=>{let e=(0,o.useContext)(es);if(!e)throw Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");return e};function ec(e){let t=(0,o.useCallback)(()=>alert(JSON.stringify(e.annotation)),[e.annotation]);return(0,i.jsx)("span",{style:{color:"blue"},onClick:t,children:e.children})}function eh(e){if(!e)throw Error("Parameter 'portabletextType' missing (required)");let t=e.of?.find(function e(t){return t.type?e(t.type):"block"===t.name?t:null});if(!t)throw Error("Block type is not defined in this schema (required)");let n=t.fields?.find(e=>"children"===e.name);if(!n)throw Error("Children field for block type found in schema (required)");let i=n.type.of;if(!i)throw Error("Valid types for block children not found in schema (required)");let r=i.find(e=>"span"===e.name);if(!r)throw Error("Span type not found in schema (required)");let l=i.filter(e=>"span"!==e.name)||[],o=e.of?.filter(e=>e.name!==t.name)||[];return{styles:function(e){let t=e.fields?.find(e=>"style"===e.name);if(!t)throw Error("A field with name 'style' is not defined in the block type (required).");let n=t.type.options?.list&&t.type.options.list?.filter(e=>e.value);if(!n||0===n.length)throw Error("The style fields need at least one style defined. I.e: {title: 'Normal', value: 'normal'}.");return n}(t),decorators:r.decorators,lists:function(e){let t=e.fields?.find(e=>"listItem"===e.name);if(!t)throw Error("A field with name 'listItem' is not defined in the block type (required).");let n=t.type.options?.list&&t.type.options.list.filter(e=>e.value);if(!n)throw Error("The list field need at least to be an empty array");return n}(t),block:t,span:r,portableText:e,inlineObjects:l,blockObjects:o,annotations:r.annotations}}function ed(e){return k.S.compile({name:"blockTypeSchema",types:[e]}).get(e.name)}
55let eu=D("operationToPatches"),ep=D("API:editable");function ef(e,t){let n=eg(e)||!1;H.set(e,!0),t(),H.set(e,n)}function eg(e){return H.get(e)}let em=new WeakMap,ey=new WeakMap;function ek(e){return em.get(e)??!1}function eb(e){return ey.get(e)??!1}function ev(e){let[t,n]=e;return[t,n]}function ex(e,t){let n=e,i=t,r=n.length,l=i.length;if(0===r||0===l)return 0;r>l?n=n.substring(r-l):r<l&&(i=i.substring(0,r));let o=Math.min(r,l);if(n===i)return o;let s=0,a=1;for(let e=0;-1!==e;){let t=n.substring(o-a);if(-1===(e=i.indexOf(t)))break;a+=e,(0===e||n.substring(o-a)===i.substring(0,a))&&(s=a,a++)}return s}function e_(e,t){if(!e||!t||e[0]!==t[0])return 0;let n=0,i=Math.min(e.length,t.length),r=i,l=0;for(;n<r;)e.substring(l,r)===t.substring(l,r)?l=n=r:i=r,r=Math.floor((i-n)/2+n);return r}function eE(e,t){if(!e||!t||e[e.length-1]!==t[t.length-1])return 0;let n=0,i=Math.min(e.length,t.length),r=i,l=0;for(;n<r;)e.substring(e.length-r,e.length-l)===t.substring(t.length-r,t.length-l)?l=n=r:i=r,r=Math.floor((i-n)/2+n);return r}let ew=/[^a-zA-Z0-9]/,eN=/\s/,eB=/[\r\n]/,eT=/\n\r?\n$/,eA=/^\r?\n\r?\n/;function eS(e){let t=e.map(e=>ev(e));function n(e,t){if(!e||!t)return 6;let n=e.charAt(e.length-1),i=t.charAt(0),r=n.match(ew),l=i.match(ew),o=r&&n.match(eN),s=l&&i.match(eN),a=o&&n.match(eB),c=s&&i.match(eB),h=a&&e.match(eT),d=c&&t.match(eA);return h||d?5:a||c?4:r&&!o&&s?3:o||s?2:r||l?1:0}let i=1;for(;i<t.length-1;){if(t[i-1][0]===eL&&t[i+1][0]===eL){let e=t[i-1][1],r=t[i][1],l=t[i+1][1],o=eE(e,r);if(o){let t=r.substring(r.length-o);e=e.substring(0,e.length-o),r=t+r.substring(0,r.length-o),l=t+l}let s=e,a=r,c=l,h=n(e,r)+n(r,l);for(;r.charAt(0)===l.charAt(0);){e+=r.charAt(0),r=r.substring(1)+l.charAt(0),l=l.substring(1);let t=n(e,r)+n(r,l);t>=h&&(h=t,s=e,a=r,c=l)}t[i-1][1]!==s&&(s?t[i-1][1]=s:(t.splice(i-1,1),i--),t[i][1]=a,c?t[i+1][1]=c:(t.splice(i+1,1),i--))}i++}return t}function eC(e){let t=e.map(e=>ev(e));t.push([eL,""]);let n=0,i=0,r=0,l="",o="",s;for(;n<t.length;)switch(t[n][0]){case e$:r++,o+=t[n][1],n++;break;case eM:i++,l+=t[n][1],n++;break;case eL:i+r>1?(0!==i&&0!==r&&(0!==(s=e_(o,l))&&(n-i-r>0&&t[n-i-r-1][0]===eL?t[n-i-r-1][1]+=o.substring(0,s):(t.splice(0,0,[eL,o.substring(0,s)]),n++),o=o.substring(s),l=l.substring(s)),0!==(s=eE(o,l))&&(t[n][1]=o.substring(o.length-s)+t[n][1],o=o.substring(0,o.length-s),l=l.substring(0,l.length-s))),n-=i+r,t.splice(n,i+r),l.length&&(t.splice(n,0,[eM,l]),n++),o.length&&(t.splice(n,0,[e$,o]),n++),n++):0!==n&&t[n-1][0]===eL?(t[n-1][1]+=t[n][1],t.splice(n,1)):n++,r=0,i=0,l="",o="";break;default:throw Error("Unknown diff operation")}""===t[t.length-1][1]&&t.pop();let a=!1;for(n=1;n<t.length-1;)t[n-1][0]===eL&&t[n+1][0]===eL&&(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),a=!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),a=!0)),n++;return a&&(t=eC(t)),t}function eD(e,t,n,i,r){let l=e.substring(0,n),o=t.substring(0,i),s=e.substring(n),a=t.substring(i),c=ej(l,o,{checkLines:!1,deadline:r}),h=ej(s,a,{checkLines:!1,deadline:r});return c.concat(h)}function eP(e,t,n){let i=e.slice(n,n+Math.floor(e.length/4)),r=-1,l="",o,s,a,c;for(;-1!==(r=t.indexOf(i,r+1));){let i=e_(e.slice(n),t.slice(r)),h=eE(e.slice(0,n),t.slice(0,r));l.length<h+i&&(l=t.slice(r-h,r)+t.slice(r,r+i),o=e.slice(0,n-h),s=e.slice(n+i),a=t.slice(0,r-h),c=t.slice(r+i))}return 2*l.length>=e.length?[o||"",s||"",a||"",c||"",l||""]:null}let eM=-1,e$=1,eL=0;function eI(e,t,n){var i,r;let l;if(null===e||null===t)throw Error("Null input. (diff)");let o=ej(e,t,{checkLines:!0,deadline:(r=(i=n||{}).timeout||1,l=1,"u">typeof r&&(l=r<=0?Number.MAX_VALUE:r),Date.now()+1e3*l),...i});return function(e){for(let t=0;t<e.length;t++){let[n,i]=e[t];if(0===i.length)continue;let r=i[0];(function(e){let t=e.charCodeAt(0);return t>=55296&&t<=56319})(i[i.length-1])&&n===eL&&eR(e,t,1),function(e){let t=e.charCodeAt(0);return t>=56320&&t<=57343}(r)&&n===eL&&eR(e,t,-1)}for(let t=0;t<e.length;t++)0===e[t][1].length&&e.splice(t,1)}(o),o}
55function ej(e,t,n){let i=e,r=t;if(i===r)return i?[[eL,i]]:[];let l=e_(i,r),o=i.substring(0,l);l=eE(i=i.substring(l),r=r.substring(l));let s=i.substring(i.length-l),a=function(e,t,n){let i;if(!e)return[[e$,t]];if(!t)return[[eM,e]];let r=e.length>t.length?e:t,l=e.length>t.length?t:e,o=r.indexOf(l);if(-1!==o)return i=[[e$,r.substring(0,o)],[eL,l],[e$,r.substring(o+l.length)]],e.length>t.length&&(i[0][0]=eM,i[2][0]=eM),i;if(1===l.length)return[[eM,e],[e$,t]];let s=function(e,t){let n,i,r,l,o;if((arguments.length>2&&void 0!==arguments[2]?arguments[2]:1)<=0)return null;let s=e.length>t.length?e:t,a=e.length>t.length?t:e;if(s.length<4||2*a.length<s.length)return null;let c=eP(s,a,Math.ceil(s.length/4)),h=eP(s,a,Math.ceil(s.length/2));if(c&&h)n=c[4].length>h[4].length?c:h;else{if(!c&&!h)return null;h?c||(n=h):n=c}if(!n)throw Error("Unable to find a half match.");return e.length>t.length?(i=n[0],r=n[1],l=n[2],o=n[3]):(l=n[0],o=n[1],i=n[2],r=n[3]),[i,r,l,o,n[4]]}(e,t);if(s){let e=s[0],t=s[1],i=s[2],r=s[3],l=s[4],o=ej(e,i,n),a=ej(t,r,n);return o.concat([[eL,l]],a)}return n.checkLines&&e.length>100&&t.length>100?function(e,t,n){let i=e,r=t,l=function(e,t){let n=[],i={};function r(e){let t="",r=0,o=-1,s=n.length;for(;o<e.length-1;){-1===(o=e.indexOf(` 56`,r))&&(o=e.length-1);let a=e.slice(r,o+1);(i.hasOwnProperty?i.hasOwnProperty(a):void 0!==i[a])?t+=String.fromCharCode(i[a]):(s===l&&(a=e.slice(r),o=e.length),t+=String.fromCharCode(s),i[a]=s,n[s++]=a),r=o+1}return t}n[0]="";let l=4e4,o=r(e);return l=65535,{chars1:o,chars2:r(t),lineArray:n}}(i,r);i=l.chars1,r=l.chars2;let o=l.lineArray,s=ej(i,r,{checkLines:!1,deadline:n.deadline});(function(e,t){for(let n=0;n<e.length;n++){let i=e[n][1],r=[];for(let e=0;e<i.length;e++)r[e]=t[i.charCodeAt(e)];e[n][1]=r.join("")}})(s,o),(s=function(e){let t=e.map(e=>ev(e)),n=!1,i=[],r=0,l=null,o=0,s=0,a=0,c=0,h=0;for(;o<t.length;)t[o][0]===eL?(i[r++]=o,s=c,a=h,c=0,h=0,l=t[o][1]):(t[o][0]===e$?c+=t[o][1].length:h+=t[o][1].length,l&&l.length<=Math.max(s,a)&&l.length<=Math.max(c,h)&&(t.splice(i[r-1],0,[eM,l]),t[i[r-1]+1][0]=e$,r--,o=--r>0?i[r-1]:-1,s=0,a=0,c=0,h=0,l=null,n=!0)),o++;for(n&&(t=eC(t)),t=eS(t),o=1;o<t.length;){if(t[o-1][0]===eM&&t[o][0]===e$){let e=t[o-1][1],n=t[o][1],i=ex(e,n),r=ex(n,e);i>=r?(i>=e.length/2||i>=n.length/2)&&(t.splice(o,0,[eL,n.substring(0,i)]),t[o-1][1]=e.substring(0,e.length-i),t[o+1][1]=n.substring(i),o++):(r>=e.length/2||r>=n.length/2)&&(t.splice(o,0,[eL,e.substring(0,r)]),t[o-1][0]=e$,t[o-1][1]=n.substring(0,n.length-r),t[o+1][0]=eM,t[o+1][1]=e.substring(r),o++),o++}o++}return t}(s)).push([eL,""]);let a=0,c=0,h=0,d="",u="";for(;a<s.length;){switch(s[a][0]){case e$:h++,u+=s[a][1];break;case eM:c++,d+=s[a][1];break;case eL:if(c>=1&&h>=1){s.splice(a-c-h,c+h),a=a-c-h;let e=ej(d,u,{checkLines:!1,deadline:n.deadline});for(let t=e.length-1;t>=0;t--)s.splice(a,0,e[t]);a+=e.length}h=0,c=0,d="",u="";break;default:throw Error("Unknown diff operation.")}a++}return s.pop(),s}(e,t,n):function(e,t,n){let i=e.length,r=t.length,l=Math.ceil((i+r)/2),o=2*l,s=Array(o),a=Array(o);for(let e=0;e<o;e++)s[e]=-1,a[e]=-1;s[l+1]=0,a[l+1]=0;let c=i-r,h=c%2!=0,d=0,u=0,p=0,f=0;for(let g=0;g<l&&!(Date.now()>n);g++){for(let p=-g+d;p<=g-u;p+=2){let f,m=l+p,y=(f=p===-g||p!==g&&s[m-1]<s[m+1]?s[m+1]:s[m-1]+1)-p;for(;f<i&&y<r&&e.charAt(f)===t.charAt(y);)f++,y++;if(s[m]=f,f>i)u+=2;else if(y>r)d+=2;else if(h){let r=l+c-p;if(r>=0&&r<o&&-1!==a[r]&&f>=i-a[r])return eD(e,t,f,y,n)}}for(let d=-g+p;d<=g-f;d+=2){let u,m=l+d,y=(u=d===-g||d!==g&&a[m-1]<a[m+1]?a[m+1]:a[m-1]+1)-d;for(;u<i&&y<r&&e.charAt(i-u-1)===t.charAt(r-y-1);)u++,y++;if(a[m]=u,u>i)f+=2;else if(y>r)p+=2;else if(!h){let r=l+c-d;if(r>=0&&r<o&&-1!==s[r]){let o=s[r],a=l+o-r;if(o>=(u=i-u))return eD(e,t,o,a,n)}}}}return[[eM,e],[e$,t]]}(e,t,n.deadline)}(i=i.substring(0,i.length-l),r=r.substring(0,r.length-l),n);return o&&a.unshift([eL,o]),s&&a.push([eL,s]),a=eC(a)}function eO(e,t,n){return 1===n?e+t:t+e}function eK(e,t){return 1===t?[e.substring(0,e.length-1),e[e.length-1]]:[e.substring(1),e[0]]}function eR(e,t,n){var i,r;let l=1===n?-1:1,o=null,s=null,a=t+n;for(;a>=0&&a<e.length&&(null===o||null===s);a+=n){let[i,r]=e[a];if(0!==r.length){if(i===e$){null===o&&(o=a);continue}else if(i===eM){null===s&&(s=a);continue}else if(i===eL){if(null===o&&null===s){let[i,r]=eK(e[t][1],n);e[t][1]=i,e[a][1]=eO(e[a][1],r,l);return}break}}}if(null!==o&&null!==s&&(i=o,r=s,1===n?e[i][1][e[i][1].length-1]===e[r][1][e[r][1].length-1]:e[i][1][0]===e[r][1][0])){let[i,r]=eK(e[o][1],l),[a]=eK(e[s][1],l);
56e[o][1]=i,e[s][1]=a,e[t][1]=eO(e[t][1],r,n);return}let[c,h]=eK(e[t][1],n);e[t][1]=c,null===o?(e.splice(a,0,[e$,h]),null!==s&&s>=a&&s++):e[o][1]=eO(e[o][1],h,l),null===s?e.splice(a,0,[eM,h]):e[s][1]=eO(e[s][1],h,l)}let ez={threshold:.5,distance:1e3};function eH(e,t,n){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){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(t.length>32)throw Error("Pattern too long for this browser.");let r={...ez,...i},l=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 o(e,i){let l=e/t.length,o=Math.abs(n-i);return r.distance?l+o/r.distance:o?1:l}let s=r.threshold,a=e.indexOf(t,n);-1!==a&&(s=Math.min(o(0,a),s),-1!==(a=e.lastIndexOf(t,n+t.length))&&(s=Math.min(o(0,a),s)));let c=1<<t.length-1;a=-1;let h,d,u=t.length+e.length,p=[];for(let i=0;i<t.length;i++){for(h=0,d=u;h<d;)o(i,n+d)<=s?h=d:u=d,d=Math.floor((u-h)/2+h);u=d;let r=Math.max(1,n-d+1),f=Math.min(n+d,e.length)+t.length,g=Array(f+2);g[f+1]=(1<<i)-1;for(let t=f;t>=r;t--){let h=l[e.charAt(t-1)];if(0===i?g[t]=(g[t+1]<<1|1)&h:g[t]=(g[t+1]<<1|1)&h|((p[t+1]|p[t])<<1|1)|p[t+1],g[t]&c){let e=o(i,t-1);if(e<=s)if(s=e,(a=t-1)>n)r=Math.max(1,2*n-a);else break}}if(o(i+1,n)>s)break;p=g}return a}(e,t,i):-1}function eV(e,t){return{diffs:[],start1:e,start2:t,utf8Start1:e,utf8Start2:t,length1:0,length2:0,utf8Length1:0,utf8Length2:0}}function eY(e){let t=[];for(let n=0;n<e.length;n++)e[n][0]!==e$&&(t[n]=e[n][1]);return t.join("")}function eJ(e){let t=[];for(let n=0;n<e.length;n++)e[n][0]!==eM&&(t[n]=e[n][1]);return t.join("")}function eQ(e){let t=0;for(let n=0;n<e.length;n++){let i=e.codePointAt(n);if(typeof i>"u")throw Error("Failed to get codepoint");t+=eU(i)}return t}function eU(e){return e<=127?1:e<=2047?2:e<=65535?3:4}function eW(e,t){let n=0,i=0,r=0,l=0,o;for(o=0;o<e.length&&(e[o][0]!==e$&&(n+=e[o][1].length),e[o][0]!==eM&&(i+=e[o][1].length),!(n>t));o++)r=n,l=i;return e.length!==o&&e[o][0]===eM?l:l+(t-r)}let eq=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;function eF(e){if(!e)return[];let t=[],n=e.split(` 57`),i=0;for(;i<n.length;){let e=n[i].match(eq);if(!e)throw Error("Invalid patch string: ".concat(n[i]));let r=eV(eZ(e[1]),eZ(e[3]));for(t.push(r),""===e[2]?(r.start1--,r.utf8Start1--,r.length1=1,r.utf8Length1=1):"0"===e[2]?(r.length1=0,r.utf8Length1=0):(r.start1--,r.utf8Start1--,r.utf8Length1=eZ(e[2]),r.length1=r.utf8Length1),""===e[4]?(r.start2--,r.utf8Start2--,r.length2=1,r.utf8Length2=1):"0"===e[4]?(r.length2=0,r.utf8Length2=0):(r.start2--,r.utf8Start2--,r.utf8Length2=eZ(e[4]),r.length2=r.utf8Length2),i++;i<n.length;){let e,t=n[i],l=t.charAt(0);if("@"===l)break;if(""===l){i++;continue}try{e=decodeURI(t.slice(1))}catch{throw Error("Illegal escape in parse: ".concat(t))}let o=eQ(e)-e.length;if("-"===l)r.diffs.push([eM,e]),r.length1-=o;else if("+"===l)r.diffs.push([e$,e]),r.length2-=o;else if(" "===l)r.diffs.push([eL,e]),r.length1-=o,r.length2-=o;else throw Error('Invalid patch mode "'.concat(l,'" in: ').concat(e));i++}}return t}function eZ(e){return parseInt(e,10)}let eX=D("applyPatches"),eG=eX.enabled&&!0;function e0(e){return"object"==typeof e&&"_key"in e}function e1(e,t){eG&&(eX(`Children ${t}:`,JSON.stringify(e.children,null,2)),eX(`Selection ${t}: `,JSON.stringify(e.selection,null,2)))}function e2(e,t){let{block:n,path:i}=function(e,t){let n=-1,i=e.children.find((e,i)=>{let r=e0(t[0])?e._key===t[0]._key:i===t[0];return r&&(n=i),r});return i?{block:i,path:[n]}:{}}(e,t);if(!(s.Hg.isElement(n)&&"children"===t[1]))return{block:n,blockPath:i,child:void 0,childPath:void 0};let r=-1,l=n.children.find((e,n)=>{let i=e0(t[2])?e._key===t[2]._key:n===t[2];return i&&(r=n),i});return l?{block:n,child:l,blockPath:i,childPath:i?.concat(r)}:{block:n,blockPath:i,child:void 0,childPath:void 0}}let e8=new WeakMap;function e6(e,t){var n;let i=(n=e,e8.get(n));e8.set(e,!1),t(),e8.set(e,i)}let e3=D("plugin:withUndoRedo"),e4=e3.enabled&&!1,e5=new WeakMap,e7=new WeakMap,e9=e=>{let t=e5.get(e);return void 0===t||t};function te(e,t,n,i,l){e4&&(e3(`Adjusting '${n.type}' operation paths for '${t.type}' patch`),e3(`Operation ${JSON.stringify(n)}`),e3(`Patch ${JSON.stringify(t)}`));let o={...n};if("insert"===t.type&&1===t.path.length){let e=(i||[]).findIndex(e=>r({_key:e._key},t.path[0]));return e3(`Adjusting block path (+${t.items.length}) for '${o.type}' operation and patch '${t.type}'`),[tt(o,t.items.length,e)]}if("unset"===t.type&&1===t.path.length){let n=(l||[]).findIndex(e=>r({_key:e._key},t.path[0]));return"path"in o&&Array.isArray(o.path)&&o.path[0]===n?(e3("Skipping transformation that targeted removed block"),[]):(e4&&(e3(`Selection ${JSON.stringify(e.selection)}`),e3(`Adjusting block path (-1) for '${o.type}' operation and patch '${t.type}'`)),[tt(o,-1,n)])}if("unset"===t.type&&0===t.path.length)return e3(`Adjusting selection for unset everything patch and ${n.type} operation`),[];
57if("diffMatchPatch"===t.type){var s,a;let n,i=(s=e,"set_selection"===(a=o).type&&s.selection?n=s.children[s.selection.focus.path[0]]:"path"in a&&(n=s.children[a.path[0]]),n);return i&&r({_key:i._key},t.path[0])&&eF(t.value).forEach(e=>{let t=0,n=e.utf8Start1,{diffs:i}=e;if(i.forEach((e,r)=>{let[l,o]=e;l===e$?(t+=o.length,n+=o.length):l===eM?(t-=o.length,n-=o.length):l===eL&&(i.slice(r).every(([e])=>e===eL)||(n+=o.length))}),"insert_text"===o.type&&n<o.offset&&(o.offset+=t),"remove_text"===o.type&&n<=o.offset-o.text.length&&(o.offset+=t),"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,l=o?.newProperties?.anchor?{...o.newProperties.anchor}:void 0;(e&&i||r&&l)&&([e,i,r,l].forEach(e=>{e&&n<e.offset&&(e.offset+=t)}),e&&i&&(o.properties={focus:e,anchor:i}),r&&l&&(o.newProperties={focus:r,anchor:l}))}}),[o]}return[o]}function tt(e,t,n){let i={...e};if(n>=0&&"set_selection"!==i.type&&Array.isArray(i.path)&&i.path[0]>=n+t&&i.path[0]+t>-1){let e=[i.path[0]+t,...i.path.slice(1)];i.path=e}if("set_selection"===i.type){let e=i.properties?.focus?{...i.properties.focus}:void 0,r=i?.properties?.anchor?{...i.properties.anchor}:void 0,l=i?.newProperties?.focus?{...i.newProperties.focus}:void 0,o=i?.newProperties?.anchor?{...i.newProperties.anchor}:void 0;(e&&r||l&&o)&&([e,r,l,o].forEach(e=>{e&&e.path[0]>=n+t&&e.path[0]+t>-1&&(e.path=[e.path[0]+t,...e.path.slice(1)])}),e&&r&&(i.properties={focus:e,anchor:r}),l&&o&&(i.newProperties={focus:l,anchor:o}))}return i}function tn(e,t){let n=e9(e);e5.set(e,!1),t(),e5.set(e,n)}let ti=D("plugin:withPatches"),tr=D("plugin:withPlaceholderBlock"),tl=D("plugin:withPortableTextBlockStyle"),to=D("plugin:withPortableTextLists"),ts=D("plugin:withPortableTextMarkModel"),ta=D("plugin:withPortableTextSelections"),tc=ta.enabled&&!1,th=D("plugin:withSchemaTypes"),td=D("plugin:withUtils"),tu=D("plugin:withHotKeys"),tp={marks:{"mod+b":"strong","mod+i":"em","mod+u":"underline","mod+'":"code"},custom:{}};function tf(e,t,n){let i=null,r=!0,l=[t.span.name,...t.inlineObjects.map(e=>e.name)],o=[t.block.name,...t.blockObjects.map(e=>e.name)];return void 0===e?{valid:!0,resolution:null,value:e}
57:Array.isArray(e)&&0!==e.length?(e.some((e,s)=>{if(!B(e))return i={patches:[(0,b.wC)([s])],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:s}}},!0;if(!e._key||"string"!=typeof e._key)return i={patches:[(0,b.hZ)({...e,_key:n()},[s])],description:`Block at index ${s} 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:s}}},!0;if(!e._type||!o.includes(e._type)){if("block"===e._type){let n=t.block.name;return i={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 i=!e._type&&(0,h.L4)({...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 i={patches:[(0,b.hZ)({children:[]},[{_key:e._key}])],description:`Text block with _key '${e._key}' has a invalid required property 'children'.`,action:"Reset the children property",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-or-invalid-children.description",action:"inputs.portable-text.invalid-value.missing-or-invalid-children.action",values:{key:e._key}}},!0;if(void 0===e.children||Array.isArray(e.children)&&0===e.children.length){let r={_type:t.span.name,_key:n(),text:"",marks:[]};return i={autoResolve:!0,patches:[(0,b.Wm)([],[{_key:e._key},"children"]),(0,b.Yr)([r],"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 o=u(E(e.children.filter(e=>e._type===t.span.name).map(e=>e.marks||[])));if(Array.isArray(e.markDefs)&&e.markDefs.length>0){let t=u(e.markDefs.map(e=>e._key).filter(e=>!o.includes(e)));if(t.length>0)return i={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 s=o.filter(e=>!t.decorators.map(e=>e.value).includes(e)).filter(t=>void 0===e.markDefs||!e.markDefs.find(e=>e._key===t));if(s.length>0){let n=e.children.filter(e=>e._type===t.span.name&&Array.isArray(e.marks)&&e.marks.some(e=>s.includes(e)));if(n){let t=s.join(", ");return i={autoResolve:!0,patches:n.map(t=>(0,b.hZ)((t.marks||[]).filter(e=>
57!s.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:s.map(e=>e.toString())}}},!0}}e.children.some((r,o)=>{if(!B(r))return i={patches:[(0,b.wC)([{_key:e._key},"children",o])],description:`Child at index '${o}' 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:o}}},!0;if(!r._key||"string"!=typeof r._key){let t={...r,_key:n()};return i={autoResolve:!0,patches:[(0,b.hZ)(t,[{_key:e._key},"children",o])],description:`Child at index ${o} 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:o}}},!0}return r._type?l.includes(r._type)?r._type===t.span.name&&"string"!=typeof r.text&&(i={patches:[(0,b.hZ)({...r,text:""},[{_key:e._key},"children",{_key:r._key}])],description:`Child with _key '${r._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
57d-span-text.description",action:"inputs.portable-text.invalid-value.invalid-span-text.action",values:{key:e._key,childKey:r._key}}},!0):(i={patches:[(0,b.wC)([{_key:e._key},"children",{_key:r._key}])],description:`Child with _key '${r._key}' in block with key '${e._key}' has invalid '_type' property (${r._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:r._key,childType:r._type}}},!0):(i={patches:[(0,b.wC)([{_key:e._key},"children",{_key:r._key}])],description:`Child with _key '${r._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:r._key}}},!0)})&&(r=!1)}return!1})&&(r=!1),{valid:r,resolution:i,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 tg=D("plugin:withInsertData"),tm={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function ty(e,t,n){e.withoutNormalizing(()=>{if(!e.selection)return;let[i,l]=s.KE.node(e,e.selection,{depth:1});if(e.isTextBlock(i)&&e.isTextBlock(t[0])){let{markDefs:n}=i;tg("Mixing markDefs of focusBlock and fragments[0] block",n,t[0].markDefs),r(n,t[0].markDefs)||s.gB.setNodes(e,{markDefs:u([...t[0].markDefs||[],...n||[]])},{at:l,mode:"lowest",voids:!1})}z(e.children,n)?(s.gB.splitNodes(e,{at:[0,0]}),e.insertFragment(t),s.gB.removeNodes(e,{at:[0]})):e.insertFragment(t)}),e.onChange()}let tk=new WeakMap,tb=(e,t)=>{let{keyGenerator:n,portableTextEditor:i,patches$:o,readOnly:c,maxBlocks:d}=t,{editorActor:p,schemaTypes:f}=i;e.subscriptions=[],e.destroy?e.destroy():tk.set(e,{apply:e.apply,onChange:e.onChange,normalizeNode:e.normalizeNode});let g=function(e){let t=e.block.name;return{insertNodePatch:function(e,n,i){let r=i[n.path[0]],l=e.isTextBlock(r);if(1===n.path.length){let e=0===n.path[0]?"before":"after",l=i[n.path[0]-1],o=0===n.path[0]?r?._key:l?._key;return o?[(0,b.Yr)([R([n.node],t)[0]],e,[{_key:o}])]:[(0,b.Wm)(i,[]),(0,b.Yr)([R([n.node],t)[0]],"before",[n.path[0]])]}if(l&&2===n.path.length&&e.children[n.path[0]]){let e=0!==r.children.length&&r.children[n.path[1]-1]?"after":"before",i={...n.node};!i._type&&s.EY.isText(i)&&(i._type="span",i.marks=[]);let l=R([{_key:"bogus",_type:t,children:[i]}],t)[0].children[0];return[(0,b.Yr)([l],e,[{_key:r._key},"children",r.children.length<=1||!r.children[n.path[1]-1]?0:{_key:r.children[n.path[1]-1]._key}])]}return eu("Something was inserted into a void block. Not producing editor patches."),[]},insertTextPatch:function(e,t,n){eu.enabled&&eu("Operation",JSON.stringify(t,null,2));let i=e.isTextBlock(e.children[t.path[0]])&&e.children[t.path[0]];if(!i)throw Error("Could not find block");let r=e.isTextBlock(i)&&e.isTextSpan(i.children[t.path[1]])&&i.children[t.path[1]];if(!r)throw Error("Could not find child");let l=[{_key:i._key},"children",{_key:r._key},"text"],o=n[t.path[0]],s=e.isTextBlock(o)&&o.children[t.path[1]],a=e.isTextSpan(s)?s.text:"",c=(0,b.jo)(a,r.text,l);return c.value.length?[c]:[]},mergeNodePatch:function(e,n,i){let r=[],l=i[n.path[0]],o=e.children[n.path[0]];if(1===n.path.length)if(l?._key){let i=R([e.children[n.path[0]-1]],t)[0];r.push((0,b.hZ)(i,[{_key:i._key}])),r.push((0,b.wC)([{_key:l._key}]))}else throw Error("Target key not found!");else if(e.isTextBlock(l)&&e.isTextBlock(o)&&2===n.path.length){let t=o.children[n.path[1]-1]&&e.isTextSpan(o.children[n.path[1]-1])?o.children[n.path[1]-1]:void 0,i=l.children[n.path[1]]&&e.isTextSpan(l.children[n.path[1]])?l.children[n.path[1]]:void 0;t&&(1===l.children.filter(e=>e._key===t._key).length?r.push((0,b.hZ)(t.text,[{_key:l._key},"children",{_key:t._key},"text"])):console.warn(`Multiple spans have \`_key\` ${t._key}. It's ambiguous which one to update.`,JSON.stringify(l,null,2))),i&&(1===l.children.filter(e=>e._key===i._key).length?r.push((0,b.wC)([{_key:l._key},"children",{_key:i._key}])):console.warn(`Multiple spans have \`_key\` ${i._key}. It's ambiguous which one to remove.`,JSON.stringify(l,null,2)))}else eu("Void nodes can't be merged, not creating any patches");return r},moveNodePatch:function(e,n,i){let r=[],l=i[n.path[0]],o=i[n.newPath[0]];if(1===n.path.length){let e=n.path[0]>n.newPath[0]?"before":"after";r.push((0,b.wC)([{_key:l._key}])),r.push((0,b.Yr)([R([l],t)[0]],e,[{_key:o._key}]))}else if(2===n.path.length&&e.isTextBlock(l)&&e.isTextBlock(o)){let e=l.children[n.path[1]],i=o.children[n.newPath[1]],s=n.newPath[1]===o.children.length?"after":"before",a=R([l],t)[0].children[n.path[1]];r.push((0,b.wC)([{_key:l._key},"children",{_key:e._key}
57])),r.push((0,b.Yr)([a],s,[{_key:o._key},"children",{_key:i._key}]))}return r},removeNodePatch:function(e,t,n){let i=n[t.path[0]];if(1===t.path.length){if(i&&i._key)return[(0,b.wC)([{_key:i._key}])];throw Error("Block not found")}if(!e.isTextBlock(i)||2!==t.path.length)return eu("Not creating patch inside object block"),[];{let e=i.children[t.path[1]];return e?i.children.filter(e=>e._key===t.node._key).length>1?(console.warn(`Multiple spans have \`_key\` ${t.node._key}. It's ambiguous which one to remove.`,JSON.stringify(i,null,2)),[]):[(0,b.wC)([{_key:i._key},"children",{_key:e._key}])]:(eu("Span not found in editor trying to remove node"),[])}},removeTextPatch:function(e,t,n){let i=e&&e.children[t.path[0]];if(!i)throw Error("Could not find block");let r=e.isTextBlock(i)&&i.children[t.path[1]]||void 0,l=e.isTextSpan(r)?r:void 0;if(r&&!l)throw Error("Expected span");if(!l)throw Error("Could not find child");let o=[{_key:i._key},"children",{_key:l._key},"text"],s=n[t.path[0]],a=e.isTextBlock(s)&&s.children[t.path[1]],c=e.isTextSpan(a)&&a.text,h=(0,b.jo)(c||"",l.text,o);return h.value?[h]:[]},setNodePatch:function(e,n){if(1===n.path.length){let i=e.children[n.path[0]];if("string"!=typeof i._key)throw Error("Expected block to have a _key");let r=_({...e.children[n.path[0]],...n.newProperties},x);return[(0,b.hZ)(R([r],t)[0],[{_key:i._key}])]}if(2===n.path.length){let t=e.children[n.path[0]];if(e.isTextBlock(t)){let e=t.children[n.path[1]];if(e){let i=t._key,r=e._key,l=[],o=Object.keys(n.newProperties);return o.forEach(s=>{if(1===o.length&&"_key"===s){let r=v(n.newProperties,s);l.push((0,b.hZ)(r,[{_key:i},"children",t.children.indexOf(e),s]))}else{let e=v(n.newProperties,s);l.push((0,b.hZ)(e,[{_key:i},"children",{_key:r},s]))}}),l}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)}`)},splitNodePatch:function(e,n,i){let r=[],l=e.children[n.path[0]];if(!e.isTextBlock(l))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 o=i[n.path[0]];if(e.isTextBlock(o)){let i=R([e.children[n.path[0]+1]],t)[0];i&&(r.push((0,b.Yr)([i],"after",[{_key:l._key}])),o.children.slice(n.position).forEach(e=>{let t=[{_key:o._key},"children",{_key:e._key}];r.push((0,b.wC)(t))}))}return r}if(2===n.path.length){let i=l.children[n.path[1]];if(e.isTextSpan(i)){let e=R([{...l,children:l.children.slice(n.path[1]+1,n.path[1]+2)}],t)[0].children;r.push((0,b.Yr)(e,"after",[{_key:l._key},"children",{_key:i._key}])),r.push((0,b.hZ)(i.text,[{_key:l._key},"children",{_key:i._key},"text"]))}}return r}}}(f),m=function(e,t,n){return function(i){let{apply:r,normalizeNode:l}=i;return i.apply=e=>eg(i)||ek(i)||eb(i)?void r(e):"split_node"===e.type?void r({...e,properties:{...e.properties,_key:n()}}):"insert_node"!==e.type||s.KE.isEditor(e.node)?void r(e):void r({...e,node:{...e.node,_key:n()}}),i.normalizeNode=r=>{let[o,a]=r;if(s.Hg.isElement(o)&&o._type===t.block.name){if(!o._key){e.send({type:"normalizing"}),s.gB.setNodes(i,{_key:n()},{at:a}),e.send({type:"done normalizing"});return}for(let[t,r]of s.bP.children(i,a))if(!t._key){e.send({type:"normalizing"}),s.gB.setNodes(i,{_key:n()},{at:r}),e.send({type:"done normalizing"});return}}l(r)},i}}(p,f,n),y=function({editorActor:e,schemaTypes:t,keyGenerator:n}){return function(i){i.isTextBlock=e=>(0,h.L4)(e)&&e._type===t.block.name,i.isTextSpan=e=>(0,h.bn)(e)&&e._type===t.span.name,i.isListBlock=e=>(0,h.U4)(e)&&e._type===t.block.name,i.isVoid=e=>t.block.name!==e._type&&(t.blockObjects.map(e=>e.name).includes(e._type)||t.inlineObjects.map(e=>e.name).includes(e._type)),i.isInline=e=>t.inlineObjects.map(e=>e.name).includes(e._type)&&"__inline"in e&&!0===e.__inline;let{normalizeNode:r}=i;return i.normalizeNode=l=>{let[o,a]=l;if(void 0===o._type&&2===a.length){th("Setting span type on text node without a type");let r=o._key||n();e.send({type:"normalizing"}),s.gB.setNodes(i,{...o,_type:t.span.name,_key:r},{at:a}),e.send({type:"done normalizing"});return}if(void 0===o._key&&(1===a.length||2===a.length)){th("Setting missing key on child node without a key");let t=n();e.send({type:"normalizing"}),s.gB.setNodes(i,{_key:t},{at:a}),e.send({type:"done normalizing"});return}r(l)},i}}({editorActor:p,schemaTypes:f,keyGenerator:n}),k=function(e,t,n){return function(i){return e.setEditable({focus:()=>{a.rL.focus(i)},blur:()=>{a.rL.blur(i)},toggleMark:e=>{i.pteToggleMark(e)},toggleList:e=>{i.pteToggleListItem(e)},toggleBlockStyle:e=>{i.pteToggleBlockStyle(e)},isMarkActive:e=>{try{return i.pteIsMarkActive(e)}catch(e){return console.warn(e),!1}},marks:()=>({...s.KE.marks(i)||{}}).marks||[],undo:()=>i.undo(),redo:()=>i.redo(),select:e=>{let t=L(e,i);t?s.gB.select(i,t):s.gB.deselect(i),i.onChange()},focusBlock:()=>
57{if(i.selection){let e=s.bP.descendant(i,i.selection.focus.path.slice(0,1));if(e)return R([e],t.block.name,q.get(i))[0]}},focusChild:()=>{if(i.selection){let e=s.bP.descendant(i,i.selection.focus.path.slice(0,1));if(e&&i.isTextBlock(e))return R([e],t.block.name,q.get(i))[0].children[i.selection.focus.path[1]]}},insertChild:(r,l)=>{if(!i.selection)throw Error("The editor has no selection");let[o]=Array.from(s.KE.nodes(i,{at:i.selection.focus.path.slice(0,1),match:e=>e._type===t.block.name}))[0]||[void 0];if(!o)throw Error("No focused text block");if(r.name!==t.span.name&&!t.inlineObjects.some(e=>e.name===r.name))throw Error("This type cannot be inserted as a child to a text block");let a=K([{_key:n(),_type:t.block.name,children:[{_key:n(),_type:r.name,...l||{}}]}],e)[0].children[0],c=i.selection.focus.path.slice(0,2),h=a._type===t.span.name,d=s.bP.get(i,c);return h&&d._type!==t.span.name&&(ep("Inserting span child next to inline object child, moving selection + 1"),i.move({distance:1,unit:"character"})),s.gB.insertNodes(i,a,{select:!0,at:i.selection}),i.onChange(),$(R(i.children,t.block.name,q.get(i)),i.selection,t)?.focus.path||[]},insertBlock:(r,l)=>{let o=K([{_key:n(),_type:r.name,...l||{}}],e)[0];if(!i.selection){let e=Array.from(s.KE.nodes(i,{match:e=>!s.KE.isEditor(e),at:[],reverse:!0}))[0];return s.KE.insertNode(i,o),e&&z([e[0]],t)&&s.gB.removeNodes(i,{at:e[1]}),i.onChange(),$(R(i.children,t.block.name,q.get(i)),i.selection,t)?.focus.path??[]}let a=Array.from(s.KE.nodes(i,{at:i.selection.focus.path.slice(0,1),match:e=>e._type===t.block.name}))[0];return s.KE.insertNode(i,o),a&&z([a[0]],t)&&s.gB.removeNodes(i,{at:a[1]}),i.onChange(),$(R(i.children,t.block.name,q.get(i)),i.selection,t)?.focus.path||[]},hasBlockStyle:e=>{try{return i.pteHasBlockStyle(e)}catch{return!1}},hasListStyle:e=>{try{return i.pteHasListStyle(e)}catch{return!1}},isVoid:e=>
57![t.block.name,t.span.name].includes(e._type),findByPath:e=>{let n=L({focus:{path:e,offset:0},anchor:{path:e,offset:0}},i);if(n){let[r,l]=s.KE.node(i,n.focus.path.slice(0,1));if(r&&l&&"string"==typeof r._key){if(1===e.length&&1===n.focus.path.length)return[R([r],t.block.name)[0],[{_key:r._key}]];let l=R([r],t.block.name,q.get(i))[0];if(i.isTextBlock(l)){let e=l.children[n.focus.path[1]];if(e)return[e,[{_key:r._key},"children",{_key:e._key}]]}}}return[void 0,void 0]},findDOMNode:e=>{let t;try{let[n]=Array.from(s.KE.nodes(i,{at:[],match:t=>t._key===e._key})||[])[0]||[void 0];t=a.rL.toDOMNode(i,n)}catch{}return t},activeAnnotations:()=>{if(!i.selection||i.selection.focus.path.length<2)return[];try{let e=[];for(let[t,n]of s.KE.nodes(i,{at:i.selection,match:e=>s.EY.isText(e)&&void 0!==e.marks&&Array.isArray(e.marks)&&e.marks.length>0})){let[r]=s.KE.node(i,n,{depth:1});i.isTextBlock(r)&&r.markDefs?.forEach(n=>{s.EY.isText(t)&&t.marks&&Array.isArray(t.marks)&&t.marks.includes(n._key)&&e.push(n)})}return e}catch{return[]}},isAnnotationActive:e=>{if(!i.selection||i.selection.focus.path.length<2)return!1;try{let t=[...s.KE.nodes(i,{at:i.selection,match:e=>s.EY.isText(e)})];if(0===t.length||t.some(([e])=>!(0,h.bn)(e)||!e.marks||e.marks?.length===0))return!1;let n=t.reduce((e,[,t])=>{let[n]=s.KE.node(i,t,{depth:1});return i.isTextBlock(n)&&n.markDefs?[...e,...n.markDefs]:e},[]);return t.every(([t])=>!!(0,h.bn)(t)&&t.marks?.map(e=>n.find(t=>t?._key===e)?._type)?.includes(e))}catch{return!1}},addAnnotation:(e,t)=>{let r,{selection:l}=i;if(l&&(s.Q6.isCollapsed(l)&&(i.pteExpandToWord(),i.onChange()),i.selection)){let l,o,a=[];s.KE.withoutNormalizing(i,()=>{if(i.selection){for(let[r,c]of s.KE.nodes(i,{at:i.selection,match:e=>i.isTextBlock(e),reverse:s.Q6.isBackward(i.selection)})){if(0===r.children.length||1===r.children.length&&""===r.children[0].text)continue;let h=n(),d=r.markDefs??[];for(let[n,u]of(void 0===d.find(t=>t._type===e.name&&t._key===h)&&(s.gB.setNodes(i,{markDefs:[...d,{_type:e.name,_key:h,...t}]},{at:c}),o=[{_key:r._key},"markDefs",{_key:h}],s.Q6.isBackward(i.selection)?a.unshift(o):a.push(o)),s.gB.setNodes(i,{},{match:s.EY.isText,split:!0}),s.bP.children(i,c))){if(!i.isTextSpan(n)||!s.Q6.includes(i.selection,u))continue;let t=n.marks??[],o=t.filter(t=>d.some(n=>n._key===t&&n._type===e.name));s.gB.setNodes(i,{marks:[...t.filter(e=>!o.includes(e)),h]},{at:u}),l=[{_key:r._key},"children",{_key:n._key}]}}o&&l&&(r={markDefPath:o,markDefPaths:a,spanPath:l})}}),i.onChange()}return r},delete:(e,n)=>{if(e){let r=L(e,i);if(!(r&&r.anchor.path.length>0&&r.focus.path.length>0))throw Error("Invalid range");if(r){if(!n?.mode||n?.mode==="selected"){ep("Deleting content in selection"),s.gB.delete(i,{at:r,hanging:!0,voids:!0}),i.onChange();return}n?.mode==="blocks"&&(ep("Deleting blocks touched by selection"),s.gB.removeNodes(i,{at:r,voids:!0,match:e=>i.isTextBlock(e)||!i.isTextBlock(e)&&s.Hg.isElement(e)})),n?.mode==="children"&&(ep("Deleting children touched by selection"),s.gB.removeNodes(i,{at:r,voids:!0,match:e=>e._type===t.span.name||!i.isTextBlock(e)&&s.Hg.isElement(e)})),0===i.children.length&&(i.children=[i.pteCreateTextBlock({decorators:[]})]),i.onChange()}}},removeAnnotation:e=>{ep("Removing annotation",e),s.KE.withoutNormalizing(i,()=>{if(i.selection)if(s.Q6.isCollapsed(i.selection)){let[t,n]=s.KE.node(i,i.selection,{depth:1});if(!i.isTextBlock(t))return;let r=(t.markDefs??[]).filter(t=>t._type===e.name),[l,o]=s.KE.node(i,i.selection,{depth:2});if(!i.isTextSpan(l))return;let a=l.marks?.find(e=>r.some(t=>t._key===e));if(!a)return;let c=[];for(let[e,t]of s.bP.children(i,n,{reverse:!0}))if(i.isTextSpan(e)&&s.wA.isBefore(t,o))if(e.marks?.includes(a))c.push([e,t]);else break;let h=[];for(let[e,t]of s.bP.children(i,n))if(i.isTextSpan(e)&&s.wA.isAfter(t,o))if(e.marks?.includes(a))h.push([e,t]);else break;for(let[e,t]of[...c,[l,o],...h])s.gB.setNodes(i,{marks:e.marks?.filter(e=>e!==a)},{at:t})}else for(let[t,n]of(s.gB.setNodes(i,{},{match:e=>i.isTextSpan(e),split:!0,hanging:!0}),s.KE.nodes(i,{at:i.selection,match:e=>i.isTextBlock(e)})))for(let[r,l]of s.bP.children(i,n)){if(!i.isTextSpan(r)||!s.Q6.includes(i.selection,l))continue;let n=t.markDefs??[],o=r.marks??[],a=o.filter(t=>n.find(e=>e._key===t)?._type!==e.name);a.length!==o.length&&s.gB.setNodes(i,{marks:a},{at:l})}}),i.onChange()},getSelection:()=>{let e=null;if(i.selection){let n=F.get(i.selection);if(n)return n;e=$(R(i.children,t.block.name,q.get(i)),i.selection,t),F.set(i.selection,e)}return e},getValue:()=>R(i.children,t.block.name,q.get(i)),isCollapsedSelection:()=>!!i.selection&&s.Q6.isCollapsed(i.selection),isExpandedSelection:()=>!!i.selection&&s.Q6.isExpanded(i.selection),insertBreak:()=>{i.insertBreak(),i.onChange()},getFragment:()=>R(i.getFragment(),t.block.name),isSelectionsOverlapping:(e,t)=>
57{let n=L(e,i),r=L(t,i);return s.Q6.isRange(n)&&s.Q6.isRange(r)&&s.Q6.includes(n,r)}}),i}}(i,f,n),w=function({editorActor:e,patches$:t,patchFunctions:n,readOnly:i,schemaTypes:r}){let l,o=(e,t)=>{let n=!1;eG&&(eX(` 58 59NEW PATCH =============================================================`),eX(JSON.stringify(t,null,2)));try{switch(t.type){case"insert":n=function(e,t,n){let{block:i,child:r,blockPath:l,childPath:o}=e2(e,t.path);if(!i||!l)return eX("Block not found"),!1;if(t.path.length>1&&"children"!==t.path[1])return eX("Ignoring patch targeting void value"),!1;if(1===t.path.length){let{items:i,position:r}=t,o=K(i,{schemaTypes:n},W.get(e)),a=l[0],c="after"===r?a+1:a;return eX(`Inserting blocks at path [${c}]`),e1(e,"before"),s.gB.insertNodes(e,o,{at:[c]}),e1(e,"after"),!0}let{items:a,position:c}=t;if(!r||!o)return eX("Child not found"),!1;let h=i&&K([{...i,children:a}],{schemaTypes:n},W.get(e)),d=o[1],u=[o[0],"after"===c?d+1:d];return eX(`Inserting children at path ${u}`),e1(e,"before"),h&&s.Hg.isElement(h[0])&&s.gB.insertNodes(e,h[0].children,{at:u}),e1(e,"after"),!0}(e,t,r);break;case"unset":n=function(e,t){if(0===t.path.length){eX("Removing everything"),e1(e,"before");let t=e.selection;return s.gB.deselect(e),e.children.forEach((t,n)=>{s.gB.removeNodes(e,{at:[n]})}),s.gB.insertNodes(e,e.pteCreateTextBlock({decorators:[]})),t&&s.gB.select(e,{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0}}),e.onChange(),e1(e,"after"),!0}let{block:n,blockPath:i,child:r,childPath:l}=e2(e,t.path);if(1===t.path.length){if(!n||!i)return eX("Block not found"),!1;let t=i[0];return eX(`Removing block at path [${t}]`),e1(e,"before"),s.gB.removeNodes(e,{at:[t]}),e1(e,"after"),!0}return!!e.isTextBlock(n)&&"children"===t.path[1]&&3===t.path.length&&(r&&l?(eX(`Unsetting child at path ${JSON.stringify(l)}`),e1(e,"before"),eG&&eX(`Removing child at path ${JSON.stringify(l)}`),s.gB.removeNodes(e,{at:l}),e1(e,"after"),!0):(eX("Child not found"),!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{block:i,blockPath:r,child:l,childPath:o}=e2(e,t.path);if(!i)return eX("Block not found"),!1;let a=e.isTextBlock(i);if(a&&t.path.length>1&&"children"!==t.path[1])return eX("Ignoring setting void value"),!1;if(e1(e,"before"),a&&l&&o){if(s.EY.isText(n)&&s.EY.isText(l)){let t=l.text;n.text!==t&&(eX("Setting text property"),e.apply({type:"remove_text",path:o,offset:0,text:t}),e.apply({type:"insert_text",path:o,offset:0,text:n.text}),e.onChange())}else eX("Setting non-text property"),e.apply({type:"set_node",path:o,properties:{},newProperties:n});return!0}if(s.Hg.isElement(i)&&1===t.path.length&&r){eX("Setting block property");let{children:t,...l}=n,{children:o,...s}=i||{children:void 0};e.apply({type:"set_node",path:r,properties:{...s},newProperties:l}),eX("Setting children"),i.children.forEach((t,n)=>{e.apply({type:"remove_node",path:r.concat(i.children.length-1-n),node:t})}),Array.isArray(t)&&t.forEach((t,n)=>{e.apply({type:"insert_node",path:r.concat(n),node:t})})}else if(i&&"value"in i){let n=(0,b.yl)([i.value],[t])[0];return s.gB.setNodes(e,{...i,value:n},{at:r}),!0}return e1(e,"after"),!0}(e,t);break;case"diffMatchPatch":n=function(e,t){let{block:n,child:i,childPath:r}=e2(e,t.path);if(!n)return eX("Block not found"),!1;if(!i||!r)return eX("Child not found"),!1;if(!(n&&e.isTextBlock(n)&&4===t.path.length&&"children"===t.path[1]&&"text"===t.path[3])||!s.EY.isText(i))return!1;let[l]=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("string"==typeof e)throw Error("Patches must be an array - pass the patch to `parsePatch()` first");let i=t;if(0===e.length)return[i,[]];let r=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=0,r=0;function l(e){for(;i<e;){let e=t.codePointAt(r);if(typeof e>"u")return r;i+=eU(e),e>65535?r+=2:r+=1}if(!n.allowExceedingIndices&&i!==e)throw Error("Failed to determine byte offset");return r}let o=[];for(let t of e)o.push({diffs:t.diffs.map(e=>ev(e)),start1:l(t.start1),start2:l(t.start2),utf8Start1:t.utf8Start1,utf8Start2:t.utf8Start2,length1:t.length1,length2:t.length2,utf8Length1:t.utf8Length1,utf8Length2:t.utf8Length2});return o}(e,i,{allowExceedingIndices:n.allowExceedingIndices}),l=n.margin||4,o=n.deleteThreshold||.4,s=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,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 i=e[0],r=i.diffs;if(0===r.length||r[0][0]!==eL)r.unshift([eL,n]),i.start1-=t,i.start2-=t,i.utf8Start1-=t,i.utf8Start2-=t,i.length1+=t,i.length2+=t,i.utf8Length1+=t,i.utf8Length2+=t;else if(t>r[0][1].length){let e=r[0][1].length,l=t-e;r[0][1]=n.substring(e)+r[0][1],i.start1-=l,i.start2-=l,i.utf8Start1-=l,i.utf8Start2-=l,i.length1+=l,i.length2+=l,i.utf8Length1+=l,i.utf8Length2+=l}if(0===(r=(i=e[e.length-1]).diffs).length||r[r.length-1][0]!==eL)r.push([eL,n]),i.length1+=t,i.length2+=t,i.utf8Length1+=t,i.utf8Length2+=t;else if(t>r[r.length-1][1].length){let e=t-r[r.length-1][1].length;r[r.length-1][1]+=n.substring(0,e),i.length1+=e,i.length2+=e,i.utf8Length1+=e,i.utf8Length2+=e}return n}(r,l);i=s+i+s,function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;for(let n=0;n<e.length;n++){if(e[n].length1<=32)continue;let i=e[n];e.splice(n--,1);let r=i.start1,l=i.start2,o="";for(;0!==i.diffs.length;){let s=eV(r-o.length,l-o.length),a=!0;if(""!==o){let e=eQ(o);s.length1=o.length,s.utf8Length1=e,s.length2=o.length,s.utf8Length2=e,s.diffs.push([eL,o])}for(;0!==i.diffs.length&&s.length1<32-t;){let e=i.diffs[0][0],n=i.diffs[0][1],o=eQ(n);if(e===e$){s.length2+=n.length,s.utf8Length2+=o,l+=n.length;let e=i.diffs.shift();e&&s.diffs.push(e),a=!1}else e===eM&&1===s.diffs.length&&s.diffs[0][0]===eL&&n.length>64?(s.length1+=n.length,s.utf8Length1+=o,r+=n.length,a=!1,s.diffs.push([e,n]),i.diffs.shift()):(o=eQ(n=n.substring(0,32-s.length1-t)),s.length1+=n.length,s.utf8Length1+=o,r+=n.length,e===eL?(s.length2+=n.length,s.utf8Length2+=o,l+=n.length):a=!1,s.diffs.push([e,n]),n===i.diffs[0][1]?i.diffs.shift():i.diffs[0][1]=i.diffs[0][1].substring(n.length))}o=(o=eJ(s.diffs)).substring(o.length-t);let c=eY(i.diffs).substring(0,t),h=eQ(c);""!==c&&(s.length1+=c.length,s.length2+=c.length,s.utf8Length1+=h,s.utf8Length2+=h,0!==s.diffs.length&&s.diffs[s.diffs.length-1][0]===eL?s.diffs[s.diffs.length-1][1]+=c:s.diffs.push([eL,c])),a||e.splice(++n,0,s)}}}(r,l);let a=0,c=[];for(let e=0;e<r.length;e++){let t=r[e].start2+a,n=eY(r[e].diffs),l,s=-1;if(n.length>32?-1!==(l=eH(i,n.substring(0,32),t))&&(-1===(s=eH(i,n.substring(n.length-32),t+n.length-32))||l>=s)&&(l=-1):l=eH(i,n,t),-1===l)c[e]=!1,a-=r[e].length2-r[e].length1;else{let h;if(c[e]=!0,a=l-t,h=-1===s?i.substring(l,l+n.length):i.substring(l,s+32),n===h)i=i.substring(0,l)+eJ(r[e].diffs)+i.substring(l+n.length);else{let t=eI(n,h,{checkLines:!1});if(n.length>32&&function(e){let t=0,n=0,i=0;for(let r=0;r<e.length;r++){let l=e[r][0],o=e[r][1];switch(l){case e$:n+=o.length;break;case eM:i+=o.length;break;case eL:t+=Math.max(n,i),n=0,i=0;break;default:throw Error("Unknown diff operation.")}}return t+Math.max(n,i)}(t)/n.length>o)c[e]=!1;else{t=eS(t);let n=0,o=0;for(let s=0;s<r[e].diffs.length;s++){let a=r[e].diffs[s];a[0]!==eL&&(o=eW(t,n)),a[0]===e$?i=i.substring(0,l+o)+a[1]+i.substring(l+o):a[0]===eM&&(i=i.substring(0,l+o)+i.substring(l+eW(t,n+a[1].length))),a[0]!==eM&&(n+=a[1].length)}}}}}return[i=i.substring(s.length,i.length-s.length),c]}(eF(t.value),i.text,{allowExceedingIndices:!0}),o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,n=e.map(e=>ev(e)),i=!1,r=[],l=0,o=null,s=0,a=!1,c=!1,h=!1,d=!1;for(;s<n.length;)n[s][0]===eL?(n[s][1].length<t&&(h||d)?(r[l++]=s,a=h,c=d,o=n[s][1]):(l=0,o=null),h=!1,d=!1):(n[s][0]===eM?d=!0:h=!0,o&&(a&&c&&h&&d||o.length<t/2&&3===function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce((e,t)=>
59e+ +!!t,0)}(a,c,h,d))&&(n.splice(r[l-1],0,[eM,o]),n[r[l-1]+1][0]=e$,l--,o=null,a&&c?(h=!0,d=!0,l=0):(s=--l>0?r[l-1]:-1,h=!1,d=!1),i=!0)),s++;return i&&(n=eC(n)),n}(eI(i.text,l),5);e1(e,"before");let a=0;for(let[t,n]of o)t===e$?(e.apply({type:"insert_text",path:r,offset:a,text:n}),a+=n.length):t===eM?e.apply({type:"remove_text",path:r,offset:a,text:n}):t===eL&&(a+=n.length);return e1(e,"after"),!0}(e,t);break;default:eX("Unhandled patch",t.type)}}catch(e){console.error(e)}return n};return function(a){H.set(a,!1),e8.set(a,!0),l=[...a.children];let{apply:c}=a,h=[],d=({patches:e})=>{let t=e.filter(e=>"local"!==e.origin);0!==t.length&&(h=h.concat(t),(()=>{if(0===h.length)return;let e=h;h=[];let t=!1;ef(a,()=>{s.KE.withoutNormalizing(a,()=>{e6(a,()=>{tn(a,()=>{e.forEach(e=>{ti.enabled&&ti(`Handling remote patch ${JSON.stringify(e)}`),t=o(a,e)})})})}),t&&(a.normalize(),a.onChange())})})())};return t&&a.subscriptions.push(()=>{ti("Subscribing to patches$");let e=t.subscribe(d);return()=>{ti("Unsubscribing to patches$"),e.unsubscribe()}}),a.apply=t=>{if(i)return c(t),a;let o=[],s=z(l=a.children,r);c(t);let h=z(a.children,r);if(!e8.get(a))return a;switch(s&&!h&&"set_selection"!==t.type&&o.push((0,b.Yr)(l,"before",[0])),t.type){case"insert_text":o=[...o,...n.insertTextPatch(a,t,l)];break;case"remove_text":o=[...o,...n.removeTextPatch(a,t,l)];break;case"remove_node":o=[...o,...n.removeNodePatch(a,t,l)];break;case"split_node":o=[...o,...n.splitNodePatch(a,t,l)];break;case"insert_node":o=[...o,...n.insertNodePatch(a,t,l)];break;case"set_node":o=[...o,...n.setNodePatch(a,t,l)];break;case"merge_node":o=[...o,...n.mergeNodePatch(a,t,l)];break;case"move_node":o=[...o,...n.moveNodePatch(a,t,l)]}return!s&&h&&["merge_node","set_node","remove_text","remove_node"].includes(t.type)&&(o=[...o,(0,b.wC)([])],e.send({type:"unset",previousValue:R(l,r.block.name,q.get(a))})),s&&o.length>0&&(o=[(0,b.Wm)([],[]),...o]),o.length>0&&o.forEach(t=>{e.send({type:"patch",patch:{...t,origin:"local"}})}),a},a}}({editorActor:p,keyGenerator:n,patches$:o,patchFunctions:g,readOnly:c,schemaTypes:f}),N=function(e){return function(t){let{apply:n}=t;return t.apply=i=>{if(eg(t)||ek(t)||eb(t))return void n(i);e>0&&t.children.length>=e&&("insert_node"===i.type||"split_node"===i.type)&&1===i.path.length||n(i)},t}}(d||-1),B=function(e){return function(t){return t.pteToggleListItem=e=>{t.pteHasListStyle(e)?(to(`Remove list item '${e}'`),t.pteUnsetListItem(e)):(to(`Add list item '${e}'`),t.pteSetListItem(e))},t.pteUnsetListItem=n=>{t.selection&&[...s.KE.nodes(t,{at:t.selection,match:t=>s.Hg.isElement(t)&&t._type===e.block.name})].forEach(([e,i])=>{if(t.isListBlock(e)){let{listItem:r,level:l,...o}=e,a={...o,listItem:void 0,level:void 0};to(`Unsetting list '${n}'`),s.gB.setNodes(t,a,{at:i})}})},t.pteSetListItem=n=>{t.selection&&[...s.KE.nodes(t,{at:t.selection,match:e=>t.isTextBlock(e)})].forEach(([i,r])=>{to(`Setting list '${n}'`),s.gB.setNodes(t,{...i,level:1,listItem:n||e.lists[0]&&e.lists[0].value},{at:r})})},t.pteEndList=()=>{if(!t.selection)return!1;let e=[...s.KE.nodes(t,{at:t.selection,match:e=>s.Hg.isElement(e)&&t.isListBlock(e)&&1===e.children.length&&s.EY.isText(e.children[0])&&""===e.children[0].text})];return 0!==e.length&&(e.forEach(([e,n])=>{s.Hg.isElement(e)&&(to("Unset list"),s.gB.setNodes(t,{...e,level:void 0,listItem:void 0},{at:n}))}),!0)},t.pteIncrementBlockLevels=e=>{if(!t.selection)return!1;let n=[...s.KE.nodes(t,{at:t.selection,match:e=>!!t.isListBlock(e)})];return 0!==n.length&&(n.forEach(([n,i])=>{if(t.isListBlock(n)){let r=n.level||1;e?to("Decrementing list level",Math.min(10,Math.max(1,--r))):to("Incrementing list level",Math.min(10,Math.max(1,++r))),s.gB.setNodes(t,{level:Math.min(10,Math.max(1,r))},{at:i})}}),!0)},t.pteHasListStyle=e=>{if(!t.selection)return!1;let n=[...s.KE.nodes(t,{at:t.selection,match:e=>t.isTextBlock(e)})];return n.length>0&&n.every(([n])=>t.isListBlock(n)&&n.listItem===e)},t}}(f),T=function(e){let{readOnly:t,patches$:n,blockSchemaType:i}=e;return e=>{let r=R(e.children,i.name),l=(e7.get(e)||e7.set(e,[]),e7.get(e)||[]);n&&e.subscriptions.push(()=>{e3("Subscribing to patches");let t=n.subscribe(({patches:t,snapshot:n})=>{let i=!1;t.forEach(t=>{if(!i&&"local"!==t.origin&&l){if("unset"===t.type&&0===t.path.length){e3("Someone else cleared the content, resetting undo/redo history"),e.history={undos:[],redos:[]},l.splice(0,l.length),e5.set(e,!0),i=!0;return}
59l.push({patch:t,time:new Date,snapshot:n,previousSnapshot:r})}}),r=n});return()=>{e3("Unsubscribing to patches"),t.unsubscribe()}}),e.history={undos:[],redos:[]};let{apply:o}=e;return e.apply=n=>{let i,r;if(t)return void o(n);let{operations:l,history:a}=e,{undos:c}=a,h=c[c.length-1],d=h&&h.operations&&h.operations[h.operations.length-1],u=(i=n,!!((r=d)&&"set_selection"===i.type&&"set_selection"===r.type)),p=e9(e),f=!0;if(p){let t,i;if(h?0===l.length&&(f=(t=n,i=d,!!("set_selection"===t.type||i&&"insert_text"===t.type&&"insert_text"===i.type&&t.offset===i.offset+i.text.length&&s.wA.equals(t.path,i.path)&&" "!==t.text||i&&"remove_text"===t.type&&"remove_text"===i.type&&t.offset+t.text.length===i.offset&&s.wA.equals(t.path,i.path))||u)):f=!1,h&&f)h.operations.push(n);else{var g;let t={operations:[...null===e.selection?[]:[{type:"set_selection",properties:{...(g=e).selection},newProperties:{...g.selection}}],n],timestamp:new Date};c.push(t),e3("Created new undo step",h)}for(;c.length>1e3;)c.shift();"set_selection"!==n.type&&(a.redos=[])}o(n)},e.undo=()=>{if(t)return;let{undos:n}=e.history;if(n.length>0){let t=n[n.length-1];if(e3("Undoing",t),t.operations.length>0){let n=l.filter(e=>e.time>=t.timestamp),i=t.operations;n.forEach(t=>{i=E(i.map(n=>te(e,t.patch,n,t.snapshot,t.previousSnapshot)))});let r=i.map(s.I.inverse).reverse();try{s.KE.withoutNormalizing(e,()=>{let t=ek(e);em.set(e,!0),tn(e,()=>{r.forEach(t=>{e.apply(t)})}),em.set(e,t)}),e.normalize(),e.onChange()}catch(t){e3("Could not perform undo step",t),l.splice(0,l.length),s.gB.deselect(e),e.history={undos:[],redos:[]},e5.set(e,!0),em.set(e,!1),e.onChange();return}e.history.redos.push(t),e.history.undos.pop()}}},e.redo=()=>{if(t)return;let{redos:n}=e.history;if(n.length>0){let t=n[n.length-1];if(e3("Redoing",t),t.operations.length>0){let n=l.filter(e=>e.time>=t.timestamp),i=t.operations;n.forEach(t=>{i=E(i.map(n=>te(e,t.patch,n,t.snapshot,t.previousSnapshot)))});try{s.KE.withoutNormalizing(e,()=>{let t=eb(e);ey.set(e,!0),tn(e,()=>{i.forEach(t=>{e.apply(t)})}),ey.set(e,t)}),e.normalize(),e.onChange()}catch(t){e3("Could not perform redo step",t),l.splice(0,l.length),s.gB.deselect(e),e.history={undos:[],redos:[]},e5.set(e,!0),ey.set(e,!1),e.onChange();return}e.history.undos.push(t),e.history.redos.pop()}}},e}}({readOnly:c,patches$:o,blockSchemaType:f.block}),A=function(e,t,n){return function(i){let{apply:l,normalizeNode:o}=i,a=t.decorators.map(e=>e.value),c=()=>{i.selection&&(s.gB.select(i,{...i.selection}),i.selection={...i.selection});let n=$(i.children,i.selection,t);e.send({type:"selection",selection:n})};return i.normalizeNode=n=>{let[l,a]=n;if(i.isTextBlock(l))for(let[t,n]of s.bP.children(i,a)){let o=l.children[n[1]+1];if(i.isTextSpan(t)&&i.isTextSpan(o)&&r(t.marks,o.marks)){ts("Merging spans",JSON.stringify(t,null,2),JSON.stringify(o,null,2)),e.send({type:"normalizing"}),s.gB.mergeNodes(i,{at:[n[0],n[1]+1],voids:!0}),e.send({type:"done normalizing"});return}}if(i.isTextBlock(l)&&!Array.isArray(l.markDefs)){ts("Adding .markDefs to block node"),e.send({type:"normalizing"}),s.gB.setNodes(i,{markDefs:[]},{at:a}),e.send({type:"done normalizing"});return}if(i.isTextSpan(l)&&!Array.isArray(l.marks)){ts("Adding .marks to span node"),e.send({type:"normalizing"}),s.gB.setNodes(i,{marks:[]},{at:a}),e.send({type:"done normalizing"});return}if(i.isTextSpan(l)){let n=s.wA.parent(a),[r]=s.KE.node(i,n),o=t.decorators.map(e=>e.value),c=l.marks?.filter(e=>!o.includes(e));if(i.isTextBlock(r)&&""===l.text&&c&&c.length>0){ts("Removing annotations from empty span node"),e.send({type:"normalizing"}),s.gB.setNodes(i,{marks:l.marks?.filter(e=>o.includes(e))},{at:a}),e.send({type:"done normalizing"});return}}if(i.isTextBlock(l)){let n=t.decorators.map(e=>e.value);for(let[t,r]of s.bP.children(i,a))if(i.isTextSpan(t)){let o=t.marks??[],a=o.filter(e=>!n.includes(e)&&!l.markDefs?.find(t=>t._key===e));if(a.length>0){ts("Removing orphaned annotations from span node"),e.send({type:"normalizing"}),s.gB.setNodes(i,{marks:o.filter(e=>!a.includes(e))},{at:r}),e.send({type:"done normalizing"});return}}}if(i.isTextSpan(l)){let n=s.wA.parent(a),[r]=s.KE.node(i,n);if(i.isTextBlock(r)){let n=t.decorators.map(e=>e.value),o=l.marks??[],c=o.filter(e=>!n.includes(e)&&!r.markDefs?.find(t=>t._key===e));if(c.length>0){ts("Removing orphaned annotations from span node"),e.send({type:"normalizing"}),s.gB.setNodes(i,{marks:o.filter(e=>!c.includes(e))},{at:a}),e.send({type:"done normalizing"});return}}}if(i.isTextBlock(l)){let t=l.markDefs??[],n=new Set,r=[];for(let e of t)n.has(e._key)||(n.add(e._key),r.push(e));if(t.length!==r.length){ts("Removing duplicate markDefs"),e.send({type:"normalizing"}),s.gB.setNodes(i,{markDefs:r},{at:a}),e.send({type:"done normalizing"});return}}if(i.isTextBlock(l)&&!i.operations.some(e=>"merge_node"===e.type&&"markDefs"in e.properties&&1===e.path.length)){let t=(l.markDefs||[]).filter(e=>l.children.find(t=>s.EY.isText(t)&&Array.isArray(t.marks)&&t.marks.includes(e._key)));if(l.markDefs&&!r(t,l.markDefs)){ts("Removing markDef not in use"),e.send({type:"normalizing"}),s.gB.setNodes(i,{markDefs:t},{at:a}),e.send({type:"done normalizing"});return}}o(n)},i.apply=e=>{if(eg(i)||ek(i)||eb(i))return void l(e);
59if("insert_text"===e.type){let{selection:t}=i,r=!!t&&s.Q6.isCollapsed(t);if(t&&r){let r,o,[c,h]=s.KE.node(i,t,{depth:1}),[d,u]=Array.from(s.KE.nodes(i,{mode:"lowest",at:t.focus,match:e=>i.isTextSpan(e),voids:!1}))[0]??[void 0,void 0],p=d.marks??[],f=p.filter(e=>a.includes(e)),g=p.length>f.length,m=0===d.text.length,y=0===t.anchor.offset,k=t.anchor.offset===d.text.length;for(let[e,t]of s.bP.children(i,h,{reverse:!0}))if(i.isTextSpan(e)&&s.wA.isBefore(t,u)){r=e;break}for(let[e,t]of s.bP.children(i,h))if(i.isTextSpan(e)&&s.wA.isAfter(t,u)){o=e;break}let b=!!r&&r.marks?.some(e=>!a.includes(e)&&p.includes(e)),v=!!r&&r.marks?.every(e=>p.includes(e)),x=!!o&&o.marks?.some(e=>!a.includes(e)&&p.includes(e)),_=!!o&&o.marks?.every(e=>p.includes(e));if(g&&!m){if(y)return void(v?s.gB.insertNodes(i,{_type:"span",_key:n(),text:e.text,marks:r?.marks??[]}):b?l(e):s.gB.insertNodes(i,{_type:"span",_key:n(),text:e.text,marks:[]}));if(k)return void(_?s.gB.insertNodes(i,{_type:"span",_key:n(),text:e.text,marks:o?.marks??[]}):x?l(e):s.gB.insertNodes(i,{_type:"span",_key:n(),text:e.text,marks:[]}))}}}if("remove_text"===e.type){var r,o;let n=Array.from(s.KE.nodes(i,{mode:"lowest",at:{path:e.path,offset:e.offset},match:e=>e._type===t.span.name,voids:!1}))[0][0],c=s.KE.node(i,s.wA.parent(e.path))[0];if(n&&"span"===(r=n)._type&&"text"in r&&"string"==typeof r.text&&(typeof r.marks>"u"||Array.isArray(r.marks)&&r.marks.every(e=>"string"==typeof e))&&c&&"string"==typeof(o=c)._type&&"@"!==o._type[0]&&(!("markDefs"in o)||!o.markDefs||Array.isArray(o.markDefs)&&o.markDefs.every(e=>"string"==typeof e._key))&&"children"in o&&Array.isArray(o.children)&&o.children.every(e=>"object"==typeof e&&"_type"in e)){let t=c.markDefs??[],r=(n.marks??[]).some(e=>t.find(t=>t._key===e)),o=0!==e.offset,h=e.offset+e.text.length===n.text.length;if(r&&o&&h){s.KE.withoutNormalizing(i,()=>{s.gB.splitNodes(i,{match:s.EY.isText,at:{path:e.path,offset:e.offset}}),s.gB.removeNodes(i,{at:s.wA.next(e.path)})}),i.onChange();return}let d=0===e.offset&&h;if(r&&d){let t=(({...s.KE.marks(i)||{}}).marks||[]).filter(e=>a.includes(e));s.KE.withoutNormalizing(i,()=>{l(e),s.gB.setNodes(i,{marks:t},{at:e.path})}),i.onChange();return}if(void 0!==n.marks&&n.marks.length>0&&d){s.KE.withoutNormalizing(i,()=>{l(e),s.gB.setNodes(i,{marks:[]},{at:e.path})}),i.onChange();return}}}if("merge_node"===e.type&&1===e.path.length&&"markDefs"in e.properties&&e.properties._type===t.block.name&&Array.isArray(e.properties.markDefs)&&e.properties.markDefs.length>0&&e.path[0]-1>=0){let[t,n]=s.KE.node(i,[e.path[0]-1]);if(i.isTextBlock(t)){let r=u([...Array.isArray(t.markDefs)&&t.markDefs||[],...e.properties.markDefs]);ts("Copying markDefs over to merged block",e),s.gB.setNodes(i,{markDefs:r},{at:n,voids:!1}),l(e);return}}l(e)},i.addMark=e=>{if(i.selection){if(s.Q6.isExpanded(i.selection))s.KE.withoutNormalizing(i,()=>{s.gB.setNodes(i,{},{match:s.EY.isText,split:!0,hanging:!0});let t=s.Q6.isRange(i.selection)?[...s.KE.nodes(i,{at:i.selection,match:s.EY.isText})]:[];t.length>1&&t.every(t=>t[0].marks?.includes(e))?i.removeMark(e):t.forEach(([t,n])=>{let r=[...(Array.isArray(t.marks)?t.marks:[]).filter(t=>t!==e),e];s.gB.setNodes(i,{marks:r},{at:n,match:s.EY.isText,split:!0,hanging:!0})})});else{let[t,n]=s.KE.node(i,i.selection,{depth:1}),r=i.isTextBlock(t)&&1===t.children.length&&i.isTextSpan(t.children[0])&&""===t.children[0].text?t.children[0]:void 0;if(r){let t=r.marks??[],l=t.filter(t=>t!==e);s.gB.setNodes(i,{marks:t.length===l.length?[...t,e]:l},{at:n,match:e=>i.isTextSpan(e)})}else{let t={...s.KE.marks(i)||{}}.marks||[],n={...s.KE.marks(i)||{},marks:[...t,e]};return i.marks=n,c(),i}}i.onChange(),c()}return i},i.removeMark=e=>{let{selection:t}=i;if(t){if(s.Q6.isExpanded(t))s.KE.withoutNormalizing(i,()=>{s.gB.setNodes(i,{},{match:s.EY.isText,split:!0,hanging:!0}),i.selection&&[...s.KE.nodes(i,{at:i.selection,match:s.EY.isText})].forEach(([t,n])=>{let r=i.children[n[0]];s.Hg.isElement(r)&&r.children.includes(t)&&s.gB.setNodes(i,{marks:(Array.isArray(t.marks)?t.marks:[]).filter(t=>t!==e),_type:"span"},{at:n})})}),s.KE.normalize(i);else{let[n,r]=s.KE.node(i,t,{depth:1}),l=i.isTextBlock(n)&&1===n.children.length&&i.isTextSpan(n.children[0])&&""===n.children[0].text?n.children[0]:void 0;if(l){let t=(l.marks??[]).filter(t=>t!==e);s.gB.setNodes(i,{marks:t},{at:r,match:e=>i.isTextSpan(e)})}else{let t={...s.KE.marks(i)||{}}.marks||[],n={...s.KE.marks(i)||{},marks:t.filter(t=>t!==e)};return i.marks={marks:n.marks,_type:"span"},c(),i}}i.onChange(),c()}return i},i.pteIsMarkActive=e=>{if(!i.selection)return!1;let t=Array.from(s.KE.nodes(i,{match:s.EY.isText,at:i.selection}));return s.Q6.isExpanded(i.selection)?t.every(t=>{let[n]=t;return n.marks?.includes(e)}):(({...s.KE.marks(i)||{}}).marks||[]).includes(e)},i.pteToggleMark=e=>{i.pteIsMarkActive(e)?(ts(`Remove mark '${e}'`),s.KE.removeMark(i,e)):(ts(`Add mark '${e}'`),s.KE.addMark(i,e,!0))},i}}(p,f,n),S=function(e,t){let n=t.styles[0].value;return function(t){let{normalizeNode:i}=t;return t.normalizeNode=r=>{let[,l]=r;for(let i of t.operations)if("split_node"===i.type&&1===i.path.length&&t.isTextBlock(i.properties)&&i.properties.style!==n&&i.path[0]===l[0]&&!s.wA.equals(l,i.path)){let[r]=s.KE.node(t,[i.path[0]+1,0]);if(s.EY.isText(r)&&""===r.text){tl(`Normalizing split node to ${n} style`,i),e.send({type:"normalizing"}),s.gB.setNodes(t,{style:n},{at:[i.path[0]+1],voids:!1}),e.send({type:"done normalizing"});return}}i(r)},t.pteHasBlockStyle=e=>!!t.selection&&[...s.KE.nodes(t,{at:t.selection,match:n=>t.isTextBlock(n)&&n.style===e})].length>0,t.pteToggleBlockStyle=e=>{t.selection&&([...s.KE.nodes(t,{at:t.selection,match:e=>t.isTextBlock(e)}
59)].forEach(([i,r])=>{t.isTextBlock(i)&&i.style===e?(tl(`Unsetting block style '${e}'`),s.gB.setNodes(t,{...i,style:n},{at:r})):(e?tl(`Setting style '${e}'`):tl("Setting default style",n),s.gB.setNodes(t,{...i,style:e||n},{at:r}))}),t.onChange())},t}}(p,f),C=function(e){let{apply:t}=e;return e.apply=n=>{if(eg(e)||ek(e)||eb(e))return void t(n);if("remove_node"===n.type){let t=n.node;if(0===n.path[0]&&s.KE.isVoid(e,t)){let t=s.wA.next(n.path);e.children[t[0]]||(tr("Adding placeholder block"),s.KE.insertNode(e,e.pteCreateTextBlock({decorators:[]})))}}t(n)},e},D=function(e,t){return function(n){let{insertBreak:i}=n;return n.insertBreak=()=>{if(!n.selection)return void i();let[l]=Array.from(s.KE.nodes(n,{mode:"lowest",at:n.selection.focus,match:e=>n.isTextSpan(e),voids:!1}))[0]??[void 0],o=l.marks?.filter(t=>e.decorators.some(e=>e.value===t))??[],a=l.marks?.filter(t=>!e.decorators.some(e=>e.value===t))??[],c=n.selection.focus.path.slice(0,1),h=s.bP.descendant(n,c);if(n.isTextBlock(h)){let[i,l]=s.Q6.edges(n.selection),d=r(l,{path:[...c,0],offset:0});if(d&&s.Q6.isCollapsed(n.selection)){s.KE.insertNode(n,n.pteCreateTextBlock({decorators:0===a.length?o:[]}));let[e]=s.wA.next(c);s.gB.select(n,{anchor:{path:[e,0],offset:0},focus:{path:[e,0],offset:0}}),n.onChange();return}let u=h.children[h.children.length-1],p=r(i,{path:[...c,h.children.length-1],offset:n.isTextSpan(u)?u.text.length:0});if(p&&s.Q6.isCollapsed(n.selection)&&o.length>0&&a.length>0){s.KE.withoutNormalizing(n,()=>{if(!n.selection)return;s.KE.insertNode(n,n.pteCreateTextBlock({decorators:[]}));let[e]=s.wA.next(c);s.gB.setSelection(n,{anchor:{path:[e,0],offset:0},focus:{path:[e,0],offset:0}})}),n.onChange();return}if(!d&&!p){s.KE.withoutNormalizing(n,()=>{if(!n.selection)return;s.gB.splitNodes(n,{at:n.selection});let[i,l]=s.KE.node(n,s.wA.next(c),{depth:1});if(s.gB.setSelection(n,{anchor:{path:[...l,0],offset:0},focus:{path:[...l,0],offset:0}}),n.isTextBlock(i)&&i.markDefs&&i.markDefs.length>0){let o=new Map,a=Array.from(s.bP.children(n,c)).map(e=>e[0]).filter(e=>n.isTextSpan(e));for(let[i,c]of s.bP.children(n,l)){if(!n.isTextSpan(i))continue;let l=i.marks??[];for(let n of l)e.decorators.some(e=>e.value===n)||a.some(e=>e.marks?.includes(n))&&!o.has(n)&&o.set(n,t());let h=l.map(e=>o.get(e)??e);r(l,h)||s.gB.setNodes(n,{marks:h},{at:c})}let h=i.markDefs.map(e=>({...e,_key:o.get(e._key)??e._key}));r(i.markDefs,h)||s.gB.setNodes(n,{markDefs:h},{at:l,match:e=>n.isTextBlock(e)})}}),n.onChange();return}}i()},n}}(f,n),P=function({schemaTypes:e,keyGenerator:t,portableTextEditor:n}){return function(i){return i.pteExpandToWord=()=>{let{selection:e}=i;if(e&&!s.Q6.isExpanded(e)){let[t]=s.KE.node(i,e.focus,{depth:2});if(!t||!s.EY.isText(t)||0===t.text.length)return void td("pteExpandToWord: Can't expand to word here");let{focus:n}=e,r=n.offset,l=t.text.slice(0,r),o=t.text.slice(r,-1),a=e=>e.match(/\s/g),c=l.split("").reverse().findIndex(e=>a(e)),h=c>-1?l.length-c:0,d=o.split("").findIndex(e=>a(e)),u=l.length+(d>-1?d:o.length+1);if(!(h===u||Number.isNaN(h)||Number.isNaN(u))){td("pteExpandToWord: Expanding to focused word"),s.gB.setSelection(i,{anchor:{...e.anchor,offset:h},focus:{...e.focus,offset:u}});return}td("pteExpandToWord: Can't expand to word here")}},i.pteCreateTextBlock=i=>K([{_type:e.block.name,_key:t(),style:e.styles[0].value||"normal",markDefs:[],children:[{_type:"span",_key:t(),text:"",marks:i.decorators.filter(t=>e.decorators.find(({value:e})=>e===t))}]}],n)[0],i}}({keyGenerator:n,schemaTypes:f,portableTextEditor:i}),M=function(e,t){let n=null;return function(i){let{onChange:r}=i;return i.onChange=()=>{let l=i.operations.length>0;r(),l&&(()=>{if(n!==i.selection){let n=null;if(i.selection){let e=F.get(i.selection);e?n=e:(n=$(i.children,i.selection,t),F.set(i.selection,n))}tc&&ta(`Emitting selection ${JSON.stringify(n||null)} (${JSON.stringify(i.selection)})`),n?e.send({type:"selection",selection:n}):e.send({type:"selection",selection:null})}n=i.selection})()},i}}(p,f);return e.destroy=()=>{let t=tk.get(e);if(!t)throw Error("Could not find pristine versions of editor functions");e.apply=t.apply,e.history={undos:[],redos:[]},e.normalizeNode=t.normalizeNode,e.onChange=t.onChange},c?{editor:y(m(A(S(P(C(B(M(k(D(e)))))))))),subscribe:()=>l}:{editor:y(m(A(S(B(C(P(N(T(w(M(k(D(e))))))))))))),subscribe:()=>{let t=[];
59return e.subscriptions.forEach(e=>{t.push(e())}),()=>{t.forEach(e=>{e()})}}}},tv=D("component:PortableTextEditor:SlateContainer");function tx(e){let{patches$:t,portableTextEditor:n,readOnly:r,maxBlocks:l,keyGenerator:c}=e,[[h,d]]=(0,o.useState)(()=>{tv("Creating new Slate editor instance");let{editor:e,subscribe:i}=tb((0,a.o$)((0,s.ie)()),{keyGenerator:c,maxBlocks:l,patches$:t,portableTextEditor:n,readOnly:r});return q.set(e,{}),W.set(e,{}),[e,i]});(0,o.useEffect)(()=>{let e=d();return()=>{e()}},[d]),(0,o.useEffect)(()=>{tv("Re-initializing plugin chain"),tb(h,{keyGenerator:c,maxBlocks:l,patches$:t,portableTextEditor:n,readOnly:r})},[c,n,l,r,t,h]);let u=(0,o.useMemo)(()=>[h.pteCreateTextBlock({decorators:[]})],[h]);return(0,o.useEffect)(()=>()=>{tv("Destroying Slate editor"),h.destroy()},[h]),(0,i.jsx)(a.A,{editor:h,initialValue:u,children:e.children})}let t_=()=>(0,A.Xp)(12),tE=(0,o.createContext)(t_),tw=()=>{let e=(0,o.useContext)(tE);if(void 0===e)throw Error("The `usePortableTextEditorKeyGenerator` hook must be used inside the <PortableTextEditor> component's context.");return e},tN=(0,o.createContext)(!1),tB=()=>{let e=(0,o.useContext)(tN);if(void 0===e)throw Error("The `usePortableTextEditorReadOnly` hook must be used inside the <PortableTextEditor> component's context.");return e},tT=D("hook:useSyncValue"),tA=new WeakMap,tS=D("component:PortableTextEditor:Synchronizer"),tC=tS.enabled&&!1;function tD(e){let t=ea(),n=tw(),i=tB(),{editorActor:l,getValue:c,onChange:h,value:d}=e,u=(0,o.useRef)([]),p=function(e){let{editorActor:t,portableTextEditor:n,readOnly:i,keyGenerator:l}=e,{schemaTypes:c}=n,h=(0,o.useRef)(),d=(0,a.Zi)(),u=(0,o.useRef)(),p=(0,o.useCallback)(()=>{let e=tA.get(n);if(h.current===e)return void tT("Value is the same object as previous, not need to sync");u.current&&e&&(tT("Updating the value debounced"),u.current(e))},[n]),f=(0,o.useMemo)(()=>S(p,1e3,{trailing:!0,leading:!1}),[p]);return(0,o.useMemo)(()=>{let e=e=>{tA.set(n,e);let o=V.get(d),a=eg(d);if(!i){if(o){tT("Has local changes, not syncing value right now"),f();return}if(a){tT("Has remote changes, not syncing value right now"),f();return}}let u=!1,p=!0,g=!!d.selection;if(e&&0!==e.length||(tT("Value is empty"),s.KE.withoutNormalizing(d,()=>{tn(d,()=>{e6(d,()=>{g&&s.gB.deselect(d);let e=d.children.length;d.children.forEach((t,n)=>{s.gB.removeNodes(d,{at:[e-1-n]})}),s.gB.insertNodes(d,d.pteCreateTextBlock({decorators:[]}),{at:[0]}),g&&s.gB.select(d,[0,0])})})}),u=!0),e&&e.length>0){let n=K(e,{schemaTypes:c});s.KE.withoutNormalizing(d,()=>{ef(d,()=>{tn(d,()=>{e6(d,()=>{let o=d.children.length;if(n.length<o){for(let e=o-1;e>n.length-1;e--)s.gB.removeNodes(d,{at:[e]});u=!0}n.forEach((n,o)=>{let a=d.children[o];if(a&&!r(n,a)&&p){let f=[e[o]],g=tf(f,c,l);!g.valid&&g.resolution?.autoResolve&&g.resolution?.patches.length>0&&!i&&h.current&&h.current!==e&&(console.warn(`${g.resolution.action} for block with _key '${f[0]._key}'. ${g.resolution?.description}`),g.resolution.patches.forEach(e=>{t.send({type:"patch",patch:e})})),g.valid||g.resolution?.autoResolve?(a._key===n._key?(tT.enabled&&tT("Updating block",a,n),function(e,t,n,i){if(s.gB.setNodes(e,t,{at:[i]}),e.isTextBlock(t)&&e.isTextBlock(n)){let l=n.children.length;t.children.length<l&&Array.from(Array(l-t.children.length)).forEach((t,n)=>{let r=l-1-n;r>0&&(tT("Removing child"),s.gB.removeNodes(e,{at:[i,r]}))}),t.children.forEach((t,l)=>{let o=n.children[l],a=!r(t,o),c=!r(t.text,o?.text),h=[i,l];if(a)if(t._key===o?._key){tT("Updating changed child",t,o),s.gB.setNodes(e,t,{at:h});let n=s.EY.isText(t)&&"span"===t._type&&s.EY.isText(o)&&"span"===o._type;n&&c?(s.gB.delete(e,{at:{focus:{path:h,offset:0},anchor:{path:h,offset:o.text.length}}}),s.gB.insertText(e,t.text,{at:h}),e.onChange()):n||(tT("Updating changed inline object child",t),s.gB.setNodes(e,{_key:j},{at:[...h,0],voids:!0}))}else o?(tT("Replacing child",t),s.gB.removeNodes(e,{at:[i,l]}),s.gB.insertNodes(e,t,{at:[i,l]}),e.onChange()):o||(tT("Inserting new child",t),s.gB.insertNodes(e,t,{at:[i,l]}),e.onChange())})}}(d,n,a,o)):(tT.enabled&&tT("Replacing block",a,n),function(e,t,n){let i=e.selection,r=i&&i.focus.path[0]===n;r&&s.gB.deselect(e),s.gB.removeNodes(e,{at:[n]}),s.gB.insertNodes(e,t,{at:[n]}),e.onChange(),r&&s.gB.select(e,i)}(d,n,o)),u=!0):(t.send({type:"invalid value",resolution:g.resolution,value:e}),p=!1)}if(!a&&p){let i=tf([e[o]],c,l);
59tT.enabled&&tT("Validating and inserting new block in the end of the value",n),i.valid||i.resolution?.autoResolve?s.gB.insertNodes(d,n,{at:[o]}):(tT("Invalid",i),t.send({type:"invalid value",resolution:i.resolution,value:e}),p=!1)}})})})})})}if(!p)return void tT("Invalid value, returning");if(u){tT("Server value changed, syncing editor");try{d.onChange()}catch(n){console.error(n),t.send({type:"invalid value",resolution:null,value:e});return}g&&!d.selection&&(s.gB.select(d,{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0}}),d.onChange()),t.send({type:"value changed",value:e})}else tT("Server value and editor value is equal, no need to sync.");h.current=e};return u.current=e,e},[t,l,n,i,c,d,f])}({editorActor:l,keyGenerator:n,portableTextEditor:t,readOnly:i}),f=(0,a.Zi)();(0,o.useEffect)(()=>{V.set(f,!1)},[f]);let g=(0,o.useCallback)(()=>{if(u.current.length>0){tS("Flushing pending patches"),tC&&tS(`Patches: 60${JSON.stringify(u.current,null,2)}`);let e=c();l.send({type:"mutation",patches:u.current,snapshot:e}),u.current=[]}V.set(f,!1)},[l,f,c]),m=(0,o.useMemo)(()=>T(()=>{if(s.KE.isNormalizing(f))return void g();m()},1e3,{leading:!1,trailing:!0}),[g,f]);(0,o.useEffect)(()=>()=>{g()},[g]),(0,o.useEffect)(()=>{tS("Subscribing to editor changes");let e=l.on("*",e=>{switch(e.type){case"patch":V.set(f,!0),u.current.push(e.patch),m(),h(e);break;case"loading":h({type:"loading",isLoading:!0});break;case"done loading":h({type:"loading",isLoading:!1});break;case"offline":h({type:"connection",value:"offline"});break;case"online":h({type:"connection",value:"online"});break;case"value changed":h({type:"value",value:e.value});break;case"invalid value":h({type:"invalidValue",resolution:e.resolution,value:e.value});break;case"error":h({...e,level:"warning"});break;default:h(e)}});return()=>{tS("Unsubscribing to changes"),e.unsubscribe()}},[l,m,f]);let y=(0,o.useCallback)(()=>{tS("Editor is online, syncing from props.value"),p(d)},[p,d]);(0,o.useEffect)(()=>{let e=l.on("online",()=>{t.props.patches$&&y()});return()=>{e.unsubscribe()}},[l]);let k=(0,o.useRef)(!0);return(0,o.useEffect)(()=>{tS("Value from props changed, syncing new value"),p(d),k.current&&(l.send({type:"ready"}),k.current=!1)},[l,p,d]),null}let tP=(0,f.SP)(({sendBack:e})=>{let t=()=>{e({type:"online"})},n=()=>{e({type:"offline"})};return window.addEventListener("online",t),window.addEventListener("offline",n),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}),tM=(0,g.mj)({types:{context:{},events:{},emitted:{}},actions:{"emit patch event":(0,m.e)(({event:e})=>((0,g.DT)(e,"patch"),e)),"emit mutation event":(0,m.e)(({event:e})=>((0,g.DT)(e,"mutation"),e)),"defer event":(0,m.a)({pendingEvents:({context:e,event:t})=>((0,g.DT)(t,["patch","mutation"]),[...e.pendingEvents,t])}),"emit pending events":(0,m.b)(({context:e,enqueue:t})=>{for(let n of e.pendingEvents)t((0,m.e)(n))}),"clear pending events":(0,m.a)({pendingEvents:[]})},actors:{networkLogic:tP}}).createMachine({id:"editor",context:{pendingEvents:[]},invoke:{id:"networkLogic",src:"networkLogic"},on:{ready:{actions:(0,m.e)(({event:e})=>e)},unset:{actions:(0,m.e)(({event:e})=>e)},"value changed":{actions:(0,m.e)(({event:e})=>e)},"invalid value":{actions:(0,m.e)(({event:e})=>e)},error:{actions:(0,m.e)(({event:e})=>e)},selection:{actions:(0,m.e)(({event:e})=>e)},blur:{actions:(0,m.e)(({event:e})=>e)},focus:{actions:(0,m.e)(({event:e})=>e)},online:{actions:(0,m.e)({type:"online"})},offline:{actions:(0,m.e)({type:"offline"})},loading:{actions:(0,m.e)({type:"loading"})},"done loading":{actions:(0,m.e)({type:"done loading"})}},initial:"pristine",states:{pristine:{initial:"idle",states:{idle:{on:{normalizing:{target:"normalizing"},patch:{actions:"defer event",target:"#editor.dirty"},mutation:{actions:"defer event",target:"#editor.dirty"}}},normalizing:{on:{"done normalizing":{target:"idle"},patch:{actions:"defer event"},mutation:{actions:"defer event"}}}}},dirty:{entry:["emit pending events","clear pending events"],on:{patch:{actions:"emit patch event"},mutation:{actions:"emit mutation event"}}}}}),t$=(0,o.createContext)(null),tL=()=>{let e=(0,o.useContext)(t$);
60if(void 0===e)throw Error("The `usePortableTextEditorSelection` hook must be used inside the <PortableTextEditor> component's context.");return e},tI=D("component:PortableTextEditor:SelectionProvider"),tj=tI.enabled&&!1;function tO(e){let[t,n]=(0,o.useState)(null);return(0,o.useEffect)(()=>{tI("Subscribing to selection changes");let t=e.editorActor.on("selection",e=>{(0,o.startTransition)(()=>{tj&&tI("Setting selection"),n(e.selection)})});return()=>{tI("Unsubscribing to selection changes"),t.unsubscribe()}},[e.editorActor]),(0,i.jsx)(t$.Provider,{value:t,children:e.children})}let tK=D("component:PortableTextEditor");class tR extends o.Component{editorActor;change$=new p.B;schemaTypes;editable;constructor(e){if(super(e),!e.schemaType)throw Error('PortableTextEditor: missing "schemaType" property');e.incomingPatches$&&console.warn("The prop 'incomingPatches$' is deprecated and renamed to 'patches$'"),this.editorActor=(0,y.A)(tM),this.editorActor.start(),this.schemaTypes=eh(e.schemaType.hasOwnProperty("jsonType")?e.schemaType:ed(e.schemaType))}componentDidUpdate(e){this.props.schemaType!==e.schemaType&&(this.schemaTypes=eh(this.props.schemaType.hasOwnProperty("jsonType")?this.props.schemaType:ed(this.props.schemaType))),this.props.editorRef!==e.editorRef&&this.props.editorRef&&(this.props.editorRef.current=this)}setEditable=e=>{this.editable={...this.editable,...e}};getValue=()=>{if(this.editable)return this.editable.getValue()};render(){let{value:e,children:t,patches$:n,incomingPatches$:r}=this.props,l=typeof this.props.maxBlocks>"u"?void 0:Number.parseInt(this.props.maxBlocks.toString(),10)||void 0,o=!!this.props.readOnly,s=this.props.keyGenerator||t_;return(0,i.jsx)(tx,{keyGenerator:s,maxBlocks:l,patches$:r||n,portableTextEditor:this,readOnly:o,children:(0,i.jsx)(tE.Provider,{value:s,children:(0,i.jsx)(es.Provider,{value:this,children:(0,i.jsx)(tN.Provider,{value:o,children:(0,i.jsxs)(tO,{editorActor:this.editorActor,children:[(0,i.jsx)(tD,{editorActor:this.editorActor,getValue:this.getValue,onChange:e=>{this.props.onChange(e),this.change$.next(e)},value:e}),t]})})})})})}static activeAnnotations=e=>e&&e.editable?e.editable.activeAnnotations():[];static isAnnotationActive=(e,t)=>!!e&&!!e.editable&&e.editable.isAnnotationActive(t);static addAnnotation=(e,t,n)=>e.editable?.addAnnotation(t,n);static blur=e=>{tK("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=>{tK("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)=>(tK("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)=>{tK("Host setting selection",t),e.editable?.select(t)};static removeAnnotation=(e,t)=>e.editable?.removeAnnotation(t);static toggleBlockStyle=(e,t)=>(tK("Host is toggling block style"),e.editable?.toggleBlockStyle(t));static toggleList=(e,t)=>e.editable?.toggleList(t);static toggleMark=(e,t)=>{tK("Host toggling mark",t),e.editable?.toggleMark(t)};static getFragment=e=>(tK("Host getting fragment"),e.editable?.getFragment());static undo=e=>{tK("Host undoing"),e.editable?.undo()};static redo=e=>{tK("Host redoing"),e.editable?.redo()};
60static isSelectionsOverlapping=(e,t,n)=>e.editable?.isSelectionsOverlapping(t,n)}let tz=D("components:Leaf"),tH=[],tV=e=>{let{attributes:t,children:n,leaf:l,schemaTypes:c,renderChild:h,renderDecorator:d,renderAnnotation:p}=e,f=(0,o.useRef)(null),g=ea(),m=(0,a.f7)(),[y,k]=(0,o.useState)(!1),[b,v]=(0,o.useState)(!1),x=n.props.parent,_=(0,o.useMemo)(()=>x?[{_key:x?._key},"children",{_key:l._key}]:[],[x,l._key]),E=(0,o.useMemo)(()=>c.decorators.map(e=>e.value),[c.decorators]),w=(0,o.useMemo)(()=>u((l.marks||tH).filter(e=>E.includes(e))),[E,l.marks]),N=Array.isArray(l.marks)?l.marks:tH,B=(0,o.useMemo)(()=>N.map(e=>!E.includes(e)&&x?.markDefs?.find(t=>t._key===e)).filter(Boolean),[N,x,E]),T=B.length>0&&m;(0,o.useEffect)(()=>{if(!T)return void k(!1);let e=tR.getSelection(g);e&&r(e.focus.path,_)&&tR.isCollapsedSelection(g)&&(0,o.startTransition)(()=>{k(!0)})},[T,_,g]);let A=(0,o.useCallback)(()=>{if(!T)return;tz("Setting selection and focus from range");let e=window.getSelection();if(!e)return void v(!1);if(e&&e.rangeCount>0){let t=e.getRangeAt(0);f.current&&t.intersectsNode(f.current)?v(!0):v(!1)}else v(!1)},[T]);(0,o.useEffect)(()=>{if(!T)return;let e=g.editorActor.on("blur",()=>{k(!1),v(!1)}),t=g.editorActor.on("focus",()=>{let e=tR.getSelection(g);e&&r(e.focus.path,_)&&tR.isCollapsedSelection(g)&&k(!0),A()}),n=g.editorActor.on("selection",e=>{e.selection&&r(e.selection.focus.path,_)&&tR.isCollapsedSelection(g)?k(!0):k(!1),A()});return()=>{e.unsubscribe(),t.unsubscribe(),n.unsubscribe()}},[_,g,A,T]),(0,o.useEffect)(()=>A(),[A]);let S=(0,o.useMemo)(()=>{let e=n;if(s.EY.isText(l)&&l._type===c.span.name&&(w.forEach(t=>{let n=c.decorators.find(e=>e.value===t);n&&d&&(e=d(Object.defineProperty({children:e,editorElementRef:f,focused:y,path:_,selected:b,schemaType:n,value:t},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),n)})))}),x&&B.length>0&&B.forEach(t=>{let n=c.annotations.find(e=>e.name===t._type);if(n)if(p){let r=Object.defineProperty({block:x,children:e,editorElementRef:f,focused:y,path:_,selected:b,schemaType:n,value:t},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),n)});e=(0,i.jsx)("span",{ref:f,children:p(r)})}else e=(0,i.jsx)(ec,{annotation:t,children:(0,i.jsx)("span",{ref:f,children:e})})}),x&&h)){let t=x.children.find(e=>e._key===l._key);if(t){let n=Object.defineProperty({annotations:B,children:(0,i.jsx)(i.Fragment,{children:e}),editorElementRef:f,focused:y,path:_,schemaType:c.span,selected:b,value:t},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),c.span)});e=h(n)}}return e},[B,x,n,y,l,w,_,p,h,d,c.annotations,c.decorators,c.span,b]);return(0,o.useMemo)(()=>(0,i.jsx)("span",{...t,ref:f,children:S},l._key),[l,t,S])},tY=D("component:Editable"),tJ={position:"absolute",userSelect:"none",pointerEvents:"none",left:0,right:0},tQ=(0,o.forwardRef)(function(e,t){let{hotkeys:n,onBlur:c,onFocus:d,onBeforeInput:u,onPaste:p,onCopy:f,onClick:g,rangeDecorations:m,renderAnnotation:y,renderBlock:k,renderChild:b,renderDecorator:v,renderListItem:x,renderPlaceholder:_,renderStyle:E,selection:B,scrollSelectionIntoView:T,spellCheck:A,...S}=e,C=ea(),D=tB(),P=tw(),M=(0,o.useRef)(null),[j,O]=(0,o.useState)(null),[H,V]=(0,o.useState)(!1),[Y,J]=(0,o.useState)([]);(0,o.useImperativeHandle)(t,()=>M.current);let Q=(0,o.useRef)(m),{editorActor:U,schemaTypes:W}=C,q=(0,a.Zi)(),F=W.block.name,Z=(0,o.useMemo)(()=>function(e){let t=W.block.name,n=W.span.name,i=W.block.options.unstable_whitespaceOnPasteMode;return e.setFragmentData=(i,r)=>{let{selection:l}=e;if(!l)return;let[o,c]=s.Q6.edges(l),h=s.KE.void(e,{at:o.path}),d=s.KE.void(e,{at:c.path});if(s.Q6.isCollapsed(l)&&!h)return;let u=a.rL.toDOMRange(e,l),p=u.cloneContents();if(d){let[t]=d,n=u.cloneRange(),i=a.rL.toDOMNode(e,t);n.setEndAfter(i),p=n.cloneContents()}Array.from(p.querySelectorAll("[data-slate-zero-width]")).forEach(e=>{let t="n"===e.getAttribute("data-slate-zero-width");e.textContent=t?` 61`:""}
61),Array.from(p.querySelectorAll("*")).forEach(e=>{for(let t in e.removeAttribute("contentEditable"),e.removeAttribute("data-slate-inline"),e.removeAttribute("data-slate-leaf"),e.removeAttribute("data-slate-node"),e.removeAttribute("data-slate-spacer"),e.removeAttribute("data-slate-string"),e.removeAttribute("data-slate-zero-width"),e.removeAttribute("draggable"),e.attributes)e.hasAttribute(t)&&e.removeAttribute(t)});let f=p.ownerDocument.createElement("div");f.appendChild(p),f.setAttribute("hidden","true"),p.ownerDocument.body.appendChild(f);let g=f.innerHTML;p.ownerDocument.body.removeChild(f);let m=R(e.getFragment(),t),y=JSON.stringify(m),k=m.map(t=>e.isTextBlock(t)?t.children.map(e=>e._type===n?e.text:`[${W.inlineObjects.find(t=>t.name===e._type)?.title||"Object"}]`).join(""):`[${W.blockObjects.find(e=>e.name===t._type)?.title||"Object"}]`).join(` 62 63`);i.clearData(),i.setData("text/plain",k),i.setData("text/html",g),i.setData("application/json",y),i.setData("application/x-portable-text",y),tg("text",k),i.setData("application/x-portable-text-event-origin",r||"external"),tg("Set fragment data",y,g)},e.insertPortableTextData=t=>{if(!e.selection)return!1;let i=t.getData("application/x-portable-text"),r=t.getData("application/x-portable-text-event-origin");if(tg(`Inserting portable text from ${r} event`,i),i){let t=JSON.parse(i);if(Array.isArray(t)&&t.length>0){var l,o,s,a,c;let i=(l=e,o=K(t,{schemaTypes:W}),s=P,a=n,c=W,o.map(e=>{let t={...e};if(l.isTextBlock(t)){let e=c.annotations.map(e=>e.name);if(0===e.length){let{markDefs:e,...n}=t;return{...n,_key:s()}}if((t.markDefs||[]).some(t=>!e.includes(t._type))){let n=(t.markDefs||[]).filter(t=>e.includes(t._type));return{...t,markDefs:n,_key:s()}}t.markDefs=(t.markDefs||[]).map(e=>{let n=e._key,i=s();return t.children=t.children.map(e=>e._type===a&&l.isTextSpan(e)?{...e,marks:e.marks&&e.marks.includes(n)?[...e.marks].filter(e=>e!==n).concat(i):e.marks}:e),{...e,_key:i}})}let n={...t,_key:s()};return l.isTextBlock(n)&&(n.children=n.children.map(e=>({...e,_key:s()}))),n})),r=tf(t,W,P);if(!r.valid&&!r.resolution?.autoResolve){let e=`${r.resolution?.description}`;return U.send({type:"error",name:"pasteError",description:e,data:r}),tg("Invalid insert result",r),!1}return ty(e,i,W),!0}}return!1},e.insertTextOrHTMLData=n=>{if(!e.selection)return tg("No selection, not inserting"),!1;let r=n.getData("text/html"),l=n.getData("text/plain");if(r||l){let o,s,a;if(tg("Inserting data",n),r){if(s=K(o=(0,N.l$)(r,W.portableText,{unstable_whitespaceOnPasteMode:i}).map(e=>(0,N.$x)(e,{blockTypeName:t})),{schemaTypes:W}),a="HTML",0===o.length)return!1}else{let e=`<html><body>${String(l).replace(/[&<>"'`=/]/g,e=>tm[e]).split(/\n{2,}/).map(e=>e?`<p>${e.replace(/(?:\r\n|\r|\n)/g,"<br/>")}</p>`:"<p></p>").join("")}</body></html>`;s=K(o=(0,N.l$)(e,W.portableText).map(e=>(0,N.$x)(e,{blockTypeName:t})),{schemaTypes:W}),a="text"}let c=tf(o,W,P);if(!c.valid){let e=`Could not validate the resulting portable text to insert. 64${c.resolution?.description} 65Try to insert as plain text (shift-paste) instead.`;return U.send({type:"error",name:"pasteError",description:e,data:c}),tg("Invalid insert result",c),!1}return tg(`Inserting ${a} fragment at ${JSON.stringify(e.selection)}`),ty(e,s,W),!0}return!1},e.insertData=t=>{e.insertPortableTextData(t)||e.insertTextOrHTMLData(t)},e.insertFragmentData=t=>{let n=t.getData("application/x-portable-text");if(n){let t=JSON.parse(n);return e.insertFragment(t),!0}return!1},e},[U,P,W]),X=(0,o.useMemo)(()=>(function(e,t,n){let i=["enter","tab","shift","delete","end"],r=n||tp;return function(n){return n.pteWithHotKeys=l=>{Object.keys(r).forEach(e=>{if("marks"===e)for(let t in r[e]){if(i.includes(t))throw Error(`The hotkey ${t} is reserved!`);if((0,w.v_)(t,l.nativeEvent)){l.preventDefault();let i=r[e];if(i){let e=i[t];tu(`HotKey ${t} to toggle ${e}`),n.pteToggleMark(e)}}}if("custom"===e)for(let n in r[e]){if(i.includes(n))throw Error(`The hotkey ${n} is reserved!`);if((0,w.v_)(n,l.nativeEvent)){let i=r[e];i&&(0,i[n])(l,t)}}});let o=(0,w.v_)("enter",l.nativeEvent),a=(0,w.v_)("tab",l.nativeEvent),c=(0,w.v_)("shift+enter",l.nativeEvent),d=(0,w.v_)("shift+tab",l.nativeEvent),u=(0,w.v_)("down",l.nativeEvent),p=(0,w.v_)("up",l.nativeEvent);
65if(u&&n.selection){let e=s.bP.descendant(n,n.selection.focus.path.slice(0,1));if(e&&s.KE.isVoid(n,e)){let e=s.wA.next(n.selection.focus.path.slice(0,1));if(!s.bP.has(n,e)){s.gB.insertNodes(n,n.pteCreateTextBlock({decorators:[]}),{at:e}),n.onChange();return}}}if(p&&n.selection){let e=0===n.selection.focus.path[0],t=s.bP.descendant(n,n.selection.focus.path.slice(0,1));if(e&&t&&s.KE.isVoid(n,t)){s.gB.insertNodes(n,n.pteCreateTextBlock({decorators:[]}),{at:[0]}),s.gB.select(n,{path:[0,0],offset:0}),n.onChange();return}}if((a||d)&&n.selection){let[e]=s.KE.node(n,n.selection.focus,{depth:2}),[t]=(0,h.bn)(e)?s.KE.node(n,n.selection.focus,{depth:1}):[],i=e&&(0,h.L4)(t)&&(0,h.bn)(e)&&(e.marks||[]).filter(e=>(t.markDefs||[]).map(e=>e._key).includes(e)).length>0,[r]=s.Q6.edges(n.selection),o=s.KE.isStart(n,r,r.path);e&&(0,h.bn)(e)&&(!i||o)&&n.pteIncrementBlockLevels(d)&&l.preventDefault()}if(o&&!c&&n.selection){let t=n.selection.focus.path.slice(0,1),i=s.bP.descendant(n,t);if(n.isListBlock(i)){n.pteEndList()&&l.preventDefault();return}if(n.isTextBlock(i)&&i.style&&i.style!==e.styles[0].value){let[,e]=s.Q6.edges(n.selection);if(s.KE.isEnd(n,e,e.path)){s.KE.insertNode(n,n.pteCreateTextBlock({decorators:[]})),l.preventDefault(),n.onChange();return}}if(i&&s.KE.isVoid(n,i)){s.KE.insertNode(n,n.pteCreateTextBlock({decorators:[]})),l.preventDefault(),n.onChange();return}l.preventDefault(),n.insertBreak(),n.onChange()}if(c){l.preventDefault(),n.insertText(` 66`);return}
66if((0,w.v_)("mod+z",l.nativeEvent)){l.preventDefault(),n.undo();return}((0,w.v_)("mod+y",l.nativeEvent)||(0,w.v_)("mod+shift+z",l.nativeEvent))&&(l.preventDefault(),n.redo())},n}})(W,C,n),[n,C,W]);(0,o.useMemo)(()=>D?(tY("Editable is in read only mode"),Z(q)):(tY("Editable is in edit mode"),Z(X(q))),[D,q,X,Z]);let G=(0,o.useCallback)(e=>(0,i.jsx)(eo,{...e,readOnly:D,renderBlock:k,renderChild:b,renderListItem:x,renderStyle:E,schemaTypes:W,spellCheck:A}),[W,A,D,k,b,x,E]),ee=(0,o.useCallback)(e=>{if("span"===e.leaf._type){let t=(0,i.jsx)(tV,{...e,schemaTypes:W,renderAnnotation:y,renderChild:b,renderDecorator:v,readOnly:D});if(_&&e.leaf.placeholder&&""===e.text.text)return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{style:tJ,contentEditable:!1,children:_()}),t]});let n=e.leaf.rangeDecoration;return n&&(t=n.component({children:t})),t}return e.children},[D,y,b,v,_,W]),et=(0,o.useCallback)(()=>{if(B){tY(`Selection from props ${JSON.stringify(B)}`);let e=function(e,t){if(!e||!t||0===t.length)return null;let n=null,i=null,{anchor:l,focus:o}=e;return l&&t.find(e=>r({_key:e._key},l.path[0]))&&(n=I(l,t)),o&&t.find(e=>r({_key:e._key},o.path[0]))&&(i=I(o,t)),n&&i?{anchor:n,focus:i,backward:e.backward}:null}(B,R(q.children,F));if(null!==e){tY(`Normalized selection from props ${JSON.stringify(e)}`);let t=L(e,q);t&&(s.gB.select(q,t),q.operations.some(e=>"set_selection"===e.type)||U.send({type:"selection",selection:e}),q.onChange())}}},[U,B,q]),en=(0,o.useCallback)(e=>{if(m&&m.length>0){let t=[];if(m.forEach(n=>{let i,r=L(n.selection,q);if(!s.Q6.isRange(r)){n.onMoved&&n.onMoved({newSelection:null,rangeDecoration:n,origin:"local"});return}if(e&&((i=function(e,t){let n=s.bR.transform(e.anchor,t),i=s.bR.transform(e.focus,t);return null===n||null===i?null:s.bR.equals(n,e.anchor)&&s.bR.equals(i,e.focus)?e:{anchor:n,focus:i}}(r,e))&&i!==r||null===i&&r)){let e=$(tR.getValue(C),i,W);n.onMoved&&n.onMoved({newSelection:e,rangeDecoration:n,origin:"local"})}null!==i&&t.push({...i||r,rangeDecoration:n})}),t.length>0)return void J(t)}Y.length>0&&J([])},[C,m,W,q]);(0,o.useEffect)(()=>{let e=U.on("ready",()=>{et()}),t=U.on("invalid value",()=>{V(!0)}),n=U.on("value changed",()=>{V(!1)});return()=>{e.unsubscribe(),t.unsubscribe(),n.unsubscribe()}},[U,et]),(0,o.useEffect)(()=>{B&&!H&&et()},[H,B,et]);let ei=(0,o.useMemo)(()=>q.apply,[q]),[er,el]=(0,o.useState)(!1);(0,o.useEffect)(()=>{er||(el(!0),en())},[en,er]),(0,o.useEffect)(()=>{r(m,Q.current)||en(),Q.current=m},[m,en]),(0,o.useEffect)(()=>(q.apply=e=>{ei(e),"set_selection"!==e.type&&en(e)},()=>{q.apply=ei}),[ei,q,en]);let es=(0,o.useCallback)(e=>{f&&void 0!==f(e)&&e.preventDefault()},[f]),ec=(0,o.useCallback)(e=>{if(e.preventDefault(),!q.selection)return;if(!p){tY("Pasting normally"),q.insertData(e.clipboardData);return}let t=tR.getValue(C),n=$(t,q.selection,W)?.focus.path||[],i=p({event:e,value:t,path:n,schemaTypes:W});void 0===i?(tY("No result from custom paste handler, pasting normally"),q.insertData(e.clipboardData)):(U.send({type:"loading"}),Promise.resolve(i).then(t=>{tY("Custom paste function from client resolved",t),t&&t.insert?t.insert?q.insertFragment(K(t.insert,{schemaTypes:W})):console.warn("Your onPaste function returned something unexpected:",t):(tY("No result from custom paste handler, pasting normally"),q.insertData(e.clipboardData))}).catch(e=>(console.error(e),e)).finally(()=>{U.send({type:"done loading"})}))},[p,C,W,q]),eh=(0,o.useCallback)(e=>{if(d&&d(e),!e.isDefaultPrevented()){let t=tR.getSelection(C);null===t&&(s.gB.select(q,s.KE.start(q,[])),q.onChange()),U.send({type:"focus",event:e}),t===tR.getSelection(C)&&U.send({type:"selection",selection:t})}},[U,d,C,q]),ed=(0,o.useCallback)(e=>{if(g&&g(e),q.selection&&e.target===e.currentTarget){let[e,t]=s.bP.last(q,[]),n=q.selection.focus.path.slice(0,1),i=t.slice(0,1);if(s.wA.equals(n,i)){let n=s.bP.descendant(q,t.slice(0,1));e&&s.KE.isVoid(q,n)&&(s.gB.insertNodes(q,q.pteCreateTextBlock({decorators:[]})),q.onChange())}}},[g,q]),eu=(0,o.useCallback)(e=>{c&&c(e),e.isPropagationStopped()||U.send({type:"blur",event:e})},[U,c]),ep=(0,o.useCallback)(e=>{u&&u(e)},[u]),ef=(0,o.useCallback)(()=>
66{if(!q.selection)return;let{activeElement:e}=a.rL.findDocumentOrShadowRoot(q);if(M.current!==e)return;let t=a.rL.getWindow(q).getSelection();if(!t||0===t.rangeCount)return;let n=t.getRangeAt(0);try{let e=a.rL.toDOMRange(q,q.selection);(e.startOffset!==n.startOffset||e.endOffset!==n.endOffset)&&(tY("DOM range out of sync, validating selection"),t?.removeAllRanges(),t.addRange(e))}catch{tY("Could not resolve selection, selecting top document"),s.gB.deselect(q),q.children.length>0&&s.gB.select(q,[0,0]),q.onChange()}},[M,q]);(0,o.useEffect)(()=>{if(j){let e=new MutationObserver(ef);return e.observe(j,{attributeOldValue:!1,attributes:!1,characterData:!1,childList:!0,subtree:!0}),()=>{e.disconnect()}}},[ef,j]);let eg=(0,o.useCallback)(t=>{e.onKeyDown&&e.onKeyDown(t),t.isDefaultPrevented()||q.pteWithHotKeys(t)},[e,q]),em=(0,o.useMemo)(()=>{if(void 0!==T)return null===T?l:(e,t)=>{T(C,t)}},[C,T]),ey=(0,o.useCallback)(([,e])=>{if(z(q.children,W))return[{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0},placeholder:!0}];if(0===e.length)return[];let t=Y.filter(t=>s.Q6.isCollapsed(t)?2===e.length&&s.wA.equals(t.focus.path,e)&&s.wA.equals(t.anchor.path,e):s.Q6.intersection(t,{anchor:{path:e,offset:0},focus:{path:e,offset:0}})||s.Q6.includes(t,e));return t.length>0?t:[]},[q,W,Y]);return(0,o.useEffect)(()=>{M.current=a.rL.toDOMNode(q,q),O(M.current)},[q,M]),C?H?null:(0,i.jsx)(a.Fo,{...S,autoFocus:!1,className:S.className||"pt-editable",decorate:ey,onBlur:eu,onCopy:es,onClick:ed,onDOMBeforeInput:ep,onFocus:eh,onKeyDown:eg,onPaste:ec,readOnly:D,renderPlaceholder:void 0,renderElement:G,renderLeaf:ee,scrollSelectionIntoView:em}):null})}}]);
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.