yjs/y.js
2017-12-05 00:53:36 -08:00

10 lines
76 KiB
JavaScript

/**
* yjs - A framework for real-time p2p shared editing on any data
* @version v13.0.0-38
* @license MIT
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Y=e()}(this,function(){"use strict";function t(t,e){return e={exports:{}},t(e,e.exports),e.exports}function e(t,e){var n=e._id;if(void 0===n)e._integrate(t);else{if(t.ss.getState(n.user)>n.clock)return;e._integrate(t);var r=t._missingStructs.get(n.user);if(null!=r)for(var i=n.clock,o=i+e._length;i<o;i++){var s=r.get(i);void 0!==s&&(s.forEach(function(e){if(0===--e.missing){var n=e.decoder,r=n.pos,i=e.struct._fromBinary(t,n);n.pos=r,0===i.length&&t._readyToIntegrate.push(e.struct)}}),r.delete(i))}}}function n(t,e,n){for(var r=e.readUint32(),i=0;i<r;i++){var o=e.readVarUint(),s=z(o),a=new s,l=a._fromBinary(t,e),u=" "+a._logString();l.length>0&&(u+=" .. missing: "+l.map(g).join(", ")),n.push(u)}}function r(t,n,r){for(var i=t.readUint32(),o=0;o<i;o++){var s=t.readVarUint(),a=z(s),l=new a,u=t.pos,h=l._fromBinary(r,t);if(0===h.length)for(;null!=l;)e(r,l),l=r._readyToIntegrate.shift();else{var c=new vt(t.uint8arr);c.pos=u;for(var f=new gt(c,h,l),d=r._missingStructs,_=h.length-1;_>=0;_--){var v=h[_];d.has(v.user)||d.set(v.user,new Map);var g=d.get(v.user);g.has(v.clock)||g.set(v.clock,[]);(g=g.get(v.clock)).push(f)}}}}function i(t){for(var e=new Map,n=t.readUint32(),r=0;r<n;r++){var i=t.readVarUint(),o=t.readVarUint();e.set(i,o)}return e}function o(t,e){var n=e.pos,r=0;e.writeUint32(0);var i=!0,o=!1,s=void 0;try{for(var a,l=t.ss.state[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){var u=lt(a.value,2),h=u[0],c=u[1];e.writeVarUint(h),e.writeVarUint(c),r++}}catch(t){o=!0,s=t}finally{try{!i&&l.return&&l.return()}finally{if(o)throw s}}e.setUint32(n,r)}function s(t,e){var n=null,r=void 0,i=void 0,o=0,s=e.pos;e.writeUint32(0),t.ds.iterate(null,null,function(t){var s=t._id.user,a=t._id.clock,l=t.len,u=t.gc;n!==s&&(o++,null!==n&&e.setUint32(i,r),n=s,e.writeVarUint(s),i=e.pos,e.writeUint32(0),r=0),e.writeVarUint(a),e.writeVarUint(l),e.writeUint8(u?1:0),r++}),null!==n&&e.setUint32(i,r),e.setUint32(s,o)}function a(t,e){for(var n=e.readUint32(),r=0;r<n;r++)!function(n){for(var r=e.readVarUint(),i=[],o=e.readUint32(),s=0;s<o;s++){var a=e.readVarUint(),l=e.readVarUint(),u=1===e.readUint8();i.push([a,l,u])}if(o>0){var h=0,c=i[h],f=[];t.ds.iterate(new ct(r,0),new ct(r,Number.MAX_VALUE),function(t){for(;null!=c;){var e=0;if(t._id.clock+t.len<=c[0])break;c[0]<t._id.clock?(e=Math.min(t._id.clock-c[0],c[1]),f.push([r,c[0],e])):(e=t._id.clock+t.len-c[0],c[2]&&!t.gc&&f.push([r,c[0],Math.min(e,c[1])])),c[1]<=e?c=i[++h]:(c[0]=c[0]+e,c[1]=c[1]-e)}});for(var d=f.length-1;d>=0;d--){var _=f[d];p(t,_[0],_[1],_[2])}for(;h<i.length;h++)c=i[h],p(t,r,c[0],c[1])}}()}function l(t,e,n){var r=e.readVarString(),i=e.readVarUint();n.push(' - auth: "'+r+'"'),n.push(" - protocolVersion: "+i);for(var o=[],s=e.readUint32(),a=0;a<s;a++){var l=e.readVarUint(),u=e.readVarUint();o.push("("+l+":"+u+")")}n.push(" == SS: "+o.join(","))}function u(t,e){var n=new pt;n.writeVarString(t.y.room),n.writeVarString("sync step 1"),n.writeVarString(t.authInfo||""),n.writeVarUint(t.protocolVersion),o(t.y,n),t.send(e,n.createBuffer())}function h(t,e,n,r){var i=t.pos;t.writeUint32(0);var o=0,s=!0,a=!1,l=void 0;try{for(var u,h=n.ss.state.keys()[Symbol.iterator]();!(s=(u=h.next()).done);s=!0){var c=u.value,f=r.get(c)||0;c!==Nt&&n.os.iterate(new ct(c,f),new ct(c,Number.MAX_VALUE),function(e){e._toBinary(t),o++})}}catch(t){a=!0,l=t}finally{try{!s&&h.return&&h.return()}finally{if(a)throw l}}t.setUint32(i,o)}function c(t,e,n,r,o){var a=t.readVarUint();a!==n.connector.protocolVersion&&(console.warn("You tried to sync with a Yjs instance that has a different protocol version\n (You: "+a+", Client: "+a+").\n "),n.destroy()),e.writeVarString("sync step 2"),e.writeVarString(n.connector.authInfo||""),h(e,t,n,i(t)),s(n,e),n.connector.send(r.uid,e.createBuffer()),r.receivedSyncStep2=!0,"slave"===n.connector.role&&u(n.connector,o)}function f(t,e,r){r.push(" - auth: "+e.readVarString()),r.push(" == OS:"),n(t,e,r),r.push(" == DS:");for(var i=e.readUint32(),o=0;o<i;o++){var s=e.readVarUint();r.push(" User: "+s+": ");for(var a=e.readUint32(),l=0;l<a;l++){var u=e.readVarUint(),h=e.readVarUint(),c=1===e.readUint8();r.push("["+u+", "+h+", "+c+"]")}}}function d(t,e,n,i,o){r(t,e,n),a(n,t),n.connector._setSyncedWith(o)}function _(t){var e=lt(t,2),r=e[0],i=e[1],o=new vt(i);o.readVarString();var s=o.readVarString(),a=[];return a.push("\n === "+s+" ==="),"update"===s?n(r,o,a):"sync step 1"===s?l(r,o,a):"sync step 2"===s?f(r,o,a):a.push("-- Unknown message type - probably an encoding issue!!!"),a.join("\n")}function v(t){var e=new vt(t);return e.readVarString(),e.readVarString()}function g(t){if(null!==t&&null!=t._id&&(t=t._id),null===t)return"()";if(t instanceof ct)return"("+t.user+","+t.clock+")";if(t instanceof Tt)return"("+t.name+","+t.type+")";if(t.constructor===Y)return"y";throw new Error("This is not a valid ID!")}function p(t,e,n,r){var i=t.connector._forwardAppliedStructs,o=t.os.getItemCleanStart(new ct(e,n));if(null!==o){o._deleted||(o._splitAt(t,r),o._delete(t,i));var s=o._length;if(r-=s,n+=s,r>0)for(var a=t.os.findNode(new ct(e,n));null!==a&&r>0&&a.val._id.equals(new ct(e,n));){var l=a.val;l._deleted||(l._splitAt(t,r),l._delete(t,i));var u=l._length;r-=u,n+=u,a=a.next()}}}function y(t,e,n){if(e!==t&&!e._deleted&&!t._transaction.newTypes.has(e)){var r=t._transaction.changedTypes,i=r.get(e);void 0===i&&(i=new Set,r.set(e,i)),i.add(n)}}function m(t,e,n,r){var i=e._id;n._id=new ct(i.user,i.clock+r),n._origin=e,n._left=e,n._right=e._right,null!==n._right&&(n._right._left=n),n._right_origin=e._right_origin,e._right=n,n._parent=e._parent,n._parentSub=e._parentSub,n._deleted=e._deleted;var o=new Set;o.add(e);for(var s=n._right;null!==s&&o.has(s._origin);)s._origin===e&&(s._origin=n),o.add(s),s=s._right;t.os.put(n)}function b(t,e){var n=void 0;do{n=e._right,e._right=null,e._right_origin=null,e._origin=e._left,e._integrate(t),e=n}while(null!==n)}function k(t,e){return e}function w(t){for(;null!==t&&t._deleted;)t=t._right;return t}function S(t,e,n){var r=t.insertDomElementsAfter(e,[n]);return r.length>0?r[0]:e}function E(t){var e=t._yxml;if(e.constructor!==YXmlHook){var n=e._y,r=new Set(Array.prototype.map.call(t.childNodes,function(t){return t._yxml}).filter(function(t){return void 0!==t}));e.forEach(function(t,e){r.has(t)||t._delete(n)});for(var i=t.childNodes,o=i.length,s=null,a=w(e._start),l=0;l<o;l++){var u=i[l],h=u._yxml;if(null!=h){if(!1===h)continue;null!==a?a!==h?(h._parent!==this?u._yxml=null:h._delete(n),s=S(e,s,u)):(s=a,a=w(a._right)):s=S(e,s,u)}else s=S(e,s,u)}}}function O(t,e){this._mutualExclude(function(){t.forEach(function(t){var n=t.target,r=n._dom;if(null!=r)if(n.constructor===YXmlText)n._dom.nodeValue=n.toString();else if(t.attributesChanged.forEach(function(t){var e=n.getAttribute(t);void 0===e?r.removeAttribute(t):r.setAttribute(t,e)}),t.childListChanged&&n.constructor!==YXmlHook){var i=e.createDocumentFragment();n.forEach(function(t){i.appendChild(t.getDom(e))});for(var o=r.lastChild;null!==o;)r.removeChild(o),o=r.lastChild;r.appendChild(i)}})})}function A(t,e){if(0===e)return["startof",t._id.user,t._id.clock||null,t._id.name||null,t._id.type||null];for(var n=t._start;null!==n;){if(!1===n._deleted){if(n._length>=e)return[n._id.user,n._id.clock+e-1];if(null===n._right)return[n._id.user,n._id.clock+n._length-1];e-=n._length}n=n._right}return null}function U(t,e){if("startof"===e[0]){var n=void 0;return n=null===e[3]?new ct(e[1],e[2]):new Tt(e[3],e[4]),{type:t.os.get(n),offset:0}}var r=0,i=t.os.findNodeWithUpperBound(new ct(e[0],e[1])).val,o=i._parent;if(o._deleted)return null;for(i._deleted||(r=e[1]-i._id.clock+1),i=i._left;null!==i;)i._deleted||(r+=i._length),i=i._left;return{type:o,offset:r}}function B(t,e,n){if(null!==kt&&n){var r=kt.to,i=kt.from,o=kt.fromY,s=kt.toY,a=!1,l=bt.anchorNode,u=bt.anchorOffset,h=bt.focusNode,c=bt.focusOffset;if(null!==i){var f=U(o,i);if(null!==f){var d=f.type.getDom(),_=f.offset;d===l&&_===u||(l=d,u=_,a=!0)}}if(null!==r){var v=U(s,r);if(null!==v){var g=v.type.getDom(),p=v.offset;g===h&&p===c||(h=g,c=p,a=!0)}}a&&(console.info("updating selection!!"),bt.setBaseAndExtent(l,u,h,c)),kt=null,bt=null}}function x(t,e,n){if(t==e)return t?[[Ot,t]]:[];(n<0||t.length<n)&&(n=null);var r=T(t,e),i=t.substring(0,r);t=t.substring(r),e=e.substring(r),r=L(t,e);var o=t.substring(t.length-r);t=t.substring(0,t.length-r),e=e.substring(0,e.length-r);var s=D(t,e);return i&&s.unshift([Ot,i]),o&&s.push([Ot,o]),C(s),null!=n&&(s=j(s,n)),s=M(s)}function D(t,e){var n;if(!t)return[[Et,e]];if(!e)return[[St,t]];var r=t.length>e.length?t:e,i=t.length>e.length?e:t,o=r.indexOf(i);if(-1!=o)return n=[[Et,r.substring(0,o)],[Ot,i],[Et,r.substring(o+i.length)]],t.length>e.length&&(n[0][0]=n[2][0]=St),n;if(1==i.length)return[[St,t],[Et,e]];var s=V(t,e);if(s){var a=s[0],l=s[1],u=s[2],h=s[3],c=s[4],f=x(a,u),d=x(l,h);return f.concat([[Ot,c]],d)}return I(t,e)}function I(t,e){for(var n=t.length,r=e.length,i=Math.ceil((n+r)/2),o=i,s=2*i,a=new Array(s),l=new Array(s),u=0;u<s;u++)a[u]=-1,l[u]=-1;a[o+1]=0,l[o+1]=0;for(var h=n-r,c=h%2!=0,f=0,d=0,_=0,v=0,g=0;g<i;g++){for(var p=-g+f;p<=g-d;p+=2){var y,m=o+p;y=p==-g||p!=g&&a[m-1]<a[m+1]?a[m+1]:a[m-1]+1;for(var b=y-p;y<n&&b<r&&t.charAt(y)==e.charAt(b);)y++,b++;if(a[m]=y,y>n)d+=2;else if(b>r)f+=2;else if(c){var k=o+h-p;if(k>=0&&k<s&&-1!=l[k]){var w=n-l[k];if(y>=w)return N(t,e,y,b)}}}for(var S=-g+_;S<=g-v;S+=2){var w,k=o+S;w=S==-g||S!=g&&l[k-1]<l[k+1]?l[k+1]:l[k-1]+1;for(var E=w-S;w<n&&E<r&&t.charAt(n-w-1)==e.charAt(r-E-1);)w++,E++;if(l[k]=w,w>n)v+=2;else if(E>r)_+=2;else if(!c){var m=o+h-S;if(m>=0&&m<s&&-1!=a[m]){var y=a[m],b=o+y-m;if(w=n-w,y>=w)return N(t,e,y,b)}}}}return[[St,t],[Et,e]]}function N(t,e,n,r){var i=t.substring(0,n),o=e.substring(0,r),s=t.substring(n),a=e.substring(r),l=x(i,o),u=x(s,a);return l.concat(u)}function T(t,e){if(!t||!e||t.charAt(0)!=e.charAt(0))return 0;for(var n=0,r=Math.min(t.length,e.length),i=r,o=0;n<i;)t.substring(o,i)==e.substring(o,i)?(n=i,o=n):r=i,i=Math.floor((r-n)/2+n);return i}function L(t,e){if(!t||!e||t.charAt(t.length-1)!=e.charAt(e.length-1))return 0;for(var n=0,r=Math.min(t.length,e.length),i=r,o=0;n<i;)t.substring(t.length-i,t.length-o)==e.substring(e.length-i,e.length-o)?(n=i,o=n):r=i,i=Math.floor((r-n)/2+n);return i}function V(t,e){function n(t,e,n){for(var r,i,o,s,a=t.substring(n,n+Math.floor(t.length/4)),l=-1,u="";-1!=(l=e.indexOf(a,l+1));){var h=T(t.substring(n),e.substring(l)),c=L(t.substring(0,n),e.substring(0,l));u.length<c+h&&(u=e.substring(l-c,l)+e.substring(l,l+h),r=t.substring(0,n-c),i=t.substring(n+h),o=e.substring(0,l-c),s=e.substring(l+h))}return 2*u.length>=t.length?[r,i,o,s,u]:null}var r=t.length>e.length?t:e,i=t.length>e.length?e:t;if(r.length<4||2*i.length<r.length)return null;var o,s=n(r,i,Math.ceil(r.length/4)),a=n(r,i,Math.ceil(r.length/2));if(!s&&!a)return null;o=a?s&&s[4].length>a[4].length?s:a:s;var l,u,h,c;return t.length>e.length?(l=o[0],u=o[1],h=o[2],c=o[3]):(h=o[0],c=o[1],l=o[2],u=o[3]),[l,u,h,c,o[4]]}function C(t){t.push([Ot,""]);for(var e,n=0,r=0,i=0,o="",s="";n<t.length;)switch(t[n][0]){case Et:i++,s+=t[n][1],n++;break;case St:r++,o+=t[n][1],n++;break;case Ot:r+i>1?(0!==r&&0!==i&&(e=T(s,o),0!==e&&(n-r-i>0&&t[n-r-i-1][0]==Ot?t[n-r-i-1][1]+=s.substring(0,e):(t.splice(0,0,[Ot,s.substring(0,e)]),n++),s=s.substring(e),o=o.substring(e)),0!==(e=L(s,o))&&(t[n][1]=s.substring(s.length-e)+t[n][1],s=s.substring(0,s.length-e),o=o.substring(0,o.length-e))),0===r?t.splice(n-i,r+i,[Et,s]):0===i?t.splice(n-r,r+i,[St,o]):t.splice(n-r-i,r+i,[St,o],[Et,s]),n=n-r-i+(r?1:0)+(i?1:0)+1):0!==n&&t[n-1][0]==Ot?(t[n-1][1]+=t[n][1],t.splice(n,1)):n++,i=0,r=0,o="",s=""}""===t[t.length-1][1]&&t.pop();var a=!1;for(n=1;n<t.length-1;)t[n-1][0]==Ot&&t[n+1][0]==Ot&&(t[n][1].substring(t[n][1].length-t[n-1][1].length)==t[n-1][1]?(t[n][1]=t[n-1][1]+t[n][1].substring(0,t[n][1].length-t[n-1][1].length),t[n+1][1]=t[n-1][1]+t[n+1][1],t.splice(n-1,1),a=!0):t[n][1].substring(0,t[n+1][1].length)==t[n+1][1]&&(t[n-1][1]+=t[n+1][1],t[n][1]=t[n][1].substring(t[n+1][1].length)+t[n+1][1],t.splice(n+1,1),a=!0)),n++;a&&C(t)}function P(t,e){if(0===e)return[Ot,t];for(var n=0,r=0;r<t.length;r++){var i=t[r];if(i[0]===St||i[0]===Ot){var o=n+i[1].length;if(e===o)return[r+1,t];if(e<o){t=t.slice();var s=e-n,a=[i[0],i[1].slice(0,s)],l=[i[0],i[1].slice(s)];return t.splice(r,1,a,l),[r+1,t]}n=o}}throw new Error("cursor_pos is out of bounds!")}function j(t,e){var n=P(t,e),r=n[1],i=n[0],o=r[i],s=r[i+1];if(null==o)return t;if(o[0]!==Ot)return t;if(null!=s&&o[1]+s[1]===s[1]+o[1])return r.splice(i,2,s,o),F(r,i,2);if(null!=s&&0===s[1].indexOf(o[1])){r.splice(i,2,[s[0],o[1]],[0,o[1]]);var a=s[1].slice(o[1].length);return a.length>0&&r.splice(i+2,0,[s[0],a]),F(r,i,3)}return t}function M(t){for(var e=!1,n=function(t){return t.charCodeAt(0)>=56320&&t.charCodeAt(0)<=57343},r=2;r<t.length;r+=1)t[r-2][0]===Ot&&function(t){return t.charCodeAt(t.length-1)>=55296&&t.charCodeAt(t.length-1)<=56319}(t[r-2][1])&&t[r-1][0]===St&&n(t[r-1][1])&&t[r][0]===Et&&n(t[r][1])&&(e=!0,t[r-1][1]=t[r-2][1].slice(-1)+t[r-1][1],t[r][1]=t[r-2][1].slice(-1)+t[r][1],t[r-2][1]=t[r-2][1].slice(0,-1));if(!e)return t;for(var i=[],r=0;r<t.length;r+=1)t[r][1].length>0&&i.push(t[r]);return i}function F(t,e,n){for(var r=e+n-1;r>=0&&r>=e-1;r--)if(r+1<t.length){var i=t[r],o=t[r+1];i[0]===o[1]&&t.splice(r,2,[i[0],i[1]+o[1]])}return t}function R(t,e,n){var r=[];return e.forEach(function(e){if(null!=e._yxml&&!1!==e._yxml&&e._yxml._unbindFromDom(),null!==t._domFilter(e.nodeName,new Map)){var i=void 0,o=e._yjsHook||(null!=e.dataset?e.dataset.yjsHook:void 0);if(void 0!==o)i=new YXmlHook(o,e);else if(e.nodeType===e.TEXT_NODE)i=new YXmlText(e);else{if(e.nodeType!==e.ELEMENT_NODE)throw new Error("Unsupported node!");i=new YXmlFragment._YXmlElement(e,t._domFilter,n)}r.push(i)}else e._yxml=!1}),r}function H(t,e){xt[t]=e}function J(t){var e=xt[t];if(void 0===e)throw new Error('The hook "'+t+'" is not specified! You must not access this hook!');return e}function W(t,e){Dt.set(t,e),It.set(e,t)}function z(t){return Dt.get(t)}function X(t){return It.get(t)}function q(){if("undefined"!=typeof crypto&&null!=crypto.getRandomValue){var t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}if("undefined"!=typeof crypto&&null!=crypto.randomBytes){var e=crypto.randomBytes(4);return new Uint32Array(e.buffer)[0]}return Math.ceil(4294967295*Math.random())}function $(t,e,n){for(;e!==t;){if(e===n)return!0;e=e._parent}return!1}function Q(t,e,n){var r=!1;return t.transact(function(){for(;!r&&n.length>0;){var i=n.pop();t.os.getItemCleanStart(i.fromState),t.os.getItemCleanEnd(i.toState),t.os.iterate(i.fromState,i.toState,function(n){!n._deleted&&$(t,n,e)&&(r=!0,n._delete(t))});var o=!0,s=!1,a=void 0;try{for(var l,u=i.deletedStructs[Symbol.iterator]();!(o=(l=u.next()).done);o=!0){var h=l.value;$(t,h,e)&&h._parent!==t&&!h._parent._deleted&&(h._parent._id.user!==t.userID||h._parent._id.clock<i.fromState.clock||h._parent._id.clock>i.fromState.clock)&&(r=!0,h=h._copy(i.deletedStructs),h._integrate(t))}}catch(t){s=!0,a=t}finally{try{!o&&u.return&&u.return()}finally{if(s)throw a}}}}),r}function Z(t){if(t=String(t),!(t.length>100)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(e){var n=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*Ht;case"days":case"day":case"d":return n*Yt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Rt;case"minutes":case"minute":case"mins":case"min":case"m":return n*Ft;case"seconds":case"second":case"secs":case"sec":case"s":return n*Mt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function G(t){return t>=Yt?Math.round(t/Yt)+"d":t>=Rt?Math.round(t/Rt)+"h":t>=Ft?Math.round(t/Ft)+"m":t>=Mt?Math.round(t/Mt)+"s":t+"ms"}function K(t){return tt(t,Yt,"day")||tt(t,Rt,"hour")||tt(t,Ft,"minute")||tt(t,Mt,"second")||t+" ms"}function tt(t,e,n){if(!(t<e))return t<1.5*e?Math.floor(t/e)+" "+n:Math.ceil(t/e)+" "+n+"s"}function et(Y){var t=function(){function t(e,n){rt(this,t),this.y=e,this.opts=n,this.saveOperationsBuffer=[],this.log=Y.debug("y:persistence")}return it(t,[{key:"saveToMessageQueue",value:function(t){this.log("Room %s: Save message to message queue",this.y.options.connector.room)}},{key:"saveOperations",value:function(t){t=t.map(function(t){return Y.Struct[t.struct].encode(t)}),0===this.saveOperationsBuffer.length?this.saveOperationsBuffer=t:this.saveOperationsBuffer=this.saveOperationsBuffer.concat(t)}}]),t}();Y.AbstractPersistence=t}var nt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rt=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},it=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),ot=function t(e,n,r){null===e&&(e=Function.prototype);var i=Object.getOwnPropertyDescriptor(e,n);if(void 0===i){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,n,r)}if("value"in i)return i.value;var s=i.get;if(void 0!==s)return s.call(r)},st=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},at=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},lt=function(){function t(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),ut=function(){function t(e){rt(this,t),this.val=e,this.color=!0,this._left=null,this._right=null,this._parent=null}return it(t,[{key:"isRed",value:function(){return this.color}},{key:"isBlack",value:function(){return!this.color}},{key:"redden",value:function(){return this.color=!0,this}},{key:"blacken",value:function(){return this.color=!1,this}},{key:"rotateLeft",value:function(t){var e=this.parent,n=this.right,r=this.right.left;if(n.left=this,this.right=r,null===e)t.root=n,n._parent=null;else if(e.left===this)e.left=n;else{if(e.right!==this)throw new Error("The elements are wrongly connected!");e.right=n}}},{key:"next",value:function(){if(null!==this.right){for(var t=this.right;null!==t.left;)t=t.left;return t}for(var e=this;null!==e.parent&&e!==e.parent.left;)e=e.parent;return e.parent}},{key:"prev",value:function(){if(null!==this.left){for(var t=this.left;null!==t.right;)t=t.right;return t}for(var e=this;null!==e.parent&&e!==e.parent.right;)e=e.parent;return e.parent}},{key:"rotateRight",value:function(t){var e=this.parent,n=this.left,r=this.left.right;if(n.right=this,this.left=r,null===e)t.root=n,n._parent=null;else if(e.left===this)e.left=n;else{if(e.right!==this)throw new Error("The elements are wrongly connected!");e.right=n}}},{key:"getUncle",value:function(){return this.parent===this.parent.parent.left?this.parent.parent.right:this.parent.parent.left}},{key:"grandparent",get:function(){return this.parent.parent}},{key:"parent",get:function(){return this._parent}},{key:"sibling",get:function(){return this===this.parent.left?this.parent.right:this.parent.left}},{key:"left",get:function(){return this._left},set:function(t){null!==t&&(t._parent=this),this._left=t}},{key:"right",get:function(){return this._right},set:function(t){null!==t&&(t._parent=this),this._right=t}}]),t}(),ht=function(){function t(){rt(this,t),this.root=null,this.length=0}return it(t,[{key:"findNext",value:function(t){var e=t.clone();return e.clock+=1,this.findWithLowerBound(e)}},{key:"findPrev",value:function(t){var e=t.clone();return e.clock-=1,this.findWithUpperBound(e)}},{key:"findNodeWithLowerBound",value:function(t){var e=this.root;if(null===e)return null;for(;;)if(null===t||t.lessThan(e.val._id)&&null!==e.left)e=e.left;else{if(null===t||!e.val._id.lessThan(t))return e;if(null===e.right)return e.next();e=e.right}}},{key:"findNodeWithUpperBound",value:function(t){if(void 0===t)throw new Error("You must define from!");var e=this.root;if(null===e)return null;for(;;)if(null!==t&&!e.val._id.lessThan(t)||null===e.right){if(null===t||!t.lessThan(e.val._id))return e;if(null===e.left)return e.prev();e=e.left}else e=e.right}},{key:"findSmallestNode",value:function(){for(var t=this.root;null!=t&&null!=t.left;)t=t.left;return t}},{key:"findWithLowerBound",value:function(t){var e=this.findNodeWithLowerBound(t);return null==e?null:e.val}},{key:"findWithUpperBound",value:function(t){var e=this.findNodeWithUpperBound(t);return null==e?null:e.val}},{key:"iterate",value:function(t,e,n){var r;for(r=null===t?this.findSmallestNode():this.findNodeWithLowerBound(t);null!==r&&(null===e||r.val._id.lessThan(e)||r.val._id.equals(e));)n(r.val),r=r.next()}},{key:"find",value:function(t){var e=this.findNode(t);return null!==e?e.val:null}},{key:"findNode",value:function(t){var e=this.root;if(null===e)return null;for(;;){if(null===e)return null;if(t.lessThan(e.val._id))e=e.left;else{if(!e.val._id.lessThan(t))return e;e=e.right}}}},{key:"delete",value:function(t){var e=this.findNode(t);if(null!=e){if(this.length--,null!==e.left&&null!==e.right){for(var n=e.left;null!==n.right;)n=n.right;e.val=n.val,e=n}var r,i=e.left||e.right;if(null===i?(r=!0,i=new ut(null),i.blacken(),e.right=i):r=!1,null===e.parent)return void(r?this.root=null:(this.root=i,i.blacken(),i._parent=null));if(e.parent.left===e)e.parent.left=i;else{if(e.parent.right!==e)throw new Error("Impossible!");e.parent.right=i}if(e.isBlack()&&(i.isRed()?i.blacken():this._fixDelete(i)),this.root.blacken(),r)if(i.parent.left===i)i.parent.left=null;else{if(i.parent.right!==i)throw new Error("Impossible #3");i.parent.right=null}}}},{key:"_fixDelete",value:function(t){function e(t){return null===t||t.isBlack()}function n(t){return null!==t&&t.isRed()}if(null!==t.parent){var r=t.sibling;if(n(r)){if(t.parent.redden(),r.blacken(),t===t.parent.left)t.parent.rotateLeft(this);else{if(t!==t.parent.right)throw new Error("Impossible #2");t.parent.rotateRight(this)}r=t.sibling}t.parent.isBlack()&&r.isBlack()&&e(r.left)&&e(r.right)?(r.redden(),this._fixDelete(t.parent)):t.parent.isRed()&&r.isBlack()&&e(r.left)&&e(r.right)?(r.redden(),t.parent.blacken()):(t===t.parent.left&&r.isBlack()&&n(r.left)&&e(r.right)?(r.redden(),r.left.blacken(),r.rotateRight(this),r=t.sibling):t===t.parent.right&&r.isBlack()&&n(r.right)&&e(r.left)&&(r.redden(),r.right.blacken(),r.rotateLeft(this),r=t.sibling),r.color=t.parent.color,t.parent.blacken(),t===t.parent.left?(r.right.blacken(),t.parent.rotateLeft(this)):(r.left.blacken(),t.parent.rotateRight(this)))}}},{key:"put",value:function(t){var e=new ut(t);if(null!==this.root){for(var n=this.root;;)if(e.val._id.lessThan(n.val._id)){if(null===n.left){n.left=e;break}n=n.left}else{if(!n.val._id.lessThan(e.val._id))return n.val=e.val,n;if(null===n.right){n.right=e;break}n=n.right}this._fixInsert(e)}else this.root=e;return this.length++,this.root.blacken(),e}},{key:"_fixInsert",value:function(t){if(null===t.parent)return void t.blacken();if(!t.parent.isBlack()){var e=t.getUncle();null!==e&&e.isRed()?(t.parent.blacken(),e.blacken(),t.grandparent.redden(),this._fixInsert(t.grandparent)):(t===t.parent.right&&t.parent===t.grandparent.left?(t.parent.rotateLeft(this),t=t.left):t===t.parent.left&&t.parent===t.grandparent.right&&(t.parent.rotateRight(this),t=t.right),t.parent.blacken(),t.grandparent.redden(),t===t.parent.left?t.grandparent.rotateRight(this):t.grandparent.rotateLeft(this))}}},{key:"flush",value:function(){}}]),t}(),ct=function(){function t(e,n){rt(this,t),this.user=e,this.clock=n}return it(t,[{key:"clone",value:function(){return new t(this.user,this.clock)}},{key:"equals",value:function(t){return null!==t&&t.user===this.user&&t.clock===this.clock}},{key:"lessThan",value:function(t){return this.user<t.user||this.user===t.user&&this.clock<t.clock}}]),t}(),ft=function(){function t(e,n,r){rt(this,t),this._id=e,this.len=n,this.gc=r}return it(t,[{key:"clone",value:function(){return new t(this._id,this.len,this.gc)}}]),t}(),dt=function(t){function e(){return rt(this,e),at(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return st(e,t),it(e,[{key:"logTable",value:function(){var t=[];this.iterate(null,null,function(e){t.push({user:e._id.user,clock:e._id.clock,len:e.len,gc:e.gc})}),console.table(t)}},{key:"isDeleted",value:function(t){var e=this.findWithUpperBound(t);return null!==e&&e._id.user===t.user&&t.clock<e._id.clock+e.len}},{key:"markDeleted",value:function(t,e){if(null==e)throw new Error("length must be defined");var n=this.findWithUpperBound(t);if(null!=n&&n._id.user===t.user)if(n._id.clock<=t.clock&&t.clock<=n._id.clock+n.len){var r=t.clock+e-(n._id.clock+n.len);if(!(r>0))return n;if(n.gc){if(!((r=n._id.clock+n.len-t.clock)<e))throw new Error("DS reached an inconsistent state. Please report this issue!");var i=t.clone();i.clock+=r,n=new ft(i,e-r,!1),this.put(n)}else n.len+=r}else n=new ft(t,e,!1),this.put(n);else n=new ft(t,e,!1),this.put(n);var o=this.findNext(n._id);if(null!=o&&n._id.user===o._id.user&&n._id.clock+n.len>=o._id.clock)for(r=n._id.clock+n.len-o._id.clock;r>=0;){if(o.gc){n.len-=r,r>=o.len&&(r-=o.len)>0&&(this.put(n),this.markDeleted(new ct(o._id.user,o._id.clock+o.len),r));break}if(!(r>o.len)){n.len+=o.len-r,this.delete(o._id);break}var s=this.findNext(o._id);if(this.delete(o._id),null==s||n._id.user!==s._id.user)break;o=s,r=n._id.clock+n.len-o._id.clock}return this.put(n),n}}]),e}(ht);String.fromCodePoint||function(){var t=function(){try{var t={},e=Object.defineProperty,n=e(t,t,t)&&e}catch(t){}return n}(),e=String.fromCharCode,n=Math.floor,r=function(t){var r,i,o=[],s=-1,a=arguments.length;if(!a)return"";for(var l="";++s<a;){var u=Number(arguments[s]);if(!isFinite(u)||u<0||u>1114111||n(u)!=u)throw RangeError("Invalid code point: "+u);u<=65535?o.push(u):(u-=65536,r=55296+(u>>10),i=u%1024+56320,o.push(r,i)),(s+1==a||o.length>16384)&&(l+=e.apply(null,o),o.length=0)}return l};t?t(String,"fromCodePoint",{value:r,configurable:!0,writable:!0}):String.fromCodePoint=r}(),String.prototype.codePointAt||function(){var t=function(){try{var t={},e=Object.defineProperty,n=e(t,t,t)&&e}catch(t){}return n}(),e=function(t){if(null==this)throw TypeError();var e=String(this),n=e.length,r=t?Number(t):0;if(r!=r&&(r=0),!(r<0||r>=n)){var i,o=e.charCodeAt(r);return o>=55296&&o<=56319&&n>r+1&&(i=e.charCodeAt(r+1))>=56320&&i<=57343?1024*(o-55296)+i-56320+65536:o}};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}();var _t=t(function(t){t.require;var e={isNotUTF8:function(t,n,r){try{e.getStringFromBytes(t,n,r,!0)}catch(t){return!0}return!1},getCharLength:function(t){return 240==(240&t)?4:224==(224&t)?3:192==(192&t)?2:t==(127&t)?1:0},getCharCode:function(t,n,r){var i=0,o="";if(n=n||0,0==(r=r||e.getCharLength(t[n])))throw new Error(t[n].toString(2)+" is not a significative byte (offset:"+n+").");if(1===r)return t[n];if(o="00000000".slice(0,r)+1+"00000000".slice(r+1),t[n]&parseInt(o,2))throw Error("Index "+n+": A "+r+" bytes encoded char cannot encode the "+(r+1)+"th rank bit to 1.");for(o="0000".slice(0,r+1)+"11111111".slice(r+1),i+=(t[n]&parseInt(o,2))<<6*--r;r;){if(128!=(128&t[n+1])||64==(64&t[n+1]))throw Error("Index "+(n+1)+': Next bytes of encoded char must begin with a "10" bit sequence.');i+=(63&t[++n])<<6*--r}return i},getStringFromBytes:function(t,n,r,i){var o,s=[];for(n|=0,r="number"==typeof r?r:t.byteLength||t.length;n<r;n++){if(o=e.getCharLength(t[n]),n+o>r){if(i)throw Error("Index "+n+": Found a "+o+" bytes encoded char declaration but only "+(r-n)+" bytes are available.")}else s.push(String.fromCodePoint(e.getCharCode(t,n,o,i)));n+=o-1}return s.join("")},getBytesForCharCode:function(t){if(t<128)return 1;if(t<2048)return 2;if(t<65536)return 3;if(t<2097152)return 4;throw new Error("CharCode "+t+" cannot be encoded with UTF8.")},setBytesFromCharCode:function(t,n,r,i){if(t|=0,n=n||[],r|=0,1==(i=i||e.getBytesForCharCode(t)))n[r]=t;else for(n[r++]=(parseInt("1111".slice(0,i),2)<<8-i)+(t>>>6*--i);i>0;)n[r++]=t>>>6*--i&63|128;return n},setBytesFromString:function(t,n,r,i,o){t=t||"",n=n||[],r|=0,i="number"==typeof i?i:n.byteLength||1/0;for(var s=0,a=t.length;s<a;s++){var l=e.getBytesForCharCode(t[s].codePointAt(0));if(o&&r+l>i)throw new Error('Not enought bytes to encode the char "'+t[s]+'" at the offset "'+r+'".');e.setBytesFromCharCode(t[s].codePointAt(0),n,r,l,o),r+=l}return n}};t.exports=e}),vt=function(){function t(e){if(rt(this,t),e instanceof ArrayBuffer)this.uint8arr=new Uint8Array(e);else{if(!(e instanceof Uint8Array||"undefined"!=typeof Buffer&&e instanceof Buffer))throw new Error("Expected an ArrayBuffer or Uint8Array!");this.uint8arr=e}this.pos=0}return it(t,[{key:"clone",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.pos,n=new t(this.uint8arr);return n.pos=e,n}},{key:"skip8",value:function(){this.pos++}},{key:"readUint8",value:function(){return this.uint8arr[this.pos++]}},{key:"readUint32",value:function(){var t=this.uint8arr[this.pos]+(this.uint8arr[this.pos+1]<<8)+(this.uint8arr[this.pos+2]<<16)+(this.uint8arr[this.pos+3]<<24);return this.pos+=4,t}},{key:"peekUint8",value:function(){return this.uint8arr[this.pos]}},{key:"readVarUint",value:function(){for(var t=0,e=0;;){var n=this.uint8arr[this.pos++];if(t|=(127&n)<<e,e+=7,n<128)return t>>>0;if(e>35)throw new Error("Integer out of range!")}}},{key:"readVarString",value:function(){for(var t=this.readVarUint(),e=new Array(t),n=0;n<t;n++)e[n]=this.uint8arr[this.pos++];return _t.getStringFromBytes(e)}},{key:"peekVarString",value:function(){var t=this.pos,e=this.readVarString();return this.pos=t,e}},{key:"readID",value:function(){var t=this.readVarUint();if(t===Nt){var e=new Tt(this.readVarString(),null);return e.type=this.readVarUint(),e}return new ct(t,this.readVarUint())}},{key:"length",get:function(){return this.uint8arr.length}}]),t}(),gt=function t(e,n,r){rt(this,t),this.decoder=e,this.missing=n.length,this.struct=r},pt=function(){function t(){rt(this,t),this.data=[]}return it(t,[{key:"createBuffer",value:function(){return Uint8Array.from(this.data).buffer}},{key:"writeUint8",value:function(t){this.data.push(255&t)}},{key:"setUint8",value:function(t,e){this.data[t]=255&e}},{key:"writeUint16",value:function(t){this.data.push(255&t,t>>>8&255)}},{key:"setUint16",value:function(t,e){this.data[t]=255&e,this.data[t+1]=e>>>8&255}},{key:"writeUint32",value:function(t){for(var e=0;e<4;e++)this.data.push(255&t),t>>>=8}},{key:"setUint32",value:function(t,e){for(var n=0;n<4;n++)this.data[t+n]=255&e,e>>>=8}},{key:"writeVarUint",value:function(t){for(;t>=128;)this.data.push(128|127&t),t>>>=7;this.data.push(127&t)}},{key:"writeVarString",value:function(t){var e=_t.setBytesFromString(t),n=e.length;this.writeVarUint(n);for(var r=0;r<n;r++)this.data.push(e[r])}},{key:"writeID",value:function(t){var e=t.user;this.writeVarUint(e),e!==Nt?this.writeVarUint(t.clock):(this.writeVarString(t.name),this.writeVarUint(t.type))}},{key:"length",get:function(){return this.data.length}},{key:"pos",get:function(){return this.data.length}}]),t}(),Delete=function(){
function Delete(){rt(this,Delete),this._target=null,this._length=null}return it(Delete,[{key:"_fromBinary",value:function(t,e){var n=e.readID();return this._targetID=n,this._length=e.readVarUint(),null===t.os.getItem(n)?[n]:[]}},{key:"_toBinary",value:function(t){t.writeUint8(X(this.constructor)),t.writeID(this._targetID),t.writeVarUint(this._length)}},{key:"_integrate",value:function(t){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])t.connector.broadcastStruct(this);else{var e=this._targetID;p(t,e.user,e.clock,this._length)}null!==t.persistence&&t.persistence.saveOperations(this)}},{key:"_logString",value:function(){return"Delete - target: "+g(this._targetID)+", len: "+this._length}}]),Delete}(),yt=function t(e){rt(this,t),this.y=e,this.newTypes=new Set,this.changedTypes=new Map,this.deletedStructs=new Set,this.beforeState=new Map,this.changedParentTypes=new Map},Item=function(){function Item(){rt(this,Item),this._id=null,this._origin=null,this._left=null,this._right=null,this._right_origin=null,this._parent=null,this._parentSub=null,this._deleted=!1}return it(Item,[{key:"_copy",value:function(){var t=new this.constructor;return t._origin=this._left,t._left=this._left,t._right=this,t._right_origin=this,t._parent=this._parent,t._parentSub=this._parentSub,t}},{key:"_splitAt",value:function(t,e){return 0===e?this:this._right}},{key:"_delete",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this._deleted=!0,t.ds.markDeleted(this._id,this._length),e){var n=new Delete;n._targetID=this._id,n._length=this._length,n._integrate(t,!0)}y(t,this._parent,this._parentSub),t._transaction.deletedStructs.add(this)}},{key:"_beforeChange",value:function(){}},{key:"_integrate",value:function(t){var e=this._parent,n=this._id,r=null===n?0:t.ss.getState(n.user);if(null===n)this._id=t.ss.getNextID(this._length);else if(n.user===Nt);else{if(n.clock<r)return[];if(n.clock!==r)throw new Error("Can not apply yet!");t.ss.setState(n.user,r+this._length)}e._deleted||t._transaction.changedTypes.has(e)||t._transaction.newTypes.has(e)||this._parent._beforeChange();var i=void 0;i=null!==this._left?this._left._right:null!==this._parentSub?this._parent._map.get(this._parentSub)||null:this._parent._start;for(var o=new Set,s=new Set;null!==i&&i!==this._right;){if(s.add(i),o.add(i),this._origin===i._origin)i._id.user<this._id.user&&(this._left=i,o.clear());else{if(!s.has(i._origin))break;o.has(i._origin)||(this._left=i,o.clear())}i=i._right}var a=this._parentSub;if(null===this._left){var l=void 0;if(null!==a){var u=e._map;l=u.get(a)||null,u.set(a,this)}else l=e._start,e._start=this;this._right=l,null!==l&&(l._left=this)}else{var h=this._left,c=h._right;this._right=c,h._right=this,null!==c&&(c._left=this)}e._deleted&&this._delete(t,!1),t.os.put(this),y(t,e,a),this._id.user!==Nt&&((t.connector._forwardAppliedStructs||this._id.user===t.userID)&&t.connector.broadcastStruct(this),null!==t.persistence&&t.persistence.saveOperations(this))}},{key:"_toBinary",value:function(t){t.writeUint8(X(this.constructor));var e=0;null!==this._origin&&(e+=1),null!==this._right_origin&&(e+=4),null!==this._parentSub&&(e+=8),t.writeUint8(e),t.writeID(this._id),1&e&&t.writeID(this._origin._lastId),4&e&&t.writeID(this._right_origin._id),0==(5&e)&&t.writeID(this._parent._id),8&e&&t.writeVarString(JSON.stringify(this._parentSub))}},{key:"_fromBinary",value:function(t,e){var n=[],r=e.readUint8(),i=e.readID();if(this._id=i,1&r){var o=e.readID(),s=t.os.getItemCleanEnd(o);null===s?n.push(o):(this._origin=s,this._left=this._origin)}if(4&r){var a=e.readID(),l=t.os.getItemCleanStart(a);null===l?n.push(a):(this._right=l,this._right_origin=l)}if(0==(5&r)){var u=e.readID();if(null===this._parent){var h=t.os.get(u);null===h?n.push(u):this._parent=h}}else null===this._parent&&(null!==this._origin?this._parent=this._origin._parent:null!==this._right_origin&&(this._parent=this._right_origin._parent));return 8&r&&(this._parentSub=JSON.parse(e.readVarString())),t.ss.getState(i.user)<i.clock&&n.push(new ct(i.user,i.clock-1)),n}},{key:"_lastId",get:function(){return new ct(this._id.user,this._id.clock+this._length-1)}},{key:"_length",get:function(){return 1}}]),Item}(),mt=function(){function t(){rt(this,t),this.eventListeners=[]}return it(t,[{key:"destroy",value:function(){this.eventListeners=null}},{key:"addEventListener",value:function(t){this.eventListeners.push(t)}},{key:"removeEventListener",value:function(t){this.eventListeners=this.eventListeners.filter(function(e){return t!==e})}},{key:"removeAllEventListeners",value:function(){this.eventListeners=[]}},{key:"callEventListeners",value:function(t,e){for(var n=0;n<this.eventListeners.length;n++)try{(0,this.eventListeners[n])(e)}catch(t){console.error(t)}}}]),t}(),Type=function(t){function Type(){rt(this,Type);var t=at(this,(Type.__proto__||Object.getPrototypeOf(Type)).call(this));return t._map=new Map,t._start=null,t._y=null,t._eventHandler=new mt,t._deepEventHandler=new mt,t}return st(Type,t),it(Type,[{key:"getPathTo",value:function(t){if(t===this)return[];for(var e=[],n=this._y;t._parent!==this&&this._parent!==n;){var r=t._parent;if(null!==t._parentSub)e.push(t._parentSub);else{var i=!0,o=!1,s=void 0;try{for(var a,l=r[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){var u=lt(a.value,2),h=u[0];if(u[1]===t){e.push(h);break}}}catch(t){o=!0,s=t}finally{try{!i&&l.return&&l.return()}finally{if(o)throw s}}}t=r}if(this._parent!==this)throw new Error("The type is not a child of this node");return e}},{key:"_callEventHandler",value:function(t,e){var n=t.changedParentTypes;this._eventHandler.callEventListeners(t,e);for(var r=this;r!==this._y;){var i=n.get(r);void 0===i&&(i=[],n.set(r,i)),i.push(e),r=r._parent}}},{key:"_copy",value:function(t){var e=ot(Type.prototype.__proto__||Object.getPrototypeOf(Type.prototype),"_copy",this).call(this),n=new Map;e._map=n;var r=!0,i=!1,o=void 0;try{for(var s,a=this._map[Symbol.iterator]();!(r=(s=a.next()).done);r=!0){var l=lt(s.value,2),u=l[0],h=l[1];if(t.has(h)||!h.deleted){h._copy(t)._parent=e,n.set(u,h._copy(t))}}}catch(t){i=!0,o=t}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}var c=null;e._start=null;for(var f=this._start;null!==f;){if(t.has(f)||!f.deleted){var d=f._copy(t);d._left=c,d._origin=c,d._right=null,d._right_origin=null,d._parent=e,null===c?e._start=d:c._right=d,c=d}f=f._right}return e}},{key:"_transact",value:function(t){var e=this._y;null!==e?e.transact(t):t(e)}},{key:"observe",value:function(t){this._eventHandler.addEventListener(t)}},{key:"observeDeep",value:function(t){this._deepEventHandler.addEventListener(t)}},{key:"unobserve",value:function(t){this._eventHandler.removeEventListener(t)}},{key:"unobserveDeep",value:function(t){this._deepEventHandler.removeEventListener(t)}},{key:"_integrate",value:function(t){t._transaction.newTypes.add(this),ot(Type.prototype.__proto__||Object.getPrototypeOf(Type.prototype),"_integrate",this).call(this,t),this._y=t;var e=this._start;null!==e&&(this._start=null,b(t,e));var n=this._map;this._map=new Map;var r=!0,i=!1,o=void 0;try{for(var s,a=n.values()[Symbol.iterator]();!(r=(s=a.next()).done);r=!0){b(t,s.value)}}catch(t){i=!0,o=t}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}}},{key:"_delete",value:function(t,e){ot(Type.prototype.__proto__||Object.getPrototypeOf(Type.prototype),"_delete",this).call(this,t,e),t._transaction.changedTypes.delete(this);var n=!0,r=!1,i=void 0;try{for(var o,s=this._map.values()[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var a=o.value;a instanceof Item&&!a._deleted&&a._delete(t,!1)}}catch(t){r=!0,i=t}finally{try{!n&&s.return&&s.return()}finally{if(r)throw i}}for(var l=this._start;null!==l;)l._deleted||l._delete(t,!1),l=l._right}}]),Type}(Item),ItemJSON=function(t){function ItemJSON(){rt(this,ItemJSON);var t=at(this,(ItemJSON.__proto__||Object.getPrototypeOf(ItemJSON)).call(this));return t._content=null,t}return st(ItemJSON,t),it(ItemJSON,[{key:"_copy",value:function(){var t=ot(ItemJSON.prototype.__proto__||Object.getPrototypeOf(ItemJSON.prototype),"_copy",this).call(this);return t._content=this._content,t}},{key:"_fromBinary",value:function(t,e){var n=ot(ItemJSON.prototype.__proto__||Object.getPrototypeOf(ItemJSON.prototype),"_fromBinary",this).call(this,t,e),r=e.readVarUint();this._content=new Array(r);for(var i=0;i<r;i++){var o=e.readVarString(),s=void 0;s="undefined"===o?void 0:JSON.parse(o),this._content[i]=s}return n}},{key:"_toBinary",value:function(t){ot(ItemJSON.prototype.__proto__||Object.getPrototypeOf(ItemJSON.prototype),"_toBinary",this).call(this,t);var e=this._content.length;t.writeVarUint(e);for(var n=0;n<e;n++){var r=void 0,i=this._content[n];r=void 0===i?"undefined":JSON.stringify(i),t.writeVarString(r)}}},{key:"_logString",value:function(){var t=null!==this._left?this._left._lastId:null,e=null!==this._origin?this._origin._lastId:null;return"ItemJSON(id:"+g(this._id)+",content:"+JSON.stringify(this._content)+",left:"+g(t)+",origin:"+g(e)+",right:"+g(this._right)+",parent:"+g(this._parent)+",parentSub:"+this._parentSub+")"}},{key:"_splitAt",value:function(t,e){if(0===e)return this;if(e>=this._length)return this._right;var n=new ItemJSON;return n._content=this._content.splice(e),m(t,this,n,e),n}},{key:"_length",get:function(){return this._content.length}}]),ItemJSON}(Item),ItemString=function(t){function ItemString(){rt(this,ItemString);var t=at(this,(ItemString.__proto__||Object.getPrototypeOf(ItemString)).call(this));return t._content=null,t}return st(ItemString,t),it(ItemString,[{key:"_copy",value:function(){var t=ot(ItemString.prototype.__proto__||Object.getPrototypeOf(ItemString.prototype),"_copy",this).call(this);return t._content=this._content,t}},{key:"_fromBinary",value:function(t,e){var n=ot(ItemString.prototype.__proto__||Object.getPrototypeOf(ItemString.prototype),"_fromBinary",this).call(this,t,e);return this._content=e.readVarString(),n}},{key:"_toBinary",value:function(t){ot(ItemString.prototype.__proto__||Object.getPrototypeOf(ItemString.prototype),"_toBinary",this).call(this,t),t.writeVarString(this._content)}},{key:"_logString",value:function(){var t=null!==this._left?this._left._lastId:null,e=null!==this._origin?this._origin._lastId:null;return"ItemJSON(id:"+g(this._id)+",content:"+JSON.stringify(this._content)+",left:"+g(t)+",origin:"+g(e)+",right:"+g(this._right)+",parent:"+g(this._parent)+",parentSub:"+this._parentSub+")"}},{key:"_splitAt",value:function(t,e){if(0===e)return this;if(e>=this._length)return this._right;var n=new ItemString;return n._content=this._content.slice(e),this._content=this._content.slice(0,e),m(t,this,n,e),n}},{key:"_length",get:function(){return this._content.length}}]),ItemString}(Item),YEvent=function(){function YEvent(t){rt(this,YEvent),this.target=t,this.currentTarget=t}return it(YEvent,[{key:"path",get:function(){for(var t=[],e=this.target,n=e._y;e!==this.currentTarget&&e!==n;){var r=e._parent;if(null!==e._parentSub)t.unshift(e._parentSub);else{var i=!0,o=!1,s=void 0;try{for(var a,l=r[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){var u=lt(a.value,2),h=u[0];if(u[1]===e){t.unshift(h);break}}}catch(t){o=!0,s=t}finally{try{!i&&l.return&&l.return()}finally{if(o)throw s}}}e=r}return t}}]),YEvent}(),YArrayEvent=function(t){function YArrayEvent(t,e){rt(this,YArrayEvent);var n=at(this,(YArrayEvent.__proto__||Object.getPrototypeOf(YArrayEvent)).call(this,t));return n.remote=e,n}return st(YArrayEvent,t),YArrayEvent}(YEvent),YArray=function(t){function YArray(){return rt(this,YArray),at(this,(YArray.__proto__||Object.getPrototypeOf(YArray)).apply(this,arguments))}return st(YArray,t),it(YArray,[{key:"_callObserver",value:function(t,e,n){this._callEventHandler(t,new YArrayEvent(this,n))}},{key:"get",value:function(t){for(var e=this._start;null!==e;){if(!e._deleted){if(t<e._length)return e.constructor===ItemJSON||e.constructor===ItemString?e._content[t]:e;t-=e._length}e=e._right}}},{key:"toArray",value:function(){return this.map(function(t){return t})}},{key:"toJSON",value:function(){return this.map(function(t){return t instanceof Type?null!==t.toJSON?t.toJSON():t.toString():t})}},{key:"map",value:function(t){var e=this,n=[];return this.forEach(function(r,i){n.push(t(r,i,e))}),n}},{key:"forEach",value:function(t){for(var e=0,n=this._start;null!==n;){if(!n._deleted)if(n instanceof Type)t(n,e++,this);else for(var r=n._content,i=r.length,o=0;o<i;o++)e++,t(r[o],e,this);n=n._right}}},{key:Symbol.iterator,value:function(){return{next:function(){for(;null!==this._item&&(this._item._deleted||this._item._length<=this._itemElement);)this._item=this._item._right,this._itemElement=0;if(null===this._item)return{done:!0};var t=void 0;return t=this._item instanceof Type?this._item:this._item._content[this._itemElement++],{value:[this._count,t],done:!1}},_item:this._start,_itemElement:0,_count:0}}},{key:"delete",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this._y.transact(function(){for(var r=e._start,i=0;null!==r&&n>0;){if(!r._deleted)if(i<=t&&t<i+r._length){var o=t-i;r=r._splitAt(e._y,o),r._splitAt(e._y,n),n-=r._length,r._delete(e._y),i+=o}else i+=r._length;r=r._right}}),n>0)throw new Error("Delete exceeds the range of the YArray")}},{key:"insertAfter",value:function(t,e){var n=this;this._transact(function(r){var i=void 0;i=null===t?n._start:t._right;for(var o=null,s=0;s<e.length;s++){var a=e[s];"function"==typeof a&&(a=new a),a instanceof Type?(null!==o&&(null!==r&&o._integrate(r),t=o,o=null),a._origin=t,a._left=t,a._right=i,a._right_origin=i,a._parent=n,null!==r?a._integrate(r):null===t?n._start=a:t._right=a,t=a):(null===o&&(o=new ItemJSON,o._origin=t,o._left=t,o._right=i,o._right_origin=i,o._parent=n,o._content=[]),o._content.push(a))}null!==o&&null!==r&&o._integrate(r)})}},{key:"insert",value:function(t,e){for(var n=null,r=this._start,i=0,o=this._y;null!==r;){var s=r._deleted?0:r._length-1;if(i<=t&&t<=i+s){var a=t-i;r=r._splitAt(o,a),n=r._left,i+=a;break}r._deleted||(i+=r._length),n=r,r=r._right}if(t>i)throw new Error("Position exceeds array range!");this.insertAfter(n,e)}},{key:"_logString",value:function(){var t=null!==this._left?this._left._lastId:null,e=null!==this._origin?this._origin._lastId:null;return"YArray(id:"+g(this._id)+",start:"+g(this._start)+",left:"+g(t)+",origin:"+g(e)+",right:"+g(this._right)+",parent:"+g(this._parent)+",parentSub:"+this._parentSub+")"}},{key:"length",get:function(){for(var t=0,e=this._start;null!==e;)e._deleted||(t+=e._length),e=e._right;return t}}]),YArray}(Type),YMapEvent=function(t){function YMapEvent(t,e,n){rt(this,YMapEvent);var r=at(this,(YMapEvent.__proto__||Object.getPrototypeOf(YMapEvent)).call(this,t));return r.keysChanged=e,r.remote=n,r}return st(YMapEvent,t),YMapEvent}(YEvent),YMap=function(t){function YMap(){return rt(this,YMap),at(this,(YMap.__proto__||Object.getPrototypeOf(YMap)).apply(this,arguments))}return st(YMap,t),it(YMap,[{key:"_callObserver",value:function(t,e,n){this._callEventHandler(t,new YMapEvent(this,e,n))}},{key:"toJSON",value:function(){var t={},e=!0,n=!1,r=void 0;try{for(var i,o=this._map[Symbol.iterator]();!(e=(i=o.next()).done);e=!0){var s=lt(i.value,2),a=s[0],l=s[1];if(!l._deleted){var u=void 0;u=l instanceof Type?void 0!==l.toJSON?l.toJSON():l.toString():l._content[0],t[a]=u}}}catch(t){n=!0,r=t}finally{try{!e&&o.return&&o.return()}finally{if(n)throw r}}return t}},{key:"keys",value:function(){var t=[],e=!0,n=!1,r=void 0;try{for(var i,o=this._map[Symbol.iterator]();!(e=(i=o.next()).done);e=!0){var s=lt(i.value,2),a=s[0];s[1]._deleted||t.push(a)}}catch(t){n=!0,r=t}finally{try{!e&&o.return&&o.return()}finally{if(n)throw r}}return t}},{key:"delete",value:function(t){var e=this;this._transact(function(n){var r=e._map.get(t);null!==n&&void 0!==r&&r._delete(n)})}},{key:"set",value:function(t,e){var n=this;return this._transact(function(r){var i=n._map.get(t)||null;if(null!==i){if(i instanceof ItemJSON&&i._content[0]===e)return e;null!==r&&i._delete(r)}var o=void 0;"function"==typeof e?(o=new e,e=o):e instanceof Item?o=e:(o=new ItemJSON,o._content=[e]),o._right=i,o._right_origin=i,o._parent=n,o._parentSub=t,null!==r?o._integrate(r):n._map.set(t,o)}),e}},{key:"get",value:function(t){var e=this._map.get(t);if(void 0!==e&&!e._deleted)return e instanceof Type?e:e._content[e._content.length-1]}},{key:"has",value:function(t){var e=this._map.get(t);return void 0!==e&&!e._deleted}},{key:"_logString",value:function(){var t=null!==this._left?this._left._lastId:null,e=null!==this._origin?this._origin._lastId:null;return"YMap(id:"+g(this._id)+",mapSize:"+this._map.size+",left:"+g(t)+",origin:"+g(e)+",right:"+g(this._right)+",parent:"+g(this._parent)+",parentSub:"+this._parentSub+")"}}]),YMap}(Type),YText=function(t){function YText(t){rt(this,YText);var e=at(this,(YText.__proto__||Object.getPrototypeOf(YText)).call(this));if("string"==typeof t){var n=new ItemString;n._parent=e,n._content=t,e._start=n}return e}return st(YText,t),it(YText,[{key:"toString",value:function(){for(var t=[],e=this._start;null!==e;)e._deleted||t.push(e._content),e=e._right;return t.join("")}},{key:"insert",value:function(t,e){var n=this;this._transact(function(r){for(var i=null,o=n._start,s=0;null!==o;){var a=o._deleted?0:o._length-1;if(s<=t&&t<=s+a){var l=t-s;o=o._splitAt(n._y,l),i=o._left,s+=l;break}o._deleted||(s+=o._length),i=o,o=o._right}if(t>s)throw new Error("Position exceeds array range!");var u=new ItemString;u._origin=i,u._left=i,u._right=o,u._right_origin=o,u._parent=n,u._content=e,null!==r?u._integrate(n._y):null===i?n._start=u:i._right=u})}},{key:"_logString",value:function(){var t=null!==this._left?this._left._lastId:null,e=null!==this._origin?this._origin._lastId:null;return"YText(id:"+g(this._id)+",start:"+g(this._start)+",left:"+g(t)+",origin:"+g(e)+",right:"+g(this._right)+",parent:"+g(this._parent)+",parentSub:"+this._parentSub+")"}}]),YText}(YArray),bt=null,kt=null,wt=void 0;wt="undefined"!=typeof getSelection?function(t,e,n){if(n){kt={from:null,to:null,fromY:null,toY:null},bt=getSelection();var r=bt.anchorNode;if(null!==r&&null!=r._yxml){var i=r._yxml;kt.from=A(i,bt.anchorOffset),kt.fromY=i._y}var o=bt.focusNode;if(null!==o&&null!=o._yxml){var s=o._yxml;kt.to=A(s,bt.focusOffset),kt.toY=s._y}}}:function(){};var YXmlEvent=function(t){function YXmlEvent(t,e,n){rt(this,YXmlEvent);var r=at(this,(YXmlEvent.__proto__||Object.getPrototypeOf(YXmlEvent)).call(this,t));return r.childListChanged=!1,r.attributesChanged=new Set,r.remote=n,e.forEach(function(t){null===t?r.childListChanged=!0:r.attributesChanged.add(t)}),r}return st(YXmlEvent,t),YXmlEvent}(YEvent),St=-1,Et=1,Ot=0,At=x;At.INSERT=Et,At.DELETE=St,At.EQUAL=Ot;var Ut=At,Bt=function(){function t(e,n){rt(this,t),this._filter=n||function(){return!0},this._root=e,this._currentNode=e,this._firstCall=!0}return it(t,[{key:Symbol.iterator,value:function(){return this}},{key:"next",value:function(){var t=this._currentNode;if(this._firstCall&&(this._firstCall=!1,!t._deleted&&this._filter(t)))return{value:t,done:!1};do{if(t._deleted||t.constructor!==YXmlFragment._YXmlElement||null===t._start){for(;t!==this._root;){if(null!==t._right){t=t._right;break}t=t._parent}t===this._root&&(t=null)}else t=t._start;if(t===this._root)break}while(null!==t&&(t._deleted||!this._filter(t)));return this._currentNode=t,null===t?{done:!0}:{value:t,done:!1}}}]),t}(),YXmlFragment=function(t){function YXmlFragment(){rt(this,YXmlFragment);var t=at(this,(YXmlFragment.__proto__||Object.getPrototypeOf(YXmlFragment)).call(this));t._dom=null,t._domFilter=k,t._domObserver=null;var e=!0;return t._mutualExclude=function(n){if(e){e=!1;try{n()}catch(t){console.error(t)}null!==t._domObserver&&t._domObserver.takeRecords(),e=!0}},t}return st(YXmlFragment,t),it(YXmlFragment,[{key:"createTreeWalker",value:function(t){return new Bt(this,t)}},{key:"querySelector",value:function(t){t=t.toUpperCase();var e=new Bt(this,function(e){return e.nodeName===t}),n=e.next();return n.done?null:n.value}},{key:"querySelectorAll",value:function(t){return t=t.toUpperCase(),Array.from(new Bt(this,function(e){return e.nodeName===t}))}},{key:"enableSmartScrolling",value:function(t){this._scrollElement=t,this.forEach(function(e){e.enableSmartScrolling(t)})}},{key:"setDomFilter",value:function(t){this._domFilter=t,this.forEach(function(e){e.setDomFilter(t)})}},{key:"_callObserver",value:function(t,e,n){this._callEventHandler(t,new YXmlEvent(this,e,n))}},{key:"toString",value:function(){return this.map(function(t){return t.toString()}).join("")}},{key:"_delete",value:function(t,e){this._unbindFromDom(),ot(YXmlFragment.prototype.__proto__||Object.getPrototypeOf(YXmlFragment.prototype),"_delete",this).call(this,t,e)}},{key:"_unbindFromDom",value:function(){null!=this._domObserver&&(this._domObserver.disconnect(),this._domObserver=null),null!=this._dom&&(this._dom._yxml=null,this._dom=null)}},{key:"insertDomElementsAfter",value:function(t,e,n){var r=R(this,e,n);return this.insertAfter(t,r),r}},{key:"insertDomElements",value:function(t,e,n){var r=R(this,e,n);return this.insert(t,r),r}},{key:"getDom",value:function(){return this._dom}},{key:"bindToDom",value:function(t,e){null!=this._dom&&this._unbindFromDom(),null!=t._yxml&&t._yxml._unbindFromDom(),t.innerHTML="",this.forEach(function(n){t.insertBefore(n.getDom(e),null)}),this._bindToDom(t,e)}},{key:"_bindToDom",value:function(t,e){var n=this;if(e=e||document,this._dom=t,t._yxml=this,(this.constructor===YXmlFragment||this._parent===this._y)&&null!==this._parent){this._y.on("beforeTransaction",wt),this._y.on("afterTransaction",B);var r=function(t){if(!t._deleted){for(var e=!1,r=t;r!==n._y;){if(r===n){e=!0;break}r=r._parent}if(e){var i=new Map;if(void 0!==t.getAttributes){var o=t.getAttributes();for(var s in o)i.set(s,o[s])}var a=n._domFilter(t.nodeName,new Map(i));null===a?t._delete(n._y):i.forEach(function(e,n){a.has(n)||t.removeAttribute(n)})}}};return this._y.on("beforeObserverCalls",function(t,e){e.changedTypes.forEach(function(t,e){(t.size>1||!t.has(null))&&r(e)}),e.newTypes.forEach(r)}),this.observeDeep(function(t){O.call(n,t,e)}),"undefined"!=typeof MutationObserver&&(this._y.on("beforeTransaction",function(){n._domObserverListener(n._domObserver.takeRecords())}),this._domObserverListener=function(t){n._mutualExclude(function(){n._y.transact(function(){var e=new Set;t.forEach(function(t){var r=t.target,i=r._yxml;if(null!=i&&i.constructor!==YXmlHook)switch(t.type){case"characterData":for(var o=Ut(i.toString(),r.nodeValue),s=0,a=0;a<o.length;a++){var l=o[a];0===l[0]?s+=l[1].length:-1===l[0]?i.delete(s,l[1].length):(i.insert(s,l[1]),s+=l[1].length)}break;case"attributes":if(i.constructor===YXmlFragment)break;var u=t.attributeName,h=r.getAttribute(u),c=new Map;c.set(u,h),n._domFilter(r.nodeName,c).size>0&&i.constructor!==YXmlFragment&&i.getAttribute(u)!==h&&(null==h?i.removeAttribute(u):i.setAttribute(u,h));break;case"childList":e.add(t.target)}});var r=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done);r=!0){var l=s.value;null!=l._yxml&&!1!==l._yxml&&E(l)}}catch(t){i=!0,o=t}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}})})},this._domObserver=new MutationObserver(this._domObserverListener),this._domObserver.observe(t,{childList:!0,attributes:!0,characterData:!0,subtree:!0})),t}}},{key:"_logString",value:function(){var t=null!==this._left?this._left._lastId:null,e=null!==this._origin?this._origin._lastId:null;return"YXml(id:"+g(this._id)+",left:"+g(t)+",origin:"+g(e)+",right:"+this._right+",parent:"+g(this._parent)+",parentSub:"+this._parentSub+")"}}]),YXmlFragment}(YArray),YXmlElement=function(t){function YXmlElement(t,e,n){rt(this,YXmlElement);var r=at(this,(YXmlElement.__proto__||Object.getPrototypeOf(YXmlElement)).call(this));return r.nodeName=null,r._scrollElement=null,"string"==typeof t?r.nodeName=t.toUpperCase():null!=t&&null!=t.nodeType&&t.nodeType===t.ELEMENT_NODE?(r.nodeName=t.nodeName,r._setDom(t,n)):r.nodeName="UNDEFINED","function"==typeof e&&(r._domFilter=e),r}return st(YXmlElement,t),it(YXmlElement,[{key:"_copy",value:function(t){var e=ot(YXmlElement.prototype.__proto__||Object.getPrototypeOf(YXmlElement.prototype),"_copy",this).call(this,t);return e.nodeName=this.nodeName,e}},{key:"_setDom",value:function(t,e){var n=this;if(null!=this._dom)throw new Error("Only call this method if you know what you are doing ;)");if(null!=t._yxml)throw new Error("Already bound to an YXml type");for(var r=new Map,i=0;i<t.attributes.length;i++){var o=t.attributes[i];r.set(o.name,o.value)}return r=this._domFilter(t,r),r.forEach(function(t,e){n.setAttribute(e,t)}),this.insertDomElements(0,Array.prototype.slice.call(t.childNodes),e),this._bindToDom(t,e),t}},{key:"_fromBinary",value:function(t,e){var n=ot(YXmlElement.prototype.__proto__||Object.getPrototypeOf(YXmlElement.prototype),"_fromBinary",this).call(this,t,e);return this.nodeName=e.readVarString(),n}},{key:"_toBinary",value:function(t){ot(YXmlElement.prototype.__proto__||Object.getPrototypeOf(YXmlElement.prototype),"_toBinary",this).call(this,t),t.writeVarString(this.nodeName)}},{key:"_integrate",value:function(t){if(null===this.nodeName)throw new Error("nodeName must be defined!");this._domFilter===k&&void 0!==this._parent._domFilter&&(this._domFilter=this._parent._domFilter),ot(YXmlElement.prototype.__proto__||Object.getPrototypeOf(YXmlElement.prototype),"_integrate",this).call(this,t)}},{key:"toString",value:function(){var t=this.getAttributes(),e=[],n=[];for(var r in t)n.push(r);n.sort();for(var i=n.length,o=0;o<i;o++){var s=n[o];e.push(s+'="'+t[s]+'"')}var a=this.nodeName.toLocaleLowerCase();return"<"+a+(e.length>0?" "+e.join(" "):"")+">"+ot(YXmlElement.prototype.__proto__||Object.getPrototypeOf(YXmlElement.prototype),"toString",this).call(this)+"</"+a+">"}},{key:"removeAttribute",value:function(){return YMap.prototype.delete.apply(this,arguments)}},{key:"setAttribute",value:function(){return YMap.prototype.set.apply(this,arguments)}},{key:"getAttribute",value:function(){return YMap.prototype.get.apply(this,arguments)}},{key:"getAttributes",value:function(){var t={},e=!0,n=!1,r=void 0;try{for(var i,o=this._map[Symbol.iterator]();!(e=(i=o.next()).done);e=!0){var s=lt(i.value,2),a=s[0],l=s[1];l._deleted||(t[a]=l._content[0])}}catch(t){n=!0,r=t}finally{try{!e&&o.return&&o.return()}finally{if(n)throw r}}return t}},{key:"getDom",value:function(t){t=t||document;var e=this._dom;if(null==e){e=t.createElement(this.nodeName),e._yxml=this;var n=this.getAttributes();for(var r in n)e.setAttribute(r,n[r]);this.forEach(function(n){e.appendChild(n.getDom(t))}),this._bindToDom(e,t)}return e}}]),YXmlElement}(YXmlFragment),xt={},YXmlHook=function(t){function YXmlHook(t,e){rt(this,YXmlHook);var n=at(this,(YXmlHook.__proto__||Object.getPrototypeOf(YXmlHook)).call(this));return n._dom=null,n.hookName=null,void 0!==t&&(n.hookName=t,n._dom=e,e._yjsHook=t,e._yxml=n,J(t).fillType(e,n)),n}return st(YXmlHook,t),it(YXmlHook,[{key:"getDom",value:function(t){if(t=t||document,null===this._dom){var e=J(this.hookName).createDom(this);this._dom=e,e._yxml=this,e._yjsHook=this.hookName}return this._dom}},{key:"_fromBinary",value:function(t,e){var n=ot(YXmlHook.prototype.__proto__||Object.getPrototypeOf(YXmlHook.prototype),"_fromBinary",this).call(this,t,e);return this.hookName=e.readVarString(),n}},{key:"_toBinary",value:function(t){ot(YXmlHook.prototype.__proto__||Object.getPrototypeOf(YXmlHook.prototype),"_toBinary",this).call(this,t),t.writeVarString(this.hookName)}},{key:"_integrate",value:function(t){if(null===this.hookName)throw new Error("hookName must be defined!");ot(YXmlHook.prototype.__proto__||Object.getPrototypeOf(YXmlHook.prototype),"_integrate",this).call(this,t)}},{key:"setDomFilter",value:function(){}},{key:"enableSmartScrolling",value:function(){}}]),YXmlHook}(YMap);YXmlHook.addHook=H;var YXmlText=function(t){function YXmlText(t){rt(this,YXmlText);var e=null,n=null;null!=t&&(null!=t.nodeType&&t.nodeType===t.TEXT_NODE?(e=t,n=e.nodeValue):"string"==typeof t&&(n=t));var r=at(this,(YXmlText.__proto__||Object.getPrototypeOf(YXmlText)).call(this,n));return r._dom=null,r._domObserver=null,r._domObserverListener=null,r._scrollElement=null,null!==e&&r._setDom(t),r}return st(YXmlText,t),it(YXmlText,[{key:"setDomFilter",value:function(){}},{key:"enableSmartScrolling",value:function(t){this._scrollElement=t}},{key:"_setDom",value:function(t){null!=this._dom&&this._unbindFromDom(),null!=t._yxml&&t._yxml._unbindFromDom(),this._dom=t,t._yxml=this}},{key:"getDom",value:function(t){if(t=t||document,null===this._dom){var e=t.createTextNode(this.toString());return this._setDom(e),e}return this._dom}},{key:"_delete",value:function(t,e){this._unbindFromDom(),ot(YXmlText.prototype.__proto__||Object.getPrototypeOf(YXmlText.prototype),"_delete",this).call(this,t,e)}},{key:"_unbindFromDom",value:function(){null!=this._domObserver&&(this._domObserver.disconnect(),this._domObserver=null),null!=this._dom&&(this._dom._yxml=null,this._dom=null)}}]),YXmlText}(YText);YXmlFragment._YXmlElement=YXmlElement,YXmlFragment._YXmlHook=YXmlHook;var Dt=new Map,It=new Map;W(0,ItemJSON),W(1,ItemString),W(2,Delete),W(3,YArray),W(4,YMap),W(5,YText),W(6,YXmlFragment),W(7,YXmlElement),W(8,YXmlText),W(9,YXmlHook);var Nt=16777215,Tt=function(){function t(e,n){rt(this,t),this.user=Nt,this.name=e,this.type=X(n)}return it(t,[{key:"equals",value:function(t){return null!==t&&t.user===this.user&&t.name===this.name&&t.type===this.type}},{key:"lessThan",value:function(t){return this.user<t.user||this.user===t.user&&(this.name<t.name||this.name===t.name&&this.type<t.type)}}]),t}(),Lt=function(t){function e(t){rt(this,e);var n=at(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.y=t,n}return st(e,t),it(e,[{key:"logTable",value:function(){var t=[];this.iterate(null,null,function(e){t.push({id:g(e),origin:g(null===e._origin?null:e._origin._lastId),left:g(null===e._left?null:e._left._lastId),right:g(e._right),right_origin:g(e._right_origin),parent:g(e._parent),parentSub:e._parentSub,deleted:e._deleted,content:JSON.stringify(e._content)})}),console.table(t)}},{key:"get",value:function(t){var e=this.find(t);if(null===e&&t instanceof Tt){var n=z(t.type),r=this.y;e=new n,e._id=t,e._parent=r,r.transact(function(){e._integrate(r)}),this.put(e)}return e}},{key:"getItem",value:function(t){var e=this.findWithUpperBound(t);if(null===e)return null;var n=e._id;return t.user===n.user&&t.clock<n.clock+e._length?e:null}},{key:"getItemCleanStart",value:function(t){var e=this.getItem(t);if(null===e||1===e._length)return e;var n=e._id;return n.clock===t.clock?e:e._splitAt(this.y,t.clock-n.clock)}},{key:"getItemCleanEnd",value:function(t){var e=this.getItem(t);if(null===e||1===e._length)return e;var n=e._id;return n.clock+e._length-1===t.clock?e:(e._splitAt(this.y,t.clock-n.clock+1),e)}}]),e}(ht),Vt=function(){function t(e){rt(this,t),this.y=e,this.state=new Map}return it(t,[{key:"logTable",value:function(){var t=[],e=!0,n=!1,r=void 0;try{for(var i,o=this.state[Symbol.iterator]();!(e=(i=o.next()).done);e=!0){var s=lt(i.value,2),a=s[0],l=s[1];t.push({user:a,state:l})}}catch(t){n=!0,r=t}finally{try{!e&&o.return&&o.return()}finally{if(n)throw r}}console.table(t)}},{key:"getNextID",value:function(t){var e=this.y.userID,n=this.getState(e);return this.setState(e,n+t),new ct(e,n)}},{key:"updateRemoteState",value:function(t){for(var e=t._id.user,n=this.state.get(e);null!==t&&t._id.clock===n;)n+=t._length,t=this.y.os.get(new ct(e,n));this.state.set(e,n)}},{key:"getState",value:function(t){var e=this.state.get(t);return null==e?0:e}},{key:"setState",value:function(t,e){var n=this.y._transaction.beforeState;n.has(t)||n.set(t,this.getState(t)),this.state.set(t,e)}}]),t}(),Ct=function(){function t(){rt(this,t),this._eventListener=new Map}return it(t,[{key:"_getListener",value:function(t){var e=this._eventListener.get(t);return void 0===e&&(e={once:new Set,on:new Set},this._eventListener.set(t,e)),e}},{key:"once",value:function(t,e){this._getListener(t).once.add(e)}},{
key:"on",value:function(t,e){this._getListener(t).on.add(e)}},{key:"off",value:function(t,e){if(null==t||null==e)throw new Error("You must specify event name and function!");var n=this._eventListener.get(t);void 0!==n&&n.remove(e)}},{key:"emit",value:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var i=this._eventListener.get(t);void 0!==i?(i.on.forEach(function(t){return t.apply(null,n)}),i.once.forEach(function(t){return t.apply(null,n)}),i.once=new Set):"error"===t&&console.error(n[0])}},{key:"destroy",value:function(){this._eventListener=null}}]),t}(),Pt=function t(e,n){rt(this,t),this.created=new Date;var r=n.beforeState;this.toState=new ct(e.userID,e.ss.getState(e.userID)-1),r.has(e.userID)?this.fromState=new ct(e.userID,r.get(e.userID)):this.fromState=this.toState,this.deletedStructs=n.deletedStructs},jt=function(){function t(e){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};rt(this,t),this.options=r,r.captureTimeout=null==r.captureTimeout?500:r.captureTimeout,this._undoBuffer=[],this._redoBuffer=[],this._scope=e,this._undoing=!1,this._redoing=!1;var i=e._y;this.y=i,i.on("afterTransaction",function(t,i,o){if(!o&&i.changedParentTypes.has(e)){var s=new Pt(t,i);if(n._undoing)n._redoBuffer.push(s);else{var a=n._undoBuffer.length>0?n._undoBuffer[n._undoBuffer.length-1]:null;null!==a&&s.created-a.created<=r.captureTimeout?(a.created=s.created,a.toState=s.toState,s.deletedStructs.forEach(a.deletedStructs.add,a.deletedStructs)):n._undoBuffer.push(s),n._redoing||(n._redoBuffer=[])}}})}return it(t,[{key:"undo",value:function(){this._undoing=!0;var t=Q(this.y,this._scope,this._undoBuffer);return this._undoing=!1,t}},{key:"redo",value:function(){this._redoing=!0;var t=Q(this.y,this._scope,this._redoBuffer);return this._redoing=!1,t}}]),t}(),Mt=1e3,Ft=60*Mt,Rt=60*Ft,Yt=24*Rt,Ht=365.25*Yt,Jt=function(t,e){e=e||{};var n=void 0===t?"undefined":nt(t);if("string"===n&&t.length>0)return Z(t);if("number"===n&&!1===isNaN(t))return e.long?K(t):G(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))},Wt=t(function(t,e){function n(t){var n,r=0;for(n in t)r=(r<<5)-r+t.charCodeAt(n),r|=0;return e.colors[Math.abs(r)%e.colors.length]}function r(t){function r(){if(r.enabled){var t=r,n=+new Date,i=n-(l||n);t.diff=i,t.prev=l,t.curr=n,l=n;for(var o=new Array(arguments.length),s=0;s<o.length;s++)o[s]=arguments[s];o[0]=e.coerce(o[0]),"string"!=typeof o[0]&&o.unshift("%O");var a=0;o[0]=o[0].replace(/%([a-zA-Z%])/g,function(n,r){if("%%"===n)return n;a++;var i=e.formatters[r];if("function"==typeof i){var s=o[a];n=i.call(t,s),o.splice(a,1),a--}return n}),e.formatArgs.call(t,o);(r.log||e.log||console.log.bind(console)).apply(t,o)}}return r.namespace=t,r.enabled=e.enabled(t),r.useColors=e.useColors(),r.color=n(t),"function"==typeof e.init&&e.init(r),r}function i(t){e.save(t),e.names=[],e.skips=[];for(var n=("string"==typeof t?t:"").split(/[\s,]+/),r=n.length,i=0;i<r;i++)n[i]&&(t=n[i].replace(/\*/g,".*?"),"-"===t[0]?e.skips.push(new RegExp("^"+t.substr(1)+"$")):e.names.push(new RegExp("^"+t+"$")))}function o(){e.enable("")}function s(t){var n,r;for(n=0,r=e.skips.length;n<r;n++)if(e.skips[n].test(t))return!1;for(n=0,r=e.names.length;n<r;n++)if(e.names[n].test(t))return!0;return!1}function a(t){return t instanceof Error?t.stack||t.message:t}e=t.exports=r.debug=r.default=r,e.coerce=a,e.disable=o,e.enable=i,e.enabled=s,e.humanize=Jt,e.names=[],e.skips=[],e.formatters={};var l}),zt=(Wt.coerce,Wt.disable,Wt.enable,Wt.enabled,Wt.humanize,Wt.names,Wt.skips,Wt.formatters,t(function(t,e){function n(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function r(t){var n=this.useColors;if(t[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+t[0]+(n?"%c ":" ")+"+"+e.humanize(this.diff),n){var r="color: "+this.color;t.splice(1,0,r,"color: inherit");var i=0,o=0;t[0].replace(/%[a-zA-Z%]/g,function(t){"%%"!==t&&(i++,"%c"===t&&(o=i))}),t.splice(o,0,r)}}function i(){return"object"===("undefined"==typeof console?"undefined":nt(console))&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function o(t){try{null==t?e.storage.removeItem("debug"):e.storage.debug=t}catch(t){}}function s(){var t;try{t=e.storage.debug}catch(t){}return!t&&"undefined"!=typeof process&&"env"in process&&(t=process.env.DEBUG),t}e=t.exports=Wt,e.log=i,e.formatArgs=r,e.save=o,e.load=s,e.useColors=n,e.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},e.enable(s())})),Xt=(zt.log,zt.formatArgs,zt.save,zt.load,zt.useColors,zt.storage,zt.colors,function(){function t(e,n){if(rt(this,t),this.y=e,this.opts=n,null==n.role||"master"===n.role)this.role="master";else{if("slave"!==n.role)throw new Error("Role must be either 'master' or 'slave'!");this.role="slave"}this.log=zt("y:connector"),this.logMessage=zt("y:connector-message"),this._forwardAppliedStructs=n.forwardAppliedOperations||!1,this.role=n.role,this.connections=new Map,this.isSynced=!1,this.userEventListeners=[],this.whenSyncedListeners=[],this.currentSyncTarget=null,this.debug=!0===n.debug,this.broadcastBuffer=new pt,this.broadcastBufferSize=0,this.protocolVersion=11,this.authInfo=n.auth||null,this.checkAuth=n.checkAuth||function(){return Promise.resolve("write")},null==n.maxBufferLength?this.maxBufferLength=-1:this.maxBufferLength=n.maxBufferLength}return it(t,[{key:"reconnect",value:function(){this.log("reconnecting..")}},{key:"disconnect",value:function(){return this.log("discronnecting.."),this.connections=new Map,this.isSynced=!1,this.currentSyncTarget=null,this.whenSyncedListeners=[],Promise.resolve()}},{key:"onUserEvent",value:function(t){this.userEventListeners.push(t)}},{key:"removeUserEventListener",value:function(t){this.userEventListeners=this.userEventListeners.filter(function(e){return t!==e})}},{key:"userLeft",value:function(t){if(this.connections.has(t)){this.log("%s: User left %s",this.y.userID,t),this.connections.delete(t),this._setSyncedWith(null);var e=!0,n=!1,r=void 0;try{for(var i,o=this.userEventListeners[Symbol.iterator]();!(e=(i=o.next()).done);e=!0){(0,i.value)({action:"userLeft",user:t})}}catch(t){n=!0,r=t}finally{try{!e&&o.return&&o.return()}finally{if(n)throw r}}}}},{key:"userJoined",value:function(t,e,n){if(null==e)throw new Error("You must specify the role of the joined user!");if(this.connections.has(t))throw new Error("This user already joined!");this.log("%s: User joined %s",this.y.userID,t),this.connections.set(t,{uid:t,isSynced:!1,role:e,processAfterAuth:[],processAfterSync:[],auth:n||null,receivedSyncStep2:!1});var r={};r.promise=new Promise(function(t){r.resolve=t}),this.connections.get(t).syncStep2=r;var i=!0,o=!1,s=void 0;try{for(var a,l=this.userEventListeners[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){(0,a.value)({action:"userJoined",user:t,role:e})}}catch(t){o=!0,s=t}finally{try{!i&&l.return&&l.return()}finally{if(o)throw s}}this._syncWithUser(t)}},{key:"whenSynced",value:function(t){this.isSynced?t():this.whenSyncedListeners.push(t)}},{key:"_syncWithUser",value:function(t){"slave"!==this.role&&u(this,t)}},{key:"_fireIsSyncedListeners",value:function(){if(!this.isSynced){this.isSynced=!0;var t=!0,e=!1,n=void 0;try{for(var r,i=this.whenSyncedListeners[Symbol.iterator]();!(t=(r=i.next()).done);t=!0){(0,r.value)()}}catch(t){e=!0,n=t}finally{try{!t&&i.return&&i.return()}finally{if(e)throw n}}this.whenSyncedListeners=[],this.y.emit("synced")}}},{key:"send",value:function(t,e){var n=this.y;if(!(e instanceof ArrayBuffer||e instanceof Uint8Array))throw new Error("Expected Message to be an ArrayBuffer or Uint8Array - don't use this method to send custom messages");this.log("User%s to User%s: Send '%y'",n.userID,t,e),this.logMessage("User%s to User%s: Send %Y",n.userID,t,[n,e])}},{key:"broadcast",value:function(t){var e=this.y;if(!(t instanceof ArrayBuffer||t instanceof Uint8Array))throw new Error("Expected Message to be an ArrayBuffer or Uint8Array - don't use this method to send custom messages");this.log("User%s: Broadcast '%y'",e.userID,t),this.logMessage("User%s: Broadcast: %Y",e.userID,[e,t])}},{key:"broadcastStruct",value:function(t){var e=this,n=0===this.broadcastBuffer.length;if(n&&(this.broadcastBuffer.writeVarString(this.y.room),this.broadcastBuffer.writeVarString("update"),this.broadcastBufferSize=0,this.broadcastBufferSizePos=this.broadcastBuffer.pos,this.broadcastBuffer.writeUint32(0)),this.broadcastBufferSize++,t._toBinary(this.broadcastBuffer),this.maxBufferLength>0&&this.broadcastBuffer.length>this.maxBufferLength){var r=this.broadcastBuffer;r.setUint32(this.broadcastBufferSizePos,this.broadcastBufferSize),this.broadcastBuffer=new pt,this.whenRemoteResponsive().then(function(){e.broadcast(r.createBuffer())})}else n&&setTimeout(function(){if(e.broadcastBuffer.length>0){var t=e.broadcastBuffer;t.setUint32(e.broadcastBufferSizePos,e.broadcastBufferSize),e.broadcast(t.createBuffer()),e.broadcastBuffer=new pt}},0)}},{key:"whenRemoteResponsive",value:function(){return new Promise(function(t){setTimeout(t,100)})}},{key:"receiveMessage",value:function(t,e,n){var r=this,i=this.y,o=i.userID;if(n=n||!1,!(e instanceof ArrayBuffer||e instanceof Uint8Array))return Promise.reject(new Error("Expected Message to be an ArrayBuffer or Uint8Array!"));if(t===o)return Promise.resolve();var s=new vt(e),a=new pt,l=s.readVarString();a.writeVarString(l);var u=s.readVarString(),h=this.connections.get(t);if(this.log("User%s from User%s: Receive '%s'",o,t,u),this.logMessage("User%s from User%s: Receive %Y",o,t,[i,e]),null==h&&!n)throw new Error("Received message from unknown peer!");if("sync step 1"===u||"sync step 2"===u){var c=s.readVarUint();if(null==h.auth)return h.processAfterAuth.push([u,h,s,a,t]),this.checkAuth(c,i,t).then(function(t){null==h.auth&&(h.auth=t,i.emit("userAuthenticated",{user:h.uid,auth:t}));var e=h.processAfterAuth;h.processAfterAuth=[],e.forEach(function(t){return r.computeMessage(t[0],t[1],t[2],t[3],t[4])})})}!n&&null==h.auth||"update"===u&&!h.isSynced?h.processAfterSync.push([u,h,s,a,t,!1]):this.computeMessage(u,h,s,a,t,n)}},{key:"computeMessage",value:function(t,e,n,i,o,s){if("sync step 1"!==t||"write"!==e.auth&&"read"!==e.auth){var a=this.y;a.transact(function(){if("sync step 2"===t&&"write"===e.auth)d(n,i,a,e,o);else{if("update"!==t||!s&&"write"!==e.auth)throw new Error("Unable to receive message");r(n,i,a,e,o)}},!0)}else c(n,i,this.y,e,o)}},{key:"_setSyncedWith",value:function(t){var e=this;if(null!=t){var n=this.connections.get(t);n.isSynced=!0;var r=n.processAfterSync;n.processAfterSync=[],r.forEach(function(t){e.computeMessage(t[0],t[1],t[2],t[3],t[4])})}var i=Array.from(this.connections.values());i.length>0&&i.every(function(t){return t.isSynced})&&this._fireIsSyncedListeners()}}]),t}()),Y=function(t){function Y(t){rt(this,Y);var e=at(this,(Y.__proto__||Object.getPrototypeOf(Y)).call(this));return e._opts=t,e.userID=null!=t._userID?t._userID:q(),e.share={},e.ds=new dt(e),e.os=new Lt(e),e.ss=new Vt(e),e.connector=new Y[t.connector.name](e,t.connector),null!=t.persistence?(e.persistence=new Y[t.persistence.name](e,t.persistence),e.persistence.retrieveContent()):e.persistence=null,e.connected=!0,e._missingStructs=new Map,e._readyToIntegrate=[],e._transaction=null,e}return st(Y,t),it(Y,[{key:"_beforeChange",value:function(){}},{key:"transact",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=null===this._transaction;n&&(this._transaction=new yt(this),this.emit("beforeTransaction",this,this._transaction,e));try{t(this)}catch(t){console.error(t)}if(n){this.emit("beforeObserverCalls",this,this._transaction,e);var r=this._transaction;this._transaction=null,r.changedTypes.forEach(function(t,n){n._deleted||n._callObserver(r,t,e)}),r.changedParentTypes.forEach(function(t,e){e._deleted||(t=t.filter(function(t){return!t.target._deleted}),t.forEach(function(t){t.currentTarget=e}),e._deepEventHandler.callEventListeners(r,t))}),this.emit("afterTransaction",this,r,e)}}},{key:"define",value:function(t,e){var n=new Tt(t,e),r=this.os.get(n);if(void 0===this.share[t])this.share[t]=r;else if(this.share[t]!==r)throw new Error("Type is already defined with a different constructor");return r}},{key:"get",value:function(t){return this.share[t]}},{key:"disconnect",value:function(){return this.connected?(this.connected=!1,this.connector.disconnect()):Promise.resolve()}},{key:"reconnect",value:function(){return this.connected?Promise.resolve():(this.connected=!0,this.connector.reconnect())}},{key:"destroy",value:function(){this.share=null,null!=this.connector.destroy?this.connector.destroy():this.connector.disconnect(),this.os=null,this.ds=null,this.ss=null}},{key:"whenSynced",value:function(){var t=this;return new Promise(function(e){t.once("synced",function(){e()})})}},{key:"_start",get:function(){return null},set:function(t){return null}},{key:"room",get:function(){return this._opts.connector.room}}]),Y}(Ct);return Y.extend=function(){for(var t=0;t<arguments.length;t++){var e=arguments[t];if("function"!=typeof e)throw new Error("Expected a function!");e(Y)}},Y.AbstractConnector=Xt,Y.Persisence=et,Y.Array=YArray,Y.Map=YMap,Y.Text=YText,Y.XmlElement=YXmlElement,Y.XmlFragment=YXmlFragment,Y.XmlText=YXmlText,Y.XmlHook=YXmlHook,Y.utils={BinaryDecoder:vt,UndoManager:jt,getRelativePosition:A,fromRelativePosition:U,addType:W},Y.debug=zt,zt.formatters.Y=_,zt.formatters.y=v,Y});
//# sourceMappingURL=y.js.map