1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3510],{60814:function(e,t,n){n.d(t,{L9:function(){return tw},_F:function(){return tE},iV:function(){return t1},q$:function(){return tI}});var r,i,a,o,l,s,c=n(85893),h=n(67294),f=n(34265),d=n(56629),p=n(79795),u=n(43146),g=n(55899),m=n(40347),y=n(91186),k=n(54432),_=n(62997),b=n.n(_),x=n(37093),w=n(12751),M=n(64514),E=n(18446),T=n.n(E),N=n(50308),D=n.n(N),A=n(14176),C=n.n(A),L=n(52353),S=n.n(L),P=n(27361),R=n.n(P),I=n(85564),B=n.n(I),j=n(97738),O=n(13218),Y=n.n(O),W=n(47037),z=n.n(W),J=n(30998),F=n.n(J),V=n(57557),U=n.n(V),H=n(66678),$=n.n(H),q=n(44908),Z=n.n(q),G=n(18156),K=n(76590),X=n(23279),Q=n.n(X),ee=n(54335);function et(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function en(e){return k.V.compile({name:"blockTypeSchema",types:[e]}).get(e.name)}function er(e){var t,n,r;if(!e)throw Error("Parameter 'portabletextType' missing (required)");let i=null==(t=e.of)?void 0:t.find(function e(t){return t.type?e(t.type):"block"===t.name?t:null});if(!i)throw Error("Block type is not defined in this schema (required)");let a=null==(n=i.fields)?void 0:n.find(e=>"children"===e.name);if(!a)throw Error("Children field for block type found in schema (required)");let o=a.type.of;if(!o)throw Error("Valid types for block children not found in schema (required)");let l=o.find(e=>"span"===e.name);if(!l)throw Error("Span type not found in schema (required)");let s=o.filter(e=>"span"!==e.name)||[],c=(null==(r=e.of)?void 0:r.filter(e=>e.name!==i.name))||[];return{styles:function(e){var t,n,r;let i=null==(t=e.fields)?void 0:t.find(e=>"style"===e.name);if(!i)throw Error("A field with name 'style' is not defined in the block type (required).");let a=(null==(n=i.type.options)?void 0:n.list)&&(null==(r=i.type.options.list)?void 0:r.filter(e=>e.value));if(!a||0===a.length)throw Error("The style fields need at least one style defined. I.e: {title: 'Normal', value: 'normal'}.");return a}(i),decorators:l.decorators,lists:function(e){var t,n;let r=null==(t=e.fields)?void 0:t.find(e=>"list"===e.name);if(!r)throw Error("A field with name 'list' is not defined in the block type (required).");let i=(null==(n=r.type.options)?void 0:n.list)&&r.type.options.list.filter(e=>e.value);if(!i)throw Error("The list field need at least to be an empty array");return i}(i),block:i,span:l,portableText:e,inlineObjects:s,blockObjects:c,annotations:l.annotations}}let ei="sanity-pte:";function ea(e){let t="".concat(ei).concat(e);return b()&&b().enabled(t)?b()(t):b()(ei)}b()(ei);let eo=()=>(0,x.E2)(12),el=(0,h.createContext)(eo),es=()=>{let e=(0,h.useContext)(el);if(void 0===e)throw Error("The `usePortableTextEditorKeyGenerator` hook must be used inside the <PortableTextEditor> component's context.");return e},ec=new WeakMap,eh=new WeakMap,ef=new WeakMap,ed=new WeakMap,ep=new WeakMap,eu=new WeakMap,eg=new WeakMap,em=new WeakMap,ey=new WeakMap,ek=[];function ev(e,t){let n=t[e._key];return n&&T()(e,n)?n:(t[e._key]=e,e)}function e_(e,t){let{schemaTypes:n}=t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e&&Array.isArray(e)?e.map(e=>{let{_type:t,_key:i,...a}=e,o=[{_key:"".concat(i,"-void-child"),_type:"span",text:"",marks:[]}];if(e&&e._type===n.block.name){let l=!1,s=void 0===e.style,c=void 0===e.markDefs,h=e.children.map(e=>{let{_type:t,_key:n,...i}=e;return"span"!==t?(l=!0,ev({_type:t,_key:n,children:o,value:i,__inline:!0},r)):e});return!s&&!c&&!l&&M.W_.isElement(e)?e:(s&&(a.style=n.styles[0].value),c&&(a.markDefs=ek),ev({_type:t,_key:i,...a,children:h},r))}return ev({_type:t,_key:i,children:o,value:a},r)}):[]}function eb(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};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,a=e.children.map(e=>{let{_type:r}=e;if("value"in e&&"span"!==r){t=!0;let{value:r,_key:i,_type:a,__inline:o,children:l,...s}=e;return ev({...s,...r,_key:i,_type:a},n)}return e});return t?ev({...e,children:a,_key:r,_type:i},n):e}let a="value"in e&&e.value;return ev({_key:r,_type:i,..."object"==typeof a?a:{}},n)})}function ex(e,t){var n;return void 0===e||e&&Array.isArray(e)&&0===e.length||e&&Array.isArray(e)&&1===e.length&&M.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&&M.xv.isText(e[0].children[0])&&"span"===e[0].children[0]._type&&!(null==(n=e[0].children[0].marks)?void 0:n.join(""))&&""===e[0].children[0].text}var ew={};function eM(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{type:"setIfMissing",path:t,value:e}}r={get exports(){return ew},set exports(v){ew=v}},(i=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32}).Diff=function(e,t){return[e,t]},i.prototype.diff_main=function(e,t,n,r){void 0===r&&(r=this.Diff_Timeout<=0?Number.MAX_VALUE:new Date().getTime()+1e3*this.Diff_Timeout);var a=r;if(null==e||null==t)throw Error("Null input. (diff_main)");if(e==t)return e?[new i.Diff(0,e)]:[];void 0===n&&(n=!0);var o=n,l=this.diff_commonPrefix(e,t),s=e.substring(0,l);e=e.substring(l),t=t.substring(l),l=this.diff_commonSuffix(e,t);var c=e.substring(e.length-l);e=e.substring(0,e.length-l),t=t.substring(0,t.length-l);var h=this.diff_compute_(e,t,o,a);return s&&h.unshift(new i.Diff(0,s)),c&&h.push(new i.Diff(0,c)),this.diff_cleanupMerge(h),h},i.prototype.diff_compute_=function(e,t,n,r){if(!e)return[new i.Diff(1,t)];if(!t)return[new i.Diff(-1,e)];var a,o=e.length>t.length?e:t,l=e.length>t.length?t:e,s=o.indexOf(l);if(-1!=s)return a=[new i.Diff(1,o.substring(0,s)),new i.Diff(0,l),new i.Diff(1,o.substring(s+l.length))],e.length>t.length&&(a[0][0]=a[2][0]=-1),a;if(1==l.length)return[new i.Diff(-1,e),new i.Diff(1,t)];var c=this.diff_halfMatch_(e,t);if(c){var h=c[0],f=c[1],d=c[2],p=c[3],u=c[4],g=this.diff_main(h,d,n,r),m=this.diff_main(f,p,n,r);return g.concat([new i.Diff(0,u)],m)}return n&&e.length>100&&t.length>100?this.diff_lineMode_(e,t,r):this.diff_bisect_(e,t,r)},i.prototype.diff_lineMode_=function(e,t,n){var r=this.diff_linesToChars_(e,t);e=r.chars1,t=r.chars2;var a=r.lineArray,o=this.diff_main(e,t,!1,n);this.diff_charsToLines_(o,a),this.diff_cleanupSemantic(o),o.push(new i.Diff(0,""));for(var l=0,s=0,c=0,h="",f="";l<o.length;){switch(o[l][0]){case 1:c++,f+=o[l][1];break;case -1:s++,h+=o[l][1];break;case 0:if(s>=1&&c>=1){o.splice(l-s-c,s+c),l=l-s-c;for(var d=this.diff_main(h,f,!1,n),p=d.length-1;p>=0;p--)o.splice(l,0,d[p]);l+=d.length}c=0,s=0,h="",f=""}l++}return o.pop(),o},i.prototype.diff_bisect_=function(e,t,n){for(var r=e.length,a=t.length,o=Math.ceil((r+a)/2),l=2*o,s=Array(l),c=Array(l),h=0;h<l;h++)s[h]=-1,c[h]=-1;s[o+1]=0,c[o+1]=0;for(var f=r-a,d=f%2!=0,p=0,u=0,g=0,m=0,y=0;y<o&&!(new Date().getTime()>n);y++){for(var k=-y+p;k<=y-u;k+=2){for(var _,b=o+k,x=(_=k==-y||k!=y&&s[b-1]<s[b+1]?s[b+1]:s[b-1]+1)-k;_<r&&x<a&&e.charAt(_)==t.charAt(x);)_++,x++;if(s[b]=_,_>r)u+=2;else if(x>a)p+=2;else if(d){var w=o+f-k;if(w>=0&&w<l&&-1!=c[w]){var M=r-c[w];if(_>=M)return this.diff_bisectSplit_(e,t,_,x,n)}}}for(var E=-y+g;E<=y-m;E+=2){for(var M,w=o+E,T=(M=E==-y||E!=y&&c[w-1]<c[w+1]?c[w+1]:c[w-1]+1)-E;M<r&&T<a&&e.charAt(r-M-1)==t.charAt(a-T-1);)M++,T++;if(c[w]=M,M>r)m+=2;else if(T>a)g+=2;else if(!d){var b=o+f-E;if(b>=0&&b<l&&-1!=s[b]){var _=s[b],x=o+_-b;if(_>=(M=r-M))return this.diff_bisectSplit_(e,t,_,x,n)}}}}return[new i.Diff(-1,e),new i.Diff(1,t)]},i.prototype.diff_bisectSplit_=function(e,t,n,r,i){var a=e.substring(0,n),o=t.substring(0,r),l=e.substring(n),s=t.substring(r),c=this.diff_main(a,o,!1,i),h=this.diff_main(l,s,!1,i);return c.concat(h)},i.prototype.diff_linesToChars_=function(e,t){var n=[],r={};function i(e){for(var t="",i=0,o=-1,l=n.length;o<e.length-1;){-1==(o=e.indexOf("\n",i))&&(o=e.length-1);var s=e.substring(i,o+1);(r.hasOwnProperty?r.hasOwnProperty(s):void 0!==r[s])?t+=String.fromCharCode(r[s]):(l==a&&(s=e.substring(i),o=e.length),t+=String.fromCharCode(l),r[s]=l,n[l++]=s),i=o+1}return t}n[0]="";var a=4e4,o=i(e);return a=65535,{chars1:o,chars2:i(t),lineArray:n}},i.prototype.diff_charsToLines_=function(e,t){for(var n=0;n<e.length;n++){for(var r=e[n][1],i=[],a=0;a<r.length;a++)i[a]=t[r.charCodeAt(a)];e[n][1]=i.join("")}},i.prototype.diff_commonPrefix=function(e,t){if(!e||!t||e.charAt(0)!=t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(a,i)==t.substring(a,i)?a=n=i:r=i,i=Math.floor((r-n)/2+n);return i},i.prototype.diff_commonSuffix=function(e,t){if(!e||!t||e.charAt(e.length-1)!=t.charAt(t.length-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(e.length-i,e.length-a)==t.substring(t.length-i,t.length-a)?a=n=i:r=i,i=Math.floor((r-n)/2+n);return i},i.prototype.diff_commonOverlap_=function(e,t){var n=e.length,r=t.length;if(0==n||0==r)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var a=0,o=1;;){var l=e.substring(i-o),s=t.indexOf(l);if(-1==s)return a;o+=s,(0==s||e.substring(i-o)==t.substring(0,o))&&(a=o,o++)}},i.prototype.diff_halfMatch_=function(e,t){if(this.Diff_Timeout<=0)return null;var n,r,i,a,o,l=e.length>t.length?e:t,s=e.length>t.length?t:e;if(l.length<4||2*s.length<l.length)return null;var c=this;function h(e,t,n){for(var r,i,a,o,l=e.substring(n,n+Math.floor(e.length/4)),s=-1,h="";-1!=(s=t.indexOf(l,s+1));){var f=c.diff_commonPrefix(e.substring(n),t.substring(s)),d=c.diff_commonSuffix(e.substring(0,n),t.substring(0,s));h.length<d+f&&(h=t.substring(s-d,s)+t.substring(s,s+f),r=e.substring(0,n-d),i=e.substring(n+f),a=t.substring(0,s-d),o=t.substring(s+f))}return 2*h.length>=e.length?[r,i,a,o,h]:null}var f=h(l,s,Math.ceil(l.length/4)),d=h(l,s,Math.ceil(l.length/2));return f||d?(n=d?f&&f[4].length>d[4].length?f:d:f,e.length>t.length?(r=n[0],i=n[1],a=n[2],o=n[3]):(a=n[0],o=n[1],r=n[2],i=n[3]),[r,i,a,o,n[4]]):null},i.prototype.diff_cleanupSemantic=function(e){for(var t=!1,n=[],r=0,a=null,o=0,l=0,s=0,c=0,h=0;o<e.length;
vendor: 6,038 bytes, line 1
1)0==e[o][0]?(n[r++]=o,l=c,s=h,c=0,h=0,a=e[o][1]):(1==e[o][0]?c+=e[o][1].length:h+=e[o][1].length,a&&a.length<=Math.max(l,s)&&a.length<=Math.max(c,h)&&(e.splice(n[r-1],0,new i.Diff(-1,a)),e[n[r-1]+1][0]=1,r--,o=--r>0?n[r-1]:-1,l=0,s=0,c=0,h=0,a=null,t=!0)),o++;for(t&&this.diff_cleanupMerge(e),this.diff_cleanupSemanticLossless(e),o=1;o<e.length;){if(-1==e[o-1][0]&&1==e[o][0]){var f=e[o-1][1],d=e[o][1],p=this.diff_commonOverlap_(f,d),u=this.diff_commonOverlap_(d,f);p>=u?(p>=f.length/2||p>=d.length/2)&&(e.splice(o,0,new i.Diff(0,d.substring(0,p))),e[o-1][1]=f.substring(0,f.length-p),e[o+1][1]=d.substring(p),o++):(u>=f.length/2||u>=d.length/2)&&(e.splice(o,0,new i.Diff(0,f.substring(0,u))),e[o-1][0]=1,e[o-1][1]=d.substring(0,d.length-u),e[o+1][0]=-1,e[o+1][1]=f.substring(u),o++),o++}o++}},i.prototype.diff_cleanupSemanticLossless=function(e){function t(e,t){if(!e||!t)return 6;var n=e.charAt(e.length-1),r=t.charAt(0),a=n.match(i.nonAlphaNumericRegex_),o=r.match(i.nonAlphaNumericRegex_),l=a&&n.match(i.whitespaceRegex_),s=o&&r.match(i.whitespaceRegex_),c=l&&n.match(i.linebreakRegex_),h=s&&r.match(i.linebreakRegex_),f=c&&e.match(i.blanklineEndRegex_),d=h&&t.match(i.blanklineStartRegex_);return f||d?5:c||h?4:a&&!l&&s?3:l||s?2:a||o?1:0}for(var n=1;n<e.length-1;){if(0==e[n-1][0]&&0==e[n+1][0]){var r=e[n-1][1],a=e[n][1],o=e[n+1][1],l=this.diff_commonSuffix(r,a);if(l){var s=a.substring(a.length-l);r=r.substring(0,r.length-l),a=s+a.substring(0,a.length-l),o=s+o}for(var c=r,h=a,f=o,d=t(r,a)+t(a,o);a.charAt(0)===o.charAt(0);){r+=a.charAt(0),a=a.substring(1)+o.charAt(0),o=o.substring(1);var p=t(r,a)+t(a,o);p>=d&&(d=p,c=r,h=a,f=o)}e[n-1][1]!=c&&(c?e[n-1][1]=c:(e.splice(n-1,1),n--),e[n][1]=h,f?e[n+1][1]=f:(e.splice(n+1,1),n--))}n++}},i.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,i.whitespaceRegex_=/\s/,i.linebreakRegex_=/[\r\n]/,i.blanklineEndRegex_=/\n\r?\n$/,i.blanklineStartRegex_=/^\r?\n\r?\n/,i.prototype.diff_cleanupEfficiency=function(e){for(var t=!1,n=[],r=0,a=null,o=0,l=!1,s=!1,c=!1,h=!1;o<e.length;)0==e[o][0]?(e[o][1].length<this.Diff_EditCost&&(c||h)?(n[r++]=o,l=c,s=h,a=e[o][1]):(r=0,a=null),c=h=!1):(-1==e[o][0]?h=!0:c=!0,a&&(l&&s&&c&&h||a.length<this.Diff_EditCost/2&&l+s+c+h==3)&&(e.splice(n[r-1],0,new i.Diff(-1,a)),e[n[r-1]+1][0]=1,r--,a=null,l&&s?(c=h=!0,r=0):(o=--r>0?n[r-1]:-1,c=h=!1),t=!0)),o++;t&&this.diff_cleanupMerge(e)},i.prototype.diff_cleanupMerge=function(e){e.push(new i.Diff(0,""));for(var t,n=0,r=0,a=0,o="",l="";n<e.length;)switch(e[n][0]){case 1:a++,l+=e[n][1],n++;break;case -1:r++,o+=e[n][1],n++;break;case 0:r+a>1?(0!==r&&0!==a&&(0!==(t=this.diff_commonPrefix(l,o))&&(n-r-a>0&&0==e[n-r-a-1][0]?e[n-r-a-1][1]+=l.substring(0,t):(e.splice(0,0,new i.Diff(0,l.substring(0,t))),n++),l=l.substring(t),o=o.substring(t)),0!==(t=this.diff_commonSuffix(l,o))&&(e[n][1]=l.substring(l.length-t)+e[n][1],l=l.substring(0,l.length-t),o=o.substring(0,o.length-t))),n-=r+a,e.splice(n,r+a),o.length&&(e.splice(n,0,new i.Diff(-1,o)),n++),l.length&&(e.splice(n,0,new i.Diff(1,l)),n++),n++):0!==n&&0==e[n-1][0]?(e[n-1][1]+=e[n][1],e.splice(n,1)):n++,a=0,r=0,o="",l=""}""===e[e.length-1][1]&&e.pop();var s=!1;for(n=1;n<e.length-1;)0==e[n-1][0]&&0==e[n+1][0]&&(e[n][1].substring(e[n][1].length-e[n-1][1].length)==e[n-1][1]?(e[n][1]=e[n-1][1]+e[n][1].substring(0,e[n][1].length-e[n-1][1].length),e[n+1][1]=e[n-1][1]+e[n+1][1],e.splice(n-1,1),s=!0):e[n][1].substring(0,e[n+1][1].length)==e[n+1][1]&&(e[n-1][1]+=e[n+1][1],e[n][1]=e[n][1].substring(e[n+1][1].length)+e[n+1][1],e.splice(n+1,1),s=!0)),n++;s&&this.diff_cleanupMerge(e)},i.prototype.diff_xIndex=function(e,t){var n,r=0,i=0,a=0,o=0;for(n=0;n<e.length&&(1!==e[n][0]&&(r+=e[n][1].length),-1!==e[n][0]&&(i+=e[n][1].length),!(r>t));n++)a=r,o=i;return e.length!=n&&-1===e[n][0]?o:o+(t-a)},i.prototype.diff_prettyHtml=function(e){for(var t=[],n=/&/g,r=/</g,i=/>/g,a=/\n/g,o=0;o<e.length;o++){var l=e[o][0],s=e[o][1].replace(n,"&").replace(r,"<").replace(i,">").replace(a,"¶<br>");switch(l){case 1:t[o]='<ins style="background:#e6ffe6;">'+s+"</ins>";break;case -1:t[o]='<del style="background:#ffe6e6;">'+s+"</del>";break;case 0:t[o]="<span>"+s+"</span>"}}return t.join("")},i.prototype.diff_text1=function(e){for(var t=[],n=0;n<e.length;n++)1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")},i.prototype.diff_text2=function(e){for(var t=[],n=0;n<e.length;n++)-1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")},i.prototype.diff_levenshtein=function(e){for(var t=0,n=0,r=0,i=0;i<e.length;i++){var a=e[i][0],o=e[i][1];switch(a){case 1:n+=o.length;break;case -1:r+=o.length;break;case 0:t+=Math.max(n,r),n=0,r=0}}return t+Math.max(n,r)},i.prototype.diff_toDelta=function(e){for(var t=[],n=0;n<e.length;n++)switch(e[n][0]){case 1:t[n]="+"+encodeURI(e[n][1]);break;case -1:t[n]="-"+e[n][1].length;break;case 0:t[n]="="+e[n][1].length}return t.join(" ").replace(/%20/g," ")},i.prototype.diff_fromDelta=function(e,t){for(var n=[],r=0,a=0,o=t.split(/\t/g),l=0;l<o.length;l++){var s=o[l].substring(1);switch(o[l].charAt(0)){case"+":try{n[r++]=new i.Diff(1,decodeURI(s))}catch(e){throw Error("Illegal escape in diff_fromDelta: "+s)}break;case"-":case"=":var c=parseInt(s,10);if(isNaN(c)||c<0)throw Error("Invalid number in diff_fromDelta: "+s);var h=e.substring(a,a+=c);"="==o[l].charAt(0)?n[r++]=new i.Diff(0,h):n[r++]=new i.Diff(-1,h);break;default:if(o[l])throw Error("Invalid diff operation in diff_fromDelta: "+o[l])}}if(a!=e.length)throw Error("Delta length ("+a+") does not equal source text length ("+e.length+").");return n},i.prototype.match_main=function(e,t,n){if(null==e||null==t||null==n)throw Error("Null input. (match_main)");return(n=Math.max(0,Math.min(n,e.length)),e==t)?0:e.length?e.substring(n,n+t.length)==t?n:this.match_bitap_(e,t,n):-1},i.prototype.match_bitap_=function(e,t,n){if(t.length>this.Match_MaxBits)throw Error("Pattern too long for this browser.");var r,i,a,o=this.match_alphabet_(t),l=this;function s(e,r){var i=e/t.length,a=Math.abs(n-r);return l.Match_Distance?i+a/l.Match_Distance:a?1:i}var c=this.Match_Threshold,h=e.indexOf(t,n);
1-1!=h&&(c=Math.min(s(0,h),c),-1!=(h=e.lastIndexOf(t,n+t.length))&&(c=Math.min(s(0,h),c)));var f=1<<t.length-1;h=-1;for(var d=t.length+e.length,p=0;p<t.length;p++){for(r=0,i=d;r<i;)s(p,n+i)<=c?r=i:d=i,i=Math.floor((d-r)/2+r);d=i;var u=Math.max(1,n-i+1),g=Math.min(n+i,e.length)+t.length,m=Array(g+2);m[g+1]=(1<<p)-1;for(var y=g;y>=u;y--){var k=o[e.charAt(y-1)];if(0===p?m[y]=(m[y+1]<<1|1)&k:m[y]=(m[y+1]<<1|1)&k|((a[y+1]|a[y])<<1|1)|a[y+1],m[y]&f){var _=s(p,y-1);if(_<=c){if(c=_,(h=y-1)>n)u=Math.max(1,2*n-h);else break}}}if(s(p+1,n)>c)break;a=m}return h},i.prototype.match_alphabet_=function(e){for(var t={},n=0;n<e.length;n++)t[e.charAt(n)]=0;for(var n=0;n<e.length;n++)t[e.charAt(n)]|=1<<e.length-n-1;return t},i.prototype.patch_addContext_=function(e,t){if(0!=t.length){if(null===e.start2)throw Error("patch not initialized");for(var n=t.substring(e.start2,e.start2+e.length1),r=0;t.indexOf(n)!=t.lastIndexOf(n)&&n.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)r+=this.Patch_Margin,n=t.substring(e.start2-r,e.start2+e.length1+r);r+=this.Patch_Margin;var a=t.substring(e.start2-r,e.start2);a&&e.diffs.unshift(new i.Diff(0,a));var o=t.substring(e.start2+e.length1,e.start2+e.length1+r);o&&e.diffs.push(new i.Diff(0,o)),e.start1-=a.length,e.start2-=a.length,e.length1+=a.length+o.length,e.length2+=a.length+o.length}},i.prototype.patch_make=function(e,t,n){if("string"==typeof e&&"string"==typeof t&&void 0===n)r=e,(a=this.diff_main(r,t,!0)).length>2&&(this.diff_cleanupSemantic(a),this.diff_cleanupEfficiency(a));else if(e&&"object"==typeof e&&void 0===t&&void 0===n)a=e,r=this.diff_text1(a);else if("string"==typeof e&&t&&"object"==typeof t&&void 0===n)r=e,a=t;else if("string"==typeof e&&"string"==typeof t&&n&&"object"==typeof n)r=e,a=n;else throw Error("Unknown call format to patch_make.");if(0===a.length)return[];for(var r,a,o=[],l=new i.patch_obj,s=0,c=0,h=0,f=r,d=r,p=0;p<a.length;p++){var u=a[p][0],g=a[p][1];switch(s||0===u||(l.start1=c,l.start2=h),u){case 1:l.diffs[s++]=a[p],l.length2+=g.length,d=d.substring(0,h)+g+d.substring(h);break;case -1:l.length1+=g.length,l.diffs[s++]=a[p],d=d.substring(0,h)+d.substring(h+g.length);break;case 0:g.length<=2*this.Patch_Margin&&s&&a.length!=p+1?(l.diffs[s++]=a[p],l.length1+=g.length,l.length2+=g.length):g.length>=2*this.Patch_Margin&&s&&(this.patch_addContext_(l,f),o.push(l),l=new i.patch_obj,s=0,f=d,c=h)}1!==u&&(c+=g.length),-1!==u&&(h+=g.length)}return s&&(this.patch_addContext_(l,f),o.push(l)),o},i.prototype.patch_deepCopy=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n],a=new i.patch_obj;a.diffs=[];for(var o=0;o<r.diffs.length;o++)a.diffs[o]=new i.Diff(r.diffs[o][0],r.diffs[o][1]);a.start1=r.start1,a.start2=r.start2,a.length1=r.length1,a.length2=r.length2,t[n]=a}return t},i.prototype.patch_apply=function(e,t){if(0==e.length)return[t,[]];e=this.patch_deepCopy(e);var n=this.patch_addPadding(e);t=n+t+n,this.patch_splitMax(e);for(var r=0,i=[],a=0;a<e.length;a++){var o=e[a].start2+r,l=this.diff_text1(e[a].diffs),s=-1;if(l.length>this.Match_MaxBits?-1!=(h=this.match_main(t,l.substring(0,this.Match_MaxBits),o))&&(-1==(s=this.match_main(t,l.substring(l.length-this.Match_MaxBits),o+l.length-this.Match_MaxBits))||h>=s)&&(h=-1):h=this.match_main(t,l,o),-1==h)i[a]=!1,r-=e[a].length2-e[a].length1;else if(i[a]=!0,r=h-o,f=-1==s?t.substring(h,h+l.length):t.substring(h,s+this.Match_MaxBits),l==f)t=t.substring(0,h)+this.diff_text2(e[a].diffs)+t.substring(h+l.length);else{var c=this.diff_main(l,f,!1);if(l.length>this.Match_MaxBits&&this.diff_levenshtein(c)/l.length>this.Patch_DeleteThreshold)i[a]=!1;else{this.diff_cleanupSemanticLossless(c);for(var h,f,d,p=0,u=0;u<e[a].diffs.length;u++){var g=e[a].diffs[u];0!==g[0]&&(d=this.diff_xIndex(c,p)),1===g[0]?t=t.substring(0,h+d)+g[1]+t.substring(h+d):-1===g[0]&&(t=t.substring(0,h+d)+t.substring(h+this.diff_xIndex(c,p+g[1].length))),-1!==g[0]&&(p+=g[1].length)}}}}return[t=t.substring(n.length,t.length-n.length),i]},i.prototype.patch_addPadding=function(e){for(var t=this.Patch_Margin,n="",r=1;r<=t;r++)n+=String.fromCharCode(r);for(var r=0;r<e.length;r++)e[r].start1+=t,e[r].start2+=t;var a=e[0],o=a.diffs;if(0==o.length||0!=o[0][0])o.unshift(new i.Diff(0,n)),a.start1-=t,a.start2-=t,a.length1+=t,a.length2+=t;else if(t>o[0][1].length){var l=t-o[0][1].length;o[0][1]=n.substring(o[0][1].length)+o[0][1],a.start1-=l,a.start2-=l,a.length1+=l,a.length2+=l}if(0==(o=(a=e[e.length-1]).diffs).length||0!=o[o.length-1][0])o.push(new i.Diff(0,n)),a.length1+=t,a.length2+=t;else if(t>o[o.length-1][1].length){var l=t-o[o.length-1][1].length;o[o.length-1][1]+=n.substring(0,l),a.length1+=l,a.length2+=l}return n},i.prototype.patch_splitMax=function(e){for(var t=this.Match_MaxBits,n=0;n<e.length;n++)if(!(e[n].length1<=t)){var r=e[n];e.splice(n--,1);for(var a=r.start1,o=r.start2,l="";0!==r.diffs.length;){var s=new i.patch_obj,c=!0;for(s.start1=a-l.length,s.start2=o-l.length,""!==l&&(s.length1=s.length2=l.length,s.diffs.push(new i.Diff(0,l)));0!==r.diffs.length&&s.length1<t-this.Patch_Margin;){var h=r.diffs[0][0],f=r.diffs[0][1];1===h?(s.length2+=f.length,o+=f.length,s.diffs.push(r.diffs.shift()),c=!1):-1===h&&1==s.diffs.length&&0==s.diffs[0][0]&&f.length>2*t?(s.length1+=f.length,a+=f.length,c=!1,s.diffs.push(new i.Diff(h,f)),r.diffs.shift()):(f=f.substring(0,t-s.length1-this.Patch_Margin),s.length1+=f.length,a+=f.length,0===h?(s.length2+=f.length,o+=f.length):c=!1,s.diffs.push(new i.Diff(h,f)),f==r.diffs[0][1]?r.diffs.shift():r.diffs[0][1]=r.diffs[0][1].substring(f.length))}
1l=(l=this.diff_text2(s.diffs)).substring(l.length-this.Patch_Margin);var d=this.diff_text1(r.diffs).substring(0,this.Patch_Margin);""!==d&&(s.length1+=d.length,s.length2+=d.length,0!==s.diffs.length&&0===s.diffs[s.diffs.length-1][0]?s.diffs[s.diffs.length-1][1]+=d:s.diffs.push(new i.Diff(0,d))),c||e.splice(++n,0,s)}}},i.prototype.patch_toText=function(e){for(var t=[],n=0;n<e.length;n++)t[n]=e[n];return t.join("")},i.prototype.patch_fromText=function(e){var t=[];if(!e)return t;for(var n=e.split("\n"),r=0,a=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;r<n.length;){var o=n[r].match(a);if(!o)throw Error("Invalid patch string: "+n[r]);var l=new i.patch_obj;for(t.push(l),l.start1=parseInt(o[1],10),""===o[2]?(l.start1--,l.length1=1):"0"==o[2]?l.length1=0:(l.start1--,l.length1=parseInt(o[2],10)),l.start2=parseInt(o[3],10),""===o[4]?(l.start2--,l.length2=1):"0"==o[4]?l.length2=0:(l.start2--,l.length2=parseInt(o[4],10)),r++;r<n.length;){var s=n[r].charAt(0);try{var c=decodeURI(n[r].substring(1))}catch(e){throw Error("Illegal escape in patch_fromText: "+c)}if("-"==s)l.diffs.push(new i.Diff(-1,c));else if("+"==s)l.diffs.push(new i.Diff(1,c));else if(" "==s)l.diffs.push(new i.Diff(0,c));else if("@"==s)break;else if(""===s);else throw Error('Invalid patch mode "'+s+'" in: '+c);r++}}return t},i.patch_obj=function(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0},i.patch_obj.prototype.toString=function(){e=0===this.length1?this.start1+",0":1==this.length1?this.start1+1:this.start1+1+","+this.length1;for(var e,t,n=["@@ -"+e+" +"+(0===this.length2?this.start2+",0":1==this.length2?this.start2+1:this.start2+1+","+this.length2)+" @@\n"],r=0;r<this.diffs.length;r++){switch(this.diffs[r][0]){case 1:t="+";break;case -1:t="-";break;case 0:t=" "}n[r+1]=t+encodeURI(this.diffs[r][1])+"\n"}return n.join("").replace(/%20/g," ")},r.exports=i,r.exports.diff_match_patch=i,r.exports.DIFF_DELETE=-1,r.exports.DIFF_INSERT=1,r.exports.DIFF_EQUAL=0;let eE=new ew.diff_match_patch;function eT(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return{type:"diffMatchPatch",path:n,value:eE.patch_make(e,t).map(e=>e.toString()).join("")}}function eN(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return{type:"insert",path:n,position:t,items:e}}function eD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{type:"set",path:t,value:e}}function eA(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:"unset",path:e}}let eC=ea("operationToPatches");
1function eL(e,t,n){let r;let i=[e.path[0]];if(!t)return null;let a=t[i[0]];if(!a)return null;let o=[{_key:a._key}];if(a._type!==n.block.name)return o;let l=e.path.slice(0,2),s=Array.isArray(a.children)&&a.children[l[1]];return s&&(r=["children",{_key:s._key}]),r?[...o,...r]:o}function eS(e,t){if(!t)return[];let[n,r]=Array.from(M.ML.nodes(t,{at:[],match:t=>(0,j.Fd)(e.path[0])&&t._key===e.path[0]._key}))[0]||[void 0,void 0];if(!n||!M.W_.isElement(n))return[];if(t.isVoid(n))return r;let i=[e.path[2]],a=n.children.findIndex(e=>T()([{_key:e._key}],i));if(a>=0&&n.children[a]){let e=n.children[a];return M.W_.isElement(e)&&t.isVoid(e)?r.concat(a).concat(0):r.concat(a)}return r}function eP(e,t,n){if(!t)return null;let r=null,i=null,a=t.anchor&&eL(t.anchor,e,n);a&&t.anchor&&(r={path:a,offset:t.anchor.offset});let o=t.focus&&eL(t.focus,e,n);return o&&t.focus&&(i={path:o,offset:t.focus.offset}),r&&i?{anchor:r,focus:i}:null}function eR(e,t){if(!e||!t)return null;let n={path:eS(e.anchor,t),offset:e.anchor.offset},r={path:eS(e.focus,t),offset:e.focus.offset};return n&&r?{anchor:n,focus:r}:null}let eI=ea("API:editable"),eB=new WeakMap;function ej(e,t){eB.set(e,!0),t(),eB.set(e,!1)}let eO=new WeakMap;function eY(e,t){let n=eO.get(e);eO.set(e,!1),t(),eO.set(e,n)}let eW="before",ez="after";function eJ(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce((e,t)=>e.concat(t),[])}let eF=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty),eV={replace:(e,t)=>t,set:(e,t)=>t,setIfMissing:(e,t)=>void 0===e?t:e,unset(e,t){},inc:(e,t)=>e+t,dec:(e,t)=>e-t},eU=Object.keys(eV),eH=new ew.diff_match_patch,e$={replace:(e,t)=>t,set:(e,t)=>t,setIfMissing:(e,t)=>void 0===e?t:e,unset(e,t){},diffMatchPatch:(e,t)=>eH.patch_apply(eH.patch_fromText(t),e)[0]},eq=Object.keys(e$);function eZ(e,t){return Array.isArray(e)?function(e,t){let n=e.slice();if(0===t.path.length){if("setIfMissing"===t.type){if(!Array.isArray(t.value))throw Error("Cannot set value of an array to a non-array");return void 0===e?t.value:e}if("set"===t.type){if(!Array.isArray(t.value))throw Error("Cannot set value of an array to a non-array");return t.value}if("unset"===t.type)return;if("move"===t.type){if(!t.value||!eF(t.value,"from")||!eF(t.value,"to"))throw Error('Invalid value of \'move\' patch. Expected a value with "from" and "to" indexes, instead got: '.concat(JSON.stringify(t.value)));return function(e,t,n){let r=e.slice(),i=r[t];return r.splice(t,1),r.splice(n,0,i),r}(n,t.value.from,t.value.to)}throw Error("Invalid array operation: ".concat(t.type))}let[r,...i]=t.path,a=function(e,t){if("number"==typeof t)return t;let n=F()(e,t);return -1!==n&&n}(e,r);if(!1===a)return n;if(0===i.length){if("insert"===t.type){let{position:n,items:r}=t;return function(e,t,n){if(t!==eW&&t!==ez)throw Error('Invalid position "'.concat(t,'", must be either ').concat(eW," or ").concat(ez));for(var r=arguments.length,i=Array(r>3?r-3:0),a=3;a<r;a++)i[a-3]=arguments[a];let o=eJ(...i);if(0===e.length)return o;let l=e.length,s=Math.abs((l+n)%l)%l,c=e.slice();return c.splice("after"===t?s+1:s,0,...eJ(o)),c}(e,n,a,r)}if("unset"===t.type){if("number"!=typeof a)throw Error('Expected array index to be a number, instead got "'.concat(a,'"'));return n.splice(a,1),n}}return n[a]=eZ(n[a],{...t,path:i}),n}(e,t):z()(e)?function(e,t){if(!eq.includes(t.type))throw Error('Received patch of unsupported type: "'.concat(JSON.stringify(t.type),'" for string. This is most likely a bug.'));if(t.path.length>0)throw Error('Cannot apply deep operations on string values. Received patch with type "'.concat(t.type,'" and path "').concat(t.path.join("."),' that targeted the value "').concat(JSON.stringify(e),'"'));let n=e$[t.type];if(n)return n(e,t.value);throw Error("Unknown patch type")}(e,t):Y()(e)?function(e,t){let n=$()(e);if(0===t.path.length){if("set"===t.type){if(!Y()(t.value))throw Error("Cannot set value of an object to a non-object");return t.value}if("unset"===t.type)return;if("setIfMissing"===t.type)return void 0===e?t.value:e;throw Error("Invalid object operation: ".concat(t.type))}let[r,...i]=t.path;if("string"!=typeof r)throw Error("Expected field name to be a string, instad got: ".concat(r));return 0===i.length&&"unset"===t.type?U()(n,r):(n[r]=eZ(n[r],{...t,path:i}),n)}(e,t):function(e,t){if(!eU.includes(t.type))throw Error('Received patch of unsupported type: "'.concat(JSON.stringify(t.type),'" for primitives. This is most likely a bug.'));if(t.path.length>0)throw Error('Cannot apply deep operations on primitive values. Received patch with type "'.concat(t.type,'" and path "').concat(t.path.map(e=>JSON.stringify(e)).join("."),' that targeted the value "').concat(JSON.stringify(e),'"'));return eV[t.type](e,t.value)}(e,t)}let eG=ea("operationToPatches"),eK=new ew.diff_match_patch;function eX(e){return"object"==typeof e&&"_key"in e}function eQ(e){let t=null;
1return e.concat("").reverse().forEach(e=>{eX(e)&&(t=e._key)}),t}function e0(e,t){eG("Children ".concat(t,":"),JSON.stringify(e.children,null,2)),eG("Selection ".concat(t,": "),JSON.stringify(e.selection,null,2))}let e1=ea("plugin:withUndoRedo"),e2=new ew.diff_match_patch,e3=new WeakMap,e6=new WeakMap,e5=e=>e6.get(e),e9=e=>!!eO.get(e)&&e3.get(e);function e4(e,t,n){let r={...n};if("insert"===t.type&&1===t.path.length)return[e7(e,t,n,t.items.length)];if("unset"===t.type&&1===t.path.length)return[e7(e,t,n,-1)];if("unset"===t.type&&0===t.path.length)return e1("Adjusting selection for unset everything patch and ".concat(n.type," operation")),[n];if("diffMatchPatch"===t.type){let i=e.children.findIndex(e=>T()({_key:e._key},t.path[0])),a=e.children[i];if(M.W_.isElement(a)&&Array.isArray(a.children)){let e=a.children.findIndex(e=>T()({_key:e._key},t.path[2])),o=e2.patch_fromText(t.value)[0];if(!o)return e1("Could not parse diffMatchPatch",t),[n];let l=o.length2-o.length1,s=o.diffs.some(e=>-1===e[0]);if("split_node"===n.type&&n.path.length>1){let e=r;return s?e.position-=l:e.position+=l,[e]}if(("insert_text"===n.type||"remove_text"===n.type)&&M.y$.isPath(n.path)&&void 0!==n.path[0]&&n.path[0]===i&&n.path[1]===e){if("insert_text"===n.type){let e=0;for(let t of o.diffs)if(0===t[0]&&(e=t[1].length),1===t[0])break;if(null!==o.start1&&e+o.start1<=n.offset){let e=r;e.offset+=l,r=e}return[r]}if("remove_text"===n.type){let e=0;for(let t of o.diffs)if(0===t[0]&&(e=t[1].length),-1===t[0])break;if(null!==o.start1&&e+o.start1<=n.offset){let e=r;e.offset-=l,r=e}return[r]}}}}return[n]}function e7(e,t,n,r){let i=e.children.findIndex(e=>T()({_key:e._key},t.path[0]));if(i>=0&&"set_selection"!==n.type&&Array.isArray(n.path)&&void 0!==n.path[0]&&n.path[0]>=i+r){let e={...n},i=[n.path[0]+r,...n.path.slice(1)];return e1("Adjusting ".concat(n.type," for block ").concat(t.type),n.path,i),e.path=i,e}return n}let e8=(e,t)=>!!("set_selection"===e.type||t&&"insert_text"===e.type&&"insert_text"===t.type&&e.offset===t.offset+t.text.length&&M.y$.equals(e.path,t.path)&&" "!==e.text||t&&"remove_text"===e.type&&"remove_text"===t.type&&e.offset+e.text.length===t.offset&&M.y$.equals(e.path,t.path)),te=(e,t)=>"set_selection"!==e.type||null!==e.newProperties,tt=(e,t)=>!!t&&"set_selection"===e.type&&"set_selection"===t.type,tn=e=>"set_selection"!==e.type;function tr(e,t){let n=e9(e);e3.set(e,!1),t(),e3.set(e,n)}let ti=ea("plugin:withPatches"),ta=ea("plugin:withPlaceholderBlock"),to=ea("plugin:withPortableTextBlockStyle"),tl=ea("plugin:withPortableTextLists"),ts=ea("plugin:withPortableTextMarkModel"),tc=ea("plugin:withPortableTextSelections"),th=ea("plugin:withSchemaTypes"),tf=ea("plugin:withUtils"),td=ea("plugin:withHotKeys"),tp={marks:{"mod+b":"strong","mod+i":"em","mod+u":"underline","mod+'":"code"},custom:{}};function tu(e,t,n){let r=null,i=!0,a=[t.span.name,...t.inlineObjects.map(e=>e.name)],o=[t.block.name,...t.blockObjects.map(e=>e.name)];return void 0===e?{valid:!0,resolution:null}:Array.isArray(e)&&0!==e.length?(e.some((e,l)=>{if(!Y()(e))return r={patches:[eA([l])],description:"Block must be an object, got ".concat(String(e)),action:"Unset invalid item",item:e},!0;if(!e._key)return r={patches:[eD({...e,_key:n()},[l])],description:"Block at index ".concat(l," is missing required _key."),action:"Set the block with a random _key value",item:e},!0;if(!e._type||!o.includes(e._type)){if("block"===e._type){let n=t.block.name;return r={patches:[eD({...e,_type:n},[{_key:e._key}])],description:"Block with _key '".concat(e._key,"' has invalid type name '").concat(e._type,"'. According to the schema, the block type name is '").concat(n,"'"),action:"Use type '".concat(n,"'"),item:e},!0}return r={patches:[eA([{_key:e._key}])],description:"Block with _key '".concat(e._key,"' has invalid _type '").concat(e._type,"'"),action:"Remove the block",item:e},!0}if(e._type===t.block.name){if(!e.children)return r={patches:[eA([{_key:e._key}])],description:"Text block with _key '".concat(e._key,"' is missing required key 'children'."),action:"Remove the block",item:e},!0;if(!e.markDefs)return r={patches:[eD({...e,markDefs:[]},[{_key:e._key}])],description:"Block is missing required key 'markDefs'.",action:"Add empty markDefs array",item:e},!0;let o=Z()(B()(e.children.filter(e=>e._type===t.span.name).map(e=>e.marks||[]))).filter(e=>!t.decorators.map(e=>e.value).includes(e)).filter(t=>!!e.markDefs&&!e.markDefs.find(e=>e._key===t));if(o.length>0){let n=e.children.filter(e=>e._type===t.span.name&&Array.isArray(e.marks)&&e.marks.some(e=>o.includes(e)));if(n)return r={patches:n.map(t=>eD((t.marks||[]).filter(e=>
1!o.includes(e)),[{_key:e._key},"children",{_key:t._key},"marks"])),description:"Block with _key '".concat(e._key,"' contains marks (").concat(o.join(", "),") not supported by the current content model."),action:"Remove invalid marks",item:e},!0}if(e.children&&0===e.children.length)return r={patches:[eN([{_type:t.span.name,_key:n(),text:""}],"after",[{_key:e._key},"children",0])],description:"Children for text block with _key '".concat(e._key,"' is empty."),action:"Insert an empty text",item:e},!0;e.children.some((i,o)=>i._key?i._type&&!1!==a.includes(i._type)?i._type===t.span.name&&void 0===i.text&&(r={patches:[eD({...i,text:""},[{_key:e._key},"children",{_key:i._key}])],description:"Child with _key '".concat(i._key,"' in block with key '").concat(e._key,"' is missing text property!"),action:"Write an empty .text to the object",item:e},!0):(r={patches:[eA([{_key:e._key},"children",{_key:i._key}])],description:"Child with _key '".concat(i._key,"' in block with key '").concat(e._key,"' has invalid '_type' property (").concat(i._type,")."),action:"Remove the object",item:e},!0):(r={patches:[eD({...i,_key:n()},[{_key:e._key},"children",o])],description:"Child at index ".concat(o," is missing required _key in block with _key ").concat(e._key,"."),action:"Set a new random _key on the object",item:e},!0))&&(i=!1)}return!1})&&(i=!1),{valid:i,resolution:r}):{valid:!1,resolution:{patches:[eA([])],description:"Editor value must be an array of Portable Text blocks, or undefined.",action:"Unset the value",item:e}}}let tg=ea("plugin:withInsertData"),tm={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function ty(e,t){if(!e.selection)return!1;let[n,r]=M.ML.node(e,e.selection,{depth:1});if(e.isTextBlock(n)&&e.isTextBlock(t[0])){let{markDefs:i}=n;return tg("Mixing markDefs of focusBlock and fragments[0] block",i,t[0].markDefs),M.YR.setNodes(e,{markDefs:[...t[0].markDefs||[],...i||[]]},{at:r,mode:"lowest",voids:!1}),!0}return!1}let tk=new WeakMap,tv=(e,t)=>{var n;let{keyGenerator:r,portableTextEditor:i,patches$:a,readOnly:o,maxBlocks:l,isPending:s}=t,{schemaTypes:c,change$:h}=i;e.subscriptions=[],e.destroy?e.destroy():tk.set(e,{apply:e.apply,onChange:e.onChange,normalizeNode:e.normalizeNode});let y=function(e){let t=e.block.name;return{insertNodePatch:function(e,n,r){let i=r[n.path[0]];if(1===n.path.length){let e=0===n.path[0]?"before":"after",a=r[n.path[0]-1],o=0===n.path[0]?null==i?void 0:i._key:null==a?void 0:a._key;return o?[eN([eb([n.node],t)[0]],e,[{_key:o}])]:[eM(r,[]),eN([eb([n.node],t)[0]],"before",[n.path[0]])]}if(2===n.path.length&&e.children[n.path[0]]){if(!e.isTextBlock(i))throw Error("Invalid block");let r=0!==i.children.length&&i.children[n.path[1]-1]?"after":"before";return[eN([eb([{_key:"bogus",_type:t,children:[n.node]}],t)[0].children[0]],r,[{_key:i._key},"children",i.children.length<=1||!i.children[n.path[1]-1]?0:{_key:i.children[n.path[1]-1]._key}])]}throw Error("Unexpected path encountered: ".concat(JSON.stringify(n.path)," - ").concat(JSON.stringify(r)))},insertTextPatch:function(e,t,n){eC("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 a=[{_key:r._key},"children",{_key:i._key},"text"],o=n[t.path[0]],l=e.isTextBlock(o)&&o.children[t.path[1]],s=eT(e.isTextSpan(l)?l.text:"",i.text,a);return s.value.length?[s]:[]},mergeNodePatch:function(e,n,r){let i=[];if(1===n.path.length){let a=r[n.path[0]],o=a&&a._key;if(o){let r=eb([e.children[n.path[0]-1]],t)[0];i.push(eD(r,[{_key:r._key}])),i.push(eA([{_key:o}]))}else throw Error("Target key not found!")}else if(2===n.path.length){let t=r[n.path[0]],a=e.isTextBlock(t)&&t.children[n.path[1]]||void 0,o=e.children[n.path[0]];if(!e.isTextBlock(o))throw Error("Invalid block");let l=o.children[n.path[1]-1];e.isTextSpan(l)&&(i.push(eD(l.text,[{_key:t._key},"children",{_key:l._key},"text"])),a&&i.push(eA([{_key:t._key},"children",{_key:a._key}])))}else throw Error("Unexpected path encountered: ".concat(JSON.stringify(n.path)));return i},moveNodePatch:function(e,n,r){let i=[],a=r[n.path[0]],o=r[n.newPath[0]];if(1===n.path.length){let e=n.path[0]>n.newPath[0]?"before":"after";i.push(eA([{_key:a._key}])),i.push(eN([eb([a],t)[0]],e,[{_key:o._key}]))}else if(2===n.path.length&&e.isTextBlock(a)&&e.isTextBlock(o)){let e=a.children[n.path[1]],r=o.children[n.newPath[1]],l=n.newPath[1]===o.children.length?"after":"before",s=eb([a],t)[0].children[n.path[1]];i.push(eA([{_key:a._key},"children",{_key:e._key}])),i.push(eN([s],l,[{_key:o._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[eA([{_key:r._key}])];throw Error("Block not found")}if(2===t.path.length){let n=e.isTextBlock(r)&&r.children&&r.children[t.path[1]];return n?[eA([{_key:r._key},"children",{_key:n._key}])]:(eC("Span not found in editor trying to remove node"),[])}throw Error("Unexpected path encountered: ".concat(JSON.stringify(t.path)))},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,a=e.isTextSpan(i)?i:void 0;if(i&&!a)throw Error("Expected span");if(!a)throw Error("Could not find child");let o=[{_key:r._key},"children",{_key:a._key},"text"],l=n[t.path[0]],s=e.isTextBlock(l)&&l.children[t.path[1]],c=eT(e.isTextSpan(s)&&s.text||"",a.text,o);return c.value?[c]:[]},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");return[eD(eb([C()({...e.children[n.path[0]],...n.newProperties},S())],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,a=[];
1return Object.keys(n.newProperties).forEach(e=>{let t=R()(n.newProperties,e);a.push(eD(t,[{_key:r},"children",{_key:i},e]))}),a}throw Error("Could not find a valid child")}throw Error("Could not find a valid block")}throw Error("Unexpected path encountered: ".concat(JSON.stringify(n.path)))},splitNodePatch:function(e,n,r){let i=[],a=e.children[n.path[0]];if(!e.isTextBlock(a))throw Error("Block with path ".concat(JSON.stringify(n.path[0])," is not a text block and can't be split"));if(1===n.path.length){let o=r[n.path[0]];if(e.isTextBlock(o)){let r=eb([e.children[n.path[0]+1]],t)[0];r&&(i.push(eN([r],"after",[{_key:a._key}])),o.children.slice(n.position).forEach(e=>{let t=[{_key:o._key},"children",{_key:e._key}];i.push(eA(t))}))}return i}if(2===n.path.length){let r=a.children[n.path[1]];if(e.isTextSpan(r)){let e=eb([{...a,children:a.children.slice(n.path[1]+1,n.path[1]+2)}],t)[0].children;i.push(eN(e,"after",[{_key:a._key},"children",{_key:r._key}])),i.push(eD(r.text,[{_key:a._key},"children",{_key:r._key},"text"]))}}return i}}}(c),k=function(e){eB.set(e,!1);let{apply:t,normalizeNode:n}=e;return e.apply=n=>{if("split_node"===n.type&&(n.properties={...n.properties,_key:r()}),"insert_node"===n.type){let t=!eB.get(e)||!("_key"in n.node);M.ML.isEditor(n.node)||(n.node={...n.node,...t?{_key:r()}:{}})}t(n)},e.normalizeNode=t=>{let[i,a]=t;if(M.W_.isElement(i)&&i._type===c.block.name){for(let[t,n]of(i._key||M.YR.setNodes(e,{_key:r()},{at:a}
1),M.NB.children(e,a)))if(!t._key){M.YR.setNodes(e,{_key:r()},{at:n});return}}n(t)},e},_=function(e){e.isTextBlock=e=>(0,j.DG)(e)&&e._type===c.block.name,e.isTextSpan=e=>(0,j.NG)(e)&&e._type==c.span.name,e.isListBlock=e=>(0,j.KA)(e)&&e._type===c.block.name,e.isVoid=e=>c.block.name!==e._type&&(c.blockObjects.map(e=>e.name).includes(e._type)||c.inlineObjects.map(e=>e.name).includes(e._type)),e.isInline=e=>c.inlineObjects.map(e=>e.name).includes(e._type)&&"__inline"in e&&!0===e.__inline;let{apply:t}=e;return e.apply=e=>{if("insert_node"===e.type&&2===e.path.length&&M.xv.isText(e.node)&&void 0===e.node._type){let t={...e.node,_type:"span"};e.node=t,th("Setting span type to child without a type",e)}t(e)},e},b=function(e){return i.setEditable({focus:()=>{if(!e.selection){let t={path:[0,0],offset:0};M.YR.select(e,{focus:t,anchor:t}),e.onChange()}w.F3.focus(e)},blur:()=>{w.F3.blur(e)},toggleMark:t=>{e.pteToggleMark(t)},toggleList:t=>{e.pteToggleListItem(t)},toggleBlockStyle:t=>{e.pteToggleBlockStyle(t)},isMarkActive:t=>{try{return e.pteIsMarkActive(t)}catch(e){return console.warn(e),!1}},marks:()=>({...M.ML.marks(e)||{}}).marks||[],undo:()=>e.undo(),redo:()=>e.redo(),select:t=>{let n=eR(t,e);n?M.YR.select(e,n):M.YR.deselect(e),e.onChange()},focusBlock:()=>{if(e.selection)try{let[t]=Array.from(M.ML.nodes(e,{at:e.selection.focus,match:t=>M.ML.isBlock(e,t)}))[0]||[void 0];if(t)return eb([t],c.block.name,em.get(e))[0]}catch(e){}},focusChild:()=>{if(e.selection)try{let[t]=Array.from(M.ML.nodes(e,{mode:"lowest",at:e.selection.focus,match:e=>void 0!==e._type,voids:!0}))[0]||[void 0];if(t&&!M.ML.isBlock(e,t)){let n={_key:"pseudo",_type:c.block.name,children:[t]},r=eb([n],c.block.name,em.get(e));if(e.isTextBlock(r[0]))return r[0].children[0]}}catch(e){}},insertChild:(t,n)=>{var a;if(!e.selection)throw Error("The editor has no selection");let[o]=Array.from(M.ML.nodes(e,{at:e.selection.focus,match:t=>M.ML.isBlock(e,t)}))[0]||[void 0];if(!o)throw Error("No focus block");if(o&&M.ML.isVoid(e,o))throw Error("Can't insert childs into block objects");let l=e_([{_key:r(),_type:c.block.name,children:[{_key:r(),_type:t.name,...n||{}}]}],i)[0].children[0];return M.ML.insertNode(e,l),e.onChange(),(null==(a=eP(eb(e.children,c.block.name,em.get(e)),e.selection,c))?void 0:a.focus.path)||[]},insertBlock:(t,n)=>{var a;if(!e.selection)throw Error("The editor has no selection");let o=e_([{_key:r(),_type:t.name,...n||{}}],i)[0];return M.ML.insertNode(e,o),e.onChange(),(null==(a=eP(eb(e.children,c.block.name,em.get(e)),e.selection,c))?void 0:a.focus.path)||[]},hasBlockStyle:t=>{try{return e.pteHasBlockStyle(t)}catch(e){return!1}},hasListStyle:t=>{try{return e.pteHasListStyle(t)}catch(e){return!1}},isVoid:e=>![c.block.name,c.span.name].includes(e._type),findByPath:t=>{let n=eR({focus:{path:t,offset:0},anchor:{path:t,offset:0}},e);if(n){let[r,i]=M.ML.node(e,n.focus.path.slice(0,1));if(r&&i&&"string"==typeof r._key){if(1===t.length&&1===n.focus.path.length)return[eb([r],c.block.name)[0],[{_key:r._key}]];let i=eb([r],c.block.name,em.get(e))[0];if(e.isTextBlock(i)){let e=i.children[n.focus.path[1]];if(e)return[e,[{_key:r._key},"children",{_key:e._key}]]}}}return[void 0,void 0]},findDOMNode:t=>{let n;try{let[r]=Array.from(M.ML.nodes(e,{at:[],match:e=>e._key===t._key})||[])[0]||[void 0];n=w.F3.toDOMNode(e,r)}catch(e){}return n},activeAnnotations:()=>{var t;if(!e.selection||e.selection.focus.path.length<2)return[];try{let n=[];for(let[r,i]of M.ML.nodes(e,{at:e.selection,match:e=>M.xv.isText(e)&&void 0!==e.marks&&Array.isArray(e.marks)&&e.marks.length>0})){let[a]=M.ML.node(e,i,{depth:1});e.isTextBlock(a)&&(null==(t=a.markDefs)||t.forEach(e=>{M.xv.isText(r)&&r.marks&&Array.isArray(r.marks)&&r.marks.includes(e._key)&&n.push(e)}))}return n}catch(e){return[]}},addAnnotation:(t,n)=>{let{selection:i}=e;if(i){let[a]=M.ML.node(e,i.focus,{depth:1});if(M.W_.isElement(a)&&a._type===c.block.name){let o=r();if(e.isTextBlock(a)){M.YR.setNodes(e,{markDefs:[...a.markDefs||[],{_type:t.name,_key:o,...n}]},{at:i.focus}),e.onChange(),M.e6.isCollapsed(i)&&(e.pteExpandToWord(),e.onChange());let[l]=M.ML.node(e,i.focus,{depth:2});if(e.selection){M.ML.withoutNormalizing(e,()=>{M.YR.setNodes(e,{},{match:M.xv.isText,split:!0}),e.selection&&M.xv.isText(l)&&(M.YR.setNodes(e,{marks:[...l.marks||[],o]},{at:e.selection,match:e=>e._type===c.span.name}),e.onChange())}),M.ML.normalize(e),e.onChange();let t=eP(eb(e.children,c.block.name,em.get(e)),e.selection,c);if(t&&"string"==typeof a._key)return M.ML.withoutNormalizing(e,()=>{e.selection&&(M.YR.insertNodes(e,[{_type:"span",text:"",marks:[],_key:r()}],{at:M.e6.end(e.selection)}),e.onChange())}),{spanPath:t.focus.path,markDefPath:[{_key:a._key},"markDefs",{_key:o}]}}}}}},delete:(t,n)=>{if(t){let r=eR(t,e);if(r){if(!(null==n?void 0:n.mode)||(null==n?void 0:n.mode)==="selected"){eI("Deleting content in selection"),M.YR.delete(e,{at:r,hanging:!0,voids:!0}),e.onChange();return}[...M.ML.nodes(e,{at:r,match:t=>(null==n?void 0:n.mode)==="blocks"?(eI("Deleting blocks touched by selection"),e.isTextBlock(t)||!e.isTextBlock(t)&&M.W_.isElement(t)):(eI("Deleting children touched by selection"),t._type===c.span.name||!e.isTextBlock(t)&&M.W_.isElement(t))}
1)].forEach(t=>{let[,n]=t;M.YR.removeNodes(e,{at:n,voids:!0,hanging:!0})}),e.onChange()}}},removeAnnotation:t=>{let{selection:n}=e;if(eI("Removing annotation",t),n){if(M.e6.isCollapsed(n)){let[t,r]=M.ML.node(e,n,{depth:2});M.xv.isText(t)&&t.marks&&"string"==typeof t.text&&(M.YR.select(e,r),n=e.selection)}M.ML.withoutNormalizing(e,()=>{n&&M.e6.isExpanded(n)&&(n=e.selection)&&(M.YR.setNodes(e,{},{match:M.xv.isText,split:!0}),e.onChange(),[...M.ML.nodes(e,{at:n,match:e=>M.xv.isText(e)&&void 0!==e.marks&&Array.isArray(e.marks)&&e.marks.length>0})].forEach(n=>{var r;let[i,a]=n,[o]=M.ML.node(e,a,{depth:1});e.isTextBlock(o)&&(null==(r=o.markDefs)||r.filter(e=>e._type===t.name).forEach(t=>{if(M.xv.isText(i)&&Array.isArray(i.marks)&&i.marks.includes(t._key)){let n=[...(i.marks||[]).filter(e=>e!==t._key)];M.YR.setNodes(e,{marks:n},{at:a,voids:!1,split:!1})}}))}))}),M.ML.normalize(e),e.onChange()}},getSelection:()=>{let t=null;if(e.selection){let n=ey.get(e.selection);if(n)return n;t=eP(eb(e.children,c.block.name,em.get(e)),e.selection,c),ey.set(e.selection,t)}return t},getValue:()=>eb(e.children,c.block.name,em.get(e)),isCollapsedSelection:()=>!!e.selection&&M.e6.isCollapsed(e.selection),isExpandedSelection:()=>!!e.selection&&M.e6.isExpanded(e.selection),insertBreak:()=>{e.insertBreak(),e.onChange()}}),e},x=function(e){let t,n,{change$:r,isPending:i,patches$:a,patchFunctions:o,readOnly:l,schemaTypes:s}=e,c=function(e,n){let r=!1;eG("\n\nNEW PATCH ============================================================="),eG(JSON.stringify(n,null,2));try{switch(n.type){case"insert":r=function(e,t){if(1===t.path.length){let{items:n,position:r}=t,i=e_(n,{schemaTypes:s},eg.get(e)),a=eQ(t.path),o=Math.max(0,e.children.findIndex((e,n)=>a?e._key===a:n===t.path[0])),l="after"===r?o+1:o;return eG("Inserting blocks at path [".concat(l,"]")),e0(e,"before"),M.YR.insertNodes(e,i,{at:[l]}),e0(e,"after"),!0}let{items:n,position:r}=t,i=eQ(t.path),a=e.children.findIndex((e,n)=>i?e._key===i:n===t.path[0]),o=e.children&&a>-1?e.children[a]:void 0,l=e.isTextBlock(o)?o.children.findIndex((e,n)=>eX(t.path[2])?e._key===t.path[2]._key:n===t.path[2]):0,c=o&&e_([{...o,children:n}],{schemaTypes:s},eg.get(e)),h=[a,"after"===r?l+1:l];return eG("Inserting children at path ".concat(h)),e0(e,"before"),c&&M.W_.isElement(c[0])&&M.YR.insertNodes(e,c[0].children,{at:h}),e0(e,"after"),!0}(e,n);break;case"unset":r=function(e,t,n){var r;if(0===t.path.length)return eG("Removing everything"),e0(e,"before"),M.YR.deselect(e),e.children.forEach((t,n)=>{M.YR.removeNodes(e,{at:[n]})}),e0(e,"after"),!0;if(1===t.path.length){let n=eQ(t.path),r=e.children.findIndex((e,r)=>n?e._key===n:r===t.path[0]);if(-1===r)return eG("Could not find block to unset at path ".concat(JSON.stringify(t.path))),!1;if(eG("Removing block at path [".concat(r,"]")),e0(e,"before"),e.selection&&e.selection.focus.path[0]===r&&e.children[r-1]){let t={path:[Math.max(e.selection.focus.path[0]-1,0)],offset:0};M.YR.select(e,{focus:t,anchor:t}),M.YR.move(e,{unit:"line"})}return M.YR.removeNodes(e,{at:[r]}),e0(e,"after"),!0}let i=e.children.findIndex((e,n)=>eX(t.path[0])?e._key===t.path[0]._key:n===t.path[0]),a=i>-1?e.children[i]:void 0;if(e.isTextBlock(a)&&"children"===t.path[1]&&3===t.path.length){let o=a.children.findIndex((e,n)=>eX(t.path[2])?e._key===t.path[2]._key:n===t.path[2]),l=[i,o],s=e.selection&&{...e.selection},c=T()(null==(r=e.selection)?void 0:r.focus.path,l);if(-1===o)return eG("Could not find child to unset at path ".concat(JSON.stringify(l))),!1;if(eG("Unsetting child at path ".concat(JSON.stringify(l))),e0(e,"before"),s&&c&&e.isTextBlock(a)&&o>=s.focus.path[1]){let t=a.children[o];if((null==n?void 0:n.type)==="set"&&"text"===n.path[3]&&"string"==typeof n.value&&e.isTextSpan(t)&&T()(n.value.slice(-t.text.length),a.children[o].text)){let n=a.children[Math.max(o-1,0)];return eG("Adjusting selection for merging of nodes"),s.focus={...s.focus},s.focus.path=[l[0],Math.max(l[1]-1,0)],s.focus.offset=e.isTextSpan(n)?n.text.length-t.text.length+s.focus.offset:0,s.anchor=s.focus,M.YR.select(e,s),M.YR.removeNodes(e,{at:[i,o]}),e0(e,"after"),!0}}return M.YR.removeNodes(e,{at:[i,o]}),e0(e,"after"),!0}if(!e.isTextBlock(a)){let n=[t].reduce(eZ,[a])[0];return M.YR.setNodes(e,n,{at:[i]}),!0}return!1}(e,n,t);break;case"set":r=function(e,t){let n=e.children.findIndex((e,n)=>eX(t.path[0])?e._key===t.path[0]._key:n===t.path[0]);eG("blockIndex",n);let r=n>-1?e.children[n]:void 0,i=e.isTextBlock(r)?r.children.findIndex((e,n)=>eX(t.path[2])?e._key===t.path[2]._key:n===t.path[2]):0,a=t.value,o=i>-1?[n,i]:[n];if("string"==typeof t.path[3]&&((a={})[t.path[3]]=t.value),e.isTextBlock(r)){if(eG("Setting nodes at ".concat(JSON.stringify(t.path)," - ").concat(JSON.stringify(o))),eG("Value to set",JSON.stringify(a,null,2)),e0(e,"before"),1===o.length){eG("Setting block property");let{children:t,...n}=a,{children:i,...l}
1=r||{children:void 0};e.apply({type:"set_node",path:o,properties:{...l},newProperties:n}),r&&M.W_.isElement(r)&&r.children.forEach((t,n)=>{e.apply({type:"remove_node",path:o.concat(n),node:t})}),Array.isArray(t)&&t.forEach((t,n)=>{e.apply({type:"insert_node",path:o.concat(n),node:t})})}else if(M.xv.isText(a)){eG("Setting text property");let t=e.selection&&{...e.selection};e.apply({type:"remove_text",path:o,offset:0,text:r.children[i].text}),e.apply({type:"insert_text",path:o,offset:0,text:a.text}),t&&T()(t.focus.path,o)&&(eG("On same path, restoring previous selection"),M.YR.select(e,t))}else eG("Setting non-text property"),e.apply({type:"set_node",path:o,properties:{},newProperties:a});return e0(e,"after"),!0}if(r&&"value"in r){var l;let i=(l=[r.value],[t].reduce(eZ,l))[0];return M.YR.setNodes(e,{...r,value:i},{at:[n]}),!0}return!1}(e,n);break;case"diffMatchPatch":r=function(e,t){let n=eQ([t.path[0]]),r=e.children.findIndex((e,r)=>n?e._key===n:r===t.path[0]),i=e.children[r],a=eK.patch_fromText(t.value)[0];if(a&&e.isTextBlock(i)){let n;let o=eQ([t.path[2]]),l=i.children.findIndex((e,n)=>o?e._key===o:n===t.path[0]),s=a.length2-a.length1,c={path:[r,l],offset:s>=0?(a.start1||0)+a.diffs[0][1].length:(a.start2||0)+a.length2-s};return e0(e,"before"),n=a.diffs[1]?a.diffs[1][1]:a.diffs[0][1],eG("Text: '".concat(n,"'")),s>=0?e.apply({type:"insert_text",path:c.path,offset:c.offset,text:n}):e.apply({type:"remove_text",path:c.path,offset:c.offset-n.length,text:n}),e0(e,"after"),!0}return!1}(e,n);break;default:eG("Unhandled patch",n.type)}}catch(e){console.error(e)}return t=n,r};return function(e){eO.set(e,!0),n=[...e.children];let{apply:t}=e;return a&&e.subscriptions.push(()=>{var t;ti("Subscribing to patches$");let n=a.pipe((0,d.b)(e=>{let{patches:t}=e;t.every(e=>"local"===e.origin)&&(i.current=!1)}),(t=()=>!i.current,e=>(0,f.P)(()=>{let n=[];return e.pipe((0,d.b)(e=>n.push(e)),(0,p.w)(()=>t(n)?(0,u.of)(n):g.E),(0,d.b)(()=>n=[]))})),(0,m.b)(e=>e)).subscribe(t=>{let{patches:n,snapshot:r}=t,i=n.filter(e=>"local"!==e.origin);0!==i.length&&(ti("Remote patches",n),M.ML.withoutNormalizing(e,()=>{i.forEach(t=>{ti("Handling remote patch ".concat(JSON.stringify(t))),eY(e,()=>{tr(e,()=>{ej(e,()=>{try{c(e,t,n,r)}catch(e){ti("Got error trying to create operations from patch"),console.error(e)}})})})})}))});return()=>{ti("Unsubscribing to patches$"),n.unsubscribe()}}),e.apply=i=>{if(l)return t(i),e;let a=[],c=ex(n=e.children,s);t(i);let h=ex(e.children,s);if(!eO.get(e))return ti("Editor is not producing patch for operation ".concat(i.type),i),e;switch(c&&!h&&(a.push(eA([])),a.push(eM([],[])),n.forEach((e,t)=>{a.push(eN(eb([e],s.block.name),"before",[t]))})),h&&["set_node"].includes(i.type)&&a.push(eA([])),i.type){case"insert_text":a=[...a,...o.insertTextPatch(e,i,n)];break;case"remove_text":a=[...a,...o.removeTextPatch(e,i,n)];break;case"remove_node":a=[...a,...o.removeNodePatch(e,i,n)];break;case"split_node":a=[...a,...o.splitNodePatch(e,i,n)];break;case"insert_node":a=[...a,...o.insertNodePatch(e,i,n)];break;case"set_node":a=[...a,...o.setNodePatch(e,i,n)];break;case"merge_node":a=[...a,...o.mergeNodePatch(e,i,n)];break;case"move_node":a=[...a,...o.moveNodePatch(e,i,n)]}return h&&["remove_text","remove_node"].includes(i.type)&&(a=[...a,eA([])],r.next({type:"unset",previousValue:eb(n,s.block.name,em.get(e))})),a.length>0&&a.forEach(e=>{r.next({type:"patch",patch:{...e,origin:"local"}})}),e},e}}({change$:h,isPending:s,keyGenerator:r,patches$:a,patchFunctions:y,readOnly:o,schemaTypes:c}),E=(n=l||-1,function(e){let{apply:t}=e;return e.apply=r=>{n>0&&e.children.length>=n&&("insert_node"===r.type||"split_node"===r.type)&&1===r.path.length||t(r)},e}),N=function(e){return e.pteToggleListItem=t=>{e.pteHasListStyle(t)?(tl("Remove list item '".concat(t,"'")),e.pteUnsetListItem(t)):(tl("Add list item '".concat(t,"'")),e.pteSetListItem(t))},e.pteUnsetListItem=t=>{e.selection&&[...M.ML.nodes(e,{at:e.selection,match:e=>M.W_.isElement(e)&&e._type===c.block.name})].forEach(n=>{let[r,i]=n;if(e.isListBlock(r)){let{listItem:n,level:a,...o}=r,l={...o,listItem:void 0,level:void 0};tl("Unsetting list '".concat(t,"'")),M.YR.setNodes(e,l,{at:i})}})},e.pteSetListItem=t=>{e.selection&&[...M.ML.nodes(e,{at:e.selection,match:t=>e.isTextBlock(t)}
1)].forEach(n=>{let[r,i]=n;tl("Setting list '".concat(t,"'")),M.YR.setNodes(e,{...r,level:1,listItem:t||c.lists[0]&&c.lists[0].value},{at:i})})},e.pteEndList=()=>{if(!e.selection)return!1;let t=[...M.ML.nodes(e,{at:e.selection,match:t=>M.W_.isElement(t)&&e.isListBlock(t)&&1===t.children.length&&M.xv.isText(t.children[0])&&""===t.children[0].text})];return 0!==t.length&&(t.forEach(t=>{let[n,r]=t;M.W_.isElement(n)&&(tl("Unset list"),M.YR.setNodes(e,{...n,level:void 0,listItem:void 0},{at:r}))}),!0)},e.pteIncrementBlockLevels=t=>{if(!e.selection)return!1;let n=[...M.ML.nodes(e,{at:e.selection,match:t=>!!e.isListBlock(t)})];return 0!==n.length&&(n.forEach(n=>{let[r,i]=n;if(e.isListBlock(r)){let n=r.level||1;t?tl("Decrementing list level",Math.min(10,Math.max(1,--n))):tl("Incrementing list level",Math.min(10,Math.max(1,++n))),M.YR.setNodes(e,{level:Math.min(10,Math.max(1,n))},{at:i})}}),!0)},e.pteHasListStyle=t=>!!e.selection&&[...M.ML.nodes(e,{at:e.selection,match:n=>e.isListBlock(n)&&n.listItem===t})].length>0,e},A=function(e){let{readOnly:t,patches$:n}=e,r=[];return e=>{n&&e.subscriptions.push(()=>{e1("Subscribing to patches");let e=n.subscribe(e=>{let{patches:t}=e;t.forEach(e=>{"local"!==e.origin&&r.push({patch:e,time:new Date})})});return()=>{e1("Unsubscribing to patches"),e.unsubscribe()}}),e.history={undos:[],redos:[]};let{apply:i}=e;return e.apply=n=>{if(t){i(n);return}let{operations:r,history:a}=e,{undos:o}=a,l=o[o.length-1],s=l&&l.operations&&l.operations[l.operations.length-1],c=tt(n,s),h=e9(e),f=e5(e);if(null==h&&(h=te(n)),h){if(null==f&&(f=null!=l&&(0!==r.length||e8(n,s)||c)),l&&f)c&&l.operations.pop(),l.operations.push(n);else{let t={operations:[...null===e.selection?[]:[{type:"set_selection",properties:{...e.selection},newProperties:{...e.selection}}],n],timestamp:new Date};o.push(t),e1("Created new undo step",l)}for(;o.length>300;)o.shift();tn(n)&&(a.redos=[])}i(n)},e.undo=()=>{if(t)return;let{undos:n}=e.history;if(n.length>0){let t=n[n.length-1];if(e1("Undoing",t),t.operations.length>0){let n=[...r.filter(e=>e.time>=t.timestamp)],i=t.operations;n.forEach(t=>{i=B()(i.map(n=>e4(e,t.patch,n)))}),tr(e,()=>{M.ML.withoutNormalizing(e,()=>{i.map(M.OX.inverse).reverse().forEach(n=>{try{e.apply(n)}catch(n){e1("Could not perform undo step",n),e.history.redos.push(t),e.history.undos.pop()}})})})}e.history.redos.push(t),e.history.undos.pop(),e.onChange()}},e.redo=()=>{if(t)return;let{redos:n}=e.history;if(n.length>0){let t=n[n.length-1];if(e1("Redoing",t),t.operations.length>0){let n=r.filter(e=>e.time>t.timestamp),i=t.operations;n.forEach(t=>{i=B()(i.map(n=>e4(e,t.patch,n)))}),tr(e,()=>{M.ML.withoutNormalizing(e,()=>{i.forEach(n=>{try{e.apply(n)}catch(n){e1("Could not perform redo step",n),e.history.undos.push(t),e.history.redos.pop()}})})})}e.history.undos.push(t),e.history.redos.pop(),e.onChange()}},e}}({readOnly:o,patches$:a}),L=function(e){let{apply:t,normalizeNode:n}=e,r=c.decorators.map(e=>e.value);return e.normalizeNode=t=>{n(t),e.operations.some(e=>["insert_node","insert_text","merge_node","remove_node","remove_text","set_node"].includes(e.type))&&function(e){let{selection:t}=e;if(t)for(let[n,r]of Array.from(M.ML.nodes(e,{at:M.ML.range(e,[t.anchor.path[0]],[t.focus.path[0]])})).reverse()){let[t]=r.length>1?M.ML.node(e,M.y$.parent(r)):[void 0],i=[r[0],r[1]+1];if(M.ML.isBlock(e,t)){let r=t.children[i[1]];M.xv.isText(n)&&M.xv.isText(r)&&T()(r.marks,n.marks)&&(ts("Merging spans"),M.YR.mergeNodes(e,{at:i,voids:!0}),e.onChange())}}}(e);let[r,i]=t,a=M.xv.isText(r)&&r._type===c.span.name,o=e.isTextBlock(r);if(a||o){for(let t of(o||Array.isArray(r.marks)||(ts("Adding .marks to span node"),M.YR.setNodes(e,{marks:[]},{at:i}),e.onChange()),e.operations)){if("merge_node"===t.type&&1===t.path.length&&"markDefs"in t.properties&&t.properties._type===c.block.name&&Array.isArray(t.properties.markDefs)&&t.properties.markDefs.length>0&&t.path[0]-1>=0){let[n,r]=M.ML.node(e,[t.path[0]-1]);if(ts("Copying markDefs over to merged block",t),e.isTextBlock(n)){let i=Array.isArray(n.markDefs)&&n.markDefs||[],a=Z()([...i,...t.properties.markDefs]);T()(a,n.markDefs)||(M.YR.setNodes(e,{markDefs:a},{at:r,voids:!1}),e.onChange())}}if("split_node"===t.type&&1===t.path.length&&M.W_.isElementProps(t.properties)&&t.properties._type===c.block.name&&"markDefs"in t.properties&&Array.isArray(t.properties.markDefs)&&t.properties.markDefs.length>0&&t.path[0]+1<e.children.length){let[n,r]=M.ML.node(e,[t.path[0]+1]);if(ts("Copying markDefs over to split block",t),e.isTextBlock(n)){let i=Array.isArray(n.markDefs)&&n.markDefs||[];M.YR.setNodes(e,{markDefs:Z()([...i,...t.properties.markDefs])},{at:r,voids:!1}),e.onChange()}}if("split_node"===t.type&&2===t.path.length&&t.properties._type===c.span.name&&"marks"in t.properties&&Array.isArray(t.properties.marks)&&t.properties.marks.length>0&&t.path[0]+1<e.children.length){let[n,r]=M.ML.node(e,[t.path[0]+1,0]);M.xv.isText(n)&&""===n.text&&Array.isArray(n.marks)&&n.marks.length>0&&(M.YR.setNodes(e,{marks:[]},{at:r,voids:!1}),e.onChange())}if("split_node"===t.type&&1===t.path.length&&t.properties._type===c.block.name&&"markDefs"in t.properties&&Array.isArray(t.properties.markDefs)&&t.properties.markDefs.length>0){let[n,r]=M.ML.node(e,[t.path[0]]);e.isTextBlock(n)&&1===n.children.length&&n.markDefs&&n.markDefs.length>0&&M.xv.isText(n.children[0])&&""===n.children[0].text&&(!n.children[0].marks||0===n.children[0].marks.length)&&(M.YR.setNodes(e,{markDefs:[]},{at:r}),e.onChange())}}a&&Array.isArray(r.marks)&&r.marks.length>0&&""===r.text&&(M.YR.setNodes(e,{marks:[]},{at:i,voids:!1}),e.onChange())}o&&e.operations.some(e=>["split_node","remove_node","remove_text","merge_node"].includes(e.type))&&function(e){let{selection:t}=e;if(t){for(let[n,r]of M.ML.nodes(e,{at:t,match:e=>e._type===c.block.name}))if(e.isTextBlock(n)){let t=(n.markDefs||[]).filter(e=>n.children.find(t=>M.xv.isText(t)&&Array.isArray(t.marks)&&t.marks.includes(e._key)));T()(t,n.markDefs)||(ts("Removing markDef not in use"),M.YR.setNodes(e,{markDefs:t},{at:r}),e.onChange())}}}(e)},e.apply=n=>{var i,a;if("insert_text"===n.type){let{selection:o}=e;if(o&&M.e6.isCollapsed(o)&&(null==(a=null==(i=M.ML.marks(e))?void 0:i.marks)?void 0:a.some(e=>!r.includes(e)))){let[i]=Array.from(M.ML.nodes(e,{mode:"lowest",at:o.focus,match:e=>e._type===c.span.name,voids:!1}
1))[0]||[void 0];if(M.xv.isText(i)&&i.text.length===o.focus.offset&&Array.isArray(i.marks)&&i.marks.length>0){t(n),M.YR.splitNodes(e,{match:M.xv.isText,at:{...o.focus,offset:o.focus.offset}});let i=(({...M.ML.marks(e)||{}}).marks||[]).filter(e=>r.includes(e));M.YR.setNodes(e,{marks:i},{at:M.y$.next(o.focus.path)});return}}}t(n)},e.addMark=t=>{if(e.selection){if(M.e6.isExpanded(e.selection)){M.YR.setNodes(e,{},{match:M.xv.isText,split:!0});let n=[...M.ML.nodes(e,{at:e.selection,match:M.xv.isText})];if(B()(n.map(e=>e[0]).map(e=>e.marks)).includes(t)){e.removeMark(t);return}M.ML.withoutNormalizing(e,()=>{n.forEach(n=>{let[r,i]=n,a=[...(Array.isArray(r.marks)?r.marks:[]).filter(e=>e!==t),t];M.YR.setNodes(e,{marks:a},{at:i,match:M.xv.isText,split:!0,hanging:!0})})}),M.ML.normalize(e)}else{let n={...M.ML.marks(e)||{}}.marks||[],r={...M.ML.marks(e)||{},marks:[...n,t]};e.marks=r}e.onChange()}},e.removeMark=t=>{let{selection:n}=e;if(n){if(M.e6.isExpanded(n))M.ML.withoutNormalizing(e,()=>{M.YR.setNodes(e,{},{match:M.xv.isText,split:!0}),e.selection&&[...M.ML.nodes(e,{at:e.selection,match:M.xv.isText})].forEach(n=>{let[r,i]=n,a=e.children[i[0]];M.W_.isElement(a)&&a.children.includes(r)&&M.YR.setNodes(e,{marks:(Array.isArray(r.marks)?r.marks:[]).filter(e=>e!==t)},{at:i})})}),M.ML.normalize(e);else{let n={...M.ML.marks(e)||{}}.marks||[],r={...M.ML.marks(e)||{},marks:n.filter(e=>e!==t)};e.marks=r}e.onChange()}},e.pteIsMarkActive=t=>{if(!e.selection||e.selection.focus.path.length<2)return!1;let n={...M.ML.marks(e)||{}}.marks||[];return M.e6.isExpanded(e.selection)&&Array.from(M.ML.nodes(e,{match:M.xv.isText,at:e.selection})).forEach(e=>{let[t]=e;n=Z()([...n,...t.marks||[]])}),n.includes(t)},e.pteToggleMark=t=>{e.pteIsMarkActive(t)?(ts("Remove mark '".concat(t,"'")),M.ML.removeMark(e,t)):(ts("Add mark '".concat(t,"'")),M.ML.addMark(e,t,!0)),e.onChange()},e},P=function(e,t){let n=e.styles[0].value;return function(r){let{normalizeNode:i}=r;return r.normalizeNode=e=>{i(e);let[,t]=e;for(let e of r.operations)if("split_node"===e.type&&1===e.path.length&&r.isTextBlock(e.properties)&&e.properties.style!==n&&e.path[0]===t[0]&&!M.y$.equals(t,e.path)){let[t]=M.ML.node(r,[e.path[0]+1,0]);if(M.xv.isText(t)&&""===t.text){to("Normalizing split node to ".concat(n," style"),e),M.YR.setNodes(r,{style:n},{at:[e.path[0]+1],voids:!1});break}}},r.pteHasBlockStyle=e=>!!r.selection&&[...M.ML.nodes(r,{at:r.selection,match:t=>r.isTextBlock(t)&&t.style===e})].length>0,r.pteToggleBlockStyle=i=>{r.selection&&([...M.ML.nodes(r,{at:r.selection,match:t=>M.W_.isElement(t)&&t._type===e.block.name})].forEach(e=>{let[t,a]=e;r.isTextBlock(t)&&t.style===i?(to("Unsetting block style '".concat(i,"'")),M.YR.setNodes(r,{...t,style:n},{at:a})):(i?to("Setting style '".concat(i,"'")):to("Setting default style",n),M.YR.setNodes(r,{...t,style:i||n},{at:a}))}),t.next({type:"selection",selection:eP(eb(r.children,e.block.name),r.selection,e)}),r.onChange())},r}}(c,h),I=function(e){let{schemaTypes:t,keyGenerator:n}=e;return function(e){e.createPlaceholderBlock=()=>({_type:t.block.name,_key:n(),style:t.styles[0].value||"normal",markDefs:[],children:[{_type:"span",_key:n(),text:"",marks:[]}]});let{onChange:r}=e;return e.onChange=()=>{let t=!!e.selection;r(),0===e.children.length&&(ta("Inserting placeholder block"),M.YR.deselect(e),e.children=[e.createPlaceholderBlock()],t&&M.YR.select(e,{focus:{path:[0,0],offset:0},anchor:{path:[0,0],offset:0}}),e.onChange())},e}}({keyGenerator:r,schemaTypes:c}),O=function(e){let{schemaTypes:t,keyGenerator:n}=e;return function(e){return e.pteExpandToWord=()=>{let{selection:t}=e;if(t&&!M.e6.isExpanded(t)){let[n]=M.ML.node(e,t.focus,{depth:2});if(!n||!M.xv.isText(n)||0===n.text.length){tf("pteExpandToWord: Can't expand to word here");return}let{focus:r}=t,i=r.offset,a=n.text.slice(0,i),o=n.text.slice(i,-1),l=e=>e.match(/\s/g),s=a.split("").reverse().findIndex(e=>l(e)),c=s>-1?a.length-s:0,h=o.split("").findIndex(e=>l(e)),f=a.length+(h>-1?h:o.length+1);if(!(c===f||isNaN(c)||isNaN(f))){tf("pteExpandToWord: Expanding to focused word"),M.YR.setSelection(e,{anchor:{...t.anchor,offset:c},focus:{...t.focus,offset:f}});return}tf("pteExpandToWord: Can't expand to word here")}},e}}({keyGenerator:r,schemaTypes:c}),Y=function(e){let t=()=>{let t=null;if(e.selection){let n=ey.get(e.selection);n?t=n:(t=eP(eb(e.children,c.block.name,em.get(e)),e.selection,c),ey.set(e.selection,t))}tc("Emitting selection ".concat(JSON.stringify(t||null))),t?h.next({type:"selection",selection:t}):h.next({type:"selection",selection:null})},{onChange:n}=e;return e.onChange=()=>{let r=e.operations.length>0;n(),r&&t()},e};return(e.destroy=()=>{let t=tk.get(e);if(!t)throw Error("Could not find pristine versions of editor functions");e.onChange=t.onChange,e.apply=t.apply,e.normalizeNode=t.normalizeNode},o)?{editor:_(k(L(P(O(I(N(Y(b(e))))))))),subscribe:()=>D()}:{editor:_(k(L(P(N(I(O(E(A(x(Y(b(e)))))))))))),subscribe:()=>{let t=[];
1return e.subscriptions.forEach(e=>{t.push(e())}),()=>{t.forEach(e=>{e()})}}}},t_=ea("component:PortableTextEditor:SlateContainer");function tb(e){let{patches$:t,portableTextEditor:n,readOnly:r,maxBlocks:i,keyGenerator:a,value:o,isPending:l}=e,[s,f]=(0,h.useMemo)(()=>{t_("Creating new Slate editor instance");let{editor:e,subscribe:o}=tv((0,w.BU)((0,M.Jh)()),{isPending:l,keyGenerator:a,maxBlocks:i,patches$:t,portableTextEditor:n,readOnly:r});return em.set(e,{}),eg.set(e,{}),[e,o]},[]);(0,h.useEffect)(()=>{let e=f();return()=>{e()}},[f]),(0,h.useEffect)(()=>{t_("Re-initializing plugin chain"),tv(s,{isPending:l,keyGenerator:a,maxBlocks:i,patches$:t,portableTextEditor:n,readOnly:r})},[a,n,i,r,t,s,l]);let d=(0,h.useMemo)(()=>o?e_(o,{schemaTypes:n.schemaTypes},eg):[s.createPlaceholderBlock()],[]);return(0,h.useEffect)(()=>()=>{t_("Destroying Slate editor"),s.destroy()},[s]),(0,c.jsx)(w.mH,{editor:s,value:d,children:e.children})}let tx=(0,h.createContext)(null),tw=()=>{let e=(0,h.useContext)(tx);if(void 0===e)throw Error("The `usePortableTextEditorSelection` hook must be used inside the <PortableTextEditor> component's context.");return e},tM=(0,h.createContext)(null),tE=()=>{let e=(0,h.useContext)(tM);if(!e)throw Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");return e},tT=(0,h.createContext)(void 0),tN=(0,h.createContext)(!1),tD=()=>{let e=(0,h.useContext)(tN);if(void 0===e)throw Error("The `usePortableTextEditorReadOnly` hook must be used inside the <PortableTextEditor> component's context.");return e},tA=ea("hook:useSyncValue"),tC=ea("component:PortableTextEditor:Synchronizer");function tL(e){let{change$:t,editor:n,isPending:r,onChange:i,keyGenerator:a,readOnly:o,value:l}=e,[s,f]=(0,h.useState)(null),d=(0,h.useRef)([]),p=function(e){let{editor:t,slateEditor:n,isPending:r,readOnly:i}=e,a=(0,h.useRef)();return(0,h.useMemo)(()=>(e,o)=>{let l=()=>{n.onChange(),o&&o()};if(r.current&&!i){tA("Has local patches");return}if(a.current===e){tA("Value is the same object");return}if(a.current=e,!e||0===e.length){tA("Value is empty"),tr(n,()=>{eY(n,()=>{M.ML.withoutNormalizing(n,()=>{let e=n.children.length;n.children.forEach((t,r)=>{M.YR.removeNodes(n,{at:[e-1-r]})}),M.YR.insertNodes(n,n.createPlaceholderBlock(),{at:[0]})}),M.ML.normalize(n)})}),l();return}if(e&&e.length>0){let r=e_(e,{schemaTypes:t.schemaTypes},eg.get(n));tr(n,()=>{eY(n,()=>{M.ML.withoutNormalizing(n,()=>{let e=n.children.length;r.length<e&&Array.from(Array(e-r.length)).forEach((t,r)=>{let i=e-1-r;i>0&&M.YR.removeNodes(n,{at:[i]})}),r.forEach((e,t)=>{let r=n.children[t];if(r&&!T()(e,r)){tA("Replacing changed block",r);let i=n.selection;M.YR.deselect(n),M.YR.removeNodes(n,{at:[t]}),ej(n,()=>{M.YR.insertNodes(n,e,{at:[t]})}),i&&M.YR.select(n,i)}r||(tA("Adding new block",e),ej(n,()=>{M.YR.insertNodes(n,e,{at:[t]})}))})})})})}l()},[t,r,i,n])}({editor:n,keyGenerator:a,isPending:r,readOnly:o,slateEditor:(0,w.ui)()});(0,h.useEffect)(()=>{(0,h.startTransition)(()=>{tC("Value from props changed, syncing new value"),p(l)}),t.next({type:"value",value:l})},[p,t,l]);let u=(0,h.useCallback)(()=>{let e=[...d.current];tC("Flushing pending patches",e),e.length>0&&(d.current=d.current.splice(e.length,d.current.length),i({type:"mutation",patches:e}))},[i]),g=(0,h.useMemo)(()=>Q()(u,1e3,{leading:!1,trailing:!0}),[u]);return(0,h.useEffect)(()=>()=>{u()},[u]),(0,h.useEffect)(()=>{tC("Subscribing to editor changes$");let e=t.subscribe(e=>{switch(e.type){case"patch":r.current=!0,d.current.push(e.patch),i(e),g();break;case"selection":(0,h.startTransition)(()=>{tC("Setting selection"),f(e.selection)}),i(e);break;default:i(e)}});return()=>{tC("Unsubscribing to changes$"),e.unsubscribe()}},[t,g,i,p,r]),(0,c.jsx)(el.Provider,{value:a,children:(0,c.jsx)(tM.Provider,{value:n,children:(0,c.jsx)(tT.Provider,{value:l,children:(0,c.jsx)(tN.Provider,{value:o,children:(0,c.jsx)(tx.Provider,{value:s,children:e.children})})})})})}let tS=ea("component:PortableTextEditor:Validator");function tP(e){let{portableTextEditor:t,keyGenerator:n,value:r}=e,{change$:i,schemaTypes:a}=t,o=(0,h.useRef)(),[l,s]=(0,h.useState)(null);return((0,h.useEffect)(()=>{let e=r&&o.current&&r.length>
1o.current.length;if(!o.current&&r||e){tS("Validating"),i.next({type:"loading",isLoading:!0});let e=tu(r,a,n);i.next({type:"loading",isLoading:!1}),r&&!e.valid&&(i.next({type:"invalidValue",resolution:e.resolution,value:r}),s(e.resolution))}o.current=r},[n,i,a,r]),l)?(0,c.jsx)(c.Fragment,{children:l.description}):(0,c.jsx)(c.Fragment,{children:e.children})}let tR=ea("component:PortableTextEditor");class tI extends h.Component{constructor(e){if(super(e),this.change$=new y.x,this.setEditable=e=>{this.editable={...this.editable,...e},this.change$.next({type:"loading",isLoading:!1}),this.change$.next({type:"ready"}),this.change$.next({type:"value",value:this.props.value})},!e.schemaType)throw Error('PortableTextEditor: missing "type" property');e.incomingPatches$&&console.warn("The prop 'incomingPatches$' is deprecated and renamed to 'patches$'"),this.change$.next({type:"loading",isLoading:!0}),this.isPending=(0,h.createRef)(),this.isPending.current=!1,this.schemaTypes=er(e.schemaType.hasOwnProperty("jsonType")?e.schemaType:en(e.schemaType))}componentDidUpdate(e){this.props.schemaType!==e.schemaType&&(this.schemaTypes=er(this.props.schemaType.hasOwnProperty("jsonType")?this.props.schemaType:en(this.props.schemaType)))}render(){let{onChange:e,value:t,children:n,patches$:r,incomingPatches$:i}=this.props,{change$:a,isPending:o}=this,l=void 0===this.props.maxBlocks?void 0:parseInt(this.props.maxBlocks.toString(),10)||void 0,s=!!this.props.readOnly,h=this.props.keyGenerator||eo;return(0,c.jsx)(tP,{portableTextEditor:this,keyGenerator:h,value:t,children:(0,c.jsx)(tb,{keyGenerator:h,maxBlocks:l,patches$:i||r,portableTextEditor:this,readOnly:s,value:t,isPending:o,children:(0,c.jsx)(tL,{change$:a,editor:this,isPending:o,keyGenerator:h,onChange:e,readOnly:s,value:t,children:n})})})}}function tB(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,a="object"==typeof e.path[2]&&"_key"in e.path[2]&&e.path[2]._key,o=t.find(e=>e._key===i);if(!o)return null;if(n.push({_key:o._key}),o&&"children"===e.path[1]){if(!o.children||Array.isArray(o.children)&&0===o.children.length)return null;let t=Array.isArray(o.children)&&o.children.find(e=>e._key===a);if(!t)return null;n.push("children"),n.push({_key:t._key}),r=t.text&&t.text.length>=e.offset?e.offset:t.text&&t.text.length||0}return{path:n,offset:r}}function tj(e){let t=(0,h.useCallback)(()=>alert(JSON.stringify(e.annotation)),[e.annotation]);return(0,c.jsx)("span",{style:{color:"blue"},onClick:t,children:e.children})}tI.activeAnnotations=e=>e&&e.editable?e.editable.activeAnnotations():[],tI.addAnnotation=(e,t,n)=>{var r;return null==(r=e.editable)?void 0:r.addAnnotation(t,n)},tI.blur=e=>{var t;tR("Host blurred"),null==(t=e.editable)||t.blur()},tI.delete=(e,t,n)=>{var r;return null==(r=e.editable)?void 0:r.delete(t,n)},tI.findDOMNode=(e,t)=>{var n;return null==(n=e.editable)?void 0:n.findDOMNode(t)},tI.findByPath=(e,t)=>{var n;return(null==(n=e.editable)?void 0:n.findByPath(t))||[]},tI.focus=e=>{var t;tR("Host requesting focus"),null==(t=e.editable)||t.focus()},tI.focusBlock=e=>{var t;return null==(t=e.editable)?void 0:t.focusBlock()},tI.focusChild=e=>{var t;return null==(t=e.editable)?void 0:t.focusChild()},tI.getSelection=e=>e.editable?e.editable.getSelection():null,tI.getValue=e=>{var t;return null==(t=e.editable)?void 0:t.getValue()},tI.hasBlockStyle=(e,t)=>{var n;return null==(n=e.editable)?void 0:n.hasBlockStyle(t)},tI.hasListStyle=(e,t)=>{var n;return null==(n=e.editable)?void 0:n.hasListStyle(t)},tI.isCollapsedSelection=e=>{var t;return null==(t=e.editable)?void 0:t.isCollapsedSelection()},tI.isExpandedSelection=e=>{var t;return null==(t=e.editable)?void 0:t.isExpandedSelection()},tI.isMarkActive=(e,t)=>{var n;return null==(n=e.editable)?void 0:n.isMarkActive(t)},tI.insertChild=(e,t,n)=>{var r;return tR("Host inserting child"),null==(r=e.editable)?void 0:r.insertChild(t,n)},tI.insertBlock=(e,t,n)=>{var r;return null==(r=e.editable)?void 0:r.insertBlock(t,n)},tI.insertBreak=e=>{var t;return null==(t=e.editable)?void 0:t.insertBreak()},tI.isVoid=(e,t)=>{var n;return null==(n=e.editable)?void 0:n.isVoid(t)},tI.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},tI.marks=e=>{var t;return null==(t=e.editable)?void 0:t.marks()},tI.select=(e,t)=>
1{var n;tR("Host setting selection",t),null==(n=e.editable)||n.select(t)},tI.removeAnnotation=(e,t)=>{var n;return null==(n=e.editable)?void 0:n.removeAnnotation(t)},tI.toggleBlockStyle=(e,t)=>{var n;return tR("Host is toggling block style"),null==(n=e.editable)?void 0:n.toggleBlockStyle(t)},tI.toggleList=(e,t)=>{var n;return null==(n=e.editable)?void 0:n.toggleList(t)},tI.toggleMark=(e,t)=>{var n;tR("Host toggling mark",t),null==(n=e.editable)||n.toggleMark(t)};let tO=ea("components:DraggableChild"),tY=e=>{let{children:t,element:n,readOnly:r}=e,i=(0,w._7)(),a=(0,h.useRef)(),o=(0,h.useMemo)(()=>M.ML.isVoid(i,n),[i,n]),l=(0,h.useCallback)(e=>{if(!ef.get(i))return;tO("handle drag over"),e.preventDefault(),e.dataTransfer.dropEffect="move";let t=w.F3.findEventRange(i,e);t&&(ep.set(i,t),M.YR.select(i,t))},[i]),s=(0,h.useCallback)(e=>{if(tO("Drag start"),ec.set(i,!0),ef.set(i,n),o){e.dataTransfer.effectAllowed="move";let t=e.currentTarget;if(t instanceof HTMLElement){let n=t.cloneNode(!0);if(a.current=n,n.style.width="".concat(t.clientWidth,"px"),n.style.height="".concat(t.clientHeight,"px"),n.style.position="absolute",n.style.top="-99999px",n.style.left="-99999px",document.body){document.body.appendChild(n);let r=t.getBoundingClientRect(),i=e.clientX-r.left,a=e.clientY-r.top;n.style.width="".concat(r.width,"px"),n.style.height="".concat(r.height,"px"),e.dataTransfer.setDragImage(n,i,a)}}}},[i,n,o]);return r?t:(0,c.jsx)("span",{draggable:o,onDragStart:s,onDragOver:l,children:t})};ea("components:Leaf");let tW=e=>{let t=(0,w._7)(),n=(0,w.vt)(),{attributes:r,children:i,leaf:a,schemaTypes:o,keyGenerator:l,renderChild:s,readOnly:f}=e,d=h.useRef(null),p=i,u=n&&t.selection&&M.e6.isCollapsed(t.selection)||!1;if(M.xv.isText(a)&&a._type===o.span.name){let t=i.props.parent,r=t?[{_key:t._key},"children",{_key:a._key}]:[],l=o.decorators.map(e=>e.value);Z()((Array.isArray(a.marks)?a.marks:[]).filter(e=>l.includes(e))).forEach(t=>{let i=o.decorators.find(e=>e.value===t);i&&e.renderDecorator&&(p=e.renderDecorator({children:p,editorElementRef:d,focused:u,path:r,selected:n,type:i,value:t}))});let h=(Array.isArray(a.marks)?a.marks:[]).map(e=>!l.includes(e)&&t&&t.markDefs&&t.markDefs.find(t=>t._key===e)).filter(Boolean);if(t&&h.length>0&&h.forEach(i=>{let a=o.annotations.find(e=>e.name===i._type);a&&(p=e.renderAnnotation?(0,c.jsx)("span",{ref:d,children:e.renderAnnotation({block:t,children:p,editorElementRef:d,focused:u,path:r,selected:n,type:a,value:i})}):(0,c.jsx)(tj,{annotation:i,children:(0,c.jsx)("span",{ref:d,children:p})}))}),t&&s){let e=t.children.find(e=>e._key===a._key);e&&(p=s({annotations:h,children:(0,c.jsx)(c.Fragment,{children:p}),editorElementRef:d,focused:u,path:r,schemaType:o.span,selected:n,value:e}))}}let g=a._key||l();return(0,c.jsx)("span",{...r,ref:d,children:(0,c.jsx)(tY,{element:a,readOnly:f,children:p})},g)},tz=e=>(0,c.jsx)("div",{children:(0,c.jsx)("pre",{children:JSON.stringify(e.value,null,2)})}),tJ=ee.ZP.div(a||(a=et(["\n user-select: none;\n border: ",";\n"])),e=>e.selected?"1px solid blue":"1px solid transparent");ee.ZP.span(o||(o=et(["\n background: #999;\n border: ",";\n"])),e=>e.selected?"1px solid blue":"1px solid transparent");let tF=ee.ZP.div(l||(l=et(["\n &.pt-list-item {\n width: fit-content;\n position: relative;\n display: block;\n\n /* Important 'transform' in order to force refresh the ::before and ::after rules\n in Webkit: https://stackoverflow.com/a/21947628/831480\n */\n transform: translateZ(0);\n margin-left: ",";\n }\n &.pt-list-item > .pt-list-item-inner {\n display: flex;\n margin: 0;\n padding: 0;\n &:before {\n justify-content: flex-start;\n vertical-align: top;\n }\n }\n &.pt-list-item-bullet > .pt-list-item-inner:before {\n content: '","';\n font-size: 0.4375rem; /* 7px */\n line-height: 1.5rem; /* Same as body text */\n /* Optical alignment */\n position: relative;\n }\n }\n &.pt-list-item-bullet > .pt-list-item-inner {\n &:before {\n min-width: 1.5rem; /* Make sure space between bullet and text never shrinks */\n }\n }\n &.pt-list-item-number {\n counter-increment: ",";\n counter-reset: ",";\n }\n & + :not(.pt-list-item-number) {\n counter-reset: listItemNumber;\n }\n &.pt-list-item-number > .pt-list-item-inner:before {\n content: ",";\n min-width: 1.5rem; /* Make sure space between number and text never shrinks */\n /* Optical alignment */\n position: relative;\n top: 1px;\n }\n"])),e=>(function(e){switch(Number(e)){case 1:return"1.5em";case 2:return"3em";case 3:return"4.5em";case 4:return"6em";
1case 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),e=>{var t;return t=e.listLevel,"bullet"===e.listStyle?tU[(t-1)%3]:"*"},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),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),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)),tV=ee.ZP.div(s||(s=et([""]))),tU=["â","â","â "],tH=ea("components:DraggableBlock"),t$=e=>{let{children:t,element:n,readOnly:r,blockRef:i}=e,a=(0,w._7)(),o=(0,h.useRef)(),[l,s]=(0,h.useState)(!1),f=(0,h.useMemo)(()=>M.ML.isVoid(a,n),[a,n]),d=(0,h.useMemo)(()=>M.ML.isInline(a,n),[a,n]),[p,u]=(0,h.useState)(null);(0,h.useEffect)(()=>u(i?i.current:w.F3.toDOMNode(a,n)),[a,n,i]);let g=(0,h.useCallback)(e=>{let t=eh.get(a);if(!t||!p)return;e.preventDefault(),e.dataTransfer.dropEffect="move",ed.set(a,n);let r=p.getBoundingClientRect(),i=r.top,o=r.height,l=e.pageY,c="bottom";if(n===a.children[0]?c="top":(c=Math.abs(i-l)<o/2?"top":"bottom",eu.set(a,c)),t===n){e.dataTransfer.dropEffect="none";return}s(!0)},[p,a,n]),m=(0,h.useCallback)(()=>{s(!1)},[]),y=(0,h.useCallback)(e=>{let t=ed.get(a);if(t){ec.set(a,!1),e.preventDefault(),e.stopPropagation(),ed.delete(a),o.current&&(tH("Removing drag ghost"),document.body.removeChild(o.current));let r=eu.get(a);eu.delete(a);let i=w.F3.findPath(a,t),l=w.F3.findPath(a,n),s=M.y$.isBefore(l,i);if("bottom"===r&&!s){if(i[0]>=a.children.length-1){tH("target is already at the bottom, not moving");return}let e=i;i=M.y$.next(i),tH("Adjusting targetPath from ".concat(JSON.stringify(e)," to ").concat(JSON.stringify(i)))}if("top"===r&&s&&i[0]!==a.children.length-1){let e=i;i=M.y$.previous(i),tH("Adjusting targetPath from ".concat(JSON.stringify(e)," to ").concat(JSON.stringify(i)))}if(M.y$.equals(i,l)){e.preventDefault(),tH("targetPath and myPath is the same, not moving");return}tH("Moving element ".concat(n._key," from path ").concat(JSON.stringify(l)," to ").concat(JSON.stringify(i)," (").concat(r,")")),M.YR.moveNodes(a,{at:l,to:i}),a.onChange();return}tH("No target element, not doing anything")},[a,n]),k=(0,h.useCallback)(e=>{eh.get(a)&&(tH("On drop (prevented)",n),e.preventDefault(),e.stopPropagation(),s(!1))},[a,n]),_=(0,h.useCallback)(e=>{if(!f){eh.delete(a);return}ec.set(a,!0),eh.set(a,n),e.stopPropagation();let t=e.target;t instanceof HTMLElement&&(t.style.opacity="1")},[a,n,f]),b=(0,h.useCallback)(e=>{if(!f||d){tH("Not dragging block"),eh.delete(a),ec.set(a,!1);return}if(tH("Drag start"),ec.set(a,!0),e.dataTransfer&&(e.dataTransfer.setData("application/portable-text","something"),e.dataTransfer.effectAllowed="move"),p&&p instanceof HTMLElement){let t=p.cloneNode(!0),n=t.querySelector("[data-pt-drag-ghost-element]");if(n&&(t=n),t.setAttribute("data-dragged",""),document.body){o.current=t,t.style.position="absolute",t.style.left="-99999px",t.style.boxSizing="border-box",document.body.appendChild(t);let n=p.getBoundingClientRect(),r=e.clientX-n.left,i=e.clientY-n.top;t.style.width="".concat(n.width,"px"),t.style.height="".concat(n.height,"px"),e.dataTransfer.setDragImage(t,r,i)}}_(e)},[p,a,_,d,f]),x=l&&a.children[0]===ed.get(a),E=l&&a.children[a.children.length-1]===ed.get(a),T=eu.get(a),N=x||l&&!x&&!E&&"top"===T,D=E||l&&!x&&!E&&"bottom"===T,A=(0,h.useMemo)(()=>(0,c.jsx)("div",{className:"pt-drop-indicator",style:{position:"absolute",width:"100%",height:1,borderBottom:"1px solid currentColor",zIndex:5}}),[]);return r?(0,c.jsx)(c.Fragment,{children:t}):(0,c.jsxs)("div",{draggable:f,onDragStart:b,onDrag:_,onDragOver:g,onDragLeave:m,onDragEnd:y,onDrop:k,children:[N&&A,t,D&&A]})};ea("components:Element");let tq=[],tZ={display:"inline-block"},tG=e=>{let t,{attributes:n,children:r,element:i,schemaTypes:a,readOnly:o,renderBlock:l,renderChild:s,renderListItem:f,render
1Style:d,spellCheck:p}=e,u=(0,w._7)(),g=(0,w.vt)(),m=(0,h.useRef)(null),y=(0,h.useRef)(null),k=g&&u.selection&&M.e6.isCollapsed(u.selection)||!1,_=(0,h.useMemo)(()=>eb([i],a.block.name,em.get(u))[0],[u,i,a.block.name]),b=r,x=(0,h.useMemo)(()=>[{_key:i._key}],[i]);if("string"!=typeof i._type)throw Error("Expected element to have a _type property");if("string"!=typeof i._key)throw Error("Expected element to have a _key property");if(u.isInline(i)){let e=w.F3.findPath(u,i),[t]=M.ML.node(u,e,{depth:1}),l=a.inlineObjects.find(e=>e.name===i._type);if(!l)throw Error("Could not find type for inline block element");if(M.W_.isElement(t)){let e=[{_key:t._key},"children",{_key:i._key}];return(0,c.jsxs)("span",{...n,children:[r,(0,c.jsx)(tY,{element:i,readOnly:o,children:(0,c.jsxs)("span",{className:"pt-inline-object",ref:y,style:tZ,contentEditable:!1,children:[s&&s({annotations:tq,children:(0,c.jsx)(tz,{value:_}),value:_,schemaType:l,focused:k,selected:g,path:e,editorElementRef:y}),!s&&(0,c.jsx)(tz,{value:_})]},i._key)})]})}throw Error("Block not found!")}if(i._type===a.block.name){let e;t="pt-block pt-text-block";let s="listItem"in i,h="style"in i&&i.style||"normal";t="pt-block pt-text-block pt-text-block-style-".concat(h);let y=a.styles.find(e=>e.value===h);if(d&&y&&(b=d({block:i,children:r,focused:k,selected:g,value:h,path:x,type:y,editorElementRef:m})),s&&("number"==typeof i.level&&(e=i.level),t+=" pt-list-item pt-list-item-".concat(i.listItem," pt-list-item-level-").concat(e||1)),u.isListBlock(_)&&s&&i.listItem){let e=a.lists.find(e=>e.value===i.listItem);b=f&&e?f({block:_,children:b,focused:k,selected:g,value:i.listItem,path:x,type:e,level:_.level||1,editorElementRef:m}):(0,c.jsx)(tF,{listStyle:_.listItem||a.lists[0].value,listLevel:_.level||1,children:(0,c.jsx)(tV,{children:b})})}let w={children:b,editorElementRef:m,focused:k,level:e,listItem:s?i.listItem:void 0,path:x,selected:g,style:h,type:a.block,value:_},M=l?l(w):r;return(0,c.jsx)("div",{...n,className:t,spellCheck:p,children:(0,c.jsx)(t$,{element:i,readOnly:o,blockRef:m,children:(0,c.jsx)("div",{ref:m,children:M})})},i._key)}let E=a.blockObjects.find(e=>e.name===i._type);if(!E)throw Error("Could not find schema type for block element of _type ".concat(i._type));t="pt-block pt-object-block";let T=eb([i],a.block.name,em.get(u))[0],N=l&&l({children:(0,c.jsx)(tz,{value:_}),value:T,type:E,selected:g,focused:k,path:x,editorElementRef:m});return(0,c.jsxs)("div",{...n,className:t,children:[r,(0,c.jsxs)(t$,{element:i,readOnly:o,blockRef:m,children:[N&&(0,c.jsx)("div",{ref:m,contentEditable:!1,children:N}),!N&&(0,c.jsx)(tJ,{selected:g,children:(0,c.jsx)(tz,{value:_})})]})]},i._key)},tK="undefined"==typeof window?h.useEffect:h.useLayoutEffect,tX=ea("component:Editable"),tQ={opacity:.5,position:"absolute",userSelect:"none",pointerEvents:"none"},t0=[],t1=(0,h.forwardRef)(function(e,t){let{hotkeys:n,onBeforeInput:r,onPaste:i,onCopy:a,renderAnnotation:o,renderBlock:l,renderChild:s,renderDecorator:f,renderListItem:d,renderPlaceholder:p,renderStyle:u,selection:g,scrollSelectionIntoView:m,spellCheck:y,...k}=e,_=tE(),b=tD(),x=es(),E=function(e){let t=(0,h.useRef)(null);return tK(()=>{e&&("function"==typeof e?e(t.current):e.current=t.current)}),t}(t),{change$:N,schemaTypes:A}=_,C=(0,w.ui)(),L=A.block.name,S=(0,h.useMemo)(()=>function(e){let t=A.block.name,n=A.span.name,r=t=>t.map(t=>{var r;return e.isTextBlock(t)?t.children.map(e=>{var t;return e._type===n?e.text:"[".concat((null==(t=A.inlineObjects.find(t=>t.name===e._type))?void 0:t.title)||"Object","]")}).join(""):"[".concat((null==(r=A.blockObjects.find(e=>e.name===t._type))?void 0:r.title)||"Object","]")}).join("\n\n");return e.setFragmentData=(n,i)=>{let{selection:a}=e;if(!a)return;let[o,l]=M.e6.edges(a),s=M.ML.void(e,{at:o.path}),c=M.ML.void(e,{at:l.path});if(M.e6.isCollapsed(a)&&!s)return;let h=w.F3.toDOMRange(e,a),f=h.cloneContents();if(c){let[t]=c,n=h.cloneRange(),r=w.F3.toDOMNode(e,t);n.setEndAfter(r),f=n.cloneContents()}Array.from(f.querySelectorAll("[data-slate-zero-width]")).forEach(e=>{let t="n"===e.getAttribute("data-slate-zero-width");e.textContent=t?"\n":""}
1),Array.from(f.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 d=f.ownerDocument.createElement("div");d.appendChild(f),d.setAttribute("hidden","true"),f.ownerDocument.body.appendChild(d);let p=d.innerHTML;f.ownerDocument.body.removeChild(d);let u=eb(e.getFragment(),t),g=JSON.stringify(u),m=r(u);n.clearData(),n.setData("text/plain",m),n.setData("text/html",p),n.setData("application/json",g),n.setData("application/x-portable-text",g),tg("text",m),n.setData("application/x-portable-text-event-origin",i||"external"),tg("Set fragment data",g,p)},e.insertPortableTextData=t=>{var r;if(!e.selection)return!1;let i=t.getData("application/x-portable-text"),a=t.getData("application/x-portable-text-event-origin");if(tg("Inserting portable text from ".concat(a," event"),i),i){let t=JSON.parse(i);if(Array.isArray(t)&&t.length>0){let i=e_(t,{schemaTypes:A}).map(t=>{let r={...t};e.isTextBlock(r)&&(r.markDefs=(r.markDefs||[]).map(t=>{let i=t._key,a=x();return e.isTextBlock(r)&&(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(a):t.marks}:t)),{...t,_key:a}}));let i={...r,_key:x()};return e.isTextBlock(i)&&(i.children=i.children.map(e=>({...e,_key:x()}))),i}),a=tu(t,A,x);if(!a.valid){let e="".concat(null==(r=a.resolution)?void 0:r.description);return N.next({type:"error",level:"warning",name:"pasteError",description:e,data:a}),tg("Invalid insert result",a),!1}return ty(e,i),e.insertFragment(i),e.onChange(),!0}}return!1},e.insertTextOrHTMLData=n=>{var r;if(!e.selection)return tg("No selection, not inserting"),!1;N.next({type:"loading",isLoading:!0});let i=n.getData("text/html"),a=n.getData("text/plain");if(i||a){let o,l,s;if(tg("Inserting data",n),i)l=e_(o=(0,K.zW)(i,A.portableText).map(e=>(0,K.nX)(e,{blockTypeName:t})),{schemaTypes:A}),s="HTML";else{let e=String(a).replace(/[&<>"'`=/]/g,e=>tm[e]).split(/\n{2,}/).map(e=>e?"<p>".concat(e.replace(/(?:\r\n|\r|\n)/g,"<br/>"),"</p>"):"<p></p>").join("");l=e_(o=(0,K.zW)("<html><body>".concat(e,"</body></html>"),A.portableText).map(e=>(0,K.nX)(e,{blockTypeName:t})),{schemaTypes:A}),s="text"}let c=tu(o,A,x);if(!c.valid){let e="Could not validate the resulting portable text to insert.\n".concat(null==(r=c.resolution)?void 0:r.description,"\nTry to insert as plain text (shift-paste) instead.");return N.next({type:"error",level:"warning",name:"pasteError",description:e,data:c}),tg("Invalid insert result",c),!1}return tg("Inserting ".concat(s," fragment at ").concat(JSON.stringify(e.selection))),ty(e,l),e.insertFragment(l),e.onChange(),N.next({type:"loading",isLoading:!1}),!0}return N.next({type:"loading",isLoading:!1}),!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},[N,x,A]),P=(0,h.useMemo)(()=>(function(e,t,n,r){let i=["enter","tab","shift","delete","end"],a=r||tp,o=()=>e_([{_type:e.block.name,_key:t(),style:"normal",markDefs:[],children:[{_type:"span",_key:t(),text:"",marks:[]}]}],n)[0];return function(t){return t.pteWithHotKeys=r=>{Object.keys(a).forEach(e=>{if("marks"===e)for(let n in a[e]){if(i.includes(n))throw Error("The hotkey ".concat(n," is reserved!"));if((0,G.ZP)(n,r.nativeEvent)){r.preventDefault();let i=a[e];if(i){let e=i[n];td("HotKey ".concat(n," to toggle ").concat(e)),t.pteToggleMark(e)}}}if("custom"===e)for(let t in a[e]){if(i.includes(t))throw Error("The hotkey ".concat(t," is reserved!"));if((0,G.ZP)(t,r.nativeEvent)){let i=a[e];i&&(0,i[t])(r,n)}}});let l=(0,G.ZP)("enter",r.nativeEvent),s=(0,G.ZP)("tab",r.nativeEvent),c=(0,G.ZP)("shift+enter",r.nativeEvent),h=(0,G.ZP)("shift+tab",r.nativeEvent),f=(0,G.ZP)("backspace",r.nativeEvent),d=(0,G.ZP)("delete",r.nativeEvent);if(f&&t.selection&&t.selection.focus.path[0]>0&&M.e6.isCollapsed(t.selection)){let[e,n]=M.ML.node(t,M.y$.previous(t.selection.focus.path.slice(0,1))),[i]=M.ML.node(t,t.selection.focus,{depth:1});if(e&&i&&M.ML.isVoid(t,e)&&0===t.selection.focus.offset){td("Preventing deleting void block above"),r.preventDefault(),r.stopPropagation(),M.YR.removeNodes(t,{match:e=>e===i}),M.YR.select(t,n),t.onChange();return}}if(d&&t.selection&&0===t.selection.focus.offset&&M.e6.isCollapsed(t.selection)&&t.children[t.selection.focus.path[0]+1]){let[e]=M.ML.node(t,M.y$.next(t.selection.focus.path.slice(0,1))),[n,i]=M.ML.node(t,t.selection.focus,{depth:1});if(e&&n&&!M.ML.isVoid(t,n)&&M.ML.isVoid(t,e)){td("Preventing deleting void block below"),r.preventDefault(),r.stopPropagation(),M.YR.removeNodes(t,{match:e=>e===n}),M.YR.select(t,i),t.onChange();return}}if((s||h)&&t.selection){let[e]=M.ML.node(t,t.selection.focus,{depth:2}),[n]=(0,j.NG)(e)?M.ML.node(t,t.selection.focus,{depth:1}):[],i=e&&(0,j.DG)(n)&&(0,j.NG)(e)&&(e.marks||[]).filter(e=>(n.markDefs||[]).map(e=>e._key).includes(e)).length>0,[a]=M.e6.edges(t.selection),o=M.ML.isStart(t,a,a.path);e&&(0,j.NG)(e)&&(!i||o)&&t.pteIncrementBlockLevels(h)&&r.preventDefault()}if(l&&!c&&t.selection){let n;try{[n]=M.ML.node(t,t.selection.focus,{depth:1})}catch(e){}if(t.isListBlock(n)){t.pteEndList()&&r.preventDefault();return}if(t.isTextBlock(n)&&n.style&&n.style!==e.styles[0].value){let[,e]=M.e6.edges(t.selection);if(M.ML.isEnd(t,e,e.path)){M.ML.insertNode(t,o()),r.preventDefault();return}}if(n&&M.ML.isVoid(t,n)){M.ML.insertNode(t,o()),r.preventDefault();return}}if(c){r.preventDefault(),t.insertText("\n");return}if((0,G.ZP)("mod+z",r.nativeEvent)){r.preventDefault(),t.undo();return}((0,G.ZP)("mod+y",r.nativeEvent)||(0,G.ZP)("mod+shift+z",r.nativeEvent))&&(r.preventDefault(),t.redo())},t}})(A,x,_,n),[n,x,_,A]);(0,h.useMemo)(()=>b?(tX("Editable is in read only mode"),S(C)):(tX("Editable is in edit mode"),S(P(C))),[b,C,P,S]);let R=(0,h.useCallback)(e=>(0,c.jsx)(tG,{...e,readOnly:b,renderBlock:l,renderChild:s,renderListItem:d,renderStyle:u,schemaTypes:A,spellCheck:y}),[A,y,b,l,s,d,u]),I=(0,h.useCallback)(e=>{let t=(0,c.jsx)(tW,{...e,keyGenerator:x,schemaTypes:A,renderAnnotation:o,renderChild:s,renderDecorator:f,readOnly:b});return p&&e.leaf.placeholder&&""===e.text.text?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("div",{style:tQ,contentEditable:!1,
1children:p()}),t]}):t},[x,b,o,s,f,p,A]);(0,h.useEffect)(()=>{if(g){tX("Selection from props ".concat(JSON.stringify(g)));let e=function(e,t){if(!e||!t||0===t.length)return null;let n=null,r=null,{anchor:i,focus:a}=e;return(i&&t.find(e=>T()({_key:e._key},i.path[0]))&&(n=tB(i,t)),a&&t.find(e=>T()({_key:e._key},a.path[0]))&&(r=tB(a,t)),n&&r)?{anchor:n,focus:r}:null}(g,eb(C.children,L));if(null!==e){tX("Normalized selection from props ".concat(JSON.stringify(e)));let t=eR(e,C);t&&(M.YR.select(C,t),C.operations.some(e=>"set_selection"===e.type)||N.next({type:"selection",selection:e}),C.onChange())}}},[C,g,L,N]),(0,h.useEffect)(()=>{g&&tI.select(_,g)},[]);let B=(0,h.useCallback)(e=>{a&&void 0!==a(e)&&e.preventDefault()},[a]),O=(0,h.useCallback)(e=>{if(e.preventDefault(),C.selection){if(!i){tX("Pasting normally"),C.insertData(e.clipboardData);return}new Promise(t=>{var n;t(i({event:e,value:tI.getValue(_),path:(null==(n=C.selection)?void 0:n.focus.path)||[],schemaTypes:A}))}).then(t=>{if(tX("Custom paste function from client resolved",t),N.next({type:"loading",isLoading:!0}),!t||!t.insert){tX("No result from custom paste handler, pasting normally"),C.insertData(e.clipboardData);return}if(t&&t.insert){C.insertFragment(e_(t.insert,{schemaTypes:A})),N.next({type:"loading",isLoading:!1});return}console.warn("Your onPaste function returned something unexpected:",t)}).catch(e=>(N.next({type:"loading",isLoading:!1}),console.error(e),e))}},[N,i,_,A,C]),Y=(0,h.useCallback)(()=>{N.next({type:"focus"})},[N]),W=(0,h.useCallback)(()=>{N.next({type:"blur"})},[N]),z=(0,h.useCallback)(e=>{r&&r(e)},[r]),J=C.pteWithHotKeys,F=(0,h.useMemo)(()=>void 0===m?void 0:null===m?D():(e,t)=>{m(_,t)},[_,m]),V=(0,h.useCallback)(()=>ex(C.children,A)?[{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0},placeholder:!0}]:t0,[A,C]),U=(0,h.useMemo)(()=>(0,c.jsx)(w.CX,{autoFocus:!1,className:"pt-editable",decorate:V,onBlur:W,onCopy:B,onDOMBeforeInput:z,onFocus:Y,onKeyDown:J,onPaste:O,readOnly:b,renderElement:R,renderLeaf:I,scrollSelectionIntoView:F}),[V,B,J,z,W,Y,O,b,R,I,F]);return _?(0,c.jsx)("div",{ref:E,...k,children:U}):null})}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.