PageSourceSearch

https://www.theyoungvets.us/_next/static/chunks/06923e47-f2b2fa26b14ad441.js

js theyoungvets.us collected 2026-10-08 10:14:55 UTC 133,429 bytes, 66 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[559],{19381:function(e,t,n){let r;n.d(t,{L9:function(){return tR},YH:function(){return tL},_F:function(){return eA},iV:function(){return nk},q$:function(){return no}});var i=n(7071),o=n(73190),l=n(20070),a=n(85893),s=n(35201),c=n(18446),d=n(50308),h=n(67294),p=n(77493),u=n(56150),f=n(11227),y=n(50562),m=n(41686),g=n(44908),k=n(91186),b=n(41622),v=n(23493),x=n(23279),_=n(64540),w=n(85564),N=n(68630),S=n(4527),E=n(94788),T=n(92125),A=n(14262),R=n(27361),M=n(52353),B=n(14176),C=n(13023);let L="u">typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent),D={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},$={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:L?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},P={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,f13:124,f14:125,f15:126,f16:127,f17:128,f18:129,f19:130,f20:131};function O(e,t){var n;return(null==(n=function(e){let t={altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1},n=e.replace("++","+add").split("+");for(let e of n){let r=e.endsWith("?")&&e.length>1,i=r?e.slice(0,-1):e,o=j(i),l=D[o],a=$[i],s=P[o];if(i.length>1&&void 0===l&&void 0===a&&void 0===s)throw TypeError(`Unknown modifier: "${i}"`);(1===n.length||void 0===l)&&(t.key=o,t.keyCode=function(e){let t=j(e);return P[t]??t.toUpperCase().charCodeAt(0)}(i)),void 0!==l&&(t[l]=!r||null)}return t}(e)).altKey||n.altKey===t.altKey)&&(null==n.ctrlKey||n.ctrlKey===t.ctrlKey)&&(null==n.metaKey||n.metaKey===t.metaKey)&&(null==n.shiftKey||n.shiftKey===t.shiftKey)&&(void 0!==n.keyCode&&void 0!==t.keyCode?91===n.keyCode&&93===t.keyCode||n.keyCode===t.keyCode:n.keyCode===t.keyCode||n.key===t.key.toLowerCase())}function j(e){let t=e.toLowerCase();return $[t]??t}function I(e){return JSON.stringify(e.selection?.anchor.path)===JSON.stringify(e.selection?.focus.path)&&e.selection?.anchor.offset===e.selection?.focus.offset}function Y(e){let t=e.selection&&(0,i.Fd)(e.selection.focus.path[0])?e.selection.focus.path[0]._key:void 0,n=t?e.value.find(e=>e._key===t):void 0;return n&&t?{node:n,path:[{_key:t}]}:void 0}function z(e){let t=Y(e);return t&&(0,i.DG)(t.node)?{node:t.node,path:t.path}:void 0}function G(e){let t=Y(e);return t&&!(0,i.DG)(t.node)?{node:t.node,path:t.path}:void 0}function K(e){let t=function(e){let t=z(e);
1if(!t)return;let n=e.selection&&(0,i.Fd)(e.selection.focus.path[2])?e.selection.focus.path[2]._key:void 0,r=n?t.node.children.find(e=>e._key===n):void 0;return r&&n?{node:r,path:[...t.path,"children",{_key:n}]}:void 0}(e);return t&&(0,i.NG)(t.node)?{node:t.node,path:t.path}:void 0}function U(e){let t;let n=function(e){let t=e.selection.backward?(0,i.Fd)(e.selection.focus.path[0])?e.selection.focus.path[0]._key:void 0:(0,i.Fd)(e.selection.anchor.path[0])?e.selection.anchor.path[0]._key:void 0,n=t?e.value.find(e=>e._key===t):void 0;return n&&t?{node:n,path:[{_key:t}]}:void 0}(e);if(!n)return;let r=!1;for(let i of e.value){if(i._key===n.node._key){r=!0;break}t={node:i,path:[{_key:i._key}]}}if(r&&t)return t}function F(e){let t;let n=function(e){let t=e.selection.backward?(0,i.Fd)(e.selection.anchor.path[0])?e.selection.anchor.path[0]._key:void 0:(0,i.Fd)(e.selection.focus.path[0])?e.selection.focus.path[0]._key:void 0,n=t?e.value.find(e=>e._key===t):void 0;return n&&t?{node:n,path:[{_key:t}]}:void 0}(e);if(!n)return;let r=!1;for(let i of e.value){if(i._key===n.node._key){r=!0;continue}if(r){t={node:i,path:[{_key:i._key}]};break}}if(r&&t)return t}function W(e){if(!(0,i.DG)(e))return!1;let t=e.children.every(i.NG),n=e.children.map(e=>e.text??"").join("");return t&&""===n}let J=[{on:"insert soft break",actions:[()=>[{type:"insert text",text:`
2`}]]},{on:"decorator.add",actions:[({event:e})=>[{type:"decorator.add",decorator:e.decorator},{type:"reselect"}]]},{on:"decorator.remove",actions:[({event:e})=>[{type:"decorator.remove",decorator:e.decorator},{type:"reselect"}]]},{on:"decorator.toggle",actions:[({event:e})=>[{type:"decorator.toggle",decorator:e.decorator},{type:"reselect"}]]},{on:"key.down",guard:({context:e,event:t})=>{let n=O("ArrowDown",t.keyboardEvent),r=G(e),i=F(e);return n&&r&&!i},actions:[()=>[{type:"insert text block",placement:"after"}]]},{on:"key.down",guard:({context:e,event:t})=>{let n=O("ArrowUp",t.keyboardEvent),r=G(e),i=U(e);return n&&r&&!i},actions:[()=>[{type:"insert text block",placement:"before"},{type:"select previous block"}]]},{on:"insert break",guard:({context:e})=>{let t=G(e);return I(e)&&void 0!==t},actions:[()=>[{type:"insert text block",placement:"after"}]]},{on:"delete backward",guard:({context:e})=>{let t=z(e),n=I(e),r=U(e);return!!t&&!!n&&!!r&&!!W(t.node)&&!(0,i.DG)(r.node)&&{focusTextBlock:t,previousBlock:r}},actions:[(e,{focusTextBlock:t,previousBlock:n})=>[{type:"delete block",blockPath:t.path},{type:"select",selection:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}}]]},{on:"delete forward",guard:({context:e})=>{let t=z(e),n=I(e),r=F(e);return!!t&&!!n&&!!r&&!!W(t.node)&&!(0,i.DG)(r.node)&&{focusTextBlock:t,nextBlock:r}},actions:[(e,{focusTextBlock:t,nextBlock:n})=>[{type:"delete block",blockPath:t.path},{type:"select",selection:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}}]]},{on:"delete backward",guard:({context:e})=>{let t=I(e),n=z(e),r=K(e);return!!t&&!!n&&!!r&&n.node.children[0]._key===r.node._key&&0===e.selection.focus.offset&&1===n.node.level&&{focusTextBlock:n}},actions:[(e,{focusTextBlock:t})=>[{type:"unset block",props:["listItem","level"],paths:[t.path]}]]},{on:"delete backward",guard:({context:e})=>{let t=I(e),n=z(e),r=K(e);return!!t&&!!n&&!!r&&n.node.children[0]._key===r.node._key&&0===e.selection.focus.offset&&void 0!==n.node.level&&n.node.level>1&&{focusTextBlock:n,level:n.node.level-1}},actions:[(e,{focusTextBlock:t,level:n})=>[{type:"set block",level:n,paths:[t.path]}]]}];function V({value:e,blockOffset:t}){let n=t.offset,r;for(let o of e)if(o._key===t.path[0]._key&&(0,i.DG)(o)){for(let e of o.children)if((0,i.NG)(e)){if(0===n){r={path:[...t.path,"children",{_key:e._key}],offset:0};break}if(n<=e.text.length){r={path:[...t.path,"children",{_key:e._key}],offset:n};break}n-=e.text.length}}return r}function H(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 r=n.type.of;if(!r)throw Error("Valid types for block children not found in schema (required)");let i=r.find(e=>"span"===e.name);if(!i)throw Error("Span type not found in schema (required)");let o=r.filter(e=>"span"!==e.name)||[],l=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);
2if(!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:i.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:i,portableText:e,inlineObjects:o,blockObjects:l,annotations:i.annotations}}let q="sanity-pte:";function Z(e){let t=`${q}${e}`;return f&&f.enabled(t)?f(t):f(q)}function X(e,t,n){let r;let i=[e.path[0]];if(!t)return null;let o=t[i[0]];if(!o)return null;let l=[{_key:o._key}];if(o._type!==n.block.name)return l;let a=e.path.slice(0,2),s=Array.isArray(o.children)&&o.children[a[1]];return s&&(r=["children",{_key:s._key}]),r?[...l,...r]:l}function Q(e,t){if(!t)return[];let[n,r]=Array.from(p.ML.nodes(t,{at:[],match:t=>(0,i.Fd)(e.path[0])&&t._key===e.path[0]._key}))[0]||[void 0,void 0];if(!n||!p.W_.isElement(n))return[];if(t.isVoid(n))return[r[0],0];let o=[e.path[2]],l=n.children.findIndex(e=>c([{_key:e._key}],o));if(l>=0&&n.children[l]){let e=n.children[l];return p.W_.isElement(e)&&t.isVoid(e)?r.concat(l).concat(0):r.concat(l)}return r}function ee(e,t,n){if(!t)return null;let r=null,i=null,o=t.anchor&&X(t.anchor,e,n);o&&t.anchor&&(r={path:o,offset:t.anchor.offset});let l=t.focus&&X(t.focus,e,n);l&&t.focus&&(i={path:l,offset:t.focus.offset});let a=!!(p.e6.isRange(t)&&p.e6.isBackward(t));return r&&i?{anchor:r,focus:i,backward:a}:null}function et(e,t){if(!e||!t)return null;let n={path:Q(e.anchor,t),offset:e.anchor.offset},r={path:Q(e.focus,t),offset:e.focus.offset};return 0===r.path.length||0===n.path.length?null:n&&r?{anchor:n,focus:r}:null}function en(e,t){if(!e||!t)return null;let n=[],r=e.offset||0,i="object"==typeof e.path[0]&&"_key"in e.path[0]&&e.path[0]._key,o="object"==typeof e.path[2]&&"_key"in e.path[2]&&e.path[2]._key,l=t.find(e=>e._key===i);if(!l)return null;if(n.push({_key:l._key}),l&&"children"===e.path[1]){if(!l.children||Array.isArray(l.children)&&0===l.children.length)return null;let t=Array.isArray(l.children)&&l.children.find(e=>e._key===o);if(!t)return null;n.push("children"),n.push({_key:t._key}),r=t.text&&t.text.length>=e.offset?e.offset:t.text&&t.text.length||0}return{path:n,offset:r}}f(q);let er="void-child";function ei(e,t){let n=t[e._key];return n&&c(e,n)?n:(t[e._key]=e,e)}function eo(e,{schemaTypes:t},n={}){return e&&Array.isArray(e)?e.map(e=>{let{_type:r,_key:i,...o}=e,l=[{_key:er,_type:"span",text:"",marks:[]}];if(e&&e._type===t.block.name){let a=!1,s=typeof e.style>"u",c=typeof e.markDefs>"u",d=typeof e.children>"u",h=(e.children||[]).map(e=>{let{_type:t,_key:r,...i}=e;return"span"!==t?(a=!0,ei({_type:t,_key:r,children:l,value:i,__inline:!0},n)):e});return!(!s&&!c&&!d&&!a&&p.W_.isElement(e))?(s&&(o.style=t.styles[0].value),ei({_type:r,_key:i,...o,children:h},n)):e}return ei({_type:r,_key:i,children:l,value:o},n)}):[]}function el(e,t,n={}){return e.map(e=>{let{_key:r,_type:i}=e;if(!r||!i)throw Error("Not a valid block");if(i===t&&"children"in e&&Array.isArray(e.children)&&r){let t=!1,o=e.children.map(e=>{let{_type:r}=e;if("value"in e&&"span"!==r){t=!0;let{value:r,_key:i,_type:o,__inline:l,children:a,...s}=e;return ei({...s,...r,_key:i,_type:o},n)}return e});return t?ei({...e,children:o,_key:r,_type:i},n):e}let o="value"in e&&e.value;return ei({_key:r,_type:i,..."object"==typeof o?o:{}},n)})}function ea(e,t){return void 0===e||e&&Array.isArray(e)&&0===e.length||e&&Array.isArray(e)&&1===e.length&&p.W_.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&&p.xv.isText(e[0].children[0])&&"span"===e[0].children[0]._type&&!e[0].children[0].marks?.join("")&&""===e[0].children[0].text}let es=new WeakMap,ec=new WeakMap,ed=new WeakMap,eh=new WeakMap,ep=new WeakMap,eu=new WeakMap,ef=new WeakMap,ey=new WeakMap,em=new WeakMap,eg=e=>{let t,n;let r=(0,y.c)(4);return r[0]!==e.value?(t=JSON.stringify(e.value,null,2),r[0]=e.value,r[1]=t):t=r[1],r[2]!==t?(n=(0,a.jsx)("div",{children:(0,a.jsx)("pre",{children:t})}),r[2]=t,r[3]=n):n=r[3],n};
2eg.displayName="DefaultObject";let ek=m.zo.div`
3  user-select: none;
4  border: ${e=>e.selected?"1px solid blue":"1px solid transparent"};
5`;m.zo.span`
6  background: #999;
7  border: ${e=>e.selected?"1px solid blue":"1px solid transparent"};
8`;let eb=m.zo.div`
9  &.pt-list-item {
10    width: fit-content;
11    position: relative;
12    display: block;
13
14    /* Important 'transform' in order to force refresh the ::before and ::after rules
15      in Webkit: https://stackoverflow.com/a/21947628/831480
16    */
17    transform: translateZ(0);
18    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";case 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)};
19  }
20  &.pt-list-item > .pt-list-item-inner {
21    display: flex;
22    margin: 0;
23    padding: 0;
24    &:before {
25      justify-content: flex-start;
26      vertical-align: top;
27    }
28  }
29  &.pt-list-item-bullet > .pt-list-item-inner:before {
30      content: '${e=>{var t;return t=e.listLevel,"bullet"===e.listStyle?ex[(t-1)%3]:"*"}}';
31      font-size: 0.4375rem; /* 7px */
32      line-height: 1.5rem; /* Same as body text */
33      /* Optical alignment */
34      position: relative;
35    }
36  }
37  &.pt-list-item-bullet > .pt-list-item-inner {
38    &:before {
39      min-width: 1.5rem; /* Make sure space between bullet and text never shrinks */
40    }
41  }
42  &.pt-list-item-number {
43    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)};
44    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)};
45  }
46  & + :not(.pt-list-item-number) {
47    counter-reset: listItemNumber;
48  }
49  &.pt-list-item-number > .pt-list-item-inner:before {
50    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)};
51    min-width: 1.5rem; /* Make sure space between number and text never shrinks */
52    /* Optical alignment */
53    position: relative;
54    top: 1px;
55  }
56`,ev=m.zo.div``,ex=["●","○","■"],e_=Z("components:DraggableBlock"),ew=e=>{let t,n,r,i,o,l,s,c,d,f,m,g,k,b,v,x,_;let w=(0,y.c)(51),{children:N,element:S,readOnly:E,blockRef:T}=e,A=(0,u._7)(),R=(0,h.useRef)(),[M,B]=(0,h.useState)(!1);w[0]!==A||w[1]!==S?(n=p.ML.isVoid(A,S),w[0]=A,w[1]=S,w[2]=n):n=w[2],t=n,w[3]!==A||w[4]!==S?(i=p.ML.isInline(A,S),w[3]=A,w[4]=S,w[5]=i):i=w[5],r=i;let[C,L]=(0,h.useState)(null);w[6]!==T||w[7]!==A||w[8]!==S?(o=()=>L(T?T.current:u.F3.toDOMNode(A,S)),l=[A,S,T],w[6]=T,w[7]=A,w[8]=S,w[9]=o,w[10]=l):(o=w[9],l=w[10]),(0,h.useEffect)(o,l),w[11]!==C||w[12]!==A||w[13]!==S?(s=e=>{let t=eh.get(A);if(!t||!C)return;e.preventDefault(),e.dataTransfer.dropEffect="move",ep.set(A,S);let n=C.getBoundingClientRect(),r=n.top,i=n.height,o=e.pageY;if(S===A.children[0]||(Math.abs(r-o)<i/2?eu.set(A,"top"):eu.set(A,"bottom")),t===S){e.dataTransfer.dropEffect="none";return}B(!0)},w[11]=C,w[12]=A,w[13]=S,w[14]=s):s=w[14];let D=s;w[15]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{B(!1)},w[15]=c):c=w[15];let $=c;w[16]!==A||w[17]!==S?(d=e=>{let t=ep.get(A);if(t){ed.set(A,!1),e.preventDefault(),e.stopPropagation(),ep.delete(A),R.current&&(e_("Removing drag ghost"),document.body.removeChild(R.current));let n=eu.get(A);eu.delete(A);let r=u.F3.findPath(A,t),i=u.F3.findPath(A,S),o=p.y$.isBefore(i,r);if("bottom"===n&&!o){if(r[0]>=A.children.length-1){e_("target is already at the bottom, not moving");return}let e=r;r=p.y$.next(r),e_(`Adjusting targetPath from ${JSON.stringify(e)} to ${JSON.stringify(r)}`)}if("top"===n&&o&&r[0]!==A.children.length-1){let e=r;r=p.y$.previous(r),e_(`Adjusting targetPath from ${JSON.stringify(e)} to ${JSON.stringify(r)}`)}if(p.y$.equals(r,i)){e.preventDefault(),e_("targetPath and myPath is the same, not moving");return}e_(`Moving element ${S._key} from path ${JSON.stringify(i)} to ${JSON.stringify(r)} (${n})`),p.YR.moveNodes(A,{at:i,to:r}),A.onChange();return}e_("No target element, not doing anything")},w[16]=A,w[17]=S,w[18]=d):d=w[18];let P=d;w[19]!==A||w[20]!==S?(f=e=>{eh.get(A)&&(e_("On drop (prevented)",S),e.preventDefault(),e.stopPropagation(),B(!1))},w[19]=A,w[20]=S,w[21]=f):f=w[21];let O=f;w[22]!==A||w[23]!==S||w[24]!==t?(m=e=>{if(!t){eh.delete(A);return}ed.set(A,!0),eh.set(A,S),e.stopPropagation();let n=e.target;n instanceof HTMLElement&&(n.style.opacity="1")},w[22]=A,w[23]=S,w[24]=t,w[25]=m):m=w[25];let j=m;w[26]!==C||w[27]!==A||w[28]!==j||w[29]!==r||w[30]!==t?(g=e=>{if(!t||r){e_("Not dragging block"),eh.delete(A),ed.set(A,!1);return}if(e_("Drag start"),ed.set(A,!0),e.dataTransfer&&(e.dataTransfer.setData("application/portable-text","something"),e.dataTransfer.effectAllowed="move"),C&&C instanceof HTMLElement){let t=C.cloneNode(!0),n=t.querySelector("[data-pt-drag-ghost-element]");if(n&&(t=n),t.setAttribute("data-dragged",""),document.body){R.current=t,t.style.position="absolute",t.style.left="-99999px",t.style.boxSizing="border-box",document.body.appendChild(t);let n=C.getBoundingClientRect(),r=e.clientX-n.left,i=e.clientY-n.top;t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,e.dataTransfer.setDragImage(t,r,i)}}j(e)},w[26]=C,w[27]=A,w[28]=j,w[29]=r,w[30]=t,w[31]=g):g=w[31];let I=g;w[32]!==A||w[33]!==M?(k=M&&A.children[0]===ep.get(A),w[32]=A,w[33]=M,w[34]=k):k=w[34];let Y=k;w[35]!==A||w[36]!==M?(b=M&&A.children[A.children.length-1]===ep.get(A),w[35]=A,w[36]=M,w[37]=b):b=w[37];let z=b,G=eu.get(A),K=Y||M&&!Y&&!z&&"top"===G,U=z||M&&!Y&&!z&&"bottom"===G;if(w[38]===Symbol.for("react.memo_cache_sentinel")?(x=(0,a.jsx)("div",{className:"pt-drop-indicator",style:{position:"absolute",width:"100%",height:1,borderBottom:"1px solid currentColor",zIndex:5}}),w[38]=x):x=w[38],v=x,E){let e;return w[39]!==N?(e=(0,a.jsx)(a.Fragment,{children:N}),w[39]=N,w[40]=e):e=w[40],e}let F=K&&v,W=U&&v;return w[41]!==N||w[42]!==j||w[43]!==P||w[44]!==D||w[45]!==I||w[46]!==O||w[47]!==t||w[48]!==F||w[49]!==W?(_=(0,a.jsxs)("div",{draggable:t,onDragStart:I,onDrag:j,onDragOver:D,onDragLeave:$,onDragEnd:P,onDrop:O,children:[F,N,W]}),w[41]=N,w[42]=j,w[43]=P,w[44]=D,w[45]=I,w[46]=O,w[47]=t,w[48]=F,w[49]=W,w[50]=_):_=w[50],_};ew.displayName="DraggableBlock",Z("components:Element");let eN=[],eS={display:"inline-block"},eE=({attributes:e,children:t,element:n,schemaTypes:r,readOnly:i,renderBlock:o,renderChild:l,renderListItem:s,renderStyle:c,spellCheck:d})=>{let f;let y=(0,u._7)(),m=(0,u.vt)(),g=(0,h.useRef)(null),k=(0,h.useRef)(null),b=m&&y.selection&&p.e6.isCollapsed(y.selection)||!1,v=(0,h.useMemo)(()=>el([n],r.block.name,ey.get(y))[0],[y,n,r.block.name]),x=t,_,w=(0,h.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");
56if(y.isInline(n)){let o=u.F3.findPath(y,n),[s]=p.ML.node(y,o,{depth:1}),c=r.inlineObjects.find(e=>e.name===n._type);if(!c)throw Error("Could not find type for inline block element");if(p.W_.isElement(s)){let r=[{_key:s._key},"children",{_key:n._key}];return(0,a.jsxs)("span",{...e,children:[t,(0,a.jsxs)("span",{draggable:!i,className:"pt-inline-object","data-testid":"pt-inline-object",ref:k,style:eS,contentEditable:!1,children:[l&&l({annotations:eN,children:(0,a.jsx)(eg,{value:v}),editorElementRef:k,focused:b,path:r,schemaType:c,selected:m,type:c,value:v}),!l&&(0,a.jsx)(eg,{value:v})]},n._key)]})}throw Error("Block not found!")}if(n._type===r.block.name){let l;_="pt-block pt-text-block";let h="listItem"in n,p="style"in n&&n.style||"normal";_=`pt-block pt-text-block pt-text-block-style-${p}`;let u=r.styles.find(e=>e.value===p);if(c&&u&&(x=c({block:n,children:t,focused:b,selected:m,value:p,path:w,schemaType:u,editorElementRef:g})),h&&("number"==typeof n.level&&(l=n.level),_+=` pt-list-item pt-list-item-${n.listItem} pt-list-item-level-${l||1}`),y.isListBlock(v)&&h&&n.listItem){let e=r.lists.find(e=>e.value===n.listItem);x=s&&e?s({block:v,children:x,focused:b,selected:m,value:n.listItem,path:w,schemaType:e,level:v.level||1,editorElementRef:g}):(0,a.jsx)(eb,{listStyle:v.listItem||r.lists[0].value,listLevel:v.level||1,children:(0,a.jsx)(ev,{children:x})})}let f=Object.defineProperty({children:x,editorElementRef:g,focused:b,level:l,listItem:h?n.listItem:void 0,path:w,selected:m,style:p,schemaType:r.block,value:v},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),r.block)}),k=o?o(f):t;return(0,a.jsx)("div",{...e,className:_,spellCheck:d,children:(0,a.jsx)(ew,{element:n,readOnly:i,blockRef:g,children:(0,a.jsx)("div",{ref:g,children:k})})},n._key)}let N=r.blockObjects.find(e=>e.name===n._type);if(!N)throw Error(`Could not find schema type for block element of _type ${n._type}`);_="pt-block pt-object-block";let S=el([n],r.block.name,ey.get(y))[0];return o&&(f=o(Object.defineProperty({children:(0,a.jsx)(eg,{value:v}),editorElementRef:g,focused:b,path:w,schemaType:N,selected:m,value:S},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),N)}))),(0,a.jsxs)("div",{...e,className:_,children:[t,(0,a.jsxs)(ew,{element:n,readOnly:i,blockRef:g,children:[f&&(0,a.jsx)("div",{ref:g,contentEditable:!1,children:f}),!f&&(0,a.jsx)(ek,{selected:m,children:(0,a.jsx)(eg,{value:v})})]})]},n._key)};eE.displayName="Element";let eT=(0,h.createContext)(null),eA=()=>{let e=(0,h.useContext)(eT);if(!e)throw Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");return e};function eR(e){let t,n,r;let i=(0,y.c)(6);i[0]!==e.annotation?(t=()=>alert(JSON.stringify(e.annotation)),i[0]=e.annotation,i[1]=t):t=i[1];let o=t;return i[2]===Symbol.for("react.memo_cache_sentinel")?(n={color:"blue"},i[2]=n):n=i[2],i[3]!==o||i[4]!==e.children?(r=(0,a.jsx)("span",{style:n,onClick:o,children:e.children}),i[3]=o,i[4]=e.children,i[5]=r):r=i[5],r}function eM(e){return o.V.compile({name:"blockTypeSchema",types:[e]}).get(e.name)}function eB(e,t,n){let r=null,o=!0,l=[t.span.name,...t.inlineObjects.map(e=>e.name)],a=[t.block.name,...t.blockObjects.map(e=>e.name)];return void 0===e?{valid:!0,resolution:null,value:e}
56:Array.isArray(e)&&0!==e.length?(e.some((e,s)=>{if(!N(e))return r={patches:[(0,_.zN)([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 r={patches:[(0,_.t8)({...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||!a.includes(e._type)){if("block"===e._type){let n=t.block.name;return r={patches:[(0,_.t8)({...e,_type:n},[{_key:e._key}])],description:`Block with _key '${e._key}' has invalid type name '${e._type}'. According to the schema, the block type name is '${n}'`,action:`Use type '${n}'`,item:e,i18n:{description:"inputs.portable-text.invalid-value.incorrect-block-type.description",action:"inputs.portable-text.invalid-value.incorrect-block-type.action",values:{key:e._key,expectedTypeName:n}}},!0}return r=!e._type&&(0,i.DG)({...e,_type:t.block.name})?{patches:[(0,_.t8)({...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,_.zN)([{_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,_.zN)([{_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 r={patches:[(0,_.t8)({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 i={_type:t.span.name,_key:n(),text:"",marks:[]};return r={autoResolve:!0,patches:[(0,_.Cb)([],[{_key:e._key},"children"]),(0,_.$T)([i],"after",[{_key:e._key},"children",0])],description:`Children for text block with _key '${e._key}' is empty.`,action:"Insert an empty text",item:e,i18n:{description:"inputs.portable-text.invalid-value.empty-children.description",action:"inputs.portable-text.invalid-value.empty-children.action",values:{key:e._key}}},!0}let i=g(w(e.children.filter(e=>e._type===t.span.name).map(e=>e.marks||[])));if(Array.isArray(e.markDefs)&&e.markDefs.length>0){let t=g(e.markDefs.map(e=>e._key).filter(e=>!i.includes(e)));if(t.length>0)return r={autoResolve:!0,patches:t.map(t=>(0,_.zN)([{_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 a=i.filter(e=>!t.decorators.map(e=>e.value).includes(e)).filter(t=>void 0===e.markDefs||!e.markDefs.find(e=>e._key===t));if(a.length>0){let n=e.children.filter(e=>e._type===t.span.name&&Array.isArray(e.marks)&&e.marks.some(e=>a.includes(e)));if(n){let t=a.join(", ");return r={autoResolve:!0,patches:n.map(t=>(0,_.t8)((t.marks||[]).filter(e=>
56!a.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:a.map(e=>e.toString())}}},!0}}e.children.some((i,o)=>{if(!N(i))return r={patches:[(0,_.zN)([{_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(!i._key||"string"!=typeof i._key){let t={...i,_key:n()};return r={autoResolve:!0,patches:[(0,_.t8)(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 i._type?l.includes(i._type)?i._type===t.span.name&&"string"!=typeof i.text&&(r={patches:[(0,_.t8)({...i,text:""},[{_key:e._key},"children",{_key:i._key}])],description:`Child with _key '${i._key}' in block with key '${e._key}' has missing or invalid text property!`,action:"Write an empty text property to the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.invali
56d-span-text.description",action:"inputs.portable-text.invalid-value.invalid-span-text.action",values:{key:e._key,childKey:i._key}}},!0):(r={patches:[(0,_.zN)([{_key:e._key},"children",{_key:i._key}])],description:`Child with _key '${i._key}' in block with key '${e._key}' has invalid '_type' property (${i._type}).`,action:"Remove the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.disallowed-child-type.description",action:"inputs.portable-text.invalid-value.disallowed-child-type.action",values:{key:e._key,childKey:i._key,childType:i._type}}},!0):(r={patches:[(0,_.zN)([{_key:e._key},"children",{_key:i._key}])],description:`Child with _key '${i._key}' in block with key '${e._key}' is missing '_type' property.`,action:"Remove the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-child-type.description",action:"inputs.portable-text.invalid-value.missing-child-type.action",values:{key:e._key,childKey:i._key}}},!0)})&&(o=!1)}return!1})&&(o=!1),{valid:o,resolution:r,value:e}):{valid:!1,resolution:{patches:[(0,_.zN)([])],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}}function eC(e,t){let n=eL(e)||!1;es.set(e,!0),t(),es.set(e,n)}function eL(e){return es.get(e)}eR.displayName="DefaultAnnotation";let eD=new WeakMap;function e$(e,t){let n=eD.get(e);eD.set(e,!1),t(),eD.set(e,n)}function eP(e){let[t,n]=e;return[t,n]}function eO(e,t){let n=e,r=t,i=n.length,o=r.length;if(0===i||0===o)return 0;i>o?n=n.substring(i-o):i<o&&(r=r.substring(0,i));let l=Math.min(i,o);if(n===r)return l;let a=0,s=1;for(let e=0;-1!==e;){let t=n.substring(l-s);if(-1===(e=r.indexOf(t)))break;s+=e,(0===e||n.substring(l-s)===r.substring(0,s))&&(a=s,s++)}return a}function ej(e,t){if(!e||!t||e[0]!==t[0])return 0;let n=0,r=Math.min(e.length,t.length),i=r,o=0;for(;n<i;)e.substring(o,i)===t.substring(o,i)?o=n=i:r=i,i=Math.floor((r-n)/2+n);return i}function eI(e,t){if(!e||!t||e[e.length-1]!==t[t.length-1])return 0;let n=0,r=Math.min(e.length,t.length),i=r,o=0;for(;n<i;)e.substring(e.length-i,e.length-o)===t.substring(t.length-i,t.length-o)?o=n=i:r=i,i=Math.floor((r-n)/2+n);return i}let eY=/[^a-zA-Z0-9]/,ez=/\s/,eG=/[\r\n]/,eK=/\n\r?\n$/,eU=/^\r?\n\r?\n/;function eF(e){let t=e.map(e=>eP(e));function n(e,t){if(!e||!t)return 6;let n=e.charAt(e.length-1),r=t.charAt(0),i=n.match(eY),o=r.match(eY),l=i&&n.match(ez),a=o&&r.match(ez),s=l&&n.match(eG),c=a&&r.match(eG),d=s&&e.match(eK),h=c&&t.match(eU);return d||h?5:s||c?4:i&&!l&&a?3:l||a?2:i||o?1:0}let r=1;for(;r<t.length-1;){if(t[r-1][0]===eZ&&t[r+1][0]===eZ){let e=t[r-1][1],i=t[r][1],o=t[r+1][1],l=eI(e,i);if(l){let t=i.substring(i.length-l);e=e.substring(0,e.length-l),i=t+i.substring(0,i.length-l),o=t+o}let a=e,s=i,c=o,d=n(e,i)+n(i,o);for(;i.charAt(0)===o.charAt(0);){e+=i.charAt(0),i=i.substring(1)+o.charAt(0),o=o.substring(1);let t=n(e,i)+n(i,o);t>=d&&(d=t,a=e,s=i,c=o)}t[r-1][1]!==a&&(a?t[r-1][1]=a:(t.splice(r-1,1),r--),t[r][1]=s,c?t[r+1][1]=c:(t.splice(r+1,1),r--))}r++}return t}function eW(e){let t=e.map(e=>eP(e));t.push([eZ,""]);let n=0,r=0,i=0,o="",l="",a;for(;n<t.length;)switch(t[n][0]){case eq:i++,l+=t[n][1],n++;break;case eH:r++,o+=t[n][1],n++;break;case eZ:r+i>1?(0!==r&&0!==i&&(0!==(a=ej(l,o))&&(n-r-i>0&&t[n-r-i-1][0]===eZ?t[n-r-i-1][1]+=l.substring(0,a):(t.splice(0,0,[eZ,l.substring(0,a)]),n++),l=l.substring(a),o=o.substring(a)),0!==(a=eI(l,o))&&(t[n][1]=l.substring(l.length-a)+t[n][1],l=l.substring(0,l.length-a),o=o.substring(0,o.length-a))),n-=r+i,t.splice(n,r+i),o.length&&(t.splice(n,0,[eH,o]),n++),l.length&&(t.splice(n,0,[eq,l]),n++),n++):0!==n&&t[n-1][0]===eZ?(t[n-1][1]+=t[n][1],t.splice(n,1)):n++,i=0,r=0,o="",l="";break;default:throw Error("Unknown diff operation")}""===t[t.length-1][1]&&t.pop();let s=!1;for(n=1;n<t.length-1;)t[n-1][0]===eZ&&t[n+1][0]===eZ&&(t[n][1].substring(t[n][1].length-t[n-1][1].length)===t[n-1][1]?(t[n][1]=t[n-1][1]+t[n][1].substring(0,t[n][1].length-t[n-1][1].length),t[n+1][1]=t[n-1][1]+t[n+1][1],t.splice(n-1,1),s=!0):t[n][1].substring(0,t[n+1][1].length)===t[n+1][1]&&(t[n-1][1]+=t[n+1][1],t[n][1]=t[n][1].substring(t[n+1][1].length)+t[n+1][1],t.splice(n+1,1),s=!0)),n++;return s&&(t=eW(t)),t}function eJ(e,t,n,r,i){let o=e.substring(0,n),l=t.substring(0,r),a=e.substring(n),s=t.substring(r),c=eQ(o,l,{checkLines:!1,deadline:i}),d=eQ(a,s,{checkLines:!1,deadline:i});return c.concat(d)}function eV(e,t,n){let r=e.slice(n,n+Math.floor(e.length/4)),i=-1,o="",l,a,s,c;for(;-1!==(i=t.indexOf(r,i+1));){let r=ej(e.slice(n),t.slice(i)),d=eI(e.slice(0,n),t.slice(0,i));o.length<d+r&&(o=t.slice(i-d,i)+t.slice(i,i+r),l=e.slice(0,n-d),a=e.slice(n+r),s=t.slice(0,i-d),c=t.slice(i+r))}return 2*o.length>=e.length?[l||"",a||"",s||"",c||"",o||""]:null}let eH=-1,eq=1,eZ=0;function eX(e,t,n){var r,i;let o;if(null===e||null===t)throw Error("Null input. (diff)");let l=eQ(e,t,{checkLines:!0,deadline:(i=(r=n||{}).timeout||1,o=1,"u">typeof i&&(o=i<=0?Number.MAX_VALUE:i),Date.now()+1e3*o),...r});return function(e){for(let t=0;t<e.length;t++){let[n,r]=e[t];if(0===r.length)continue;let i=r[0];(function(e){let t=e.charCodeAt(0);return t>=55296&&t<=56319})(r[r.length-1])&&n===eZ&&e2(e,t,1),function(e){let t=e.charCodeAt(0);return t>=56320&&t<=57343}(i)&&n===eZ&&e2(e,t,-1)}for(let t=0;t<e.length;t++)0===e[t][1].length&&e.splice(t,1)}(l),l}function eQ(e,t,n){let r=e,i=t;if(r===i)return r?[[eZ,r]]:[];let o=ej(r,i),l=r.substring(0,o);o=eI(r=r.substring(o),i=i.substring(o));let a=r.substring(r.length-o),s=function(e,t,n){let r;if(!e)return[[eq,t]];if(!t)return[[eH,e]];let i=e.length>t.length?e:t,o=e.length>t.length?t:e,l=i.indexOf(o);if(-1!==l)return r=[[eq,i.substring(0,l)],[eZ,o],[eq,i.substring(l+o.length)]],e.length>t.length&&(r[0][0]=eH,r[2][0]=eH),r;if(1===o.length)return[[eH,e],[eq,t]];let a=function(e,t){let n,r,i,o,l;if((arguments.length>2&&void 0!==arguments[2]?arguments[2]:1)<=0)return null;let a=e.length>t.length?e:t,s=e.length>t.length?t:e;if(a.length<4||2*s.length<a.length)return null;
56let c=eV(a,s,Math.ceil(a.length/4)),d=eV(a,s,Math.ceil(a.length/2));if(c&&d)n=c[4].length>d[4].length?c:d;else{if(!c&&!d)return null;d?c||(n=d):n=c}if(!n)throw Error("Unable to find a half match.");return e.length>t.length?(r=n[0],i=n[1],o=n[2],l=n[3]):(o=n[0],l=n[1],r=n[2],i=n[3]),[r,i,o,l,n[4]]}(e,t);if(a){let e=a[0],t=a[1],r=a[2],i=a[3],o=a[4],l=eQ(e,r,n),s=eQ(t,i,n);return l.concat([[eZ,o]],s)}return n.checkLines&&e.length>100&&t.length>100?function(e,t,n){let r=e,i=t,o=function(e,t){let n=[],r={};function i(e){let t="",i=0,l=-1,a=n.length;for(;l<e.length-1;){-1===(l=e.indexOf(`
57`,i))&&(l=e.length-1);let s=e.slice(i,l+1);(r.hasOwnProperty?r.hasOwnProperty(s):void 0!==r[s])?t+=String.fromCharCode(r[s]):(a===o&&(s=e.slice(i),l=e.length),t+=String.fromCharCode(a),r[s]=a,n[a++]=s),i=l+1}return t}n[0]="";let o=4e4,l=i(e);return o=65535,{chars1:l,chars2:i(t),lineArray:n}}(r,i);r=o.chars1,i=o.chars2;let l=o.lineArray,a=eQ(r,i,{checkLines:!1,deadline:n.deadline});(function(e,t){for(let n=0;n<e.length;n++){let r=e[n][1],i=[];for(let e=0;e<r.length;e++)i[e]=t[r.charCodeAt(e)];e[n][1]=i.join("")}})(a,l),(a=function(e){let t=e.map(e=>eP(e)),n=!1,r=[],i=0,o=null,l=0,a=0,s=0,c=0,d=0;for(;l<t.length;)t[l][0]===eZ?(r[i++]=l,a=c,s=d,c=0,d=0,o=t[l][1]):(t[l][0]===eq?c+=t[l][1].length:d+=t[l][1].length,o&&o.length<=Math.max(a,s)&&o.length<=Math.max(c,d)&&(t.splice(r[i-1],0,[eH,o]),t[r[i-1]+1][0]=eq,i--,l=--i>0?r[i-1]:-1,a=0,s=0,c=0,d=0,o=null,n=!0)),l++;for(n&&(t=eW(t)),t=eF(t),l=1;l<t.length;){if(t[l-1][0]===eH&&t[l][0]===eq){let e=t[l-1][1],n=t[l][1],r=eO(e,n),i=eO(n,e);r>=i?(r>=e.length/2||r>=n.length/2)&&(t.splice(l,0,[eZ,n.substring(0,r)]),t[l-1][1]=e.substring(0,e.length-r),t[l+1][1]=n.substring(r),l++):(i>=e.length/2||i>=n.length/2)&&(t.splice(l,0,[eZ,e.substring(0,i)]),t[l-1][0]=eq,t[l-1][1]=n.substring(0,n.length-i),t[l+1][0]=eH,t[l+1][1]=e.substring(i),l++),l++}l++}return t}(a)).push([eZ,""]);let s=0,c=0,d=0,h="",p="";for(;s<a.length;){switch(a[s][0]){case eq:d++,p+=a[s][1];break;case eH:c++,h+=a[s][1];break;case eZ:if(c>=1&&d>=1){a.splice(s-c-d,c+d),s=s-c-d;let e=eQ(h,p,{checkLines:!1,deadline:n.deadline});for(let t=e.length-1;t>=0;t--)a.splice(s,0,e[t]);s+=e.length}d=0,c=0,h="",p="";break;default:throw Error("Unknown diff operation.")}s++}return a.pop(),a}(e,t,n):function(e,t,n){let r=e.length,i=t.length,o=Math.ceil((r+i)/2),l=2*o,a=Array(l),s=Array(l);for(let e=0;e<l;e++)a[e]=-1,s[e]=-1;a[o+1]=0,s[o+1]=0;let c=r-i,d=c%2!=0,h=0,p=0,u=0,f=0;for(let y=0;y<o&&!(Date.now()>n);y++){for(let u=-y+h;u<=y-p;u+=2){let f;let m=o+u,g=(f=u===-y||u!==y&&a[m-1]<a[m+1]?a[m+1]:a[m-1]+1)-u;for(;f<r&&g<i&&e.charAt(f)===t.charAt(g);)f++,g++;if(a[m]=f,f>r)p+=2;else if(g>i)h+=2;else if(d){let i=o+c-u;if(i>=0&&i<l&&-1!==s[i]&&f>=r-s[i])return eJ(e,t,f,g,n)}}for(let h=-y+u;h<=y-f;h+=2){let p;let m=o+h,g=(p=h===-y||h!==y&&s[m-1]<s[m+1]?s[m+1]:s[m-1]+1)-h;for(;p<r&&g<i&&e.charAt(r-p-1)===t.charAt(i-g-1);)p++,g++;if(s[m]=p,p>r)f+=2;else if(g>i)u+=2;else if(!d){let i=o+c-h;if(i>=0&&i<l&&-1!==a[i]){let l=a[i],s=o+l-i;if(l>=(p=r-p))return eJ(e,t,l,s,n)}}}}return[[eH,e],[eq,t]]}(e,t,n.deadline)}(r=r.substring(0,r.length-o),i=i.substring(0,i.length-o),n);return l&&s.unshift([eZ,l]),a&&s.push([eZ,a]),s=eW(s)}function e0(e,t,n){return 1===n?e+t:t+e}function e1(e,t){return 1===t?[e.substring(0,e.length-1),e[e.length-1]]:[e.substring(1),e[0]]}function e2(e,t,n){var r,i;let o=1===n?-1:1,l=null,a=null,s=t+n;for(;s>=0&&s<e.length&&(null===l||null===a);s+=n){let[r,i]=e[s];if(0!==i.length){if(r===eq){null===l&&(l=s);continue}if(r===eH){null===a&&(a=s);continue}if(r===eZ){if(null===l&&null===a){let[r,i]=e1(e[t][1],n);e[t][1]=r,e[s][1]=e0(e[s][1],i,o);return}break}}}if(null!==l&&null!==a&&(r=l,i=a,1===n?e[r][1][e[r][1].length-1]===e[i][1][e[i][1].length-1]:e[r][1][0]===e[i][1][0])){let[r,i]=e1(e[l][1],o),[s]=e1(e[a][1],o);e[l][1]=r,e[a][1]=s,e[t][1]=e0(e[t][1],i,n);return}let[c,d]=e1(e[t][1],n);e[t][1]=c,null===l?(e.splice(s,0,[eq,d]),null!==a&&a>=s&&a++):e[l][1]=e0(e[l][1],d,o),null===a?e.splice(s,0,[eH,d]):e[a][1]=e0(e[a][1],d,o)}let e3={threshold:.5,distance:1e3};function e8(e,t,n){if(null===e||null===t||null===n)throw Error("Null input. (match())");let r=Math.max(0,Math.min(n,e.length));return e===t?0:e.length?e.substring(r,r+t.length)===t?r:function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(t.length>32)throw Error("Pattern too long for this browser.");let i={...e3,...r},o=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 l(e,r){let o=e/t.length,l=Math.abs(n-r);return i.distance?o+l/i.distance:l?1:o}let a=i.threshold,s=e.indexOf(t,n);-1!==s&&(a=Math.min(l(0,s),a),-1!==(s=e.lastIndexOf(t,n+t.length))&&(a=Math.min(l(0,s),a)));let c=1<<t.length-1;s=-1;let d,h,p=t.length+e.length,u=[];for(let r=0;r<t.length;r++){for(d=0,h=p;d<h;)l(r,n+h)<=a?d=h:p=h,h=Math.floor((p-d)/2+d);p=h;let i=Math.max(1,n-h+1),f=Math.min(n+h,e.length)+t.length,y=Array(f+2);y[f+1]=(1<<r)-1;for(let t=f;t>=i;t--){let d=o[e.charAt(t-1)];if(0===r?y[t]=(y[t+1]<<1|1)&d:y[t]=(y[t+1]<<1|1)&d|((u[t+1]|u[t])<<1|1)|u[t+1],y[t]&c){let e=l(r,t-1);if(e<=a){if(a=e,(s=t-1)>n)i=Math.max(1,2*n-s);else break}}}if(l(r+1,n)>a)break;u=y}return s}(e,t,r):-1}function e4(e,t){return{diffs:[],start1:e,start2:t,utf8Start1:e,utf8Start2:t,length1:0,length2:0,utf8Length1:0,utf8Length2:0}}function e6(e){let t=[];for(let n=0;n<e.length;n++)e[n][0]!==eq&&(t[n]=e[n][1]);return t.join("")}function e5(e){let t=[];for(let n=0;n<e.length;n++)e[n][0]!==eH&&(t[n]=e[n][1]);return t.join("")}function e9(e){let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);if(typeof r>"u")throw Error("Failed to get codepoint");t+=e7(r)}return t}function e7(e){return e<=127?1:e<=2047?2:e<=65535?3:4}function te(e,t){let n=0,r=0,i=0,o=0,l;for(l=0;l<e.length&&(e[l][0]!==eq&&(n+=e[l][1].length),e[l][0]!==eH&&(r+=e[l][1].length),!(n>t));l++)i=n,o=r;return e.length!==l&&e[l][0]===eH?o:o+(t-i)}let tt=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;function tn(e){if(!e)return[];let t=[],n=e.split(`
58`),r=0;for(;r<n.length;){let e=n[r].match(tt);if(!e)throw Error("Invalid patch string: ".concat(n[r]));let i=e4(tr(e[1]),tr(e[3]));for(t.push(i),""===e[2]?(i.start1--,i.utf8Start1--,i.length1=1,i.utf8Length1=1):"0"===e[2]?(i.length1=0,i.utf8Length1=0):(i.start1--,i.utf8Start1--,i.utf8Length1=tr(e[2]),i.length1=i.utf8Length1),""===e[4]?(i.start2--,i.utf8Start2--,i.length2=1,i.utf8Length2=1):"0"===e[4]?(i.length2=0,i.utf8Length2=0):(i.start2--,i.utf8Start2--,i.utf8Length2=tr(e[4]),i.length2=i.utf8Length2),r++;r<n.length;){let e;let t=n[r],o=t.charAt(0);if("@"===o)break;if(""===o){r++;continue}try{e=decodeURI(t.slice(1))}catch{throw Error("Illegal escape in parse: ".concat(t))}let l=e9(e)-e.length;if("-"===o)i.diffs.push([eH,e]),i.length1-=l;else if("+"===o)i.diffs.push([eq,e]),i.length2-=l;else if(" "===o)i.diffs.push([eZ,e]),i.length1-=l,i.length2-=l;else throw Error('Invalid patch mode "'.concat(o,'" in: ').concat(e));r++}}return t}function tr(e){return parseInt(e,10)}let ti=new WeakMap,to=new WeakMap;function tl(e){return ti.get(e)??!1}function ta(e){return to.get(e)??!1}let ts=Z("plugin:withUndoRedo"),tc=ts.enabled&&!1,td=new WeakMap,th=new WeakMap,tp=e=>{let t=td.get(e);return void 0===t||t},tu=e=>(th.get(e)||th.set(e,[]),th.get(e)||[]);function tf(e,t,n,r,i){tc&&(ts(`Adjusting '${n.type}' operation paths for '${t.type}' patch`),ts(`Operation ${JSON.stringify(n)}`),ts(`Patch ${JSON.stringify(t)}`));let o={...n};if("insert"===t.type&&1===t.path.length){let e=(r||[]).findIndex(e=>c({_key:e._key},t.path[0]));return ts(`Adjusting block path (+${t.items.length}) for '${o.type}' operation and patch '${t.type}'`),[ty(o,t.items.length,e)]}if("unset"===t.type&&1===t.path.length){let n=(i||[]).findIndex(e=>c({_key:e._key},t.path[0]));return"path"in o&&Array.isArray(o.path)&&o.path[0]===n?(ts("Skipping transformation that targeted removed block"),[]):(tc&&(ts(`Selection ${JSON.stringify(e.selection)}`),ts(`Adjusting block path (-1) for '${o.type}' operation and patch '${t.type}'`)),[ty(o,-1,n)])}if("unset"===t.type&&0===t.path.length)return ts(`Adjusting selection for unset everything patch and ${n.type} operation`),[];
58if("diffMatchPatch"===t.type){let n;let r=("set_selection"===o.type&&e.selection?n=e.children[e.selection.focus.path[0]]:"path"in o&&(n=e.children[o.path[0]]),n);return r&&c({_key:r._key},t.path[0])&&tn(t.value).forEach(e=>{let t=0,n=e.utf8Start1,{diffs:r}=e;if(r.forEach((e,i)=>{let[o,l]=e;o===eq?(t+=l.length,n+=l.length):o===eH?(t-=l.length,n-=l.length):o===eZ&&(r.slice(i).every(([e])=>e===eZ)||(n+=l.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,r=o?.properties?.anchor?{...o.properties.anchor}:void 0,i=o?.newProperties?.focus?{...o.newProperties.focus}:void 0,l=o?.newProperties?.anchor?{...o.newProperties.anchor}:void 0;(e&&r||i&&l)&&([e,r,i,l].forEach(e=>{e&&n<e.offset&&(e.offset+=t)}),e&&r&&(o.properties={focus:e,anchor:r}),i&&l&&(o.newProperties={focus:i,anchor:l}))}}),[o]}return[o]}function ty(e,t,n){let r={...e};if(n>=0&&"set_selection"!==r.type&&Array.isArray(r.path)&&r.path[0]>=n+t&&r.path[0]+t>-1){let e=[r.path[0]+t,...r.path.slice(1)];r.path=e}if("set_selection"===r.type){let e=r.properties?.focus?{...r.properties.focus}:void 0,i=r?.properties?.anchor?{...r.properties.anchor}:void 0,o=r?.newProperties?.focus?{...r.newProperties.focus}:void 0,l=r?.newProperties?.anchor?{...r.newProperties.anchor}:void 0;(e&&i||o&&l)&&([e,i,o,l].forEach(e=>{e&&e.path[0]>=n+t&&e.path[0]+t>-1&&(e.path=[e.path[0]+t,...e.path.slice(1)])}),e&&i&&(r.properties={focus:e,anchor:i}),o&&l&&(r.newProperties={focus:o,anchor:l}))}return r}let tm=(e,t)=>!!("set_selection"===e.type||t&&"insert_text"===e.type&&"insert_text"===t.type&&e.offset===t.offset+t.text.length&&p.y$.equals(e.path,t.path)&&" "!==e.text||t&&"remove_text"===e.type&&"remove_text"===t.type&&e.offset+e.text.length===t.offset&&p.y$.equals(e.path,t.path)),tg=(e,t)=>!!(t&&"set_selection"===e.type&&"set_selection"===t.type),tk=e=>"set_selection"!==e.type;function tb(e,t){let n=tp(e);td.set(e,!1),t(),td.set(e,n)}let tv=Z("hook:useSyncValue"),tx=new WeakMap,t_=Z("component:PortableTextEditor:Synchronizer"),tw=t_.enabled&&!1;function tN(e){let t,n,r,i,o,l,a,d,u,f,m;let g=(0,y.c)(26),k=(0,s.v9)(e.editorActor,tE),b=(0,s.v9)(e.editorActor,tS),{editorActor:_,getValue:w,portableTextEditor:N,slateEditor:S}=e;g[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],g[0]=t):t=g[0];let E=(0,h.useRef)(t);g[1]!==_||g[2]!==N||g[3]!==k||g[4]!==S?(n={editorActor:_,portableTextEditor:N,readOnly:k,slateEditor:S},g[1]=_,g[2]=N,g[3]=k,g[4]=S,g[5]=n):n=g[5];let T=function(e){let{editorActor:t,portableTextEditor:n,readOnly:r,slateEditor:i}=e,o=t.getSnapshot().context.schema,l=(0,h.useRef)(),a=(0,h.useRef)(),s=(0,h.useCallback)(()=>{let e=tx.get(n);if(l.current===e){tv("Value is the same object as previous, not need to sync");return}a.current&&e&&(tv("Updating the value debounced"),a.current(e))},[n]),d=(0,h.useMemo)(()=>x(s,1e3,{trailing:!0,leading:!1}),[s]);return(0,h.useMemo)(()=>{let e=e=>{tx.set(n,e);let a=ec.get(i),s=eL(i);if(!r){if(a){tv("Has local changes, not syncing value right now"),d();return}if(s){tv("Has remote changes, not syncing value right now"),d();return}}let h=!1,u=!0,f=!!i.selection;if(e&&0!==e.length||(tv("Value is empty"),p.ML.withoutNormalizing(i,()=>{tb(i,()=>{e$(i,()=>{f&&p.YR.deselect(i);let e=i.children.length;i.children.forEach((t,n)=>{p.YR.removeNodes(i,{at:[e-1-n]})}),p.YR.insertNodes(i,i.pteCreateTextBlock({decorators:[]}),{at:[0]}),f&&p.YR.select(i,[0,0])})})}),h=!0),e&&e.length>0){let n=eo(e,{schemaTypes:o});p.ML.withoutNormalizing(i,()=>{eC(i,()=>{tb(i,()=>{e$(i,()=>{let a=i.children.length;if(n.length<a){for(let e=a-1;e>n.length-1;e--)p.YR.removeNodes(i,{at:[e]});h=!0}n.forEach((n,a)=>{let s=i.children[a];if(s&&!c(n,s)&&u){let d=[e[a]],f=eB(d,o,t.getSnapshot().context.keyGenerator);!f.valid&&f.resolution?.autoResolve&&f.resolution?.patches.length>0&&!r&&l.current&&l.current!==e&&(console.warn(`${f.resolution.action} for block with _key '${d[0]._key}'. ${f.resolution?.description}`),f.resolution.patches.forEach(e=>{t.send({type:"patch",patch:e})})),f.valid||f.resolution?.autoResolve?(s._key===n._key?(tv.enabled&&tv("Updating block",s,n),function(e,t,n,r){if(p.YR.setNodes(e,t,{at:[r]}),e.isTextBlock(t)&&e.isTextBlock(n)){let i=n.children.length;t.children.length<i&&Array.from(Array(i-t.children.length)).forEac
58h((t,n)=>{let o=i-1-n;o>0&&(tv("Removing child"),p.YR.removeNodes(e,{at:[r,o]}))}),t.children.forEach((t,i)=>{let o=n.children[i],l=!c(t,o),a=!c(t.text,o?.text),s=[r,i];if(l){if(t._key===o?._key){tv("Updating changed child",t,o),p.YR.setNodes(e,t,{at:s});let n=p.xv.isText(t)&&"span"===t._type&&p.xv.isText(o)&&"span"===o._type;n&&a?(p.YR.delete(e,{at:{focus:{path:s,offset:0},anchor:{path:s,offset:o.text.length}}}),p.YR.insertText(e,t.text,{at:s}),e.onChange()):n||(tv("Updating changed inline object child",t),p.YR.setNodes(e,{_key:er},{at:[...s,0],voids:!0}))}else o?(tv("Replacing child",t),p.YR.removeNodes(e,{at:[r,i]}),p.YR.insertNodes(e,t,{at:[r,i]}),e.onChange()):o||(tv("Inserting new child",t),p.YR.insertNodes(e,t,{at:[r,i]}),e.onChange())}})}}(i,n,s,a)):(tv.enabled&&tv("Replacing block",s,n),function(e,t,n){let r=e.selection,i=r&&r.focus.path[0]===n;i&&p.YR.deselect(e),p.YR.removeNodes(e,{at:[n]}),p.YR.insertNodes(e,t,{at:[n]}),e.onChange(),i&&p.YR.select(e,r)}(i,n,a)),h=!0):(t.send({type:"invalid value",resolution:f.resolution,value:e}),u=!1)}if(!s&&u){let r=eB([e[a]],o,t.getSnapshot().context.keyGenerator);tv.enabled&&tv("Validating and inserting new block in the end of the value",n),r.valid||r.resolution?.autoResolve?p.YR.insertNodes(i,n,{at:[a]}):(tv("Invalid",r),t.send({type:"invalid value",resolution:r.resolution,value:e}),u=!1)}})})})})})}if(!u){tv("Invalid value, returning");return}if(h){tv("Server value changed, syncing editor");try{i.onChange()}catch(n){console.error(n),t.send({type:"invalid value",resolution:null,value:e});return}f&&!i.selection&&(p.YR.select(i,{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0}}),i.onChange()),t.send({type:"value changed",value:e})}else tv("Server value and editor value is equal, no need to sync.");l.current=e};return a.current=e,e},[t,n,r,o,i,d])}(n);g[6]!==S?(r=()=>{ec.set(S,!1)},i=[S],g[6]=S,g[7]=r,g[8]=i):(r=g[7],i=g[8]),(0,h.useEffect)(r,i),g[9]!==_||g[10]!==w||g[11]!==S?(o=()=>{if(E.current.length>0){t_("Flushing pending patches"),tw&&t_(`Patches:
59${JSON.stringify(E.current,null,2)}`);let e=w();_.send({type:"mutation",patches:E.current,snapshot:e}),E.current=[]}ec.set(S,!1)},g[9]=_,g[10]=w,g[11]=S,g[12]=o):o=g[12];let A=o;g[13]!==A?(l=()=>()=>{A()},a=[A],g[13]=A,g[14]=l,g[15]=a):(l=g[14],a=g[15]),(0,h.useEffect)(l,a),g[16]!==_||g[17]!==A||g[18]!==S?(d=()=>{let e=v(()=>{if(p.ML.isNormalizing(S)){A();return}e()},1e3,{leading:!1,trailing:!0});t_("Subscribing to patch events");let t=_.on("patch",t=>{ec.set(S,!0),E.current.push(t.patch),e()});return()=>{t_("Unsubscribing to patch events"),t.unsubscribe()}},u=[_,A,S],g[16]=_,g[17]=A,g[18]=S,g[19]=d,g[20]=u):(d=g[19],u=g[20]),(0,h.useEffect)(d,u);let R=(0,h.useRef)(!0);return g[21]!==_||g[22]!==T||g[23]!==b?(m=()=>{t_("Value from props changed, syncing new value"),T(b),R.current&&(_.send({type:"ready"}),R.current=!1)},f=[_,T,b],g[21]=_,g[22]=T,g[23]=b,g[24]=f,g[25]=m):(f=g[24],m=g[25]),(0,h.useEffect)(m,f),null}function tS(e){return e.context.value}function tE(e){return e.context.readOnly}tN.displayName="Synchronizer";let tT=(0,h.createContext)({}),tA=(0,h.createContext)(null),tR=()=>{let e=(0,h.useContext)(tA);if(void 0===e)throw Error("The `usePortableTextEditorSelection` hook must be used inside the <PortableTextEditor> component's context.");return e},tM=Z("component:PortableTextEditor:SelectionProvider"),tB=tM.enabled&&!1;function tC(e){let t,n,r;let i=(0,y.c)(6),[o,l]=(0,h.useState)(null);return i[0]!==e.editorActor?(t=()=>{tM("Subscribing to selection changes");let t=e.editorActor.on("selection",e=>{(0,h.startTransition)(()=>{tB&&tM("Setting selection"),l(e.selection)})});return()=>{tM("Unsubscribing to selection changes"),t.unsubscribe()}},n=[e.editorActor],i[0]=e.editorActor,i[1]=t,i[2]=n):(t=i[1],n=i[2]),(0,h.useEffect)(t,n),i[3]!==e.children||i[4]!==o?(r=(0,a.jsx)(tA.Provider,{value:o,children:e.children}),i[3]=e.children,i[4]=o,i[5]=r):r=i[5],r}let tL=()=>(function(e){let t=tD();return(function(e=16){let t=new Uint8Array(e);return(0,S.Z)(t),t})(12).reduce((e,n)=>e+t[n],"").slice(0,12)})(12),tD=()=>{if(r)return r;r=[];for(let e=0;e<256;++e)r[e]=(e+256).toString(16).slice(1);return r},t$=Z("operationToPatches"),tP=Z("applyPatches"),tO=tP.enabled&&!0;function tj(e){return"object"==typeof e&&"_key"in e}function tI(e,t){tO&&(tP(`Children ${t}:`,JSON.stringify(e.children,null,2)),tP(`Selection ${t}: `,JSON.stringify(e.selection,null,2)))}function tY(e,t){let{block:n,path:r}=function(e,t){let n=-1,r=e.children.find((e,r)=>{let i=tj(t[0])?e._key===t[0]._key:r===t[0];return i&&(n=r),i});return r?{block:r,path:[n]}:{}}(e,t);if(!(p.W_.isElement(n)&&"children"===t[1]))return{block:n,blockPath:r,child:void 0,childPath:void 0};let i=-1,o=n.children.find((e,n)=>{let r=tj(t[2])?e._key===t[2]._key:n===t[2];return r&&(i=n),r});return o?{block:n,child:o,blockPath:r,childPath:r?.concat(i)}:{block:n,blockPath:r,child:void 0,childPath:void 0}}
59let tz=Z("plugin:withPatches"),tG=Z("plugin:withPlaceholderBlock"),tK=Z("plugin:withPortableTextBlockStyle"),tU=Z("plugin:withPortableTextLists");function tF(e){return"span"===e._type&&"text"in e&&"string"==typeof e.text&&(typeof e.marks>"u"||Array.isArray(e.marks)&&e.marks.every(e=>"string"==typeof e))}function tW({editor:e,blockPath:t,spanPath:n}){let r;for(let[i,o]of p.NB.children(e,t,{reverse:!0}))if(e.isTextSpan(i)&&p.y$.isBefore(o,n)){r=i;break}return r}function tJ({editor:e,blockPath:t,spanPath:n}){let r;for(let[i,o]of p.NB.children(e,t))if(e.isTextSpan(i)&&p.y$.isAfter(o,n)){r=i;break}return r}let tV=Z("plugin:withPortableTextMarkModel"),tH=({action:e})=>{let t=e.editor,n=e.decorator;if(t.selection){if(p.e6.isExpanded(t.selection)){p.YR.setNodes(t,{},{match:p.xv.isText,split:!0,hanging:!0});let e=p.e6.isRange(t.selection)?[...p.ML.nodes(t,{at:t.selection,match:p.xv.isText})]:[];e.length>1&&e.every(e=>e[0].marks?.includes(n))?t.removeMark(n):e.forEach(([e,r])=>{let i=[...(Array.isArray(e.marks)?e.marks:[]).filter(e=>e!==n),n];p.YR.setNodes(t,{marks:i},{at:r,match:p.xv.isText,split:!0,hanging:!0})})}else{let[e,r]=p.ML.node(t,t.selection,{depth:1}),i=t.isTextBlock(e)&&1===e.children.length&&t.isTextSpan(e.children[0])&&""===e.children[0].text?e.children[0]:void 0;if(i){let e=i.marks??[],o=e.filter(e=>e!==n);p.YR.setNodes(t,{marks:e.length===o.length?[...e,n]:o},{at:r,match:e=>t.isTextSpan(e)})}else{let e={...p.ML.marks(t)||{}}.marks||[],r={...p.ML.marks(t)||{},marks:[...e,n]};t.marks=r}}t.onChange()}},tq=({action:e})=>{let t=e.editor,n=e.decorator,{selection:r}=t;if(r){if(p.e6.isExpanded(r))p.YR.setNodes(t,{},{match:p.xv.isText,split:!0,hanging:!0}),t.selection&&[...p.ML.nodes(t,{at:t.selection,match:p.xv.isText})].forEach(([e,r])=>{let i=t.children[r[0]];p.W_.isElement(i)&&i.children.includes(e)&&p.YR.setNodes(t,{marks:(Array.isArray(e.marks)?e.marks:[]).filter(e=>e!==n),_type:"span"},{at:r})});else{let[e,i]=p.ML.node(t,r,{depth:1}),o=t.isTextBlock(e)&&1===e.children.length&&t.isTextSpan(e.children[0])&&""===e.children[0].text?e.children[0]:void 0;if(o){let e=(o.marks??[]).filter(e=>e!==n);p.YR.setNodes(t,{marks:e},{at:i,match:e=>t.isTextSpan(e)})}else{let e={...p.ML.marks(t)||{}}.marks||[],r={...p.ML.marks(t)||{},marks:e.filter(e=>e!==n)};t.marks={marks:r.marks,_type:"span"}}}}};function tZ({editor:e,decorator:t}){if(!e.selection)return!1;let n=Array.from(p.ML.nodes(e,{match:p.xv.isText,at:e.selection}));return 0!==n.length&&(p.e6.isExpanded(e.selection)?n.every(e=>{let[n]=e;return n.marks?.includes(t)}):(({...p.ML.marks(e)||{}}).marks||[]).includes(t))}let tX=Z("plugin:withPortableTextSelections"),tQ=tX.enabled&&!1,t0=Z("plugin:withSchemaTypes"),t1=Z("plugin:withUtils"),t2=(e,t)=>{var n,r;let o;let{editorActor:l}=t,a=l.getSnapshot().context.schema,s=function(e){let t=e.block.name;return{insertNodePatch:function(e,n,r){let i=r[n.path[0]],o=e.isTextBlock(i);if(1===n.path.length){let e=0===n.path[0]?"before":"after",o=r[n.path[0]-1],l=0===n.path[0]?i?._key:o?._key;return l?[(0,_.$T)([el([n.node],t)[0]],e,[{_key:l}])]:[(0,_.Cb)(r,[]),(0,_.$T)([el([n.node],t)[0]],"before",[n.path[0]])]}if(o&&2===n.path.length&&e.children[n.path[0]]){let e=0!==i.children.length&&i.children[n.path[1]-1]?"after":"before",r={...n.node};!r._type&&p.xv.isText(r)&&(r._type="span",r.marks=[]);let o=el([{_key:"bogus",_type:t,children:[r]}],t)[0].children[0];return[(0,_.$T)([o],e,[{_key:i._key},"children",i.children.length<=1||!i.children[n.path[1]-1]?0:{_key:i.children[n.path[1]-1]._key}])]}return t$("Something was inserted into a void block. Not producing editor patches."),[]},insertTextPatch:function(e,t,n){t$.enabled&&t$("Operation",JSON.stringify(t,null,2));let r=e.isTextBlock(e.children[t.path[0]])&&e.children[t.path[0]];if(!r)throw Error("Could not find block");let i=e.isTextBlock(r)&&e.isTextSpan(r.children[t.path[1]])&&r.children[t.path[1]];if(!i)throw Error("Could not find child");let o=[{_key:r._key},"children",{_key:i._key},"text"],l=n[t.path[0]],a=e.isTextBlock(l)&&l.children[t.path[1]],s=e.isTextSpan(a)?a.text:"",c=(0,_.aH)(s,i.text,o);return c.value.length?[c]:[]},mergeNodePatch:function(e,n,r){let i=[],o=r[n.path[0]],l=e.children[n.path[0]];if(1===n.path.length){if(o?._key){let r=el([e.children[n.path[0]-1]],t)[0];i.push((0,_.t8)(r,[{_key:r._key}])),i.push((0,_.zN)([{_key:o._key}]))}else throw Error("Target key not found!")}else if(e.isTextBlock(o)&&e.isTextBlock(l)&&2===n.path.length){let t=l.children[n.path[1]-1]&&e.isTextSpan(l.children[n.path[1]-1])?l.children[n.path[1]-1]:void 0,r=o.children[n.path[1]]&&e.isTextSpan(o.children[n.path[1]])?o.children[n.path[1]]:void 0;t&&(1===o.children.filter(e=>e._key===t._key).length?i.push((0,_.t8)(t.text,[{_key:o._key},"children",{_key:t._key},"text"])):console.warn(`Multiple spans have \`_key\` ${t._key}. It's ambiguous which one to update.`,JSON.stringify(o,null,2))),r&&(1===o.children.filter(e=>e._key===r._key).length?i.push((0,_.zN)([{_key:o._key},"children",{_key:r._key}])):console.warn(`Multiple spans have \`_key\` ${r._key}. It's ambiguous which one to remove.`,JSON.stringify(o,null,2)))}else t$("Void nodes can't be merged, not creating any patches");return i},moveNodePatch:function(e,n,r){let i=[],o=r[n.path[0]],l=r[n.newPath[0]];if(1===n.path.length){let e=n.path[0]>n.newPath[0]?"before":"after";i.push((0,_.zN)([{_key:o._key}])),i.push((0,_.$T)([el([o],t)[0]],e,[{_key:l._key}]))}else if(2===n.path.length&&e.isTextBlock(o)&&e.isTextBlock(l)){let e=o.children[n.path[1]],r=l.children[n.newPath[1]],a=n.newPath[1]===l.children.length?"after":"before",s=el([o],t)[0].children[n.path[1]];i.push((0,_.zN)([{_key:o._key},"children",{_key:e._key}])),i.push((0,_.$T)([s],a,[{_key:l._key},"children",{_key:r._key}]))}return i},removeNodePatch:function(e,t,n){let r=n[t.path[0]];if(1===t.path.length){if(r&&r._key)return[(0,_.zN)([{_key:r._key}])];throw Error("Block not found")}if(!e.isTextBlock(r)||2!==t.path.length)return t$("Not creating patch inside object block"),[];{let e=r.children[t.path[1]];return e?r.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(r,null,2)),[]):[(0,_.zN)([{_key:r._key},"children",{_key:e._key}])]:(t$("Span not found in editor trying to remove node"),[])}},removeTextPatch:function(e,t,n){let r=e&&e.children[t.path[0]];if(!r)throw Error("Could not find block");let i=e.isTextBlock(r)&&r.children[t.path[1]]||void 0,o=e.isTextSpan(i)?i:void 0;if(i&&!o)throw Error("Expected span");if(!o)throw Error("Could not find child");let l=[{_key:r._key},"children",{_key:o._key},"text"],a=n[t.path[0]],s=e.isTextBlock(a)&&a.children[t.path[1]],c=e.isTextSpan(s)&&s.text,d=(0,_.aH)(c||"",o.text,l);return d.value?[d]:[]},setNodePatch:function(e,n){if(1===n.path.length){let r=e.children[n.path[0]];if("string"!=typeof r._key)throw Error("Expected block to have a _key");let i=B({...e.children[n.path[0]],...n.newProperties},M);return[(0,_.t8)(el([i],t)[0],[{_key:r._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 r=t._key,i=e._key,o=[],l=Object.keys(n.newProperties);return l.forEach(a=>{if(1===l.length&&"_key"===a){let i=R(n.newProperties,a);o.push((0,_.t8)(i,[{_key:r},"children",t.children.indexOf(e),a]))}else{let e=R(n.newProperties,a);o.push((0,_.t8)(e,[{_key:r},"children",{_key:i},a]))}}),o}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,r){let i=[],o=e.children[n.path[0]];if(!e.isTextBlock(o))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 l=r[n.path[0]];if(e.isTextBlock(l)){let r=el([e.children[n.path[0]+1]],t)[0];r&&(i.push((0,_.$T)([r],"after",[{_key:o._key}
59])),l.children.slice(n.position).forEach(e=>{let t=[{_key:l._key},"children",{_key:e._key}];i.push((0,_.zN)(t))}))}return i}if(2===n.path.length){let r=o.children[n.path[1]];if(e.isTextSpan(r)){let e=el([{...o,children:o.children.slice(n.path[1]+1,n.path[1]+2)}],t)[0].children;i.push((0,_.$T)(e,"after",[{_key:o._key},"children",{_key:r._key}])),i.push((0,_.t8)(r.text,[{_key:o._key},"children",{_key:r._key},"text"]))}}return i}}}(a),d=function({editorActor:e,schemaTypes:t}){return function(n){n.isTextBlock=e=>(0,i.DG)(e)&&e._type===t.block.name,n.isTextSpan=e=>(0,i.NG)(e)&&e._type===t.span.name,n.isListBlock=e=>(0,i.KA)(e)&&e._type===t.block.name,n.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)),n.isInline=e=>t.inlineObjects.map(e=>e.name).includes(e._type)&&"__inline"in e&&!0===e.__inline;let{normalizeNode:r}=n;return n.normalizeNode=i=>{let[o,l]=i;if(void 0===o._type&&2===l.length){t0("Setting span type on text node without a type");let r=o._key||e.getSnapshot().context.keyGenerator();e.send({type:"normalizing"}),p.YR.setNodes(n,{...o,_type:t.span.name,_key:r},{at:l}),e.send({type:"done normalizing"});return}if(void 0===o._key&&(1===l.length||2===l.length)){t0("Setting missing key on child node without a key");let t=e.getSnapshot().context.keyGenerator();e.send({type:"normalizing"}),p.YR.setNodes(n,{_key:t},{at:l}),e.send({type:"done normalizing"});return}r(i)},n}}({editorActor:l,schemaTypes:a}),h=function({editorActor:e,patchFunctions:t,schemaTypes:n,subscriptions:r}){let i;let o=(e,t)=>{let r=!1;tO&&(tP(`
60
61NEW PATCH =============================================================`),tP(JSON.stringify(t,null,2)));try{switch(t.type){case"insert":r=function(e,t,n){let{block:r,child:i,blockPath:o,childPath:l}=tY(e,t.path);if(!r||!o)return tP("Block not found"),!1;if(t.path.length>1&&"children"!==t.path[1])return tP("Ignoring patch targeting void value"),!1;if(1===t.path.length){let{items:r,position:i}=t,l=eo(r,{schemaTypes:n},ef.get(e)),a=o[0],s="after"===i?a+1:a;return tP(`Inserting blocks at path [${s}]`),tI(e,"before"),p.YR.insertNodes(e,l,{at:[s]}),tI(e,"after"),!0}let{items:a,position:s}=t;if(!i||!l)return tP("Child not found"),!1;let c=r&&eo([{...r,children:a}],{schemaTypes:n},ef.get(e)),d=l[1],h=[l[0],"after"===s?d+1:d];return tP(`Inserting children at path ${h}`),tI(e,"before"),c&&p.W_.isElement(c[0])&&p.YR.insertNodes(e,c[0].children,{at:h}),tI(e,"after"),!0}(e,t,n);break;case"unset":r=function(e,t){if(0===t.path.length){tP("Removing everything"),tI(e,"before");let t=e.selection;return p.YR.deselect(e),e.children.forEach((t,n)=>{p.YR.removeNodes(e,{at:[n]})}),p.YR.insertNodes(e,e.pteCreateTextBlock({decorators:[]})),t&&p.YR.select(e,{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0}}),e.onChange(),tI(e,"after"),!0}let{block:n,blockPath:r,child:i,childPath:o}=tY(e,t.path);if(1===t.path.length){if(!n||!r)return tP("Block not found"),!1;let t=r[0];return tP(`Removing block at path [${t}]`),tI(e,"before"),p.YR.removeNodes(e,{at:[t]}),tI(e,"after"),!0}return!!e.isTextBlock(n)&&"children"===t.path[1]&&3===t.path.length&&(i&&o?(tP(`Unsetting child at path ${JSON.stringify(o)}`),tI(e,"before"),tO&&tP(`Removing child at path ${JSON.stringify(o)}`),p.YR.removeNodes(e,{at:o}),tI(e,"after"),!0):(tP("Child not found"),!1))}(e,t);break;case"set":r=function(e,t){let n=t.value;"string"==typeof t.path[3]&&((n={})[t.path[3]]=t.value);let{block:r,blockPath:i,child:o,childPath:l}=tY(e,t.path);if(!r)return tP("Block not found"),!1;let a=e.isTextBlock(r);if(a&&t.path.length>1&&"children"!==t.path[1])return tP("Ignoring setting void value"),!1;if(tI(e,"before"),a&&o&&l){if(p.xv.isText(n)&&p.xv.isText(o)){let t=o.text;n.text!==t&&(tP("Setting text property"),e.apply({type:"remove_text",path:l,offset:0,text:t}),e.apply({type:"insert_text",path:l,offset:0,text:n.text}),e.onChange())}else tP("Setting non-text property"),e.apply({type:"set_node",path:l,properties:{},newProperties:n});return!0}if(p.W_.isElement(r)&&1===t.path.length&&i){tP("Setting block property");let{children:t,...o}=n,{children:l,...a}=r||{children:void 0};e.apply({type:"set_node",path:i,properties:{...a},newProperties:o}
61),tP("Setting children"),r.children.forEach((t,n)=>{e.apply({type:"remove_node",path:i.concat(r.children.length-1-n),node:t})}),Array.isArray(t)&&t.forEach((t,n)=>{e.apply({type:"insert_node",path:i.concat(n),node:t})})}else if(r&&"value"in r){let n=(0,_.g7)([r.value],[t])[0];return p.YR.setNodes(e,{...r,value:n},{at:i}),!0}return tI(e,"after"),!0}(e,t);break;case"diffMatchPatch":r=function(e,t){let{block:n,child:r,childPath:i}=tY(e,t.path);if(!n)return tP("Block not found"),!1;if(!r||!i)return tP("Child not found"),!1;if(!(n&&e.isTextBlock(n)&&4===t.path.length&&"children"===t.path[1]&&"text"===t.path[3])||!p.xv.isText(r))return!1;let[o]=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 r=t;if(0===e.length)return[r,[]];let i=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=0,i=0;function o(e){for(;r<e;){let e=t.codePointAt(i);if(typeof e>"u")return i;r+=e7(e),e>65535?i+=2:i+=1}if(!n.allowExceedingIndices&&r!==e)throw Error("Failed to determine byte offset");return i}let l=[];for(let t of e)l.push({diffs:t.diffs.map(e=>eP(e)),start1:o(t.start1),start2:o(t.start2),utf8Start1:t.utf8Start1,utf8Start2:t.utf8Start2,length1:t.length1,length2:t.length2,utf8Length1:t.utf8Length1,utf8Length2:t.utf8Length2});return l}(e,r,{allowExceedingIndices:n.allowExceedingIndices}),o=n.margin||4,l=n.deleteThreshold||.4,a=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 r=e[0],i=r.diffs;if(0===i.length||i[0][0]!==eZ)i.unshift([eZ,n]),r.start1-=t,r.start2-=t,r.utf8Start1-=t,r.utf8Start2-=t,r.length1+=t,r.length2+=t,r.utf8Length1+=t,r.utf8Length2+=t;else if(t>i[0][1].length){let e=i[0][1].length,o=t-e;i[0][1]=n.substring(e)+i[0][1],r.start1-=o,r.start2-=o,r.utf8Start1-=o,r.utf8Start2-=o,r.length1+=o,r.length2+=o,r.utf8Length1+=o,r.utf8Length2+=o}if(0===(i=(r=e[e.length-1]).diffs).length||i[i.length-1][0]!==eZ)i.push([eZ,n]),r.length1+=t,r.length2+=t,r.utf8Length1+=t,r.utf8Length2+=t;else if(t>i[i.length-1][1].length){let e=t-i[i.length-1][1].length;i[i.length-1][1]+=n.substring(0,e),r.length1+=e,r.length2+=e,r.utf8Length1+=e,r.utf8Length2+=e}return n}(i,o);r=a+r+a,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 r=e[n];e.splice(n--,1);let i=r.start1,o=r.start2,l="";for(;0!==r.diffs.length;){let a=e4(i-l.length,o-l.length),s=!0;if(""!==l){let e=e9(l);a.length1=l.length,a.utf8Length1=e,a.length2=l.length,a.utf8Length2=e,a.diffs.push([eZ,l])}for(;0!==r.diffs.length&&a.length1<32-t;){let e=r.diffs[0][0],n=r.diffs[0][1],l=e9(n);if(e===eq){a.length2+=n.length,a.utf8Length2+=l,o+=n.length;let e=r.diffs.shift();e&&a.diffs.push(e),s=!1}else e===eH&&1===a.diffs.length&&a.diffs[0][0]===eZ&&n.length>64?(a.length1+=n.length,a.utf8Length1+=l,i+=n.length,s=!1,a.diffs.push([e,n]),r.diffs.shift()):(l=e9(n=n.substring(0,32-a.length1-t)),a.length1+=n.length,a.utf8Length1+=l,i+=n.length,e===eZ?(a.length2+=n.length,a.utf8Length2+=l,o+=n.length):s=!1,a.diffs.push([e,n]),n===r.diffs[0][1]?r.diffs.shift():r.diffs[0][1]=r.diffs[0][1].substring(n.length))}l=(l=e5(a.diffs)).substring(l.length-t);let c=e6(r.diffs).substring(0,t),d=e9(c);""!==c&&(a.length1+=c.length,a.length2+=c.length,a.utf8Length1+=d,a.utf8Length2+=d,0!==a.diffs.length&&a.diffs[a.diffs.length-1][0]===eZ?a.diffs[a.diffs.length-1][1]+=c:a.diffs.push([eZ,c])),s||e.splice(++n,0,a)}}}(i,o);let s=0,c=[];for(let e=0;e<i.length;e++){let t=i[e].start2+s,n=e6(i[e].diffs),o,a=-1;if(n.length>32?-1!==(o=e8(r,n.substring(0,32),t))&&(-1===(a=e8(r,n.substring(n.length-32),t+n.length-32))||o>=a)&&(o=-1):o=e8(r,n,t),-1===o)c[e]=!1,s-=i[e].length2-i[e].length1;else{let d;if(c[e]=!0,s=o-t,d=-1===a?r.substring(o,o+n.length):r.substring(o,a+32),n===d)r=r.substring(0,o)+e5(i[e].diffs)+r.substring(o+n.length);else{let t=eX(n,d,{checkLines:!1});if(n.length>32&&function(e){let t=0,n=0,r=0;for(let i=0;i<e.length;i++){let o=e[i][0],l=e[i][1];switch(o){case eq:n+=l.length;break;case eH:r+=l.length;break;case eZ:t+=Math.max(n,r),n=0,r=0;break;default:throw Error("Unknown diff operation.")}}return t+Math.max(n,r)}(t)/n.length>l)c[e]=!1;else{t=eF(t);let n=0,l=0;for(let a=0;a<i[e].diffs.length;a++){let s=i[e].diffs[a];s[0]!==eZ&&(l=te(t,n)),s[0]===eq?r=r.substring(0,o+l)+s[1]+r.substring(o+l):s[0]===eH&&(r=r.substring(0,o+l)+r.substring(o+te(t,n+s[1].length))),s[0]!==eH&&(n+=s[1].length)}}}}}return[r=r.substring(a.length,r.length-a.length),c]}(tn(t.value),r.text,{allowExceedingIndices:!0}),l=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,n=e.map(e=>eP(e)),r=!1,i=[],o=0,l=null,a=0,s=!1,c=!1,d=!1,h=!1;for(;a<n.length;)n[a][0]===eZ?(n[a][1].length<t&&(d||h)?(i[o++]=a,s=d,c=h,l=n[a][1]):(o=0,l=null),d=!1,h=!1):(n[a][0]===eH?h=!0:d=!0,l&&(s&&c&&d&&h||l.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)=>
61e+(t?1:0),0)}(s,c,d,h))&&(n.splice(i[o-1],0,[eH,l]),n[i[o-1]+1][0]=eq,o--,l=null,s&&c?(d=!0,h=!0,o=0):(a=--o>0?i[o-1]:-1,d=!1,h=!1),r=!0)),a++;return r&&(n=eW(n)),n}(eX(r.text,o),5);tI(e,"before");let a=0;for(let[t,n]of l)t===eq?(e.apply({type:"insert_text",path:i,offset:a,text:n}),a+=n.length):t===eH?e.apply({type:"remove_text",path:i,offset:a,text:n}):t===eZ&&(a+=n.length);return tI(e,"after"),!0}(e,t);break;default:tP("Unhandled patch",t.type)}}catch(e){console.error(e)}return r};return function(l){es.set(l,!1),eD.set(l,!0),i=[...l.children];let{apply:a}=l,s=[],c=()=>{if(0===s.length)return;let e=s;s=[];let t=!1;eC(l,()=>{p.ML.withoutNormalizing(l,()=>{e$(l,()=>{tb(l,()=>{e.forEach(e=>{tz.enabled&&tz(`Handling remote patch ${JSON.stringify(e)}`),t=o(l,e)})})})}),t&&(l.normalize(),l.onChange())})},d=({patches:e})=>{let t=e.filter(e=>"local"!==e.origin);0!==t.length&&(s=s.concat(t),c())};return r.push(()=>{tz("Subscribing to remote patches");let t=e.on("patches",d);return()=>{tz("Unsubscribing to remote patches"),t.unsubscribe()}}),l.apply=r=>{if(e.getSnapshot().context.readOnly)return a(r),l;let o=[],s=ea(i=l.children,n);a(r);let c=ea(l.children,n);if(!eD.get(l))return l;switch(s&&!c&&"set_selection"!==r.type&&o.push((0,_.$T)(i,"before",[0])),r.type){case"insert_text":o=[...o,...t.insertTextPatch(l,r,i)];break;case"remove_text":o=[...o,...t.removeTextPatch(l,r,i)];break;case"remove_node":o=[...o,...t.removeNodePatch(l,r,i)];break;case"split_node":o=[...o,...t.splitNodePatch(l,r,i)];break;case"insert_node":o=[...o,...t.insertNodePatch(l,r,i)];break;case"set_node":o=[...o,...t.setNodePatch(l,r,i)];break;case"merge_node":o=[...o,...t.mergeNodePatch(l,r,i)];break;case"move_node":o=[...o,...t.moveNodePatch(l,r,i)]}return!s&&c&&["merge_node","set_node","remove_text","remove_node"].includes(r.type)&&(o=[...o,(0,_.zN)([])],e.send({type:"unset",previousValue:el(i,n.block.name,ey.get(l))})),s&&o.length>0&&(o=[(0,_.Cb)([],[]),...o]),o.length>0&&o.forEach(t=>{e.send({type:"patch",patch:{...t,origin:"local"}})}),l},l}}({editorActor:l,patchFunctions:s,schemaTypes:a,subscriptions:t.subscriptions}),u=function(e){let{editorActor:t,blockSchemaType:n}=e;return r=>{let i=el(r.children,n.name),o=tu(r);e.subscriptions.push(()=>{ts("Subscribing to patches");let e=t.on("patches",({patches:e,snapshot:t})=>{let n=!1;e.forEach(e=>{if(!n&&"local"!==e.origin&&o){if("unset"===e.type&&0===e.path.length){ts("Someone else cleared the content, resetting undo/redo history"),r.history={undos:[],redos:[]},o.splice(0,o.length),td.set(r,!0),n=!0;return}o.push({patch:e,time:new Date,snapshot:t,previousSnapshot:i})}}),i=t});return()=>{ts("Unsubscribing to patches"),e.unsubscribe()}}),r.history={undos:[],redos:[]};let{apply:l}=r;return r.apply=e=>{if(t.getSnapshot().context.readOnly||eL(r)||tl(r)||ta(r)){l(e);return}let{operations:n,history:i}=r,{undos:o}=i,a=o[o.length-1],s=a&&a.operations&&a.operations[a.operations.length-1],c=tg(e,s),d=tp(r),h=!0;if(d){if(a?0===n.length&&(h=tm(e,s)||c):h=!1,a&&h)a.operations.push(e);else{let t={operations:[...null===r.selection?[]:[{type:"set_selection",properties:{...r.selection},newProperties:{...r.selection}}],e],timestamp:new Date};o.push(t),ts("Created new undo step",a)}for(;o.length>1e3;)o.shift();tk(e)&&(i.redos=[])}l(e)},r.undo=()=>{if(t.getSnapshot().context.readOnly)return;let{undos:e}=r.history;if(e.length>0){let t=e[e.length-1];if(ts("Undoing",t),t.operations.length>0){let e=o.filter(e=>e.time>=t.timestamp),n=t.operations;e.forEach(e=>{n=w(n.map(t=>tf(r,e.patch,t,e.snapshot,e.previousSnapshot)))});let i=n.map(p.OX.inverse).reverse();try{p.ML.withoutNormalizing(r,()=>{(function(e,t){let n=tl(e);ti.set(e,!0),t(),ti.set(e,n)})(r,()=>{tb(r,()=>{i.forEach(e=>{r.apply(e)})})})}),r.normalize(),r.onChange()}catch(e){ts("Could not perform undo step",e),o.splice(0,o.length),p.YR.deselect(r),r.history={undos:[],redos:[]},td.set(r,!0),ti.set(r,!1),r.onChange();return}r.history.redos.push(t),r.history.undos.pop()}}},r.redo=()=>{if(t.getSnapshot().context.readOnly)return;let{redos:e}=r.history;if(e.length>0){let t=e[e.length-1];if(ts("Redoing",t),t.operations.length>0){let e=o.filter(e=>e.time>
61=t.timestamp),n=t.operations;e.forEach(e=>{n=w(n.map(t=>tf(r,e.patch,t,e.snapshot,e.previousSnapshot)))});try{p.ML.withoutNormalizing(r,()=>{(function(e,t){let n=ta(e);to.set(e,!0),t(),to.set(e,n)})(r,()=>{tb(r,()=>{n.forEach(e=>{r.apply(e)})})})}),r.normalize(),r.onChange()}catch(e){ts("Could not perform redo step",e),o.splice(0,o.length),p.YR.deselect(r),r.history={undos:[],redos:[]},td.set(r,!0),to.set(r,!1),r.onChange();return}r.history.undos.push(t),r.history.redos.pop()}}},r}}({editorActor:l,blockSchemaType:a.block,subscriptions:t.subscriptions}),f=function(e,t){let n=t.styles[0].value;return function(t){let{normalizeNode:r}=t;return t.normalizeNode=i=>{let[,o]=i;for(let r of t.operations)if("split_node"===r.type&&1===r.path.length&&t.isTextBlock(r.properties)&&r.properties.style!==n&&r.path[0]===o[0]&&!p.y$.equals(o,r.path)){let[i]=p.ML.node(t,[r.path[0]+1,0]);if(p.xv.isText(i)&&""===i.text){tK(`Normalizing split node to ${n} style`,r),e.send({type:"normalizing"}),p.YR.setNodes(t,{style:n},{at:[r.path[0]+1],voids:!1}),e.send({type:"done normalizing"});return}}r(i)},t.pteHasBlockStyle=e=>!!t.selection&&[...p.ML.nodes(t,{at:t.selection,match:n=>t.isTextBlock(n)&&n.style===e})].length>0,t.pteToggleBlockStyle=e=>{t.selection&&([...p.ML.nodes(t,{at:t.selection,match:e=>t.isTextBlock(e)})].forEach(([r,i])=>{t.isTextBlock(r)&&r.style===e?(tK(`Unsetting block style '${e}'`),p.YR.setNodes(t,{...r,style:n},{at:i})):(e?tK(`Setting style '${e}'`):tK("Setting default style",n),p.YR.setNodes(t,{...r,style:e||n},{at:i}))}),t.onChange())},t}}(l,a),y=function({editorActor:e,schemaTypes:t}){return function(n){return n.pteExpandToWord=()=>{let{selection:e}=n;if(e&&!p.e6.isExpanded(e)){let[t]=p.ML.node(n,e.focus,{depth:2});if(!t||!p.xv.isText(t)||0===t.text.length){t1("pteExpandToWord: Can't expand to word here");return}let{focus:r}=e,i=r.offset,o=t.text.slice(0,i),l=t.text.slice(i,-1),a=e=>e.match(/\s/g),s=o.split("").reverse().findIndex(e=>a(e)),c=s>-1?o.length-s:0,d=l.split("").findIndex(e=>a(e)),h=o.length+(d>-1?d:l.length+1);if(!(c===h||Number.isNaN(c)||Number.isNaN(h))){t1("pteExpandToWord: Expanding to focused word"),p.YR.setSelection(n,{anchor:{...e.anchor,offset:c},focus:{...e.focus,offset:h}});return}t1("pteExpandToWord: Can't expand to word here")}},n.pteCreateTextBlock=n=>eo([{_type:t.block.name,_key:e.getSnapshot().context.keyGenerator(),style:t.styles[0].value||"normal",...n.listItem?{listItem:n.listItem}:{},...n.level?{level:n.level}:{},markDefs:[],children:[{_type:"span",_key:e.getSnapshot().context.keyGenerator(),text:"",marks:n.decorators.filter(e=>t.decorators.find(({value:t})=>t===e))}]}],{schemaTypes:t})[0],n}}({editorActor:l,schemaTypes:a}),m=(o=null,function(e){let t=()=>{if(o!==e.selection){let t=null;if(e.selection){let n=em.get(e.selection);n?t=n:(t=ee(e.children,e.selection,a),em.set(e.selection,t))}tQ&&tX(`Emitting selection ${JSON.stringify(t||null)} (${JSON.stringify(e.selection)})`),t?l.send({type:"selection",selection:t}):l.send({type:"selection",selection:null})}o=e.selection},{onChange:n}=e;return e.onChange=()=>{let r=e.operations.length>0;n(),r&&t()},e});return(n=t.subscriptions,function(e){return void 0!==l.getSnapshot().context.maxBlocks||(n.push(()=>{let t=l.on("*",t=>{switch(t.type){case"annotation.add":l.send({type:"behavior event",behaviorEvent:{type:"annotation.add",annotation:t.annotation},editor:e});break;case"annotation.remove":l.send({type:"behavior event",behaviorEvent:{type:"annotation.remove",annotation:t.annotation},editor:e});break;case"annotation.toggle":l.send({type:"behavior event",behaviorEvent:{type:"annotation.toggle",annotation:t.annotation},editor:e});break;case"focus":l.send({type:"behavior event",behaviorEvent:{type:"focus"},editor:e})}});return()=>{t.unsubscribe()}}),e.addMark=t=>{l.send({type:"behavior event",behaviorEvent:{type:"decorator.add",decorator:t},editor:e})},e.removeMark=t=>{l.send({type:"behavior event",behaviorEvent:{type:"decorator.remove",decorator:t},editor:e})},e.deleteBackward=t=>{l.send({type:"behavior event",behaviorEvent:{type:"delete backward",unit:t},editor:e})},e.deleteForward=t=>{l.send({type:"behavior event",behaviorEvent:{type:"delete forward",unit:t},editor:e})},e.insertBreak=()=>{l.send({type:"behavior event",behaviorEvent:{type:"insert break"},editor:e})},e.insertSoftBreak=()=>{l.send({type:"behavior event",behaviorEvent:{type:"insert soft break"},editor:e})},e.insertText=(t,n)=>{l.send({type:"behavior event",behaviorEvent:{type:"insert text",text:t,options:n},editor:e})}),e})(d(function(e){let{apply:t,normalizeNode:n}=e;return e.apply=n=>{if(eL(e)||tl(e)||ta(e)){t(n);return}
61if("split_node"===n.type){t({...n,properties:{...n.properties,_key:l.getSnapshot().context.keyGenerator()}});return}if("insert_node"===n.type&&!p.ML.isEditor(n.node)){t({...n,node:{...n.node,_key:l.getSnapshot().context.keyGenerator()}});return}t(n)},e.normalizeNode=t=>{let[r,i]=t;if(p.W_.isElement(r)&&r._type===a.block.name){if(!r._key){l.send({type:"normalizing"}),p.YR.setNodes(e,{_key:l.getSnapshot().context.keyGenerator()},{at:i}),l.send({type:"done normalizing"});return}for(let[t,n]of p.NB.children(e,i))if(!t._key){l.send({type:"normalizing"}),p.YR.setNodes(e,{_key:l.getSnapshot().context.keyGenerator()},{at:n}),l.send({type:"done normalizing"});return}}n(t)},e}(function(e){let{apply:t,normalizeNode:n}=e,r=a.decorators.map(e=>e.value);return e.normalizeNode=t=>{let[r,i]=t;if(e.isTextBlock(r))for(let[t,n]of p.NB.children(e,i)){let i=r.children[n[1]+1];if(e.isTextSpan(t)&&e.isTextSpan(i)&&t.marks?.every(e=>i.marks?.includes(e))&&i.marks?.every(e=>t.marks?.includes(e))){tV("Merging spans",JSON.stringify(t,null,2),JSON.stringify(i,null,2)),l.send({type:"normalizing"}),p.YR.mergeNodes(e,{at:[n[0],n[1]+1],voids:!0}),l.send({type:"done normalizing"});return}}if(e.isTextBlock(r)&&!Array.isArray(r.markDefs)){tV("Adding .markDefs to block node"),l.send({type:"normalizing"}),p.YR.setNodes(e,{markDefs:[]},{at:i}),l.send({type:"done normalizing"});return}if(e.isTextSpan(r)&&!Array.isArray(r.marks)){tV("Adding .marks to span node"),l.send({type:"normalizing"}),p.YR.setNodes(e,{marks:[]},{at:i}),l.send({type:"done normalizing"});return}if(e.isTextSpan(r)){let t=p.y$.parent(i),[n]=p.ML.node(e,t),o=a.decorators.map(e=>e.value),s=r.marks?.filter(e=>!o.includes(e));if(e.isTextBlock(n)&&""===r.text&&s&&s.length>0){tV("Removing annotations from empty span node"),l.send({type:"normalizing"}),p.YR.setNodes(e,{marks:r.marks?.filter(e=>o.includes(e))},{at:i}),l.send({type:"done normalizing"});return}}if(e.isTextBlock(r)){let t=a.decorators.map(e=>e.value);for(let[n,o]of p.NB.children(e,i))if(e.isTextSpan(n)){let i=n.marks??[],a=i.filter(e=>!t.includes(e)&&!r.markDefs?.find(t=>t._key===e));if(a.length>0){tV("Removing orphaned annotations from span node"),l.send({type:"normalizing"}),p.YR.setNodes(e,{marks:i.filter(e=>!a.includes(e))},{at:o}),l.send({type:"done normalizing"});return}}}if(e.isTextSpan(r)){let t=p.y$.parent(i),[n]=p.ML.node(e,t);if(e.isTextBlock(n)){let t=a.decorators.map(e=>e.value),o=r.marks??[],s=o.filter(e=>!t.includes(e)&&!n.markDefs?.find(t=>t._key===e));if(s.length>0){tV("Removing orphaned annotations from span node"),l.send({type:"normalizing"}),p.YR.setNodes(e,{marks:o.filter(e=>!s.includes(e))},{at:i}),l.send({type:"done normalizing"});return}}}if(e.isTextBlock(r)){let t=r.markDefs??[],n=new Set,o=[];for(let e of t)n.has(e._key)||(n.add(e._key),o.push(e));if(t.length!==o.length){tV("Removing duplicate markDefs"),l.send({type:"normalizing"}),p.YR.setNodes(e,{markDefs:o},{at:i}),l.send({type:"done normalizing"});return}}if(e.isTextBlock(r)&&!e.operations.some(e=>"merge_node"===e.type&&"markDefs"in e.properties&&1===e.path.length)){let t=(r.markDefs||[]).filter(e=>r.children.find(t=>p.xv.isText(t)&&Array.isArray(t.marks)&&t.marks.includes(e._key)));if(r.markDefs&&!c(t,r.markDefs)){tV("Removing markDef not in use"),l.send({type:"normalizing"}),p.YR.setNodes(e,{markDefs:t},{at:i}),l.send({type:"done normalizing"});return}}n(t)},e.apply=n=>{if(eL(e)||tl(e)||ta(e)){t(n);return}if("set_selection"===n.type&&p.ML.marks(e)&&n.properties&&n.newProperties&&n.properties.anchor&&n.properties.focus&&n.newProperties.anchor&&n.newProperties.focus){let t=p.e6.isCollapsed({anchor:n.properties.anchor,focus:n.properties.focus}),r=p.e6.isCollapsed({anchor:n.newProperties.anchor,focus:n.newProperties.focus});if(t&&r){let t=Array.from(p.ML.nodes(e,{mode:"lowest",at:n.properties.focus,match:t=>e.isTextSpan(t),voids:!1}))[0]?.[0],r=Array.from(p.ML.nodes(e,{mode:"lowest",at:n.newProperties.focus,match:t=>e.isTextSpan(t),voids:!1}))[0]?.[0],i=t&&r&&n.newProperties.focus.path[0]===n.properties.focus.path[0]&&n.newProperties.focus.path[1]===n.properties.focus.path[1]+1&&t.text.length===n.properties.focus.offset&&0===n.newProperties.focus.offset,o=t&&r&&n.newProperties.focus.path[0]===n.properties.focus.path[0]&&n.newProperties.focus.path[1]===n.properties.focus.path[1]-1&&0===n.properties.focus.offset&&r.text.length===n.newProperties.focus.offset;if(i||o)return}}if("insert_node"===n.type){let{selection:t}=e;if(t){let[i,o]=p.ML.node(e,t,{depth:1}),l=tW({editor:e,blockPath:o,spanPath:n.path}
61),a=l?l.marks?.filter(e=>!r.includes(e)):[],s=tJ({editor:e,blockPath:o,spanPath:[n.path[0],n.path[1]-1]}),c=s?s.marks?.filter(e=>!r.includes(e)):[],d=a?.filter(e=>!c?.includes(e))??[],h=d.length>0;if(h&&tF(n.node)&&n.node.marks?.some(e=>d.includes(e))){p.YR.insertNodes(e,{...n.node,marks:n.node.marks?.filter(e=>!d.includes(e))??[]});return}let u=c?.filter(e=>!a?.includes(e))??[],f=u.length>0;if(f&&tF(n.node)&&n.node.marks?.some(e=>u.includes(e))){p.YR.insertNodes(e,{...n.node,marks:n.node.marks?.filter(e=>!u.includes(e))??[]});return}let y=s?.marks?.filter(e=>r.includes(e))??[];if(y.length>0&&h&&!f&&tF(n.node)&&n.node.marks?.length===0){p.YR.insertNodes(e,{...n.node,marks:y});return}}}if("insert_text"===n.type){let{selection:i}=e,o=!!i&&p.e6.isCollapsed(i);if(i&&o){let[o,a]=p.ML.node(e,i,{depth:1}),[s,c]=Array.from(p.ML.nodes(e,{mode:"lowest",at:i.focus,match:t=>e.isTextSpan(t),voids:!1}))[0]??[void 0,void 0],d=s.marks??[],h=d.filter(e=>r.includes(e)),u=d.length>h.length,f=0===s.text.length,y=0===i.anchor.offset,m=i.anchor.offset===s.text.length,g=tW({editor:e,blockPath:a,spanPath:c}),k=tJ({editor:e,blockPath:a,spanPath:c}),b=k?.marks?.filter(e=>!r.includes(e))??[],v=d.filter(e=>!r.includes(e)),x=!!g&&g.marks?.some(e=>
61!r.includes(e)),_=!!g&&g.marks?.filter(e=>!r.includes(e)).every(e=>d.includes(e)),w=!!g&&g.marks?.some(e=>!r.includes(e)&&d.includes(e)),N=!!g&&g.marks?.every(e=>d.includes(e)),S=v.some(e=>b?.includes(e));if(u&&!f){if(y){if(N||_){p.YR.insertNodes(e,{_type:"span",_key:l.getSnapshot().context.keyGenerator(),text:n.text,marks:g?.marks??[]});return}if(w){t(n);return}if(!g){p.YR.insertNodes(e,{_type:"span",_key:l.getSnapshot().context.keyGenerator(),text:n.text,marks:[]});return}}if(m){if(k&&S&&b.length<v.length||!S){p.YR.insertNodes(e,{_type:"span",_key:l.getSnapshot().context.keyGenerator(),text:n.text,marks:k?.marks??[]});return}if(!k){p.YR.insertNodes(e,{_type:"span",_key:l.getSnapshot().context.keyGenerator(),text:n.text,marks:[]});return}}}if(y&&!f&&g){p.YR.insertNodes(e,{_type:"span",_key:l.getSnapshot().context.keyGenerator(),text:n.text,marks:x?[]:(g.marks??[]).filter(e=>r.includes(e))});return}}}if("remove_text"===n.type){let{selection:o}=e;if(o&&p.e6.isExpanded(o)){var i;let[l,a]=p.ML.node(e,o,{depth:1}),[s,c]=Array.from(p.ML.nodes(e,{mode:"lowest",at:{path:n.path,offset:n.offset},match:t=>e.isTextSpan(t),voids:!1}))[0]??[void 0,void 0];if(s&&l&&"string"==typeof(i=l)._type&&"@"!==i._type[0]&&(!("markDefs"in i)||!i.markDefs||Array.isArray(i.markDefs)&&i.markDefs.every(e=>"string"==typeof e._key))&&"children"in i&&Array.isArray(i.children)&&i.children.every(e=>"object"==typeof e&&"_type"in e)){let i=l.markDefs??[],o=s.marks??[],d=o.some(e=>i.find(t=>t._key===e)),h=n.offset+n.text.length===s.text.length,u=0===n.offset&&h,f=tW({editor:e,blockPath:a,spanPath:c}),y=tJ({editor:e,blockPath:a,spanPath:c}),m=!!f&&f.marks?.some(e=>!r.includes(e)&&o.includes(e)),g=!!y&&y.marks?.some(e=>!r.includes(e)&&o.includes(e));if(d&&u&&!m&&!g){let i=(({...p.ML.marks(e)||{}}).marks||[]).filter(e=>r.includes(e));p.ML.withoutNormalizing(e,()=>{t(n),p.YR.setNodes(e,{marks:i},{at:n.path})}),e.onChange();return}}}}if("merge_node"===n.type&&1===n.path.length&&"markDefs"in n.properties&&n.properties._type===a.block.name&&Array.isArray(n.properties.markDefs)&&n.properties.markDefs.length>0&&n.path[0]-1>=0){let[r,i]=p.ML.node(e,[n.path[0]-1]);if(e.isTextBlock(r)){let o=g([...Array.isArray(r.markDefs)&&r.markDefs||[],...n.properties.markDefs]);tV("Copying markDefs over to merged block",n),p.YR.setNodes(e,{markDefs:o},{at:i,voids:!1}),t(n);return}}t(n)},e}(f(((r=function(e){let{apply:t}=e;return e.apply=n=>{if(l.getSnapshot().context.readOnly||eL(e)||tl(e)||ta(e)){t(n);return}if("remove_node"===n.type){let t=n.node;if(0===n.path[0]&&p.ML.isVoid(e,t)){let t=p.y$.next(n.path);e.children[t[0]]||(tG("Adding placeholder block"),p.ML.insertNode(e,e.pteCreateTextBlock({decorators:[]})))}}t(n)},e}(y(function(e){let{apply:t}=e;return e.apply=n=>{if(l.getSnapshot().context.readOnly||eL(e)||tl(e)||ta(e)){t(n);return}let r=l.getSnapshot().context.maxBlocks??-1;r>0&&e.children.length>=r&&("insert_node"===n.type||"split_node"===n.type)&&1===n.path.length||t(n)},e}(u(h(m(e))))))).pteToggleListItem=e=>{r.pteHasListStyle(e)?(tU(`Remove list item '${e}'`),r.pteUnsetListItem(e)):(tU(`Add list item '${e}'`),r.pteSetListItem(e))},r.pteUnsetListItem=e=>{r.selection&&[...p.ML.nodes(r,{at:r.selection,match:e=>p.W_.isElement(e)&&e._type===a.block.name})].forEach(([t,n])=>{if(r.isListBlock(t)){let{listItem:i,level:o,...l}=t,a={...l,listItem:void 0,level:void 0};tU(`Unsetting list '${e}'`),p.YR.setNodes(r,a,{at:n})}})},r.pteSetListItem=e=>{r.selection&&[...p.ML.nodes(r,{at:r.selection,match:e=>r.isTextBlock(e)})].forEach(([t,n])=>{tU(`Setting list '${e}'`),p.YR.setNodes(r,{...t,level:1,listItem:e||a.lists[0]&&a.lists[0].value},{at:n})})},r.pteEndList=()=>{if(!r.selection)return!1;let e=[...p.ML.nodes(r,{at:r.selection,match:e=>p.W_.isElement(e)&&r.isListBlock(e)&&1===e.children.length&&p.xv.isText(e.children[0])&&""===e.children[0].text})];return 0!==e.length&&(e.forEach(([e,t])=>{p.W_.isElement(e)&&(tU("Unset list"),p.YR.setNodes(r,{...e,level:void 0,listItem:void 0},{at:t}))}),!0)},r.pteIncrementBlockLevels=e=>{if(!r.selection)return!1;let t=[...p.ML.nodes(r,{at:r.selection,match:e=>!!r.isListBlock(e)})];return 0!==t.length&&(t.forEach(([t,n])=>{if(r.isListBlock(t)){let i=t.level||1;e?tU("Decrementing list level",Math.min(10,Math.max(1,--i))):tU("Incrementing list level",Math.min(10,Math.max(1,++i))),p.YR.setNodes(r,{level:Math.min(10,Math.max(1,i))},{at:n})}}),!0)},r.pteHasListStyle=e=>{if(!r.selection)return!1;let t=[...p.ML.nodes(r,{at:r.selection,match:e=>r.isTextBlock(e)})];return t.length>0&&t.every(([t])=>r.isListBlock(t)&&t.listItem===e)},r))))))},t3=Z("component:PortableTextEditor:SlateContainer"),t8=new WeakMap;function t4({block:e,placement:t,editor:n,schema:r}){if(n.selection){let[i,o]=Array.from(p.ML.nodes(n,{at:n.selection.focus.path.slice(0,1),match:e=>!p.ML.isEditor(e)}))[0]??[void 0,void 0];if("after"===t){let t=[o[0]+1];p.YR.insertNodes(n,e,{at:t}
61),p.YR.select(n,{anchor:{path:[t[0],0],offset:0},focus:{path:[t[0],0],offset:0}})}else"before"===t?p.YR.insertNodes(n,e,{at:o}):p.ML.insertNode(n,e);i&&ea([i],r)&&p.YR.removeNodes(n,{at:o})}else{let t=Array.from(p.ML.nodes(n,{match:e=>!p.ML.isEditor(e),at:[],reverse:!0}))[0];p.ML.insertNode(n,e),t&&ea([t[0]],r)&&p.YR.removeNodes(n,{at:t[1]})}}let t6=({context:e,action:t})=>{t4({block:eo([{_key:e.keyGenerator(),_type:t.blockObject.name,...t.blockObject.value?t.blockObject.value:{}}],{schemaTypes:e.schema})[0],placement:t.placement,editor:t.editor,schema:e.schema})},t5=Z("API:editable");function t9({editor:e,annotation:t}){if(!e.selection||e.selection.focus.path.length<2)return!1;try{let n=[...p.ML.nodes(e,{at:e.selection,match:e=>p.xv.isText(e)})];if(0===n.length||n.some(([e])=>!(0,i.NG)(e)||!e.marks||e.marks?.length===0))return!1;let r=n.reduce((t,[,n])=>{let[r]=p.ML.node(e,n,{depth:1});return e.isTextBlock(r)&&r.markDefs?[...t,...r.markDefs]:t},[]);return n.every(([e])=>!!(0,i.NG)(e)&&e.marks?.map(e=>r.find(t=>t?._key===e)?._type)?.includes(t.name))}catch{return!1}}let t7=({context:e,action:t})=>{let n;let r=t.editor,{selection:i}=r;if(i&&(p.e6.isCollapsed(i)&&(r.pteExpandToWord(),r.onChange()),r.selection)){let i,o;let l=[];if(!r.selection)return;for(let[n,a]of p.ML.nodes(r,{at:r.selection,match:e=>r.isTextBlock(e),reverse:p.e6.isBackward(r.selection)})){if(0===n.children.length||1===n.children.length&&""===n.children[0].text)continue;let s=e.keyGenerator(),c=n.markDefs??[];for(let[e,d]of(void 0===c.find(e=>e._type===t.annotation.name&&e._key===s)&&(p.YR.setNodes(r,{markDefs:[...c,{_type:t.annotation.name,_key:s,...t.annotation.value}]},{at:a}),o=[{_key:n._key},"markDefs",{_key:s}],p.e6.isBackward(r.selection)?l.unshift(o):l.push(o)),p.YR.setNodes(r,{},{match:p.xv.isText,split:!0}),p.NB.children(r,a))){if(!r.isTextSpan(e)||!p.e6.includes(r.selection,d))continue;let o=e.marks??[],l=o.filter(e=>c.some(n=>n._key===e&&n._type===t.annotation.name));p.YR.setNodes(r,{marks:[...o.filter(e=>!l.includes(e)),s]},{at:d}),i=[{_key:n._key},"children",{_key:e._key}]}}o&&i&&(n={markDefPath:o,markDefPaths:l,spanPath:i})}return n},ne=({action:e})=>{let t=e.editor;if(t5("Removing annotation",e.annotation.name),t.selection){if(p.e6.isCollapsed(t.selection)){let[n,r]=p.ML.node(t,t.selection,{depth:1});if(!t.isTextBlock(n))return;let i=(n.markDefs??[]).filter(t=>t._type===e.annotation.name),[o,l]=p.ML.node(t,t.selection,{depth:2});if(!t.isTextSpan(o))return;let a=o.marks?.find(e=>i.some(t=>t._key===e));if(!a)return;let s=[];for(let[e,n]of p.NB.children(t,r,{reverse:!0}))if(t.isTextSpan(e)&&p.y$.isBefore(n,l)){if(e.marks?.includes(a))s.push([e,n]);else break}let c=[];for(let[e,n]of p.NB.children(t,r))if(t.isTextSpan(e)&&p.y$.isAfter(n,l)){if(e.marks?.includes(a))c.push([e,n]);else break}for(let[e,n]of[...s,[o,l],...c])p.YR.setNodes(t,{marks:e.marks?.filter(e=>e!==a)},{at:n})}else for(let[n,r]of(p.YR.setNodes(t,{},{match:e=>t.isTextSpan(e),split:!0,hanging:!0}),p.ML.nodes(t,{at:t.selection,match:e=>t.isTextBlock(e)})))for(let[i,o]of p.NB.children(t,r)){if(!t.isTextSpan(i)||!p.e6.includes(t.selection,o))continue;let r=n.markDefs??[],l=i.marks??[],a=l.filter(t=>r.find(e=>e._key===t)?._type!==e.annotation.name);a.length!==l.length&&p.YR.setNodes(t,{marks:a},{at:o})}}},nt=({context:e,action:t})=>{let n=e.keyGenerator,r=e.schema,i=t.editor;if(!i.selection)return;let[o]=Array.from(p.ML.nodes(i,{mode:"lowest",at:i.selection.focus,match:e=>i.isTextSpan(e),voids:!1}))[0]??[void 0],l=o?.marks?.filter(e=>r.decorators.some(t=>
61t.value===e))??[],a=o?.marks?.filter(e=>!r.decorators.some(t=>t.value===e))??[],s=i.selection.anchor.path.slice(0,1),d=i.selection.focus.path.slice(0,1),h=p.NB.descendant(i,d);if(i.isTextBlock(h)){let[e,t]=p.e6.edges(i.selection),o=h.children[h.children.length-1],u=c(e,{path:[...d,h.children.length-1],offset:i.isTextSpan(o)?o.text.length:0}),f=c(t,{path:[...d,0],offset:0});if(u&&p.e6.isCollapsed(i.selection)){p.ML.insertNode(i,i.pteCreateTextBlock({decorators:[],listItem:h.listItem,level:h.level}));return}if(f&&p.e6.isCollapsed(i.selection)){p.ML.insertNode(i,i.pteCreateTextBlock({decorators:0===a.length?l:[],listItem:h.listItem,level:h.level}));let[e]=p.y$.next(d);p.YR.select(i,{anchor:{path:[e,0],offset:0},focus:{path:[e,0],offset:0}});return}let y=s[0]!==d[0];if(!f&&!u&&!y){p.ML.withoutNormalizing(i,()=>{if(!i.selection)return;p.YR.splitNodes(i,{at:i.selection});let[e,t]=p.ML.node(i,p.y$.next(d),{depth:1});if(p.YR.setSelection(i,{anchor:{path:[...t,0],offset:0},focus:{path:[...t,0],offset:0}}),i.isTextBlock(e)&&e.markDefs&&e.markDefs.length>0){let o=new Map,l=Array.from(p.NB.children(i,d)).map(e=>e[0]).filter(e=>i.isTextSpan(e));for(let[e,a]of p.NB.children(i,t)){if(!i.isTextSpan(e))continue;let t=e.marks??[];for(let e of t)r.decorators.some(t=>t.value===e)||l.some(t=>t.marks?.includes(e))&&!o.has(e)&&o.set(e,n());let s=t.map(e=>o.get(e)??e);c(t,s)||p.YR.setNodes(i,{marks:s},{at:a})}let a=e.markDefs.map(e=>({...e,_key:o.get(e._key)??e._key}));c(e.markDefs,a)||p.YR.setNodes(i,{markDefs:a},{at:t,match:e=>i.isTextBlock(e)})}}),i.onChange();return}}p.YR.splitNodes(i,{always:!0})},nn={"annotation.add":t7,"annotation.remove":ne,"annotation.toggle":({context:e,action:t})=>{if(!t9({editor:t.editor,annotation:{name:t.annotation.name}}))return t7({context:e,action:{type:"annotation.add",annotation:t.annotation,editor:t.editor}});ne({context:e,action:{type:"annotation.remove",annotation:t.annotation,editor:t.editor}})},"decorator.add":tH,"decorator.remove":tq,"decorator.toggle":({context:e,action:t})=>{tZ({editor:t.editor,decorator:t.decorator})?tq({context:e,action:{type:"decorator.remove",editor:t.editor,decorator:t.decorator}}):tH({context:e,action:{type:"decorator.add",editor:t.editor,decorator:t.decorator}})},focus:({action:e})=>{u.F3.focus(e.editor)},"set block":({action:e})=>{for(let t of e.paths){let n=et({anchor:{path:t,offset:0},focus:{path:t,offset:0}},e.editor);p.YR.setNodes(e.editor,{...e.style?{style:e.style}:{},...e.listItem?{listItem:e.listItem}:{},...e.level?{level:e.level}:{}},{at:n})}},"unset block":({action:e})=>{for(let t of e.paths){let n=et({anchor:{path:t,offset:0},focus:{path:t,offset:0}},e.editor);p.YR.unsetNodes(e.editor,e.props,{at:n})}},"delete backward":({action:e})=>{(0,p.j)(e.editor,e.unit)},"delete forward":({action:e})=>{(0,p.Kb)(e.editor,e.unit)},"delete block":({action:e})=>{let t=et({anchor:{path:e.blockPath,offset:0},focus:{path:e.blockPath,offset:0}},e.editor);if(!t){console.error("Unable to find Slate range from selection points");return}p.YR.removeNodes(e.editor,{at:t})},"delete text":({context:e,action:t})=>{let n=el(t.editor.children,e.schema.block.name,ey.get(t.editor)),r=V({value:n,blockOffset:t.anchor}),i=V({value:n,blockOffset:t.focus});if(!r||!i){console.error("Unable to find anchor or focus selection point");return}let o=et({anchor:r,focus:i},t.editor);if(!o){console.error("Unable to find Slate range from selection points");return}p.YR.delete(t.editor,{at:o})},"insert block object":t6,"insert break":nt,"insert soft break":({context:e,action:t})=>{nt({context:e,action:{...t,type:"insert break"}})},"insert span":({context:e,action:t})=>{if(!t.editor.selection){console.error("Unable to perform action without selection",t);return}let[n,r]=Array.from(p.ML.nodes(t.editor,{at:t.editor.selection.focus.path,match:e=>t.editor.isTextBlock(e)}))[0]??[void 0,void 0];if(!n||!r){console.error("Unable to perform action without focus block",t);return}let i=n.markDefs??[],o=t.annotations?t.annotations.map(t=>({_type:t.name,_key:e.keyGenerator(),...t.value})):void 0;o&&o.length>0&&p.YR.setNodes(t.editor,{markDefs:[...i,...o]}),p.YR.insertNodes(t.editor,{_type:"span",_key:e.keyGenerator(),text:t.text,marks:[...o?.map(e=>e._key)??[],...t.decorators??[]]})},"insert text":({action:e})=>{(0,p.Om)(e.editor,e.text)},"insert text block":({context:e,action:t})=>{t4({block:eo([{_key:e.keyGenerator(),_type:e.schema.block.name,style:e.schema.styles[0].value??"normal",markDefs:[],children:t.textBlock?.children?.map(t=>({...t,_key:e.keyGenerator()}))??[{_type:e.schema.span.name,_key:e.keyGenerator(),text:""}]}],{schemaTypes:e.schema})[0],editor:t.editor,schema:e.schema,placement:t.placement})},effect:({action:e})=>{e.effect()},"move block":({action:e})=>{let t=et({anchor:{path:e.blockPath,offset:0},focus:{path:e.blockPath,offset:0}},e.editor);if(!t){console.error("Unable to find Slate range from selection points");return}let n=et({anchor:{path:e.to,offset:0},focus:{path:e.to,offset:0}},e.editor);if(!n){console.error("Unable to find Slate range from selection points");return}p.YR.moveNodes(e.editor,{at:t,to:n.anchor.path.slice(0,1),mode:"highest"})},select:({action:e})=>{let t=et(e.selection,e.editor);t?p.YR.select(e.editor,t):p.YR.deselect(e.editor)},"select previous block":({action:e})=>
61{if(!e.editor.selection){console.error("Unable to select previous block without a selection");return}let t=e.editor.selection.focus.path.slice(0,1);if(!p.y$.hasPrevious(t)){console.error("There's no previous block to select");return}let n=p.y$.previous(t);p.YR.select(e.editor,n)},"select next block":({action:e})=>{if(!e.editor.selection){console.error("Unable to select next block without a selection");return}let t=[e.editor.selection.focus.path.slice(0,1)[0]+1];p.YR.select(e.editor,t)},reselect:({action:e})=>{let t=e.editor.selection;t&&(p.YR.select(e.editor,{...t}),e.editor.selection={...t})}},nr=(0,E.cY)({types:{context:{},events:{},emitted:{},input:{}},actions:{"assign behaviors":(0,T.a)({behaviors:({event:e})=>((0,E.ZD)(e,"update behaviors"),e.behaviors)}),"assign schema":(0,T.a)({schema:({event:e})=>((0,E.ZD)(e,"update schema"),e.schema)}),"emit patch event":(0,T.e)(({event:e})=>((0,E.ZD)(e,"patch"),e)),"emit mutation event":(0,T.e)(({event:e})=>((0,E.ZD)(e,"mutation"),e)),"defer event":(0,T.a)({pendingEvents:({context:e,event:t})=>((0,E.ZD)(t,["patch","mutation"]),[...e.pendingEvents,t])}),"emit pending events":(0,T.b)(({context:e,enqueue:t})=>{for(let n of e.pendingEvents)t((0,T.e)(n))}),"clear pending events":(0,T.a)({pendingEvents:[]}),"handle behavior event":(0,T.b)(({context:e,event:t,enqueue:n})=>{(0,E.ZD)(t,["behavior event"]);let r={...t.behaviorEvent,editor:t.editor},i=e.behaviors.filter(e=>e.on===t.behaviorEvent.type);if(0===i.length){n.raise({type:"behavior action intends",editor:t.editor,actionIntends:[r]});return}let o=el(t.editor.children,e.schema.block.name,ey.get(t.editor)),l=ee(o,t.editor.selection,e.schema);if(!l){console.warn(`Unable to handle event ${t.type} due to missing selection`),n.raise({type:"behavior action intends",editor:t.editor,actionIntends:[r]});return}let a={schema:e.schema,value:o,selection:l},s=!1;for(let e of i){let r=void 0===e.guard||e.guard({context:a,event:t.behaviorEvent});if(r){for(let i of e.actions.map(e=>e({context:a,event:t.behaviorEvent},r)))s=s||i.length>0&&i.some(e=>"effect"!==e.type),n.raise({type:"behavior action intends",editor:t.editor,actionIntends:i});if(s){t.nativeEvent?.preventDefault();break}}}s||n.raise({type:"behavior action intends",editor:t.editor,actionIntends:[r]})})}}).createMachine({id:"editor",context:({input:e})=>({behaviors:e.behaviors??J,keyGenerator:e.keyGenerator,pendingEvents:[],schema:e.schema,readOnly:e.readOnly??!1,maxBlocks:e.maxBlocks,value:e.value}),on:{"annotation.add":{actions:(0,T.e)(({event:e})=>e),guard:({context:e})=>!e.readOnly},"annotation.remove":{actions:(0,T.e)(({event:e})=>e),guard:({context:e})=>!e.readOnly},"annotation.toggle":{actions:(0,T.e)(({event:e})=>e),guard:({context:e})=>!e.readOnly},focus:{actions:(0,T.e)(({event:e})=>e),guard:({context:e})=>!e.readOnly},ready:{actions:(0,T.e)(({event:e})=>e)},unset:{actions:(0,T.e)(({event:e})=>e)},"value changed":{actions:(0,T.e)(({event:e})=>e)},"invalid value":{actions:(0,T.e)(({event:e})=>e)},error:{actions:(0,T.e)(({event:e})=>e)},selection:{actions:(0,T.e)(({event:e})=>e)},blur:{actions:(0,T.e)(({event:e})=>e)},focused:{actions:(0,T.e)(({event:e})=>e)},loading:{actions:(0,T.e)({type:"loading"})},patches:{actions:(0,T.e)(({event:e})=>e)},"done loading":{actions:(0,T.e)({type:"done loading"})},"update behaviors":{actions:"assign behaviors"},"update schema":{actions:"assign schema"},"update value":{actions:(0,T.a)({value:({event:e})=>e.value})},"toggle readOnly":{actions:[(0,T.a)({readOnly:({context:e})=>!e.readOnly}),(0,T.e)(({context:e})=>({type:"readOnly toggled",readOnly:e.readOnly}))]},"update maxBlocks":{actions:(0,T.a)({maxBlocks:({event:e})=>e.maxBlocks})},"behavior event":{actions:"handle behavior event",guard:({context:e})=>!e.readOnly},"behavior action intends":{actions:[({context:e,event:t})=>{p.ML.withoutNormalizing(t.editor,()=>{for(let n of t.actionIntends)(function({context:e,action:t}){switch(t.type){case"delete block":nn["delete block"]({context:e,action:t});break;case"delete text":nn["delete text"]({context:e,action:t});break;case"insert block object":nn["insert block object"]({context:e,action:t});break;case"insert span":nn["insert span"]({context:e,action:t});break;case"insert text block":nn["insert text block"]({context:e,action:t});break;case"move block":nn["move block"]({context:e,action:t});break;case"set block":nn["set block"]({context:e,action:t});break;case"unset block":nn["unset block"]({context:e,action:t});break;case"effect":nn.effect({context:e,action:t});break;case"select":nn.select({context:e,action:t});break;case"select previous block":nn["select previous block"]({context:e,action:t});break;case"select next block":nn["select next block"]({context:e,action:t});break;case"reselect":nn.reselect({context:e,action:t});break;default:(function({context:e,action:t}){switch(t.type){case"annotation.add":nn["annotation.add"]({context:e,action:t});break;case"annotation.remove":nn["annotation.remove"]({context:e,action:t});break;case"annotation.toggle":nn["annotation.toggle"]({context:e,action:t});break;case"copy":break;case"decorator.add":nn["decorator.add"]({context:e,action:t});break;case"decorator.remove":nn["decorator.remove"]({context:e,action:t});break;case"decorator.toggle":nn["decorator.toggle"]({context:e,action:t});break;case"delete backward":nn["delete backward"]({context:e,action:t});break;case"delete forward":nn["delete forward"]({context:e,action:t});break;case"focus":nn.focus({context:e,action:t});break;case"insert break":nn["insert break"]({context:e,action:t});break;case"insert soft break":nn["insert soft break"]({context:e,action:t});break;case"insert text":nn["insert text"]({context:e,action:t})}})({context:e,action:t})}})({context:e,action:{...n,editor:t.editor}})}),t.editor.onChange()},(0,T.b)(({context:e,event:t,enqueue:n})=>{t.actionIntends.some(e=>"reselect"===e.type)&&n.raise({type:"selection",selection:ee(t.editor.children,t.editor.selection,e.schema)})})]}},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"}}}}}),ni=Z("component:PortableTextEditor");class no extends h.Component{static displayName="PortableTextEditor";change$=new k.x;constructor(e){super(e),e.editor?this.editor=e.editor:this.editor=function(e){let t=(0,A.A)(nr,{input:{behaviors:e.behaviors,keyGenerator:e.keyGenerator??tL,maxBlocks:e.maxBlocks,readOnly:e.readOnly,schema:e.schemaDefinition?function(e){let t=e?.blockObjects?.map(e=>i.fe({type:"object",name:"image"===e.name?"tmp-image":e.name,title:e.title,icon:e.icon,fields:[]}))??[],n=e?.inlineObjects?.map(e=>i.fe({type:"object",name:e.name,title:e.title,icon:e.icon,fields:[]}))??[],r=(0,i.Z2)({type:"array",name:"portable-text",of:[...t.map(e=>({type:e.name})),{type:"block",name:"block",of:n.map(e=>({type:e.name})),marks:{decorators:e?.decorators?.map(e=>({title:e.title??l(e.name),value:e.name,icon:e.icon}))??[],annotations:e?.annotations?.map(e=>({name:e.name,type:"object",title:e.title,icon:e.icon}))??[]},lists:e?.lists?.map(e=>({value:e.name,title:e.title??l(e.name),icon:e.icon}))??[],styles:e?.styles?.map(e=>({value:e.name,title:e.title??l(e.name),icon:e.icon}))??[]}]}),a=H(o.V.compile({types:[r,...t,...n]}).get("portable-text"));return{...a,blockObjects:a.blockObjects.map(e=>"tmp-image"===e.name?{...e,name:"image",type:{...e.type,name:"image"}}:e)}}(e.schemaDefinition):H(e.schema.hasOwnProperty("jsonType")?e.schema:eM(e.sc
61hema)),value:e.initialValue}});t.start();let n=function(e){let t=t8.get(e.editorActor);if(t)return t3("Reusing existing Slate editor instance",e.editorActor.id),t;t3("Creating new Slate editor instance",e.editorActor.id);let n=[],r=[],i=t2((0,u.BU)((0,p.Jh)()),{editorActor:e.editorActor,subscriptions:r});for(let e of(ey.set(i,{}),ef.set(i,{}),r))n.push(e());let o=[i.pteCreateTextBlock({decorators:[]})],l={instance:i,initialValue:o};return t8.set(e.editorActor,l),l}({editorActor:t});return{send:e=>{t.send(e)},on:(e,n)=>t.on(e,n),editable:function(e,t){let n=t.getSnapshot().context.schema;return{focus:()=>{u.F3.focus(e)},blur:()=>{u.F3.blur(e)},toggleMark:n=>{t.send({type:"behavior event",behaviorEvent:{type:"decorator.toggle",decorator:n},editor:e})},toggleList:t=>{e.pteToggleListItem(t)},toggleBlockStyle:t=>{e.pteToggleBlockStyle(t)},isMarkActive:t=>{try{return tZ({editor:e,decorator:t})}catch(e){return console.warn(e),!1}},marks:()=>({...p.ML.marks(e)||{}}).marks||[],undo:()=>e.undo(),redo:()=>e.redo(),select:t=>{let n=et(t,e);n?p.YR.select(e,n):p.YR.deselect(e),e.onChange()},focusBlock:()=>{if(e.selection){let t=p.NB.descendant(e,e.selection.focus.path.slice(0,1));if(t)return el([t],n.block.name,ey.get(e))[0]}},focusChild:()=>{if(e.selection){let t=p.NB.descendant(e,e.selection.focus.path.slice(0,1));if(t&&e.isTextBlock(t))return el([t],n.block.name,ey.get(e))[0].children[e.selection.focus.path[1]]}},insertChild:(r,i)=>{if(!e.selection)throw Error("The editor has no selection");let[o]=Array.from(p.ML.nodes(e,{at:e.selection.focus.path.slice(0,1),match:e=>e._type===n.block.name}))[0]||[void 0];if(!o)throw Error("No focused text block");if(r.name!==n.span.name&&!n.inlineObjects.some(e=>e.name===r.name))throw Error("This type cannot be inserted as a child to a text block");let l=eo([{_key:t.getSnapshot().context.keyGenerator(),_type:n.block.name,children:[{_key:t.getSnapshot().context.keyGenerator(),_type:r.name,...i||{}}]}],{schemaTypes:t.getSnapshot().context.schema})[0].children[0],a=e.selection.focus.path.slice(0,2),s=l._type===n.span.name,c=p.NB.get(e,a);return s&&c._type!==n.span.name&&(t5("Inserting span child next to inline object child, moving selection + 1"),e.move({distance:1,unit:"character"})),p.YR.insertNodes(e,l,{select:!0,at:e.selection}),e.onChange(),ee(el(e.children,n.block.name,ey.get(e)),e.selection,n)?.focus.path||[]},insertBlock:(r,i)=>(t6({context:{keyGenerator:t.getSnapshot().context.keyGenerator,schema:n},action:{type:"insert block object",blockObject:{name:r.name,value:i},placement:"auto",editor:e}}),e.onChange(),ee(el(e.children,n.block.name,ey.get(e)),e.selection,n)?.focus.path??[]),hasBlockStyle:t=>{try{return e.pteHasBlockStyle(t)}catch{return!1}},hasListStyle:t=>{try{return e.pteHasListStyle(t)}catch{return!1}},isVoid:e=>![n.block.name,n.span.name].includes(e._type),findByPath:t=>{let r=et({focus:{path:t,offset:0},anchor:{path:t,offset:0}},e);if(r){let[i,o]=p.ML.node(e,r.focus.path.slice(0,1));if(i&&o&&"string"==typeof i._key){if(1===t.length&&1===r.focus.path.length)return[el([i],n.block.name)[0],[{_key:i._key}]];let o=el([i],n.block.name,ey.get(e))[0];if(e.isTextBlock(o)){let e=o.children[r.focus.path[1]];if(e)return[e,[{_key:i._key},"children",{_key:e._key}]]}}}return[void 0,void 0]},findDOMNode:t=>{let n;try{let[r]=Array.from(p.ML.nodes(e,{at:[],match:e=>e._key===t._key})||[])[0]||[void 0];n=u.F3.toDOMNode(e,r)}catch{}return n},activeAnnotations:()=>{if(!e.selection||e.selection.focus.path.length<2)return[];try{let t=[];for(let[n,r]of p.ML.nodes(e,{at:e.selection,match:e=>p.xv.isText(e)&&void 0!==e.marks&&Array.isArray(e.marks)&&e.marks.length>0})){let[i]=p.ML.node(e,r,{depth:1});e.isTextBlock(i)&&i.markDefs?.forEach(e=>{p.xv.isText(n)&&n.marks&&Array.isArray(n.marks)&&n.marks.includes(e._key)&&t.push(e)})}return t}catch{return[]}},isAnnotationActive:t=>t9({editor:e,annotation:{name:t}}),addAnnotation:(r,i)=>{let o;return p.ML.withoutNormalizing(e,()=>{o=t7({context:{keyGenerator:t.getSnapshot().context.keyGenerator,schema:n},action:{type:"annotation.add",annotation:{name:r.name,value:i??{}},editor:e}})}),e.onChange(),o},delete:(t,r)=>{if(t){let i=et(t,e);if(!(i&&i.anchor.path.length>0&&i.focus.path.length>0))throw Error("Invalid range");if(i){if(!r?.mode||r?.mode==="selected"){t5("Deleting content in selection"),p.YR.delete(e,{at:i,hanging:!0,voids:!0}),e.onChange();return}r?.mode==="blocks"&&(t5("Deleting blocks touched by selection"),p.YR.removeNodes(e,{at:i,voids:!0,match:t=>e.isTextBlock(t)||!e.isTextBlock(t)&&p.W_.isElement(t)})),r?.mode==="children"&&(t5("Deleting children touched by selection"),p.YR.removeNodes(e,{at:i,voids:!0,match:t=>t._type===n.span.name||!e.isTextBlock(t)&&p.W_.isElement(t)})),0===e.children.length&&(e.children=[e.pteCreateTextBlock({decorators:[]})]),e.onChange()}}},removeAnnotation:n=>
61{t.send({type:"behavior event",behaviorEvent:{type:"annotation.remove",annotation:{name:n.name}},editor:e})},getSelection:()=>{let t=null;if(e.selection){let r=em.get(e.selection);if(r)return r;t=ee(el(e.children,n.block.name,ey.get(e)),e.selection,n),em.set(e.selection,t)}return t},getValue:()=>el(e.children,n.block.name,ey.get(e)),isCollapsedSelection:()=>!!e.selection&&p.e6.isCollapsed(e.selection),isExpandedSelection:()=>!!e.selection&&p.e6.isExpanded(e.selection),insertBreak:()=>{e.insertBreak(),e.onChange()},getFragment:()=>el(e.getFragment(),n.block.name),isSelectionsOverlapping:(t,n)=>{let r=et(t,e),i=et(n,e);return p.e6.isRange(r)&&p.e6.isRange(i)&&p.e6.includes(r,i)}}}(n.instance,t),_internal:{editorActor:t,slateEditor:n}}}({keyGenerator:e.keyGenerator??tL,schema:e.schemaType,initialValue:e.value,maxBlocks:void 0===e.maxBlocks?void 0:Number.parseInt(e.maxBlocks.toString(),10),readOnly:e.readOnly}),this.schemaTypes=this.editor._internal.editorActor.getSnapshot().context.schema,this.editable=this.editor.editable}componentDidUpdate(e){this.props.editor||e.editor||this.props.schemaType===e.schemaType||(this.schemaTypes=H(this.props.schemaType.hasOwnProperty("jsonType")?this.props.schemaType:eM(this.props.schemaType)),this.editor._internal.editorActor.send({type:"update schema",schema:this.schemaTypes})),this.props.editor||e.editor||(this.props.readOnly!==e.readOnly&&this.editor._internal.editorActor.send({type:"toggle readOnly"}),this.props.maxBlocks!==e.maxBlocks&&this.editor._internal.editorActor.send({type:"update maxBlocks",maxBlocks:void 0===this.props.maxBlocks?void 0:Number.parseInt(this.props.maxBlocks.toString(),10)}),this.props.value!==e.value&&this.editor._internal.editorActor.send({type:"update value",value:this.props.value}),this.props.editorRef!==e.editorRef&&this.props.editorRef&&(this.props.editorRef.current=this))}setEditable=e=>{this.editor.editable={...this.editor.editable,...e}};render(){let e=this.props.editor?void 0:this.props.incomingPatches$??this.props.patches$;return(0,a.jsxs)(a.Fragment,{children:[e?(0,a.jsx)(nl,{editorActor:this.editor._internal.editorActor,patches$:e}):null,(0,a.jsx)(na,{editorActor:this.editor._internal.editorActor,onChange:e=>{this.props.editor||this.props.onChange(e),this.change$.next(e)}}),(0,a.jsx)(tN,{editorActor:this.editor._internal.editorActor,getValue:this.editor.editable.getValue,portableTextEditor:this,slateEditor:this.editor._internal.slateEditor.instance}),(0,a.jsx)(tT.Provider,{value:this.editor._internal.editorActor,children:(0,a.jsx)(u.mH,{editor:this.editor._internal.slateEditor.instance,initialValue:this.editor._internal.slateEditor.initialValue,children:(0,a.jsx)(eT.Provider,{value:this,children:(0,a.jsx)(tC,{editorActor:this.editor._internal.editorActor,children:this.props.children})})})})]})}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=>{ni("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=>{ni("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)=>(ni("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)=>
61{ni("Host setting selection",t),e.editable?.select(t)};static removeAnnotation=(e,t)=>e.editable?.removeAnnotation(t);static toggleBlockStyle=(e,t)=>(ni("Host is toggling block style"),e.editable?.toggleBlockStyle(t));static toggleList=(e,t)=>e.editable?.toggleList(t);static toggleMark=(e,t)=>{ni("Host toggling mark",t),e.editable?.toggleMark(t)};static getFragment=e=>(ni("Host getting fragment"),e.editable?.getFragment());static undo=e=>{ni("Host undoing"),e.editable?.undo()};static redo=e=>{ni("Host redoing"),e.editable?.redo()};static isSelectionsOverlapping=(e,t,n)=>e.editable?.isSelectionsOverlapping(t,n)}function nl(e){let t,n;let r=(0,y.c)(4);return r[0]!==e.editorActor||r[1]!==e.patches$?(t=()=>{let t=e.patches$.subscribe(t=>{e.editorActor.send({type:"patches",...t})});return()=>{t.unsubscribe()}},n=[e.editorActor,e.patches$],r[0]=e.editorActor,r[1]=e.patches$,r[2]=t,r[3]=n):(t=r[2],n=r[3]),(0,h.useEffect)(t,n),null}function na(e){let t,n,r;let i=(0,y.c)(6);i[0]!==e?(t=t=>e.onChange(t),i[0]=e,i[1]=t):t=i[1];let o=(0,b.i)(t);return i[2]!==o||i[3]!==e.editorActor?(n=()=>{ni("Subscribing to editor changes");let t=e.editorActor.on("*",e=>{switch(e.type){case"patch":default:o(e);break;case"loading":o({type:"loading",isLoading:!0});break;case"done loading":o({type:"loading",isLoading:!1});break;case"focused":o({type:"focus",event:e.event});break;case"value changed":o({type:"value",value:e.value});break;case"invalid value":o({type:"invalidValue",resolution:e.resolution,value:e.value});break;case"error":o({...e,level:"warning"});case"annotation.add":case"annotation.remove":case"annotation.toggle":case"focus":case"patches":case"readOnly toggled":}});return()=>{ni("Unsubscribing to changes"),t.unsubscribe()}},r=[e.editorActor,o],i[2]=o,i[3]=e.editorActor,i[4]=n,i[5]=r):(n=i[4],r=i[5]),(0,h.useEffect)(n,r),null}let ns=Z("components:Leaf"),nc=[],nd=e=>{let{editorActor:t,attributes:n,children:r,leaf:i,schemaTypes:o,renderChild:l,renderDecorator:s,renderAnnotation:d}=e,f=(0,h.useRef)(null),y=eA(),m=(0,u.vt)(),[k,b]=(0,h.useState)(!1),[v,x]=(0,h.useState)(!1),_=r.props.parent,w=(0,h.useMemo)(()=>_?[{_key:_?._key},"children",{_key:i._key}]:[],[_,i._key]),N=(0,h.useMemo)(()=>o.decorators.map(e=>e.value),[o.decorators]),S=(0,h.useMemo)(()=>g((i.marks||nc).filter(e=>N.includes(e))),[N,i.marks]),E=Array.isArray(i.marks)?i.marks:nc,T=(0,h.useMemo)(()=>E.map(e=>!N.includes(e)&&_?.markDefs?.find(t=>t._key===e)).filter(Boolean),[E,_,N]),A=T.length>0&&m;(0,h.useEffect)(()=>{if(!A){b(!1);return}let e=no.getSelection(y);e&&c(e.focus.path,w)&&no.isCollapsedSelection(y)&&(0,h.startTransition)(()=>{b(!0)})},[A,w,y]);let R=(0,h.useCallback)(()=>{if(!A)return;ns("Setting selection and focus from range");let e=window.getSelection();if(!e){x(!1);return}if(e&&e.rangeCount>0){let t=e.getRangeAt(0);f.current&&t.intersectsNode(f.current)?x(!0):x(!1)}else x(!1)},[A]);(0,h.useEffect)(()=>{if(!A)return;let e=t.on("blur",()=>{b(!1),x(!1)}),n=t.on("focus",()=>{let e=no.getSelection(y);e&&c(e.focus.path,w)&&no.isCollapsedSelection(y)&&b(!0),R()}),r=t.on("selection",e=>{e.selection&&c(e.selection.focus.path,w)&&no.isCollapsedSelection(y)?b(!0):b(!1),R()});return()=>{e.unsubscribe(),n.unsubscribe(),r.unsubscribe()}},[t,w,y,R,A]),(0,h.useEffect)(()=>R(),[R]);let M=(0,h.useMemo)(()=>{let e=r;if(p.xv.isText(i)&&i._type===o.span.name&&(S.forEach(t=>{let n=o.decorators.find(e=>e.value===t);n&&s&&(e=s(Object.defineProperty({children:e,editorElementRef:f,focused:k,path:w,selected:v,schemaType:n,value:t},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),n)})))}),_&&T.length>0&&T.forEach(t=>{let n=o.annotations.find(e=>e.name===t._type);if(n){if(d){let r=Object.defineProperty({block:_,children:e,editorElementRef:f,focused:k,path:w,selected:v,schemaType:n,value:t},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),n)});e=(0,a.jsx)("span",{ref:f,children:d(r)})}else e=(0,a.jsx)(eR,{annotation:t,children:(0,a.jsx)("span",{ref:f,children:e})})}}),_&&l)){let t=_.children.find(e=>e._key===i._key);t&&(e=l(Object.defineProperty({annotations:T,children:(0,a.jsx)(a.Fragment,{children:e}),editorElementRef:f,focused:k,path:w,schemaType:o.span,selected:v,value:t},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),o.span)})))}return e},[T,_,r,k,i,S,w,d,l,s,o.annotations,o.decorators,o.span,v]);return(0,h.useMemo)(()=>(0,a.jsx)("span",{...n,ref:f,children:M},i._key),[i,n,M])};nd.displayName="Leaf";let nh=Z("plugin:withHotKeys"),np={marks:{"mod+b":"strong","mod+i":"em","mod+u":"underline","mod+'":"code"},custom:{}},nu=Z("plugin:withInsertData"),nf={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function ny(e,t,n){e.withoutNormalizing(()=>{if(!e.selection)return;let[r,i]=p.ML.node(e,e.selection,{depth:1});if(e.isTextBlock(r)&&e.isTextBlock(t[0])){let{markDefs:n}=r;nu("Mixing markDefs of focusBlock and fragments[0] block",n,t[0].markDefs),c(n,t[0].markDefs)||p.YR.setNodes(e,{markDefs:g([...t[0].markDefs||[],...n||[]])},{at:i,mode:"lowest",voids:!1})}ea(e.children,n)?(p.YR.splitNodes(e,{at:[0,0]}),e.insertFragment(t),p.YR.removeNodes(e,{at:[0]})):e.insertFragment(t)}),e.onChange()}let nm=Z("component:Editable"),ng={position:"absolute",userSelect:"none",pointerEvents:"none",left:0,right:0},nk=(0,h.forwardRef)(function(e,t){let{hotkeys:n,onBlur:r,onFocus:o,onBeforeInput:l,onPaste:f,onCopy:y,onClick:m,rangeDecorations:g,renderAnnotation:k,renderBlock:b,renderChild:v,renderDecorator:x,renderListItem:_,renderPlaceholder:w,renderStyle:N,selection:S,scrollSelectionIntoView:E,spellCheck:T,...A}=e,R=eA(),M=(0,h.useRef)(null),[B,L]=(0,h.useState)(null),[D,$]=(0,h.useState)(!1),[P,j]=(0,h.useState)([]);(0,h.useImperativeHandle)(t,()=>M.current);let I=(0,h.useRef)(g),Y=(0,h.useContext)(tT),z=(0,s.v9)(Y,e=>e.context.readOnly),G=(0,s.v9)(Y,e=>e.context.schema),K=(0,u.ui)(),U=G.block.name;(0,h.useMemo)(()=>{let e=function(e){let t=G.block.name,n=G.span.name,r=G.block.options.unstable_whitespaceOnPasteMode,i=t=>t.map(t=>e.isTextBlock(t)?t.children.map(e=>e._type===n?e.text:`[${G.inlineObjects.find(t=>t.name===e._type)?.title||"Object"}]`).join(""):`[${G.blockObjects.find(e=>e.name===t._type)?.title||"Object"}]`).join(`
62
63`);return e.setFragmentData=(n,r)=>{let{selection:o}=e;if(!o)return;let[l,a]=p.e6.edges(o),s=p.ML.void(e,{at:l.path}),c=p.ML.void(e,{at:a.path});if(p.e6.isCollapsed(o)&&!s)return;let d=u.F3.toDOMRange(e,o),h=d.cloneContents();if(c){let[t]=c,n=d.cloneRange(),r=u.F3.toDOMNode(e,t);n.setEndAfter(r),h=n.cloneContents()}Array.from(h.querySelectorAll("[data-slate-zero-width]")).forEac
63h(e=>{let t="n"===e.getAttribute("data-slate-zero-width");e.textContent=t?`
64`:""}),Array.from(h.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=h.ownerDocument.createElement("div");f.appendChild(h),f.setAttribute("hidden","true"),h.ownerDocument.body.appendChild(f);let y=f.innerHTML;h.ownerDocument.body.removeChild(f);let m=el(e.getFragment(),t),g=JSON.stringify(m),k=i(m);n.clearData(),n.setData("text/plain",k),n.setData("text/html",y),n.setData("application/json",g),n.setData("application/x-portable-text",g),nu("text",k),n.setData("application/x-portable-text-event-origin",r||"external"),nu("Set fragment data",g,y)},e.insertPortableTextData=t=>{if(!e.selection)return!1;let r=t.getData("application/x-portable-text"),i=t.getData("application/x-portable-text-event-origin");if(nu(`Inserting portable text from ${i} event`,r),r){let t=JSON.parse(r);if(Array.isArray(t)&&t.length>0){var o,l;let r=(o=eo(t,{schemaTypes:G}),l=Y.getSnapshot().context.keyGenerator,o.map(t=>{let r={...t};if(e.isTextBlock(r)){let t=G.annotations.map(e=>e.name);if(0===t.length){let{markDefs:e,...t}=r;return{...t,_key:l()}}if((r.markDefs||[]).some(e=>!t.includes(e._type))){let e=(r.markDefs||[]).filter(e=>t.includes(e._type));return{...r,markDefs:e,_key:l()}}r.markDefs=(r.markDefs||[]).map(t=>{let i=t._key,o=l();return r.children=r.children.map(t=>t._type===n&&e.isTextSpan(t)?{...t,marks:t.marks&&t.marks.includes(i)?[...t.marks].filter(e=>e!==i).concat(o):t.marks}:t),{...t,_key:o}})}let i={...r,_key:l()};return e.isTextBlock(i)&&(i.children=i.children.map(e=>({...e,_key:l()}))),i})),i=eB(t,G,Y.getSnapshot().context.keyGenerator);if(!i.valid&&!i.resolution?.autoResolve){let e=`${i.resolution?.description}`;return Y.send({type:"error",name:"pasteError",description:e,data:i}),nu("Invalid insert result",i),!1}return ny(e,r,G),!0}}return!1},e.insertTextOrHTMLData=n=>{if(!e.selection)return nu("No selection, not inserting"),!1;let i=n.getData("text/html"),o=n.getData("text/plain");if(i||o){let l,a,s;if(nu("Inserting data",n),i){if(a=eo(l=(0,C.zW)(i,G.portableText,{unstable_whitespaceOnPasteMode:r}).map(e=>(0,C.nX)(e,{blockTypeName:t})),{schemaTypes:G}),s="HTML",0===l.length)return!1}else{let e=`<html><body>${String(o).replace(/[&<>"'`=/]/g,e=>nf[e]).split(/\n{2,}/).map(e=>e?`<p>${e.replace(/(?:\r\n|\r|\n)/g,"<br/>")}</p>`:"<p></p>").join("")}</body></html>`;a=eo(l=(0,C.zW)(e,G.portableText).map(e=>(0,C.nX)(e,{blockTypeName:t})),{schemaTypes:G}),s="text"}let c=eB(l,G,Y.getSnapshot().context.keyGenerator);if(!c.valid){let e=`Could not validate the resulting portable text to insert.
65${c.resolution?.description}
66Try to insert as plain text (shift-paste) instead.`;return Y.send({type:"error",name:"pasteError",description:e,data:c}),nu("Invalid insert result",c),!1}return nu(`Inserting ${s} fragment at ${JSON.stringify(e.selection)}`),ny(e,a,G),!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};if(z)return nm("Editable is in read only mode"),e(K);let t=function(e,t,n){let r=["enter","tab","shift","delete","end"],o=n||np;return function(n){return n.pteWithHotKeys=l=>{Object.keys(o).forEach(i=>{if("marks"===i)for(let t in o[i]){if(r.includes(t))throw Error(`The hotkey ${t} is reserved!`);if(O(t,l.nativeEvent)){l.preventDefault();let r=o[i];if(r){let i=r[t];nh(`HotKey ${t} to toggle ${i}`),e.send({type:"behavior event",behaviorEvent:{type:"decorator.toggle",decorator:i},editor:n})}}}if("custom"===i)for(let e in o[i]){if(r.includes(e))throw Error(`The hotkey ${e} is reserved!`);if(O(e,l.nativeEvent)){let n=o[i];n&&(0,n[e])(l,t)}}});let a=O("enter",l.nativeEvent),s=O("tab",l.nativeEvent),c=O("shift+enter",l.nativeEvent),d=O("shift+tab",l.nativeEvent);if((s||d)&&n.selection){let[e]=p.ML.node(n,n.selection.focus,{depth:2}),[t]=(0,i.NG)(e)?p.ML.node(n,n.selection.focus,{depth:1}):[],r=e&&(0,i.DG)(t)&&(0,i.NG)(e)&&(e.marks||[]).filter(e=>(t.markDefs||[]).map(e=>e._key).includes(e)).length>0,[o]=p.e6.edges(n.selection),a=p.ML.isStart(n,o,o.path);e&&(0,i.NG)(e)&&(!r||a)&&n.pteIncrementBlockLevels(d)&&l.preventDefault()}if(a&&!c&&n.selection){let e=n.selection.focus.path.slice(0,1),t=p.NB.descendant(n,e);if(n.isListBlock(t)){n.pteEndList()&&l.preventDefault();return}}},n}}(Y,R,n);return nm("Editable is in edit mode"),e(t(K))}
66,[Y,n,R,z,G,K]);let F=(0,h.useCallback)(e=>(0,a.jsx)(eE,{...e,readOnly:z,renderBlock:b,renderChild:v,renderListItem:_,renderStyle:N,schemaTypes:G,spellCheck:T}),[G,T,z,b,v,_,N]),W=(0,h.useCallback)(e=>{if("span"===e.leaf._type){let t=(0,a.jsx)(nd,{...e,editorActor:Y,schemaTypes:G,renderAnnotation:k,renderChild:v,renderDecorator:x,readOnly:z});if(w&&e.leaf.placeholder&&""===e.text.text)return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{style:ng,contentEditable:!1,children:w()}),t]});let n=e.leaf.rangeDecoration;return n&&(t=n.component({children:t})),t}return e.children},[Y,z,k,v,x,w,G]),J=(0,h.useCallback)(()=>{if(S){nm(`Selection from props ${JSON.stringify(S)}`);let e=function(e,t){if(!e||!t||0===t.length)return null;let n=null,r=null,{anchor:i,focus:o}=e;return i&&t.find(e=>c({_key:e._key},i.path[0]))&&(n=en(i,t)),o&&t.find(e=>c({_key:e._key},o.path[0]))&&(r=en(o,t)),n&&r?{anchor:n,focus:r,backward:e.backward}:null}(S,el(K.children,U));if(null!==e){nm(`Normalized selection from props ${JSON.stringify(e)}`);let t=et(e,K);t&&(p.YR.select(K,t),K.operations.some(e=>"set_selection"===e.type)||Y.send({type:"selection",selection:e}),K.onChange())}}},[U,Y,S,K]),V=(0,h.useCallback)(e=>{if(g&&g.length>0){let t=[];if(g.forEach(n=>{let r;let i=et(n.selection,K);if(!p.e6.isRange(i)){n.onMoved&&n.onMoved({newSelection:null,rangeDecoration:n,origin:"local"});return}if(e&&((r=function(e,t){let n=p.E9.transform(e.anchor,t),r=p.E9.transform(e.focus,t);return null===n||null===r?null:p.E9.equals(n,e.anchor)&&p.E9.equals(r,e.focus)?e:{anchor:n,focus:r}}(i,e))&&r!==i||null===r&&i)){let e=ee(no.getValue(R),r,G);n.onMoved&&n.onMoved({newSelection:e,rangeDecoration:n,origin:"local"})}null!==r&&t.push({...r||i,rangeDecoration:n})}),t.length>0){j(t);return}}j(e=>e.length>0?[]:e)},[R,g,G,K]);(0,h.useEffect)(()=>{let e=Y.on("ready",()=>{J()}),t=Y.on("invalid value",()=>{$(!0)}),n=Y.on("value changed",()=>{$(!1)});return()=>{e.unsubscribe(),t.unsubscribe(),n.unsubscribe()}},[Y,J]),(0,h.useEffect)(()=>{S&&!D&&J()},[D,S,J]);let[H,q]=(0,h.useState)(!1);(0,h.useEffect)(()=>{H||(q(!0),V())},[V,H]),(0,h.useEffect)(()=>{c(g,I.current)||V(),I.current=g},[g,V]),(0,h.useEffect)(()=>{let e=function(e,t){let n=e.apply;return e.apply=e=>{n(e),"set_selection"!==e.type&&t(e)},()=>{e.apply=n}}(K,V);return()=>e()},[K,V]);let Z=(0,h.useCallback)(e=>{y?void 0!==y(e)&&e.preventDefault():e.nativeEvent.clipboardData&&Y.send({type:"behavior event",behaviorEvent:{type:"copy",data:e.nativeEvent.clipboardData},editor:K,nativeEvent:e})},[y,Y,K]),X=(0,h.useCallback)(e=>{let t=no.getValue(R),n=ee(t,K.selection,G)?.focus.path||[],r=f?.({event:e,value:t,path:n,schemaTypes:G});r||!K.selection?(e.preventDefault(),Y.send({type:"loading"}),Promise.resolve(r).then(t=>{nm("Custom paste function from client resolved",t),t&&t.insert?t.insert?K.insertFragment(eo(t.insert,{schemaTypes:G})):console.warn("Your onPaste function returned something unexpected:",t):(nm("No result from custom paste handler, pasting normally"),K.insertData(e.clipboardData))}).catch(e=>(console.error(e),e)).finally(()=>{Y.send({type:"done loading"})})):e.nativeEvent.clipboardData&&Y.send({type:"behavior event",behaviorEvent:{type:"paste",data:e.nativeEvent.clipboardData},editor:K,nativeEvent:e}),nm("No result from custom paste handler, pasting normally")},[Y,f,R,G,K]),Q=(0,h.useCallback)(e=>{if(o&&o(e),!e.isDefaultPrevented()){let t=no.getSelection(R);null===t&&(p.YR.select(K,p.ML.start(K,[])),K.onChange()),Y.send({type:"focused",event:e}),t===no.getSelection(R)&&Y.send({type:"selection",selection:t})}},[Y,o,R,K]),er=(0,h.useCallback)(e=>{m&&m(e);let t=K.selection?K.selection.focus.path.slice(0,1):void 0,n=t?p.NB.descendant(K,t):void 0,[r,i]=p.NB.last(K,[]),o=i.slice(0,1),l=!!t&&p.y$.equals(o,t),a=!!n&&!K.isTextBlock(n);K.selection&&p.e6.isCollapsed(K.selection)&&l&&a&&(p.YR.insertNodes(K,K.pteCreateTextBlock({decorators:[]})),K.onChange())},[m,K]),ei=(0,h.useCallback)(e=>{r&&r(e),e.isPropagationStopped()||Y.send({type:"blur",event:e})},[Y,r]),es=(0,h.useCallback)(e=>{l&&l(e)},[l]),ec=(0,h.useCallback)(()=>
66{if(!K.selection)return;let{activeElement:e}=u.F3.findDocumentOrShadowRoot(K);if(M.current!==e)return;let t=u.F3.getWindow(K).getSelection();if(!t||0===t.rangeCount)return;let n=t.getRangeAt(0);try{let e=u.F3.toDOMRange(K,K.selection);(e.startOffset!==n.startOffset||e.endOffset!==n.endOffset)&&(nm("DOM range out of sync, validating selection"),t?.removeAllRanges(),t.addRange(e))}catch{nm("Could not resolve selection, selecting top document"),p.YR.deselect(K),K.children.length>0&&p.YR.select(K,[0,0]),K.onChange()}},[M,K]);(0,h.useEffect)(()=>{if(B){let e=new MutationObserver(ec);return e.observe(B,{attributeOldValue:!1,attributes:!1,characterData:!1,childList:!0,subtree:!0}),()=>{e.disconnect()}}},[ec,B]);let ed=(0,h.useCallback)(t=>{e.onKeyDown&&e.onKeyDown(t),t.isDefaultPrevented()||K.pteWithHotKeys(t),t.isDefaultPrevented()||Y.send({type:"behavior event",behaviorEvent:{type:"key.down",keyboardEvent:{key:t.key,code:t.code,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey}},editor:K,nativeEvent:t})},[e,Y,K]),eh=(0,h.useCallback)(t=>{e.onKeyUp&&e.onKeyUp(t),t.isDefaultPrevented()||Y.send({type:"behavior event",behaviorEvent:{type:"key.up",keyboardEvent:{key:t.key,code:t.code,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey}},editor:K,nativeEvent:t})},[e,Y,K]),ep=(0,h.useMemo)(()=>{if(void 0!==E)return null===E?d:(e,t)=>{E(R,t)}},[R,E]),eu=(0,h.useCallback)(([,e])=>{if(ea(K.children,G))return[{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0},placeholder:!0}];if(0===e.length)return[];let t=P.filter(t=>p.e6.isCollapsed(t)?2===e.length&&p.y$.equals(t.focus.path,e)&&p.y$.equals(t.anchor.path,e):p.e6.intersection(t,{anchor:{path:e,offset:0},focus:{path:e,offset:0}})||p.e6.includes(t,e));return t.length>0?t:[]},[K,G,P]);return(0,h.useEffect)(()=>{M.current=u.F3.toDOMNode(K,K),L(M.current)},[K,M]),R?D?null:(0,a.jsx)(u.CX,{...A,autoFocus:!1,className:A.className||"pt-editable",decorate:eu,onBlur:ei,onCopy:Z,onClick:er,onDOMBeforeInput:es,onFocus:Q,onKeyDown:ed,onKeyUp:eh,onPaste:X,readOnly:z,renderPlaceholder:void 0,renderElement:F,renderLeaf:W,scrollSelectionIntoView:ep}):null});nk.displayName="ForwardRef(PortableTextEditable)",h.createContext(void 0)}}]);

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.