@wangeditor-next/yjs-for-react 0.1.9 → 0.1.10-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,2 +1,831 @@
1
- import r,{createContext as t,useContext as n,useReducer as e,useRef as u,useEffect as i,useCallback as o,useState as f,useLayoutEffect as c,useMemo as a}from"react";import{relativeRangeToSlateRange as s,CursorEditor as l}from"@wangeditor-next/yjs";import{DomEditor as v}from"@wangeditor-next/editor";import{Range as p,Editor as h,Text as y,Path as d}from"slate";var g,b,m,w,O,S,j,E,x,A,P,R,T,k,z,I,L,C,M=t(null),F=function(){var r=n(M);return r||console.warn("The `useEditorStatic` hook must be used inside the <EditorContext> component's context."),r},_="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function D(){return b?g:(b=1,g=function(r){try{return!!r()}catch(r){return!0}})}function N(){if(w)return m;w=1;var r=D();return m=!r((function(){var r=function(){}.bind();return"function"!=typeof r||r.hasOwnProperty("prototype")}))}function G(){if(S)return O;S=1;var r=N(),t=Function.prototype,n=t.call,e=r&&t.bind.bind(n,n);return O=r?e:function(r){return function(){return n.apply(r,arguments)}},O}function W(){if(E)return j;E=1;var r=G(),t=r({}.toString),n=r("".slice);return j=function(r){return n(t(r),8,-1)}}function V(){if(A)return x;A=1;var r=G(),t=D(),n=W(),e=Object,u=r("".split);return x=t((function(){return!e("z").propertyIsEnumerable(0)}))?function(r){return"String"===n(r)?u(r,""):e(r)}:e}function B(){return R?P:(R=1,P=function(r){return null==r})}function U(){if(k)return T;k=1;var r=B(),t=TypeError;return T=function(n){if(r(n))throw new t("Can't call method on "+n);return n}}function q(){if(I)return z;I=1;var r=V(),t=U();return z=function(n){return r(t(n))}}function H(){if(C)return L;C=1;var r=function(r){return r&&r.Math===Math&&r};return L=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof _&&_)||r("object"==typeof L&&L)||function(){return this}()||Function("return this")()}var X,K,Y,$,J,Q,Z,rr,tr,nr,er,ur,ir,or,fr,cr,ar,sr,lr,vr,pr,hr,yr,dr,gr,br,mr,wr,Or,Sr={exports:{}};function jr(){return K?X:(K=1,X=!1)}function Er(){if($)return Y;$=1;var r=H(),t=Object.defineProperty;return Y=function(n,e){try{t(r,n,{value:e,configurable:!0,writable:!0})}catch(t){r[n]=e}return e}}function xr(){if(J)return Sr.exports;J=1;var r=jr(),t=H(),n=Er(),e="__core-js_shared__",u=Sr.exports=t[e]||n(e,{});return(u.versions||(u.versions=[])).push({version:"3.38.1",mode:r?"pure":"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE",source:"https://github.com/zloirock/core-js"}),Sr.exports}function Ar(){if(Z)return Q;Z=1;var r=xr();return Q=function(t,n){return r[t]||(r[t]=n||{})}}function Pr(){if(tr)return rr;tr=1;var r=U(),t=Object;return rr=function(n){return t(r(n))}}function Rr(){if(er)return nr;er=1;var r=G(),t=Pr(),n=r({}.hasOwnProperty);return nr=Object.hasOwn||function(r,e){return n(t(r),e)}}function Tr(){if(ir)return ur;ir=1;var r=G(),t=0,n=Math.random(),e=r(1..toString);return ur=function(r){return"Symbol("+(void 0===r?"":r)+")_"+e(++t+n,36)}}function kr(){if(ar)return cr;ar=1;var r,t,n=H(),e=function(){if(fr)return or;fr=1;var r=H().navigator,t=r&&r.userAgent;return or=t?String(t):""}(),u=n.process,i=n.Deno,o=u&&u.versions||i&&i.version,f=o&&o.v8;return f&&(t=(r=f.split("."))[0]>0&&r[0]<4?1:+(r[0]+r[1])),!t&&e&&(!(r=e.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=e.match(/Chrome\/(\d+)/))&&(t=+r[1]),cr=t}function zr(){if(lr)return sr;lr=1;var r=kr(),t=D(),n=H().String;return sr=!!Object.getOwnPropertySymbols&&!t((function(){var t=Symbol("symbol detection");return!n(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&r&&r<41}))}function Ir(){if(pr)return vr;pr=1;var r=zr();return vr=r&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function Lr(){if(yr)return hr;yr=1;var r=H(),t=Ar(),n=Rr(),e=Tr(),u=zr(),i=Ir(),o=r.Symbol,f=t("wks"),c=i?o.for||o:o&&o.withoutSetter||e;return hr=function(r){return n(f,r)||(f[r]=u&&n(o,r)?o[r]:c("Symbol."+r)),f[r]}}function Cr(){if(gr)return dr;gr=1;var r="object"==typeof document&&document.all;return dr=void 0===r&&void 0!==r?function(t){return"function"==typeof t||t===r}:function(r){return"function"==typeof r}}function Mr(){if(mr)return br;mr=1;var r=Cr();return br=function(t){return"object"==typeof t?null!==t:r(t)}}function Fr(){if(Or)return wr;Or=1;var r=Mr(),t=String,n=TypeError;return wr=function(e){if(r(e))return e;throw new n(t(e)+" is not an object")}}var _r,Dr,Nr,Gr,Wr={};function Vr(){if(Dr)return _r;Dr=1;var r=D();return _r=!r((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))}function Br(){if(Gr)return Nr;Gr=1;var r=Vr(),t=D();return Nr=r&&t((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))}var Ur,qr,Hr,Xr,Kr,Yr,$r,Jr,Qr,Zr,rt,tt,nt,et,ut,it,ot,ft,ct,at,st,lt,vt,pt,ht,yt,dt,gt,bt,mt,wt,Ot,St,jt,Et,xt,At,Pt,Rt,Tt,kt,zt,It,Lt,Ct,Mt,Ft,_t,Dt,Nt,Gt,Wt,Vt,Bt,Ut,qt,Ht,Xt,Kt,Yt,$t,Jt,Qt,Zt,rn={};function tn(){if(qr)return Ur;qr=1;var r=H(),t=Mr(),n=r.document,e=t(n)&&t(n.createElement);return Ur=function(r){return e?n.createElement(r):{}}}function nn(){if(Xr)return Hr;Xr=1;var r=Vr(),t=D(),n=tn();return Hr=!r&&!t((function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}))}function en(){if(Yr)return Kr;Yr=1;var r=N(),t=Function.prototype.call;return Kr=r?t.bind(t):function(){return t.apply(t,arguments)},Kr}function un(){if(Jr)return $r;Jr=1;var r=H(),t=Cr();return $r=function(n,e){return arguments.length<2?(u=r[n],t(u)?u:void 0):r[n]&&r[n][e];var u},$r}function on(){if(Zr)return Qr;Zr=1;var r=G();return Qr=r({}.isPrototypeOf)}function fn(){if(tt)return rt;tt=1;var r=un(),t=Cr(),n=on(),e=Ir(),u=Object;return rt=e?function(r){return"symbol"==typeof r}:function(e){var i=r("Symbol");return t(i)&&n(i.prototype,u(e))}}function cn(){if(et)return nt;et=1;var r=String;return nt=function(t){try{return r(t)}catch(r){return"Object"}}}function an(){if(it)return ut;it=1;var r=Cr(),t=cn(),n=TypeError;return ut=function(e){if(r(e))return e;throw new n(t(e)+" is not a function")}}function sn(){if(ft)return ot;ft=1;var r=an(),t=B();return ot=function(n,e){var u=n[e];return t(u)?void 0:r(u)}}function ln(){if(at)return ct;at=1;var r=en(),t=Cr(),n=Mr(),e=TypeError;return ct=function(u,i){var o,f;if("string"===i&&t(o=u.toString)&&!n(f=r(o,u)))return f;if(t(o=u.valueOf)&&!n(f=r(o,u)))return f;if("string"!==i&&t(o=u.toString)&&!n(f=r(o,u)))return f;throw new e("Can't convert object to primitive value")}}function vn(){if(lt)return st;lt=1;var r=en(),t=Mr(),n=fn(),e=sn(),u=ln(),i=Lr(),o=TypeError,f=i("toPrimitive");return st=function(i,c){if(!t(i)||n(i))return i;var a,s=e(i,f);if(s){if(void 0===c&&(c="default"),a=r(s,i,c),!t(a)||n(a))return a;throw new o("Can't convert object to primitive value")}return void 0===c&&(c="number"),u(i,c)}}function pn(){if(pt)return vt;pt=1;var r=vn(),t=fn();return vt=function(n){var e=r(n,"string");return t(e)?e:e+""}}function hn(){if(ht)return rn;ht=1;var r=Vr(),t=nn(),n=Br(),e=Fr(),u=pn(),i=TypeError,o=Object.defineProperty,f=Object.getOwnPropertyDescriptor,c="enumerable",a="configurable",s="writable";return rn.f=r?n?function(r,t,n){if(e(r),t=u(t),e(n),"function"==typeof r&&"prototype"===t&&"value"in n&&s in n&&!n[s]){var i=f(r,t);i&&i[s]&&(r[t]=n.value,n={configurable:a in n?n[a]:i[a],enumerable:c in n?n[c]:i[c],writable:!1})}return o(r,t,n)}:o:function(r,n,f){if(e(r),n=u(n),e(f),t)try{return o(r,n,f)}catch(r){}if("get"in f||"set"in f)throw new i("Accessors not supported");return"value"in f&&(r[n]=f.value),r},rn}function yn(){if(bt)return gt;bt=1;var r=function(){if(dt)return yt;dt=1;var r=Math.ceil,t=Math.floor;return yt=Math.trunc||function(n){var e=+n;return(e>0?t:r)(e)}}();return gt=function(t){var n=+t;return n!=n||0===n?0:r(n)}}function dn(){if(wt)return mt;wt=1;var r=yn(),t=Math.max,n=Math.min;return mt=function(e,u){var i=r(e);return i<0?t(i+u,0):n(i,u)}}function gn(){if(St)return Ot;St=1;var r=yn(),t=Math.min;return Ot=function(n){var e=r(n);return e>0?t(e,9007199254740991):0}}function bn(){if(Et)return jt;Et=1;var r=gn();return jt=function(t){return r(t.length)}}function mn(){return Rt?Pt:(Rt=1,Pt={})}function wn(){if(kt)return Tt;kt=1;var r=G(),t=Rr(),n=q(),e=function(){if(At)return xt;At=1;var r=q(),t=dn(),n=bn(),e=function(e){return function(u,i,o){var f=r(u),c=n(f);if(0===c)return!e&&-1;var a,s=t(o,c);if(e&&i!=i){for(;c>s;)if((a=f[s++])!=a)return!0}else for(;c>s;s++)if((e||s in f)&&f[s]===i)return e||s||0;return!e&&-1}};return xt={includes:e(!0),indexOf:e(!1)}}().indexOf,u=mn(),i=r([].push);return Tt=function(r,o){var f,c=n(r),a=0,s=[];for(f in c)!t(u,f)&&t(c,f)&&i(s,f);for(;o.length>a;)t(c,f=o[a++])&&(~e(s,f)||i(s,f));return s}}function On(){return It?zt:(It=1,zt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])}function Sn(){if(Ct)return Lt;Ct=1;var r=wn(),t=On();return Lt=Object.keys||function(n){return r(n,t)}}function jn(){if(_t)return Ft;_t=1;var r=un();return Ft=r("document","documentElement")}function En(){if(Nt)return Dt;Nt=1;var r=Ar(),t=Tr(),n=r("keys");return Dt=function(r){return n[r]||(n[r]=t(r))}}function xn(){if(Wt)return Gt;Wt=1;var r,t=Fr(),n=function(){if(Mt)return Wr;Mt=1;var r=Vr(),t=Br(),n=hn(),e=Fr(),u=q(),i=Sn();return Wr.f=r&&!t?Object.defineProperties:function(r,t){e(r);for(var o,f=u(t),c=i(t),a=c.length,s=0;a>s;)n.f(r,o=c[s++],f[o]);return r},Wr}(),e=On(),u=mn(),i=jn(),o=tn(),f=En(),c="prototype",a="script",s=f("IE_PROTO"),l=function(){},v=function(r){return"<"+a+">"+r+"</"+a+">"},p=function(r){r.write(v("")),r.close();var t=r.parentWindow.Object;return r=null,t},h=function(){try{r=new ActiveXObject("htmlfile")}catch(r){}var t,n,u;h="undefined"!=typeof document?document.domain&&r?p(r):(n=o("iframe"),u="java"+a+":",n.style.display="none",i.appendChild(n),n.src=String(u),(t=n.contentWindow.document).open(),t.write(v("document.F=Object")),t.close(),t.F):p(r);for(var f=e.length;f--;)delete h[c][e[f]];return h()};return u[s]=!0,Gt=Object.create||function(r,e){var u;return null!==r?(l[c]=t(r),u=new l,l[c]=null,u[s]=r):u=h(),void 0===e?u:n.f(u,e)}}function An(){if(Bt)return Vt;Bt=1;var r=Lr(),t=xn(),n=hn().f,e=r("unscopables"),u=Array.prototype;return void 0===u[e]&&n(u,e,{configurable:!0,value:t(null)}),Vt=function(r){u[e][r]=!0}}function Pn(){return qt?Ut:(qt=1,Ut={})}function Rn(){if(Xt)return Ht;Xt=1;var r=H(),t=Cr(),n=r.WeakMap;return Ht=t(n)&&/native code/.test(String(n))}function Tn(){return Yt?Kt:(Yt=1,Kt=function(r,t){return{enumerable:!(1&r),configurable:!(2&r),writable:!(4&r),value:t}})}function kn(){if(Jt)return $t;Jt=1;var r=Vr(),t=hn(),n=Tn();return $t=r?function(r,e,u){return t.f(r,e,n(1,u))}:function(r,t,n){return r[t]=n,r}}function zn(){if(Zt)return Qt;Zt=1;var r,t,n,e=Rn(),u=H(),i=Mr(),o=kn(),f=Rr(),c=xr(),a=En(),s=mn(),l="Object already initialized",v=u.TypeError,p=u.WeakMap;if(e||c.state){var h=c.state||(c.state=new p);h.get=h.get,h.has=h.has,h.set=h.set,r=function(r,t){if(h.has(r))throw new v(l);return t.facade=r,h.set(r,t),t},t=function(r){return h.get(r)||{}},n=function(r){return h.has(r)}}else{var y=a("state");s[y]=!0,r=function(r,t){if(f(r,y))throw new v(l);return t.facade=r,o(r,y,t),t},t=function(r){return f(r,y)?r[y]:{}},n=function(r){return f(r,y)}}return Qt={set:r,get:t,has:n,enforce:function(e){return n(e)?t(e):r(e,{})},getterFor:function(r){return function(n){var e;if(!i(n)||(e=t(n)).type!==r)throw new v("Incompatible receiver, "+r+" required");return e}}}}var In,Ln,Cn={},Mn={};function Fn(){if(In)return Mn;In=1;var r={}.propertyIsEnumerable,t=Object.getOwnPropertyDescriptor,n=t&&!r.call({1:2},1);return Mn.f=n?function(r){var n=t(this,r);return!!n&&n.enumerable}:r,Mn}function _n(){if(Ln)return Cn;Ln=1;var r=Vr(),t=en(),n=Fn(),e=Tn(),u=q(),i=pn(),o=Rr(),f=nn(),c=Object.getOwnPropertyDescriptor;return Cn.f=r?c:function(r,a){if(r=u(r),a=i(a),f)try{return c(r,a)}catch(r){}if(o(r,a))return e(!t(n.f,r,a),r[a])},Cn}var Dn,Nn,Gn,Wn,Vn,Bn,Un,qn={exports:{}};function Hn(){if(Nn)return Dn;Nn=1;var r=Vr(),t=Rr(),n=Function.prototype,e=r&&Object.getOwnPropertyDescriptor,u=t(n,"name"),i=u&&"something"===function(){}.name,o=u&&(!r||r&&e(n,"name").configurable);return Dn={EXISTS:u,PROPER:i,CONFIGURABLE:o}}function Xn(){if(Wn)return Gn;Wn=1;var r=G(),t=Cr(),n=xr(),e=r(Function.toString);return t(n.inspectSource)||(n.inspectSource=function(r){return e(r)}),Gn=n.inspectSource}function Kn(){if(Vn)return qn.exports;Vn=1;var r=G(),t=D(),n=Cr(),e=Rr(),u=Vr(),i=Hn().CONFIGURABLE,o=Xn(),f=zn(),c=f.enforce,a=f.get,s=String,l=Object.defineProperty,v=r("".slice),p=r("".replace),h=r([].join),y=u&&!t((function(){return 8!==l((function(){}),"length",{value:8}).length})),d=String(String).split("String"),g=qn.exports=function(r,t,n){"Symbol("===v(s(t),0,7)&&(t="["+p(s(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!e(r,"name")||i&&r.name!==t)&&(u?l(r,"name",{value:t,configurable:!0}):r.name=t),y&&n&&e(n,"arity")&&r.length!==n.arity&&l(r,"length",{value:n.arity});try{n&&e(n,"constructor")&&n.constructor?u&&l(r,"prototype",{writable:!1}):r.prototype&&(r.prototype=void 0)}catch(r){}var o=c(r);return e(o,"source")||(o.source=h(d,"string"==typeof t?t:"")),r};return Function.prototype.toString=g((function(){return n(this)&&a(this).source||o(this)}),"toString"),qn.exports}function Yn(){if(Un)return Bn;Un=1;var r=Cr(),t=hn(),n=Kn(),e=Er();return Bn=function(u,i,o,f){f||(f={});var c=f.enumerable,a=void 0!==f.name?f.name:i;if(r(o)&&n(o,a,f),f.global)c?u[i]=o:e(i,o);else{try{f.unsafe?u[i]&&(c=!0):delete u[i]}catch(r){}c?u[i]=o:t.f(u,i,{value:o,enumerable:!1,configurable:!f.nonConfigurable,writable:!f.nonWritable})}return u}}var $n,Jn={};function Qn(){if($n)return Jn;$n=1;var r=wn(),t=On().concat("length","prototype");return Jn.f=Object.getOwnPropertyNames||function(n){return r(n,t)},Jn}var Zn,re,te,ne,ee,ue,ie,oe,fe,ce,ae,se,le,ve,pe,he,ye,de,ge,be,me,we,Oe,Se,je,Ee,xe,Ae,Pe,Re,Te,ke,ze,Ie={};function Le(){if(te)return re;te=1;var r=un(),t=G(),n=Qn(),e=(Zn||(Zn=1,Ie.f=Object.getOwnPropertySymbols),Ie),u=Fr(),i=t([].concat);return re=r("Reflect","ownKeys")||function(r){var t=n.f(u(r)),o=e.f;return o?i(t,o(r)):t}}function Ce(){if(ee)return ne;ee=1;var r=Rr(),t=Le(),n=_n(),e=hn();return ne=function(u,i,o){for(var f=t(i),c=e.f,a=n.f,s=0;s<f.length;s++){var l=f[s];r(u,l)||o&&r(o,l)||c(u,l,a(i,l))}}}function Me(){if(ie)return ue;ie=1;var r=D(),t=Cr(),n=/#|\.prototype\./,e=function(n,e){var c=i[u(n)];return c===f||c!==o&&(t(e)?r(e):!!e)},u=e.normalize=function(r){return String(r).replace(n,".").toLowerCase()},i=e.data={},o=e.NATIVE="N",f=e.POLYFILL="P";return ue=e}function Fe(){if(fe)return oe;fe=1;var r=H(),t=_n().f,n=kn(),e=Yn(),u=Er(),i=Ce(),o=Me();return oe=function(f,c){var a,s,l,v,p,h=f.target,y=f.global,d=f.stat;if(a=y?r:d?r[h]||u(h,{}):r[h]&&r[h].prototype)for(s in c){if(v=c[s],l=f.dontCallGetSet?(p=t(a,s))&&p.value:a[s],!o(y?s:h+(d?".":"#")+s,f.forced)&&void 0!==l){if(typeof v==typeof l)continue;i(v,l)}(f.sham||l&&l.sham)&&n(v,"sham",!0),e(a,s,v,f)}}}function _e(){if(le)return se;le=1;var r=Rr(),t=Cr(),n=Pr(),e=En(),u=function(){if(ae)return ce;ae=1;var r=D();return ce=!r((function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype}))}(),i=e("IE_PROTO"),o=Object,f=o.prototype;return se=u?o.getPrototypeOf:function(e){var u=n(e);if(r(u,i))return u[i];var c=u.constructor;return t(c)&&u instanceof c?c.prototype:u instanceof o?f:null}}function De(){if(pe)return ve;pe=1;var r,t,n,e=D(),u=Cr(),i=Mr(),o=xn(),f=_e(),c=Yn(),a=Lr(),s=jr(),l=a("iterator"),v=!1;return[].keys&&("next"in(n=[].keys())?(t=f(f(n)))!==Object.prototype&&(r=t):v=!0),!i(r)||e((function(){var t={};return r[l].call(t)!==t}))?r={}:s&&(r=o(r)),u(r[l])||c(r,l,(function(){return this})),ve={IteratorPrototype:r,BUGGY_SAFARI_ITERATORS:v}}function Ne(){if(ye)return he;ye=1;var r=hn().f,t=Rr(),n=Lr()("toStringTag");return he=function(e,u,i){e&&!i&&(e=e.prototype),e&&!t(e,n)&&r(e,n,{configurable:!0,value:u})}}function Ge(){if(Oe)return we;Oe=1;var r=Mr();return we=function(t){return r(t)||null===t}}function We(){if(je)return Se;je=1;var r=Ge(),t=String,n=TypeError;return Se=function(e){if(r(e))return e;throw new n("Can't set "+t(e)+" as a prototype")}}function Ve(){if(xe)return Ee;xe=1;var r=function(){if(me)return be;me=1;var r=G(),t=an();return be=function(n,e,u){try{return r(t(Object.getOwnPropertyDescriptor(n,e)[u]))}catch(r){}}}(),t=Mr(),n=U(),e=We();return Ee=Object.setPrototypeOf||("__proto__"in{}?function(){var u,i=!1,o={};try{(u=r(Object.prototype,"__proto__","set"))(o,[]),i=o instanceof Array}catch(r){}return function(r,o){return n(r),e(o),t(r)?(i?u(r,o):r.__proto__=o,r):r}}():void 0)}function Be(){if(Pe)return Ae;Pe=1;var r=Fe(),t=en(),n=jr(),e=Hn(),u=Cr(),i=function(){if(ge)return de;ge=1;var r=De().IteratorPrototype,t=xn(),n=Tn(),e=Ne(),u=Pn(),i=function(){return this};return de=function(o,f,c,a){var s=f+" Iterator";return o.prototype=t(r,{next:n(+!a,c)}),e(o,s,!1,!0),u[s]=i,o}}(),o=_e(),f=Ve(),c=Ne(),a=kn(),s=Yn(),l=Lr(),v=Pn(),p=De(),h=e.PROPER,y=e.CONFIGURABLE,d=p.IteratorPrototype,g=p.BUGGY_SAFARI_ITERATORS,b=l("iterator"),m="keys",w="values",O="entries",S=function(){return this};return Ae=function(e,l,p,j,E,x,A){i(p,l,j);var P,R,T,k=function(r){if(r===E&&M)return M;if(!g&&r&&r in L)return L[r];switch(r){case m:case w:case O:return function(){return new p(this,r)}}return function(){return new p(this)}},z=l+" Iterator",I=!1,L=e.prototype,C=L[b]||L["@@iterator"]||E&&L[E],M=!g&&C||k(E),F="Array"===l&&L.entries||C;if(F&&(P=o(F.call(new e)))!==Object.prototype&&P.next&&(n||o(P)===d||(f?f(P,d):u(P[b])||s(P,b,S)),c(P,z,!0,!0),n&&(v[z]=S)),h&&E===w&&C&&C.name!==w&&(!n&&y?a(L,"name",w):(I=!0,M=function(){return t(C,this)})),E)if(R={values:k(w),keys:x?M:k(m),entries:k(O)},A)for(T in R)(g||I||!(T in L))&&s(L,T,R[T]);else r({target:l,proto:!0,forced:g||I},R);return n&&!A||L[b]===M||s(L,b,M,{name:E}),v[l]=M,R}}function Ue(){return Te?Re:(Te=1,Re=function(r,t){return{value:r,done:t}})}function qe(){if(ze)return ke;ze=1;var r=q(),t=An(),n=Pn(),e=zn(),u=hn().f,i=Be(),o=Ue(),f=jr(),c=Vr(),a="Array Iterator",s=e.set,l=e.getterFor(a);ke=i(Array,"Array",(function(t,n){s(this,{type:a,target:r(t),index:0,kind:n})}),(function(){var r=l(this),t=r.target,n=r.index++;if(!t||n>=t.length)return r.target=null,o(void 0,!0);switch(r.kind){case"keys":return o(n,!1);case"values":return o(t[n],!1)}return o([n,t[n]],!1)}),"values");var v=n.Arguments=n.Array;if(t("keys"),t("values"),t("entries"),!f&&c&&"values"!==v.name)try{u(v,"name",{value:"values"})}catch(r){}return ke}qe();var He,Xe,Ke,Ye,$e,Je,Qe,Ze,ru,tu,nu,eu,uu,iu,ou,fu,cu,au,su,lu,vu,pu={};function hu(){if(Ye)return Ke;Ye=1;var r=function(){if(Xe)return He;Xe=1;var r=W(),t=G();return He=function(n){if("Function"===r(n))return t(n)}}(),t=an(),n=N(),e=r(r.bind);return Ke=function(r,u){return t(r),void 0===u?r:n?e(r,u):function(){return r.apply(u,arguments)}},Ke}function yu(){if(Je)return $e;Je=1;var r=W();return $e=Array.isArray||function(t){return"Array"===r(t)}}function du(){if(Ze)return Qe;Ze=1;var r={};return r[Lr()("toStringTag")]="z",Qe="[object z]"===String(r)}function gu(){if(tu)return ru;tu=1;var r=du(),t=Cr(),n=W(),e=Lr()("toStringTag"),u=Object,i="Arguments"===n(function(){return arguments}());return ru=r?n:function(r){var o,f,c;return void 0===r?"Undefined":null===r?"Null":"string"==typeof(f=function(r,t){try{return r[t]}catch(r){}}(o=u(r),e))?f:i?n(o):"Object"===(c=n(o))&&t(o.callee)?"Arguments":c}}function bu(){if(eu)return nu;eu=1;var r=G(),t=D(),n=Cr(),e=gu(),u=un(),i=Xn(),o=function(){},f=u("Reflect","construct"),c=/^\s*(?:class|function)\b/,a=r(c.exec),s=!c.test(o),l=function(r){if(!n(r))return!1;try{return f(o,[],r),!0}catch(r){return!1}},v=function(r){if(!n(r))return!1;switch(e(r)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return s||!!a(c,i(r))}catch(r){return!0}};return v.sham=!0,nu=!f||t((function(){var r;return l(l.call)||!l(Object)||!l((function(){r=!0}))||r}))?v:l}function mu(){if(iu)return uu;iu=1;var r=yu(),t=bu(),n=Mr(),e=Lr()("species"),u=Array;return uu=function(i){var o;return r(i)&&(o=i.constructor,(t(o)&&(o===u||r(o.prototype))||n(o)&&null===(o=o[e]))&&(o=void 0)),void 0===o?u:o}}function wu(){if(fu)return ou;fu=1;var r=mu();return ou=function(t,n){return new(r(t))(0===n?0:n)}}function Ou(){if(au)return cu;au=1;var r=hu(),t=G(),n=V(),e=Pr(),u=bn(),i=wu(),o=t([].push),f=function(t){var f=1===t,c=2===t,a=3===t,s=4===t,l=6===t,v=7===t,p=5===t||l;return function(h,y,d,g){for(var b,m,w=e(h),O=n(w),S=u(O),j=r(y,d),E=0,x=g||i,A=f?x(h,S):c||v?x(h,0):void 0;S>E;E++)if((p||E in O)&&(m=j(b=O[E],E,w),t))if(f)A[E]=m;else if(m)switch(t){case 3:return!0;case 5:return b;case 6:return E;case 2:o(A,b)}else switch(t){case 4:return!1;case 7:o(A,b)}return l?-1:a||s?s:A}};return cu={forEach:f(0),map:f(1),filter:f(2),some:f(3),every:f(4),find:f(5),findIndex:f(6),filterReject:f(7)}}function Su(){if(lu)return su;lu=1;var r=D(),t=Lr(),n=kr(),e=t("species");return su=function(t){return n>=51||!r((function(){var r=[];return(r.constructor={})[e]=function(){return{foo:1}},1!==r[t](Boolean).foo}))}}!function(){if(vu)return pu;vu=1;var r=Fe(),t=Ou().map;r({target:"Array",proto:!0,forced:!Su()("map")},{map:function(r){return t(this,r,arguments.length>1?arguments[1]:void 0)}})}();var ju,Eu,xu,Au={};!function(){if(xu)return Au;xu=1;var r=Fe(),t=function(){if(Eu)return ju;Eu=1;var r=Vr(),t=D(),n=G(),e=_e(),u=Sn(),i=q(),o=n(Fn().f),f=n([].push),c=r&&t((function(){var r=Object.create(null);return r[2]=2,!o(r,2)})),a=function(t){return function(n){for(var a,s=i(n),l=u(s),v=c&&null===e(s),p=l.length,h=0,y=[];p>h;)a=l[h++],r&&!(v?a in s:o(s,a))||f(y,t?[a,s[a]]:s[a]);return y}};return ju={entries:a(!0),values:a(!1)}}().entries;r({target:"Object",stat:!0},{entries:function(r){return t(r)}})}();var Pu,Ru,Tu={};function ku(){if(Ru)return Pu;Ru=1;var r=D();return Pu=!r((function(){return Object.isExtensible(Object.preventExtensions({}))}))}var zu,Iu,Lu,Cu,Mu,Fu,_u,Du,Nu,Gu={exports:{}},Wu={};function Vu(){if(Iu)return zu;Iu=1;var r=G();return zu=r([].slice)}function Bu(){if(Lu)return Wu;Lu=1;var r=W(),t=q(),n=Qn().f,e=Vu(),u="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];return Wu.f=function(i){return u&&"Window"===r(i)?function(r){try{return n(r)}catch(r){return e(u)}}(i):n(t(i))},Wu}function Uu(){if(_u)return Fu;_u=1;var r=D(),t=Mr(),n=W(),e=function(){if(Mu)return Cu;Mu=1;var r=D();return Cu=r((function(){if("function"==typeof ArrayBuffer){var r=new ArrayBuffer(8);Object.isExtensible(r)&&Object.defineProperty(r,"a",{value:8})}}))}(),u=Object.isExtensible,i=r((function(){}));return Fu=i||e?function(r){return!!t(r)&&((!e||"ArrayBuffer"!==n(r))&&(!u||u(r)))}:u}function qu(){if(Du)return Gu.exports;Du=1;var r=Fe(),t=G(),n=mn(),e=Mr(),u=Rr(),i=hn().f,o=Qn(),f=Bu(),c=Uu(),a=Tr(),s=ku(),l=!1,v=a("meta"),p=0,h=function(r){i(r,v,{value:{objectID:"O"+p++,weakData:{}}})},y=Gu.exports={enable:function(){y.enable=function(){},l=!0;var n=o.f,e=t([].splice),u={};u[v]=1,n(u).length&&(o.f=function(r){for(var t=n(r),u=0,i=t.length;u<i;u++)if(t[u]===v){e(t,u,1);break}return t},r({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:f.f}))},fastKey:function(r,t){if(!e(r))return"symbol"==typeof r?r:("string"==typeof r?"S":"P")+r;if(!u(r,v)){if(!c(r))return"F";if(!t)return"E";h(r)}return r[v].objectID},getWeakData:function(r,t){if(!u(r,v)){if(!c(r))return!0;if(!t)return!1;h(r)}return r[v].weakData},onFreeze:function(r){return s&&l&&c(r)&&!u(r,v)&&h(r),r}};return n[v]=!0,Gu.exports}!function(){if(Nu)return Tu;Nu=1;var r=Fe(),t=ku(),n=D(),e=Mr(),u=qu().onFreeze,i=Object.freeze;r({target:"Object",stat:!0,forced:n((function(){i(1)})),sham:!t},{freeze:function(r){return i&&e(r)?i(u(r)):r}})}();var Hu,Xu,Ku,Yu,$u,Ju,Qu,Zu,ri,ti,ni,ei,ui,ii={};function oi(){if(Xu)return Hu;Xu=1;var r=Lr(),t=Pn(),n=r("iterator"),e=Array.prototype;return Hu=function(r){return void 0!==r&&(t.Array===r||e[n]===r)}}function fi(){if(Yu)return Ku;Yu=1;var r=gu(),t=sn(),n=B(),e=Pn(),u=Lr()("iterator");return Ku=function(i){if(!n(i))return t(i,u)||t(i,"@@iterator")||e[r(i)]}}function ci(){if(Ju)return $u;Ju=1;var r=en(),t=an(),n=Fr(),e=cn(),u=fi(),i=TypeError;return $u=function(o,f){var c=arguments.length<2?u(o):f;if(t(c))return n(r(c,o));throw new i(e(o)+" is not iterable")},$u}function ai(){if(Zu)return Qu;Zu=1;var r=en(),t=Fr(),n=sn();return Qu=function(e,u,i){var o,f;t(e);try{if(!(o=n(e,"return"))){if("throw"===u)throw i;return i}o=r(o,e)}catch(r){f=!0,o=r}if("throw"===u)throw i;if(f)throw o;return t(o),i}}function si(){if(ti)return ri;ti=1;var r=hu(),t=en(),n=Fr(),e=cn(),u=oi(),i=bn(),o=on(),f=ci(),c=fi(),a=ai(),s=TypeError,l=function(r,t){this.stopped=r,this.result=t},v=l.prototype;return ri=function(p,h,y){var d,g,b,m,w,O,S,j=y&&y.that,E=!(!y||!y.AS_ENTRIES),x=!(!y||!y.IS_RECORD),A=!(!y||!y.IS_ITERATOR),P=!(!y||!y.INTERRUPTED),R=r(h,j),T=function(r){return d&&a(d,"normal",r),new l(!0,r)},k=function(r){return E?(n(r),P?R(r[0],r[1],T):R(r[0],r[1])):P?R(r,T):R(r)};if(x)d=p.iterator;else if(A)d=p;else{if(!(g=c(p)))throw new s(e(p)+" is not iterable");if(u(g)){for(b=0,m=i(p);m>b;b++)if((w=k(p[b]))&&o(v,w))return w;return new l(!1)}d=f(p,g)}for(O=x?p.next:d.next;!(S=t(O,d)).done;){try{w=k(S.value)}catch(r){a(d,"throw",r)}if("object"==typeof w&&w&&o(v,w))return w}return new l(!1)}}function li(){if(ei)return ni;ei=1;var r=Vr(),t=hn(),n=Tn();return ni=function(e,u,i){r?t.f(e,u,n(0,i)):e[u]=i}}!function(){if(ui)return ii;ui=1;var r=Fe(),t=si(),n=li();r({target:"Object",stat:!0},{fromEntries:function(r){var e={};return t(r,(function(r,t){n(e,r,t)}),{AS_ENTRIES:!0}),e}})}();var vi,pi={};!function(){if(vi)return pi;vi=1;var r=Fe(),t=Pr(),n=Sn();r({target:"Object",stat:!0,forced:D()((function(){n(1)}))},{keys:function(r){return n(t(r))}})}();var hi,yi,di,gi={};!function(){if(di)return gi;di=1;var r=du(),t=Yn(),n=function(){if(yi)return hi;yi=1;var r=du(),t=gu();return hi=r?{}.toString:function(){return"[object "+t(this)+"]"}}();r||t(Object.prototype,"toString",n,{unsafe:!0})}();var bi,mi,wi,Oi,Si,ji={};function Ei(){if(mi)return bi;mi=1;var r=gu(),t=String;return bi=function(n){if("Symbol"===r(n))throw new TypeError("Cannot convert a Symbol value to a string");return t(n)}}!function(){if(Si)return ji;Si=1;var r=function(){if(Oi)return wi;Oi=1;var r=G(),t=yn(),n=Ei(),e=U(),u=r("".charAt),i=r("".charCodeAt),o=r("".slice),f=function(r){return function(f,c){var a,s,l=n(e(f)),v=t(c),p=l.length;return v<0||v>=p?r?"":void 0:(a=i(l,v))<55296||a>56319||v+1===p||(s=i(l,v+1))<56320||s>57343?r?u(l,v):a:r?o(l,v,v+2):s-56320+(a-55296<<10)+65536}};return wi={codeAt:f(!1),charAt:f(!0)}}().charAt,t=Ei(),n=zn(),e=Be(),u=Ue(),i="String Iterator",o=n.set,f=n.getterFor(i);e(String,"String",(function(r){o(this,{type:i,string:t(r),index:0})}),(function(){var t,n=f(this),e=n.string,i=n.index;return i>=e.length?u(void 0,!0):(t=r(e,i),n.index+=t.length,u(t,!1))}))}();var xi,Ai,Pi,Ri,Ti,ki,zi,Ii,Li,Ci,Mi,Fi,_i,Di,Ni={};function Gi(){if(Ai)return xi;Ai=1;var r=Yn();return xi=function(t,n,e){for(var u in n)r(t,u,n[u],e);return t}}function Wi(){if(Ri)return Pi;Ri=1;var r=on(),t=TypeError;return Pi=function(n,e){if(r(e,n))return n;throw new t("Incorrect invocation")}}function Vi(){if(ki)return Ti;ki=1;var r=Lr()("iterator"),t=!1;try{var n=0,e={next:function(){return{done:!!n++}},return:function(){t=!0}};e[r]=function(){return this},Array.from(e,(function(){throw 2}))}catch(r){}return Ti=function(n,e){try{if(!e&&!t)return!1}catch(r){return!1}var u=!1;try{var i={};i[r]=function(){return{next:function(){return{done:u=!0}}}},n(i)}catch(r){}return u}}function Bi(){if(Ii)return zi;Ii=1;var r=Cr(),t=Mr(),n=Ve();return zi=function(e,u,i){var o,f;return n&&r(o=u.constructor)&&o!==i&&t(f=o.prototype)&&f!==i.prototype&&n(e,f),e}}function Ui(){if(Ci)return Li;Ci=1;var r=Fe(),t=H(),n=G(),e=Me(),u=Yn(),i=qu(),o=si(),f=Wi(),c=Cr(),a=B(),s=Mr(),l=D(),v=Vi(),p=Ne(),h=Bi();return Li=function(y,d,g){var b=-1!==y.indexOf("Map"),m=-1!==y.indexOf("Weak"),w=b?"set":"add",O=t[y],S=O&&O.prototype,j=O,E={},x=function(r){var t=n(S[r]);u(S,r,"add"===r?function(r){return t(this,0===r?0:r),this}:"delete"===r?function(r){return!(m&&!s(r))&&t(this,0===r?0:r)}:"get"===r?function(r){return m&&!s(r)?void 0:t(this,0===r?0:r)}:"has"===r?function(r){return!(m&&!s(r))&&t(this,0===r?0:r)}:function(r,n){return t(this,0===r?0:r,n),this})};if(e(y,!c(O)||!(m||S.forEach&&!l((function(){(new O).entries().next()})))))j=g.getConstructor(d,y,b,w),i.enable();else if(e(y,!0)){var A=new j,P=A[w](m?{}:-0,1)!==A,R=l((function(){A.has(1)})),T=v((function(r){new O(r)})),k=!m&&l((function(){for(var r=new O,t=5;t--;)r[w](t,t);return!r.has(-0)}));T||((j=d((function(r,t){f(r,S);var n=h(new O,r,j);return a(t)||o(t,n[w],{that:n,AS_ENTRIES:b}),n}))).prototype=S,S.constructor=j),(R||k)&&(x("delete"),x("has"),b&&x("get")),(k||P)&&x(w),m&&S.clear&&delete S.clear}return E[y]=j,r({global:!0,constructor:!0,forced:j!==O},E),p(j,y),m||g.setStrong(j,y,b),j}}function qi(){if(Fi)return Mi;Fi=1;var r=G(),t=Gi(),n=qu().getWeakData,e=Wi(),u=Fr(),i=B(),o=Mr(),f=si(),c=Ou(),a=Rr(),s=zn(),l=s.set,v=s.getterFor,p=c.find,h=c.findIndex,y=r([].splice),d=0,g=function(r){return r.frozen||(r.frozen=new b)},b=function(){this.entries=[]},m=function(r,t){return p(r.entries,(function(r){return r[0]===t}))};return b.prototype={get:function(r){var t=m(this,r);if(t)return t[1]},has:function(r){return!!m(this,r)},set:function(r,t){var n=m(this,r);n?n[1]=t:this.entries.push([r,t])},delete:function(r){var t=h(this.entries,(function(t){return t[0]===r}));return~t&&y(this.entries,t,1),!!~t}},Mi={getConstructor:function(r,c,s,p){var h=r((function(r,t){e(r,y),l(r,{type:c,id:d++,frozen:null}),i(t)||f(t,r[p],{that:r,AS_ENTRIES:s})})),y=h.prototype,b=v(c),m=function(r,t,e){var i=b(r),o=n(u(t),!0);return!0===o?g(i).set(t,e):o[i.id]=e,r};return t(y,{delete:function(r){var t=b(this);if(!o(r))return!1;var e=n(r);return!0===e?g(t).delete(r):e&&a(e,t.id)&&delete e[t.id]},has:function(r){var t=b(this);if(!o(r))return!1;var e=n(r);return!0===e?g(t).has(r):e&&a(e,t.id)}}),t(y,s?{get:function(r){var t=b(this);if(o(r)){var e=n(r);if(!0===e)return g(t).get(r);if(e)return e[t.id]}},set:function(r,t){return m(this,r,t)}}:{add:function(r){return m(this,r,!0)}}),h}}}Di||(Di=1,function(){if(_i)return Ni;_i=1;var r,t=ku(),n=H(),e=G(),u=Gi(),i=qu(),o=Ui(),f=qi(),c=Mr(),a=zn().enforce,s=D(),l=Rn(),v=Object,p=Array.isArray,h=v.isExtensible,y=v.isFrozen,d=v.isSealed,g=v.freeze,b=v.seal,m=!n.ActiveXObject&&"ActiveXObject"in n,w=function(r){return function(){return r(this,arguments.length?arguments[0]:void 0)}},O=o("WeakMap",w,f),S=O.prototype,j=e(S.set);if(l)if(m){r=f.getConstructor(w,"WeakMap",!0),i.enable();var E=e(S.delete),x=e(S.has),A=e(S.get);u(S,{delete:function(t){if(c(t)&&!h(t)){var n=a(this);return n.frozen||(n.frozen=new r),E(this,t)||n.frozen.delete(t)}return E(this,t)},has:function(t){if(c(t)&&!h(t)){var n=a(this);return n.frozen||(n.frozen=new r),x(this,t)||n.frozen.has(t)}return x(this,t)},get:function(t){if(c(t)&&!h(t)){var n=a(this);return n.frozen||(n.frozen=new r),x(this,t)?A(this,t):n.frozen.get(t)}return A(this,t)},set:function(t,n){if(c(t)&&!h(t)){var e=a(this);e.frozen||(e.frozen=new r),x(this,t)?j(this,t,n):e.frozen.set(t,n)}else j(this,t,n);return this}})}else t&&s((function(){var r=g([]);return j(new O,r,1),!y(r)}))&&u(S,{set:function(r,t){var n;return p(r)&&(y(r)?n=g:d(r)&&(n=b)),j(this,r,t),n&&n(r),this}})}());var Hi,Xi,Ki,Yi,$i,Ji={};function Qi(){return Xi?Hi:(Xi=1,Hi={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0})}function Zi(){if(Yi)return Ki;Yi=1;var r=tn()("span").classList,t=r&&r.constructor&&r.constructor.prototype;return Ki=t===Object.prototype?void 0:t}!function(){if($i)return Ji;$i=1;var r=H(),t=Qi(),n=Zi(),e=qe(),u=kn(),i=Ne(),o=Lr()("iterator"),f=e.values,c=function(r,n){if(r){if(r[o]!==f)try{u(r,o,f)}catch(t){r[o]=f}if(i(r,n,!0),t[n])for(var c in e)if(r[c]!==e[c])try{u(r,c,e[c])}catch(t){r[c]=e[c]}}};for(var a in t)c(r[a]&&r[a].prototype,a);c(n,"DOMTokenList")}();var ro=function(){return ro=Object.assign||function(r){for(var t,n=1,e=arguments.length;n<e;n++)for(var u in t=arguments[n])Object.prototype.hasOwnProperty.call(t,u)&&(r[u]=t[u]);return r},ro.apply(this,arguments)};function to(r,t){var n="function"==typeof Symbol&&r[Symbol.iterator];if(!n)return r;var e,u,i=n.call(r),o=[];try{for(;(void 0===t||t-- >0)&&!(e=i.next()).done;)o.push(e.value)}catch(r){u={error:r}}finally{try{e&&!e.done&&(n=i.return)&&n.call(i)}finally{if(u)throw u.error}}return o}"function"==typeof SuppressedError&&SuppressedError;var no=new WeakMap;function eo(r,t){if(!t.relativeSelection)return null;var n=no.get(r.children);n||(n=new WeakMap,no.set(r.children,n));var e=n.get(t);if(void 0===e)try{e=s(r.sharedRoot,r,t.relativeSelection),n.set(t,e)}catch(r){return null}return e}function uo(r,t,n){var e,u,i=n.yOffset,o=n.xOffset,f=n.shouldGenerateOverlay,c=to(p.edges(t),2),a=c[0],s=c[1],l=function(r,t){try{return v.toDOMRange(r,t)}catch(r){return null}}(r,t);if(!l)return{caretPosition:null,selectionRects:[]};var g=[],b=h.nodes(r,{at:t,match:function(r,t){return y.isText(r)&&(!f||f(r,t))}}),m=null,w=p.isBackward(t);try{for(var O=function(r){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&r[t],e=0;if(n)return n.call(r);if(r&&"number"==typeof r.length)return{next:function(){return r&&e>=r.length&&(r=void 0),{value:r&&r[e++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(b),S=O.next();!S.done;S=O.next()){var j=to(S.value,2),E=j[0],x=j[1],A=v.toDOMNode(r,E),P=d.equals(x,a.path),R=d.equals(x,s.path),T=null;if(P||R){var k=document.createRange();k.selectNode(A),P&&k.setStart(l.startContainer,l.startOffset),R&&k.setEnd(l.endContainer,l.endOffset),T=k.getClientRects()}else T=A.getClientRects();for(var z=w?P:R,I=0;I<T.length;I+=1){var L=T.item(I);if(L){var C=z&&(w?0===I:I===T.length-1),M=L.top-i,F=L.left-o;C&&(m={height:L.height,top:M,left:F+(w||p.isCollapsed(t)?0:L.width)}),g.push({width:L.width,height:L.height,top:M,left:F})}}}}catch(r){e={error:r}}finally{try{S&&!S.done&&(u=O.return)&&u.call(O)}finally{if(e)throw e.error}}return{selectionRects:g,caretPosition:m}}function io(){var r=F();return l.isCursorEditor(r)||console.warn("Cannot use useSyncExternalStore outside the context of a RemoteCursorEditor"),r}var oo,fo,co={exports:{}},ao={};function so(){return fo||(fo=1,co.exports=function(){if(oo)return ao;oo=1;var t=r,n="function"==typeof Object.is?Object.is:function(r,t){return r===t&&(0!==r||1/r==1/t)||r!=r&&t!=t},e=t.useState,u=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function f(r){var t=r.getSnapshot;r=r.value;try{var e=t();return!n(r,e)}catch(r){return!0}}var c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(r,t){return t()}:function(r,t){var n=t(),c=e({inst:{value:n,getSnapshot:t}}),a=c[0].inst,s=c[1];return i((function(){a.value=n,a.getSnapshot=t,f(a)&&s({inst:a})}),[r,n,t]),u((function(){return f(a)&&s({inst:a}),r((function(){f(a)&&s({inst:a})}))}),[r]),o(n),n};return ao.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:c,ao}()),co.exports}var lo,vo,po=so(),ho={exports:{}},yo={};var go,bo,mo,wo,Oo,So=(vo||(vo=1,ho.exports=function(){if(lo)return yo;lo=1;var t=r,n=so(),e="function"==typeof Object.is?Object.is:function(r,t){return r===t&&(0!==r||1/r==1/t)||r!=r&&t!=t},u=n.useSyncExternalStore,i=t.useRef,o=t.useEffect,f=t.useMemo,c=t.useDebugValue;return yo.useSyncExternalStoreWithSelector=function(r,t,n,a,s){var l=i(null);if(null===l.current){var v={hasValue:!1,value:null};l.current=v}else v=l.current;l=f((function(){function r(r){if(!o){if(o=!0,u=r,r=a(r),void 0!==s&&v.hasValue){var t=v.value;if(s(t,r))return i=t}return i=r}if(t=i,e(u,r))return t;var n=a(r);return void 0!==s&&s(t,n)?t:(u=r,i=n)}var u,i,o=!1,f=void 0===n?null:n;return[function(){return r(t())},null===f?void 0:function(){return r(f())}]}),[t,n,a,s]);var p=u(r,l[0],l[1]);return o((function(){v.hasValue=!0,v.value=p}),[p]),c(p),p},yo}()),ho.exports),jo={};function Eo(){if(wo)return mo;wo=1;var r=en(),t=Rr(),n=on(),e=function(){if(bo)return go;bo=1;var r=Fr();return go=function(){var t=r(this),n="";return t.hasIndices&&(n+="d"),t.global&&(n+="g"),t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),t.dotAll&&(n+="s"),t.unicode&&(n+="u"),t.unicodeSets&&(n+="v"),t.sticky&&(n+="y"),n}}(),u=RegExp.prototype;return mo=function(i){var o=i.flags;return void 0!==o||"flags"in u||t(i,"flags")||!n(u,i)?o:r(e,i)}}!function(){if(Oo)return jo;Oo=1;var r=Hn().PROPER,t=Yn(),n=Fr(),e=Ei(),u=D(),i=Eo(),o="toString",f=RegExp.prototype,c=f[o],a=u((function(){return"/a/b"!==c.call({source:"a",flags:"b"})})),s=r&&c.name!==o;(a||s)&&t(f,o,(function(){var r=n(this);return"/"+e(r.source)+"/"+e(i(r))}),{unsafe:!0})}();var xo,Ao,Po,Ro,To,ko,zo,Io;function Lo(){if(Ao)return xo;Ao=1;var r=Kn(),t=hn();return xo=function(n,e,u){return u.get&&r(u.get,e,{getter:!0}),u.set&&r(u.set,e,{setter:!0}),t.f(n,e,u)}}function Co(){if(Ro)return Po;Ro=1;var r=un(),t=Lo(),n=Lr(),e=Vr(),u=n("species");return Po=function(n){var i=r(n);e&&i&&!i[u]&&t(i,u,{configurable:!0,get:function(){return this}})}}Io||(Io=1,zo||(zo=1,Ui()("Set",(function(r){return function(){return r(this,arguments.length?arguments[0]:void 0)}}),function(){if(ko)return To;ko=1;var r=xn(),t=Lo(),n=Gi(),e=hu(),u=Wi(),i=B(),o=si(),f=Be(),c=Ue(),a=Co(),s=Vr(),l=qu().fastKey,v=zn(),p=v.set,h=v.getterFor;return To={getConstructor:function(f,c,a,v){var y=f((function(t,n){u(t,d),p(t,{type:c,index:r(null),first:null,last:null,size:0}),s||(t.size=0),i(n)||o(n,t[v],{that:t,AS_ENTRIES:a})})),d=y.prototype,g=h(c),b=function(r,t,n){var e,u,i=g(r),o=m(r,t);return o?o.value=n:(i.last=o={index:u=l(t,!0),key:t,value:n,previous:e=i.last,next:null,removed:!1},i.first||(i.first=o),e&&(e.next=o),s?i.size++:r.size++,"F"!==u&&(i.index[u]=o)),r},m=function(r,t){var n,e=g(r),u=l(t);if("F"!==u)return e.index[u];for(n=e.first;n;n=n.next)if(n.key===t)return n};return n(d,{clear:function(){for(var t=g(this),n=t.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=null),n=n.next;t.first=t.last=null,t.index=r(null),s?t.size=0:this.size=0},delete:function(r){var t=this,n=g(t),e=m(t,r);if(e){var u=e.next,i=e.previous;delete n.index[e.index],e.removed=!0,i&&(i.next=u),u&&(u.previous=i),n.first===e&&(n.first=u),n.last===e&&(n.last=i),s?n.size--:t.size--}return!!e},forEach:function(r){for(var t,n=g(this),u=e(r,arguments.length>1?arguments[1]:void 0);t=t?t.next:n.first;)for(u(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(r){return!!m(this,r)}}),n(d,a?{get:function(r){var t=m(this,r);return t&&t.value},set:function(r,t){return b(this,0===r?0:r,t)}}:{add:function(r){return b(this,r=0===r?0:r,r)}}),s&&t(d,"size",{configurable:!0,get:function(){return g(this).size}}),y},setStrong:function(r,t,n){var e=t+" Iterator",u=h(t),i=h(e);f(r,t,(function(r,t){p(this,{type:e,target:r,state:u(r),kind:t,last:null})}),(function(){for(var r=i(this),t=r.kind,n=r.last;n&&n.removed;)n=n.previous;return r.target&&(r.last=n=n?n.next:r.state.first)?c("keys"===t?n.key:"values"===t?n.value:[n.key,n.value],!1):(r.target=null,c(void 0,!0))}),n?"entries":"values",!n,!0),a(t)}},To}())));var Mo,Fo,_o,Do,No,Go={};!function(){if(No)return Go;No=1;var r=H(),t=Qi(),n=Zi(),e=function(){if(Do)return _o;Do=1;var r=Ou().forEach,t=function(){if(Fo)return Mo;Fo=1;var r=D();return Mo=function(t,n){var e=[][t];return!!e&&r((function(){e.call(null,n||function(){return 1},1)}))}}()("forEach");return _o=t?[].forEach:function(t){return r(this,t,arguments.length>1?arguments[1]:void 0)},_o}(),u=kn(),i=function(r){if(r&&r.forEach!==e)try{u(r,"forEach",e)}catch(t){r.forEach=e}};for(var o in t)t[o]&&i(r[o]&&r[o].prototype);i(n)}();var Wo=new WeakMap;function Vo(r){var t=Wo.get(r);if(t)return t;var n=function(r){var t={},n=new Set,e=n.add.bind(n),u=new Set,i=null;return[function(t){return u.add(t),i||(i=function(r){r.added.forEach(e),r.removed.forEach(e),r.updated.forEach(e),u.forEach((function(r){return r()}))},l.on(r,"change",i)),function(){u.delete(t),i&&0===u.size&&(l.off(r,"change",i),i=null)}},function(){return 0===n.size?t:(n.forEach((function(n){var e=l.cursorState(r,n);null!==e?t[n]=e:delete t[n.toString()]})),n.clear(),t=ro({},t))}]}(r);return r&&Wo.set(r,n),n}function Bo(){return Vo(io())}function Uo(){var r=to(Bo(),2),t=r[0],n=r[1];return po.useSyncExternalStore(t,n)}function qo(r,t){var n=to(Bo(),2),e=n[0],u=n[1];return So.useSyncExternalStoreWithSelector(e,u,null,r,t)}var Ho=Object.freeze([]);function Xo(r){var t;void 0===r&&(r={});var n,s,l,v=r.containerRef,p=r.shouldGenerateOverlay,h=function(r,t){var n={};for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&t.indexOf(e)<0&&(n[e]=r[e]);if(null!=r&&"function"==typeof Object.getOwnPropertySymbols){var u=0;for(e=Object.getOwnPropertySymbols(r);u<e.length;u++)t.indexOf(e[u])<0&&Object.prototype.propertyIsEnumerable.call(r,e[u])&&(n[e[u]]=r[e[u]])}return n}(r,["containerRef","shouldGenerateOverlay"]),y=io(),d=Uo(),g=(n=to(e((function(r){return r+1}),0),2)[1],s=u(null),i(l=function(){s.current&&(cancelAnimationFrame(s.current),s.current=0)}),i((function(){return l}),[]),o((function(r){void 0===r&&(r=!1),r?n():s.current||(s.current=requestAnimationFrame(n))}),[])),b=u(new WeakMap),m=to(f({}),2),w=m[0],O=m[1],S=!("refreshOnResize"in h)||(null===(t=h.refreshOnResize)||void 0===t||t);!function(r,t){var n=u(t);n.current=t;var e=to(f((function(){return new ResizeObserver((function(){n.current()}))})),1)[0];i((function(){if(null==r?void 0:r.current){var t=r.current;return e.observe(t),function(){return e.unobserve(t)}}}),[e,r])}(S?v:void 0,(function(){b.current=new WeakMap,g("debounced"!==S)})),c((function(){var r,t,n;if(!v||v.current){var e=null===(r=null==v?void 0:v.current)||void 0===r?void 0:r.getBoundingClientRect(),u=null!==(t=null==e?void 0:e.x)&&void 0!==t?t:0,i=null!==(n=null==e?void 0:e.y)&&void 0!==n?n:0,o=Object.keys(w).length!==Object.keys(d).length,f=Object.fromEntries(Object.entries(d).map((function(r){var t=to(r,2),n=t[0],e=t[1],f=e.relativeSelection&&eo(y,e);if(!f)return[n,Ho];var c=b.current.get(f);if(c)return[n,c];var a=uo(y,f,{xOffset:u,yOffset:i,shouldGenerateOverlay:p});return o=!0,b.current.set(f,a),[n,a]})));o&&O(f)}}));var j=a((function(){return Object.entries(d).map((function(r){var t,n,e=to(r,2),u=e[0],i=e[1],o=i.relativeSelection&&eo(y,i),f=w[u];return ro(ro({},i),{range:o,caretPosition:null!==(t=null==f?void 0:f.caretPosition)&&void 0!==t?t:null,selectionRects:null!==(n=null==f?void 0:f.selectionRects)&&void 0!==n?n:Ho})}))}),[d,y,w]);return[j,o((function(){b.current=new WeakMap,g(!0)}),[g])]}export{M as EditorContext,eo as getCursorRange,F as useEditorStatic,Xo as useRemoteCursorOverlayPositions,Uo as useRemoteCursorStates,qo as useRemoteCursorStatesSelector};
2
- //# sourceMappingURL=index.mjs.map
1
+ import require$$0, { createContext, useContext, useReducer, useRef, useEffect, useCallback, useState, useLayoutEffect, useMemo } from 'react';
2
+ import { relativeRangeToSlateRange, CursorEditor } from '@wangeditor-next/yjs';
3
+ import { DomEditor } from '@wangeditor-next/editor';
4
+ import { Range, Editor, Text, Path } from 'slate';
5
+
6
+ var EditorContext = createContext(null);
7
+ var useEditorStatic = function () {
8
+ var editor = useContext(EditorContext);
9
+ if (!editor) {
10
+ // throw new Error(
11
+ // `The \`useEditorStatic\` hook must be used inside the <EditorContext> component's context.`
12
+ // )
13
+ console.warn("The `useEditorStatic` hook must be used inside the <EditorContext> component's context.");
14
+ }
15
+ return editor;
16
+ };
17
+
18
+ /******************************************************************************
19
+ Copyright (c) Microsoft Corporation.
20
+
21
+ Permission to use, copy, modify, and/or distribute this software for any
22
+ purpose with or without fee is hereby granted.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
25
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
26
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
27
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
28
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
29
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
30
+ PERFORMANCE OF THIS SOFTWARE.
31
+ ***************************************************************************** */
32
+ /* global Reflect, Promise, SuppressedError, Symbol */
33
+
34
+
35
+ var __assign = function() {
36
+ __assign = Object.assign || function __assign(t) {
37
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
38
+ s = arguments[i];
39
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
40
+ }
41
+ return t;
42
+ };
43
+ return __assign.apply(this, arguments);
44
+ };
45
+
46
+ function __rest(s, e) {
47
+ var t = {};
48
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
49
+ t[p] = s[p];
50
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
51
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
52
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
53
+ t[p[i]] = s[p[i]];
54
+ }
55
+ return t;
56
+ }
57
+
58
+ function __values(o) {
59
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
60
+ if (m) return m.call(o);
61
+ if (o && typeof o.length === "number") return {
62
+ next: function () {
63
+ if (o && i >= o.length) o = void 0;
64
+ return { value: o && o[i++], done: !o };
65
+ }
66
+ };
67
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
68
+ }
69
+
70
+ function __read(o, n) {
71
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
72
+ if (!m) return o;
73
+ var i = m.call(o), r, ar = [], e;
74
+ try {
75
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
76
+ }
77
+ catch (error) { e = { error: error }; }
78
+ finally {
79
+ try {
80
+ if (r && !r.done && (m = i["return"])) m.call(i);
81
+ }
82
+ finally { if (e) throw e.error; }
83
+ }
84
+ return ar;
85
+ }
86
+
87
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
88
+ var e = new Error(message);
89
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
90
+ };
91
+
92
+ var CHILDREN_TO_CURSOR_STATE_TO_RANGE = new WeakMap();
93
+ function getCursorRange(editor, cursorState) {
94
+ if (!cursorState.relativeSelection) {
95
+ return null;
96
+ }
97
+ var cursorStates = CHILDREN_TO_CURSOR_STATE_TO_RANGE.get(editor.children);
98
+ if (!cursorStates) {
99
+ cursorStates = new WeakMap();
100
+ CHILDREN_TO_CURSOR_STATE_TO_RANGE.set(editor.children, cursorStates);
101
+ }
102
+ var range = cursorStates.get(cursorState);
103
+ if (range === undefined) {
104
+ try {
105
+ range = relativeRangeToSlateRange(editor.sharedRoot, editor, cursorState.relativeSelection);
106
+ cursorStates.set(cursorState, range);
107
+ }
108
+ catch (e) {
109
+ return null;
110
+ }
111
+ }
112
+ return range;
113
+ }
114
+
115
+ function reactEditorToDomRangeSafe(editor, range) {
116
+ try {
117
+ return DomEditor.toDOMRange(editor, range);
118
+ }
119
+ catch (e) {
120
+ return null;
121
+ }
122
+ }
123
+
124
+ function getOverlayPosition(editor, range, _a) {
125
+ var e_1, _b;
126
+ var yOffset = _a.yOffset, xOffset = _a.xOffset, shouldGenerateOverlay = _a.shouldGenerateOverlay;
127
+ var _c = __read(Range.edges(range), 2), start = _c[0], end = _c[1];
128
+ var domRange = reactEditorToDomRangeSafe(editor, range);
129
+ if (!domRange) {
130
+ return {
131
+ caretPosition: null,
132
+ selectionRects: [],
133
+ };
134
+ }
135
+ var selectionRects = [];
136
+ var nodeIterator = Editor.nodes(editor, {
137
+ at: range,
138
+ match: function (n, p) { return Text.isText(n) && (!shouldGenerateOverlay || shouldGenerateOverlay(n, p)); },
139
+ });
140
+ var caretPosition = null;
141
+ var isBackward = Range.isBackward(range);
142
+ try {
143
+ for (var nodeIterator_1 = __values(nodeIterator), nodeIterator_1_1 = nodeIterator_1.next(); !nodeIterator_1_1.done; nodeIterator_1_1 = nodeIterator_1.next()) {
144
+ var _d = __read(nodeIterator_1_1.value, 2), node = _d[0], path = _d[1];
145
+ var domNode = DomEditor.toDOMNode(editor, node);
146
+ var isStartNode = Path.equals(path, start.path);
147
+ var isEndNode = Path.equals(path, end.path);
148
+ var clientRects = null;
149
+ if (isStartNode || isEndNode) {
150
+ var nodeRange = document.createRange();
151
+ nodeRange.selectNode(domNode);
152
+ if (isStartNode) {
153
+ nodeRange.setStart(domRange.startContainer, domRange.startOffset);
154
+ }
155
+ if (isEndNode) {
156
+ nodeRange.setEnd(domRange.endContainer, domRange.endOffset);
157
+ }
158
+ clientRects = nodeRange.getClientRects();
159
+ }
160
+ else {
161
+ clientRects = domNode.getClientRects();
162
+ }
163
+ var isCaret = isBackward ? isStartNode : isEndNode;
164
+ for (var i = 0; i < clientRects.length; i += 1) {
165
+ var clientRect = clientRects.item(i);
166
+ if (!clientRect) {
167
+ continue;
168
+ }
169
+ var isCaretRect = isCaret && (isBackward ? i === 0 : i === clientRects.length - 1);
170
+ var top_1 = clientRect.top - yOffset;
171
+ var left = clientRect.left - xOffset;
172
+ if (isCaretRect) {
173
+ caretPosition = {
174
+ height: clientRect.height,
175
+ top: top_1,
176
+ left: left + (isBackward || Range.isCollapsed(range) ? 0 : clientRect.width),
177
+ };
178
+ }
179
+ selectionRects.push({
180
+ width: clientRect.width,
181
+ height: clientRect.height,
182
+ top: top_1,
183
+ left: left,
184
+ });
185
+ }
186
+ }
187
+ }
188
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
189
+ finally {
190
+ try {
191
+ if (nodeIterator_1_1 && !nodeIterator_1_1.done && (_b = nodeIterator_1.return)) _b.call(nodeIterator_1);
192
+ }
193
+ finally { if (e_1) throw e_1.error; }
194
+ }
195
+ return {
196
+ selectionRects: selectionRects,
197
+ caretPosition: caretPosition,
198
+ };
199
+ }
200
+
201
+ function useRemoteCursorEditor() {
202
+ var editor = useEditorStatic();
203
+ if (!CursorEditor.isCursorEditor(editor)) {
204
+ console.warn('Cannot use useSyncExternalStore outside the context of a RemoteCursorEditor');
205
+ }
206
+ return editor;
207
+ }
208
+
209
+ var shim = {exports: {}};
210
+
211
+ var useSyncExternalStoreShim_development = {};
212
+
213
+ /**
214
+ * @license React
215
+ * use-sync-external-store-shim.development.js
216
+ *
217
+ * Copyright (c) Facebook, Inc. and its affiliates.
218
+ *
219
+ * This source code is licensed under the MIT license found in the
220
+ * LICENSE file in the root directory of this source tree.
221
+ */
222
+
223
+ var hasRequiredUseSyncExternalStoreShim_development;
224
+
225
+ function requireUseSyncExternalStoreShim_development () {
226
+ if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
227
+ hasRequiredUseSyncExternalStoreShim_development = 1;
228
+
229
+ {
230
+ (function() {
231
+
232
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
233
+ if (
234
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
235
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
236
+ 'function'
237
+ ) {
238
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
239
+ }
240
+ var React = require$$0;
241
+
242
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
243
+
244
+ function error(format) {
245
+ {
246
+ {
247
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
248
+ args[_key2 - 1] = arguments[_key2];
249
+ }
250
+
251
+ printWarning('error', format, args);
252
+ }
253
+ }
254
+ }
255
+
256
+ function printWarning(level, format, args) {
257
+ // When changing this logic, you might want to also
258
+ // update consoleWithStackDev.www.js as well.
259
+ {
260
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
261
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
262
+
263
+ if (stack !== '') {
264
+ format += '%s';
265
+ args = args.concat([stack]);
266
+ } // eslint-disable-next-line react-internal/safe-string-coercion
267
+
268
+
269
+ var argsWithFormat = args.map(function (item) {
270
+ return String(item);
271
+ }); // Careful: RN currently depends on this prefix
272
+
273
+ argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
274
+ // breaks IE9: https://github.com/facebook/react/issues/13610
275
+ // eslint-disable-next-line react-internal/no-production-logging
276
+
277
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
278
+ }
279
+ }
280
+
281
+ /**
282
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
283
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
284
+ */
285
+ function is(x, y) {
286
+ return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
287
+ ;
288
+ }
289
+
290
+ var objectIs = typeof Object.is === 'function' ? Object.is : is;
291
+
292
+ // dispatch for CommonJS interop named imports.
293
+
294
+ var useState = React.useState,
295
+ useEffect = React.useEffect,
296
+ useLayoutEffect = React.useLayoutEffect,
297
+ useDebugValue = React.useDebugValue;
298
+ var didWarnOld18Alpha = false;
299
+ var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
300
+ // because of a very particular set of implementation details and assumptions
301
+ // -- change any one of them and it will break. The most important assumption
302
+ // is that updates are always synchronous, because concurrent rendering is
303
+ // only available in versions of React that also have a built-in
304
+ // useSyncExternalStore API. And we only use this shim when the built-in API
305
+ // does not exist.
306
+ //
307
+ // Do not assume that the clever hacks used by this hook also work in general.
308
+ // The point of this shim is to replace the need for hacks by other libraries.
309
+
310
+ function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
311
+ // React do not expose a way to check if we're hydrating. So users of the shim
312
+ // will need to track that themselves and return the correct value
313
+ // from `getSnapshot`.
314
+ getServerSnapshot) {
315
+ {
316
+ if (!didWarnOld18Alpha) {
317
+ if (React.startTransition !== undefined) {
318
+ didWarnOld18Alpha = true;
319
+
320
+ error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
321
+ }
322
+ }
323
+ } // Read the current snapshot from the store on every render. Again, this
324
+ // breaks the rules of React, and only works here because of specific
325
+ // implementation details, most importantly that updates are
326
+ // always synchronous.
327
+
328
+
329
+ var value = getSnapshot();
330
+
331
+ {
332
+ if (!didWarnUncachedGetSnapshot) {
333
+ var cachedValue = getSnapshot();
334
+
335
+ if (!objectIs(value, cachedValue)) {
336
+ error('The result of getSnapshot should be cached to avoid an infinite loop');
337
+
338
+ didWarnUncachedGetSnapshot = true;
339
+ }
340
+ }
341
+ } // Because updates are synchronous, we don't queue them. Instead we force a
342
+ // re-render whenever the subscribed state changes by updating an some
343
+ // arbitrary useState hook. Then, during render, we call getSnapshot to read
344
+ // the current value.
345
+ //
346
+ // Because we don't actually use the state returned by the useState hook, we
347
+ // can save a bit of memory by storing other stuff in that slot.
348
+ //
349
+ // To implement the early bailout, we need to track some things on a mutable
350
+ // object. Usually, we would put that in a useRef hook, but we can stash it in
351
+ // our useState hook instead.
352
+ //
353
+ // To force a re-render, we call forceUpdate({inst}). That works because the
354
+ // new object always fails an equality check.
355
+
356
+
357
+ var _useState = useState({
358
+ inst: {
359
+ value: value,
360
+ getSnapshot: getSnapshot
361
+ }
362
+ }),
363
+ inst = _useState[0].inst,
364
+ forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
365
+ // in the layout phase so we can access it during the tearing check that
366
+ // happens on subscribe.
367
+
368
+
369
+ useLayoutEffect(function () {
370
+ inst.value = value;
371
+ inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
372
+ // commit phase if there was an interleaved mutation. In concurrent mode
373
+ // this can happen all the time, but even in synchronous mode, an earlier
374
+ // effect may have mutated the store.
375
+
376
+ if (checkIfSnapshotChanged(inst)) {
377
+ // Force a re-render.
378
+ forceUpdate({
379
+ inst: inst
380
+ });
381
+ }
382
+ }, [subscribe, value, getSnapshot]);
383
+ useEffect(function () {
384
+ // Check for changes right before subscribing. Subsequent changes will be
385
+ // detected in the subscription handler.
386
+ if (checkIfSnapshotChanged(inst)) {
387
+ // Force a re-render.
388
+ forceUpdate({
389
+ inst: inst
390
+ });
391
+ }
392
+
393
+ var handleStoreChange = function () {
394
+ // TODO: Because there is no cross-renderer API for batching updates, it's
395
+ // up to the consumer of this library to wrap their subscription event
396
+ // with unstable_batchedUpdates. Should we try to detect when this isn't
397
+ // the case and print a warning in development?
398
+ // The store changed. Check if the snapshot changed since the last time we
399
+ // read from the store.
400
+ if (checkIfSnapshotChanged(inst)) {
401
+ // Force a re-render.
402
+ forceUpdate({
403
+ inst: inst
404
+ });
405
+ }
406
+ }; // Subscribe to the store and return a clean-up function.
407
+
408
+
409
+ return subscribe(handleStoreChange);
410
+ }, [subscribe]);
411
+ useDebugValue(value);
412
+ return value;
413
+ }
414
+
415
+ function checkIfSnapshotChanged(inst) {
416
+ var latestGetSnapshot = inst.getSnapshot;
417
+ var prevValue = inst.value;
418
+
419
+ try {
420
+ var nextValue = latestGetSnapshot();
421
+ return !objectIs(prevValue, nextValue);
422
+ } catch (error) {
423
+ return true;
424
+ }
425
+ }
426
+
427
+ function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
428
+ // Note: The shim does not use getServerSnapshot, because pre-18 versions of
429
+ // React do not expose a way to check if we're hydrating. So users of the shim
430
+ // will need to track that themselves and return the correct value
431
+ // from `getSnapshot`.
432
+ return getSnapshot();
433
+ }
434
+
435
+ var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
436
+
437
+ var isServerEnvironment = !canUseDOM;
438
+
439
+ var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
440
+ var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
441
+
442
+ useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
443
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
444
+ if (
445
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
446
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
447
+ 'function'
448
+ ) {
449
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
450
+ }
451
+
452
+ })();
453
+ }
454
+ return useSyncExternalStoreShim_development;
455
+ }
456
+
457
+ var hasRequiredShim;
458
+
459
+ function requireShim () {
460
+ if (hasRequiredShim) return shim.exports;
461
+ hasRequiredShim = 1;
462
+
463
+ {
464
+ shim.exports = requireUseSyncExternalStoreShim_development();
465
+ }
466
+ return shim.exports;
467
+ }
468
+
469
+ var shimExports = requireShim();
470
+
471
+ var withSelector = {exports: {}};
472
+
473
+ var withSelector_development = {};
474
+
475
+ /**
476
+ * @license React
477
+ * use-sync-external-store-shim/with-selector.development.js
478
+ *
479
+ * Copyright (c) Facebook, Inc. and its affiliates.
480
+ *
481
+ * This source code is licensed under the MIT license found in the
482
+ * LICENSE file in the root directory of this source tree.
483
+ */
484
+
485
+ var hasRequiredWithSelector_development;
486
+
487
+ function requireWithSelector_development () {
488
+ if (hasRequiredWithSelector_development) return withSelector_development;
489
+ hasRequiredWithSelector_development = 1;
490
+
491
+ {
492
+ (function() {
493
+
494
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
495
+ if (
496
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
497
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
498
+ 'function'
499
+ ) {
500
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
501
+ }
502
+ var React = require$$0;
503
+ var shim = requireShim();
504
+
505
+ /**
506
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
507
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
508
+ */
509
+ function is(x, y) {
510
+ return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
511
+ ;
512
+ }
513
+
514
+ var objectIs = typeof Object.is === 'function' ? Object.is : is;
515
+
516
+ var useSyncExternalStore = shim.useSyncExternalStore;
517
+
518
+ // for CommonJS interop.
519
+
520
+ var useRef = React.useRef,
521
+ useEffect = React.useEffect,
522
+ useMemo = React.useMemo,
523
+ useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
524
+
525
+ function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
526
+ // Use this to track the rendered snapshot.
527
+ var instRef = useRef(null);
528
+ var inst;
529
+
530
+ if (instRef.current === null) {
531
+ inst = {
532
+ hasValue: false,
533
+ value: null
534
+ };
535
+ instRef.current = inst;
536
+ } else {
537
+ inst = instRef.current;
538
+ }
539
+
540
+ var _useMemo = useMemo(function () {
541
+ // Track the memoized state using closure variables that are local to this
542
+ // memoized instance of a getSnapshot function. Intentionally not using a
543
+ // useRef hook, because that state would be shared across all concurrent
544
+ // copies of the hook/component.
545
+ var hasMemo = false;
546
+ var memoizedSnapshot;
547
+ var memoizedSelection;
548
+
549
+ var memoizedSelector = function (nextSnapshot) {
550
+ if (!hasMemo) {
551
+ // The first time the hook is called, there is no memoized result.
552
+ hasMemo = true;
553
+ memoizedSnapshot = nextSnapshot;
554
+
555
+ var _nextSelection = selector(nextSnapshot);
556
+
557
+ if (isEqual !== undefined) {
558
+ // Even if the selector has changed, the currently rendered selection
559
+ // may be equal to the new selection. We should attempt to reuse the
560
+ // current value if possible, to preserve downstream memoizations.
561
+ if (inst.hasValue) {
562
+ var currentSelection = inst.value;
563
+
564
+ if (isEqual(currentSelection, _nextSelection)) {
565
+ memoizedSelection = currentSelection;
566
+ return currentSelection;
567
+ }
568
+ }
569
+ }
570
+
571
+ memoizedSelection = _nextSelection;
572
+ return _nextSelection;
573
+ } // We may be able to reuse the previous invocation's result.
574
+
575
+
576
+ // We may be able to reuse the previous invocation's result.
577
+ var prevSnapshot = memoizedSnapshot;
578
+ var prevSelection = memoizedSelection;
579
+
580
+ if (objectIs(prevSnapshot, nextSnapshot)) {
581
+ // The snapshot is the same as last time. Reuse the previous selection.
582
+ return prevSelection;
583
+ } // The snapshot has changed, so we need to compute a new selection.
584
+
585
+
586
+ // The snapshot has changed, so we need to compute a new selection.
587
+ var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
588
+ // has changed. If it hasn't, return the previous selection. That signals
589
+ // to React that the selections are conceptually equal, and we can bail
590
+ // out of rendering.
591
+
592
+ // If a custom isEqual function is provided, use that to check if the data
593
+ // has changed. If it hasn't, return the previous selection. That signals
594
+ // to React that the selections are conceptually equal, and we can bail
595
+ // out of rendering.
596
+ if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
597
+ return prevSelection;
598
+ }
599
+
600
+ memoizedSnapshot = nextSnapshot;
601
+ memoizedSelection = nextSelection;
602
+ return nextSelection;
603
+ }; // Assigning this to a constant so that Flow knows it can't change.
604
+
605
+
606
+ // Assigning this to a constant so that Flow knows it can't change.
607
+ var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
608
+
609
+ var getSnapshotWithSelector = function () {
610
+ return memoizedSelector(getSnapshot());
611
+ };
612
+
613
+ var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
614
+ return memoizedSelector(maybeGetServerSnapshot());
615
+ };
616
+ return [getSnapshotWithSelector, getServerSnapshotWithSelector];
617
+ }, [getSnapshot, getServerSnapshot, selector, isEqual]),
618
+ getSelection = _useMemo[0],
619
+ getServerSelection = _useMemo[1];
620
+
621
+ var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
622
+ useEffect(function () {
623
+ inst.hasValue = true;
624
+ inst.value = value;
625
+ }, [value]);
626
+ useDebugValue(value);
627
+ return value;
628
+ }
629
+
630
+ withSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
631
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
632
+ if (
633
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
634
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
635
+ 'function'
636
+ ) {
637
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
638
+ }
639
+
640
+ })();
641
+ }
642
+ return withSelector_development;
643
+ }
644
+
645
+ var hasRequiredWithSelector;
646
+
647
+ function requireWithSelector () {
648
+ if (hasRequiredWithSelector) return withSelector.exports;
649
+ hasRequiredWithSelector = 1;
650
+
651
+ {
652
+ withSelector.exports = requireWithSelector_development();
653
+ }
654
+ return withSelector.exports;
655
+ }
656
+
657
+ var withSelectorExports = requireWithSelector();
658
+
659
+ var EDITOR_TO_CURSOR_STORE = new WeakMap();
660
+ function createRemoteCursorStateStore(editor) {
661
+ var cursors = {};
662
+ var changed = new Set();
663
+ var addChanged = changed.add.bind(changed);
664
+ var onStoreChangeListeners = new Set();
665
+ var changeHandler = null;
666
+ var subscribe = function (onStoreChange) {
667
+ onStoreChangeListeners.add(onStoreChange);
668
+ if (!changeHandler) {
669
+ changeHandler = function (event) {
670
+ event.added.forEach(addChanged);
671
+ event.removed.forEach(addChanged);
672
+ event.updated.forEach(addChanged);
673
+ onStoreChangeListeners.forEach(function (listener) { return listener(); });
674
+ };
675
+ CursorEditor.on(editor, 'change', changeHandler);
676
+ }
677
+ return function () {
678
+ onStoreChangeListeners.delete(onStoreChange);
679
+ if (changeHandler && onStoreChangeListeners.size === 0) {
680
+ CursorEditor.off(editor, 'change', changeHandler);
681
+ changeHandler = null;
682
+ }
683
+ };
684
+ };
685
+ var getSnapshot = function () {
686
+ if (changed.size === 0) {
687
+ return cursors;
688
+ }
689
+ changed.forEach(function (clientId) {
690
+ var state = CursorEditor.cursorState(editor, clientId);
691
+ if (state === null) {
692
+ delete cursors[clientId.toString()];
693
+ return;
694
+ }
695
+ cursors[clientId] = state;
696
+ });
697
+ changed.clear();
698
+ cursors = __assign({}, cursors);
699
+ return cursors;
700
+ };
701
+ return [subscribe, getSnapshot];
702
+ }
703
+ function getCursorStateStore(editor) {
704
+ var existing = EDITOR_TO_CURSOR_STORE.get(editor);
705
+ if (existing) {
706
+ return existing;
707
+ }
708
+ var store = createRemoteCursorStateStore(editor);
709
+ if (editor) {
710
+ EDITOR_TO_CURSOR_STORE.set(editor, store);
711
+ }
712
+ return store;
713
+ }
714
+ function useRemoteCursorStateStore() {
715
+ var editor = useRemoteCursorEditor();
716
+ return getCursorStateStore(editor);
717
+ }
718
+
719
+ function useRemoteCursorStates() {
720
+ var _a = __read(useRemoteCursorStateStore(), 2), subscribe = _a[0], getSnapshot = _a[1];
721
+ return shimExports.useSyncExternalStore(subscribe, getSnapshot);
722
+ }
723
+ function useRemoteCursorStatesSelector(selector, isEqual) {
724
+ var _a = __read(useRemoteCursorStateStore(), 2), subscribe = _a[0], getSnapshot = _a[1];
725
+ return withSelectorExports.useSyncExternalStoreWithSelector(subscribe, getSnapshot, null, selector, isEqual);
726
+ }
727
+
728
+ function useRequestRerender() {
729
+ var _a = __read(useReducer(function (s) { return s + 1; }, 0), 2), rerender = _a[1];
730
+ var animationFrameIdRef = useRef(null);
731
+ var clearAnimationFrame = function () {
732
+ if (animationFrameIdRef.current) {
733
+ cancelAnimationFrame(animationFrameIdRef.current);
734
+ animationFrameIdRef.current = 0;
735
+ }
736
+ };
737
+ useEffect(clearAnimationFrame);
738
+ useEffect(function () { return clearAnimationFrame; }, []);
739
+ return useCallback(function (immediately) {
740
+ if (immediately === void 0) { immediately = false; }
741
+ if (immediately) {
742
+ rerender();
743
+ return;
744
+ }
745
+ if (animationFrameIdRef.current) {
746
+ return;
747
+ }
748
+ animationFrameIdRef.current = requestAnimationFrame(rerender);
749
+ }, []);
750
+ }
751
+ function useOnResize(ref, onResize) {
752
+ var onResizeRef = useRef(onResize);
753
+ onResizeRef.current = onResize;
754
+ var _a = __read(useState(function () { return new ResizeObserver(function () {
755
+ onResizeRef.current();
756
+ }); }), 1), observer = _a[0];
757
+ useEffect(function () {
758
+ if (!(ref === null || ref === void 0 ? void 0 : ref.current)) {
759
+ return;
760
+ }
761
+ var element = ref.current;
762
+ observer.observe(element);
763
+ return function () { return observer.unobserve(element); };
764
+ }, [observer, ref]);
765
+ }
766
+
767
+ var FROZEN_EMPTY_ARRAY = Object.freeze([]);
768
+ function useRemoteCursorOverlayPositions(_a) {
769
+ var _b;
770
+ if (_a === void 0) { _a = {}; }
771
+ var containerRef = _a.containerRef, shouldGenerateOverlay = _a.shouldGenerateOverlay, opts = __rest(_a, ["containerRef", "shouldGenerateOverlay"]);
772
+ var editor = useRemoteCursorEditor();
773
+ var cursorStates = useRemoteCursorStates();
774
+ var requestRerender = useRequestRerender();
775
+ var overlayPositionCache = useRef(new WeakMap());
776
+ var _c = __read(useState({}), 2), overlayPositions = _c[0], setOverlayPositions = _c[1];
777
+ var refreshOnResize = 'refreshOnResize' in opts ? (_b = opts.refreshOnResize) !== null && _b !== void 0 ? _b : true : true;
778
+ useOnResize(refreshOnResize ? containerRef : undefined, function () {
779
+ overlayPositionCache.current = new WeakMap();
780
+ requestRerender(refreshOnResize !== 'debounced');
781
+ });
782
+ // Update selection rects after paint
783
+ useLayoutEffect(function () {
784
+ var _a, _b, _c;
785
+ // We have a container ref but the ref is null => container
786
+ // isn't mounted to we can't calculate the selection rects.
787
+ if (containerRef && !containerRef.current) {
788
+ return;
789
+ }
790
+ var containerRect = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
791
+ var xOffset = (_b = containerRect === null || containerRect === void 0 ? void 0 : containerRect.x) !== null && _b !== void 0 ? _b : 0;
792
+ var yOffset = (_c = containerRect === null || containerRect === void 0 ? void 0 : containerRect.y) !== null && _c !== void 0 ? _c : 0;
793
+ var overlayPositionsChanged = Object.keys(overlayPositions).length !== Object.keys(cursorStates).length;
794
+ var updated = Object.fromEntries(Object.entries(cursorStates).map(function (_a) {
795
+ var _b = __read(_a, 2), key = _b[0], state = _b[1];
796
+ var range = state.relativeSelection && getCursorRange(editor, state);
797
+ if (!range) {
798
+ return [key, FROZEN_EMPTY_ARRAY];
799
+ }
800
+ var cached = overlayPositionCache.current.get(range);
801
+ if (cached) {
802
+ return [key, cached];
803
+ }
804
+ var overlayPosition = getOverlayPosition(editor, range, {
805
+ xOffset: xOffset,
806
+ yOffset: yOffset,
807
+ shouldGenerateOverlay: shouldGenerateOverlay,
808
+ });
809
+ overlayPositionsChanged = true;
810
+ overlayPositionCache.current.set(range, overlayPosition);
811
+ return [key, overlayPosition];
812
+ }));
813
+ if (overlayPositionsChanged) {
814
+ setOverlayPositions(updated);
815
+ }
816
+ });
817
+ var overlayData = useMemo(function () { return Object.entries(cursorStates).map(function (_a) {
818
+ var _b, _c;
819
+ var _d = __read(_a, 2), clientId = _d[0], state = _d[1];
820
+ var range = state.relativeSelection && getCursorRange(editor, state);
821
+ var overlayPosition = overlayPositions[clientId];
822
+ return __assign(__assign({}, state), { range: range, caretPosition: (_b = overlayPosition === null || overlayPosition === void 0 ? void 0 : overlayPosition.caretPosition) !== null && _b !== void 0 ? _b : null, selectionRects: (_c = overlayPosition === null || overlayPosition === void 0 ? void 0 : overlayPosition.selectionRects) !== null && _c !== void 0 ? _c : FROZEN_EMPTY_ARRAY });
823
+ }); }, [cursorStates, editor, overlayPositions]);
824
+ var refresh = useCallback(function () {
825
+ overlayPositionCache.current = new WeakMap();
826
+ requestRerender(true);
827
+ }, [requestRerender]);
828
+ return [overlayData, refresh];
829
+ }
830
+
831
+ export { EditorContext, getCursorRange, useEditorStatic, useRemoteCursorOverlayPositions, useRemoteCursorStates, useRemoteCursorStatesSelector };