PageSourceSearch

https://ridecake.com/_next/static/chunks/53adca4f-7794e319f288ea56.js

js ridecake.com collected 2026-09-25 20:25:07 UTC 99,857 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3510],{60814:function(e,t,n){n.d(t,{L9:function(){return tb},_F:function(){return tw},iV:function(){return tK},q$:function(){return tS}});var r,i,l,o,a,s,c=n(85893),h=n(67294),f=n(19917),d=n(42006),p=n(34978),u=n(32817),g=n(1545),m=n(51313),y=n(82649),k=n(42076),_=n(62997),b=n.n(_),x=n(57122),w=n(74362),M=n(77493),E=n(50308),N=n.n(E),T=n(14176),D=n.n(T),A=n(52353),C=n.n(A),S=n(27361),L=n.n(S),P=n(85564),R=n.n(P),I=n(18446),B=n.n(I),j=n(42930),O=n(13218),Y=n.n(O),W=n(47037),z=n.n(W),J=n(30998),U=n.n(J),F=n(57557),V=n.n(F),$=n(66678),H=n.n($),q=n(44908),Z=n.n(q),G=n(18156),K=n(76590),X=n(23279),Q=n.n(X),ee=n(64429);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 l=null==(n=i.fields)?void 0:n.find(e=>"children"===e.name);if(!l)throw Error("Children field for block type found in schema (required)");let o=l.type.of;if(!o)throw Error("Valid types for block children not found in schema (required)");let a=o.find(e=>"span"===e.name);if(!a)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 l=(null==(n=i.type.options)?void 0:n.list)&&(null==(r=i.type.options.list)?void 0:r.filter(e=>e.value));if(!l||0===l.length)throw Error("The style fields need at least one style defined. I.e: {title: 'Normal', value: 'normal'}.");return l}(i),decorators:a.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:a,portableText:e,inlineObjects:s,blockObjects:c,annotations:a.annotations}}let ei="sanity-pte:";function el(e){let t="".concat(ei).concat(e);return b()&&b().enabled(t)?b()(t):b()(ei)}b()(ei);let eo=()=>(0,x.E2)(12),ea=(0,h.createContext)(eo),es=()=>{let e=(0,h.useContext)(ea);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;var em={};function ey(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{type:"setIfMissing",path:t,value:e}}r={get exports(){return em},set exports(v){em=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 l=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,a=this.diff_commonPrefix(e,t),s=e.substring(0,a);e=e.substring(a),t=t.substring(a),a=this.diff_commonSuffix(e,t);var c=e.substring(e.length-a);e=e.substring(0,e.length-a),t=t.substring(0,t.length-a);var h=this.diff_compute_(e,t,o,l);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 l,o=e.length>t.length?e:t,a=e.length>t.length?t:e,s=o.indexOf(a);if(-1!=s)return l=[new i.Diff(1,o.substring(0,s)),new i.Diff(0,a),new i.Diff(1,o.substring(s+a.length))],e.length>t.length&&(l[0][0]=l[2][0]=-1),l;if(1==a.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 l=r.lineArray,o=this.diff_main(e,t,!1,n);this.diff_charsToLines_(o,l),this.diff_cleanupSemantic(o),o.push(new i.Diff(0,""));for(var a=0,s=0,c=0,h="",f="";a<o.length;){switch(o[a][0]){case 1:c++,f+=o[a][1];break;case -1:s++,h+=o[a][1];break;case 0:if(s>=1&&c>=1){o.splice(a-s-c,s+c),a=a-s-c;for(var d=this.diff_main(h,f,!1,n),p=d.length-1;p>=0;p--)o.splice(a,0,d[p]);a+=d.length}c=0,s=0,h="",f=""}a++}return o.pop(),o},i.prototype.diff_bisect_=function(e,t,n){for(var r=e.length,l=t.length,o=Math.ceil((r+l)/2),a=2*o,s=Array(a),c=Array(a),h=0;h<a;h++)s[h]=-1,c[h]=-1;s[o+1]=0,c[o+1]=0;
vendor: 16,669 bytes, line 1
1for(var f=r-l,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<l&&e.charAt(_)==t.charAt(x);)_++,x++;if(s[b]=_,_>r)u+=2;else if(x>l)p+=2;else if(d){var w=o+f-k;if(w>=0&&w<a&&-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,N=(M=E==-y||E!=y&&c[w-1]<c[w+1]?c[w+1]:c[w-1]+1)-E;M<r&&N<l&&e.charAt(r-M-1)==t.charAt(l-N-1);)M++,N++;if(c[w]=M,M>r)m+=2;else if(N>l)g+=2;else if(!d){var b=o+f-E;if(b>=0&&b<a&&-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 l=e.substring(0,n),o=t.substring(0,r),a=e.substring(n),s=t.substring(r),c=this.diff_main(l,o,!1,i),h=this.diff_main(a,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,a=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]):(a==l&&(s=e.substring(i),o=e.length),t+=String.fromCharCode(a),r[s]=a,n[a++]=s),i=o+1}return t}n[0]="";var l=4e4;return l=65535,{chars1:i(e),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=[],l=0;l<r.length;l++)i[l]=t[r.charCodeAt(l)];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,l=0;n<i;)e.substring(l,i)==t.substring(l,i)?l=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,l=0;n<i;)e.substring(e.length-i,e.length-l)==t.substring(t.length-i,t.length-l)?l=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 l=0,o=1;;){var a=e.substring(i-o),s=t.indexOf(a);if(-1==s)return l;o+=s,(0==s||e.substring(i-o)==t.substring(0,o))&&(l=o,o++)}},i.prototype.diff_halfMatch_=function(e,t){if(this.Diff_Timeout<=0)return null;var n,r,i,l,o,a=e.length>t.length?e:t,s=e.length>t.length?t:e;if(a.length<4||2*s.length<a.length)return null;var c=this;function h(e,t,n){for(var r,i,l,o,a=e.substring(n,n+Math.floor(e.length/4)),s=-1,h="";-1!=(s=t.indexOf(a,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),l=t.substring(0,s-d),o=t.substring(s+f))}return 2*h.length>=e.length?[r,i,l,o,h]:null}var f=h(a,s,Math.ceil(a.length/4)),d=h(a,s,Math.ceil(a.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],l=n[2],o=n[3]):(l=n[0],o=n[1],r=n[2],i=n[3]),[r,i,l,o,n[4]]):null},i.prototype.diff_cleanupSemantic=function(e){for(var t=!1,n=[],r=0,l=null,o=0,a=0,s=0,c=0,h=0;o<e.length;)0==e[o][0]?(n[r++]=o,a=c,s=h,c=0,h=0,l=e[o][1]):(1==e[o][0]?c+=e[o][1].length:h+=e[o][1].length,l&&l.length<=Math.max(a,s)&&l.length<=Math.max(c,h)&&(e.splice(n[r-1],0,new i.Diff(-1,l)),e[n[r-1]+1][0]=1,r--,o=--r>0?n[r-1]:-1,a=0,s=0,c=0,h=0,l=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),l=n.match(i.nonAlphaNumericRegex_),o=r.match(i.nonAlphaNumericRegex_),a=l&&n.match(i.whitespaceRegex_),s=o&&r.match(i.whitespaceRegex_),c=a&&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:l&&!a&&s?3:a||s?2:l||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],l=e[n][1],o=e[n+1][1],a=this.diff_commonSuffix(r,l);if(a){var s=l.substring(l.length-a);r=r.substring(0,r.length-a),l=s+l.substring(0,l.length-a),o=s+o}for(var c=r,h=l,f=o,d=t(r,l)+t(l,o);l.charAt(0)===o.charAt(0);){r+=l.charAt(0),l=l.substring(1)+o.charAt(0),o=o.substring(1);var p=t(r,l)+t(l,o);p>=d&&(d=p,c=r,h=l,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,l=null,o=0,a=!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,a=c,s=h,l=e[o][1]):(r=0,l=null),c=h=!1):(-1==e[o][0]?h=!0:c=!0,l&&(a&&s&&c&&h||l.length<this.Diff_EditCost/2&&a+s+c+h==3)&&(e.splice(n[r-1],0,new i.Diff(-1,l)),e[n[r-1]+1][0]=1,r--,l=null,a&&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,l=0,o="",a="";n<e.length;)switch(e[n][0]){case 1:l++,a+=e[n][1],n++;break;case -1:r++,o+=e[n][1],n++;break;case 0:r+l>1?(0!==r&&0!==l&&(0!==(t=this.diff_commonPrefix(a,o))&&(n-r-l>0&&0==e[n-r-l-1][0]?e[n-r-l-1][1]+=a.substring(0,t):(e.splice(0,0,new i.Diff(0,a.substring(0,t))),n++),a=a.substring(t),o=o.substring(t)),0!==(t=this.diff_commonSuffix(a,o))&&(e[n][1]=a.substring(a.length-t)+e[n][1],a=a.substring(0,a.length-t),o=o.substring(0,o.length-t))),n-=r+l,e.splice(n,r+l),o.length&&(e.splice(n,0,new i.Diff(-1,o)),n++),a.length&&(e.splice(n,0,new i.Diff(1,a)),n++),n++):0!==n&&0==e[n-1][0]?(e[n-1][1]+=e[n][1],e.splice(n,1)):n++,l=0,r=0,o="",a=""}""===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,l=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++)l=r,o=i;return e.length!=n&&-1===e[n][0]?o:o+(t-l)},i.prototype.diff_prettyHtml=function(e){for(var t=[],n=/&/g,r=/</g,i=/>/g,l=/\n/g,o=0;o<e.length;o++){var a=e[o][0],s=e[o][1].replace(n,"&amp;").replace(r,"&lt;").replace(i,"&gt;").replace(l,"&para;<br>");switch(a){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 l=e[i][0],o=e[i][1];switch(l){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,l=0,o=t.split(/\t/g),a=0;a<o.length;a++){var s=o[a].substring(1);switch(o[a].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(l,l+=c);"="==o[a].charAt(0)?n[r++]=new i.Diff(0,h):n[r++]=new i.Diff(-1,h);break;default:if(o[a])throw Error("Invalid diff operation in diff_fromDelta: "+o[a])}}if(l!=e.length)throw Error("Delta length ("+l+") 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,l,o=this.match_alphabet_(t),a=this;function s(e,r){var i=e/t.length,l=Math.abs(n-r);return a.Match_Distance?i+l/a.Match_Distance:l?1:i}var c=this.Match_Threshold,h=e.indexOf(t,n);-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|((l[y+1]|l[y])<<1|1)|l[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;l=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 l=t.substring(e.start2-r,e.start2);l&&e.diffs.unshift(new i.Diff(0,l));var o=t.substring(e.start2+e.length1,e.start2+e.length1+r);o&&e.diffs.push(new i.Diff(0,o)),e.start1-=l.length,e.start2-=l.length,e.length1+=l.length+o.length,e.length2+=l.length+o.length}},i.prototype.patch_make=function(e,t,n){if("string"==typeof e&&"string"==typeof t&&void 0===n)r=e,(l=this.diff_main(r,t,!0)).length>2&&(this.diff_cleanupSemantic(l),this.diff_cleanupEfficiency(l));else if(e&&"object"==typeof e&&void 0===t&&void 0===n)l=e,r=this.diff_text1(l);else if("string"==typeof e&&t&&"object"==typeof t&&void 0===n)r=e,l=t;else if("string"==typeof e&&"string"==typeof t&&n&&"object"==typeof n)r=e,l=n;else throw Error("Unknown call format to patch_make.");if(0===l.length)return[];for(var r,l,o=[],a=new i.patch_obj,s=0,c=0,h=0,f=r,d=r,p=0;p<l.length;p++){var u=l[p][0],g=l[p][1];switch(s||0===u||(a.start1=c,a.start2=h),u){case 1:a.diffs[s++]=l[p],a.length2+=g.length,d=d.substring(0,h)+g+d.substring(h);break;case -1:a.length1+=g.length,a.diffs[s++]=l[p],d=d.substring(0,h)+d.substring(h+g.length);break;case 0:g.length<=2*this.Patch_Margin&&s&&l.length!=p+1?(a.diffs[s++]=l[p],a.length1+=g.length,a.length2+=g.length):g.length>=2*this.Patch_Margin&&s&&(this.patch_addContext_(a,f),o.push(a),a=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_(a,f),o.push(a)),o},i.prototype.patch_deepCopy=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n],l=new i.patch_obj;l.diffs=[];for(var o=0;o<r.diffs.length;o++)l.diffs[o]=new i.Diff(r.diffs[o][0],r.diffs[o][1]);l.start1=r.start1,l.start2=r.start2,l.length1=r.length1,l.length2=r.length2,t[n]=l}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=[],l=0;l<e.length;l++){var o=e[l].start2+r,a=this.diff_text1(e[l].diffs),s=-1;if(a.length>this.Match_MaxBits?-1!=(h=this.match_main(t,a.substring(0,this.Match_MaxBits),o))&&(-1==(s=this.match_main(t,a.substring(a.length-this.Match_MaxBits),o+a.length-this.Match_MaxBits))||h>=s)&&(h=-1):h=this.match_main(t,a,o),-1==h)i[l]=!1,r-=e[l].length2-e[l].length1;else if(i[l]=!0,r=h-o,f=-1==s?t.substring(h,h+a.length):t.substring(h,s+this.Match_MaxBits),a==f)t=t.substring(0,h)+this.diff_text2(e[l].diffs)+t.substring(h+a.length);else{var c=this.diff_main(a,f,!1);if(a.length>this.Match_MaxBits&&this.diff_levenshtein(c)/a.length>this.Patch_DeleteThreshold)i[l]=!1;else{this.diff_cleanupSemanticLossless(c);for(var h,f,d,p=0,u=0;u<e[l].diffs.length;u++){var g=e[l].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 l=e[0],o=l.diffs;if(0==o.length||0!=o[0][0])o.unshift(new i.Diff(0,n)),l.start1-=t,l.start2-=t,l.length1+=t,l.length2+=t;else if(t>o[0][1].length){var a=t-o[0][1].length;o[0][1]=n.substring(o[0][1].length)+o[0][1],l.start1-=a,l.start2-=a,l.length1+=a,l.length2+=a}if(0==(o=(l=e[e.length-1]).diffs).length||0!=o[o.length-1][0])o.push(new i.Diff(0,n)),l.length1+=t,l.length2+=t;else if(t>o[o.length-1][1].length){var a=t-o[o.length-1][1].length;o[o.length-1][1]+=n.substring(0,a),l.length1+=a,l.length2+=a}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 l=r.start1,o=r.start2,a="";0!==r.diffs.length;){var s=new i.patch_obj,c=!0;for(s.start1=l-a.length,s.start2=o-a.length,""!==a&&(s.length1=s.length2=a.length,s.diffs.push(new i.Diff(0,a)));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,l+=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,l+=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))}a=(a=this.diff_text2(s.diffs)).substring(a.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,l=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;r<n.length;){var o=n[r].match(l);if(!o)throw Error("Invalid patch string: "+n[r]);var a=new i.patch_obj;for(t.push(a),a.start1=parseInt(o[1],10),""===o[2]?(a.start1--,a.length1=1):"0"==o[2]?a.length1=0:(a.start1--,a.length1=parseInt(o[2],10)),a.start2=parseInt(o[3],10),""===o[4]?(a.start2--,a.length2=1):"0"==o[4]?a.length2=0:(a.start2--,a.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)a.diffs.push(new i.Diff(-1,c));else if("+"==s)a.diffs.push(new i.Diff(1,c));else if(" "==s)a.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," ")}
1,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 ek=new em.diff_match_patch;function ev(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=ek.patch_make(e,t).map(e=>e.toString()).join("");return{type:"diffMatchPatch",path:n,value:r}}function e_(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return{type:"insert",path:n,position:t,items:e}}function eb(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{type:"set",path:t,value:e}}function ex(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:"unset",path:e}}let ew=[];function eM(e,t){let n=t[e._key];return n&&B()(e,n)?n:(t[e._key]=e,e)}function eE(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,...l}=e,o=[{_key:"".concat(i,"-void-child"),_type:"span",text:"",marks:[]}],a=e&&e._type===n.block.name;if(a){let a=!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?(a=!0,eM({_type:t,_key:n,children:o,value:i,__inline:!0},r)):e});return!s&&!c&&!a&&M.W_.isElement(e)?e:(s&&(l.style=n.styles[0].value),c&&(l.markDefs=ew),eM({_type:t,_key:i,...l,children:h},r))}return eM({_type:t,_key:i,children:o,value:l},r)}):[]}function eN(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,l=e.children.map(e=>{let{_type:r}=e;if("value"in e&&"span"!==r){t=!0;let{value:r,_key:i,_type:l,__inline:o,children:a,...s}=e;return eM({...s,...r,_key:i,_type:l},n)}return e});return t?eM({...e,children:l,_key:r,_type:i},n):e}let l="value"in e&&e.value;return eM({_key:r,_type:i,..."object"==typeof l?l:{}},n)})}function eT(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}let eD=el("operationToPatches");function eA(e,t,n){let r;let i=[e.path[0]];if(!t)return null;let l=t[i[0]];if(!l)return null;let o=[{_key:l._key}];if(l._type!==n.block.name)return o;let a=e.path.slice(0,2),s=Array.isArray(l.children)&&l.children[a[1]];return s&&(r=["children",{_key:s._key}]),r?[...o,...r]:o}function eC(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]],l=n.children.findIndex(e=>B()([{_key:e._key}],i));if(l>=0&&n.children[l]){let e=n.children[l];return M.W_.isElement(e)&&t.isVoid(e)?r.concat(l).concat(0):r.concat(l)}return r}function eS(e,t,n){if(!t)return null;let r=null,i=null,l=t.anchor&&eA(t.anchor,e,n);l&&t.anchor&&(r={path:l,offset:t.anchor.offset});let o=t.focus&&eA(t.focus,e,n);return o&&t.focus&&(i={path:o,offset:t.focus.offset}),r&&i?{anchor:r,focus:i}:null}function eL(e,t){if(!e||!t)return null;let n={path:eC(e.anchor,t),offset:e.anchor.offset},r={path:eC(e.focus,t),offset:e.focus.offset};return n&&r?{anchor:n,focus:r}:null}let eP=el("API:editable"),eR=new WeakMap;function eI(e,t){eR.set(e,!0),t(),eR.set(e,!1)}let eB=new WeakMap;function ej(e,t){let n=eB.get(e);eB.set(e,!1),t(),eB.set(e,n)}let eO="before",eY="after";function eW(){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 ez=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty),eJ={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(eJ),eF=new em.diff_match_patch,eV={replace:(e,t)=>t,set:(e,t)=>t,setIfMissing:(e,t)=>void 0===e?t:e,unset(e,t){},diffMatchPatch:(e,t)=>eF.patch_apply(eF.patch_fromText(t),e)[0]},e$=Object.keys(eV);function eH(e,t){let n=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||!ez(t.value,"from")||!ez(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,l=function(e,t){if("number"==typeof t)return t;let n=U()(e,t);return -1!==n&&n}(e,r);if(!1===l)return n;if(0===i.length){if("insert"===t.type){let{position:n,items:r}=t;return function(e,t,n){if(t!==eO&&t!==eY)throw Error('Invalid position "'.concat(t,'", must be either ').
1concat(eO," or ").concat(eY));for(var r=arguments.length,i=Array(r>3?r-3:0),l=3;l<r;l++)i[l-3]=arguments[l];let o=eW(...i);if(0===e.length)return o;let a=e.length,s=Math.abs((a+n)%a)%a,c=e.slice();return c.splice("after"===t?s+1:s,0,...eW(o)),c}(e,n,l,r)}if("unset"===t.type){if("number"!=typeof l)throw Error('Expected array index to be a number, instead got "'.concat(l,'"'));return n.splice(l,1),n}}return n[l]=eH(n[l],{...t,path:i}),n}(e,t):z()(e)?function(e,t){if(!e$.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=eV[t.type];if(n)return n(e,t.value);throw Error("Unknown patch type")}(e,t):Y()(e)?function(e,t){let n=H()(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?V()(n,r):(n[r]=eH(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 eJ[t.type](e,t.value)}(e,t);return n}let eq=el("patchToOperations"),eZ=new em.diff_match_patch;function eG(e){return"object"==typeof e&&"_key"in e}function eK(e){let t=null;return e.concat("").reverse().forEach(e=>{eG(e)&&(t=e._key)}),t}function eX(e,t){eq("Children ".concat(t,":"),JSON.stringify(e.children,null,2)),eq("Selection ".concat(t,": "),JSON.stringify(e.selection,null,2))}let eQ=el("plugin:withUndoRedo"),e0=new em.diff_match_patch,e1=new WeakMap,e2=new WeakMap,e3=e=>e2.get(e),e6=e=>!!eB.get(e)&&e1.get(e);function e4(e,t,n){let r={...n};if("insert"===t.type&&1===t.path.length)return[e5(e,t,n,t.items.length)];if("unset"===t.type&&1===t.path.length)return[e5(e,t,n,-1)];if("unset"===t.type&&0===t.path.length)return eQ("Adjusting selection for unset everything patch and ".concat(n.type," operation")),[n];if("diffMatchPatch"===t.type){let i=e.children.findIndex(e=>B()({_key:e._key},t.path[0])),l=e.children[i];if(M.W_.isElement(l)&&Array.isArray(l.children)){let e=l.children.findIndex(e=>B()({_key:e._key},t.path[2])),o=e0.patch_fromText(t.value)[0];if(!o)return eQ("Could not parse diffMatchPatch",t),[n];let a=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-=a:e.position+=a,[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+=a,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-=a,r=e}return[r]}}}}return[n]}function e5(e,t,n,r){let i=e.children.findIndex(e=>B()({_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 eQ("Adjusting ".concat(n.type," for block ").concat(t.type),n.path,i),e.path=i,e}return n}let e9=(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)),e7=(e,t)=>"set_selection"!==e.type||null!==e.newProperties,e8=(e,t)=>
1!!t&&"set_selection"===e.type&&"set_selection"===t.type,te=e=>"set_selection"!==e.type;function tt(e,t){let n=e6(e);e1.set(e,!1),t(),e1.set(e,n)}let tn=el("plugin:withPatches"),tr=el("plugin:withPlaceholderBlock"),ti=el("plugin:withPortableTextBlockStyle"),tl=el("plugin:withPortableTextLists"),to=el("plugin:withPortableTextMarkModel"),ta=el("plugin:withPortableTextSelections"),ts=el("plugin:withSchemaTypes"),tc=el("plugin:withUtils"),th=el("plugin:withHotKeys"),tf={marks:{"mod+b":"strong","mod+i":"em","mod+u":"underline","mod+'":"code"},custom:{}};function td(e,t,n){let r=null,i=!0,l=[t.span.name,...t.inlineObjects.map(e=>e.name)],o=[t.block.name,...t.blockObjects.map(e=>e.name)];return void 0===e?{valid:!0,resolution:null,value:e}:Array.isArray(e)&&0!==e.length?(e.some((e,a)=>{if(!Y()(e))return r={patches:[ex([a])],description:"Block must be an object, got ".concat(String(e)),action:"Unset invalid item",item:e},!0;if(!e._key)return r={patches:[eb({...e,_key:n()},[a])],description:"Block at index ".concat(a," 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:[eb({...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:[ex([{_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:[ex([{_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:[eb({...e,markDefs:[]},[{_key:e._key}])],description:"Block is missing required key 'markDefs'.",action:"Add empty markDefs array",item:e},!0;let o=Z()(R()(e.children.filter(e=>e._type===t.span.name).map(e=>e.marks||[]))),a=o.filter(e=>!t.decorators.map(e=>e.value).includes(e)),s=a.filter(t=>!!e.markDefs&&!e.markDefs.find(e=>e._key===t));if(s.length>0){let n=e.children.filter(e=>e._type===t.span.name&&Array.isArray(e.marks)&&e.marks.some(e=>s.includes(e)));if(n)return r={patches:n.map(t=>eb((t.marks||[]).filter(e=>!s.includes(e)),[{_key:e._key},"children",{_key:t._key},"marks"])),description:"Block with _key '".concat(e._key,"' contains marks (").concat(s.join(", "),") not supported by the current content model."),action:"Remove invalid marks",item:e},!0}if(e.children&&0===e.children.length){let i={_type:t.span.name,_key:n(),text:""};return r={patches:[e_([i],"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)=>{if(!i._key){let t={...i,_key:n()};return r={patches:[eb(t,[{_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}return i._type&&!1!==l.includes(i._type)?i._type===t.span.name&&void 0===i.text&&(r={patches:[eb({...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:[ex([{_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)})&&(i=!1)}return!1})&&(i=!1),{valid:i,resolution:r,value:e}):{valid:!1,resolution:{patches:[ex([])],description:"Editor value must be an array of Portable Text blocks, or undefined.",action:"Unset the value",item:e},value:e}}let tp=el("plugin:withInsertData"),tu={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function tg(e,t,n){if(!e.selection)return;let[r,i]=M.ML.node(e,e.selection,{depth:1});if(e.isTextBlock(r)&&e.isTextBlock(t[0])){let{markDefs:n}=r;tp("Mixing markDefs of focusBlock and fragments[0] block",n,t[0].markDefs),B()(n,t[0].markDefs)||M.YR.setNodes(e,{markDefs:Z()([...t[0].markDefs||[],...n||[]])},{at:i,mode:"lowest",voids:!1})}let l=eT(e.children,n);l?(M.YR.splitNodes(e,{at:[0,0]}),e.insertFragment(t),M.YR.removeNodes(e,{at:[0]})):e.insertFragment(t),e.onChange()}let tm=new WeakMap,ty=(e,t)=>{var n;let r;let i=e,{keyGenerator:l,portableTextEditor:o,patches$:a,readOnly:s,maxBlocks:c,isPending:h}=t,{schemaTypes:y,change$:k}=o;i.subscriptions=[],i.destroy?i.destroy():tm.set(i,{apply:i.apply,onChange:i.onChange,normalizeNode:i.normalizeNode});let _=function(e){let t=e.block.name;
1return{insertNodePatch:function(e,n,r){let i=r[n.path[0]];if(1===n.path.length){let e=0===n.path[0]?"before":"after",l=r[n.path[0]-1],o=0===n.path[0]?null==i?void 0:i._key:null==l?void 0:l._key;return o?[e_([eN([n.node],t)[0]],e,[{_key:o}])]:[ey(r,[]),e_([eN([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",l=eN([{_key:"bogus",_type:t,children:[n.node]}],t)[0],o=l.children[0];return[e_([o],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){eD("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 l=[{_key:r._key},"children",{_key:i._key},"text"],o=n[t.path[0]],a=e.isTextBlock(o)&&o.children[t.path[1]],s=e.isTextSpan(a)?a.text:"",c=ev(s,i.text,l);return c.value.length?[c]:[]},mergeNodePatch:function(e,n,r){let i=[];if(1===n.path.length){let l=r[n.path[0]],o=l&&l._key;if(o){let r=eN([e.children[n.path[0]-1]],t)[0];i.push(eb(r,[{_key:r._key}])),i.push(ex([{_key:o}]))}else throw Error("Target key not found!")}else if(2===n.path.length){let t=r[n.path[0]],l=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 a=o.children[n.path[1]-1];e.isTextSpan(a)&&(i.push(eb(a.text,[{_key:t._key},"children",{_key:a._key},"text"])),l&&i.push(ex([{_key:t._key},"children",{_key:l._key}])))}else throw Error("Unexpected path encountered: ".concat(JSON.stringify(n.path)));return i},moveNodePatch:function(e,n,r){let i=[],l=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(ex([{_key:l._key}])),i.push(e_([eN([l],t)[0]],e,[{_key:o._key}]))}else if(2===n.path.length&&e.isTextBlock(l)&&e.isTextBlock(o)){let e=l.children[n.path[1]],r=o.children[n.newPath[1]],a=n.newPath[1]===o.children.length?"after":"before",s=eN([l],t)[0].children[n.path[1]];i.push(ex([{_key:l._key},"children",{_key:e._key}])),i.push(e_([s],a,[{_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[ex([{_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?[ex([{_key:r._key},"children",{_key:n._key}])]:(eD("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,l=e.isTextSpan(i)?i:void 0;if(i&&!l)throw Error("Expected span");if(!l)throw Error("Could not find child");let o=[{_key:r._key},"children",{_key:l._key},"text"],a=n[t.path[0]],s=e.isTextBlock(a)&&a.children[t.path[1]],c=e.isTextSpan(s)&&s.text,h=ev(c||"",l.text,o);return h.value?[h]:[]},setNodePatch:function(e,n){if(1===n.path.length){let r=e.children[n.path[0]];if("string"!=typeof r._key)throw Error("Expected block to have a _key");let i=D()({...e.children[n.path[0]],...n.newProperties},C());return[eb(eN([i],t)[0],[{_key:r._key}])]}if(2===n.path.length){let t=e.children[n.path[0]];if(e.isTextBlock(t)){let e=t.children[n.path[1]];if(e){let r=t._key,i=e._key,l=[];return Object.keys(n.newProperties).forEach(e=>{let t=L()(n.newProperties,e);l.push(eb(t,[{_key:r},"children",{_key:i},e]))}),l}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=[],l=e.children[n.path[0]];
1if(!e.isTextBlock(l))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=eN([e.children[n.path[0]+1]],t)[0];if(r){i.push(e_([r],"after",[{_key:l._key}]));let e=o.children.slice(n.position);e.forEach(e=>{let t=[{_key:o._key},"children",{_key:e._key}];i.push(ex(t))})}}return i}if(2===n.path.length){let r=l.children[n.path[1]];if(e.isTextSpan(r)){let e=eN([{...l,children:l.children.slice(n.path[1]+1,n.path[1]+2)}],t)[0].children;i.push(e_(e,"after",[{_key:l._key},"children",{_key:r._key}])),i.push(eb(r.text,[{_key:l._key},"children",{_key:r._key},"text"]))}}return i}}}(y),b=function(e){eR.set(e,!1);let{apply:t,normalizeNode:n}=e;return e.apply=n=>{if("split_node"===n.type&&(n.properties={...n.properties,_key:l()}),"insert_node"===n.type){let t=!eR.get(e)||!("_key"in n.node);M.ML.isEditor(n.node)||(n.node={...n.node,...t?{_key:l()}:{}})}t(n)},e.normalizeNode=t=>{let[r,i]=t;if(M.W_.isElement(r)&&r._type===y.block.name){for(let[t,n]of(r._key||M.YR.setNodes(e,{_key:l()},{at:i}),M.NB.children(e,i)))if(!t._key){M.YR.setNodes(e,{_key:l()},{at:n});return}}n(t)},e},x=function(e){e.isTextBlock=e=>(0,j.DG)(e)&&e._type===y.block.name,e.isTextSpan=e=>(0,j.NG)(e)&&e._type==y.span.name,e.isListBlock=e=>(0,j.KA)(e)&&e._type===y.block.name,e.isVoid=e=>y.block.name!==e._type&&(y.blockObjects.map(e=>e.name).includes(e._type)||y.inlineObjects.map(e=>e.name).includes(e._type)),e.isInline=e=>{let t=y.inlineObjects.map(e=>e.name);return t.includes(e._type)&&"__inline"in e&&!0===e.__inline};let{apply:t}=e;return e.apply=e=>{let n="insert_node"===e.type&&2===e.path.length&&M.xv.isText(e.node)&&void 0===e.node._type;if(n){let t={...e.node,_type:"span"};e.node=t,ts("Setting span type to child without a type",e)}t(e)},e},E=function(e){return o.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=eL(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 eN([t],y.block.name,eu.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:y.block.name,children:[t]},r=eN([n],y.block.name,eu.get(e));if(e.isTextBlock(r[0]))return r[0].children[0]}}catch(e){}},insertChild:(t,n)=>{var r;if(!e.selection)throw Error("The editor has no selection");let[i]=Array.from(M.ML.nodes(e,{at:e.selection.focus,match:t=>M.ML.isBlock(e,t)}))[0]||[void 0];if(!i)throw Error("No focus block");if(i&&M.ML.isVoid(e,i))throw Error("Can't insert childs into block objects");let a=eE([{_key:l(),_type:y.block.name,children:[{_key:l(),_type:t.name,...n||{}}]}],o)[0],s=a.children[0];return M.ML.insertNode(e,s),e.onChange(),(null==(r=eS(eN(e.children,y.block.name,eu.get(e)),e.selection,y))?void 0:r.focus.path)||[]},insertBlock:(t,n)=>{var r;if(!e.selection)throw Error("The editor has no selection");let i=eE([{_key:l(),_type:t.name,...n||{}}],o)[0];return M.ML.insertNode(e,i),e.onChange(),(null==(r=eS(eN(e.children,y.block.name,eu.get(e)),e.selection,y))?void 0:r.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=>![y.block.name,y.span.name].includes(e._type),findByPath:t=>{let n=eL({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[eN([r],y.block.name)[0],[{_key:r._key}]];let i=eN([r],y.block.name,eu.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=[],r=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});for(let[i,l]of r){let[r]=M.ML.node(e,l,{depth:1});
1e.isTextBlock(r)&&(null==(t=r.markDefs)||t.forEach(e=>{M.xv.isText(i)&&i.marks&&Array.isArray(i.marks)&&i.marks.includes(e._key)&&n.push(e)}))}return n}catch(e){return[]}},addAnnotation:(t,n)=>{let{selection:r}=e;if(r){let[i]=M.ML.node(e,r.focus,{depth:1});if(M.W_.isElement(i)&&i._type===y.block.name){let o=l();if(e.isTextBlock(i)){M.YR.setNodes(e,{markDefs:[...i.markDefs||[],{_type:t.name,_key:o,...n}]},{at:r.focus}),e.onChange(),M.e6.isCollapsed(r)&&(e.pteExpandToWord(),e.onChange());let[a]=M.ML.node(e,r.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(a)&&(M.YR.setNodes(e,{marks:[...a.marks||[],o]},{at:e.selection,match:e=>e._type===y.span.name}),e.onChange())}),M.ML.normalize(e),e.onChange();let t=eS(eN(e.children,y.block.name,eu.get(e)),e.selection,y);if(t&&"string"==typeof i._key)return M.ML.withoutNormalizing(e,()=>{e.selection&&(M.YR.insertNodes(e,[{_type:"span",text:"",marks:[],_key:l()}],{at:M.e6.end(e.selection)}),e.onChange())}),{spanPath:t.focus.path,markDefPath:[{_key:i._key},"markDefs",{_key:o}]}}}}}},delete:(t,n)=>{if(t){let r=eL(t,e);if(r){if(!(null==n?void 0:n.mode)||(null==n?void 0:n.mode)==="selected"){eP("Deleting content in selection"),M.YR.delete(e,{at:r,hanging:!0,voids:!0}),e.onChange();return}let t=M.ML.nodes(e,{at:r,match:t=>(null==n?void 0:n.mode)==="blocks"?(eP("Deleting blocks touched by selection"),e.isTextBlock(t)||!e.isTextBlock(t)&&M.W_.isElement(t)):(eP("Deleting children touched by selection"),t._type===y.span.name||!e.isTextBlock(t)&&M.W_.isElement(t))}),i=[...t];i.forEach(t=>{let[,n]=t;M.YR.removeNodes(e,{at:n,voids:!0,hanging:!0})}),e.onChange()}}},removeAnnotation:t=>{let{selection:n}=e;if(eP("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,()=>{if(n&&M.e6.isExpanded(n)){if(!(n=e.selection))return;M.YR.setNodes(e,{},{match:M.xv.isText,split:!0}),e.onChange();let r=[...M.ML.nodes(e,{at:n,match:e=>M.xv.isText(e)&&void 0!==e.marks&&Array.isArray(e.marks)&&e.marks.length>0})];r.forEach(n=>{var r;let[i,l]=n,[o]=M.ML.node(e,l,{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:l,voids:!1,split:!1})}}))})}}),M.ML.normalize(e),e.onChange()}},getSelection:()=>{let t=null;if(e.selection){let n=eg.get(e.selection);if(n)return n;t=eS(eN(e.children,y.block.name,eu.get(e)),e.selection,y),eg.set(e.selection,t)}return t},getValue:()=>eN(e.children,y.block.name,eu.get(e)),isCollapsedSelection:()=>!!e.selection&&M.e6.isCollapsed(e.selection),isExpandedSelection:()=>!!e.selection&&M.e6.isExpanded(e.selection),insertBreak:()=>{e.insertBreak(),e.onChange()}}),e},T=function(e){let t,n,{change$:r,isPending:i,patches$:l,patchFunctions:o,readOnly:a,schemaTypes:s}=e,c=function(e,n){let r=!1;eq("\n\nNEW PATCH ============================================================="),eq(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=eE(n,{schemaTypes:s},ep.get(e)),l=eK(t.path),o=Math.max(0,e.children.findIndex((e,n)=>l?e._key===l:n===t.path[0])),a="after"===r?o+1:o;return eq("Inserting blocks at path [".concat(a,"]")),eX(e,"before"),M.YR.insertNodes(e,i,{at:[a]}),eX(e,"after"),!0}let{items:n,position:r}=t,i=eK(t.path),l=e.children.findIndex((e,n)=>i?e._key===i:n===t.path[0]),o=e.children&&l>-1?e.children[l]:void 0,a=e.isTextBlock(o)?o.children.findIndex((e,n)=>eG(t.path[2])?e._key===t.path[2]._key:n===t.path[2]):0,c=o&&eE([{...o,children:n}],{schemaTypes:s},ep.get(e)),h=[l,"after"===r?a+1:a];return eq("Inserting children at path ".concat(h)),eX(e,"before"),c&&M.W_.isElement(c[0])&&M.YR.insertNodes(e,c[0].children,{at:h}),eX(e,"after"),!0}(e,n);break;case"unset":r=function(e,t,n){var r;if(0===t.path.length)return eq("Removing everything"),eX(e,"before"),M.YR.deselect(e),e.children.forEac
1h((t,n)=>{M.YR.removeNodes(e,{at:[n]})}),eX(e,"after"),!0;if(1===t.path.length){let n=eK(t.path),r=e.children.findIndex((e,r)=>n?e._key===n:r===t.path[0]);if(-1===r)return eq("Could not find block to unset at path ".concat(JSON.stringify(t.path))),!1;if(eq("Removing block at path [".concat(r,"]")),eX(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]}),eX(e,"after"),!0}let i=e.children.findIndex((e,n)=>eG(t.path[0])?e._key===t.path[0]._key:n===t.path[0]),l=i>-1?e.children[i]:void 0;if(e.isTextBlock(l)&&"children"===t.path[1]&&3===t.path.length){let o=l.children.findIndex((e,n)=>eG(t.path[2])?e._key===t.path[2]._key:n===t.path[2]),a=[i,o],s=e.selection&&{...e.selection},c=B()(null==(r=e.selection)?void 0:r.focus.path,a);if(-1===o)return eq("Could not find child to unset at path ".concat(JSON.stringify(a))),!1;if(eq("Unsetting child at path ".concat(JSON.stringify(a))),eX(e,"before"),s&&c&&e.isTextBlock(l)){let t=o>=s.focus.path[1];if(t){let t=l.children[o],r=(null==n?void 0:n.type)==="set"&&"text"===n.path[3]&&"string"==typeof n.value&&e.isTextSpan(t)&&B()(n.value.slice(-t.text.length),l.children[o].text);if(r){let n=l.children[Math.max(o-1,0)];return eq("Adjusting selection for merging of nodes"),s.focus={...s.focus},s.focus.path=[a[0],Math.max(a[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]}),eX(e,"after"),!0}}}return M.YR.removeNodes(e,{at:[i,o]}),eX(e,"after"),!0}if(!e.isTextBlock(l)){let n=[t].reduce(eH,[l])[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)=>eG(t.path[0])?e._key===t.path[0]._key:n===t.path[0]);eq("blockIndex",n);let r=n>-1?e.children[n]:void 0,i=e.isTextBlock(r)?r.children.findIndex((e,n)=>eG(t.path[2])?e._key===t.path[2]._key:n===t.path[2]):0,l=t.value,o=i>-1?[n,i]:[n];"string"==typeof t.path[3]&&((l={})[t.path[3]]=t.value);let a=e.isTextBlock(r);if(a){if(eq("Setting nodes at ".concat(JSON.stringify(t.path)," - ").concat(JSON.stringify(o))),eq("Value to set",JSON.stringify(l,null,2)),eX(e,"before"),1===o.length){eq("Setting block property");let{children:t,...n}=l,{children:i,...a}=r||{children:void 0};e.apply({type:"set_node",path:o,properties:{...a},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(l)){eq("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:l.text});let n=t&&B()(t.focus.path,o);n&&(eq("On same path, restoring previous selection"),M.YR.select(e,t))}else eq("Setting non-text property"),e.apply({type:"set_node",path:o,properties:{},newProperties:l});return eX(e,"after"),!0}if(r&&"value"in r){var s;let i=(s=[r.value],[t].reduce(eH,s))[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=eK([t.path[0]]),r=e.children.findIndex((e,r)=>n?e._key===n:r===t.path[0]),i=e.children[r],l=eZ.patch_fromText(t.value)[0],o=e.isTextBlock(i)&&"children"===t.path[1]&&4===t.path.length&&"text"===t.path[3];if(l&&o){let n;let o=l.length2-l.length1;if(n=l.diffs[1]?l.diffs[1][1]:l.diffs[0][1],"children"===t.path[1]){let a=eK([t.path[2]]),s=i.children.findIndex((e,n)=>a?e._key===a:n===t.path[0]),c=[r];s>-1&&c.push(s);let h={path:c,offset:o>=0?(l.start1||0)+l.diffs[0][1].length:(l.start2||0)+l.length2-o};eX(e,"before"),o>=0?e.apply({type:"insert_text",path:h.path,offset:h.offset,text:n}):e.apply({type:"remove_text",path:h.path,offset:h.offset-n.length,text:n})}return eX(e,"after"),!0}return!1}(e,n);break;default:eq("Unhandled patch",n.type)}}catch(e){console.error(e)}return t=n,r};return function(e){eB.set(e,!0),n=[...e.children];let{apply:t}=e;return l&&e.subscriptions.push(()=>{var t;tn("Subscribing to patches$");let n=l.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)(()=>
1t(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&&(tn("Remote patches",n),M.ML.withoutNormalizing(e,()=>{i.forEach(t=>{tn("Handling remote patch ".concat(JSON.stringify(t))),ej(e,()=>{tt(e,()=>{eI(e,()=>{try{c(e,t,n,r)}catch(e){tn("Got error trying to create operations from patch"),console.error(e)}})})})})}))});return()=>{tn("Unsubscribing to patches$"),n.unsubscribe()}}),e.apply=i=>{if(a)return t(i),e;let l=[];n=e.children;let c=eT(n,s);t(i);let h=eT(e.children,s);if(!eB.get(e))return tn("Editor is not producing patch for operation ".concat(i.type),i),e;switch(c&&!h&&"set_selection"!==i.type&&l.push(e_(n,"before",[0])),i.type){case"insert_text":l=[...l,...o.insertTextPatch(e,i,n)];break;case"remove_text":l=[...l,...o.removeTextPatch(e,i,n)];break;case"remove_node":l=[...l,...o.removeNodePatch(e,i,n)];break;case"split_node":l=[...l,...o.splitNodePatch(e,i,n)];break;case"insert_node":l=[...l,...o.insertNodePatch(e,i,n)];break;case"set_node":l=[...l,...o.setNodePatch(e,i,n)];break;case"merge_node":l=[...l,...o.mergeNodePatch(e,i,n)];break;case"move_node":l=[...l,...o.moveNodePatch(e,i,n)]}return!c&&h&&["set_node","remove_text","remove_node"].includes(i.type)&&(l=[...l,ex([])],r.next({type:"unset",previousValue:eN(n,s.block.name,eu.get(e))})),c&&l.length>0&&(l=[ey([],[]),...l]),l.length>0&&l.forEach(e=>{r.next({type:"patch",patch:{...e,origin:"local"}})}),e},e}}({change$:k,isPending:h,keyGenerator:l,patches$:a,patchFunctions:_,readOnly:s,schemaTypes:y}),A=(n=c||-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}),S=function(e){return e.pteToggleListItem=t=>{let n=e.pteHasListStyle(t);n?(tl("Remove list item '".concat(t,"'")),e.pteUnsetListItem(t)):(tl("Add list item '".concat(t,"'")),e.pteSetListItem(t))},e.pteUnsetListItem=t=>{if(!e.selection)return;let n=[...M.ML.nodes(e,{at:e.selection,match:e=>M.W_.isElement(e)&&e._type===y.block.name})];n.forEach(n=>{let[r,i]=n;if(e.isListBlock(r)){let{listItem:n,level:l,...o}=r,a={...o,listItem:void 0,level:void 0};tl("Unsetting list '".concat(t,"'")),M.YR.setNodes(e,a,{at:i})}})},e.pteSetListItem=t=>{if(!e.selection)return;let n=[...M.ML.nodes(e,{at:e.selection,match:t=>e.isTextBlock(t)})];n.forEach(n=>{let[r,i]=n;tl("Setting list '".concat(t,"'")),M.YR.setNodes(e,{...r,level:1,listItem:t||y.lists[0]&&y.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=>{if(!e.selection)return!1;let n=[...M.ML.nodes(e,{at:e.selection,match:n=>e.isListBlock(n)&&n.listItem===t})];return n.length>0},e},P=function(e){let{readOnly:t,patches$:n}=e,r=[];return e=>{n&&e.subscriptions.push(()=>{eQ("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()=>{eQ("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:l}=e,{undos:o}=l,a=o[o.length-1],s=a&&a.operations&&a.operations[a.operations.length-1],c=e8(n,s),h=e6(e),f=e3(e);if(null==h&&(h=e7(n)),h){if(null==f&&(f=null!=a&&(0!==r.length||e9(n,s)||c)),a&&f)c&&a.operations.pop(),a.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),eQ("Created new undo step",a)}for(;o.length>300;)o.shift();te(n)&&(l.redos=[])}i(n)},e.undo=()=>
1{if(t)return;let{undos:n}=e.history;if(n.length>0){let t=n[n.length-1];if(eQ("Undoing",t),t.operations.length>0){let n=[...r.filter(e=>e.time>=t.timestamp)],i=t.operations;n.forEach(t=>{i=R()(i.map(n=>e4(e,t.patch,n)))}),tt(e,()=>{M.ML.withoutNormalizing(e,()=>{i.map(M.OX.inverse).reverse().forEach(n=>{try{e.apply(n)}catch(n){eQ("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(eQ("Redoing",t),t.operations.length>0){let n=r.filter(e=>e.time>t.timestamp),i=t.operations;n.forEach(t=>{i=R()(i.map(n=>e4(e,t.patch,n)))}),tt(e,()=>{M.ML.withoutNormalizing(e,()=>{i.forEach(n=>{try{e.apply(n)}catch(n){eQ("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:s,patches$:a}),I=function(e){let{apply:t,normalizeNode:n}=e,r=y.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)&&B()(r.marks,n.marks)&&(to("Merging spans"),M.YR.mergeNodes(e,{at:i,voids:!0}),e.onChange())}}}(e);let[r,i]=t,l=M.xv.isText(r)&&r._type===y.span.name,o=e.isTextBlock(r);if(l||o){for(let t of(l&&!Array.isArray(r.marks)&&(to("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===y.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(to("Copying markDefs over to merged block",t),e.isTextBlock(n)){let i=Array.isArray(n.markDefs)&&n.markDefs||[],l=Z()([...i,...t.properties.markDefs]),o=B()(l,n.markDefs);o||(M.YR.setNodes(e,{markDefs:l},{at:r,voids:!1}),e.onChange())}}if("split_node"===t.type&&1===t.path.length&&M.W_.isElementProps(t.properties)&&t.properties._type===y.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(to("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===y.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===y.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())}}l&&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){let n=M.ML.nodes(e,{at:t,match:e=>e._type===y.block.name});for(let[t,r]of n)if(e.isTextBlock(t)){let n=(t.markDefs||[]).filter(e=>t.children.find(t=>M.xv.isText(t)&&Array.isArray(t.marks)&&t.marks.includes(e._key)));B()(n,t.markDefs)||(to("Removing markDef not in use"),M.YR.setNodes(e,{markDefs:n},{at:r}),e.onChange())}}}(e)},e.apply=n=>{var i,l;if("insert_text"===n.type){let{selection:o}=e;if(o&&M.e6.isCollapsed(o)&&(null==(l=null==(i=M.ML.marks(e))?void 0:i.marks)?void 0:l.some(e=>!r.includes(e)))){let[i]=Array.from(M.ML.nodes(e,{mode:"lowest",at:o.focus,match:e=>e._type===y.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})],r=R()(n.map(e=>e[0]).map(e=>e.marks)).includes(t);if(r){e.removeMark(t);return}M.ML.withoutNormalizing(e,()=>{n.forEach(n=>{let[r,i]=n,l=[...(Array.isArray(r.marks)?r.marks:[]).filter(e=>e!==t),t];M.YR.setNodes(e,{marks:l},{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,()=>{if(M.YR.setNodes(e,{},{match:M.xv.isText,split:!0}),e.selection){let n=[...M.ML.nodes(e,{at:e.selection,match:M.xv.isText})];n.forEach(n=>{let[r,i]=n,l=e.children[i[0]];M.W_.isElement(l)&&l.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=>{let n=e.pteIsMarkActive(t);n?(to("Remove mark '".concat(t,"'")),M.ML.removeMark(e,t)):(to("Add mark '".concat(t,"'")),M.ML.addMark(e,t,!0)),e.onChange()},e},O=function(e,t){let n=e.styles[0].value;return function(t){let{normalizeNode:r}=t;return t.normalizeNode=e=>{r(e);let[,i]=e;for(let e of t.operations)if("split_node"===e.type&&1===e.path.length&&t.isTextBlock(e.properties)&&e.properties.style!==n&&e.path[0]===i[0]&&!M.y$.equals(i,e.path)){let[r]=M.ML.node(t,[e.path[0]+1,0]);if(M.xv.isText(r)&&""===r.text){ti("Normalizing split node to ".concat(n," style"),e),M.YR.setNodes(t,{style:n},{at:[e.path[0]+1],voids:!1});break}}},t.pteHasBlockStyle=e=>{if(!t.selection)return!1;let n=[...M.ML.nodes(t,{at:t.selection,match:n=>t.isTextBlock(n)&&n.style===e})];return n.length>0},t.pteToggleBlockStyle=r=>{if(!t.selection)return;let i=[...M.ML.nodes(t,{at:t.selection,match:t=>M.W_.isElement(t)&&t._type===e.block.name})];i.forEach(e=>{let[i,l]=e;t.isTextBlock(i)&&i.style===r?(ti("Unsetting block style '".concat(r,"'")),M.YR.setNodes(t,{...i,style:n},{at:l})):(r?ti("Setting style '".concat(r,"'")):ti("Setting default style",n),M.YR.setNodes(t,{...i,style:r||n},{at:l}))}),t.onChange()},t}}(y),Y=function(e){let{schemaTypes:t,keyGenerator:n}=e;return function(e){return e.createPlaceholderBlock=()=>(tr("Creating placeholder block"),{_type:t.block.name,_key:n(),style:t.styles[0].value||"normal",markDefs:[],children:[{_type:"span",_key:n(),text:"",marks:[]}]}),e}}({keyGenerator:l,schemaTypes:y}),W=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){tc("pteExpandToWord: Can't expand to word here");return}let{focus:r}=t,i=r.offset,l=n.text.slice(0,i),o=n.text.slice(i,-1),a=e=>e.match(/\s/g),s=l.split("").reverse().findIndex(e=>a(e)),c=s>-1?l.length-s:0,h=o.split("").findIndex(e=>a(e)),f=l.length+(h>-1?h:o.length+1);if(!(c===f||isNaN(c)||isNaN(f))){tc("pteExpandToWord: Expanding to focused word"),M.YR.setSelection(e,{anchor:{...t.anchor,offset:c},focus:{...t.focus,offset:f}});return}tc("pteExpandToWord: Can't expand to word here")}},e}}({keyGenerator:l,schemaTypes:y}),z=(r=null,function(e){let t=()=>{if(r!==e.selection){let t=null;if(e.selection){let n=eg.get(e.selection);if(n)t=n;else{let n=e.children;t=eS(n,e.selection,y),eg.set(e.selection,t)}}ta("Emitting selection ".concat(JSON.stringify(t||null))),t?k.next({type:"selection",selection:t}):k.next({type:"selection",selection:null})}r=e.selection},{onChange:n}=e;return e.onChange=()=>{let r=e.operations.length>0;n(),r&&t()},e});return(i.destroy=()=>{let e=tm.get(i);if(!e)throw Error("Could not find pristine versions of editor functions");
1i.onChange=e.onChange,i.apply=e.apply,i.normalizeNode=e.normalizeNode},s)?{editor:x(b(I(O(W(Y(S(z(E(i))))))))),subscribe:()=>N()}:{editor:x(b(I(O(S(Y(W(A(P(T(z(E(i)))))))))))),subscribe:()=>{let t=[];return e.subscriptions.forEach(e=>{t.push(e())}),()=>{t.forEach(e=>{e()})}}}},tk=el("component:PortableTextEditor:SlateContainer");function tv(e){let{patches$:t,portableTextEditor:n,readOnly:r,maxBlocks:i,keyGenerator:l,isPending:o}=e,[a,s]=(0,h.useMemo)(()=>{tk("Creating new Slate editor instance");let{editor:e,subscribe:a}=ty((0,w.BU)((0,M.Jh)()),{isPending:o,keyGenerator:l,maxBlocks:i,patches$:t,portableTextEditor:n,readOnly:r});return eu.set(e,{}),ep.set(e,{}),[e,a]},[]);(0,h.useEffect)(()=>{let e=s();return()=>{e()}},[s]),(0,h.useEffect)(()=>{tk("Re-initializing plugin chain"),ty(a,{isPending:o,keyGenerator:l,maxBlocks:i,patches$:t,portableTextEditor:n,readOnly:r})},[l,n,i,r,t,a,o]);let f=(0,h.useMemo)(()=>[a.createPlaceholderBlock()],[a]);return(0,h.useEffect)(()=>()=>{tk("Destroying Slate editor"),a.destroy()},[a]),(0,c.jsx)(w.mH,{editor:a,value:f,children:e.children})}let t_=(0,h.createContext)(null),tb=()=>{let e=(0,h.useContext)(t_);if(void 0===e)throw Error("The `usePortableTextEditorSelection` hook must be used inside the <PortableTextEditor> component's context.");return e},tx=(0,h.createContext)(null),tw=()=>{let e=(0,h.useContext)(tx);if(!e)throw Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");return e},tM=(0,h.createContext)(void 0),tE=(0,h.createContext)(!1),tN=()=>{let e=(0,h.useContext)(tE);if(void 0===e)throw Error("The `usePortableTextEditorReadOnly` hook must be used inside the <PortableTextEditor> component's context.");return e},tT=el("hook:useSyncValue"),tD=el("component:PortableTextEditor:Synchronizer");function tA(e){let{change$:t,portableTextEditor:n,isPending:r,onChange:i,keyGenerator:l,readOnly:o,value:a}=e,[s,f]=(0,h.useState)(null),d=(0,h.useRef)([]),p=function(e){let{portableTextEditor:t,isPending:n,readOnly:r,keyGenerator:i}=e,{change$:l,schemaTypes:o}=t,a=(0,h.useRef)(),s=(0,w.ui)();return(0,h.useMemo)(()=>e=>{if(n.current&&!r){tT("Has local patches");return}if(a.current===e){tT("Value is the same object"),l.next({type:"value",value:e});return}if(e&&0===e.length){let t=td(e,o,i);l.next({type:"invalidValue",resolution:t.resolution,value:e});return}let t=!1;if(a.current=e,e&&0!==e.length||(tT("Value is empty"),tt(s,()=>{ej(s,()=>{M.ML.withoutNormalizing(s,()=>{let e=!!s.selection;e&&M.YR.deselect(s);let t=s.children.length;s.children.forEach((e,n)=>{M.YR.removeNodes(s,{at:[t-1-n]})}),M.YR.insertNodes(s,s.createPlaceholderBlock(),{at:[0]}),e&&M.YR.select(s,[0,0])})})}),t=!0),e&&e.length>0){let n=eE(e,{schemaTypes:o},ep.get(s));tt(s,()=>{ej(s,()=>{M.ML.withoutNormalizing(s,()=>{let r=s.children.length;if(n.length<r){for(let e=r-1;e>n.length-1;e--)M.YR.removeNodes(s,{at:[e]});t=!0}n.forEach((n,r)=>{let a=s.children[r],c=a&&!B()(n,a);if(c){let c=[e[r]],h=td(c,o,i);h.valid?(a._key===n._key?(tT("Updating block",a,n),function(e,t,n,r){if(M.YR.setNodes(e,t,{at:[r]}),e.isTextBlock(t)&&e.isTextBlock(n)){let i=n.children.length;t.children.length<i&&Array.from(Array(i-t.children.length)).forEach((t,n)=>{let l=i-1-n;l>0&&(tT("Removing child"),M.YR.removeNodes(e,{at:[r,l]}))}),t.children.forEach((i,l)=>{let o=n.children[l],a=!B()(i,o);a&&(i._key===(null==o?void 0:o._key)?(tT("Updating changed child",i),M.YR.setNodes(e,i,{at:[r,l]}),"span"!==i._type&&(tT("Updating changed inline object child",i),M.YR.setNodes(e,{_key:"".concat(t._key,"-void-child")},{at:[r,l,0],voids:!0}))):o?(tT("Replacing child",i),M.YR.removeNodes(e,{at:[r,l]}),eI(e,()=>{M.YR.insertNodes(e,i,{at:[r,l]})})):o||(tT("Inserting new child",i),eI(e,()=>{M.YR.insertNodes(e,i,{at:[r,l]})})))})}}(s,n,a,r)):(tT("Replacing block",a,n),function(e,t,n){let r=e.selection,i=r&&r.focus.path[0]===n;i&&M.YR.deselect(e),M.YR.removeNodes(e,{at:[n]}),eI(e,()=>{M.YR.insertNodes(e,t,{at:[n]})}),i&&M.YR.select(e,r)}(s,n,r)),t=!0):l.next({type:"invalidValue",resolution:h.resolution,value:e})}if(!a){let t=[e[r]];tT("Adding and validating new block",n);let a=td(t,o,i);
1a.valid?eI(s,()=>{M.YR.insertNodes(s,n,{at:[r]})}):l.next({type:"invalidValue",resolution:a.resolution,value:e})}})})})})}t?(tT("Server value changed, syncing editor"),M.ML.normalize(s),s.onChange(),l.next({type:"value",value:e})):tT("Server value and editor value is the same, no need to sync.")},[l,n,i,r,o,s])}({isPending:r,keyGenerator:l,onChange:i,portableTextEditor:n,readOnly:o}),u=(0,h.useCallback)(()=>{let e=[...d.current];tD("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]);(0,h.useEffect)(()=>()=>{u()},[u]),(0,h.useEffect)(()=>{tD("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)(()=>{tD("Setting selection"),f(e.selection)}),i(e);break;default:i(e)}});return()=>{tD("Unsubscribing to changes$"),e.unsubscribe()}},[t,g,i,p,r]);let m=(0,h.useRef)(!0);return(0,h.useEffect)(()=>{tD("Value from props changed, syncing new value"),p(a),m.current&&(t.next({type:"loading",isLoading:!1}),t.next({type:"ready"}),m.current=!1)},[t,p,a]),(0,c.jsx)(ea.Provider,{value:l,children:(0,c.jsx)(tx.Provider,{value:n,children:(0,c.jsx)(tM.Provider,{value:a,children:(0,c.jsx)(tE.Provider,{value:o,children:(0,c.jsx)(t_.Provider,{value:s,children:e.children})})})})})}let tC=el("component:PortableTextEditor");class tS extends h.Component{constructor(e){if(super(e),this.change$=new y.x,this.setEditable=e=>{this.editable={...this.editable,...e}},!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$:l,isPending:o}=this,a=void 0===this.props.maxBlocks?void 0:parseInt(this.props.maxBlocks.toString(),10)||void 0,s=Boolean(this.props.readOnly),h=this.props.keyGenerator||eo;return(0,c.jsx)(tv,{isPending:o,keyGenerator:h,maxBlocks:a,patches$:i||r,portableTextEditor:this,readOnly:s,children:(0,c.jsx)(tA,{change$:l,isPending:o,keyGenerator:h,onChange:e,portableTextEditor:this,readOnly:s,value:t,children:n})})}}function tL(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,l="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===l);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 tP(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})}tS.activeAnnotations=e=>e&&e.editable?e.editable.activeAnnotations():[],tS.addAnnotation=(e,t,n)=>{var r;return null==(r=e.editable)?void 0:r.addAnnotation(t,n)},tS.blur=e=>{var t;tC("Host blurred"),null==(t=e.editable)||t.blur()},tS.delete=(e,t,n)=>{var r;return null==(r=e.editable)?void 0:r.delete(t,n)},tS.findDOMNode=(e,t)=>{var n;return null==(n=e.editable)?void 0:n.findDOMNode(t)},tS.findByPath=(e,t)=>{var n;return(null==(n=e.editable)?void 0:n.findByPath(t))||[]},tS.focus=e=>{var t;tC("Host requesting focus"),null==(t=e.editable)||t.focus()},tS.focusBlock=e=>{var t;return null==(t=e.editable)?void 0:t.focusBlock()},tS.focusChild=e=>{var t;return null==(t=e.editable)?void 0:t.focusChild()},tS.getSelection=e=>e.editable?e.editable.getSelection():null,tS.getValue=e=>{var t;return null==(t=e.editable)?void 0:t.getValue()},tS.hasBlockStyle=(e,t)=>
1{var n;return null==(n=e.editable)?void 0:n.hasBlockStyle(t)},tS.hasListStyle=(e,t)=>{var n;return null==(n=e.editable)?void 0:n.hasListStyle(t)},tS.isCollapsedSelection=e=>{var t;return null==(t=e.editable)?void 0:t.isCollapsedSelection()},tS.isExpandedSelection=e=>{var t;return null==(t=e.editable)?void 0:t.isExpandedSelection()},tS.isMarkActive=(e,t)=>{var n;return null==(n=e.editable)?void 0:n.isMarkActive(t)},tS.insertChild=(e,t,n)=>{var r;return tC("Host inserting child"),null==(r=e.editable)?void 0:r.insertChild(t,n)},tS.insertBlock=(e,t,n)=>{var r;return null==(r=e.editable)?void 0:r.insertBlock(t,n)},tS.insertBreak=e=>{var t;return null==(t=e.editable)?void 0:t.insertBreak()},tS.isVoid=(e,t)=>{var n;return null==(n=e.editable)?void 0:n.isVoid(t)},tS.isObjectPath=(e,t)=>{if(!t||!Array.isArray(t))return!1;let n=t.length>3&&"children"===t[1],r=t.length>1&&"children"!==t[1];return r||n},tS.marks=e=>{var t;return null==(t=e.editable)?void 0:t.marks()},tS.select=(e,t)=>{var n;tC("Host setting selection",t),null==(n=e.editable)||n.select(t)},tS.removeAnnotation=(e,t)=>{var n;return null==(n=e.editable)?void 0:n.removeAnnotation(t)},tS.toggleBlockStyle=(e,t)=>{var n;return tC("Host is toggling block style"),null==(n=e.editable)?void 0:n.toggleBlockStyle(t)},tS.toggleList=(e,t)=>{var n;return null==(n=e.editable)?void 0:n.toggleList(t)},tS.toggleMark=(e,t)=>{var n;tC("Host toggling mark",t),null==(n=e.editable)||n.toggleMark(t)};let tR=el("components:Leaf"),tI=[],tB=e=>{let{attributes:t,children:n,leaf:r,schemaTypes:i,renderChild:l,renderDecorator:o,renderAnnotation:a}=e,s=h.useRef(null),f=tw(),d=(0,w.vt)(),[p,u]=(0,h.useState)(!1),[g,m]=(0,h.useState)(!1),y=n.props.parent,k=(0,h.useMemo)(()=>y?[{_key:null==y?void 0:y._key},"children",{_key:r._key}]:[],[y,r._key]),_=(0,h.useMemo)(()=>i.decorators.map(e=>e.value),[i.decorators]),b=(0,h.useMemo)(()=>Z()((r.marks||tI).filter(e=>_.includes(e))),[_,r.marks]),x=Array.isArray(r.marks)?r.marks:tI,E=(0,h.useMemo)(()=>x.map(e=>{var t;return!_.includes(e)&&(null==(t=null==y?void 0:y.markDefs)?void 0:t.find(t=>t._key===e))}).filter(Boolean),[x,y,_]),N=E.length>0&&d;(0,h.useEffect)(()=>{if(!N){u(!1);return}let e=tS.getSelection(f);e&&B()(e.focus.path,k)&&tS.isCollapsedSelection(f)&&(0,h.startTransition)(()=>{u(!0)})},[N,k,f]);let T=(0,h.useCallback)(()=>{if(!N)return;tR("Setting selection and focus from range");let e=window.getSelection();if(!e){m(!1);return}if(e&&e.rangeCount>0){let t=e.getRangeAt(0);s.current&&t.intersectsNode(s.current)?m(!0):m(!1)}else m(!1)},[N]);(0,h.useEffect)(()=>{if(!N)return;let e=f.change$.subscribe(e=>{if("blur"===e.type){u(!1),m(!1);return}if("focus"===e.type){let e=tS.getSelection(f);e&&B()(e.focus.path,k)&&tS.isCollapsedSelection(f)&&u(!0),T();return}"selection"===e.type&&(e.selection&&B()(e.selection.focus.path,k)&&tS.isCollapsedSelection(f)?u(!0):u(!1),T())});return()=>{e.unsubscribe()}},[k,f,T,N]),(0,h.useEffect)(()=>T(),[T]);let D=(0,h.useMemo)(()=>{let e=n;if(M.xv.isText(r)&&r._type===i.span.name&&(b.forEach(t=>{let n=i.decorators.find(e=>e.value===t);if(n&&o){let r=Object.defineProperty({children:e,editorElementRef:s,focused:p,path:k,selected:g,schemaType:n,value:t},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),n)});e=o(r)}}),y&&E.length>0&&E.forEach(t=>{let n=i.annotations.find(e=>e.name===t._type);if(n){if(a){let r=Object.defineProperty({block:y,children:e,editorElementRef:s,focused:p,path:k,selected:g,schemaType:n,value:t},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),n)});e=(0,c.jsx)("span",{ref:s,children:a(r)})}else e=(0,c.jsx)(tP,{annotation:t,children:(0,c.jsx)("span",{ref:s,children:e})})}}),y&&l)){let t=y.children.find(e=>e._key===r._key);if(t){let n=(0,c.jsx)(c.Fragment,{children:e}),r=Object.defineProperty({annotations:E,children:n,editorElementRef:s,focused:p,path:k,schemaType:i.span,selected:g,value:t},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),i.span)});e=l(r)}}return e},[E,y,n,p,r,b,k,a,l,o,i.annotations,i.decorators,i.span,g]);return(0,h.useMemo)(()=>(0,c.jsx)("span",{...t,ref:s,children:D},r._key),[r,t,D])},tj=e=>(0,c.jsx)("div",{children:(0,c.jsx)("pre",{children:JSON.stringify(e.value,null,2)})}),tO=ee.ZP.div(l||(l=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 tY=ee.ZP.div(a||(a=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?tz[(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)),tW=ee.ZP.div(s||(s=et([""]))),tz=["●","○","■"],tJ=el("components:DraggableBlock"),tU=e=>{let{children:t,element:n,readOnly:r,blockRef:i}=e,l=(0,w._7)(),o=(0,h.useRef)(),[a,s]=(0,h.useState)(!1),f=(0,h.useMemo)(()=>M.ML.isVoid(l,n),[l,n]),d=(0,h.useMemo)(()=>M.ML.isInline(l,n),[l,n]),[p,u]=(0,h.useState)(null);(0,h.useEffect)(()=>u(i?i.current:w.F3.toDOMNode(l,n)),[l,n,i]);let g=(0,h.useCallback)(e=>{let t=eh.get(l);if(!t||!p)return;e.preventDefault(),e.dataTransfer.dropEffect="move",ef.set(l,n);let r=p.getBoundingClientRect(),i=r.top,o=r.height,a=e.pageY,c="bottom";if(n===l.children[0]?c="top":Math.abs(i-a)<o/2?(c="top",ed.set(l,c)):(c="bottom",ed.set(l,c)),t===n){e.dataTransfer.dropEffect="none";return}s(!0)},[p,l,n]),m=(0,h.useCallback)(()=>{s(!1)},[]),y=(0,h.useCallback)(e=>{let t=ef.get(l);if(t){ec.set(l,!1),e.preventDefault(),e.stopPropagation(),ef.delete(l),o.current&&(tJ("Removing drag ghost"),document.body.removeChild(o.current));let r=ed.get(l);ed.delete(l);let i=w.F3.findPath(l,t),a=w.F3.findPath(l,n),s=M.y$.isBefore(a,i);if("bottom"===r&&!s){if(i[0]>=l.children.length-1){tJ("target is already at the bottom, not moving");return}let e=i;i=M.y$.next(i),tJ("Adjusting targetPath from ".concat(JSON.stringify(e)," to ").concat(JSON.stringify(i)))}if("top"===r&&s&&i[0]!==l.children.length-1){let e=i;i=M.y$.previous(i),tJ("Adjusting targetPath from ".concat(JSON.stringify(e)," to ").concat(JSON.stringify(i)))}if(M.y$.equals(i,a)){e.preventDefault(),tJ("targetPath and myPath is the same, not moving");return}tJ("Moving element ".concat(n._key," from path ").concat(JSON.stringify(a)," to ").concat(JSON.stringify(i)," (").concat(r,")")),M.YR.moveNodes(l,{at:a,to:i}),l.onChange();return}tJ("No target element, not doing anything")},[l,n]),k=(0,h.useCallback)(e=>{eh.get(l)&&(tJ("On drop (prevented)",n),e.preventDefault(),e.stopPropagation(),s(!1))},[l,n]),_=(0,h.useCallback)(e=>{if(!f){eh.delete(l);return}ec.set(l,!0),eh.set(l,n),e.stopPropagation();let t=e.target;t instanceof HTMLElement&&(t.style.opacity="1")},[l,n,f]),b=(0,h.useCallback)(e=>{if(!f||d){tJ("Not dragging block"),eh.delete(l),ec.set(l,!1);return}if(tJ("Drag start"),ec.set(l,!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,l,_,d,f]),x=a&&l.children[0]===ef.get(l),E=a&&l.children[l.children.length-1]===ef.get(l),N=ed.get(l),T=(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:[(x||a&&!x&&!E&&"top"===N)&&T,t,(E||a&&!x&&!E&&"bottom"===N)&&T]})};el("components:Element");let tF=[],tV={display:"inline-block"},t$=e=>
1{let t,n,{attributes:r,children:i,element:l,schemaTypes:o,readOnly:a,renderBlock:s,renderChild:f,renderListItem:d,renderStyle:p,spellCheck:u}=e,g=(0,w._7)(),m=(0,w.vt)(),y=(0,h.useRef)(null),k=(0,h.useRef)(null),_=m&&g.selection&&M.e6.isCollapsed(g.selection)||!1,b=(0,h.useMemo)(()=>eN([l],o.block.name,eu.get(g))[0],[g,l,o.block.name]),x=i,E=(0,h.useMemo)(()=>[{_key:l._key}],[l]);if("string"!=typeof l._type)throw Error("Expected element to have a _type property");if("string"!=typeof l._key)throw Error("Expected element to have a _key property");if(g.isInline(l)){let e=w.F3.findPath(g,l),[t]=M.ML.node(g,e,{depth:1}),n=o.inlineObjects.find(e=>e.name===l._type);if(!n)throw Error("Could not find type for inline block element");if(M.W_.isElement(t)){let e=[{_key:t._key},"children",{_key:l._key}];return(0,c.jsxs)("span",{...r,children:[i,(0,c.jsxs)("span",{draggable:!a,className:"pt-inline-object",ref:k,style:tV,contentEditable:!1,children:[f&&f({annotations:tF,children:(0,c.jsx)(tj,{value:b}),editorElementRef:k,focused:_,path:e,schemaType:n,selected:m,type:n,value:b}),!f&&(0,c.jsx)(tj,{value:b})]},l._key)]})}throw Error("Block not found!")}if(l._type===o.block.name){let e;t="pt-block pt-text-block";let n="listItem"in l,h="style"in l&&l.style||"normal";t="pt-block pt-text-block pt-text-block-style-".concat(h);let f=o.styles.find(e=>e.value===h);if(p&&f&&(x=p({block:l,children:i,focused:_,selected:m,value:h,path:E,schemaType:f,editorElementRef:y})),n&&("number"==typeof l.level&&(e=l.level),t+=" pt-list-item pt-list-item-".concat(l.listItem," pt-list-item-level-").concat(e||1)),g.isListBlock(b)&&n&&l.listItem){let e=o.lists.find(e=>e.value===l.listItem);x=d&&e?d({block:b,children:x,focused:_,selected:m,value:l.listItem,path:E,schemaType:e,level:b.level||1,editorElementRef:y}):(0,c.jsx)(tY,{listStyle:b.listItem||o.lists[0].value,listLevel:b.level||1,children:(0,c.jsx)(tW,{children:x})})}let k=Object.defineProperty({children:x,editorElementRef:y,focused:_,level:e,listItem:n?l.listItem:void 0,path:E,selected:m,style:h,schemaType:o.block,value:b},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),o.block)}),w=s?s(k):i;return(0,c.jsx)("div",{...r,className:t,spellCheck:u,children:(0,c.jsx)(tU,{element:l,readOnly:a,blockRef:y,children:(0,c.jsx)("div",{ref:y,children:w})})},l._key)}let N=o.blockObjects.find(e=>e.name===l._type);if(!N)throw Error("Could not find schema type for block element of _type ".concat(l._type));t="pt-block pt-object-block";let T=eN([l],o.block.name,eu.get(g))[0];if(s){let e=Object.defineProperty({children:(0,c.jsx)(tj,{value:b}),editorElementRef:y,focused:_,path:E,schemaType:N,selected:m,value:T},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),N)});n=s(e)}return(0,c.jsxs)("div",{...r,className:t,children:[i,(0,c.jsxs)(tU,{element:l,readOnly:a,blockRef:y,children:[n&&(0,c.jsx)("div",{ref:y,contentEditable:!1,children:n}),!n&&(0,c.jsx)(tO,{selected:m,children:(0,c.jsx)(tj,{value:b})})]})]},l._key)},tH="undefined"==typeof window?h.useEffect:h.useLayoutEffect,tq=el("component:Editable"),tZ={opacity:.5,position:"absolute",userSelect:"none",pointerEvents:"none"},tG=[],tK=(0,h.forwardRef)(function(e,t){let{hotkeys:n,onBeforeInput:r,onPaste:i,onCopy:l,renderAnnotation:o,renderBlock:a,renderChild:s,renderDecorator:f,renderListItem:d,renderPlaceholder:p,renderStyle:u,selection:g,scrollSelectionIntoView:m,spellCheck:y,...k}=e,_=tw(),b=tN(),x=es(),E=function(e){let t=(0,h.useRef)(null);return tH(()=>{e&&("function"==typeof e?e(t.current):e.current=t.current)}),t}(t),[T,D]=(0,h.useState)(!1),{change$:A,schemaTypes:C}=_,S=(0,w.ui)(),L=C.block.name,P=(0,h.useMemo)(()=>function(e){let t=C.block.name,n=C.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=C.inlineObjects.find(t=>t.name===e._type))?void 0:t.title)||"Object","]")}).join(""):"[".concat((null==(r=C.blockObjects.find(e=>e.name===t._type))?void 0:r.title)||"Object","]")}).join("\n\n");return e.setFragmentData=(n,i)=>{let{selection:l}=e;if(!l)return;let[o,a]=M.e6.edges(l),s=M.ML.void(e,{at:o.path}),c=M.ML.void(e,{at:a.path});if(M.e6.isCollapsed(l)&&!s)return;let h=w.F3.toDOMRange(e,l),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]")).forEac
1h(e=>{let t="n"===e.getAttribute("data-slate-zero-width");e.textContent=t?"\n":""}),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=e.getFragment(),g=eN(u,t),m=JSON.stringify(g),y=r(g);n.clearData(),n.setData("text/plain",y),n.setData("text/html",p),n.setData("application/json",m),n.setData("application/x-portable-text",m),tp("text",y),n.setData("application/x-portable-text-event-origin",i||"external"),tp("Set fragment data",m,p)},e.insertPortableTextData=t=>{var r;if(!e.selection)return!1;let i=t.getData("application/x-portable-text"),l=t.getData("application/x-portable-text-event-origin");if(tp("Inserting portable text from ".concat(l," event"),i),i){let t=JSON.parse(i);if(Array.isArray(t)&&t.length>0){let i=eE(t,{schemaTypes:C}).map(t=>{let r={...t};e.isTextBlock(r)&&(r.markDefs=(r.markDefs||[]).map(t=>{let i=t._key,l=x();return r.children=r.children.map(t=>t._type===n&&e.isTextSpan(t)?{...t,marks:t.marks&&t.marks.includes(i)?[...t.marks].filter(e=>e!==i).concat(l):t.marks}:t),{...t,_key:l}}));let i={...r,_key:x()};return e.isTextBlock(i)&&(i.children=i.children.map(e=>({...e,_key:x()}))),i}),l=td(t,C,x);if(!l.valid){let e="".concat(null==(r=l.resolution)?void 0:r.description);return A.next({type:"error",level:"warning",name:"pasteError",description:e,data:l}),tp("Invalid insert result",l),!1}return tg(e,i,C),!0}}return!1},e.insertTextOrHTMLData=n=>{var r;if(!e.selection)return tp("No selection, not inserting"),!1;A.next({type:"loading",isLoading:!0});let i=n.getData("text/html"),l=n.getData("text/plain");if(i||l){let o,a,s;if(tp("Inserting data",n),i)a=eE(o=(0,K.zW)(i,C.portableText).map(e=>(0,K.nX)(e,{blockTypeName:t})),{schemaTypes:C}),s="HTML";else{let e=String(l).replace(/[&<>"'`=/]/g,e=>tu[e]).split(/\n{2,}/).map(e=>e?"<p>".concat(e.replace(/(?:\r\n|\r|\n)/g,"<br/>"),"</p>"):"<p></p>").join("");a=eE(o=(0,K.zW)("<html><body>".concat(e,"</body></html>"),C.portableText).map(e=>(0,K.nX)(e,{blockTypeName:t})),{schemaTypes:C}),s="text"}let c=td(o,C,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 A.next({type:"error",level:"warning",name:"pasteError",description:e,data:c}),tp("Invalid insert result",c),!1}return tp("Inserting ".concat(s," fragment at ").concat(JSON.stringify(e.selection))),tg(e,a,C),A.next({type:"loading",isLoading:!1}),!0}return A.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},[A,x,C]),R=(0,h.useMemo)(()=>(function(e,t,n,r){let i=["enter","tab","shift","delete","end"],l=r||tf,o=()=>eE([{_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(l).forEach(e=>{if("marks"===e)for(let n in l[e]){if(i.includes(n))throw Error("The hotkey ".concat(n," is reserved!"));if((0,G.ZP)(n,r.nativeEvent)){r.preventDefault();let i=l[e];if(i){let e=i[n];th("HotKey ".concat(n," to toggle ").concat(e)),t.pteToggleMark(e)}}}if("custom"===e)for(let t in l[e]){if(i.includes(t))throw Error("The hotkey ".concat(t," is reserved!"));if((0,G.ZP)(t,r.nativeEvent)){let i=l[e];if(i){let e=i[t];e(r,n)}}}});let a=(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){th("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)){th("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,[l]=M.e6.edges(t.selection),o=M.ML.isStart(t,l,l.path);e&&(0,j.NG)(e)&&(!i||o)&&t.pteIncrementBlockLevels(h)&&r.preventDefault()}if(a&&!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),n=M.ML.isEnd(t,e,e.path);if(n){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}})(C,x,_,n),[n,x,_,C]);(0,h.useMemo)(()=>b?(tq("Editable is in read only mode"),P(S)):(tq("Editable is in edit mode"),P(R(S))),[b,S,R,P]);let I=(0,h.useCallback)(e=>(0,c.jsx)(t$,{...e,readOnly:b,renderBlock:a,renderChild:s,renderListItem:d,renderStyle:u,schemaTypes:C,spellCheck:y}),[C,y,b,a,s,d,u]),O=(0,h.useCallback)(e=>{let t=(0,c.jsx)(tB,{...e,schemaTypes:C,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:tZ,contentEditable:!1,
1children:p()}),t]}):t},[b,o,s,f,p,C]),Y=(0,h.useCallback)(()=>{if(g){tq("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:l}=e;return(i&&t.find(e=>B()({_key:e._key},i.path[0]))&&(n=tL(i,t)),l&&t.find(e=>B()({_key:e._key},l.path[0]))&&(r=tL(l,t)),n&&r)?{anchor:n,focus:r}:null}(g,eN(S.children,L));if(null!==e){tq("Normalized selection from props ".concat(JSON.stringify(e)));let t=eL(e,S);t&&(M.YR.select(S,t),S.operations.some(e=>"set_selection"===e.type)||A.next({type:"selection",selection:e}),S.onChange())}}},[g,S,L,A]);(0,h.useEffect)(()=>{tq("Subscribing to editor changes$");let e=A.subscribe(e=>{switch(e.type){case"ready":Y();break;case"invalidValue":D(!0);break;case"value":D(!1)}});return()=>{tq("Unsubscribing to changes$"),e.unsubscribe()}},[A,Y]),(0,h.useEffect)(()=>{g&&!T&&Y()},[T,g,Y]);let W=(0,h.useCallback)(e=>{if(l){let t=l(e);void 0!==t&&e.preventDefault()}},[l]),z=(0,h.useCallback)(e=>{if(e.preventDefault(),S.selection){if(!i){tq("Pasting normally"),S.insertData(e.clipboardData);return}new Promise(t=>{var n;t(i({event:e,value:tS.getValue(_),path:(null==(n=S.selection)?void 0:n.focus.path)||[],schemaTypes:C}))}).then(t=>{if(tq("Custom paste function from client resolved",t),A.next({type:"loading",isLoading:!0}),!t||!t.insert){tq("No result from custom paste handler, pasting normally"),S.insertData(e.clipboardData);return}if(t&&t.insert){S.insertFragment(eE(t.insert,{schemaTypes:C})),A.next({type:"loading",isLoading:!1});return}console.warn("Your onPaste function returned something unexpected:",t)}).catch(e=>(A.next({type:"loading",isLoading:!1}),console.error(e),e))}},[A,i,_,C,S]),J=(0,h.useCallback)(()=>{A.next({type:"focus"})},[A]),U=(0,h.useCallback)(()=>{A.next({type:"blur"})},[A]),F=(0,h.useCallback)(e=>{r&&r(e)},[r]),V=S.pteWithHotKeys,$=(0,h.useMemo)(()=>void 0===m?void 0:null===m?N():(e,t)=>{m(_,t)},[_,m]),H=(0,h.useCallback)(()=>eT(S.children,C)?[{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0},placeholder:!0}]:tG,[C,S]),q=(0,h.useMemo)(()=>(0,c.jsx)(w.CX,{autoFocus:!1,className:"pt-editable",decorate:H,onBlur:U,onCopy:W,onDOMBeforeInput:F,onFocus:J,onKeyDown:V,onPaste:z,readOnly:b,renderElement:I,renderLeaf:O,scrollSelectionIntoView:$}),[H,W,V,F,U,J,z,b,I,O,$]);return _?(0,c.jsx)("div",{ref:E,...k,children:T?null:q}):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.