/*! For license information please see 111.679c28d1.js.LICENSE */ (()=>{var e={29293:function(e,t,n){var r;!function(i,o){"use strict";var a="model",s="name",c="type",u="vendor",l="version",d="mobile",p="tablet",h={extend:function(e,t){var n={};for(var r in e)t[r]&&t[r].length%2==0?n[r]=t[r].concat(e[r]):n[r]=e[r];return n},has:function(e,t){return"string"==typeof e&&-1!==t.toLowerCase().indexOf(e.toLowerCase())},lowerize:function(e){return e.toLowerCase()},major:function(e){return"string"==typeof e?e.replace(/[^\d\.]/g,"").split(".")[0]:void 0},trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},f={rgx:function(e,t){for(var n,r,i,o,a,s,c=0;c0?2==o.length?"function"==typeof o[1]?this[o[0]]=o[1].call(this,s):this[o[0]]=o[1]:3==o.length?"function"!=typeof o[1]||o[1].exec&&o[1].test?this[o[0]]=s?s.replace(o[1],o[2]):void 0:this[o[0]]=s?o[1].call(this,s,o[2]):void 0:4==o.length&&(this[o[0]]=s?o[3].call(this,s.replace(o[1],o[2])):void 0):this[o]=s||void 0;c+=2}},str:function(e,t){for(var n in t)if("object"==typeof t[n]&&t[n].length>0){for(var r=0;r{"use strict";n.d(t,{Er:()=>u,jY:()=>c,os:()=>s,eJ:()=>d,UP:()=>p});var r,i=n(67294),o=n.n(i),a=n(47591);function s(){return r||(r=o().createContext({})),r}var c,u=function(e){var t=e.client,n=e.children,r=s();return o().createElement(r.Consumer,null,(function(e){return void 0===e&&(e={}),t&&e.client!==t&&(e=Object.assign({},e,{client:t})),(0,a.Yk)(e.client,5),o().createElement(r.Provider,{value:e},n)}))};!function(e){e[e.Query=0]="Query",e[e.Mutation=1]="Mutation",e[e.Subscription=2]="Subscription"}(c||(c={}));var l=new Map;function d(e){var t;switch(e){case c.Query:t="Query";break;case c.Mutation:t="Mutation";break;case c.Subscription:t="Subscription"}return t}function p(e){var t,n,r=l.get(e);if(r)return r;(0,a.Yk)(!!e&&!!e.kind,1);var i=e.definitions.filter((function(e){return"FragmentDefinition"===e.kind})),o=e.definitions.filter((function(e){return"OperationDefinition"===e.kind&&"query"===e.operation})),s=e.definitions.filter((function(e){return"OperationDefinition"===e.kind&&"mutation"===e.operation})),u=e.definitions.filter((function(e){return"OperationDefinition"===e.kind&&"subscription"===e.operation}));(0,a.Yk)(!i.length||o.length||s.length||u.length,2),(0,a.Yk)(o.length+s.length+u.length<=1,3),n=o.length?c.Query:c.Mutation,o.length||s.length||(n=c.Subscription);var d=o.length?o:s.length?s:u;(0,a.Yk)(1===d.length,4);var p=d[0];t=p.variableDefinitions||[];var h={name:p.name&&"Name"===p.name.kind?p.name.value:"data",type:n,variables:t};return l.set(e,h),h}},59713:e=>{e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},63349:(e,t,n)=>{"use strict";function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}n.d(t,{b:()=>r})},22122:(e,t,n)=>{"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;tr})},41788:(e,t,n)=>{"use strict";function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}n.d(t,{b:()=>r})},19756:(e,t,n)=>{"use strict";function r(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}n.d(t,{b:()=>r})},85354:e=>{e.exports=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}},60693:(e,t,n)=>{var r=n(59713);e.exports=function(e){for(var t=1;t{function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(r){return"function"==typeof Symbol&&"symbol"===t(Symbol.iterator)?e.exports=n=function(e){return t(e)}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":t(e)},n(r)}e.exports=n},5752:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i=n(70655),o=n(31313),a=n(14594),s=((r={})["no-app"]="No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()",r["bad-app-name"]="Illegal App name: '{$appName}",r["duplicate-app"]="Firebase App named '{$appName}' already exists",r["app-deleted"]="Firebase App named '{$appName}' already deleted",r["invalid-app-argument"]="firebase.{$appName}() takes either no argument or a Firebase App instance.",r),c=new o.ErrorFactory("app","Firebase",s),u="[DEFAULT]",l=[],d=function(){function e(e,t,n){this.firebase_=n,this.isDeleted_=!1,this.services_={},this.name_=t.name,this.automaticDataCollectionEnabled_=t.automaticDataCollectionEnabled||!1,this.options_=o.deepCopy(e),this.INTERNAL={getUid:function(){return null},getToken:function(){return Promise.resolve(null)},addAuthTokenListener:function(e){l.push(e),setTimeout((function(){return e(null)}),0)},removeAuthTokenListener:function(e){l=l.filter((function(t){return t!==e}))}}}return Object.defineProperty(e.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this.automaticDataCollectionEnabled_},set:function(e){this.checkDestroyed_(),this.automaticDataCollectionEnabled_=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!0,configurable:!0}),e.prototype.delete=function(){var e=this;return new Promise((function(t){e.checkDestroyed_(),t()})).then((function(){e.firebase_.INTERNAL.removeApp(e.name_);for(var t=[],n=0,r=Object.keys(e.services_);n=0&&h.warn("\n Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n ")}var m=function e(){var t=function(e){var t={},n={},r={},i={__esModule:!0,initializeApp:function(n,r){void 0===r&&(r={});if("object"!=typeof r||null===r){r={name:r}}var a=r;void 0===a.name&&(a.name=u);var s=a.name;if("string"!=typeof s||!s)throw c.create("bad-app-name",{appName:String(s)});if(o.contains(t,s))throw c.create("duplicate-app",{appName:s});var d=new e(n,a,i);return t[s]=d,l(d,"create"),d},app:a,apps:null,SDK_VERSION:p,INTERNAL:{registerService:function(t,u,l,d,p){void 0===p&&(p=!1);if(n[t])return h.debug("There were multiple attempts to register service "+t+"."),i[t];n[t]=u,d&&(r[t]=d,s().forEach((function(e){d("create",e)})));function f(e){if(void 0===e&&(e=a()),"function"!=typeof e[t])throw c.create("invalid-app-argument",{appName:t});return e[t]()}void 0!==l&&o.deepExtend(f,l);return i[t]=f,e.prototype[t]=function(){for(var e=[],n=0;n{"use strict";var r=n(34155);Object.defineProperty(t,"__esModule",{value:!0});var i=function(e){return e&&"object"==typeof e&&"default"in e?e.default:e}(n(5752)),o=n(70655),a=n(31313),s=n(14594),c=function(){function e(e){this.domStorage_=e,this.prefix_="firebase:"}return e.prototype.set=function(e,t){null==t?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),a.stringify(t))},e.prototype.get=function(e){var t=this.domStorage_.getItem(this.prefixedName_(e));return null==t?null:a.jsonEval(t)},e.prototype.remove=function(e){this.domStorage_.removeItem(this.prefixedName_(e))},e.prototype.prefixedName_=function(e){return this.prefix_+e},e.prototype.toString=function(){return this.domStorage_.toString()},e}(),u=function(){function e(){this.cache_={},this.isInMemoryStorage=!0}return e.prototype.set=function(e,t){null==t?delete this.cache_[e]:this.cache_[e]=t},e.prototype.get=function(e){return a.contains(this.cache_,e)?this.cache_[e]:null},e.prototype.remove=function(e){delete this.cache_[e]},e}(),l=function(e){try{if("undefined"!=typeof window&&void 0!==window[e]){var t=window[e];return t.setItem("firebase:sentinel","cache"),t.removeItem("firebase:sentinel"),new c(t)}}catch(n){}return new u},d=l("localStorage"),p=l("sessionStorage"),h=new s.Logger("@firebase/database"),f="FIREBASE_DATABASE_EMULATOR_HOST",m=function(){var e=1;return function(){return e++}}(),g=function(e){var t=a.stringToByteArray(e),n=new a.Sha1;n.update(t);var r=n.digest();return a.base64.encodeByteArray(r)},y=function(){for(var e=[],t=0;tn?r.push(e.substring(i,n)):r.push(e.substring(i,i+t));return r};function N(e,t){for(var n in e)e.hasOwnProperty(n)&&t(n,e[n])}var L=function(e){a.assert(!O(e),"Invalid JSON number");var t,n,r,i,o,s,c;for(0===e?(n=0,r=0,t=1/e==-1/0?1:0):(t=e<0,(e=Math.abs(e))>=Math.pow(2,-1022)?(n=(i=Math.min(Math.floor(Math.log(e)/Math.LN2),1023))+1023,r=Math.round(e*Math.pow(2,52-i)-Math.pow(2,52))):(n=0,r=Math.round(e/Math.pow(2,-1074)))),s=[],o=52;o;o-=1)s.push(r%2?1:0),r=Math.floor(r/2);for(o=11;o;o-=1)s.push(n%2?1:0),n=Math.floor(n/2);s.push(t?1:0),s.reverse(),c=s.join("");var u="";for(o=0;o<64;o+=8){var l=parseInt(c.substr(o,8),2).toString(16);1===l.length&&(l="0"+l),u+=l}return u.toLowerCase()},j=new RegExp("^-?\\d{1,10}$"),M=function(e){if(j.test(e)){var t=Number(e);if(t>=-2147483648&&t<=2147483647)return t}return null},B=function(e){try{e()}catch(t){setTimeout((function(){var e=t.stack||"";throw k("Exception was thrown by user callback.",e),t}),Math.floor(0))}},F=function(){return("object"==typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},U=function(e,t){var n=setTimeout(e,t);return"object"==typeof n&&n.unref&&n.unref(),n},z=function(){function e(e,t){if(void 0===t){this.pieces_=e.split("/");for(var n=0,r=0;r0&&(this.pieces_[n]=this.pieces_[r],n++);this.pieces_.length=n,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=t}return Object.defineProperty(e,"Empty",{get:function(){return new e("")},enumerable:!0,configurable:!0}),e.prototype.getFront=function(){return this.pieceNum_>=this.pieces_.length?null:this.pieces_[this.pieceNum_]},e.prototype.getLength=function(){return this.pieces_.length-this.pieceNum_},e.prototype.popFront=function(){var t=this.pieceNum_;return t=this.pieces_.length)return null;for(var t=[],n=this.pieceNum_;n0&&n.push(i[r])}return new e(n,0)},e.prototype.isEmpty=function(){return this.pieceNum_>=this.pieces_.length},e.relativePath=function(t,n){var r=t.getFront(),i=n.getFront();if(null===r)return n;if(r===i)return e.relativePath(t.popFront(),n.popFront());throw new Error("INTERNAL ERROR: innerPath ("+n+") is not within outerPath ("+t+")")},e.comparePaths=function(e,t){for(var n=e.slice(),r=t.slice(),i=0;ie.getLength())return!1;for(;t0&&(this.byteLength_+=1),this.parts_.push(e),this.byteLength_+=a.stringLength(e),this.checkValid_()},e.prototype.pop=function(){var e=this.parts_.pop();this.byteLength_-=a.stringLength(e),this.parts_.length>0&&(this.byteLength_-=1)},e.prototype.checkValid_=function(){if(this.byteLength_>e.MAX_PATH_LENGTH_BYTES)throw new Error(this.errorPrefix_+"has a key path longer than "+e.MAX_PATH_LENGTH_BYTES+" bytes ("+this.byteLength_+").");if(this.parts_.length>e.MAX_PATH_DEPTH)throw new Error(this.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+e.MAX_PATH_DEPTH+") or object contains a cycle "+this.toErrorString())},e.prototype.toErrorString=function(){return 0==this.parts_.length?"":"in property '"+this.parts_.join(".")+"'"},e}(),q="long_polling",H=function(){function e(e,t,n,r,i,o){void 0===i&&(i=""),void 0===o&&(o=!1),this.secure=t,this.namespace=n,this.webSocketOnly=r,this.persistenceKey=i,this.includeNamespaceInQueryParams=o,this.host=e.toLowerCase(),this.domain=this.host.substr(this.host.indexOf(".")+1),this.internalHost=d.get("host:"+e)||this.host}return e.prototype.needsQueryParam=function(){return this.host!==this.internalHost||this.isCustomHost()||this.includeNamespaceInQueryParams},e.prototype.isCacheableHost=function(){return"s-"===this.internalHost.substr(0,2)},e.prototype.isDemoHost=function(){return"firebaseio-demo.com"===this.domain},e.prototype.isCustomHost=function(){return"firebaseio.com"!==this.domain&&"firebaseio-demo.com"!==this.domain},e.prototype.updateHost=function(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&d.set("host:"+this.host,this.internalHost))},e.prototype.connectionURL=function(e,t){var n;if(a.assert("string"==typeof e,"typeof type must == string"),a.assert("object"==typeof t,"typeof params must == object"),"websocket"===e)n=(this.secure?"wss://":"ws://")+this.internalHost+"/.ws?";else{if(e!==q)throw new Error("Unknown connection type: "+e);n=(this.secure?"https://":"http://")+this.internalHost+"/.lp?"}this.needsQueryParam()&&(t.ns=this.namespace);var r=[];return N(t,(function(e,t){r.push(e+"="+t)})),n+r.join("&")},e.prototype.toString=function(){var e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e},e.prototype.toURLString=function(){return(this.secure?"https://":"http://")+this.host},e}();var G,K,V=function(e){var t=W(e),n=t.namespace;"firebase"===t.domain&&S(t.host+" is no longer supported. Please use .firebaseio.com instead"),n&&"undefined"!=n||"localhost"===t.domain||S("Cannot parse Firebase url. Please use https://.firebaseio.com"),t.secure||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&k("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");var r="ws"===t.scheme||"wss"===t.scheme;return{repoInfo:new H(t.host,t.secure,n,r,"",n!=t.subdomain),path:new z(t.pathString)}},W=function(e){var t="",n="",r="",i="",a="",s=!0,c="https",u=443;if("string"==typeof e){var l=e.indexOf("//");l>=0&&(c=e.substring(0,l-1),e=e.substring(l+2));var d=e.indexOf("/");-1===d&&(d=e.length);var p=e.indexOf("?");-1===p&&(p=e.length),t=e.substring(0,Math.min(d,p)),d0){var i=n[r];try{i=decodeURIComponent(i.replace(/\+/g," "))}catch(o){}t+="/"+i}return t}(e.substring(d,p)));var h=function(e){var t,n,r={};"?"===e.charAt(0)&&(e=e.substring(1));try{for(var i=o.__values(e.split("&")),a=i.next();!a.done;a=i.next()){var s=a.value;if(0!==s.length){var c=s.split("=");2===c.length?r[decodeURIComponent(c[0])]=decodeURIComponent(c[1]):k("Invalid query segment '"+s+"' in query '"+e+"'")}}}catch(u){t={error:u}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r}(e.substring(Math.min(e.length,p)));(l=t.indexOf(":"))>=0?(s="https"===c||"wss"===c,u=parseInt(t.substring(l+1),10)):l=e.length;var f=t.split(".");3===f.length?(n=f[1],a=r=f[0].toLowerCase()):2===f.length?n=f[0]:"localhost"===f[0].slice(0,l).toLowerCase()&&(n="localhost"),"ns"in h&&(a=h.ns)}return{host:t,port:u,domain:n,subdomain:r,secure:s,scheme:c,pathString:i,namespace:a}},Y=/[\[\].#$\/\u0000-\u001F\u007F]/,J=/[\[\].#$\u0000-\u001F\u007F]/,Q=function(e){return"string"==typeof e&&0!==e.length&&!Y.test(e)},X=function(e){return"string"==typeof e&&0!==e.length&&!J.test(e)},Z=function(e){return null===e||"string"==typeof e||"number"==typeof e&&!O(e)||e&&"object"==typeof e&&a.contains(e,".sv")},ee=function(e,t,n,r,i){i&&void 0===n||te(a.errorPrefix(e,t,i),n,r)},te=function(e,t,n){var r=n instanceof z?new $(n,e):n;if(void 0===t)throw new Error(e+"contains undefined "+r.toErrorString());if("function"==typeof t)throw new Error(e+"contains a function "+r.toErrorString()+" with contents = "+t.toString());if(O(t))throw new Error(e+"contains "+t.toString()+" "+r.toErrorString());if("string"==typeof t&&t.length>10485760/3&&a.stringLength(t)>10485760)throw new Error(e+"contains a string greater than 10485760 utf8 bytes "+r.toErrorString()+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t){var i=!1,o=!1;if(N(t,(function(t,n){if(".value"===t)i=!0;else if(".priority"!==t&&".sv"!==t&&(o=!0,!Q(t)))throw new Error(e+" contains an invalid key ("+t+") "+r.toErrorString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');r.push(t),te(e,n,r),r.pop()})),i&&o)throw new Error(e+' contains ".value" child '+r.toErrorString()+" in addition to actual children.")}},ne=function(e,t,n,r,i){if(!i||void 0!==n){var o=a.errorPrefix(e,t,i);if(!n||"object"!=typeof n||Array.isArray(n))throw new Error(o+" must be an object containing the children to replace.");var s=[];N(n,(function(e,t){var n=new z(e);if(te(o,t,r.child(n)),".priority"===n.getBack()&&!Z(t))throw new Error(o+"contains an invalid value for '"+n.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");s.push(n)})),function(e,t){var n,r;for(n=0;n=0;i--)s[i]=e.charAt(r%64),r=Math.floor(r/64);a.assert(0===r,"Cannot push at time == 0");var c=s.join("");if(o){for(i=11;i>=0&&63===n[i];i--)n[i]=0;n[i]++}else for(i=0;i<12;i++)n[i]=Math.floor(64*Math.random());for(i=0;i<12;i++)c+=e.charAt(n[i]);return a.assert(20===c.length,"nextPushId: Length should be 20."),c}}(),fe=function(){function e(e,t){this.name=e,this.node=t}return e.Wrap=function(t,n){return new e(t,n)},e}(),me=function(){function e(){}return e.prototype.getCompare=function(){return this.compare.bind(this)},e.prototype.indexedValueChanged=function(e,t){var n=new fe(T,e),r=new fe(T,t);return 0!==this.compare(n,r)},e.prototype.minPost=function(){return fe.MIN},e}(),ge=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o.__extends(t,e),Object.defineProperty(t,"__EMPTY_NODE",{get:function(){return G},set:function(e){G=e},enumerable:!0,configurable:!0}),t.prototype.compare=function(e,t){return I(e.name,t.name)},t.prototype.isDefinedOn=function(e){throw a.assertionError("KeyIndex.isDefinedOn not expected to be called.")},t.prototype.indexedValueChanged=function(e,t){return!1},t.prototype.minPost=function(){return fe.MIN},t.prototype.maxPost=function(){return new fe(A,G)},t.prototype.makePost=function(e,t){return a.assert("string"==typeof e,"KeyIndex indexValue must always be a string."),new fe(e,G)},t.prototype.toString=function(){return".key"},t}(me),ye=new ge;var ve,be,Ee,we=function(e){return"number"==typeof e?"number:"+L(e):"string:"+e},_e=function(e){if(e.isLeafNode()){var t=e.val();a.assert("string"==typeof t||"number"==typeof t||"object"==typeof t&&a.contains(t,".sv"),"Priority must be a string or number.")}else a.assert(e===K||e.isEmpty(),"priority of unexpected type.");a.assert(e===K||e.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")},xe=function(){function e(t,n){void 0===n&&(n=e.__childrenNodeConstructor.EMPTY_NODE),this.value_=t,this.priorityNode_=n,this.lazyHash_=null,a.assert(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),_e(this.priorityNode_)}return Object.defineProperty(e,"__childrenNodeConstructor",{get:function(){return ve},set:function(e){ve=e},enumerable:!0,configurable:!0}),e.prototype.isLeafNode=function(){return!0},e.prototype.getPriority=function(){return this.priorityNode_},e.prototype.updatePriority=function(t){return new e(this.value_,t)},e.prototype.getImmediateChild=function(t){return".priority"===t?this.priorityNode_:e.__childrenNodeConstructor.EMPTY_NODE},e.prototype.getChild=function(t){return t.isEmpty()?this:".priority"===t.getFront()?this.priorityNode_:e.__childrenNodeConstructor.EMPTY_NODE},e.prototype.hasChild=function(){return!1},e.prototype.getPredecessorChildName=function(e,t){return null},e.prototype.updateImmediateChild=function(t,n){return".priority"===t?this.updatePriority(n):n.isEmpty()&&".priority"!==t?this:e.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(t,n).updatePriority(this.priorityNode_)},e.prototype.updateChild=function(t,n){var r=t.getFront();return null===r?n:n.isEmpty()&&".priority"!==r?this:(a.assert(".priority"!==r||1===t.getLength(),".priority must be the last token in a path"),this.updateImmediateChild(r,e.__childrenNodeConstructor.EMPTY_NODE.updateChild(t.popFront(),n)))},e.prototype.isEmpty=function(){return!1},e.prototype.numChildren=function(){return 0},e.prototype.forEachChild=function(e,t){return!1},e.prototype.val=function(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()},e.prototype.hash=function(){if(null===this.lazyHash_){var e="";this.priorityNode_.isEmpty()||(e+="priority:"+we(this.priorityNode_.val())+":");var t=typeof this.value_;e+=t+":",e+="number"===t?L(this.value_):this.value_,this.lazyHash_=g(e)}return this.lazyHash_},e.prototype.getValue=function(){return this.value_},e.prototype.compareTo=function(t){return t===e.__childrenNodeConstructor.EMPTY_NODE?1:t instanceof e.__childrenNodeConstructor?-1:(a.assert(t.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(t))},e.prototype.compareToLeafNode_=function(t){var n=typeof t.value_,r=typeof this.value_,i=e.VALUE_TYPE_ORDER.indexOf(n),o=e.VALUE_TYPE_ORDER.indexOf(r);return a.assert(i>=0,"Unknown leaf type: "+n),a.assert(o>=0,"Unknown leaf type: "+r),i===o?"object"===r?0:this.value_0},e.prototype.peek=function(){if(0===this.nodeStack_.length)return null;var e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}},e}(),Ae=function(){function e(t,n,r,i,o){this.key=t,this.value=n,this.color=null!=r?r:e.RED,this.left=null!=i?i:De.EMPTY_NODE,this.right=null!=o?o:De.EMPTY_NODE}return e.prototype.copy=function(t,n,r,i,o){return new e(null!=t?t:this.key,null!=n?n:this.value,null!=r?r:this.color,null!=i?i:this.left,null!=o?o:this.right)},e.prototype.count=function(){return this.left.count()+1+this.right.count()},e.prototype.isEmpty=function(){return!1},e.prototype.inorderTraversal=function(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)},e.prototype.reverseTraversal=function(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)},e.prototype.min_=function(){return this.left.isEmpty()?this:this.left.min_()},e.prototype.minKey=function(){return this.min_().key},e.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},e.prototype.insert=function(e,t,n){var r,i;return(i=(r=n(e,(i=this).key))<0?i.copy(null,null,null,i.left.insert(e,t,n),null):0===r?i.copy(null,t,null,null,null):i.copy(null,null,null,null,i.right.insert(e,t,n))).fixUp_()},e.prototype.removeMin_=function(){if(this.left.isEmpty())return De.EMPTY_NODE;var e=this;return e.left.isRed_()||e.left.left.isRed_()||(e=e.moveRedLeft_()),(e=e.copy(null,null,null,e.left.removeMin_(),null)).fixUp_()},e.prototype.remove=function(e,t){var n,r;if(t(e,(n=this).key)<0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed_()&&(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===t(e,n.key)){if(n.right.isEmpty())return De.EMPTY_NODE;r=n.right.min_(),n=n.copy(r.key,r.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.fixUp_()},e.prototype.isRed_=function(){return this.color},e.prototype.fixUp_=function(){var e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e},e.prototype.moveRedLeft_=function(){var e=this.colorFlip_();return e.right.left.isRed_()&&(e=(e=(e=e.copy(null,null,null,null,e.right.rotateRight_())).rotateLeft_()).colorFlip_()),e},e.prototype.moveRedRight_=function(){var e=this.colorFlip_();return e.left.left.isRed_()&&(e=(e=e.rotateRight_()).colorFlip_()),e},e.prototype.rotateLeft_=function(){var t=this.copy(null,null,e.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},e.prototype.rotateRight_=function(){var t=this.copy(null,null,e.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},e.prototype.colorFlip_=function(){var e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)},e.prototype.checkMaxDepth_=function(){var e=this.check_();return Math.pow(2,e)<=this.count()+1},e.prototype.check_=function(){var e;if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");if((e=this.left.check_())!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)},e.RED=!0,e.BLACK=!1,e}(),Ie=function(){function e(){}return e.prototype.copy=function(e,t,n,r,i){return this},e.prototype.insert=function(e,t,n){return new Ae(e,t,null)},e.prototype.remove=function(e,t){return this},e.prototype.count=function(){return 0},e.prototype.isEmpty=function(){return!0},e.prototype.inorderTraversal=function(e){return!1},e.prototype.reverseTraversal=function(e){return!1},e.prototype.minKey=function(){return null},e.prototype.maxKey=function(){return null},e.prototype.check_=function(){return 0},e.prototype.isRed_=function(){return!1},e}(),De=function(){function e(t,n){void 0===n&&(n=e.EMPTY_NODE),this.comparator_=t,this.root_=n}return e.prototype.insert=function(t,n){return new e(this.comparator_,this.root_.insert(t,n,this.comparator_).copy(null,null,Ae.BLACK,null,null))},e.prototype.remove=function(t){return new e(this.comparator_,this.root_.remove(t,this.comparator_).copy(null,null,Ae.BLACK,null,null))},e.prototype.get=function(e){for(var t,n=this.root_;!n.isEmpty();){if(0===(t=this.comparator_(e,n.key)))return n.value;t<0?n=n.left:t>0&&(n=n.right)}return null},e.prototype.getPredecessorKey=function(e){for(var t,n=this.root_,r=null;!n.isEmpty();){if(0===(t=this.comparator_(e,n.key))){if(n.left.isEmpty())return r?r.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}t<0?n=n.left:t>0&&(r=n,n=n.right)}throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")},e.prototype.isEmpty=function(){return this.root_.isEmpty()},e.prototype.count=function(){return this.root_.count()},e.prototype.minKey=function(){return this.root_.minKey()},e.prototype.maxKey=function(){return this.root_.maxKey()},e.prototype.inorderTraversal=function(e){return this.root_.inorderTraversal(e)},e.prototype.reverseTraversal=function(e){return this.root_.reverseTraversal(e)},e.prototype.getIterator=function(e){return new Te(this.root_,null,this.comparator_,!1,e)},e.prototype.getIteratorFrom=function(e,t){return new Te(this.root_,e,this.comparator_,!1,t)},e.prototype.getReverseIteratorFrom=function(e,t){return new Te(this.root_,e,this.comparator_,!0,t)},e.prototype.getReverseIterator=function(e){return new Te(this.root_,null,this.comparator_,!0,e)},e.EMPTY_NODE=new Ie,e}(),Ce=Math.log(2),Pe=function(){function e(e){var t;this.count=(t=e+1,parseInt(Math.log(t)/Ce,10)),this.current_=this.count-1;var n,r=(n=this.count,parseInt(Array(n+1).join("1"),2));this.bits_=e+1&r}return e.prototype.nextBitIsOne=function(){var e=!(this.bits_&1<0;)r.getNext(),i=r.peek();return r},e.prototype.compareTo=function(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===Fe?-1:0},e.prototype.withIndex=function(t){if(t===ye||this.indexMap_.hasIndex(t))return this;var n=this.indexMap_.addIndex(t,this.children_);return new e(this.children_,this.priorityNode_,n)},e.prototype.isIndexed=function(e){return e===ye||this.indexMap_.hasIndex(e)},e.prototype.equals=function(e){if(e===this)return!0;if(e.isLeafNode())return!1;var t=e;if(this.getPriority().equals(t.getPriority())){if(this.children_.count()===t.children_.count()){for(var n=this.getIterator(Oe),r=t.getIterator(Oe),i=n.getNext(),o=r.getNext();i&&o;){if(i.name!==o.name||!i.node.equals(o.node))return!1;i=n.getNext(),o=r.getNext()}return null===i&&null===o}return!1}return!1},e.prototype.resolveIndex_=function(e){return e===ye?null:this.indexMap_.get(e.toString())},e.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/,e}(),Fe=new(function(e){function t(){return e.call(this,new De(Me),Be.EMPTY_NODE,Le.Default)||this}return o.__extends(t,e),t.prototype.compareTo=function(e){return e===this?0:1},t.prototype.equals=function(e){return e===this},t.prototype.getPriority=function(){return this},t.prototype.getImmediateChild=function(e){return Be.EMPTY_NODE},t.prototype.isEmpty=function(){return!1},t}(Be));Object.defineProperties(fe,{MIN:{value:new fe(T,Be.EMPTY_NODE)},MAX:{value:new fe(A,Fe)}}),ge.__EMPTY_NODE=Be.EMPTY_NODE,xe.__childrenNodeConstructor=Be,function(e){K=e}(Fe),function(e){Ee=e}(Fe);var Ue=!0;function ze(e,t){if(void 0===t&&(t=null),null===e)return Be.EMPTY_NODE;if("object"==typeof e&&".priority"in e&&(t=e[".priority"]),a.assert(null===t||"string"==typeof t||"number"==typeof t||"object"==typeof t&&".sv"in t,"Invalid priority type found: "+typeof t),"object"==typeof e&&".value"in e&&null!==e[".value"]&&(e=e[".value"]),"object"!=typeof e||".sv"in e)return new xe(e,ze(t));if(e instanceof Array||!Ue){var n=Be.EMPTY_NODE;return N(e,(function(t,r){if(a.contains(e,t)&&"."!==t.substring(0,1)){var i=ze(r);!i.isLeafNode()&&i.isEmpty()||(n=n.updateImmediateChild(t,i))}})),n.updatePriority(ze(t))}var r=[],i=!1;if(N(e,(function(e,t){if("."!==e.substring(0,1)){var n=ze(t);n.isEmpty()||(i=i||!n.getPriority().isEmpty(),r.push(new fe(e,n)))}})),0==r.length)return Be.EMPTY_NODE;var o=Re(r,je,(function(e){return e.name}),Me);if(i){var s=Re(r,Oe.getCompare());return new Be(o,ze(t),new Le({".priority":s},{".priority":Oe}))}return new Be(o,ze(t),Le.Default)}!function(e){be=e}(ze);var $e,qe,He=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o.__extends(t,e),t.prototype.compare=function(e,t){var n=e.node.compareTo(t.node);return 0===n?I(e.name,t.name):n},t.prototype.isDefinedOn=function(e){return!0},t.prototype.indexedValueChanged=function(e,t){return!e.equals(t)},t.prototype.minPost=function(){return fe.MIN},t.prototype.maxPost=function(){return fe.MAX},t.prototype.makePost=function(e,t){var n=ze(e);return new fe(t,n)},t.prototype.toString=function(){return".value"},t}(me)),Ge=function(e){function t(t){var n=e.call(this)||this;return n.indexPath_=t,a.assert(!t.isEmpty()&&".priority"!==t.getFront(),"Can't create PathIndex with empty path or .priority key"),n}return o.__extends(t,e),t.prototype.extractChild=function(e){return e.getChild(this.indexPath_)},t.prototype.isDefinedOn=function(e){return!e.getChild(this.indexPath_).isEmpty()},t.prototype.compare=function(e,t){var n=this.extractChild(e.node),r=this.extractChild(t.node),i=n.compareTo(r);return 0===i?I(e.name,t.name):i},t.prototype.makePost=function(e,t){var n=ze(e),r=Be.EMPTY_NODE.updateChild(this.indexPath_,n);return new fe(t,r)},t.prototype.maxPost=function(){var e=Be.EMPTY_NODE.updateChild(this.indexPath_,Fe);return new fe(A,e)},t.prototype.toString=function(){return this.indexPath_.slice().join("/")},t}(me),Ke=function(){function e(e,t,n){this.node_=e,this.ref_=t,this.index_=n}return e.prototype.val=function(){return a.validateArgCount("DataSnapshot.val",0,0,arguments.length),this.node_.val()},e.prototype.exportVal=function(){return a.validateArgCount("DataSnapshot.exportVal",0,0,arguments.length),this.node_.val(!0)},e.prototype.toJSON=function(){return a.validateArgCount("DataSnapshot.toJSON",0,1,arguments.length),this.exportVal()},e.prototype.exists=function(){return a.validateArgCount("DataSnapshot.exists",0,0,arguments.length),!this.node_.isEmpty()},e.prototype.child=function(t){a.validateArgCount("DataSnapshot.child",0,1,arguments.length),t=String(t),ae("DataSnapshot.child",1,t,!1);var n=new z(t),r=this.ref_.child(n);return new e(this.node_.getChild(n),r,Oe)},e.prototype.hasChild=function(e){a.validateArgCount("DataSnapshot.hasChild",1,1,arguments.length),ae("DataSnapshot.hasChild",1,e,!1);var t=new z(e);return!this.node_.getChild(t).isEmpty()},e.prototype.getPriority=function(){return a.validateArgCount("DataSnapshot.getPriority",0,0,arguments.length),this.node_.getPriority().val()},e.prototype.forEach=function(t){var n=this;if(a.validateArgCount("DataSnapshot.forEach",1,1,arguments.length),a.validateCallback("DataSnapshot.forEach",1,t,!1),this.node_.isLeafNode())return!1;var r=this.node_;return!!r.forEachChild(this.index_,(function(r,i){return t(new e(i,n.ref_.child(r),Oe))}))},e.prototype.hasChildren=function(){return a.validateArgCount("DataSnapshot.hasChildren",0,0,arguments.length),!this.node_.isLeafNode()&&!this.node_.isEmpty()},Object.defineProperty(e.prototype,"key",{get:function(){return this.ref_.getKey()},enumerable:!0,configurable:!0}),e.prototype.numChildren=function(){return a.validateArgCount("DataSnapshot.numChildren",0,0,arguments.length),this.node_.numChildren()},e.prototype.getRef=function(){return a.validateArgCount("DataSnapshot.ref",0,0,arguments.length),this.ref_},Object.defineProperty(e.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),e}(),Ve=function(){function e(e,t,n,r){this.eventType=e,this.eventRegistration=t,this.snapshot=n,this.prevName=r}return e.prototype.getPath=function(){var e=this.snapshot.getRef();return"value"===this.eventType?e.path:e.getParent().path},e.prototype.getEventType=function(){return this.eventType},e.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},e.prototype.toString=function(){return this.getPath().toString()+":"+this.eventType+":"+a.stringify(this.snapshot.exportVal())},e}(),We=function(){function e(e,t,n){this.eventRegistration=e,this.error=t,this.path=n}return e.prototype.getPath=function(){return this.path},e.prototype.getEventType=function(){return"cancel"},e.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},e.prototype.toString=function(){return this.path.toString()+":cancel"},e}(),Ye=function(){function e(e,t,n){this.callback_=e,this.cancelCallback_=t,this.context_=n}return e.prototype.respondsTo=function(e){return"value"===e},e.prototype.createEvent=function(e,t){var n=t.getQueryParams().getIndex();return new Ve("value",this,new Ke(e.snapshotNode,t.getRef(),n))},e.prototype.getEventRunner=function(e){var t=this.context_;if("cancel"===e.getEventType()){a.assert(this.cancelCallback_,"Raising a cancel event on a listener with no cancel callback");var n=this.cancelCallback_;return function(){n.call(t,e.error)}}var r=this.callback_;return function(){r.call(t,e.snapshot)}},e.prototype.createCancelEvent=function(e,t){return this.cancelCallback_?new We(this,e,t):null},e.prototype.matches=function(t){return t instanceof e&&(!t.callback_||!this.callback_||t.callback_===this.callback_&&t.context_===this.context_)},e.prototype.hasAnyCallback=function(){return null!==this.callback_},e}(),Je=function(){function e(e,t,n){this.callbacks_=e,this.cancelCallback_=t,this.context_=n}return e.prototype.respondsTo=function(e){var t="children_added"===e?"child_added":e;return t="children_removed"===t?"child_removed":t,a.contains(this.callbacks_,t)},e.prototype.createCancelEvent=function(e,t){return this.cancelCallback_?new We(this,e,t):null},e.prototype.createEvent=function(e,t){a.assert(null!=e.childName,"Child events should have a childName.");var n=t.getRef().child(e.childName),r=t.getQueryParams().getIndex();return new Ve(e.type,this,new Ke(e.snapshotNode,n,r),e.prevName)},e.prototype.getEventRunner=function(e){var t=this.context_;if("cancel"===e.getEventType()){a.assert(this.cancelCallback_,"Raising a cancel event on a listener with no cancel callback");var n=this.cancelCallback_;return function(){n.call(t,e.error)}}var r=this.callbacks_[e.eventType];return function(){r.call(t,e.snapshot,e.prevName)}},e.prototype.matches=function(t){var n=this;if(t instanceof e){if(!this.callbacks_||!t.callbacks_)return!0;if(this.context_===t.context_){var r=Object.keys(t.callbacks_),i=Object.keys(this.callbacks_),o=r.length;if(o===i.length){if(1===o){var a=r[0],s=i[0];return!(s!==a||t.callbacks_[a]&&this.callbacks_[s]&&t.callbacks_[a]!==this.callbacks_[s])}return i.every((function(e){return t.callbacks_[e]===n.callbacks_[e]}))}}}return!1},e.prototype.hasAnyCallback=function(){return null!==this.callbacks_},e}(),Qe=function(){function e(e,t,n,r){this.repo=e,this.path=t,this.queryParams_=n,this.orderByCalled_=r}return Object.defineProperty(e,"__referenceConstructor",{get:function(){return a.assert($e,"Reference.ts has not been loaded"),$e},set:function(e){$e=e},enumerable:!0,configurable:!0}),e.validateQueryEndpoints_=function(e){var t=null,n=null;if(e.hasStart()&&(t=e.getIndexStartValue()),e.hasEnd()&&(n=e.getIndexEndValue()),e.getIndex()===ye){var r="Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().",i="Query: When ordering by key, the argument passed to startAt(), endAt(),or equalTo() must be a string.";if(e.hasStart()){if(e.getIndexStartName()!=T)throw new Error(r);if("string"!=typeof t)throw new Error(i)}if(e.hasEnd()){if(e.getIndexEndName()!=A)throw new Error(r);if("string"!=typeof n)throw new Error(i)}}else if(e.getIndex()===Oe){if(null!=t&&!Z(t)||null!=n&&!Z(n))throw new Error("Query: When ordering by priority, the first argument passed to startAt(), endAt(), or equalTo() must be a valid priority value (null, a number, or a string).")}else if(a.assert(e.getIndex()instanceof Ge||e.getIndex()===He,"unknown index type."),null!=t&&"object"==typeof t||null!=n&&"object"==typeof n)throw new Error("Query: First argument passed to startAt(), endAt(), or equalTo() cannot be an object.")},e.validateLimit_=function(e){if(e.hasStart()&&e.hasEnd()&&e.hasLimit()&&!e.hasAnchoredLimit())throw new Error("Query: Can't combine startAt(), endAt(), and limit(). Use limitToFirst() or limitToLast() instead.")},e.prototype.validateNoPreviousOrderByCall_=function(e){if(!0===this.orderByCalled_)throw new Error(e+": You can't combine multiple orderBy calls.")},e.prototype.getQueryParams=function(){return this.queryParams_},e.prototype.getRef=function(){return a.validateArgCount("Query.ref",0,0,arguments.length),new e.__referenceConstructor(this.repo,this.path)},e.prototype.on=function(t,n,r,i){a.validateArgCount("Query.on",2,4,arguments.length),ie("Query.on",1,t,!1),a.validateCallback("Query.on",2,n,!1);var o=e.getCancelAndContextArgs_("Query.on",r,i);if("value"===t)this.onValueEvent(n,o.cancel,o.context);else{var s={};s[t]=n,this.onChildEvent(s,o.cancel,o.context)}return n},e.prototype.onValueEvent=function(e,t,n){var r=new Ye(e,t||null,n||null);this.repo.addEventCallbackForQuery(this,r)},e.prototype.onChildEvent=function(e,t,n){var r=new Je(e,t,n);this.repo.addEventCallbackForQuery(this,r)},e.prototype.off=function(e,t,n){a.validateArgCount("Query.off",0,3,arguments.length),ie("Query.off",1,e,!0),a.validateCallback("Query.off",2,t,!0),a.validateContextObject("Query.off",3,n,!0);var r=null,i=null;if("value"===e){var o=t||null;r=new Ye(o,null,n||null)}else e&&(t&&((i={})[e]=t),r=new Je(i,null,n||null));this.repo.removeEventCallbackForQuery(this,r)},e.prototype.once=function(t,n,r,i){var o=this;a.validateArgCount("Query.once",1,4,arguments.length),ie("Query.once",1,t,!1),a.validateCallback("Query.once",2,n,!0);var s=e.getCancelAndContextArgs_("Query.once",r,i),c=!0,u=new a.Deferred;u.promise.catch((function(){}));var l=function(e){c&&(c=!1,o.off(t,l),n&&n.bind(s.context)(e),u.resolve(e))};return this.on(t,l,(function(e){o.off(t,l),s.cancel&&s.cancel.bind(s.context)(e),u.reject(e)})),u.promise},e.prototype.limitToFirst=function(t){if(a.validateArgCount("Query.limitToFirst",1,1,arguments.length),"number"!=typeof t||Math.floor(t)!==t||t<=0)throw new Error("Query.limitToFirst: First argument must be a positive integer.");if(this.queryParams_.hasLimit())throw new Error("Query.limitToFirst: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new e(this.repo,this.path,this.queryParams_.limitToFirst(t),this.orderByCalled_)},e.prototype.limitToLast=function(t){if(a.validateArgCount("Query.limitToLast",1,1,arguments.length),"number"!=typeof t||Math.floor(t)!==t||t<=0)throw new Error("Query.limitToLast: First argument must be a positive integer.");if(this.queryParams_.hasLimit())throw new Error("Query.limitToLast: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new e(this.repo,this.path,this.queryParams_.limitToLast(t),this.orderByCalled_)},e.prototype.orderByChild=function(t){if(a.validateArgCount("Query.orderByChild",1,1,arguments.length),"$key"===t)throw new Error('Query.orderByChild: "$key" is invalid. Use Query.orderByKey() instead.');if("$priority"===t)throw new Error('Query.orderByChild: "$priority" is invalid. Use Query.orderByPriority() instead.');if("$value"===t)throw new Error('Query.orderByChild: "$value" is invalid. Use Query.orderByValue() instead.');ae("Query.orderByChild",1,t,!1),this.validateNoPreviousOrderByCall_("Query.orderByChild");var n=new z(t);if(n.isEmpty())throw new Error("Query.orderByChild: cannot pass in empty path. Use Query.orderByValue() instead.");var r=new Ge(n),i=this.queryParams_.orderBy(r);return e.validateQueryEndpoints_(i),new e(this.repo,this.path,i,!0)},e.prototype.orderByKey=function(){a.validateArgCount("Query.orderByKey",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByKey");var t=this.queryParams_.orderBy(ye);return e.validateQueryEndpoints_(t),new e(this.repo,this.path,t,!0)},e.prototype.orderByPriority=function(){a.validateArgCount("Query.orderByPriority",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByPriority");var t=this.queryParams_.orderBy(Oe);return e.validateQueryEndpoints_(t),new e(this.repo,this.path,t,!0)},e.prototype.orderByValue=function(){a.validateArgCount("Query.orderByValue",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByValue");var t=this.queryParams_.orderBy(He);return e.validateQueryEndpoints_(t),new e(this.repo,this.path,t,!0)},e.prototype.startAt=function(t,n){void 0===t&&(t=null),a.validateArgCount("Query.startAt",0,2,arguments.length),ee("Query.startAt",1,t,this.path,!0),oe("Query.startAt",2,n,!0);var r=this.queryParams_.startAt(t,n);if(e.validateLimit_(r),e.validateQueryEndpoints_(r),this.queryParams_.hasStart())throw new Error("Query.startAt: Starting point was already set (by another call to startAt or equalTo).");return void 0===t&&(t=null,n=null),new e(this.repo,this.path,r,this.orderByCalled_)},e.prototype.endAt=function(t,n){void 0===t&&(t=null),a.validateArgCount("Query.endAt",0,2,arguments.length),ee("Query.endAt",1,t,this.path,!0),oe("Query.endAt",2,n,!0);var r=this.queryParams_.endAt(t,n);if(e.validateLimit_(r),e.validateQueryEndpoints_(r),this.queryParams_.hasEnd())throw new Error("Query.endAt: Ending point was already set (by another call to endAt or equalTo).");return new e(this.repo,this.path,r,this.orderByCalled_)},e.prototype.equalTo=function(e,t){if(a.validateArgCount("Query.equalTo",1,2,arguments.length),ee("Query.equalTo",1,e,this.path,!1),oe("Query.equalTo",2,t,!0),this.queryParams_.hasStart())throw new Error("Query.equalTo: Starting point was already set (by another call to startAt or equalTo).");if(this.queryParams_.hasEnd())throw new Error("Query.equalTo: Ending point was already set (by another call to endAt or equalTo).");return this.startAt(e,t).endAt(e,t)},e.prototype.toString=function(){return a.validateArgCount("Query.toString",0,0,arguments.length),this.repo.toString()+this.path.toUrlEncodedString()},e.prototype.toJSON=function(){return a.validateArgCount("Query.toJSON",0,1,arguments.length),this.toString()},e.prototype.queryObject=function(){return this.queryParams_.getQueryObject()},e.prototype.queryIdentifier=function(){var e=this.queryObject(),t=P(e);return"{}"===t?"default":t},e.prototype.isEqual=function(t){if(a.validateArgCount("Query.isEqual",1,1,arguments.length),!(t instanceof e)){var n="Query.isEqual failed: First argument must be an instance of firebase.database.Query.";throw new Error(n)}var r=this.repo===t.repo,i=this.path.equals(t.path),o=this.queryIdentifier()===t.queryIdentifier();return r&&i&&o},e.getCancelAndContextArgs_=function(e,t,n){var r={cancel:null,context:null};if(t&&n)r.cancel=t,a.validateCallback(e,3,r.cancel,!0),r.context=n,a.validateContextObject(e,4,r.context,!0);else if(t)if("object"==typeof t&&null!==t)r.context=t;else{if("function"!=typeof t)throw new Error(a.errorPrefix(e,3,!0)+" must either be a cancel callback or a context object.");r.cancel=t}return r},Object.defineProperty(e.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),e}(),Xe=function(){function e(){this.value=null,this.children=new Map}return e.prototype.find=function(e){if(null!=this.value)return this.value.getChild(e);if(!e.isEmpty()&&this.children.size>0){var t=e.getFront();return e=e.popFront(),this.children.has(t)?this.children.get(t).find(e):null}return null},e.prototype.remember=function(t,n){if(t.isEmpty())this.value=n,this.children.clear();else if(null!==this.value)this.value=this.value.updateChild(t,n);else{var r=t.getFront();this.children.has(r)||this.children.set(r,new e);var i=this.children.get(r);t=t.popFront(),i.remember(t,n)}},e.prototype.forget=function(e){if(e.isEmpty())return this.value=null,this.children.clear(),!0;if(null!==this.value){if(this.value.isLeafNode())return!1;var t=this.value;this.value=null;var n=this;return t.forEachChild(Oe,(function(e,t){n.remember(new z(e),t)})),this.forget(e)}if(this.children.size>0){var r=e.getFront();if(e=e.popFront(),this.children.has(r))this.children.get(r).forget(e)&&this.children.delete(r);return 0===this.children.size}return!0},e.prototype.forEachTree=function(e,t){null!==this.value?t(e,this.value):this.forEachChild((function(n,r){var i=new z(e.toString()+"/"+n);r.forEachTree(i,t)}))},e.prototype.forEachChild=function(e){this.children.forEach((function(t,n){e(n,t)}))},e}(),Ze=function(e,t){return e&&"object"==typeof e?(a.assert(".sv"in e,"Unexpected leaf node or priority contents"),t[e[".sv"]]):e},et=function(e,t){var n,r=e.getPriority().val(),i=Ze(r,t);if(e.isLeafNode()){var o=e,a=Ze(o.getValue(),t);return a!==o.getValue()||i!==o.getPriority().val()?new xe(a,ze(i)):e}var s=e;return n=s,i!==s.getPriority().val()&&(n=n.updatePriority(new xe(i))),s.forEachChild(Oe,(function(e,r){var i=et(r,t);i!==r&&(n=n.updateImmediateChild(e,i))})),n};!function(e){e[e.OVERWRITE=0]="OVERWRITE",e[e.MERGE=1]="MERGE",e[e.ACK_USER_WRITE=2]="ACK_USER_WRITE",e[e.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(qe||(qe={}));var tt,nt,rt=function(){function e(e,t,n,r){this.fromUser=e,this.fromServer=t,this.queryId=n,this.tagged=r,a.assert(!r||t,"Tagged queries must be from server.")}return e.User=new e(!0,!1,null,!1),e.Server=new e(!1,!0,null,!1),e.forServerTaggedQuery=function(t){return new e(!1,!0,t,!0)},e}(),it=function(){function e(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=qe.ACK_USER_WRITE,this.source=rt.User}return e.prototype.operationForChild=function(t){if(this.path.isEmpty()){if(null!=this.affectedTree.value)return a.assert(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;var n=this.affectedTree.subtree(new z(t));return new e(z.Empty,n,this.revert)}return a.assert(this.path.getFront()===t,"operationForChild called for unrelated child."),new e(this.path.popFront(),this.affectedTree,this.revert)},e}(),ot=function(){return tt||(tt=new De(D)),tt},at=function(){function e(e,t){void 0===t&&(t=ot()),this.value=e,this.children=t}return e.fromObject=function(t){var n=e.Empty;return N(t,(function(e,t){n=n.set(new z(e),t)})),n},e.prototype.isEmpty=function(){return null===this.value&&this.children.isEmpty()},e.prototype.findRootMostMatchingPathAndValue=function(e,t){if(null!=this.value&&t(this.value))return{path:z.Empty,value:this.value};if(e.isEmpty())return null;var n=e.getFront(),r=this.children.get(n);if(null!==r){var i=r.findRootMostMatchingPathAndValue(e.popFront(),t);return null!=i?{path:new z(n).child(i.path),value:i.value}:null}return null},e.prototype.findRootMostValueAndPath=function(e){return this.findRootMostMatchingPathAndValue(e,(function(){return!0}))},e.prototype.subtree=function(t){if(t.isEmpty())return this;var n=t.getFront(),r=this.children.get(n);return null!==r?r.subtree(t.popFront()):e.Empty},e.prototype.set=function(t,n){if(t.isEmpty())return new e(n,this.children);var r=t.getFront(),i=(this.children.get(r)||e.Empty).set(t.popFront(),n),o=this.children.insert(r,i);return new e(this.value,o)},e.prototype.remove=function(t){if(t.isEmpty())return this.children.isEmpty()?e.Empty:new e(null,this.children);var n=t.getFront(),r=this.children.get(n);if(r){var i=r.remove(t.popFront()),o=void 0;return o=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),null===this.value&&o.isEmpty()?e.Empty:new e(this.value,o)}return this},e.prototype.get=function(e){if(e.isEmpty())return this.value;var t=e.getFront(),n=this.children.get(t);return n?n.get(e.popFront()):null},e.prototype.setTree=function(t,n){if(t.isEmpty())return n;var r=t.getFront(),i=(this.children.get(r)||e.Empty).setTree(t.popFront(),n),o=void 0;return o=i.isEmpty()?this.children.remove(r):this.children.insert(r,i),new e(this.value,o)},e.prototype.fold=function(e){return this.fold_(z.Empty,e)},e.prototype.fold_=function(e,t){var n={};return this.children.inorderTraversal((function(r,i){n[r]=i.fold_(e.child(r),t)})),t(e,this.value,n)},e.prototype.findOnPath=function(e,t){return this.findOnPath_(e,z.Empty,t)},e.prototype.findOnPath_=function(e,t,n){var r=!!this.value&&n(t,this.value);if(r)return r;if(e.isEmpty())return null;var i=e.getFront(),o=this.children.get(i);return o?o.findOnPath_(e.popFront(),t.child(i),n):null},e.prototype.foreachOnPath=function(e,t){return this.foreachOnPath_(e,z.Empty,t)},e.prototype.foreachOnPath_=function(t,n,r){if(t.isEmpty())return this;this.value&&r(n,this.value);var i=t.getFront(),o=this.children.get(i);return o?o.foreachOnPath_(t.popFront(),n.child(i),r):e.Empty},e.prototype.foreach=function(e){this.foreach_(z.Empty,e)},e.prototype.foreach_=function(e,t){this.children.inorderTraversal((function(n,r){r.foreach_(e.child(n),t)})),this.value&&t(e,this.value)},e.prototype.foreachChild=function(e){this.children.inorderTraversal((function(t,n){n.value&&e(t,n.value)}))},e.Empty=new e(null),e}(),st=function(){function e(e,t){this.source=e,this.path=t,this.type=qe.LISTEN_COMPLETE}return e.prototype.operationForChild=function(t){return this.path.isEmpty()?new e(this.source,z.Empty):new e(this.source,this.path.popFront())},e}(),ct=function(){function e(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=qe.OVERWRITE}return e.prototype.operationForChild=function(t){return this.path.isEmpty()?new e(this.source,z.Empty,this.snap.getImmediateChild(t)):new e(this.source,this.path.popFront(),this.snap)},e}(),ut=function(){function e(e,t,n){this.source=e,this.path=t,this.children=n,this.type=qe.MERGE}return e.prototype.operationForChild=function(t){if(this.path.isEmpty()){var n=this.children.subtree(new z(t));return n.isEmpty()?null:n.value?new ct(this.source,z.Empty,n.value):new e(this.source,z.Empty,n)}return a.assert(this.path.getFront()===t,"Can't get a merge for a child not on the path of the operation"),new e(this.source,this.path.popFront(),this.children)},e.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"},e}(),lt=function(){function e(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}return e.prototype.isFullyInitialized=function(){return this.fullyInitialized_},e.prototype.isFiltered=function(){return this.filtered_},e.prototype.isCompleteForPath=function(e){if(e.isEmpty())return this.isFullyInitialized()&&!this.filtered_;var t=e.getFront();return this.isCompleteForChild(t)},e.prototype.isCompleteForChild=function(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)},e.prototype.getNode=function(){return this.node_},e}(),dt=function(){function e(e,t){this.eventCache_=e,this.serverCache_=t}return e.prototype.updateEventSnap=function(t,n,r){return new e(new lt(t,n,r),this.serverCache_)},e.prototype.updateServerSnap=function(t,n,r){return new e(this.eventCache_,new lt(t,n,r))},e.prototype.getEventCache=function(){return this.eventCache_},e.prototype.getCompleteEventSnap=function(){return this.eventCache_.isFullyInitialized()?this.eventCache_.getNode():null},e.prototype.getServerCache=function(){return this.serverCache_},e.prototype.getCompleteServerSnap=function(){return this.serverCache_.isFullyInitialized()?this.serverCache_.getNode():null},e.Empty=new e(new lt(Be.EMPTY_NODE,!1,!1),new lt(Be.EMPTY_NODE,!1,!1)),e}(),pt=function(){function e(e,t,n,r,i){this.type=e,this.snapshotNode=t,this.childName=n,this.oldSnap=r,this.prevName=i}return e.valueChange=function(t){return new e(e.VALUE,t)},e.childAddedChange=function(t,n){return new e(e.CHILD_ADDED,n,t)},e.childRemovedChange=function(t,n){return new e(e.CHILD_REMOVED,n,t)},e.childChangedChange=function(t,n,r){return new e(e.CHILD_CHANGED,n,t,r)},e.childMovedChange=function(t,n){return new e(e.CHILD_MOVED,n,t)},e.CHILD_ADDED="child_added",e.CHILD_REMOVED="child_removed",e.CHILD_CHANGED="child_changed",e.CHILD_MOVED="child_moved",e.VALUE="value",e}(),ht=function(){function e(e){this.index_=e}return e.prototype.updateChild=function(e,t,n,r,i,o){a.assert(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");var s=e.getImmediateChild(t);return s.getChild(r).equals(n.getChild(r))&&s.isEmpty()==n.isEmpty()?e:(null!=o&&(n.isEmpty()?e.hasChild(t)?o.trackChildChange(pt.childRemovedChange(t,s)):a.assert(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):s.isEmpty()?o.trackChildChange(pt.childAddedChange(t,n)):o.trackChildChange(pt.childChangedChange(t,n,s))),e.isLeafNode()&&n.isEmpty()?e:e.updateImmediateChild(t,n).withIndex(this.index_))},e.prototype.updateFullNode=function(e,t,n){return null!=n&&(e.isLeafNode()||e.forEachChild(Oe,(function(e,r){t.hasChild(e)||n.trackChildChange(pt.childRemovedChange(e,r))})),t.isLeafNode()||t.forEachChild(Oe,(function(t,r){if(e.hasChild(t)){var i=e.getImmediateChild(t);i.equals(r)||n.trackChildChange(pt.childChangedChange(t,r,i))}else n.trackChildChange(pt.childAddedChange(t,r))}))),t.withIndex(this.index_)},e.prototype.updatePriority=function(e,t){return e.isEmpty()?Be.EMPTY_NODE:e.updatePriority(t)},e.prototype.filtersNodes=function(){return!1},e.prototype.getIndexedFilter=function(){return this},e.prototype.getIndex=function(){return this.index_},e}(),ft=function(){function e(){this.changeMap=new Map}return e.prototype.trackChildChange=function(e){var t=e.type,n=e.childName;a.assert(t==pt.CHILD_ADDED||t==pt.CHILD_CHANGED||t==pt.CHILD_REMOVED,"Only child changes supported for tracking"),a.assert(".priority"!==n,"Only non-priority child changes can be tracked.");var r=this.changeMap.get(n);if(r){var i=r.type;if(t==pt.CHILD_ADDED&&i==pt.CHILD_REMOVED)this.changeMap.set(n,pt.childChangedChange(n,e.snapshotNode,r.snapshotNode));else if(t==pt.CHILD_REMOVED&&i==pt.CHILD_ADDED)this.changeMap.delete(n);else if(t==pt.CHILD_REMOVED&&i==pt.CHILD_CHANGED)this.changeMap.set(n,pt.childRemovedChange(n,r.oldSnap));else if(t==pt.CHILD_CHANGED&&i==pt.CHILD_ADDED)this.changeMap.set(n,pt.childAddedChange(n,e.snapshotNode));else{if(t!=pt.CHILD_CHANGED||i!=pt.CHILD_CHANGED)throw a.assertionError("Illegal combination of changes: "+e+" occurred after "+r);this.changeMap.set(n,pt.childChangedChange(n,e.snapshotNode,r.oldSnap))}}else this.changeMap.set(n,e)},e.prototype.getChanges=function(){return Array.from(this.changeMap.values())},e}(),mt=new(function(){function e(){}return e.prototype.getCompleteChild=function(e){return null},e.prototype.getChildAfterChild=function(e,t,n){return null},e}()),gt=function(){function e(e,t,n){void 0===n&&(n=null),this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=n}return e.prototype.getCompleteChild=function(e){var t=this.viewCache_.getEventCache();if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);var n=null!=this.optCompleteServerCache_?new lt(this.optCompleteServerCache_,!0,!1):this.viewCache_.getServerCache();return this.writes_.calcCompleteChild(e,n)},e.prototype.getChildAfterChild=function(e,t,n){var r=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:this.viewCache_.getCompleteServerSnap(),i=this.writes_.calcIndexedSlice(r,t,1,n,e);return 0===i.length?null:i[0]},e}(),yt=function(e,t){this.viewCache=e,this.changes=t},vt=function(){function e(e){this.filter_=e}return e.prototype.assertIndexed=function(e){a.assert(e.getEventCache().getNode().isIndexed(this.filter_.getIndex()),"Event snap not indexed"),a.assert(e.getServerCache().getNode().isIndexed(this.filter_.getIndex()),"Server snap not indexed")},e.prototype.applyOperation=function(t,n,r,i){var o,s,c=new ft;if(n.type===qe.OVERWRITE){var u=n;u.source.fromUser?o=this.applyUserOverwrite_(t,u.path,u.snap,r,i,c):(a.assert(u.source.fromServer,"Unknown source."),s=u.source.tagged||t.getServerCache().isFiltered()&&!u.path.isEmpty(),o=this.applyServerOverwrite_(t,u.path,u.snap,r,i,s,c))}else if(n.type===qe.MERGE){var l=n;l.source.fromUser?o=this.applyUserMerge_(t,l.path,l.children,r,i,c):(a.assert(l.source.fromServer,"Unknown source."),s=l.source.tagged||t.getServerCache().isFiltered(),o=this.applyServerMerge_(t,l.path,l.children,r,i,s,c))}else if(n.type===qe.ACK_USER_WRITE){var d=n;o=d.revert?this.revertUserWrite_(t,d.path,r,i,c):this.ackUserWrite_(t,d.path,d.affectedTree,r,i,c)}else{if(n.type!==qe.LISTEN_COMPLETE)throw a.assertionError("Unknown operation type: "+n.type);o=this.listenComplete_(t,n.path,r,c)}var p=c.getChanges();return e.maybeAddValueEvent_(t,o,p),new yt(o,p)},e.maybeAddValueEvent_=function(e,t,n){var r=t.getEventCache();if(r.isFullyInitialized()){var i=r.getNode().isLeafNode()||r.getNode().isEmpty(),o=e.getCompleteEventSnap();(n.length>0||!e.getEventCache().isFullyInitialized()||i&&!r.getNode().equals(o)||!r.getNode().getPriority().equals(o.getPriority()))&&n.push(pt.valueChange(t.getCompleteEventSnap()))}},e.prototype.generateEventCacheAfterServerEvent_=function(e,t,n,r,i){var o=e.getEventCache();if(null!=n.shadowingWrite(t))return e;var s=void 0,c=void 0;if(t.isEmpty())if(a.assert(e.getServerCache().isFullyInitialized(),"If change path is empty, we must have complete server data"),e.getServerCache().isFiltered()){var u=e.getCompleteServerSnap(),l=u instanceof Be?u:Be.EMPTY_NODE,d=n.calcCompleteEventChildren(l);s=this.filter_.updateFullNode(e.getEventCache().getNode(),d,i)}else{var p=n.calcCompleteEventCache(e.getCompleteServerSnap());s=this.filter_.updateFullNode(e.getEventCache().getNode(),p,i)}else{var h=t.getFront();if(".priority"==h){a.assert(1==t.getLength(),"Can't have a priority with additional path components");var f=o.getNode();c=e.getServerCache().getNode();var m=n.calcEventCacheAfterServerOverwrite(t,f,c);s=null!=m?this.filter_.updatePriority(f,m):o.getNode()}else{var g=t.popFront(),y=void 0;if(o.isCompleteForChild(h)){c=e.getServerCache().getNode();var v=n.calcEventCacheAfterServerOverwrite(t,o.getNode(),c);y=null!=v?o.getNode().getImmediateChild(h).updateChild(g,v):o.getNode().getImmediateChild(h)}else y=n.calcCompleteChild(h,e.getServerCache());s=null!=y?this.filter_.updateChild(o.getNode(),h,y,g,r,i):o.getNode()}}return e.updateEventSnap(s,o.isFullyInitialized()||t.isEmpty(),this.filter_.filtersNodes())},e.prototype.applyServerOverwrite_=function(e,t,n,r,i,o,a){var s,c=e.getServerCache(),u=o?this.filter_:this.filter_.getIndexedFilter();if(t.isEmpty())s=u.updateFullNode(c.getNode(),n,null);else if(u.filtersNodes()&&!c.isFiltered()){var l=c.getNode().updateChild(t,n);s=u.updateFullNode(c.getNode(),l,null)}else{var d=t.getFront();if(!c.isCompleteForPath(t)&&t.getLength()>1)return e;var p=t.popFront(),h=c.getNode().getImmediateChild(d).updateChild(p,n);s=".priority"==d?u.updatePriority(c.getNode(),h):u.updateChild(c.getNode(),d,h,p,mt,null)}var f=e.updateServerSnap(s,c.isFullyInitialized()||t.isEmpty(),u.filtersNodes()),m=new gt(r,f,i);return this.generateEventCacheAfterServerEvent_(f,t,r,m,a)},e.prototype.applyUserOverwrite_=function(e,t,n,r,i,o){var a,s,c=e.getEventCache(),u=new gt(r,e,i);if(t.isEmpty())s=this.filter_.updateFullNode(e.getEventCache().getNode(),n,o),a=e.updateEventSnap(s,!0,this.filter_.filtersNodes());else{var l=t.getFront();if(".priority"===l)s=this.filter_.updatePriority(e.getEventCache().getNode(),n),a=e.updateEventSnap(s,c.isFullyInitialized(),c.isFiltered());else{var d=t.popFront(),p=c.getNode().getImmediateChild(l),h=void 0;if(d.isEmpty())h=n;else{var f=u.getCompleteChild(l);h=null!=f?".priority"===d.getBack()&&f.getChild(d.parent()).isEmpty()?f:f.updateChild(d,n):Be.EMPTY_NODE}if(p.equals(h))a=e;else{var m=this.filter_.updateChild(c.getNode(),l,h,d,u,o);a=e.updateEventSnap(m,c.isFullyInitialized(),this.filter_.filtersNodes())}}}return a},e.cacheHasChild_=function(e,t){return e.getEventCache().isCompleteForChild(t)},e.prototype.applyUserMerge_=function(t,n,r,i,o,a){var s=this,c=t;return r.foreach((function(r,u){var l=n.child(r);e.cacheHasChild_(t,l.getFront())&&(c=s.applyUserOverwrite_(c,l,u,i,o,a))})),r.foreach((function(r,u){var l=n.child(r);e.cacheHasChild_(t,l.getFront())||(c=s.applyUserOverwrite_(c,l,u,i,o,a))})),c},e.prototype.applyMerge_=function(e,t){return t.foreach((function(t,n){e=e.updateChild(t,n)})),e},e.prototype.applyServerMerge_=function(e,t,n,r,i,o,a){var s=this;if(e.getServerCache().getNode().isEmpty()&&!e.getServerCache().isFullyInitialized())return e;var c,u=e;c=t.isEmpty()?n:at.Empty.setTree(t,n);var l=e.getServerCache().getNode();return c.children.inorderTraversal((function(t,n){if(l.hasChild(t)){var c=e.getServerCache().getNode().getImmediateChild(t),d=s.applyMerge_(c,n);u=s.applyServerOverwrite_(u,new z(t),d,r,i,o,a)}})),c.children.inorderTraversal((function(t,n){var c=!e.getServerCache().isCompleteForChild(t)&&null==n.value;if(!l.hasChild(t)&&!c){var d=e.getServerCache().getNode().getImmediateChild(t),p=s.applyMerge_(d,n);u=s.applyServerOverwrite_(u,new z(t),p,r,i,o,a)}})),u},e.prototype.ackUserWrite_=function(e,t,n,r,i,o){if(null!=r.shadowingWrite(t))return e;var a=e.getServerCache().isFiltered(),s=e.getServerCache();if(null!=n.value){if(t.isEmpty()&&s.isFullyInitialized()||s.isCompleteForPath(t))return this.applyServerOverwrite_(e,t,s.getNode().getChild(t),r,i,a,o);if(t.isEmpty()){var c=at.Empty;return s.getNode().forEachChild(ye,(function(e,t){c=c.set(new z(e),t)})),this.applyServerMerge_(e,t,c,r,i,a,o)}return e}var u=at.Empty;return n.foreach((function(e,n){var r=t.child(e);s.isCompleteForPath(r)&&(u=u.set(e,s.getNode().getChild(r)))})),this.applyServerMerge_(e,t,u,r,i,a,o)},e.prototype.listenComplete_=function(e,t,n,r){var i=e.getServerCache(),o=e.updateServerSnap(i.getNode(),i.isFullyInitialized()||t.isEmpty(),i.isFiltered());return this.generateEventCacheAfterServerEvent_(o,t,n,mt,r)},e.prototype.revertUserWrite_=function(e,t,n,r,i){var o;if(null!=n.shadowingWrite(t))return e;var s=new gt(n,e,r),c=e.getEventCache().getNode(),u=void 0;if(t.isEmpty()||".priority"===t.getFront()){var l=void 0;if(e.getServerCache().isFullyInitialized())l=n.calcCompleteEventCache(e.getCompleteServerSnap());else{var d=e.getServerCache().getNode();a.assert(d instanceof Be,"serverChildren would be complete if leaf node"),l=n.calcCompleteEventChildren(d)}l=l,u=this.filter_.updateFullNode(c,l,i)}else{var p=t.getFront(),h=n.calcCompleteChild(p,e.getServerCache());null==h&&e.getServerCache().isCompleteForChild(p)&&(h=c.getImmediateChild(p)),(u=null!=h?this.filter_.updateChild(c,p,h,t.popFront(),s,i):e.getEventCache().getNode().hasChild(p)?this.filter_.updateChild(c,p,Be.EMPTY_NODE,t.popFront(),s,i):c).isEmpty()&&e.getServerCache().isFullyInitialized()&&(o=n.calcCompleteEventCache(e.getCompleteServerSnap())).isLeafNode()&&(u=this.filter_.updateFullNode(u,o,i))}return o=e.getServerCache().isFullyInitialized()||null!=n.shadowingWrite(z.Empty),e.updateEventSnap(u,o,this.filter_.filtersNodes())},e}(),bt=function(){function e(e){this.query_=e,this.index_=this.query_.getQueryParams().getIndex()}return e.prototype.generateEventsForChanges=function(e,t,n){var r=this,i=[],o=[];return e.forEach((function(e){e.type===pt.CHILD_CHANGED&&r.index_.indexedValueChanged(e.oldSnap,e.snapshotNode)&&o.push(pt.childMovedChange(e.childName,e.snapshotNode))})),this.generateEventsForType_(i,pt.CHILD_REMOVED,e,n,t),this.generateEventsForType_(i,pt.CHILD_ADDED,e,n,t),this.generateEventsForType_(i,pt.CHILD_MOVED,o,n,t),this.generateEventsForType_(i,pt.CHILD_CHANGED,e,n,t),this.generateEventsForType_(i,pt.VALUE,e,n,t),i},e.prototype.generateEventsForType_=function(e,t,n,r,i){var o=this,a=n.filter((function(e){return e.type===t}));a.sort(this.compareChanges_.bind(this)),a.forEach((function(t){var n=o.materializeSingleChange_(t,i);r.forEach((function(r){r.respondsTo(t.type)&&e.push(r.createEvent(n,o.query_))}))}))},e.prototype.materializeSingleChange_=function(e,t){return"value"===e.type||"child_removed"===e.type?e:(e.prevName=t.getPredecessorChildName(e.childName,e.snapshotNode,this.index_),e)},e.prototype.compareChanges_=function(e,t){if(null==e.childName||null==t.childName)throw a.assertionError("Should only compare child_ events.");var n=new fe(e.childName,e.snapshotNode),r=new fe(t.childName,t.snapshotNode);return this.index_.compare(n,r)},e}(),Et=function(){function e(e,t){this.query_=e,this.eventRegistrations_=[];var n=this.query_.getQueryParams(),r=new ht(n.getIndex()),i=n.getNodeFilter();this.processor_=new vt(i);var o=t.getServerCache(),a=t.getEventCache(),s=r.updateFullNode(Be.EMPTY_NODE,o.getNode(),null),c=i.updateFullNode(Be.EMPTY_NODE,a.getNode(),null),u=new lt(s,o.isFullyInitialized(),r.filtersNodes()),l=new lt(c,a.isFullyInitialized(),i.filtersNodes());this.viewCache_=new dt(l,u),this.eventGenerator_=new bt(this.query_)}return e.prototype.getQuery=function(){return this.query_},e.prototype.getServerCache=function(){return this.viewCache_.getServerCache().getNode()},e.prototype.getCompleteServerCache=function(e){var t=this.viewCache_.getCompleteServerSnap();return t&&(this.query_.getQueryParams().loadsAllData()||!e.isEmpty()&&!t.getImmediateChild(e.getFront()).isEmpty())?t.getChild(e):null},e.prototype.isEmpty=function(){return 0===this.eventRegistrations_.length},e.prototype.addEventRegistration=function(e){this.eventRegistrations_.push(e)},e.prototype.removeEventRegistration=function(e,t){var n=[];if(t){a.assert(null==e,"A cancel should cancel all event registrations.");var r=this.query_.path;this.eventRegistrations_.forEach((function(e){t=t;var i=e.createCancelEvent(t,r);i&&n.push(i)}))}if(e){for(var i=[],o=0;othis.lastWriteId_,"Stacking an older write on top of newer ones"),void 0===r&&(r=!0),this.allWrites_.push({path:e,snap:t,writeId:n,visible:r}),r&&(this.visibleWrites_=this.visibleWrites_.addWrite(e,t)),this.lastWriteId_=n},e.prototype.addMerge=function(e,t,n){a.assert(n>this.lastWriteId_,"Stacking an older merge on top of newer ones"),this.allWrites_.push({path:e,children:t,writeId:n,visible:!0}),this.visibleWrites_=this.visibleWrites_.addWrites(e,t),this.lastWriteId_=n},e.prototype.getWrite=function(e){for(var t=0;t=0,"removeWrite called with nonexistent writeId.");var r=this.allWrites_[n];this.allWrites_.splice(n,1);for(var i=r.visible,o=!1,s=this.allWrites_.length-1;i&&s>=0;){var c=this.allWrites_[s];c.visible&&(s>=n&&this.recordContainsPath_(c,r.path)?i=!1:r.path.contains(c.path)&&(o=!0)),s--}if(i){if(o)return this.resetTree_(),!0;r.snap?this.visibleWrites_=this.visibleWrites_.removeWrite(r.path):N(r.children,(function(e){t.visibleWrites_=t.visibleWrites_.removeWrite(r.path.child(e))}));return!0}return!1},e.prototype.getCompleteWriteData=function(e){return this.visibleWrites_.getCompleteNode(e)},e.prototype.calcCompleteEventCache=function(t,n,r,i){if(r||i){var o=this.visibleWrites_.childCompoundWrite(t);if(!i&&o.isEmpty())return n;if(i||null!=n||o.hasCompleteWrite(z.Empty)){var a=e.layerTree_(this.allWrites_,(function(e){return(e.visible||i)&&(!r||!~r.indexOf(e.writeId))&&(e.path.contains(t)||t.contains(e.path))}),t);u=n||Be.EMPTY_NODE;return a.apply(u)}return null}var s=this.visibleWrites_.getCompleteNode(t);if(null!=s)return s;var c=this.visibleWrites_.childCompoundWrite(t);if(c.isEmpty())return n;if(null!=n||c.hasCompleteWrite(z.Empty)){var u=n||Be.EMPTY_NODE;return c.apply(u)}return null},e.prototype.calcCompleteEventChildren=function(e,t){var n=Be.EMPTY_NODE,r=this.visibleWrites_.getCompleteNode(e);if(r)return r.isLeafNode()||r.forEachChild(Oe,(function(e,t){n=n.updateImmediateChild(e,t)})),n;if(t){var i=this.visibleWrites_.childCompoundWrite(e);return t.forEachChild(Oe,(function(e,t){var r=i.childCompoundWrite(new z(e)).apply(t);n=n.updateImmediateChild(e,r)})),i.getCompleteChildren().forEach((function(e){n=n.updateImmediateChild(e.name,e.node)})),n}return this.visibleWrites_.childCompoundWrite(e).getCompleteChildren().forEach((function(e){n=n.updateImmediateChild(e.name,e.node)})),n},e.prototype.calcEventCacheAfterServerOverwrite=function(e,t,n,r){a.assert(n||r,"Either existingEventSnap or existingServerSnap must exist");var i=e.child(t);if(this.visibleWrites_.hasCompleteWrite(i))return null;var o=this.visibleWrites_.childCompoundWrite(i);return o.isEmpty()?r.getChild(t):o.apply(r.getChild(t))},e.prototype.calcCompleteChild=function(e,t,n){var r=e.child(t),i=this.visibleWrites_.getCompleteNode(r);return null!=i?i:n.isCompleteForChild(t)?this.visibleWrites_.childCompoundWrite(r).apply(n.getNode().getImmediateChild(t)):null},e.prototype.shadowingWrite=function(e){return this.visibleWrites_.getCompleteNode(e)},e.prototype.calcIndexedSlice=function(e,t,n,r,i,o){var a,s=this.visibleWrites_.childCompoundWrite(e),c=s.getCompleteNode(z.Empty);if(null!=c)a=c;else{if(null==t)return[];a=s.apply(t)}if((a=a.withIndex(o)).isEmpty()||a.isLeafNode())return[];for(var u=[],l=o.getCompare(),d=i?a.getReverseIteratorFrom(n,o):a.getIteratorFrom(n,o),p=d.getNext();p&&u.length0?this.lastWriteId_=this.allWrites_[this.allWrites_.length-1].writeId:this.lastWriteId_=-1},e.DefaultFilter_=function(e){return e.visible},e.layerTree_=function(e,t,n){for(var r=_t.Empty,i=0;i0&&!r)if(l){this.listenProvider_.stopListening(e.queryForListening_(t),null)}else u.forEach((function(t){var n=i.queryToTagMap.get(e.makeQueryKey_(t));i.listenProvider_.stopListening(e.queryForListening_(t),n)}));this.removeTags_(u)}return s},e.prototype.calcCompleteEventCache=function(e,t){var n=this.pendingWriteTree_,r=this.syncPointTree_.findOnPath(e,(function(t,n){var r=z.relativePath(t,e),i=n.getCompleteServerCache(r);if(i)return i}));return n.calcCompleteEventCache(e,r,t,!0)},e.prototype.collectDistinctViewsForSubTree_=function(e){return e.fold((function(e,t,n){if(t&&t.hasCompleteView())return[t.getCompleteView()];var r=[];return t&&(r=t.getQueryViews()),N(n,(function(e,t){r=r.concat(t)})),r}))},e.prototype.removeTags_=function(t){for(var n=0;n0&&a.contains(e.statsToReport_,t)&&(n[t]=i,r=!0)})),r&&this.server_.reportStats(n),U(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))},e}(),jt=function(){function e(){this.eventLists_=[],this.recursionDepth_=0}return e.prototype.queueEvents=function(e){for(var t=null,n=0;n0,"Requires a non-empty array")}return e.prototype.trigger=function(e){for(var t=[],n=1;ndocument.domain="'+document.domain+'";<\/script>';var s=""+o+"";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(s),this.myIFrame.doc.close()}catch(c){w("frame writing exception"),c.stack&&w(c.stack),w(c)}}}return e.createIFrame_=function(){var e=document.createElement("iframe");if(e.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(e);try{e.contentWindow.document||w("No IE domain setting required")}catch(n){var t=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+t+"';document.close();})())"}return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e},e.prototype.close=function(){var e=this;this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.innerHTML="",setTimeout((function(){null!==e.myIFrame&&(document.body.removeChild(e.myIFrame),e.myIFrame=null)}),Math.floor(0)));var t=this.onDisconnect;t&&(this.onDisconnect=null,t())},e.prototype.startLongPoll=function(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););},e.prototype.newRequest_=function(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;var e={};e.id=this.myID,e.pw=this.myPW,e.ser=this.currentSerial;for(var t=this.urlFn(e),n="",r=0;this.pendingSegs.length>0;){if(!(this.pendingSegs[0].d.length+30+n.length<=1870))break;var i=this.pendingSegs.shift();n=n+"&seg"+r+"="+i.seg+"&ts"+r+"="+i.ts+"&d"+r+"="+i.d,r++}return t+=n,this.addLongPollTag_(t,this.currentSerial),!0}return!1},e.prototype.enqueueSegment=function(e,t,n){this.pendingSegs.push({seg:e,ts:t,d:n}),this.alive&&this.newRequest_()},e.prototype.addLongPollTag_=function(e,t){var n=this;this.outstandingRequests.add(t);var r=function(){n.outstandingRequests.delete(t),n.newRequest_()},i=setTimeout(r,Math.floor(25e3));this.addTag(e,(function(){clearTimeout(i),r()}))},e.prototype.addTag=function(e,t){var n=this;a.isNodeSdk()?this.doNodeLongPoll(e,t):setTimeout((function(){try{if(!n.sendNewPolls)return;var r=n.myIFrame.doc.createElement("script");r.type="text/javascript",r.async=!0,r.src=e,r.onload=r.onreadystatechange=function(){var e=r.readyState;e&&"loaded"!==e&&"complete"!==e||(r.onload=r.onreadystatechange=null,r.parentNode&&r.parentNode.removeChild(r),t())},r.onerror=function(){w("Long-poll script failed to load: "+e),n.sendNewPolls=!1,n.close()},n.myIFrame.doc.body.appendChild(r)}catch(i){}}),Math.floor(1))},e}(),Kt="";var Vt=null;"undefined"!=typeof MozWebSocket?Vt=MozWebSocket:"undefined"!=typeof WebSocket&&(Vt=WebSocket);var Wt=function(){function e(t,n,r,i){this.connId=t,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=_(this.connId),this.stats_=Ct.getCollection(n),this.connURL=e.connectionURL_(n,r,i)}return e.connectionURL_=function(e,t,n){var r={v:"5"};return!a.isNodeSdk()&&"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf("firebaseio.com")&&(r.r="f"),t&&(r.s=t),n&&(r.ls=n),e.connectionURL("websocket",r)},e.prototype.open=function(e,t){var n=this;this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,d.set("previous_websocket_failure",!0);try{if(a.isNodeSdk()){var i=a.CONSTANTS.NODE_ADMIN?"AdminNode":"Node",o={headers:{"User-Agent":"Firebase/5/"+Kt+"/"+r.platform+"/"+i}},s=r.env,c=0==this.connURL.indexOf("wss://")?s.HTTPS_PROXY||s.https_proxy:s.HTTP_PROXY||s.http_proxy;c&&(o.proxy={origin:c}),this.mySock=new Vt(this.connURL,[],o)}else this.mySock=new Vt(this.connURL)}catch(l){this.log_("Error instantiating WebSocket.");var u=l.message||l.data;return u&&this.log_(u),void this.onClosed_()}this.mySock.onopen=function(){n.log_("Websocket connected."),n.everConnected_=!0},this.mySock.onclose=function(){n.log_("Websocket connection was disconnected."),n.mySock=null,n.onClosed_()},this.mySock.onmessage=function(e){n.handleIncomingFrame(e)},this.mySock.onerror=function(e){n.log_("WebSocket error. Closing connection.");var t=e.message||e.data;t&&n.log_(t),n.onClosed_()}},e.prototype.start=function(){},e.forceDisallow=function(){e.forceDisallow_=!0},e.isAvailable=function(){var t=!1;if("undefined"!=typeof navigator&&navigator.userAgent){var n=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/);n&&n.length>1&&parseFloat(n[1])<4.4&&(t=!0)}return!t&&null!==Vt&&!e.forceDisallow_},e.previouslyFailed=function(){return d.isInMemoryStorage||!0===d.get("previous_websocket_failure")},e.prototype.markConnectionHealthy=function(){d.remove("previous_websocket_failure")},e.prototype.appendFrame_=function(e){if(this.frames.push(e),this.frames.length==this.totalFrames){var t=this.frames.join("");this.frames=null;var n=a.jsonEval(t);this.onMessage(n)}},e.prototype.handleNewFrameCount_=function(e){this.totalFrames=e,this.frames=[]},e.prototype.extractFrameCount_=function(e){if(a.assert(null===this.frames,"We already have a frame buffer"),e.length<=6){var t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e},e.prototype.handleIncomingFrame=function(e){if(null!==this.mySock){var t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(t);else{var n=this.extractFrameCount_(t);null!==n&&this.appendFrame_(n)}}},e.prototype.send=function(e){this.resetKeepAlive();var t=a.stringify(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);var n=R(t,16384);n.length>1&&this.sendString_(String(n.length));for(var r=0;r0)return this.transports_[0];throw new Error("No transports available")},e.prototype.upgradeTransport=function(){return this.transports_.length>1?this.transports_[1]:null},e}(),Jt=function(){function e(e,t,n,r,i,o,a){this.id=e,this.repoInfo_=t,this.onMessage_=n,this.onReady_=r,this.onDisconnect_=i,this.onKill_=o,this.lastSessionId=a,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=_("c:"+this.id+":"),this.transportManager_=new Yt(t),this.log_("Connection created"),this.start_()}return e.prototype.start_=function(){var e=this,t=this.transportManager_.initialTransport();this.conn_=new t(this.nextTransportId_(),this.repoInfo_,void 0,this.lastSessionId),this.primaryResponsesRequired_=t.responsesRequiredToBeHealthy||0;var n=this.connReceiver_(this.conn_),r=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout((function(){e.conn_&&e.conn_.open(n,r)}),Math.floor(0));var i=t.healthyTimeout||0;i>0&&(this.healthyTimeout_=U((function(){e.healthyTimeout_=null,e.isHealthy_||(e.conn_&&e.conn_.bytesReceived>102400?(e.log_("Connection exceeded healthy timeout but has received "+e.conn_.bytesReceived+" bytes. Marking connection healthy."),e.isHealthy_=!0,e.conn_.markConnectionHealthy()):e.conn_&&e.conn_.bytesSent>10240?e.log_("Connection exceeded healthy timeout but has sent "+e.conn_.bytesSent+" bytes. Leaving connection alive."):(e.log_("Closing unhealthy connection after timeout."),e.close()))}),Math.floor(i)))},e.prototype.nextTransportId_=function(){return"c:"+this.id+":"+this.connectionCount++},e.prototype.disconnReceiver_=function(e){var t=this;return function(n){e===t.conn_?t.onConnectionLost_(n):e===t.secondaryConn_?(t.log_("Secondary connection lost."),t.onSecondaryConnectionLost_()):t.log_("closing an old connection")}},e.prototype.connReceiver_=function(e){var t=this;return function(n){2!=t.state_&&(e===t.rx_?t.onPrimaryMessageReceived_(n):e===t.secondaryConn_?t.onSecondaryMessageReceived_(n):t.log_("message on old connection"))}},e.prototype.sendRequest=function(e){var t={t:"d",d:e};this.sendData_(t)},e.prototype.tryCleanupConnection=function(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)},e.prototype.onSecondaryControl_=function(e){if("t"in e){var t=e.t;"a"===t?this.upgradeIfSecondaryHealthy_():"r"===t?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===t&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}},e.prototype.onSecondaryMessageReceived_=function(e){var t=C("t",e),n=C("d",e);if("c"==t)this.onSecondaryControl_(n);else{if("d"!=t)throw new Error("Unknown protocol layer: "+t);this.pendingDataMessages.push(n)}},e.prototype.upgradeIfSecondaryHealthy_=function(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:"p",d:{}}}))},e.prototype.proceedWithUpgrade_=function(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()},e.prototype.onPrimaryMessageReceived_=function(e){var t=C("t",e),n=C("d",e);"c"==t?this.onControl_(n):"d"==t&&this.onDataMessage_(n)},e.prototype.onDataMessage_=function(e){this.onPrimaryResponse_(),this.onMessage_(e)},e.prototype.onPrimaryResponse_=function(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))},e.prototype.onControl_=function(e){var t=C("t",e);if("d"in e){var n=e.d;if("h"===t)this.onHandshake_(n);else if("n"===t){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(var r=0;r3e4&&(this.reconnectDelay_=Xt),this.lastConnectionEstablishedTime_=null}}else this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime();var e=(new Date).getTime()-this.lastConnectionAttemptTime_,t=Math.max(0,this.reconnectDelay_-e);t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)}this.onConnectStatus_(!1)},t.prototype.establishConnection_=function(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;var e=this.onDataMessage_.bind(this),n=this.onReady_.bind(this),r=this.onRealtimeDisconnect_.bind(this),i=this.id+":"+t.nextConnectionId_++,o=this,s=this.lastSessionId,c=!1,u=null,l=function(){u?u.close():(c=!0,r())};this.realtime_={close:l,sendRequest:function(e){a.assert(u,"sendRequest call when we're not connected not allowed."),u.sendRequest(e)}};var d=this.forceTokenRefresh_;this.forceTokenRefresh_=!1,this.authTokenProvider_.getToken(d).then((function(t){c?w("getToken() completed but was canceled"):(w("getToken() completed. Creating connection."),o.authToken_=t&&t.accessToken,u=new Jt(i,o.repoInfo_,e,n,r,(function(e){k(e+" ("+o.repoInfo_.toString()+")"),o.interrupt("server_kill")}),s))})).then(null,(function(e){o.log_("Failed to get token: "+e),c||(a.CONSTANTS.NODE_ADMIN&&k(e),l())}))}},t.prototype.interrupt=function(e){w("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())},t.prototype.resume=function(e){w("Resuming connection for reason: "+e),delete this.interruptReasons_[e],a.isEmpty(this.interruptReasons_)&&(this.reconnectDelay_=Xt,this.realtime_||this.scheduleConnect_(0))},t.prototype.handleTimestamp_=function(e){var t=e-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:t})},t.prototype.cancelSentTransactions_=function(){for(var e=0;e=3&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))},t.prototype.onSecurityDebugPacket_=function(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace("\n","\nFIREBASE: "))},t.prototype.restoreState_=function(){var e,t,n,r;this.tryAuth();try{for(var i=o.__values(this.listens.values()),a=i.next();!a.done;a=i.next()){var s=a.value;try{for(var c=(n=void 0,o.__values(s.values())),u=c.next();!u.done;u=c.next()){var l=u.value;this.sendListen_(l)}}catch(h){n={error:h}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}}}catch(f){e={error:f}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}for(var d=0;d=200&&c.status<300){try{e=a.jsonEval(c.responseText)}catch(t){k("Failed to parse JSON response for "+s+": "+c.responseText)}n(null,e)}else 401!==c.status&&404!==c.status&&k("Got unsuccessful REST response for "+s+" Status: "+c.status),n(c.status);n=null}},c.open("GET",s,!0),c.send()}))},t}(Qt),nn=function(){function e(e,t,n){var i,o=this;if(this.repoInfo_=e,this.app=n,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new jt,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=new Xe,this.persistentConnection_=null,i=void 0!==r&&r.env[f]?new It(n):new Tt(n),this.stats_=Ct.getCollection(e),t||F())this.server_=new tn(this.repoInfo_,this.onDataUpdate_.bind(this),i),setTimeout(this.onConnectStatus_.bind(this,!0),0);else{var s=n.options.databaseAuthVariableOverride;if(null!=s){if("object"!=typeof s)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{a.stringify(s)}catch(c){throw new Error("Invalid authOverride provided: "+c)}}this.persistentConnection_=new en(this.repoInfo_,this.onDataUpdate_.bind(this),this.onConnectStatus_.bind(this),this.onServerInfoUpdate_.bind(this),i,s),this.server_=this.persistentConnection_}i.addTokenChangeListener((function(e){o.server_.refreshAuthToken(e)})),this.statsReporter_=Ct.getOrCreateReporter(e,(function(){return new Lt(o.stats_,o.server_)})),this.transactions_init_(),this.infoData_=new Ot,this.infoSyncTree_=new kt({startListening:function(e,t,n,r){var i=[],a=o.infoData_.getNode(e.path);return a.isEmpty()||(i=o.infoSyncTree_.applyServerOverwrite(e.path,a),setTimeout((function(){r("ok")}),0)),i},stopListening:function(){}}),this.updateInfo_("connected",!1),this.serverSyncTree_=new kt({startListening:function(e,t,n,r){return o.server_.listen(e,n,t,(function(t,n){var i=r(t,n);o.eventQueue_.raiseEventsForChangedPath(e.path,i)})),[]},stopListening:function(e,t){o.server_.unlisten(e,t)}})}return e.prototype.toString=function(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host},e.prototype.name=function(){return this.repoInfo_.namespace},e.prototype.serverTime=function(){var e=this.infoData_.getNode(new z(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+e},e.prototype.generateServerValues=function(){return(e=(e={timestamp:this.serverTime()})||{}).timestamp=e.timestamp||(new Date).getTime(),e;var e},e.prototype.onDataUpdate_=function(e,t,n,r){this.dataUpdateCount++;var i=new z(e);t=this.interceptServerDataCallback_?this.interceptServerDataCallback_(e,t):t;var o=[];if(r)if(n){var s=a.map(t,(function(e){return ze(e)}));o=this.serverSyncTree_.applyTaggedQueryMerge(i,s,r)}else{var c=ze(t);o=this.serverSyncTree_.applyTaggedQueryOverwrite(i,c,r)}else if(n){var u=a.map(t,(function(e){return ze(e)}));o=this.serverSyncTree_.applyServerMerge(i,u)}else{var l=ze(t);o=this.serverSyncTree_.applyServerOverwrite(i,l)}var d=i;o.length>0&&(d=this.rerunTransactions_(i)),this.eventQueue_.raiseEventsForChangedPath(d,o)},e.prototype.interceptServerData_=function(e){this.interceptServerDataCallback_=e},e.prototype.onConnectStatus_=function(e){this.updateInfo_("connected",e),!1===e&&this.runOnDisconnectEvents_()},e.prototype.onServerInfoUpdate_=function(e){var t=this;N(e,(function(e,n){t.updateInfo_(e,n)}))},e.prototype.updateInfo_=function(e,t){var n=new z("/.info/"+e),r=ze(t);this.infoData_.updateSnapshot(n,r);var i=this.infoSyncTree_.applyServerOverwrite(n,r);this.eventQueue_.raiseEventsForChangedPath(n,i)},e.prototype.getNextWriteId_=function(){return this.nextWriteId_++},e.prototype.setWithPriority=function(e,t,n,r){var i=this;this.log_("set",{path:e.toString(),value:t,priority:n});var o=this.generateServerValues(),a=ze(t,n),s=et(a,o),c=this.getNextWriteId_(),u=this.serverSyncTree_.applyUserOverwrite(e,s,c,!0);this.eventQueue_.queueEvents(u),this.server_.put(e.toString(),a.val(!0),(function(t,n){var o="ok"===t;o||k("set at "+e+" failed: "+t);var a=i.serverSyncTree_.ackUserWrite(c,!o);i.eventQueue_.raiseEventsForChangedPath(e,a),i.callOnCompleteCallback(r,t,n)}));var l=this.abortTransactions_(e);this.rerunTransactions_(l),this.eventQueue_.raiseEventsForChangedPath(l,[])},e.prototype.update=function(e,t,n){var r=this;this.log_("update",{path:e.toString(),value:t});var i=!0,o=this.generateServerValues(),a={};if(N(t,(function(e,t){i=!1;var n=ze(t);a[e]=et(n,o)})),i)w("update() called with empty data. Don't do anything."),this.callOnCompleteCallback(n,"ok");else{var s=this.getNextWriteId_(),c=this.serverSyncTree_.applyUserMerge(e,a,s);this.eventQueue_.queueEvents(c),this.server_.merge(e.toString(),t,(function(t,i){var o="ok"===t;o||k("update at "+e+" failed: "+t);var a=r.serverSyncTree_.ackUserWrite(s,!o),c=a.length>0?r.rerunTransactions_(e):e;r.eventQueue_.raiseEventsForChangedPath(c,a),r.callOnCompleteCallback(n,t,i)})),N(t,(function(t){var n=r.abortTransactions_(e.child(t));r.rerunTransactions_(n)})),this.eventQueue_.raiseEventsForChangedPath(e,[])}},e.prototype.runOnDisconnectEvents_=function(){var e=this;this.log_("onDisconnectEvents");var t=this.generateServerValues(),n=function(e,t){var n=new Xe;return e.forEachTree(new z(""),(function(e,r){n.remember(e,et(r,t))})),n}(this.onDisconnect_,t),r=[];n.forEachTree(z.Empty,(function(t,n){r=r.concat(e.serverSyncTree_.applyServerOverwrite(t,n));var i=e.abortTransactions_(t);e.rerunTransactions_(i)})),this.onDisconnect_=new Xe,this.eventQueue_.raiseEventsForChangedPath(z.Empty,r)},e.prototype.onDisconnectCancel=function(e,t){var n=this;this.server_.onDisconnectCancel(e.toString(),(function(r,i){"ok"===r&&n.onDisconnect_.forget(e),n.callOnCompleteCallback(t,r,i)}))},e.prototype.onDisconnectSet=function(e,t,n){var r=this,i=ze(t);this.server_.onDisconnectPut(e.toString(),i.val(!0),(function(t,o){"ok"===t&&r.onDisconnect_.remember(e,i),r.callOnCompleteCallback(n,t,o)}))},e.prototype.onDisconnectSetWithPriority=function(e,t,n,r){var i=this,o=ze(t,n);this.server_.onDisconnectPut(e.toString(),o.val(!0),(function(t,n){"ok"===t&&i.onDisconnect_.remember(e,o),i.callOnCompleteCallback(r,t,n)}))},e.prototype.onDisconnectUpdate=function(e,t,n){var r=this;if(a.isEmpty(t))return w("onDisconnect().update() called with empty data. Don't do anything."),void this.callOnCompleteCallback(n,"ok");this.server_.onDisconnectMerge(e.toString(),t,(function(i,o){"ok"===i&&N(t,(function(t,n){var i=ze(n);r.onDisconnect_.remember(e.child(t),i)})),r.callOnCompleteCallback(n,i,o)}))},e.prototype.addEventCallbackForQuery=function(e,t){var n;n=".info"===e.path.getFront()?this.infoSyncTree_.addEventRegistration(e,t):this.serverSyncTree_.addEventRegistration(e,t),this.eventQueue_.raiseEventsAtPath(e.path,n)},e.prototype.removeEventCallbackForQuery=function(e,t){var n;n=".info"===e.path.getFront()?this.infoSyncTree_.removeEventRegistration(e,t):this.serverSyncTree_.removeEventRegistration(e,t),this.eventQueue_.raiseEventsAtPath(e.path,n)},e.prototype.interrupt=function(){this.persistentConnection_&&this.persistentConnection_.interrupt("repo_interrupt")},e.prototype.resume=function(){this.persistentConnection_&&this.persistentConnection_.resume("repo_interrupt")},e.prototype.stats=function(e){if(void 0===e&&(e=!1),"undefined"!=typeof console){var t;e?(this.statsListener_||(this.statsListener_=new Pt(this.stats_)),t=this.statsListener_.get()):t=this.stats_.get();var n=Object.keys(t).reduce((function(e,t){return Math.max(t.length,e)}),0);N(t,(function(e,t){for(var r=e,i=e.length;i=0)return null!=i&&i.trackChildChange(pt.childChangedChange(t,n,p)),c.updateImmediateChild(t,n);null!=i&&i.trackChildChange(pt.childRemovedChange(t,p));var m=c.updateImmediateChild(t,Be.EMPTY_NODE);return null!=h&&this.rangedFilter_.matches(h)?(null!=i&&i.trackChildChange(pt.childAddedChange(h.name,h.node)),m.updateImmediateChild(h.name,h.node)):m}return n.isEmpty()?e:d&&o(l,u)>=0?(null!=i&&(i.trackChildChange(pt.childRemovedChange(l.name,l.node)),i.trackChildChange(pt.childAddedChange(t,n))),c.updateImmediateChild(t,n).updateImmediateChild(l.name,Be.EMPTY_NODE)):e},e}(),an=function(){function e(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=Oe}return e.prototype.hasStart=function(){return this.startSet_},e.prototype.isViewFromLeft=function(){return""===this.viewFrom_?this.startSet_:this.viewFrom_===e.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT},e.prototype.getIndexStartValue=function(){return a.assert(this.startSet_,"Only valid if start has been set"),this.indexStartValue_},e.prototype.getIndexStartName=function(){return a.assert(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:T},e.prototype.hasEnd=function(){return this.endSet_},e.prototype.getIndexEndValue=function(){return a.assert(this.endSet_,"Only valid if end has been set"),this.indexEndValue_},e.prototype.getIndexEndName=function(){return a.assert(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:A},e.prototype.hasLimit=function(){return this.limitSet_},e.prototype.hasAnchoredLimit=function(){return this.limitSet_&&""!==this.viewFrom_},e.prototype.getLimit=function(){return a.assert(this.limitSet_,"Only valid if limit has been set"),this.limit_},e.prototype.getIndex=function(){return this.index_},e.prototype.copy_=function(){var t=new e;return t.limitSet_=this.limitSet_,t.limit_=this.limit_,t.startSet_=this.startSet_,t.indexStartValue_=this.indexStartValue_,t.startNameSet_=this.startNameSet_,t.indexStartName_=this.indexStartName_,t.endSet_=this.endSet_,t.indexEndValue_=this.indexEndValue_,t.endNameSet_=this.endNameSet_,t.indexEndName_=this.indexEndName_,t.index_=this.index_,t.viewFrom_=this.viewFrom_,t},e.prototype.limit=function(e){var t=this.copy_();return t.limitSet_=!0,t.limit_=e,t.viewFrom_="",t},e.prototype.limitToFirst=function(t){var n=this.copy_();return n.limitSet_=!0,n.limit_=t,n.viewFrom_=e.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT,n},e.prototype.limitToLast=function(t){var n=this.copy_();return n.limitSet_=!0,n.limit_=t,n.viewFrom_=e.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_RIGHT,n},e.prototype.startAt=function(e,t){var n=this.copy_();return n.startSet_=!0,void 0===e&&(e=null),n.indexStartValue_=e,null!=t?(n.startNameSet_=!0,n.indexStartName_=t):(n.startNameSet_=!1,n.indexStartName_=""),n},e.prototype.endAt=function(e,t){var n=this.copy_();return n.endSet_=!0,void 0===e&&(e=null),n.indexEndValue_=e,void 0!==t?(n.endNameSet_=!0,n.indexEndName_=t):(n.endNameSet_=!1,n.indexEndName_=""),n},e.prototype.orderBy=function(e){var t=this.copy_();return t.index_=e,t},e.prototype.getQueryObject=function(){var t=e.WIRE_PROTOCOL_CONSTANTS_,n={};if(this.startSet_&&(n[t.INDEX_START_VALUE]=this.indexStartValue_,this.startNameSet_&&(n[t.INDEX_START_NAME]=this.indexStartName_)),this.endSet_&&(n[t.INDEX_END_VALUE]=this.indexEndValue_,this.endNameSet_&&(n[t.INDEX_END_NAME]=this.indexEndName_)),this.limitSet_){n[t.LIMIT]=this.limit_;var r=this.viewFrom_;""===r&&(r=this.isViewFromLeft()?t.VIEW_FROM_LEFT:t.VIEW_FROM_RIGHT),n[t.VIEW_FROM]=r}return this.index_!==Oe&&(n[t.INDEX]=this.index_.toString()),n},e.prototype.loadsAllData=function(){return!(this.startSet_||this.endSet_||this.limitSet_)},e.prototype.isDefault=function(){return this.loadsAllData()&&this.index_==Oe},e.prototype.getNodeFilter=function(){return this.loadsAllData()?new ht(this.getIndex()):this.hasLimit()?new on(this):new rn(this)},e.prototype.toRestQueryStringParameters=function(){var t,n=e.REST_QUERY_CONSTANTS_,r={};return this.isDefault()?r:(this.index_===Oe?t=n.PRIORITY_INDEX:this.index_===He?t=n.VALUE_INDEX:this.index_===ye?t=n.KEY_INDEX:(a.assert(this.index_ instanceof Ge,"Unrecognized index type!"),t=this.index_.toString()),r[n.ORDER_BY]=a.stringify(t),this.startSet_&&(r[n.START_AT]=a.stringify(this.indexStartValue_),this.startNameSet_&&(r[n.START_AT]+=","+a.stringify(this.indexStartName_))),this.endSet_&&(r[n.END_AT]=a.stringify(this.indexEndValue_),this.endNameSet_&&(r[n.END_AT]+=","+a.stringify(this.indexEndName_))),this.limitSet_&&(this.isViewFromLeft()?r[n.LIMIT_TO_FIRST]=this.limit_:r[n.LIMIT_TO_LAST]=this.limit_),r)},e.WIRE_PROTOCOL_CONSTANTS_={INDEX_START_VALUE:"sp",INDEX_START_NAME:"sn",INDEX_END_VALUE:"ep",INDEX_END_NAME:"en",LIMIT:"l",VIEW_FROM:"vf",VIEW_FROM_LEFT:"l",VIEW_FROM_RIGHT:"r",INDEX:"i"},e.REST_QUERY_CONSTANTS_={ORDER_BY:"orderBy",PRIORITY_INDEX:"$priority",VALUE_INDEX:"$value",KEY_INDEX:"$key",START_AT:"startAt",END_AT:"endAt",LIMIT_TO_FIRST:"limitToFirst",LIMIT_TO_LAST:"limitToLast"},e.DEFAULT=new e,e}(),sn=function(e){function t(t,n){if(!(t instanceof nn))throw new Error("new Reference() no longer supported - use app.database().");return e.call(this,t,n,an.DEFAULT,!1)||this}return o.__extends(t,e),t.prototype.getKey=function(){return a.validateArgCount("Reference.key",0,0,arguments.length),this.path.isEmpty()?null:this.path.getBack()},t.prototype.child=function(e){return a.validateArgCount("Reference.child",1,1,arguments.length),"number"==typeof e?e=String(e):e instanceof z||(null===this.path.getFront()?se("Reference.child",1,e,!1):ae("Reference.child",1,e,!1)),new t(this.repo,this.path.child(e))},t.prototype.getParent=function(){a.validateArgCount("Reference.parent",0,0,arguments.length);var e=this.path.parent();return null===e?null:new t(this.repo,e)},t.prototype.getRoot=function(){a.validateArgCount("Reference.root",0,0,arguments.length);for(var e=this;null!==e.getParent();)e=e.getParent();return e},t.prototype.databaseProp=function(){return this.repo.database},t.prototype.set=function(e,t){a.validateArgCount("Reference.set",1,2,arguments.length),ce("Reference.set",this.path),ee("Reference.set",1,e,this.path,!1),a.validateCallback("Reference.set",2,t,!0);var n=new a.Deferred;return this.repo.setWithPriority(this.path,e,null,n.wrapCallback(t)),n.promise},t.prototype.update=function(e,t){if(a.validateArgCount("Reference.update",1,2,arguments.length),ce("Reference.update",this.path),Array.isArray(e)){for(var n={},r=0;r0},e.prototype.isEmpty=function(){return null===this.getValue()&&!this.hasChildren()},e.prototype.forEachChild=function(t){var n=this;N(this.node_.children,(function(r,i){t(new e(r,n,i))}))},e.prototype.forEachDescendant=function(e,t,n){t&&!n&&e(this),this.forEachChild((function(t){t.forEachDescendant(e,!0,n)})),t&&n&&e(this)},e.prototype.forEachAncestor=function(e,t){for(var n=t?this:this.parent();null!==n;){if(e(n))return!0;n=n.parent()}return!1},e.prototype.forEachImmediateDescendantWithValue=function(e){this.forEachChild((function(t){null!==t.getValue()?e(t):t.forEachImmediateDescendantWithValue(e)}))},e.prototype.path=function(){return new z(null===this.parent_?this.name_:this.parent_.path()+"/"+this.name_)},e.prototype.name=function(){return this.name_},e.prototype.parent=function(){return this.parent_},e.prototype.updateParents_=function(){null!==this.parent_&&this.parent_.updateChild_(this.name_,this)},e.prototype.updateChild_=function(e,t){var n=t.isEmpty(),r=a.contains(this.node_.children,e);n&&r?(delete this.node_.children[e],this.node_.childCount--,this.updateParents_()):n||r||(this.node_.children[e]=t.node_,this.node_.childCount++,this.updateParents_())},e}();!function(e){e[e.RUN=0]="RUN",e[e.SENT=1]="SENT",e[e.COMPLETED=2]="COMPLETED",e[e.SENT_NEEDS_ABORT=3]="SENT_NEEDS_ABORT",e[e.NEEDS_ABORT=4]="NEEDS_ABORT"}(cn||(cn={})),nn.MAX_TRANSACTION_RETRIES_=25,nn.prototype.transactions_init_=function(){this.transactionQueueTree_=new ln},nn.prototype.startTransaction=function(e,t,n,r){this.log_("transaction on "+e);var i=function(){},o=new sn(this,e);o.on("value",i);var s={path:e,update:t,onComplete:n,status:null,order:m(),applyLocally:r,retryCount:0,unwatcher:function(){o.off("value",i)},abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},c=this.getLatestState_(e);s.currentInputSnapshot=c;var u=s.update(c.val());if(void 0===u){if(s.unwatcher(),s.currentOutputSnapshotRaw=null,s.currentOutputSnapshotResolved=null,s.onComplete){var l=new Ke(s.currentInputSnapshot,new sn(this,s.path),Oe);s.onComplete(null,!1,l)}}else{te("transaction failed: Data returned ",u,s.path),s.status=cn.RUN;var d=this.transactionQueueTree_.subTree(e),p=d.getValue()||[];p.push(s),d.setValue(p);var h=void 0;if("object"==typeof u&&null!==u&&a.contains(u,".priority"))h=a.safeGet(u,".priority"),a.assert(Z(h),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.");else h=(this.serverSyncTree_.calcCompleteEventCache(e)||Be.EMPTY_NODE).getPriority().val();h=h;var f=this.generateServerValues(),g=ze(u,h),y=et(g,f);s.currentOutputSnapshotRaw=g,s.currentOutputSnapshotResolved=y,s.currentWriteId=this.getNextWriteId_();var v=this.serverSyncTree_.applyUserOverwrite(e,y,s.currentWriteId,s.applyLocally);this.eventQueue_.raiseEventsForChangedPath(e,v),this.sendReadyTransactions_()}},nn.prototype.getLatestState_=function(e,t){return this.serverSyncTree_.calcCompleteEventCache(e,t)||Be.EMPTY_NODE},nn.prototype.sendReadyTransactions_=function(e){var t=this;if(void 0===e&&(e=this.transactionQueueTree_),e||this.pruneCompletedTransactionsBelowNode_(e),null!==e.getValue()){var n=this.buildTransactionQueue_(e);a.assert(n.length>0,"Sending zero length transaction queue"),n.every((function(e){return e.status===cn.RUN}))&&this.sendTransactionQueue_(e.path(),n)}else e.hasChildren()&&e.forEachChild((function(e){t.sendReadyTransactions_(e)}))},nn.prototype.sendTransactionQueue_=function(e,t){for(var n=this,r=t.map((function(e){return e.currentWriteId})),i=this.getLatestState_(e,r),o=i,s=i.hash(),c=0;c=nn.MAX_TRANSACTION_RETRIES_)l=!0,d="maxretry",i=i.concat(this.serverSyncTree_.ackUserWrite(c.currentWriteId,!0));else{var p=this.getLatestState_(c.path,o);c.currentInputSnapshot=p;var h=e[s].update(p.val());if(void 0!==h){te("transaction failed: Data returned ",h,c.path);var f=ze(h);"object"==typeof h&&null!=h&&a.contains(h,".priority")||(f=f.updatePriority(p.getPriority()));var m=c.currentWriteId,g=this.generateServerValues(),y=et(f,g);c.currentOutputSnapshotRaw=f,c.currentOutputSnapshotResolved=y,c.currentWriteId=this.getNextWriteId_(),o.splice(o.indexOf(m),1),i=(i=i.concat(this.serverSyncTree_.applyUserOverwrite(c.path,y,c.currentWriteId,c.applyLocally))).concat(this.serverSyncTree_.ackUserWrite(m,!0))}else l=!0,d="nodata",i=i.concat(this.serverSyncTree_.ackUserWrite(c.currentWriteId,!0))}if(this.eventQueue_.raiseEventsForChangedPath(t,i),i=[],l&&(e[s].status=cn.COMPLETED,n=e[s].unwatcher,setTimeout(n,Math.floor(0)),e[s].onComplete))if("nodata"===d){var v=new sn(this,e[s].path),b=e[s].currentInputSnapshot,E=new Ke(b,v,Oe);r.push(e[s].onComplete.bind(null,null,!1,E))}else r.push(e[s].onComplete.bind(null,new Error(d),!1,null))}this.pruneCompletedTransactionsBelowNode_(this.transactionQueueTree_);for(s=0;s0?n:null)}e.forEachChild((function(e){t.pruneCompletedTransactionsBelowNode_(e)}))},nn.prototype.abortTransactions_=function(e){var t=this,n=this.getAncestorTransactionNode_(e).path(),r=this.transactionQueueTree_.subTree(e);return r.forEachAncestor((function(e){t.abortTransactionsOnNode_(e)})),this.abortTransactionsOnNode_(r),r.forEachDescendant((function(e){t.abortTransactionsOnNode_(e)})),n},nn.prototype.abortTransactionsOnNode_=function(e){var t=e.getValue();if(null!==t){for(var n=[],r=[],i=-1,o=0;o{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){return e&&"object"==typeof e&&"default"in e?e.default:e}(n(5752)),i=n(70655),o={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},a=function(e){function t(n,r,i){var o=e.call(this,r)||this;return Object.setPrototypeOf(o,t.prototype),o.code=n,o.details=i,o}return i.__extends(t,e),t}(Error);var s=function(){function e(e){this.app=e}return e.prototype.getAuthToken=function(){return i.__awaiter(this,void 0,void 0,(function(){var e;return i.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.app.INTERNAL.getToken()];case 1:return(e=t.sent())?[2,e.accessToken]:[2,void 0];case 2:return t.sent(),[2,void 0];case 3:return[2]}}))}))},e.prototype.getInstanceIdToken=function(){return i.__awaiter(this,void 0,void 0,(function(){var e;return i.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.app.messaging?[4,this.app.messaging().getToken()]:[2,void 0];case 1:return(e=t.sent())?[2,e]:[2,void 0];case 2:return t.sent(),[2,void 0];case 3:return[2]}}))}))},e.prototype.getContext=function(){return i.__awaiter(this,void 0,void 0,(function(){var e,t;return i.__generator(this,(function(n){switch(n.label){case 0:return[4,this.getAuthToken()];case 1:return e=n.sent(),[4,this.getInstanceIdToken()];case 2:return t=n.sent(),[2,{authToken:e,instanceIdToken:t}]}}))}))},e}();function c(e,t){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r]));return n}var u=function(){function e(){}return e.prototype.encode=function(e){var t=this;if(null==e)return null;if(e instanceof Number&&(e=e.valueOf()),"number"==typeof e&&isFinite(e))return e;if(!0===e||!1===e)return e;if("[object String]"===Object.prototype.toString.call(e))return e;if(Array.isArray(e))return e.map((function(e){return t.encode(e)}));if("function"==typeof e||"object"==typeof e)return c(e,(function(e){return t.encode(e)}));throw new Error("Data cannot be encoded in JSON: "+e)},e.prototype.decode=function(e){var t=this;if(null==e)return e;if(e["@type"])switch(e["@type"]){case"type.googleapis.com/google.protobuf.Int64Value":case"type.googleapis.com/google.protobuf.UInt64Value":var n=Number(e.value);if(isNaN(n))throw new Error("Data cannot be decoded from JSON: "+e);return n;default:throw new Error("Data cannot be decoded from JSON: "+e)}return Array.isArray(e)?e.map((function(e){return t.decode(e)})):"function"==typeof e||"object"==typeof e?c(e,(function(e){return t.decode(e)})):e},e}();var l=function(){function e(e,t){var n=this;void 0===t&&(t="us-central1"),this.app_=e,this.region_=t,this.serializer=new u,this.emulatorOrigin=null,this.INTERNAL={delete:function(){return n.deleteService()}},this.contextProvider=new s(e),this.cancelAllRequests=new Promise((function(e){n.deleteService=function(){return e()}}))}return Object.defineProperty(e.prototype,"app",{get:function(){return this.app_},enumerable:!0,configurable:!0}),e.prototype._url=function(e){var t=this.app_.options.projectId,n=this.region_;return null!==this.emulatorOrigin?this.emulatorOrigin+"/"+t+"/"+n+"/"+e:"https://"+n+"-"+t+".cloudfunctions.net/"+e},e.prototype.useFunctionsEmulator=function(e){this.emulatorOrigin=e},e.prototype.httpsCallable=function(e,t){var n=this;return function(r){return n.call(e,r,t||{})}},e.prototype.postJSON=function(e,t,n){return i.__awaiter(this,void 0,void 0,(function(){var r,o;return i.__generator(this,(function(i){switch(i.label){case 0:n.append("Content-Type","application/json"),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,fetch(e,{method:"POST",body:JSON.stringify(t),headers:n})];case 2:return r=i.sent(),[3,4];case 3:return i.sent(),[2,{status:0,json:null}];case 4:o=null,i.label=5;case 5:return i.trys.push([5,7,,8]),[4,r.json()];case 6:return o=i.sent(),[3,8];case 7:return i.sent(),[3,8];case 8:return[2,{status:r.status,json:o}]}}))}))},e.prototype.call=function(e,t,n){return i.__awaiter(this,void 0,void 0,(function(){var r,s,c,u,l,d,p,h;return i.__generator(this,(function(i){switch(i.label){case 0:return r=this._url(e),t=this.serializer.encode(t),s={data:t},c=new Headers,[4,this.contextProvider.getContext()];case 1:return(u=i.sent()).authToken&&c.append("Authorization","Bearer "+u.authToken),u.instanceIdToken&&c.append("Firebase-Instance-ID-Token",u.instanceIdToken),l=n.timeout||7e4,[4,Promise.race([this.postJSON(r,s,c),(f=l,new Promise((function(e,t){setTimeout((function(){t(new a("deadline-exceeded","deadline-exceeded"))}),f)}))),this.cancelAllRequests])];case 2:if(!(d=i.sent()))throw new a("cancelled","Firebase Functions instance was deleted.");if(p=function(e,t,n){var r=function(e){if(e>=200&&e<300)return"ok";switch(e){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}(e),i=r,s=void 0;try{var c=t&&t.error;if(c){var u=c.status;if("string"==typeof u){if(!o[u])return new a("internal","internal");r=o[u],i=u}var l=c.message;"string"==typeof l&&(i=l),void 0!==(s=c.details)&&(s=n.decode(s))}}catch(d){}return"ok"===r?null:new a(r,i,s)}(d.status,d.json,this.serializer))throw p;if(!d.json)throw new a("internal","Response is not valid JSON object.");if(void 0===(h=d.json.data)&&(h=d.json.result),void 0===h)throw new a("internal","Response is missing data field.");return[2,{data:this.serializer.decode(h)}]}var f}))}))},e}(),d="functions";function p(e,t,n){return new l(e,n)}function h(e){var t={Functions:l};e.INTERNAL.registerService(d,p,t,void 0,!0)}h(r),t.registerFunctions=h},14594:(e,t,n)=>{"use strict";n.r(t),n.d(t,{LogLevel:()=>r,Logger:()=>s,setLogLevel:()=>c});var r,i=[];!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(r||(r={}));var o=r.INFO,a=function(e,t){for(var n=[],i=2;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(70655),i={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},o=function(e,t){if(!e)throw a(t)},a=function(e){return new Error("Firebase Database ("+i.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)},s=function(e){for(var t=[],n=0,r=0;r>6|192,t[n++]=63&i|128):55296==(64512&i)&&r+1>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=63&i|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=63&i|128)}return t},c={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray:function(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();for(var n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[],i=0;i>2,d=(3&o)<<4|s>>4,p=(15&s)<<2|u>>6,h=63&u;c||(h=64,a||(p=64)),r.push(n[l],n[d],n[p],n[h])}return r.join("")},encodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(s(e),t)},decodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){for(var t=[],n=0,r=0;n191&&i<224){var o=e[n++];t[r++]=String.fromCharCode((31&i)<<6|63&o)}else if(i>239&&i<365){var a=((7&i)<<18|(63&(o=e[n++]))<<12|(63&(s=e[n++]))<<6|63&e[n++])-65536;t[r++]=String.fromCharCode(55296+(a>>10)),t[r++]=String.fromCharCode(56320+(1023&a))}else{o=e[n++];var s=e[n++];t[r++]=String.fromCharCode((15&i)<<12|(63&o)<<6|63&s)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray:function(e,t){this.init_();for(var n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[],i=0;i>4;if(r.push(u),64!==s){var l=a<<4&240|s>>2;if(r.push(l),64!==c){var d=s<<6&192|c;r.push(d)}}}return r},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var e=0;e=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}},u=function(e){try{return c.decodeString(e,!0)}catch(t){console.error("base64Decode failed: ",t)}return null};function l(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(var n in t)t.hasOwnProperty(n)&&(e[n]=l(e[n],t[n]));return e}var d=function(){function e(){var e=this;this.reject=function(){},this.resolve=function(){},this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))}return e.prototype.wrapCallback=function(e){var t=this;return function(n,r){n?t.reject(n):t.resolve(r),"function"==typeof e&&(t.promise.catch((function(){})),1===e.length?e(n):e(n,r))}},e}();function p(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}var h="FirebaseError",f=function(e){function t(n,r){var i=e.call(this,r)||this;return i.code=n,i.name=h,Object.setPrototypeOf(i,t.prototype),Error.captureStackTrace&&Error.captureStackTrace(i,m.prototype.create),i}return r.__extends(t,e),t}(Error),m=function(){function e(e,t,n){this.service=e,this.serviceName=t,this.errors=n}return e.prototype.create=function(e){for(var t=[],n=1;n"}))}var y=/\{\$([^}]+)}/g;function v(e){return JSON.parse(e)}var b=function(e){var t={},n={},r={},i="";try{var o=e.split(".");t=v(u(o[0])||""),n=v(u(o[1])||""),i=o[2],r=n.d||{},delete n.d}catch(a){}return{header:t,claims:n,data:r,signature:i}};var E=function(){function e(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(var e=1;e>>31)}var o,a,s=this.chain_[0],c=this.chain_[1],u=this.chain_[2],l=this.chain_[3],d=this.chain_[4];for(r=0;r<80;r++){r<40?r<20?(o=l^c&(u^l),a=1518500249):(o=c^u^l,a=1859775393):r<60?(o=c&u|l&(c|u),a=2400959708):(o=c^u^l,a=3395469782);i=(s<<5|s>>>27)+o+d+a+n[r]&4294967295;d=l,l=u,u=4294967295&(c<<30|c>>>2),c=s,s=i}this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+c&4294967295,this.chain_[2]=this.chain_[2]+u&4294967295,this.chain_[3]=this.chain_[3]+l&4294967295,this.chain_[4]=this.chain_[4]+d&4294967295},e.prototype.update=function(e,t){if(null!=e){void 0===t&&(t=e.length);for(var n=t-this.blockSize,r=0,i=this.buf_,o=this.inbuf_;r=56;n--)this.buf_[n]=255&t,t/=256;this.compress_(this.buf_);var r=0;for(n=0;n<5;n++)for(var i=24;i>=0;i-=8)e[r]=this.chain_[n]>>i&255,++r;return e},e}();var w=function(){function e(e,t){var n=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then((function(){e(n)})).catch((function(e){n.error(e)}))}return e.prototype.next=function(e){this.forEachObserver((function(t){t.next(e)}))},e.prototype.error=function(e){this.forEachObserver((function(t){t.error(e)})),this.close(e)},e.prototype.complete=function(){this.forEachObserver((function(e){e.complete()})),this.close()},e.prototype.subscribe=function(e,t,n){var r,i=this;if(void 0===e&&void 0===t&&void 0===n)throw new Error("Missing Observer.");void 0===(r=function(e,t){if("object"!=typeof e||null===e)return!1;for(var n=0,r=t;n 4. Need to update it?")}var i=e+" failed: ";return i+=r+" argument "}t.CONSTANTS=i,t.Deferred=d,t.ErrorFactory=m,t.FirebaseError=f,t.Sha1=E,t.assert=o,t.assertionError=a,t.async=function(e,t){return function(){for(var n=[],r=0;r=r&&n<=i},t.issuedAtTime=function(e){var t=b(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null},t.jsonEval=v,t.map=function(e,t,n){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=t.call(n,e[i],i,e));return r},t.querystring=function(e){for(var t=[],n=function(e,n){Array.isArray(n)?n.forEach((function(n){t.push(encodeURIComponent(e)+"="+encodeURIComponent(n))})):t.push(encodeURIComponent(e)+"="+encodeURIComponent(n))},r=0,i=Object.entries(e);r=55296&&r<=56319?(t+=4,n++):t+=3}return t},t.stringToByteArray=function(e){for(var t=[],n=0,r=0;r=55296&&i<=56319){var a=i-55296;r++,o(r>6|192,t[n++]=63&i|128):i<65536?(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=63&i|128):(t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=63&i|128)}return t},t.stringify=function(e){return JSON.stringify(e)},t.validateArgCount=function(e,t,n,r){var i;if(rn&&(i=0===n?"none":"no more than "+n),i)throw new Error(e+" failed: Was called with "+r+(1===r?" argument.":" arguments.")+" Expects "+i+".")},t.validateCallback=function(e,t,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(x(e,t,r)+"must be a valid function.")},t.validateContextObject=function(e,t,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(x(e,t,r)+"must be a valid context object.")},t.validateNamespace=function(e,t,n,r){if((!r||n)&&"string"!=typeof n)throw new Error(x(e,t,r)+"must be a valid firebase namespace.")}},51211:(e,t,n)=>{"use strict";n.d(t,{zi:()=>d,Zc:()=>l,tj:()=>p,ar:()=>a});var r=n(92974),i=n.n(r),o=n(34155);const a=i(),s=Boolean(void 0!==o&&o.env&&!1),c="undefined"!=typeof console&&"function"==typeof console.log&&"function"==typeof console.warn&&"function"==typeof console.error;function u(e,t,...n){s&&c&&console[e](t,...n)}function l(e,...t){u("warn",`Warning: ${e}`,...t)}function d(e,t,...n){u("warn",`Deprecation (${e}): ${t}`,...n)}function p(e){setTimeout(()=>{throw e},0)}},92974:(e,t,n)=>{var r=n(34155);function i(){var e;try{e=t.storage.debug}catch(n){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}(t=e.exports=n(73221)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))})),e.splice(o,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(n){}},t.load=i,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"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+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},t.enable(i())},73221:(e,t,n)=>{function r(e){var n;function r(){if(r.enabled){var e=r,i=+new Date,o=i-(n||i);e.diff=o,e.prev=n,e.curr=i,n=i;for(var a=new Array(arguments.length),s=0;s{var t=1e3,n=60*t,r=60*n,i=24*r,o=365.25*i;function a(e,t,n){if(!(e0)return function(e){if((e=String(e)).length>100)return;var a=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!a)return;var s=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return s*o;case"days":case"day":case"d":return s*i;case"hours":case"hour":case"hrs":case"hr":case"h":return s*r;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}(e);if("number"===u&&!1===isNaN(e))return s.long?a(c=e,i,"day")||a(c,r,"hour")||a(c,n,"minute")||a(c,t,"second")||c+" ms":function(e){if(e>=i)return Math.round(e/i)+"d";if(e>=r)return Math.round(e/r)+"h";if(e>=n)return Math.round(e/n)+"m";if(e>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},57212:(e,t,n)=>{"use strict";n.d(t,{UG:()=>l,Bm:()=>d,m:()=>p,BY:()=>h,ru:()=>f,Sh:()=>m,yy:()=>g,gS:()=>y,wS:()=>v});var r=n(33827);const i=[["edge",/Edge\/([0-9\._]+)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)$/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+)\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["android",/Android\s([0-9\.]+)/],["safari",/Version\/([0-9\._]+).*Safari/]],o=[["beforeinput",e=>"onbeforeinput"in e]],a=[["ios",/os ([\.\_\d]+) like mac os/i],["macos",/mac os x/i],["android",/android/i],["firefoxos",/mozilla\/[a-z\.\_\d]+ \((?:mobile)|(?:tablet)/i],["windows",/windows\s*(?:nt)?\s*([\.\_\d]+)/i]];let s;const c={};let u;if(r.b){const{userAgent:e}=window.navigator;for(const[n,r]of i)if(r.test(e)){s=n;break}for(const[n,r]of a)if(r.test(e)){u=n;break}const t=window.document.createElement("div");t.contentEditable="true";for(const[n,r]of o)c[n]=r(t)}const l=Boolean(r.b),d="firefox"===s,p="safari"===s,h="ie"===s,f="edge"===s,m="android"===u,g="ios"===u,y="macos"===u,v=c},69e3:(e,t,n)=>{"use strict";n.d(t,{b:()=>v});var r=n(35369),i=n(69929),o=n(40214);const a={type:"blockquote",typeDefault:"paragraph",exitBlockType:"paragraph"};class s extends((0,r.Record)(a)){}function c(e,t){return t.unwrapBlock(e.type)}function u(e,t){return t.wrapBlock(e.type)}function l(e,t,n){const{document:r}=t;if(!n){if(!t.selection.startKey)return null;n=t.startBlock}const i=r.getParent(n.key);return i&&i.type===e.type?i:null}function d(e,t){return Boolean(l(e,t))}function p(e,t){return(n,...r)=>{const{value:i}=n;return d(e,i)?t(...[e,n].concat(r)):n}}const h="Enter",f="Backspace";function m(e,t,n,r){const o=[e,t,n,r];switch(t.key){case h:return t.metaKey&&e.exitBlockType?function(e,t,n){const{value:r}=n,o=l(e,r);if(!o)return;t.preventDefault();const a=i.AB.create({type:e.exitBlockType,nodes:[i.Hr.create("")]}),s=r.document.getParent(o.key),c=s.getChildIndex(o.key);return n.insertNodeByKey(s.key,c+1,a).collapseToStartOf(a)}(...o):function(e,t,n,r){const{value:i}=n,{startBlock:o}=i;if(l(e,i)&&0===o.text.length)return t.preventDefault(),c(e,n)}(...o);case f:return function(e,t,n,r){const{value:i}=n,{startOffset:o,selection:a,isCollapsed:s}=i;if(!s)return;if(o>0)return;const u=l(e,i);if(!u)return;const d=u.getClosestBlock(a.anchorKey);return a.isAtStartOf(d)?(t.preventDefault(),c(e,n)):void 0}(...o);default:return}}function g(e){return{onKeyDown:m.bind(null,e)}}function y(e){return i.RI.create({blocks:{[e.type]:{nodes:[{objects:["block"]}],normalize(t,n,r){switch(n){case o.ue:return function(e,t,n){const r=n.node.nodes.filter(e=>"block"!==e.object);if(r.isEmpty())return;const o=i.AB.create({type:e.typeDefault,nodes:[]});return t.insertNodeByKey(n.node.key,0,o,{normalize:!1}),r.forEach((e,n)=>{const i=n===r.size-1;t.moveNodeByKey(e.key,o.key,n,{normalize:i})}),t}(e,t,r);default:return}}}}})}const v=function(e={}){const t=function(e){return{utils:{isSelectionInBlockquote:d.bind(null,e)},changes:{wrapInBlockquote:u.bind(null,e),unwrapBlockquote:p(e,c)}}}(e=new s(e));return Object.assign({},t,{schema:y(e),plugin:g(e)})}},44036:(e,t,n)=>{"use strict";n.d(t,{b:()=>U});var r=n(57212),i=n(18156);const o=r.yy||r.gS,a=(0,i.isKeyHotkey)("mod+b"),s=(0,i.isKeyHotkey)("mod+i"),c=(0,i.isKeyHotkey)("enter"),u=(0,i.isKeyHotkey)("shift+enter"),l=e=>c(e)||u(e),d=(0,i.isKeyHotkey)("backspace"),p=(0,i.isKeyHotkey)("shift+backspace"),h=(0,i.isKeyHotkey)("delete"),f=(0,i.isKeyHotkey)("shift+delete"),m=(0,i.isKeyHotkey)("ctrl+h"),g=(0,i.isKeyHotkey)("ctrl+d"),y=e=>(e=>d(e)||p(e))(e)||o&&m(e),v=e=>(e=>h(e)||f(e))(e)||o&&g(e),b=(0,i.isKeyHotkey)("ctrl+k"),E=e=>o&&(e=>(0,i.isKeyHotkey)("cmd+shift+backspace",e)||(0,i.isKeyHotkey)("cmd+backspace",e))(e),w=e=>o&&b(e),_=(0,i.isKeyHotkey)("ctrl+backspace"),x=(0,i.isKeyHotkey)("ctrl+delete"),S=e=>o?(e=>(0,i.isKeyHotkey)("shift+option+backspace",e)||(0,i.isKeyHotkey)("option+backspace",e))(e):_(e),k=e=>o?(e=>(0,i.isKeyHotkey)("shift+option+delete",e)||(0,i.isKeyHotkey)("option+delete",e))(e):x(e),O=(0,i.isKeyHotkey)("shift+right"),T=(0,i.isKeyHotkey)("shift+left"),A=(0,i.isKeyHotkey)("right"),I=(0,i.isKeyHotkey)("left"),D=(0,i.isKeyHotkey)("option+up"),C=(0,i.isKeyHotkey)("option+down"),P=(0,i.isKeyHotkey)("option+shift+up"),R=(0,i.isKeyHotkey)("option+shift+down"),N=(0,i.isKeyHotkey)("mod+z"),L=(0,i.isKeyHotkey)("mod+shift+z"),j=(0,i.isKeyHotkey)("mod+y"),M=e=>o?L(e):j(e),B=(0,i.isKeyHotkey)("mod+shift+v"),F=(0,i.isKeyHotkey)("ctrl+t"),U={isBold:a,isCollapseCharBackward:e=>I(e)&&!T(e),isCollapseCharForward:e=>A(e)&&!O(e),isCollapseLineBackward:e=>o&&D(e),isCollapseLineForward:e=>o&&C(e),isComposing:e=>"ArrowDown"===e.key||"ArrowLeft"===e.key||"ArrowRight"===e.key||"ArrowUp"===e.key||"Backspace"===e.key||"Enter"===e.key,isContentEditable:e=>a(e)||y(e)||v(e)||E(e)||w(e)||S(e)||k(e)||s(e)||M(e)||l(e)||(e=>o&&F(e))(e)||N(e),isDeleteCharBackward:y,isDeleteCharForward:v,isDeleteLineBackward:E,isDeleteLineForward:w,isDeleteWordBackward:S,isDeleteWordForward:k,isExtendCharBackward:T,isExtendCharForward:O,isExtendLineBackward:e=>o&&P(e),isExtendLineForward:e=>o&&R(e),isItalic:s,isRedo:M,isSplitBlock:l,isUndo:N,isRawPaste:B}},73620:(e,t,n)=>{"use strict";n.d(t,{b:()=>a});var r=n(69929),i=n(35369);function o(e){return"document"===e.object||"block"===e.object&&r.AB.isBlockList(e.nodes)?e.nodes.map(o).join("\n"):e.text}const a={deserialize:function(e,t={}){let{defaultBlock:n="line",defaultMarks:o=[]}=t;const{toJSON:a=!1}=t;i.Set.isSet(o)&&(o=o.toArray()),n=r.LD.createProperties(n),o=o.map(r.nH.createProperties);const s={object:"value",document:{object:"document",data:{},nodes:e.split("\n").map(e=>Object.assign({},n,{object:"block",isVoid:!1,data:{},nodes:[{object:"text",leaves:[{object:"leaf",text:e,marks:o}]}]}))}};return a?s:r.Nb.fromJS(s)},serialize:function(e){return o(e.document)}}},39856:(e,t,n)=>{"use strict";var r=n(51211),i=n(57212),o=n(84025),a=n.n(o),s=n(67294),c=n(73935),u=n.n(c),l=n(69929),d=n(67869);function p(e){const t=JSON.stringify(e);return(0,d.btoa)(encodeURIComponent(t))}function h(e){const t=decodeURIComponent((0,d.atob)(e));return JSON.parse(t)}const f={deserialize:function(e,t){const n=h(e);return l.Nb.fromJS(n,t)},deserializeNode:function(e,t){const n=h(e);return l.LD.fromJS(n,t)},serialize:function(e,t){return p(e.toJS(t))},serializeNode:function(e,t){return p(e.toJS(t))}};var m=n(44036),g=n(73620),y=n(48528),v=n.n(y),b=n(35369),E=n(259),w=n.n(E);n.d(t,{iZ:()=>ge,ds:()=>F,AF:()=>S,vH:()=>U,qC:()=>Y});const _=["onBeforeInput","onBlur","onClick","onContextMenu","onCompositionEnd","onCompositionStart","onCopy","onCut","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop","onInput","onFocus","onKeyDown","onKeyUp","onPaste","onSelect"],x={FRAGMENT:"application/x-slate-fragment",HTML:"text/html",NODE:"application/x-slate-node",RICH:"text/rtf",TEXT:"text/plain"};function S(e,t=window){l.LD.isNode(e)&&(e=e.key);const n=t.document.querySelector(`[data-key="${e}"]`);return n||((0,r.Zc)(`Unable to find a DOM node for "${e}". This is often because of forgetting to add \`props.attributes\` to a custom component.`),null)}const k=/^([\w-]+)(?::(\d+))?$/;var O={parse:function(e){const t=k.exec(e);if(!t)throw new Error(`Invalid offset key string "${e}".`);return{key:t[1],index:parseInt(t[2],10)}},stringify:function(e){return`${e.key}:${e.index}`}};const T="data-slate-zero-width",A=`[${T}]`,I="data-offset-key",D=`[${I}]`,C="[data-key]",P="[data-slate-void]";function R(e,t,n){const{node:r,offset:o}=function(e,t){if(1===e.nodeType&&e.childNodes.length){const n=t===e.childNodes.length,r=n?"backward":"forward";for(e=N(e,n?t-1:t,r);1===e.nodeType&&e.childNodes.length;){const t=n?e.childNodes.length-1:0;e=N(e,t,r)}t=n?e.textContent.length:0}return{node:e,offset:t}}(e,t),s=a()(e),{parentNode:c}=r;let u,l,d=c.closest(D);if(d){const e=s.document.createRange(),t=d.closest(C);e.setStart(t,0),e.setEnd(r,o),l=t,u=i.ru?e.cloneContents().textContent.length:e.toString().length}else{const e=c.closest(P);if(!e)return null;if(!(d=e.querySelector(D)))return null;u=(l=d).textContent.length}u===l.textContent.length&&c.hasAttribute(T)&&u--;const p=d.getAttribute(I);if(!p)return null;const{key:h}=O.parse(p);return n.document.hasDescendant(h)?{key:h,offset:u}:null}function N(e,t,n){const{childNodes:r}=e;let i=r[t],o=t,a=!1,s=!1;for(;(8===i.nodeType||1===i.nodeType&&0===i.childNodes.length||1===i.nodeType&&"false"===i.getAttribute("contenteditable"))&&(!a||!s);)o>=r.length?(a=!0,o=t-1,n="backward"):o<0?(s=!0,o=t+1,n="forward"):(i=r[o],"forward"===n&&o++,"backward"===n&&o--);return i||null}function L(e){const t=window.document;if(t&&t.body.createTextRange){const e=t.body.createTextRange();e.collapse(),e.select()}else e.removeAllRanges()}const{FRAGMENT:j,HTML:M,TEXT:B}=x;function F(e,t,n=t.fragment){const o=a()(e.target),s=o.getSelection(),{startKey:c,endKey:u}=t,d=t.document.getClosestVoid(c),p=t.document.getClosestVoid(u);if(s.rangeCount<1)return void(0,r.tj)(new Error("Cannot copy a selection with no range"));if(s.isCollapsed&&!d)return;const h=f.serializeNode(n),m=s.getRangeAt(0);let y=m.cloneContents(),v=y.childNodes[0];if(Array.from(y.childNodes).forEach(e=>{e.textContent&&""!==e.textContent.trim()&&(v=e)}),p){const e=m.cloneRange(),t=S(p,o);t&&(e.setEndAfter(t),y=e.cloneContents())}if(d&&(v=y.childNodes[0].childNodes[1].firstChild),[].slice.call(y.querySelectorAll(A)).forEach(e=>{const t="n"===e.getAttribute(T);e.textContent=t?"\n":""}),3===v.nodeType){const e=o.document.createElement("span");e.style.whiteSpace="pre",e.appendChild(v),y.appendChild(e),v=e}v.setAttribute("data-slate-fragment",h);const b=l.Nb.create({document:n}),E=g.b.serialize(b),w=o.document.createElement("div");if(w.appendChild(y),e.clipboardData&&e.clipboardData.setData&&!i.BY)return e.preventDefault(),e.clipboardData.setData(B,E),e.clipboardData.setData(j,h),void e.clipboardData.setData(M,w.innerHTML);const _=e.target.closest("[data-slate-editor]");w.setAttribute("contenteditable",!0),w.style.position="absolute",w.style.left="-9999px",_.appendChild(w),s.selectAllChildren(w),o.requestAnimationFrame(()=>{_.removeChild(w),L(s),s.addRange(m)})}function U(e,t){const n=e.closest("[data-key]");if(!n)return null;const r=n.getAttribute("data-key");return r&&t.document.getNode(r)||null}function z(e,t,n=window){const r=S(e,n);if(!r)return null;let i=0;const o=n.document.createNodeIterator(r,NodeFilter.SHOW_TEXT,()=>NodeFilter.FILTER_ACCEPT);for(;;){const e=o.nextNode();if(!e)break;const{length:n}=e.textContent,r=i+n;if(t<=r){const n=t-i;return{node:e,offset:n>=0?n:0}}i=r}return null}function $(e,t){const n=e.anchorNode||e.startContainer;if(!n)return null;const r=a()(n);(e instanceof r.Range||r.StaticRange&&e instanceof r.StaticRange)&&(e={anchorNode:e.startContainer,anchorOffset:e.startOffset,focusNode:e.endContainer,focusOffset:e.endOffset});const{anchorNode:o,anchorOffset:s,focusNode:c,focusOffset:u,isCollapsed:d}=e,p=R(o,s,t),h=d?p:R(c,u,t);if(!p||!h)return null;if(i.BY||i.ru){const t=z(p.key,p.offset),n=z(h.key,h.offset);t&&n&&(e={anchorNode:t.node,anchorOffset:t.offset,focusNode:n.node,focusOffset:n.offset})}return l.aS.create({anchorKey:p.key,anchorOffset:p.offset,focusKey:h.key,focusOffset:h.offset,isBackward:!d&&v()(e),isFocused:!0})}const{FRAGMENT:q,HTML:H,NODE:G,RICH:K,TEXT:V}=x,W=/ data-slate-fragment="([^\s"]+)"/;function Y(e){!i.BY&&e.nativeEvent&&(e=e.nativeEvent);const t=e.dataTransfer||e.clipboardData;let n=J(t,q),r=J(t,G);const o=J(t,H),a=J(t,K);let s,c=J(t,V);if(!n&&o&&o.indexOf(' data-slate-fragment="')>=0){const e=W.exec(o)[1];e&&(n=e)}if(c){const e=function(e){const t="SLATE-DATA-EMBED::";if(e.substring(0,t.length)!==t)return{TEXT:e};try{return JSON.parse(e.substring(t.length))}catch(n){throw new Error("Unable to parse custom Slate drag event data.")}}(c);e[q]&&(n=e[q]),e[G]&&(r=e[G]),e[V]&&(c=e[V])}n&&(n=f.deserializeNode(n)),r&&(r=f.deserializeNode(r));try{t.items&&t.items.length?s=Array.from(t.items).map(e=>"file"===e.kind?e.getAsFile():null).filter(e=>e):t.files&&t.files.length&&(s=Array.from(t.files))}catch(l){t.files&&t.files.length&&(s=Array.from(t.files))}const u={files:s,fragment:n,html:o,node:r,rich:a,text:c};return u.type=function(e){if(e.fragment)return"fragment";if(e.node)return"node";if(e.rich&&e.html)return"html";if(e.rich&&e.text)return"text";if(e.files&&e.files.length)return"files";if(e.html)return"html";if(e.text)return"text";return"unknown"}(u),u}function J(e,t){if(!e.types||!e.types.length)return t===V&&e.getData("Text")||null;return-1!==Array.from(e.types).indexOf(t)&&e.getData(t)||null}const{TEXT:Q}=x;function X(e,t,n){const r=x[t.toUpperCase()];if(!r)throw new Error(`Cannot set unknown transfer type "${r}".`);e.nativeEvent&&(e=e.nativeEvent);const i=e.dataTransfer||e.clipboardData;try{i.setData(r,n),i.setData("text",i.getData("text"))}catch(o){const e="SLATE-DATA-EMBED::",t=i.getData(Q);let s={};if(t.substring(0,e.length)===e)try{s=JSON.parse(t.substring(e.length))}catch(a){throw new Error("Failed to parse Slate data from `DataTransfer` object.")}else s[Q]=t;s[r]=n;const c=`${e}${JSON.stringify(s)}`;i.setData(Q,c)}}const Z=(0,r.ar)("slate:after");function ee(){let e=null;return{onBeforeInput:function(e,t,n){Z("onBeforeInput",{event:e}),e.preventDefault(),t.insertText(e.data)},onBlur:function(e,t,n){Z("onBlur",{event:e}),t.blur()},onClick:function(e,t,n){if(n.readOnly)return!0;const{value:r}=t,{document:i}=r,o=U(e.target,r);o&&((o.isVoid||i.hasVoidParent(o.key))&&t.focus().collapseToEndOf(o),Z("onClick",{event:e}))},onCopy:function(e,t,n){Z("onCopy",{event:e}),F(e,t.value)},onCut:function(e,t,n){Z("onCut",{event:e});const{value:r}=t;F(e,r),n.readOnly||a()(e.target).requestAnimationFrame(()=>{const{endBlock:e,endInline:t,isCollapsed:i}=r,o=e&&e.isVoid&&i,a=t&&t.isVoid&&i;o?n.change(t=>t.removeNodeByKey(e.key)):a?n.change(e=>e.removeNodeByKey(t.key)):n.change(e=>e.delete())})},onDragEnd:function(t,n,r){Z("onDragEnd",{event:t}),e=null},onDragOver:function(e,t,n){Z("onDragOver",{event:e})},onDragStart:function(t,n,r){Z("onDragStart",{event:t}),e=!0;const{value:i}=n,{document:o}=i,a=U(t.target,i);if(a&&(a.isVoid||o.hasVoidParent(a.key))){X(t,"node",f.serializeNode(a,{preserveKeys:!0}))}else{const{fragment:e}=i;X(t,"fragment",f.serializeNode(e))}},onDrop:function(t,n,r){Z("onDrop",{event:t});const{value:i}=n,{document:o,selection:s}=i,c=a()(t.target);let u=function(e,t){e.nativeEvent&&(e=e.nativeEvent);const{x:n,y:r,target:i}=e;if(null==n||null==r)return null;const{document:o}=t,s=U(i,t);if(!s)return null;if(s.isVoid){const e=i.getBoundingClientRect(),t="inline"===s.object?n-e.left{t>0&&n.splitBlock(),n.insertText(e)})}"fragment"===p&&n.insertFragment(h),"node"===p&&l.AB.isBlock(f)&&n.insertBlock(f.regenerateKey()).removeNodeByKey(f.key),"node"===p&&l.iE.isInline(f)&&n.insertInline(f.regenerateKey()).removeNodeByKey(f.key);const g=S(o.getNode(u.focusKey),c);g&&g.dispatchEvent(new MouseEvent("mouseup",{view:c,bubbles:!0,cancelable:!0}))},onInput:function(e,t,n){Z("onInput",{event:e});const r=a()(e.target),{value:i}=t,o=r.getSelection(),{anchorNode:s}=o,c=R(s,0,i);if(!c)return;const{document:u,selection:l}=i,d=u.getDescendant(c.key),p=u.getClosestBlock(d.key),h=d.getLeaves(),f=p.getLastText(),m=h.last();let g=0,y=0;const v=h.find(e=>{if(g=y,(y+=e.text.length)>c.offset)return!0})||m,{text:b}=v;let{textContent:E}=s;const w=d===f,_=v===m,x=E.charAt(E.length-1);if(w&&_&&"\n"===x&&(E=E.slice(0,-1)),E===b)return;const S=E.length-b.length,k=l.collapseToEnd().move(S),O=l.moveAnchorTo(c.key,g).moveFocusTo(c.key,y);t.insertTextAtRange(O,E,v.marks).select(k)},onKeyDown:function(e,t,n){Z("onKeyDown",{event:e});const{value:r}=t;if(m.b.isSplitBlock(e)&&!i.yy)return r.isInVoid?t.collapseToStartOfNextText():t.splitBlock();if(m.b.isDeleteCharBackward(e)&&!i.yy)return t.deleteCharBackward();if(m.b.isDeleteCharForward(e)&&!i.yy)return t.deleteCharForward();if(m.b.isDeleteLineBackward(e))return t.deleteLineBackward();if(m.b.isDeleteLineForward(e))return t.deleteLineForward();if(m.b.isDeleteWordBackward(e))return t.deleteWordBackward();if(m.b.isDeleteWordForward(e))return t.deleteWordForward();if(m.b.isRedo(e))return t.redo();if(m.b.isUndo(e))return t.undo();if(m.b.isCollapseLineBackward(e))return e.preventDefault(),t.collapseLineBackward();if(m.b.isCollapseLineForward(e))return e.preventDefault(),t.collapseLineForward();if(m.b.isExtendLineBackward(e))return e.preventDefault(),t.extendLineBackward();if(m.b.isExtendLineForward(e))return e.preventDefault(),t.extendLineForward();if(m.b.isCollapseCharBackward(e)){const{document:n,isInVoid:i,previousText:o,startText:a}=r,s=o&&n.hasVoidParent(o.key);if(i||s||""===a.text)return e.preventDefault(),t.collapseCharBackward()}if(m.b.isCollapseCharForward(e)){const{document:n,isInVoid:i,nextText:o,startText:a}=r,s=o&&n.hasVoidParent(o.key);if(i||s||""===a.text)return e.preventDefault(),t.collapseCharForward()}if(m.b.isExtendCharBackward(e)){const{document:n,isInVoid:i,previousText:o,startText:a}=r,s=o&&n.hasVoidParent(o.key);if(i||s||""===a.text)return e.preventDefault(),t.extendCharBackward()}if(m.b.isExtendCharForward(e)){const{document:n,isInVoid:i,nextText:o,startText:a}=r,s=o&&n.hasVoidParent(o.key);if(i||s||""===a.text)return e.preventDefault(),t.extendCharForward()}},onPaste:function(e,t,n){Z("onPaste",{event:e});const r=Y(e),{type:i,fragment:o,text:a}=r;if("fragment"===i&&t.insertFragment(o),"text"===i||"html"===i){if(!a)return;const{value:e}=t,{document:n,selection:r,startBlock:i}=e;if(i.isVoid)return;const o=i,s=n.getInsertMarksAtRange(r),c=g.b.deserialize(a,{defaultBlock:o,defaultMarks:s}).document;t.insertFragment(c)}},onSelect:function(e,t,n){Z("onSelect",{event:e});const r=a()(e.target),{value:i}=t,{document:o}=i,s=r.getSelection();if(!s.rangeCount)return void t.blur();let c=$(s,i);if(!c)return;const{anchorKey:u,anchorOffset:l,focusKey:d,focusOffset:p}=c,h=o.getNode(u),f=o.getNode(d),m=o.getClosestInline(u),g=o.getClosestInline(d),y=o.getClosestBlock(d),v=o.getClosestBlock(u);if(v&&!v.isVoid&&0===l&&y&&y.isVoid&&0!==p&&(c=c.set("focusOffset",0)),m&&!m.isVoid&&l===h.text.length){const e=o.getClosestBlock(u).getNextText(u);e&&(c=c.moveAnchorTo(e.key,0))}if(g&&!g.isVoid&&p===f.text.length){const e=o.getClosestBlock(d).getNextText(d);e&&(c=c.moveFocusTo(e.key,0))}c=(c=c.normalize(o)).set("marks",i.selection.marks),t.select(c)},renderNode:function(e){const{attributes:t,children:n,node:r}=e;if("block"!==r.object&&"inline"!==r.object)return;const i="block"===r.object?"div":"span";return(0,s.createElement)(i,Object.assign({},t,{style:{position:"relative"}}),n)}}}const te=(0,r.ar)("slate:before");function ne(){let e=null,t=0,n=!1,r=!1,o=!1;return{onBeforeInput:function(e,t,n){return!!n.readOnly||(!(!i.yy&&!i.Sh||!i.wS.beforeinput)||void te("onBeforeInput",{event:e}))},onBlur:function(t,n,i){if(r)return!0;if(i.readOnly)return!0;const{value:o}=n,{relatedTarget:s,target:c}=t,u=a()(c);if(e===u.document.activeElement)return!0;if(s){const e=i.element;if(s===e)return!0;if(s.hasAttribute("data-slate-spacer"))return!0;const t=U(s,o);if(e.contains(s)&&t&&!t.isVoid)return!0}te("onBlur",{event:t})},onCompositionEnd:function(e,r,i){const o=t;window.requestAnimationFrame(()=>{t>o||(n=!1)}),te("onCompositionEnd",{event:e})},onCompositionStart:function(e,r,i){n=!0,t++,te("onCompositionStart",{event:e})},onCopy:function(e,t,n){const i=a()(e.target);if(!function(e,t,n){const{readOnly:r}=n,{value:i}=t;if(!r)return!0;const o=$(a()(e.target).getSelection(),i);return!!o&&(t.select(o),!0)}(e,t,n))return!0;r=!0,i.requestAnimationFrame(()=>r=!1),te("onCopy",{event:e})},onCut:function(e,t,n){const i=a()(e.target);r=!0,i.requestAnimationFrame(()=>r=!1),te("onCut",{event:e})},onDragEnd:function(e,t,n){o=!1,te("onDragEnd",{event:e})},onDragEnter:function(e,t,n){te("onDragEnter",{event:e})},onDragExit:function(e,t,n){te("onDragExit",{event:e})},onDragLeave:function(e,t,n){te("onDragLeave",{event:e})},onDragOver:function(e,t,n){U(e.target,n.value).isVoid&&e.preventDefault(),i.BY&&e.preventDefault(),o||(o=!0,i.BY||(e.nativeEvent.dataTransfer.dropEffect="move")),te("onDragOver",{event:e})},onDragStart:function(e,t,n){o=!0,te("onDragStart",{event:e})},onDrop:function(e,t,n){if(n.readOnly)return!0;e.preventDefault(),te("onDrop",{event:e})},onFocus:function(t,n,o){if(r)return!0;if(o.readOnly)return!0;const s=o.element,c=a()(t.target);if(e=c.document.activeElement,i.Bm&&t.target!==s)return s.focus(),!0;te("onFocus",{event:t})},onInput:function(e,t,r){return!!n||(!!t.value.isBlurred||void te("onInput",{event:e}))},onKeyDown:function(e,t,r){return!!r.readOnly||(n?(m.b.isComposing(e)&&e.preventDefault(),!0):(m.b.isContentEditable(e)&&!i.yy&&e.preventDefault(),void te("onKeyDown",{event:e})))},onPaste:function(e,t,n){if(n.readOnly)return!0;e.preventDefault(),te("onPaste",{event:e})},onSelect:function(t,i,o){if(r)return!0;if(n)return!0;if(o.readOnly)return!0;const s=a()(t.target);e=s.document.activeElement,te("onSelect",{event:t})}}}class re extends((0,b.Record)({plugins:[]})){static create(e){return new re({plugins:e})}getDecorations(e){const t=this.find("decorateNode",e);return l.aS.createList(t||[])}find(e,...t){const{plugins:n}=this;for(const r of n){const n=r[e];if(!n)continue;const i=n(...t);if(null!=i)return i}}run(e,...t){const{plugins:n}=this;for(const r of n){const n=r[e];if(n&&null!=n(...t))return}}}function ie(e,t=window){const{anchorKey:n,anchorOffset:r,focusKey:i,focusOffset:o,isBackward:a,isCollapsed:s}=e,c=z(n,r,t),u=s?c:z(i,o,t);if(!c||!u)return null;const l=t.document.createRange(),d=a?u:c,p=a?c:u;return l.setStart(d.node,d.offset),l.setEnd(p.node,p.offset),l}function oe(e,t){const n=new Set,r=[];return function(e,t){if(t.isEmpty())return e.nodes.toArray().map((e,t)=>({child:e,index:t}));const n={[e.key]:0};let r=1;e.forEachDescendant(e=>{n[e.key]=r,r+=1});const i=e.nodes.toArray(),o=i.map((e,t)=>({child:e,index:t,order:n[e.key]}));return t.forEach(e=>{const t=n[e.startKey],a=void 0===t?0:function(e,t,n){const r=e.findIndex(e=>n{if(e.isRangeStart)n.add(e.decoration);else if(e.isRangeEnd)n.delete(e.decoration);else{const e=[...n.values()],t=new b.List(e);r.push(t)}}),r}function ae(e,t){return e.order>t.order?1:e.orderd+c&&(S=x+g+w-c),_l+u&&(k=_+m+b+p.height-u),r?t.scrollTo(S,k):(n.scrollTop=k,n.scrollLeft=S)}const le=(0,s.memo)((function(e){const{marks:t,node:n,index:r,offset:i,text:o,editor:a}=e,{stack:c}=a,u=function(e){const{block:t,node:n,text:r,index:i,parent:o,leaves:a}=e;if(o.isVoid)return(0,s.createElement)("span",{"data-slate-zero-width":"z"},"​");if(""===r&&"block"===o.object&&""===o.text&&1===o.nodes.size)return(0,s.createElement)("span",{"data-slate-zero-width":"n"},"​");if(""===r)return(0,s.createElement)("span",{"data-slate-zero-width":"z"},"​");const c=t.getLastText(),u=r.charAt(r.length-1),l=n===c,d=i===a.size-1;if(l&&d&&"\n"===u)return`${r}\n`;return r}(e),l={"data-slate-leaf":!0},d=O.stringify({key:n.key,index:r});return(0,s.createElement)("span",{"data-offset-key":d},t.reduce((e,r)=>{const s={editor:a,mark:r,marks:t,node:n,offset:i,text:o,children:e,attributes:l};return c.find("renderMark",s)||e},u))}),(function(e,t){if(t.index!==e.index||t.marks!==e.marks||t.parent!==e.parent||t.text!==e.text)return!1;return!0}));const de=(0,s.memo)((function(e){const{block:t,decorations:n,editor:r,node:i,parent:o}=e,{value:a}=r,{document:c}=a,{key:u}=i,l=n.filter(e=>{const{startKey:t,endKey:n}=e;return t===u||n===u||t!==n&&(!!c.areDescendantsSorted(t,u)&&c.areDescendantsSorted(u,n))}),d=0===l.size?i.getLeaves():i.getLeaves(l);let p=0;const h=d.map((e,n)=>{const a=(0,s.createElement)(le,{key:`${i.key}-${n}`,block:t,editor:r,index:n,marks:e.marks,node:i,offset:p,parent:o,leaves:d,text:e.text});return p+=e.text.length,a});return(0,s.createElement)("span",{"data-key":u},h)}),(function(e,t){if(t.node!==e.node)return!1;if("block"===t.parent.object){const n=e.parent.nodes.last(),r=t.parent.nodes.last();if(e.node===n&&t.node!==r)return!1}if(!t.decorations.equals(e.decorations))return!1;return!0}));function pe(e){const{children:t,block:n,node:r,decorations:i,editor:o,readOnly:a}=e,c=r.getFirstText(),u="block"===r.object?"div":"span",l=(0,s.createElement)(u,{"data-slate-spacer":!0,style:{height:0,color:"transparent",outline:"none",position:"absolute"}},(0,s.createElement)(de,{block:"block"===r.object?r:n,decorations:i,editor:o,key:c.key,node:c,parent:r,readOnly:a})),d=(0,s.createElement)(u,{contentEditable:!!a&&null},t);return(0,s.createElement)(u,{"data-slate-void":!0,"data-key":r.key,contentEditable:!(!a&&"block"!==r.object)&&null},a?null:l,d)}const he=(0,s.memo)((function e(t){const{editor:n,isSelected:r,isFocused:i,block:o,node:a,parent:c,decorations:u,readOnly:l}=t,{value:d}=n,{selection:p}=d,{stack:h}=n,f=a.getSelectionIndexes(p,r),m=u.concat(h.getDecorations(a)),g=oe(a,m),y=a.nodes.map((t,r)=>{const c=!!f&&f.start<=r&&r{e()};function ge(e){const{value:t,readOnly:n,role:r,spellCheck:o,tabIndex:c,style:u,decorations:l=[],plugins:d,renderNode:p,renderMark:h}=e,{document:f,selection:m,isFocused:g}=t,y=(0,s.useMemo)(()=>{const e=ne(),t=ee(),n=[e,{renderNode:p,renderMark:h},...d,t];return re.create(n)},[d,p,h]),v=(0,s.useRef)(),b=(0,s.useRef)(!1),E=(0,s.useRef)({});E.current.readOnly=n,E.current.stack=y,E.current.value=t,E.current.change=e=>{const n=t.change().call(e);E.current.onChange(n)},E.current.onChange=r=>{n||(y.run("onChange",r,E.current),r.value!==t&&e.onChange(r))};const w=e=>{const t=v.current;!n&&t&&me(()=>{const n=E.current,r=a()(e.target),{activeElement:i}=r.document;i===t&&n.change(t=>{n.stack.run("onSelect",e,t,n)})})},x=e=>{me(()=>{const r=v.current,i=E.current;if(n||!r)return;if(!ve(r,e.target))return;const[o]=e.getTargetRanges();if(o)switch(e.inputType){case"deleteContentBackward":{e.preventDefault();const t=$(o,i.value);i.change(e=>e.deleteAtRange(t));break}case"insertLineBreak":case"insertParagraph":{e.preventDefault();const t=$(o,i.value);i.change(e=>{e.value.isInVoid?e.collapseToStartOfNextText():e.splitBlockAtRange(t)});break}case"insertReplacementText":case"insertText":{const n=null==e.data?e.dataTransfer.getData("text/plain"):e.data;if(null==n)return;e.preventDefault();const r=$(o,t);i.change(e=>{e.insertTextAtRange(r,n,m.marks),m.marks&&t.document!==e.value.document&&e.select({marks:null})});break}}})};(0,s.useEffect)(()=>{const e=v.current,t=a()(e);return E.current.element=e,t.document.addEventListener("selectionchange",w),(i.yy||i.Sh)&&i.wS.beforeinput&&e.addEventListener("beforeinput",x),()=>{t.document.removeEventListener("selectionchange",w),(i.yy||i.Sh)&&i.wS.beforeinput&&e.removeEventListener("beforeinput",x)}},[]),i.UG&&(0,s.useLayoutEffect)(()=>{const e=v.current;e&&ye(e,t,b)});const S={};_.forEach(e=>{S[e]=t=>{((e,t)=>{me(()=>{const n=v.current,r=E.current;if(n&&(!b.current||"onSelect"!==e&&"onBlur"!==e&&"onFocus"!==e)){if("onSelect"===e){const e=$(a()(t.target).getSelection(),r.value);if(e&&e.equals(m))return void ye(n,r.value,b)}if("onDragEnd"===e||"onDragEnter"===e||"onDragExit"===e||"onDragLeave"===e||"onDragOver"===e||"onDragStart"===e||"onDrop"===e){const{target:e}=t;if(e.closest("[data-slate-editor]")!==n)return}("onBeforeInput"!==e&&"onBlur"!==e&&"onCut"!==e&&"onCompositionEnd"!==e&&"onCompositionStart"!==e&&"onFocus"!==e&&"onInput"!==e&&"onKeyDown"!==e&&"onKeyUp"!==e&&"onPaste"!==e&&"onSelect"!==e||ve(n,t.target))&&("onCopy"!==e||ve(n,t.target,!1))&&r.change(n=>{r.stack.run(e,t,n,r)})}})})(e,t)}});const k=f.getSelectionIndexes(m),O=y.getDecorations(f).concat(l||[]),T=oe(f,O),A=f.nodes.toArray().map((e,t)=>{const r=!!k&&k.start<=t&&te.type):[]}const i=new Error("Unable to find a native DOM range for current selection.");i.selection=t.toJS(),i.anchorAncestors=n(t.anchorKey),i.focusAncestors=n(t.focusKey),(0,r.tj)(i)}(t);const{startContainer:d,startOffset:p,endContainer:h,endOffset:f}=l;if(a&&(d===a.startContainer&&p===a.startOffset&&h===a.endContainer&&f===a.endOffset||d===a.endContainer&&p===a.endOffset&&h===a.startContainer&&f===a.startOffset))return;n.current=!0,L(u),u.setBaseAndExtent?s?u.setBaseAndExtent(l.endContainer,l.endOffset,l.startContainer,l.startOffset):u.setBaseAndExtent(l.startContainer,l.startOffset,l.endContainer,l.endOffset):u.addRange(l),ue(u),setTimeout(()=>{i.Bm&&e.focus(),n.current=!1})}}function ve(e,t,n=!0){let r;try{r=3===t.nodeType?t.parentNode:t}catch(o){if(i.Bm&&fe.test(o.message))return!1;throw o}return(!n||r.isContentEditable)&&(r===e||r.closest("[data-slate-editor]")===e)}ge.defaultProps={autoFocus:!1,autoCorrect:!0,role:"textbox",onChange:function(){},plugins:[],readOnly:!1,schema:{},style:{},spellCheck:!0}},40214:(e,t,n)=>{"use strict";n.d(t,{ue:()=>r,DS:()=>i,wu:()=>o,EK:()=>a,NW:()=>s,ck:()=>c,JS:()=>u,J:()=>l,JX:()=>d,he:()=>p,CP:()=>h,Ue:()=>f,jN:()=>m,Sd:()=>g});const r="child_object_invalid",i="child_required",o="child_type_invalid",a="child_unknown",s="first_child_object_invalid",c="first_child_type_invalid",u="last_child_object_invalid",l="last_child_type_invalid",d="node_data_invalid",p="node_is_void_invalid",h="node_mark_invalid",f="node_text_invalid",m="parent_object_invalid",g="parent_type_invalid"},69929:(e,t,n)=>{"use strict";var r=n(259),i=n.n(r),o=n(51211),a=n(35369),s=n(55299),c=n.n(s),u=n(6907),l=n.n(u),d=n(78181);const p=function(){this.__data__=[],this.size=0};const h=function(e,t){return e===t||e!=e&&t!=t};const f=function(e,t){for(var n=e.length;n--;)if(h(e[n][0],t))return n;return-1};var m=Array.prototype.splice;const g=function(e){var t=this.__data__,n=f(t,e);return!(n<0)&&(n==t.length-1?t.pop():m.call(t,n,1),--this.size,!0)};const y=function(e){var t=this.__data__,n=f(t,e);return n<0?void 0:t[n][1]};const v=function(e){return f(this.__data__,e)>-1};const b=function(e,t){var n=this.__data__,r=f(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};function E(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e<=st};const ut=function(e){return null!=e&&ct(e.length)&&!K(e)};const lt=function(e){return Ze(e)&&ut(e)};const dt=function(){return!1};e=n.hmd(e);var pt="object"==typeof exports&&exports&&!exports.nodeType&&exports,ht=pt&&e&&!e.nodeType&&e,ft=ht&&ht.exports===pt?A.Buffer:void 0;const mt=(ft?ft.isBuffer:void 0)||dt;var gt="[object Object]",yt=Function.prototype,vt=Object.prototype,bt=yt.toString,Et=vt.hasOwnProperty,wt=bt.call(Object);const _t=function(e){if(!Ze(e)||U(e)!=gt)return!1;var t=Ye(e);if(null===t)return!0;var n=Et.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&bt.call(n)==wt};var xt={};xt["[object Float32Array]"]=xt["[object Float64Array]"]=xt["[object Int8Array]"]=xt["[object Int16Array]"]=xt["[object Int32Array]"]=xt["[object Uint8Array]"]=xt["[object Uint8ClampedArray]"]=xt["[object Uint16Array]"]=xt["[object Uint32Array]"]=!0,xt["[object Arguments]"]=xt["[object Array]"]=xt["[object ArrayBuffer]"]=xt["[object Boolean]"]=xt["[object DataView]"]=xt["[object Date]"]=xt["[object Error]"]=xt["[object Function]"]=xt["[object Map]"]=xt["[object Number]"]=xt["[object Object]"]=xt["[object RegExp]"]=xt["[object Set]"]=xt["[object String]"]=xt["[object WeakMap]"]=!1;const St=function(e){return Ze(e)&&ct(e.length)&&!!xt[U(e)]};const kt=function(e){return function(t){return e(t)}};e=n.hmd(e);var Ot="object"==typeof exports&&exports&&!exports.nodeType&&exports,Tt=Ot&&e&&!e.nodeType&&e,At=Tt&&Tt.exports===Ot&&O.process;const It=function(){try{var e=Tt&&Tt.require&&Tt.require("util").types;return e||At&&At.binding&&At.binding("util")}catch(t){}}();var Dt=It&&It.isTypedArray;const Ct=Dt?kt(Dt):St;const Pt=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]};var Rt=Object.prototype.hasOwnProperty;const Nt=function(e,t,n){var r=e[t];Rt.call(e,t)&&h(r,n)&&(void 0!==n||t in e)||Ne(e,t,n)};const Lt=function(e,t,n,r){var i=!n;n||(n={});for(var o=-1,a=t.length;++o-1&&e%1==0&&e0){if(++t>=tn)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(en);const an=function(e,t){return on(Xt(e,t,Yt),e+"")};const sn=function(e,t,n){if(!z(n))return!1;var r=typeof t;return!!("number"==r?ut(n)&&Ft(t,n.length):"string"==r&&t in n)&&h(n[t],e)};const cn=function(e){return an((function(t,n){var r=-1,i=n.length,o=i>1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,a&&sn(n[0],n[1],a)&&(o=i<3?void 0:o,i=1),t=Object(t);++r0&&r(c)?n>1?e(c,n-1,r,i,o):Bn(o,c):i||(o[o.length]=c)}return o};const $n=function(e){return(null==e?0:e.length)?zn(e,1):[]};const qn=function(e){return on(Xt(e,void 0,$n),e+"")};const Hn=qn((function(e,t){return null==e?{}:Mn(e,t)}));var Gn="__lodash_hash_undefined__";const Kn=function(e){return this.__data__.set(e,Gn),this};const Vn=function(e){return this.__data__.has(e)};function Wn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Ae;++ts))return!1;var u=o.get(e);if(u&&o.get(t))return u==t;var l=-1,d=!0,p=n&Zn?new Yn:void 0;for(o.set(e,t),o.set(t,e);++li?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r1),t})),Lt(e,ii(e),n),r&&(n=Yi(n,7,eo));for(var i=t.length;i--;)Zi(n,t[i]);return n}));var no=n(54975),ro=n.n(no);n.d(t,{AB:()=>_o,Je:()=>yo,fA:()=>So,iE:()=>wo,jZ:()=>bo,nH:()=>vo,LD:()=>ko,aS:()=>Fo,RI:()=>qo,Hr:()=>Eo,Nb:()=>ia,Pc:()=>uo});const io={BLOCK:"@@__SLATE_BLOCK__@@",CHANGE:"@@__SLATE_CHANGE__@@",CHARACTER:"@@__SLATE_CHARACTER__@@",DOCUMENT:"@@__SLATE_DOCUMENT__@@",HISTORY:"@@__SLATE_HISTORY__@@",INLINE:"@@__SLATE_INLINE__@@",LEAF:"@@__SLATE_LEAF__@@",MARK:"@@__SLATE_MARK__@@",OPERATION:"@@__SLATE_OPERATION__@@",RANGE:"@@__SLATE_RANGE__@@",SCHEMA:"@@__SLATE_SCHEMA__@@",TEXT:"@@__SLATE_TEXT__@@",VALUE:"@@__SLATE_VALUE__@@"};function oo(e,t){return!(!t||!t[io[e]])}let ao,so;function co(){return so()}function uo(e){so=e}ao=0,so=()=>`${ao++}`;class lo{constructor(e,t){this.ownerKey=e,this.m=new Map;for(const n of t)for(const e of n)this.m.set(e[0],e[1])}get(e){const t=[];let n=e;for(;n!==this.ownerKey;){const e=this.m.get(n);if(!e)return;n=e.parentKey,t.unshift(e.index)}return t}keys(){return this.m.keys()}}function po(e,t){return-1===function(e,t){const n=Math.min(e.length,t.length);for(let r=0;rt[r])return 1;if(e[r]t.length?1:-1}(e,t)}function ho(e,t){return e.push.apply(e,t),e}function fo(e){const t=Object.assign({key:"",data:(0,a.Map)(),nodes:(0,a.List)()},e);return class extends((0,a.Record)(t)){isText(){return!1}isBlock(){return"block"===this.object}isInline(){return"block"===this.object}isDocument(){return"document"===this.object}getLookupIndex(){return new lo(this.key,this.getIndexPairs())}getIndexPairs(){if(!this.nodes)return[];const e=[];e.length=this.nodes.size;const t=[e];return this.nodes.forEach((n,r)=>{if(e[r]=[n.key,{index:r,parentKey:this.key}],n.isText())return;const i=n.getIndexPairs();ho(t,i)}),t}getByPath(e){return e.reduce((e,t)=>e&&e.nodes?e.nodes.get(t):null,this)}getPath(e){if(e===this.key)return[];return this.getLookupIndex().get(e)||null}getByKey(e){const t=this.getPath(e);return t?this.getByPath(t):null}areDescendantsSorted(e,t){const n=this.getPath(e),r=this.getPath(t);return n&&r?po(n,r):null}assertChild(e){const t=this.getChild(e);if(!t)throw new Error(`Could not find a child node with key "${e}".`);return t}assertDescendant(e){const t=this.getDescendant(e);if(!t)throw new Error(`Could not find a descendant node with key "${e}".`);return t}assertNode(e){const t=this.getNode(e);if(!t)throw new Error(`Could not find a node with key "${e}".`);return t}assertPath(e){const t=this.getByPath(e);if(!t)throw new Error(`Could not find a descendant at path "${e}".`);return t}filterDescendants(e){const t=[];return this.forEachDescendant((n,r,i)=>{e(n,r,i)&&t.push(n)}),(0,a.List)(t)}findDescendant(e){let t=null;return this.forEachDescendant((n,r,i)=>{if(e(n,r,i))return t=n,!1}),t}forEachDescendant(e){let t;return this.nodes.forEach((n,r,i)=>!1===e(n,r,i)?(t=!1,!1):"text"!==n.object?t=n.forEachDescendant(e):void 0),t}getAncestors(e){if(e===this.key)return(0,a.List)();const t=this.getPath(e);if(!t)return null;const n=t.map((e,n)=>t.slice(0,n)).map(e=>this.getByPath(e));return new a.List(n)}getBlocks(){const e=this.getBlocksAsArray();return(0,a.List)(e)}getBlocksAsArray(){return this.nodes.reduce((e,t)=>"block"!==t.object?e:t.isLeafBlock()?(e.push(t),e):ho(e,t.getBlocksAsArray()),[])}getBlocksAtRange(e){const t=this.getBlocksAtRangeAsArray(e);return(0,a.List)(new a.OrderedSet(t))}getBlocksAtRangeAsArray(e){if((e=e.normalize(this)).isUnset)return[];const{startKey:t,endKey:n}=e,r=this.getClosestBlock(t);if(t===n)return[r];const i=this.getClosestBlock(n),o=this.getBlocksAsArray(),a=o.indexOf(r),s=o.indexOf(i);return o.slice(a,s+1)}getBlocksByType(e){const t=this.getBlocksByTypeAsArray(e);return(0,a.List)(t)}getBlocksByTypeAsArray(e){return this.nodes.reduce((t,n)=>"block"!==n.object?t:n.isLeafBlock()&&n.type===e?(t.push(n),t):ho(t,n.getBlocksByTypeAsArray(e)),[])}getChild(e){const t=this.getChildIndex(e);return t>=0?this.nodes.get(t):null}getChildIndex(e){const t=this.getPath(e);return t&&1===t.length?t[0]:-1}getClosest(e,t){const n=this.getAncestors(e);if(!n)throw new Error(`Could not find a descendant node with key "${e}".`);return n.rest().findLast(t)}getClosestBlock(e){return this.getClosest(e,e=>"block"===e.object)}getClosestInline(e){return this.getClosest(e,e=>"inline"===e.object)}getClosestVoid(e){return this.getClosest(e,e=>e.isVoid)}getCommonAncestor(e,t){if(e===this.key)return this;if(t===this.key)return this;this.assertDescendant(e),this.assertDescendant(t);let n=new a.List,r=this.getParent(e),i=this.getParent(t);for(;r;)n=n.push(r),r=this.getParent(r.key);for(;i;){if(n.includes(i))return i;i=this.getParent(i.key)}return null}getDepth(e,t=1){return this.assertDescendant(e),this.hasChild(e)?t:this.getFurthestAncestor(e).getDepth(e,t+1)}getDescendant(e){const t=this.getPath(e);return t?this.getDescendantAtPath(t):null}getDescendantAtPath(e){return e.length<1?null:this.getByPath(e)}getFirstText(){let e=null;const t=this.nodes.find(t=>"text"===t.object||(e=t.getFirstText()));return e||t}getFurthest(e,t){const n=this.getAncestors(e);if(!n)throw new Error(`Could not find a descendant node with key "${e}".`);return n.rest().find(t)}getFurthestBlock(e){return this.getFurthest(e,e=>"block"===e.object)}getFurthestInline(e){return this.getFurthest(e,e=>"inline"===e.object)}getFurthestAncestor(e){const t=this.getPath(e);return t?this.getByPath(t.slice(0,1)):null}getFurthestOnlyChildAncestor(e){const t=this.getAncestors(e);if(!t)throw new Error(`Could not find a descendant node with key "${e}".`);const n=t.shift().reverse().takeUntil(e=>e.nodes.size>1).last();return n||null}getInlines(){const e=this.getInlinesAsArray();return new a.List(e)}getInlinesAsArray(){const e=[];return this.nodes.forEach(t=>{"text"!==t.object&&(t.isLeafInline()?e.push(t):ho(e,t.getInlinesAsArray()))}),e}getInlinesAtRange(e){const t=this.getInlinesAtRangeAsArray(e);return new a.List((0,a.OrderedSet)(t))}getInlinesAtRangeAsArray(e){return(e=e.normalize(this)).isUnset?[]:this.getTextsAtRangeAsArray(e).map(e=>this.getClosestInline(e.key)).filter(e=>e)}getInlinesByType(e){const t=this.getInlinesByTypeAsArray(e);return new a.List(t)}getInlinesByTypeAsArray(e){return this.nodes.reduce((t,n)=>"text"===n.object?t:n.isLeafInline()&&n.type===e?(t.push(n),t):ho(t,n.getInlinesByTypeAsArray(e)),[])}getKeysAsArray(){return[...this.getLookupIndex().keys()]}getKeys(){const e=this.getKeysAsArray();return(0,a.Set)(e)}getLastText(){let e=null;const t=this.nodes.findLast(t=>"text"===t.object||(e=t.getLastText()));return e||t}getMarks(){const e=this.getMarksAsArray();return(0,a.Set)(e)}getOrderedMarks(){const e=this.getMarksAsArray();return(0,a.OrderedSet)(e)}getMarksAsArray(){const e=[];return this.nodes.forEach(t=>{ho(e,t.getMarksAsArray())}),e}getMarksAtRange(e){return new a.Set(this.getOrderedMarksAtRange(e))}getInsertMarksAtRange(e){if((e=e.normalize(this)).isUnset)return(0,a.Set)();if(e.isCollapsed)return this.getMarksAtPosition(e.startKey,e.startOffset);const{startKey:t,startOffset:n}=e;return this.getDescendant(t).getMarksAtIndex(n+1)}getOrderedMarksAtRange(e){if((e=e.normalize(this)).isUnset)return(0,a.OrderedSet)();if(e.isCollapsed)return this.getMarksAtPosition(e.startKey,e.startOffset);const{startKey:t,startOffset:n,endKey:r,endOffset:i}=e;return this.getOrderedMarksBetweenPositions(t,n,r,i)}getOrderedMarksBetweenPositions(e,t,n,r){if(e===n){return this.getDescendant(e).getMarksBetweenOffsets(t,r)}const i=this.getTextsBetweenPositionsAsArray(e,n);return(0,a.OrderedSet)().withMutations(o=>{i.forEach(i=>{i.key===e?o.union(i.getMarksBetweenOffsets(t,i.text.length)):i.key===n?o.union(i.getMarksBetweenOffsets(0,r)):o.union(i.getMarks())})})}getActiveMarksAtRange(e){if((e=e.normalize(this)).isUnset)return(0,a.Set)();if(e.isCollapsed)return this.getMarksAtPosition(e.startKey,e.startOffset).toSet();let{startKey:t,endKey:n,startOffset:r,endOffset:i}=e,o=this.getDescendant(t);if(t!==n){for(;t!==n&&0===i;){const e=this.getPreviousText(n);n=e.key,i=e.text.length}for(;t!==n&&r===o.text.length;)t=(o=this.getNextText(t)).key,r=0}if(t===n)return o.getActiveMarksBetweenOffsets(r,i);const s=o.getActiveMarksBetweenOffsets(r,o.text.length);if(0===s.size)return(0,a.Set)();const c=this.getDescendant(n).getActiveMarksBetweenOffsets(0,i);let u=s.intersect(c);if(0===u.size)return u;let l=this.getNextText(t);for(;l.key!==n;){if(0!==l.text.length&&0===(u=u.intersect(l.getActiveMarks())).size)return(0,a.Set)();l=this.getNextText(l.key)}return u}getMarksAtPosition(e,t){const n=this.getDescendant(e).getMarksAtIndex(t);if(0!==t)return n;const r=this.getClosestBlock(e);if(""===r.text)return n;const i=this.getPreviousText(e);return i?r.hasDescendant(i.key)?i.getMarksAtIndex(i.text.length):n:(0,a.Set)()}getMarksByType(e){const t=this.getMarksByTypeAsArray(e);return(0,a.Set)(t)}getOrderedMarksByType(e){const t=this.getMarksByTypeAsArray(e);return(0,a.OrderedSet)(t)}getMarksByTypeAsArray(e){return this.nodes.reduce((t,n)=>"text"===n.object?ho(t,n.getMarksAsArray().filter(t=>t.type===e)):ho(t,n.getMarksByTypeAsArray(e)),[])}getNextBlock(e){const t=this.assertDescendant(e);let n;if("block"===t.object)n=t.getLastText();else{n=this.getClosestBlock(e).getLastText()}const r=this.getNextText(n.key);return r?this.getClosestBlock(r.key):null}getNextSibling(e){const t=this.getParent(e).nodes.skipUntil(t=>t.key===e);if(0===t.size)throw new Error(`Could not find a child node with key "${e}".`);return t.get(1)}getNextText(e){return this.getTexts().skipUntil(t=>t.key===e).get(1)}getNode(e){return this.key===e?this:this.getDescendant(e)}getNodeAtPath(e){return e.length?this.getDescendantAtPath(e):this}getOffset(e){this.assertDescendant(e);const t=this.getFurthestAncestor(e),n=this.nodes.takeUntil(e=>e===t).reduce((e,t)=>e+t.text.length,0);return this.hasChild(e)?n:n+t.getOffset(e)}getOffsetAtRange(e){if((e=e.normalize(this)).isUnset)throw new Error("The range cannot be unset to calculcate its offset.");if(e.isExpanded)throw new Error("The range must be collapsed to calculcate its offset.");const{startKey:t,startOffset:n}=e;return this.getOffset(t)+n}getParent(e){if(this.key===e)return null;const t=this.getPath(e);return t?this.getByPath(t.slice(0,-1)):null}refindPath(e,t){const n=this.getByPath(e);return n&&n.key===t?e:this.getPath(t)}refindNode(e,t){const n=this.getByPath(e);return n&&n.key===t?n:this.getByKey(t)}getPreviousBlock(e){const t=this.assertDescendant(e);let n;if("block"===t.object)n=t.getFirstText();else{n=this.getClosestBlock(e).getFirstText()}const r=this.getPreviousText(n.key);return r?this.getClosestBlock(r.key):null}getPreviousSibling(e){const t=this.getParent(e),n=t.nodes.takeUntil(t=>t.key===e);if(n.size===t.nodes.size)throw new Error(`Could not find a child node with key "${e}".`);return n.last()}getPreviousText(e){return this.getTexts().takeUntil(t=>t.key===e).last()}getSelectionIndexes(e,t=!0){const{startKey:n,endKey:r}=e;if(!t)return null;if(e.isUnset)return null;if(n===r){const e=this.getFurthestAncestor(n),t=e?this.getChildIndex(e.key):null;return{start:t,end:t+1}}let i=null,o=null;return this.nodes.forEach((e,t)=>("text"===e.object?(null==i&&e.key===n&&(i=t),null==o&&e.key===r&&(o=t+1)):(null==i&&e.hasDescendant(n)&&(i=t),null==o&&e.hasDescendant(r)&&(o=t+1)),null==i||null==o)),t&&null==i&&(i=0),t&&null==o&&(o=this.nodes.size),null==i?null:{start:i,end:o}}getText(){return this.nodes.reduce((e,t)=>e+t.text,"")}getTextAtOffset(e){if(0===e)return this.getFirstText();if(e===this.text.length)return this.getLastText();if(e<0||e>this.text.length)return null;let t=0;return this.getTexts().find((n,r,i)=>(t+=n.text.length)>e)}getTextDirection(){const e=l()(this.text);return"neutral"===e?void 0:e}getTexts(){const e=this.getTextsAsArray();return new a.List(e)}getTextsAsArray(){const e=[];return this.nodes.forEach(t=>{"text"===t.object?e.push(t):ho(e,t.getTextsAsArray())}),e}getTextsAtRange(e){if((e=e.normalize(this)).isUnset)return(0,a.List)();const{startKey:t,endKey:n}=e;return new a.List(this.getTextsBetweenPositionsAsArray(t,n))}getTextsBetweenPositionsAsArray(e,t){const n=this.getDescendant(e);if(!n.isText())throw new Error(`Expected "${e}" to be a text`);if(e===t)return[n];const r=this.getDescendant(t);if(!r.isText())throw new Error(`Expected "${t}" to be a text`);const i=this.getTextsAsArray(),o=i.indexOf(n),a=i.indexOf(r,o);return i.slice(o,a+1)}getTextsAtRangeAsArray(e){if((e=e.normalize(this)).isUnset)return[];const{startKey:t,endKey:n}=e;return this.getTextsBetweenPositionsAsArray(t,n)}hasChild(e){return!!this.getChild(e)}hasBlocks(e){const t=this.assertNode(e);return!(!t.nodes||!t.nodes.find(e=>"block"===e.object))}hasInlines(e){const t=this.assertNode(e);return!(!t.nodes||!t.nodes.find(e=>e.isInline||e.isText))}hasDescendant(e){return!!this.getDescendant(e)}hasNode(e){return!!this.getNode(e)}hasVoidParent(e){return!!this.getClosestVoid(e)}insertNode(e,t){this.hasNode(t.key)&&(t=t.regenerateKey()),"text"!==t.object&&(t=t.mapDescendants(e=>this.hasNode(e.key)?e.regenerateKey():e));const n=this.nodes.insert(e,t);return this.merge({nodes:n})}isInRange(e){e=e.normalize(this);const t=this,{startKey:n,endKey:r,isCollapsed:i}=e;if(t.key===n||t.key===r||t.hasDescendant(n)||t.hasDescendant(r))return!0;if(i)return!1;const o=t.getTextsAtRange(e);let a=!1;return o.forEach(e=>(t.hasDescendant(e.key)&&(a=!0),a)),a}isLeafBlock(){return"block"===this.object&&this.nodes.every(e=>"block"!==e.object)}isLeafInline(){return"inline"===this.object&&this.nodes.every(e=>"inline"!==e.object)}mergeNode(e,t){let n=this.nodes.get(e);const r=this.nodes.get(t);if(n.object!==r.object)throw new Error(`Tried to merge two nodes of different objects: "${n.object}" and "${r.object}".`);if("text"===n.object)n=n.mergeText(r);else{const e=n.nodes.concat(r.nodes);n=n.set("nodes",e)}return this.removeNode(t).removeNode(e).insertNode(e,n)}mapChildren(e){let{nodes:t}=this;return t.forEach((n,r)=>{const i=e(n,r,this.nodes);i!==n&&(t=t.set(i.key,i))}),this.merge({nodes:t})}mapDescendants(e){let{nodes:t}=this;return t.forEach((n,r)=>{let i=n;"text"!==i.object&&(i=i.mapDescendants(e)),(i=e(i,r,this.nodes))!==n&&(t=t.set(r,i))}),this.merge({nodes:t})}regenerateKey(){const e=co();return this.merge({key:e})}removeDescendant(e){let t=this,n=t.getParent(e);if(!n)throw new Error(`Could not find a descendant node with key "${e}".`);const r=n.getChildIndex(e),i=n.nodes.delete(r);return n=n.merge({nodes:i}),t=t.updateNode(n)}removeNode(e){const t=this.nodes.delete(e);return this.merge({nodes:t})}splitNode(e,t){const n=this.nodes.get(e);let r,i;if("text"===n.object)[r,i]=n.splitText(t);else{const e=n.nodes.take(t),o=n.nodes.skip(t);r=n.set("nodes",e),i=n.set("nodes",o).regenerateKey()}return this.removeNode(e).insertNode(e,i).insertNode(e,r)}updateNode(e){if(e.key===this.key)return e;let t=this.assertDescendant(e.key);return this.getAncestors(e.key).reverse().forEach(n=>{let{nodes:r}=n;const i=n.getChildIndex(t.key);t=n,r=r.set(i,e),n=n.set("nodes",r),e=n}),e}}}function mo(e){if("text"!==e.object)throw new Error(`Expected node "${e.key}" to be a text`);return e}function go(e,t=[]){i()(e.prototype,["areDescendantsSorted","getAncestors","getBlocksAsArray","getBlocksAtRangeAsArray","getBlocksByTypeAsArray","getChild","getClosestBlock","getClosestInline","getClosestVoid","getCommonAncestor","getDepth","getDescendant","getDescendantAtPath","getFirstText","getFurthestBlock","getFurthestInline","getFurthestAncestor","getFurthestOnlyChildAncestor","getInlinesAsArray","getInlinesAtRangeAsArray","getInlinesByTypeAsArray","getMarksAsArray","getMarksAtPosition","getOrderedMarksBetweenPositions","getInsertMarksAtRange","getKeysAsArray","getLastText","getMarksByTypeAsArray","getNextBlock","getNextSibling","getNextText","getNode","getNodeAtPath","getOffset","getOffsetAtRange","getParent","getPath","getPreviousBlock","getPreviousSibling","getPreviousText","getText","getTextAtOffset","getTextDirection","getTextsAsArray","getTextsBetweenPositionsAsArray","isLeafBlock","isLeafInline","getLookupIndex","getIndexPairs",...t])}const yo={create(e={}){if(a.Map.isMap(e))return e;if(c()(e))return yo.fromJS(e);throw new Error(`\`Data.create\` only accepts objects or maps, but you passed it: ${e}`)},fromJS:e=>new a.Map(e)};class vo extends((0,a.Record)({data:new a.Map,type:""})){get object(){return"mark"}static isMark(e){return oo("MARK",e)}static create(e={}){if(vo.isMark(e))return e;if("string"==typeof e&&(e={type:e}),c()(e))return vo.fromJS(e);throw new Error(`\`Mark.create\` only accepts objects, strings or marks, but you passed it: ${e}`)}static createSet(e){if(a.Set.isSet(e)||Array.isArray(e)){return new a.Set(e.map(vo.create))}if(null==e)return(0,a.Set)();throw new Error(`\`Mark.createSet\` only accepts sets, arrays or null, but you passed it: ${e}`)}static createProperties(e={}){if(vo.isMark(e))return{data:e.data,type:e.type};if("string"==typeof e)return{type:e};if(c()(e)){const t={};return"type"in e&&(t.type=e.type),"data"in e&&(t.data=yo.create(e.data)),t}throw new Error(`\`Mark.createProperties\` only accepts objects, strings or marks, but you passed it: ${e}`)}static fromJS(e){const{data:t={},type:n}=e;if("string"!=typeof n)throw new Error("`Mark.fromJS` requires a `type` string.");return new vo({type:n,data:yo.fromJS(t)})}static isMarkSet(e){return a.Set.isSet(e)&&e.every(e=>vo.isMark(e))}getComponent(e){return e.__getComponent(this)}toJS(){return{object:this.object,type:this.type,data:this.data.toJS()}}}vo.prototype[io.MARK]=!0,i()(vo.prototype,["getComponent"]);class bo extends((0,a.Record)({marks:(0,a.Set)(),text:""})){get object(){return"leaf"}static isLeaf(e){return oo("LEAF",e)}static create(e={}){if(bo.isLeaf(e))return e;if("string"==typeof e&&(e={text:e}),c()(e))return bo.fromJS(e);throw new Error(`\`Leaf.create\` only accepts objects, strings or leaves, but you passed it: ${e}`)}static createLeaves(e){if(e.size<=1)return e;let t=!1;const n=(0,a.List)().withMutations(n=>{e.findLast((e,r)=>{const i=n.first();if(i){if(i.marks.equals(e.marks))return t=!0,void n.set(0,i.set("text",`${e.text}${i.text}`));if(""===i.text)return t=!0,void n.set(0,e);if(""===e.text)return void(t=!0)}n.unshift(e)})});return t?n:e}static splitLeaves(e,t){if(t<0)return[(0,a.List)(),e];if(0===e.size)return[(0,a.List)(),(0,a.List)()];let n,r,i=0,o=-1;return e.find(e=>{o++;const a=i,{text:s}=e;if((i+=s.length)t)return!1;const c=t-a;return n=e.set("text",s.slice(0,c)),r=e.set("text",s.slice(c)),!0}),n?""===n.text?0===o?[a.List.of(n),e]:[e.take(o),e.skip(o)]:""===r.text?o===e.size-1?[e,a.List.of(r)]:[e.take(o+1),e.skip(o+1)]:[e.take(o).push(n),e.skip(o+1).unshift(r)]:[e,(0,a.List)()]}static createList(e=[]){if(a.List.isList(e)||Array.isArray(e)){return new a.List(e.map(bo.create))}throw new Error(`\`Leaf.createList\` only accepts arrays or lists, but you passed it: ${e}`)}static fromJS(e){const{text:t="",marks:n=[]}=e;return new bo({text:t,marks:(0,a.Set)(n.map(vo.fromJS))})}static isLeafList(e){return a.List.isList(e)&&e.every(e=>bo.isLeaf(e))}updateMark(e,t){const{marks:n}=this;if(t.equals(e))return this;if(!n.has(e))return this;const r=n.withMutations(n=>{n.remove(e).add(t)});return this.set("marks",r)}addMarks(e){const{marks:t}=this;return this.set("marks",t.union(e))}removeMark(e){const{marks:t}=this;return this.set("marks",t.remove(e))}toJS(){return{object:this.object,text:this.text,marks:this.marks.toArray().map(e=>e.toJS())}}}bo.prototype[io.LEAF]=!0;class Eo extends((0,a.Record)({leaves:(0,a.List)(),key:""})){get object(){return"text"}get isEmpty(){return""===this.text}get text(){return this.getString()}static isText(e){return oo("TEXT",e)}static isTextList(e){return a.List.isList(e)&&e.every(e=>Eo.isText(e))}static create(e=""){if(Eo.isText(e))return e;if("string"==typeof e&&(e={leaves:[{text:e}]}),c()(e)){if(e.text){const{text:t,marks:n,key:r}=e;e={key:r,leaves:[{text:t,marks:n}]}}return Eo.fromJS(e)}throw new Error(`\`Text.create\` only accepts objects, arrays, strings or texts, but you passed it: ${e}`)}static createList(e=[]){if(a.List.isList(e)||Array.isArray(e)){return(0,a.List)(e.map(e=>Eo.create(e)))}throw new Error(`\`Text.createList\` only accepts arrays or lists, but you passed it: ${e}`)}static fromJS(e){if(Eo.isText(e))return e;const{key:t=co()}=e;let{leaves:n=(0,a.List)()}=e;if(Array.isArray(n))n=(0,a.List)(n.map(e=>bo.create(e)));else{if(!a.List.isList(n))throw new Error("leaves must be either Array or Immutable.List");n=n.map(e=>bo.create(e))}return new Eo({leaves:bo.createLeaves(n),key:t})}isText(){return!0}getString(){return this.leaves.reduce((e,t)=>e+t.text,"")}searchLeafAtOffset(e){let t=0,n=0,r=-1;return{leaf:this.leaves.find(i=>(r++,(t=(n=t)+i.text.length)>=e)),endOffset:t,index:r,startOffset:n}}addMark(e,t,n){const r=a.Set.of(n);return this.addMarks(e,t,r)}addMarks(e,t,n){if(""===this.text&&0===t&&0===e){const{leaves:e}=this,t=e.first();if(!t)return this.set("leaves",a.List.of(bo.fromJS({text:"",marks:n})));const r=t.addMarks(n);return r===t?this:this.set("leaves",a.List.of(r))}if(""===this.text)return this;if(0===t)return this;if(e>=this.text.length)return this;const[r,i]=bo.splitLeaves(this.leaves,e),[o,s]=bo.splitLeaves(i,t);return this.setLeaves(r.concat(o.map(e=>e.addMarks(n)),s))}getLeaves(e=[]){let{leaves:t}=this;if(0===t.size)return a.List.of(bo.create({}));if(!e||0===e.length)return t;if(0===this.text.length)return t;const{key:n}=this;return e.forEach(e=>{const{startKey:r,endKey:i,startOffset:o,endOffset:a,marks:s}=e,c=r===n,u=i===n;if(c&&u){const e=c?o:0,n=u?a-e:this.text.length-e;if(n<1)return;if(e>=this.text.length)return;if(0!==e||ne.addMarks(s)),a))}}t=t.map(e=>e.addMarks(s))}),t===this.leaves?t:bo.createLeaves(t)}getActiveMarksBetweenOffsets(e,t){if(e<=0&&t>=this.text.length)return this.getActiveMarks();if(e>=t)return(0,a.Set)();if(""===this.text)return this.getActiveMarks();let n=null,r=0;return this.leaves.forEach(i=>{const o=r;if(!((r=o+i.text.length)<=e)){if(o>=t)return!1;if(n)return(n=n.intersect(i.marks))&&n.size,!1;n=i.marks}}),n||(0,a.Set)()}getActiveMarks(){if(0===this.leaves.size)return(0,a.Set)();const e=this.leaves.first().marks;return 0===e.size?e:e.withMutations(e=>{this.leaves.forEach(t=>{if(e.intersect(t.marks),0===e.size)return!1})})}getMarksBetweenOffsets(e,t){if(e<=0&&t>=this.text.length)return this.getMarks();if(e>=t)return(0,a.Set)();if(""===this.text)return this.getActiveMarks();let n=null,r=0;return this.leaves.forEach(i=>{const o=r;if(!((r=o+i.text.length)<=e))return!(o>=t)&&void(n=n?n.union(i.marks):i.marks)}),n||(0,a.Set)()}getMarks(){const e=this.getMarksAsArray();return new a.OrderedSet(e)}getMarksAsArray(){if(0===this.leaves.size)return[];const e=this.leaves.first().marks;if(1===this.leaves.size)return e.toArray();const t=[];return this.leaves.forEach(e=>{t.push(e.marks.toArray())}),Array.prototype.concat.apply(e.toArray(),t)}getMarksAtIndex(e){const{leaf:t}=this.searchLeafAtOffset(e);return t?t.marks:(0,a.Set)()}getNode(e){return this.key===e?this:null}hasNode(e){return!!this.getNode(e)}insertText(e,t,n){if(""===this.text)return this.set("leaves",a.List.of(bo.create({text:t,marks:n})));if(0===t.length)return this;n||(n=(0,a.Set)());const{startOffset:r,leaf:i,index:o}=this.searchLeafAtOffset(e),s=e-r,c=i.text.slice(0,s),u=i.text.slice(s),{leaves:l}=this;if(i.marks.equals(n))return this.set("leaves",l.set(o,i.set("text",c+t+u)));const d=l.splice(o,1,i.set("text",c),bo.create({text:t,marks:n}),i.set("text",u));return this.setLeaves(d)}regenerateKey(){const e=co();return this.merge({key:e})}removeMark(e,t,n){if(""===this.text&&0===e&&0===t){const e=this.leaves.first();if(!e)return this;const t=e.removeMark(n);return t===e?this:this.set("leaves",a.List.of(t))}if(t<=0)return this;if(e>=this.text.length)return this;const[r,i]=bo.splitLeaves(this.leaves,e),[o,s]=bo.splitLeaves(i,t),c=r.concat(o.map(e=>e.removeMark(n)),s);return this.setLeaves(c)}removeText(e,t){if(t<=0)return this;if(e>=this.text.length)return this;if(1===t){const{leaf:n,index:r,startOffset:i}=this.searchLeafAtOffset(e+1),o=e-i;if(n){if(1===n.text.length)return this.setLeaves(this.leaves.remove(r));const e=n.text.slice(0,o)+n.text.slice(o+t);if(e.length>0)return this.set("leaves",this.leaves.set(r,n.set("text",e)))}}const[n,r]=bo.splitLeaves(this.leaves,e),i=bo.splitLeaves(r,t)[1],o=bo.createLeaves(n.concat(i));if(1===o.size){const e=o.first();if(""===e.text)return this.set("leaves",a.List.of(e.set("marks",this.getActiveMarks())))}return this.merge({leaves:o})}toJS(e={}){const t={object:this.object,leaves:this.getLeaves().toArray().map(e=>e.toJS())};return e.preserveKeys&&(t.key=this.key),t}updateMark(e,t,n,r){const i=n.merge(r);if(""===this.text&&0===t&&0===e){const e=this.leaves.first();if(!e)return this;const t=e.updateMark(n,i);return t===e?this:this.set("leaves",a.List.of(t))}if(t<=0)return this;if(e>=this.text.length)return this;const[o,s]=bo.splitLeaves(this.leaves,e),[c,u]=bo.splitLeaves(s,t),l=o.concat(c.map(e=>e.updateMark(n,i)),u);return this.setLeaves(l)}splitText(e){const t=bo.splitLeaves(this.leaves,e);return[this.set("leaves",t[0]),this.set("leaves",t[1]).regenerateKey()]}mergeText(e){const t=this.leaves.concat(e.leaves);return this.setLeaves(t)}setLeaves(e){const t=bo.createLeaves(e);if(1===t.size){const e=t.first();if((!e.marks||0===e.marks.size)&&""===e.text)return this.set("leaves",(0,a.List)())}return this.set("leaves",bo.createLeaves(e))}}Eo.prototype[io.TEXT]=!0,i()(Eo.prototype,["getActiveMarks","getMarks","getMarksAsArray","getString"]);class wo extends(fo({type:"",isVoid:!1})){get object(){return"inline"}get isEmpty(){return!this.isVoid&&!this.nodes.some(e=>!e.isEmpty)}get text(){return this.getText()}static isInline(e){return oo("INLINE",e)}static isInlineList(e){return a.List.isList(e)&&e.every(e=>wo.isInline(e))}static create(e={}){if(wo.isInline(e))return e;if("string"==typeof e&&(e={type:e}),c()(e))return wo.fromJS(e);throw new Error(`\`Inline.create\` only accepts objects, strings or inlines, but you passed it: ${e}`)}static createList(e=[]){return(0,a.List)(e.map(wo.create))}static createChildren(e){return(0,a.List)(e.map(e=>wo.isInline(e)?e:Eo.isText(e)?e:"inline"===e.object?wo.create(e):Eo.create(e)))}static fromJS(e){if(wo.isInline(e))return e;const{data:t={},isVoid:n=!1,key:r=co(),nodes:i=[],type:o}=e;if("string"!=typeof o)throw new Error("`Inline.fromJS` requires a `type` string.");return new wo({key:r,type:o,isVoid:!!n,data:new a.Map(t),nodes:wo.createChildren(i)})}toJS(e={}){const t={object:this.object,type:this.type,isVoid:this.isVoid,data:this.data.toJS(),nodes:this.nodes.toArray().map(t=>t.toJS(e))};return e.preserveKeys&&(t.key=this.key),t}}wo.prototype[io.INLINE]=!0,go(wo);class _o extends(fo({isVoid:!1,type:""})){get object(){return"block"}get isEmpty(){return!this.isVoid&&!this.nodes.some(e=>!e.isEmpty)}get text(){return this.getText()}static isBlock(e){return oo("BLOCK",e)}static create(e={}){if(_o.isBlock(e))return e;if("string"==typeof e&&(e={type:e}),c()(e))return _o.fromJS(e);throw new Error(`\`Block.create\` only accepts objects, strings or blocks, but you passed it: ${e}`)}static createList(e=[]){return(0,a.List)(e.map(_o.create))}static createChildren(e){return(0,a.List)(e.map(e=>"block"===e.object?_o.create(e):"inline"===e.object?wo.create(e):Eo.create(e)))}static fromJS(e){if(_o.isBlock(e))return e;const{data:t={},isVoid:n=!1,key:r=co(),nodes:i=[],type:o}=e;if("string"!=typeof o)throw new Error("`Block.fromJS` requires a `type` string.");return new _o({key:r,type:o,isVoid:!!n,data:(0,a.Map)(t),nodes:_o.createChildren(i)})}static isBlockList(e){return a.List.isList(e)&&e.every(e=>_o.isBlock(e))}toJS(e={}){const t={object:this.object,type:this.type,isVoid:this.isVoid,data:this.data.toJS(),nodes:this.nodes.toArray().map(t=>t.toJS(e))};return e.preserveKeys&&(t.key=this.key),t}}_o.prototype[io.BLOCK]=!0,go(_o);const xo={};["deleteBackward","deleteCharBackward","deleteLineBackward","deleteWordBackward","deleteForward","deleteCharForward","deleteWordForward","deleteLineForward","setBlocks","setInlines","splitInline","unwrapBlock","unwrapInline","wrapBlock","wrapInline"].forEach(e=>{xo[e]=(t,...n)=>{const{value:r}=t,{selection:i}=r;t[`${e}AtRange`](i,...n),e.match(/Backward$/)?t.collapseToStart():e.match(/Forward$/)&&t.collapseToEnd()}}),xo.setBlock=(...e)=>{(0,o.zi)("slate@0.33.0","The `setBlock` method of Slate changes has been renamed to `setBlocks`."),xo.setBlocks(...e)},xo.setInline=(...e)=>{(0,o.zi)("slate@0.33.0","The `setInline` method of Slate changes has been renamed to `setInlines`."),xo.setInlines(...e)},xo.addMark=(e,t)=>{t=vo.create(t);const{value:n}=e,{document:r,selection:i}=n;if(i.isExpanded)e.addMarkAtRange(i,t);else if(i.marks){const n=i.marks.add(t),r=i.set("marks",n);e.select(r)}else{const n=r.getActiveMarksAtRange(i).add(t),o=i.set("marks",n);e.select(o)}},xo.addMarks=(e,t)=>{t.forEach(t=>e.addMark(t))},xo.delete=e=>{const{value:t}=e,{selection:n}=t;e.deleteAtRange(n),e.collapseToStart()},xo.insertBlock=(e,t)=>{t=_o.create(t);const{value:n}=e,{selection:r}=n;e.insertBlockAtRange(r,t);const i=e.value.document.getNode(t.key);i&&e.collapseToEndOf(i)},xo.insertFragment=(e,t)=>{if(!t.nodes.size)return;let{value:n}=e,{document:r}=n;const{selection:i}=n,{startText:o,endText:a,startInline:s}=n,c=t.getLastText(),u=t.getClosestInline(c.key),l=t.nodes.first(),d=t.nodes.last(),p=r.getTexts().map(e=>e.key),h=!s||i.hasEdgeAtStartOf(o)||i.hasEdgeAtEndOf(a),f=t.hasBlocks(l.key)||t.hasBlocks(d.key);e.insertFragmentAtRange(i,t);const m=(r=(n=e.value).document).getTexts().filter(e=>!p.includes(e.key)),g=h?m.last():m.takeLast(2).first();g&&(u||f)?e.select(i.collapseToEndOf(g)):g?e.select(i.collapseToStartOf(g).move(c.text.length)):e.select(i.collapseToStart().move(c.text.length))},xo.insertInline=(e,t)=>{t=wo.create(t);const{value:n}=e,{selection:r}=n;e.insertInlineAtRange(r,t);const i=e.value.document.getNode(t.key);i&&e.collapseToEndOf(i)},xo.insertText=(e,t,n)=>{const{value:r}=e,{document:i,selection:o}=r;n=n||o.marks||i.getInsertMarksAtRange(o),e.insertTextAtRange(o,t,n),o.marks&&i!==e.value.document&&e.select({marks:null})},xo.splitBlock=(e,t=1)=>{const{value:n}=e,{selection:r,document:i}=n,o=r.marks||i.getInsertMarksAtRange(r);e.splitBlockAtRange(r,t).collapseToEnd(),o&&0!==o.size&&e.select({marks:o})},xo.removeMark=(e,t)=>{t=vo.create(t);const{value:n}=e,{document:r,selection:i}=n;if(i.isExpanded)e.removeMarkAtRange(i,t);else if(i.marks){const n=i.marks.remove(t),r=i.set("marks",n);e.select(r)}else{const n=r.getActiveMarksAtRange(i).remove(t),o=i.set("marks",n);e.select(o)}},xo.replaceMark=(e,t,n)=>{e.removeMark(t),e.addMark(n)},xo.toggleMark=(e,t)=>{t=vo.create(t);const{value:n}=e;n.activeMarks.has(t)?e.removeMark(t):e.addMark(t)},xo.wrapText=(e,t,n=t)=>{const{value:r}=e,{selection:i}=r;e.wrapTextAtRange(i,t,n),i.isCollapsed&&e.moveStart(0-t.length),e.moveEnd(0-n.length),i.isForward!==e.value.selection.isForward&&e.flip()};class So extends(fo({})){get object(){return"document"}get isEmpty(){return!this.nodes.some(e=>!e.isEmpty)}get text(){return this.getText()}static isDocument(e){return oo("DOCUMENT",e)}static create(e={}){if(So.isDocument(e))return e;if((a.List.isList(e)||Array.isArray(e))&&(e={nodes:e}),c()(e))return So.fromJS(e);throw new Error(`\`Document.create\` only accepts objects, arrays, lists or documents, but you passed it: ${e}`)}static fromJS(e){if(So.isDocument(e))return e;const{data:t={},key:n=co(),nodes:r=[]}=e;return new So({key:n,data:(0,a.Map)(t),nodes:So.createChildren(r)})}toJS(e={}){const t={object:this.object,data:this.data.toJS(),nodes:this.nodes.toArray().map(t=>t.toJS(e))};return e.preserveKeys&&(t.key=this.key),t}getFragmentAtRange(e){if((e=e.normalize(this)).isUnset)return So.create();let t=this;const{startKey:n,startOffset:r,endKey:i,endOffset:o}=e,a=t.assertDescendant(n),s=t.assertDescendant(i);let c,u,l=a;for(;u=t.getParent(l.key);){const e=u.getChildIndex(l.key),n="text"===l.object?r:l.getChildIndex(c.key);u=u.splitNode(e,n),t=t.updateNode(u),c=u.nodes.get(e+1),l=u}for(l=n===i?t.getNextText(n):s;u=t.getParent(l.key);){const e=u.getChildIndex(l.key),a="text"===l.object?n===i?o-r:o:l.getChildIndex(c.key);u=u.splitNode(e,a),t=t.updateNode(u),c=u.nodes.get(e+1),l=u}const d=t.getNextSibling(t.getFurthestAncestor(n).key),p=n===i?t.getNextSibling(t.getNextSibling(t.getFurthestAncestor(i).key).key):t.getNextSibling(t.getFurthestAncestor(i).key),h=t.getChildIndex(d.key),f=t.getChildIndex(p.key),m=t.nodes.slice(h,f);return So.create({nodes:m})}}So.createChildren=_o.createChildren,So.prototype[io.DOCUMENT]=!0,go(So);const ko={isNode:e=>!!["BLOCK","DOCUMENT","INLINE","TEXT"].find(t=>oo(t,e)),isNodeList:e=>a.List.isList(e)&&e.every(e=>ko.isNode(e)),create(e={}){if(ko.isNode(e))return e;if(c()(e))switch(e.object){case"block":return _o.create(e);case"document":return So.create(e);case"inline":return wo.create(e);case"text":return Eo.create(e);default:throw new Error("`Node.create` requires a `object` string.")}throw new Error(`\`Node.create\` only accepts objects or nodes but you passed it: ${e}`)},createList:(e=[])=>(0,a.List)(e.map(ko.create)),createProperties(e={}){if(_o.isBlock(e)||wo.isInline(e))return{data:e.data,isVoid:e.isVoid,type:e.type};if("string"==typeof e)return{type:e};if(c()(e)){const t={};return"type"in e&&(t.type=e.type),"data"in e&&(t.data=yo.create(e.data)),"isVoid"in e&&(t.isVoid=e.isVoid),t}throw new Error(`\`Node.createProperties\` only accepts objects, strings, blocks or inlines, but you passed it: ${e}`)},fromJS(e){switch(e.object){case"block":return _o.fromJS(e);case"document":return So.fromJS(e);case"inline":return wo.fromJS(e);case"text":return Eo.fromJS(e);default:throw new Error(`\`Node.fromJS\` requires an \`object\` of either 'block', 'document', 'inline' or 'text', but you passed: ${e}`)}}},Oo=55296,To=57343,Ao=/\s/,Io=/['\u2018\u2019]/,Do=/[\u0021-\u0023\u0025-\u002A\u002C-\u002F\u003A\u003B\u003F\u0040\u005B-\u005D\u005F\u007B\u007D\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;function Co(e,t){if(Ao.test(e))return!1;if(Io.test(e)){let e=t.charAt(0);const n=Po(e);if(Co(e=t.slice(0,n),t.slice(n)))return!0}return!Do.test(e)}function Po(e){return t=e.charCodeAt(0),Oo<=t&&t<=To?2:1;var t}function Ro(e){return Po(e.charAt(0))}function No(e){let t=0,n=0,r=!1;for(;;){let i=e.charAt(n);if(!i)break;const o=Po(i);if(Co(i=e.slice(n,n+o),e.slice(n+o)))r=!0,t+=o;else{if(r)break;t+=o}n+=o}return t}var Lo={getCharOffsetForward:function(e,t){return Ro(e=e.slice(t))},getCharOffsetBackward:function(e,t){return e=e.slice(0,t),Ro(e=(0,d.reverse)(e))},getWordOffsetBackward:function(e,t){return e=e.slice(0,t),No(e=(0,d.reverse)(e))},getWordOffsetForward:function(e,t){return No(e=e.slice(t))}};const jo={};function Mo(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i{if(t.isCollapsed)return;const i=e.getFlag("normalize",r),{value:o}=e,{document:a}=o,{startKey:s,startOffset:c,endKey:u,endOffset:l}=t;a.getTextsAtRange(t).forEach(t=>{const{key:r}=t;let o=0,a=t.text.length;r===s&&(o=c),r===u&&(a=l),r===s&&r===u&&(a=l-c),e.addMarkByKey(r,o,a,n,{normalize:i})})},jo.addMarksAtRange=(e,t,n,r={})=>{n.forEach(n=>e.addMarkAtRange(t,n,r))},jo.deleteAtRange=(e,t,n={})=>{if(t.isCollapsed)return;e.snapshotSelection();const r=e.getFlag("normalize",n),{value:i}=e;let{startKey:o,startOffset:a,endKey:s,endOffset:c}=t,{document:u}=i,l=u.hasVoidParent(o),d=u.hasVoidParent(s),p=u.getClosestBlock(o),h=u.getClosestBlock(s);const f=0===a&&0===c&&!1===l&&o===p.getFirstText().key&&s===h.getFirstText().key;if(f&&d){const e=u.getPreviousText(s);s=e.key,c=e.text.length,d=u.hasVoidParent(s)}for(;l;){const t=u.getClosestVoid(o),n=u.getNextText(o);if(e.removeNodeByKey(t.key,{normalize:!1}),o===s)return;if(!n)return;u=e.value.document,o=n.key,a=0,l=u.hasVoidParent(o)}for(;d;){const t=u.getClosestVoid(s),n=u.getPreviousText(s);e.removeNodeByKey(t.key,{normalize:!1}),u=e.value.document,s=n.key,c=n.text.length,d=u.hasVoidParent(s)}if(o===s&&f)e.removeNodeByKey(p.key,{normalize:r});else if(o!==s){p=u.getClosestBlock(o),h=u.getClosestBlock(s);const t=u.getNode(o),n=u.getNode(s),i=t.text.length-a,l=c,d=u.getCommonAncestor(o,s),m=d.getFurthestAncestor(o),g=d.getFurthestAncestor(s),y=u.getParent(p.key),v=y.getChildIndex(p.key),b=y.getChildIndex(h.key);let E;for(E=t;E.key!==m.key;){const t=u.getParent(E.key),n=t.getChildIndex(E.key);t.nodes.slice(n+1).reverse().forEach(t=>{e.removeNodeByKey(t.key,{normalize:!1})}),E=t}const w=d.getChildIndex(m.key),_=d.getChildIndex(g.key);for(d.nodes.slice(w+1,_).reverse().forEach(t=>{e.removeNodeByKey(t.key,{normalize:!1})}),E=n;E.key!==g.key;){const t=u.getParent(E.key),n=t.getChildIndex(E.key);t.nodes.slice(0,n).reverse().forEach(t=>{e.removeNodeByKey(t.key,{normalize:!1})}),E=t}if(0!==i&&e.removeTextByKey(o,a,i,{normalize:!1}),0!==l&&e.removeTextByKey(s,0,c,{normalize:!1}),p.key!==h.key){const t=(u=e.value.document).getFurthestOnlyChildAncestor(h.key);b!==v+1&&e.moveNodeByKey(h.key,y.key,v+1,{normalize:!1}),f?e.removeNodeByKey(p.key,{normalize:!1}):e.mergeNodeByKey(h.key,{normalize:!1}),t&&e.removeNodeByKey(t.key,{normalize:!1})}r&&e.normalizeNodeByKey(d.key)}else{const t=a,n=c-a;e.removeTextByKey(o,t,n,{normalize:r})}},jo.deleteCharBackwardAtRange=(e,t,n)=>{const{value:r}=e,{document:i}=r,{startKey:o,startOffset:a}=t,s=i.getClosestBlock(o),c=s.getOffset(o)+a,{text:u}=s,l=Lo.getCharOffsetBackward(u,c);e.deleteBackwardAtRange(t,l,n)},jo.deleteLineBackwardAtRange=(e,t,n)=>{const{value:r}=e,{document:i}=r,{startKey:o,startOffset:a}=t,s=i.getClosestBlock(o).getOffset(o)+a;e.deleteBackwardAtRange(t,s,n)},jo.deleteWordBackwardAtRange=(e,t,n)=>{const{value:r}=e,{document:i}=r,{startKey:o,startOffset:a}=t,s=i.getClosestBlock(o),c=s.getOffset(o)+a,{text:u}=s,l=Lo.getWordOffsetBackward(u,c);e.deleteBackwardAtRange(t,l,n)},jo.deleteBackwardAtRange=(e,t,n=1,r={})=>{if(0===n)return;const i=e.getFlag("normalize",r),{value:o}=e,{document:a}=o,{startKey:s,focusOffset:c}=t;if(t.isExpanded)return void e.deleteAtRange(t,{normalize:i});const u=a.getClosestVoid(s);if(u)return void e.removeNodeByKey(u.key,{normalize:i});const l=a.getClosestBlock(s);if(l&&l.isEmpty&&1!==a.nodes.size)return void e.removeNodeByKey(l.key,{normalize:i});if(t.isAtStartOf(a))return;const d=a.getDescendant(s);if(t.isAtStartOf(d)){const r=a.getPreviousText(d.key),o=a.getClosestBlock(r.key),s=a.getClosestVoid(r.key);if(s)return void e.removeNodeByKey(s.key,{normalize:i});if(1===n&&o!==l)return t=t.merge({anchorKey:r.key,anchorOffset:r.text.length}),void e.deleteAtRange(t,{normalize:i})}if(nf;){const e=f+(p=a.getPreviousText(p.key)).text.length;if(n<=e){h=e-n;break}f=e}t=t.merge({focusKey:p.key,focusOffset:h,isBackward:!0}),e.deleteAtRange(t,{normalize:i})},jo.deleteCharForwardAtRange=(e,t,n)=>{const{value:r}=e,{document:i}=r,{startKey:o,startOffset:a}=t,s=i.getClosestBlock(o),c=s.getOffset(o)+a,{text:u}=s,l=Lo.getCharOffsetForward(u,c);e.deleteForwardAtRange(t,l,n)},jo.deleteLineForwardAtRange=(e,t,n)=>{const{value:r}=e,{document:i}=r,{startKey:o,startOffset:a}=t,s=i.getClosestBlock(o),c=s.getOffset(o)+a;e.deleteForwardAtRange(t,s.text.length-c,n)},jo.deleteWordForwardAtRange=(e,t,n)=>{const{value:r}=e,{document:i}=r,{startKey:o,startOffset:a}=t,s=i.getClosestBlock(o),c=s.getOffset(o)+a,{text:u}=s,l=Lo.getWordOffsetForward(u,c);e.deleteForwardAtRange(t,l,n)},jo.deleteForwardAtRange=(e,t,n=1,r={})=>{if(0===n)return;const i=e.getFlag("normalize",r),{value:o}=e,{document:a}=o,{startKey:s,focusOffset:c}=t;if(t.isExpanded)return void e.deleteAtRange(t,{normalize:i});const u=a.getClosestVoid(s);if(u)return void e.removeNodeByKey(u.key,{normalize:i});const l=a.getClosestBlock(s);if(l&&l.isEmpty&&1!==a.nodes.size){const t=a.getNextBlock(l.key);return e.removeNodeByKey(l.key,{normalize:i}),void(t&&t.key&&e.moveToStartOf(t))}if(t.isAtEndOf(a))return;const d=a.getDescendant(s);if(t.isAtEndOf(d)){const r=a.getNextText(d.key),o=a.getClosestBlock(r.key),s=a.getClosestVoid(r.key);if(s)return void e.removeNodeByKey(s.key,{normalize:i});if(1===n&&o!==l)return t=t.merge({focusKey:r.key,focusOffset:0}),void e.deleteAtRange(t,{normalize:i})}if(n<=d.text.length-c)return t=t.merge({focusOffset:c+n}),void e.deleteAtRange(t,{normalize:i});let p=d,h=c,f=d.text.length-c;for(;n>f;){const e=f+(p=a.getNextText(p.key)).text.length;if(n<=e){h=n-f;break}f=e}if(a.hasVoidParent(p.key)){const e=a.getClosestVoid(p.key);h=(p=a.getPreviousText(e.key)).text.length}t=t.merge({focusKey:p.key,focusOffset:h}),e.deleteAtRange(t,{normalize:i})},jo.insertBlockAtRange=(e,t,n,r={})=>{n=_o.create(n);const i=e.getFlag("normalize",r);t.isExpanded&&(e.deleteAtRange(t),t=t.collapseToStart());const{value:o}=e,{document:a}=o;let{startKey:s,startOffset:c}=t;const u=a.getClosestBlock(s),l=a.getClosestInline(s),d=a.getParent(u.key),p=d.getChildIndex(u.key);if(u.isVoid){const r=t.isAtEndOf(u)?1:0;e.insertNodeByKey(d.key,p+r,n,{normalize:i})}else if(u.isEmpty)e.insertNodeByKey(d.key,p+1,n,{normalize:i});else if(t.isAtStartOf(u))e.insertNodeByKey(d.key,p,n,{normalize:i});else if(t.isAtEndOf(u))e.insertNodeByKey(d.key,p+1,n,{normalize:i});else{if(l&&l.isVoid){const e=t.isAtEndOf(l),n=e?a.getNextText(s):a.getPreviousText(s),r=e?t.moveToStartOf(n):t.moveToEndOf(n);s=r.startKey,c=r.startOffset}e.splitDescendantsByKey(u.key,s,c,{normalize:!1}),e.insertNodeByKey(d.key,p+1,n,{normalize:i})}i&&e.normalizeNodeByKey(d.key)},jo.insertFragmentAtRange=(e,t,n,r={})=>{const i=e.getFlag("normalize",r);if(t.isExpanded&&(e.deleteAtRange(t,{normalize:!1}),t=e.value.document.getDescendant(t.startKey)?t.collapseToStart():t.collapseTo(t.endKey,0)),!n.nodes.size)return;n=n.mapDescendants(e=>e.regenerateKey());const{startKey:o,startOffset:s}=t,{value:c}=e;let{document:u}=c,l=u.getDescendant(o),d=u.getClosestBlock(l.key),p=d.getFurthestAncestor(l.key);const h=t.isAtStartOf(d),f=u.getParent(d.key),m=f.getChildIndex(d.key),g=n.getBlocks(),y=n.nodes.first(),v=n.nodes.last(),b=g.first(),E=g.last();if(b===E&&b.isVoid)e.insertBlockAtRange(t,b,r);else if(n.hasBlocks(y.key)||n.hasBlocks(v.key))n.nodes.reverse().forEach(n=>{e.insertBlockAtRange(t,n,r)});else{if(b!==E){const t=n.getFurthest(b.key,e=>1===e.nodes.size)||b,r=f.getChildIndex(d.key);(n=n.removeDescendant(t.key)).nodes.forEach((t,n)=>{const i=r+n+1;e.insertNodeByKey(f.key,i,t,{normalize:!1})})}if(0!==s&&e.splitDescendantsByKey(p.key,o,s,{normalize:!1}),l=(u=e.value.document).getDescendant(o),p=(d=u.getClosestBlock(o)).getFurthestAncestor(l.key),b!==E){const t=h?p:d.getNextSibling(p.key),n=t?d.nodes.skipUntil(e=>e.key===t.key):(0,a.List)(),r=E.nodes.size;n.forEach((t,n)=>{const i=r+n;e.moveNodeByKey(t.key,E.key,i,{normalize:!1})})}if(d.isEmpty)e.removeNodeByKey(d.key,{normalize:!1}),e.insertNodeByKey(f.key,m,b,{normalize:!1});else{const t=d.getFurthestAncestor(l.key),n=d.getChildIndex(t.key);b.nodes.forEach((t,r)=>{const i=n+r+(0===s?0:1);e.insertNodeByKey(d.key,i,t,{normalize:!1})})}i&&e.normalizeNodeByKey(f.key)}},jo.insertInlineAtRange=(e,t,n,r={})=>{const i=e.getFlag("normalize",r);n=wo.create(n),t.isExpanded&&(e.deleteAtRange(t,{normalize:!1}),t=t.collapseToStart());const{value:o}=e,{document:a}=o,{startKey:s,startOffset:c}=t,u=a.getParent(s),l=a.assertDescendant(s),d=u.getChildIndex(l.key);u.isVoid||(e.splitNodeByKey(s,c,{normalize:!1}),e.insertNodeByKey(u.key,d+1,n,{normalize:!1}),i&&e.normalizeNodeByKey(u.key))},jo.insertTextAtRange=(e,t,n,r,i={})=>{let{normalize:o}=i;const{value:a}=e,{document:s}=a,{startKey:c,startOffset:u}=t;let l=c,d=u;if(!s.getParent(c).isVoid&&(t.isExpanded&&(e.deleteAtRange(t,{normalize:!1}),e.value.startKey!==l&&(l=e.value.startKey,d=e.value.startOffset)),void 0===o&&(o=t.isExpanded&&r&&0!==r.size),e.insertTextByKey(l,d,n,r,{normalize:!1}),o)){const n=s.getCommonAncestor(c,t.endKey),r=s.getAncestors(n.key).push(n).findLast(t=>e.value.document.getDescendant(t.key)),i=r?r.key:c;e.normalizeNodeByKey(i)}},jo.removeMarkAtRange=(e,t,n,r={})=>{if(t.isCollapsed)return;const i=e.getFlag("normalize",r),{value:o}=e,{document:a}=o,s=a.getTextsAtRange(t),{startKey:c,startOffset:u,endKey:l,endOffset:d}=t;s.forEach(t=>{const{key:r}=t;let o=0,a=t.text.length;r===c&&(o=u),r===l&&(a=d),r===c&&r===l&&(a=d-u),e.removeMarkByKey(r,o,a,n,{normalize:i})})},jo.setBlocksAtRange=(e,t,n,r={})=>{const i=e.getFlag("normalize",r),{value:o}=e,{document:a}=o,s=a.getBlocksAtRange(t),{startKey:c,startOffset:u,endKey:l,endOffset:d,isCollapsed:p}=t,h=a.hasVoidParent(c),f=a.getClosestBlock(c),m=a.getClosestBlock(l);(!1===p&&0===u&&0===d&&!1===h&&c===f.getFirstText().key&&l===m.getFirstText().key?s.slice(0,-1):s).forEach(t=>{e.setNodeByKey(t.key,n,{normalize:i})})},jo.setBlockAtRange=(...e)=>{(0,o.zi)("slate@0.33.0","The `setBlockAtRange` method of Slate changes has been renamed to `setBlocksAtRange`."),jo.setBlocksAtRange(...e)},jo.setInlinesAtRange=(e,t,n,r={})=>{const i=e.getFlag("normalize",r),{value:o}=e,{document:a}=o;a.getInlinesAtRange(t).forEach(t=>{e.setNodeByKey(t.key,n,{normalize:i})})},jo.setInlineAtRange=(...e)=>{(0,o.zi)("slate@0.33.0","The `setInlineAtRange` method of Slate changes has been renamed to `setInlinesAtRange`."),jo.setInlinesAtRange(...e)},jo.splitBlockAtRange=(e,t,n=1,r={})=>{const i=e.getFlag("normalize",r),{startKey:o,startOffset:a,endOffset:s,endKey:c}=t,{value:u}=e,{document:l}=u;let d=l.assertDescendant(o),p=l.getClosestBlock(d.key),h=0;for(;p&&"block"===p.object&&h{const i=e.getFlag("normalize",r);t.isExpanded&&(e.deleteAtRange(t,{normalize:i}),t=t.collapseToStart());const{startKey:o,startOffset:a}=t,{value:s}=e,{document:c}=s;let u=c.assertDescendant(o),l=c.getClosestInline(u.key),d=0;for(;l&&"inline"===l.object&&d{if(t.isCollapsed)return;n=vo.create(n);const i=e.getFlag("normalize",r),{value:o}=e,{document:a}=o;a.getActiveMarksAtRange(t).some(e=>e.equals(n))?e.removeMarkAtRange(t,n,{normalize:i}):e.addMarkAtRange(t,n,{normalize:i})},jo.unwrapBlockAtRange=(e,t,n,r={})=>{n=ko.createProperties(n);const i=e.getFlag("normalize",r),o=e.value.document.getBlocksAtRange(t);o.map(t=>e.value.document.getClosest(t.key,e=>"block"===e.object&&((null==n.type||e.type===n.type)&&((null==n.isVoid||e.isVoid===n.isVoid)&&!(null!=n.data&&!e.data.isSuperset(n.data)))))).filter(e=>e).toOrderedSet().toList().forEach(t=>{const n=t.nodes.first(),r=t.nodes.last(),i=e.value.document.getParent(t.key),a=i.getChildIndex(t.key),s=t.nodes.filter(e=>o.some(t=>e===t||e.hasDescendant(t.key))),c=s.first(),u=s.last();if(n===c&&r===u)t.nodes.forEach((t,n)=>{e.moveNodeByKey(t.key,i.key,a+n,{normalize:!1})}),e.removeNodeByKey(t.key,{normalize:!1});else if(r===u)t.nodes.skipUntil(e=>e===c).forEach((t,n)=>{e.moveNodeByKey(t.key,i.key,a+1+n,{normalize:!1})});else if(n===c)t.nodes.takeUntil(e=>e===u).push(u).forEach((t,n)=>{e.moveNodeByKey(t.key,i.key,a+n,{normalize:!1})});else{const n=c.getFirstText();e.splitDescendantsByKey(t.key,n.key,0,{normalize:!1}),s.forEach((t,n)=>{if(0===n){const n=t;t=e.value.document.getNextBlock(t.key),e.removeNodeByKey(n.key,{normalize:!1})}e.moveNodeByKey(t.key,i.key,a+1+n,{normalize:!1})})}}),i&&e.normalizeDocument()},jo.unwrapInlineAtRange=(e,t,n,r={})=>{n=ko.createProperties(n);const i=e.getFlag("normalize",r),{value:o}=e,{document:a}=o;a.getTextsAtRange(t).map(e=>a.getClosest(e.key,e=>"inline"===e.object&&((null==n.type||e.type===n.type)&&((null==n.isVoid||e.isVoid===n.isVoid)&&!(null!=n.data&&!e.data.isSuperset(n.data)))))).filter(e=>e).toOrderedSet().toList().forEach(t=>{const n=e.value.document.getParent(t.key),r=n.getChildIndex(t.key);t.nodes.forEach((t,i)=>{e.moveNodeByKey(t.key,n.key,r+i,{normalize:!1})})}),i&&e.normalizeDocument()},jo.wrapBlockAtRange=(e,t,n,r={})=>{n=(n=_o.create(n)).set("nodes",n.nodes.clear());const i=e.getFlag("normalize",r),{value:o}=e,{document:a}=o,s=a.getBlocksAtRange(t),c=s.first(),u=s.last();let l,d,p;if(1===s.length?(l=a.getParent(c.key),d=s):l=a.getClosest(c.key,e=>!!a.getClosest(u.key,t=>e===t)),null==l&&(l=a),null==d){const e=l.nodes.reduce((e,t,n)=>((t===c||t.hasDescendant(c.key))&&(e[0]=n),(t===u||t.hasDescendant(u.key))&&(e[1]=n),e),[]);p=e[0],d=l.nodes.slice(e[0],e[1]+1)}null==p&&(p=l.nodes.indexOf(d.first())),e.insertNodeByKey(l.key,p,n,{normalize:!1}),d.forEach((t,r)=>{e.moveNodeByKey(t.key,n.key,r,{normalize:!1})}),i&&e.normalizeNodeByKey(l.key)},jo.wrapInlineAtRange=(e,t,n,r={})=>{const{value:i}=e;let{document:o}=i;const s=e.getFlag("normalize",r),{startKey:c,startOffset:u,endKey:l,endOffset:d}=t;if(t.isCollapsed){const t=o.getClosestInline(c);if(!t.isVoid)return;return e.wrapInlineByKey(t.key,n,r)}n=(n=wo.create(n)).set("nodes",n.nodes.clear());const p=o.getBlocksAtRange(t);let h=o.getClosestBlock(c),f=o.getClosestBlock(l);const m=o.getClosestInline(c),g=o.getClosestInline(l);let y=h.getFurthestAncestor(c),v=f.getFurthestAncestor(l);m&&m===g||(e.splitDescendantsByKey(v.key,l,d,{normalize:!1}),e.splitDescendantsByKey(y.key,c,u,{normalize:!1})),h=(o=e.value.document).getDescendant(h.key),f=o.getDescendant(f.key),y=h.getFurthestAncestor(c),v=f.getFurthestAncestor(l);const b=h.getChildIndex(y.key),E=f.getChildIndex(v.key);if(m&&m===g){const r=h.getTextsAtRange(t).get(0).splitText(u)[1].splitText(d-u)[0];n=n.set("nodes",(0,a.List)([r])),jo.insertInlineAtRange(e,t,n,{normalize:!1});const i=n.getFirstText().key,o={anchorKey:i,focusKey:i,anchorOffset:0,focusOffset:d-u,isFocused:!0};e.select(o)}else if(h===f){y=(h=(o=e.value.document).getClosestBlock(c)).getFurthestAncestor(c);const t=o.getNextSibling(y.key),r=h.getChildIndex(t.key),i=c===l?t:h.getFurthestAncestor(l),a=h.nodes.skipUntil(e=>e===t).takeUntil(e=>e===i).push(i),u=n.regenerateKey();e.insertNodeByKey(h.key,r,u,{normalize:!1}),a.forEach((t,n)=>{e.moveNodeByKey(t.key,u.key,n,{normalize:!1})}),s&&e.normalizeNodeByKey(h.key)}else{const t=h.nodes.slice(b+1),r=f.nodes.slice(0,E+1),i=n.regenerateKey(),o=n.regenerateKey();e.insertNodeByKey(h.key,b+1,i,{normalize:!1}),e.insertNodeByKey(f.key,E,o,{normalize:!1}),t.forEach((t,n)=>{e.moveNodeByKey(t.key,i.key,n,{normalize:!1})}),r.forEach((t,n)=>{e.moveNodeByKey(t.key,o.key,n,{normalize:!1})}),s&&e.normalizeNodeByKey(h.key).normalizeNodeByKey(f.key),p.slice(1,-1).forEach(t=>{const r=n.regenerateKey();e.insertNodeByKey(t.key,0,r,{normalize:!1}),t.nodes.forEach((t,n)=>{e.moveNodeByKey(t.key,r.key,n,{normalize:!1})}),s&&e.normalizeNodeByKey(t.key)})}},jo.wrapTextAtRange=(e,t,n,r=n,i={})=>{const o=e.getFlag("normalize",i),{startKey:a,endKey:s}=t,c=t.collapseToStart();let u=t.collapseToEnd();a===s&&(u=u.move(n.length)),e.insertTextAtRange(c,n,[],{normalize:o}),e.insertTextAtRange(u,r,[],{normalize:o})};const Bo={add_mark:["value","path","offset","length","mark"],insert_node:["value","path","node"],insert_text:["value","path","offset","text","marks"],merge_node:["value","path","position","properties","target"],move_node:["value","path","newPath"],remove_mark:["value","path","offset","length","mark"],remove_node:["value","path","node"],remove_text:["value","path","offset","text","marks"],set_mark:["value","path","offset","length","mark","properties"],set_node:["value","path","node","properties"],set_selection:["value","selection","properties"],set_value_data:["data","previousData"],split_node:["value","path","position","properties","target"]};class Fo extends((0,a.Record)({anchorKey:null,anchorOffset:0,focusKey:null,focusOffset:0,isBackward:null,isFocused:!1,marks:null,isAtomic:!1})){get object(){return"range"}get isBlurred(){return!this.isFocused}get isCollapsed(){return this.anchorKey===this.focusKey&&this.anchorOffset===this.focusOffset}get isExpanded(){return!this.isCollapsed}get isForward(){return null==this.isBackward?null:!this.isBackward}get isSet(){return null!=this.anchorKey&&null!=this.focusKey}get isUnset(){return!this.isSet}get startKey(){return this.isBackward?this.focusKey:this.anchorKey}get startOffset(){return this.isBackward?this.focusOffset:this.anchorOffset}get endKey(){return this.isBackward?this.anchorKey:this.focusKey}get endOffset(){return this.isBackward?this.anchorOffset:this.focusOffset}static create(e={}){if(Fo.isRange(e))return e;if(c()(e))return Fo.fromJS(e);throw new Error(`\`Range.create\` only accepts objects or ranges, but you passed it: ${e}`)}static createList(e=[]){if(a.List.isList(e)||Array.isArray(e)){return new a.List(e.map(Fo.create))}throw new Error(`\`Range.createList\` only accepts arrays or lists, but you passed it: ${e}`)}static createProperties(e={}){if(Fo.isRange(e))return{anchorKey:e.anchorKey,anchorOffset:e.anchorOffset,focusKey:e.focusKey,focusOffset:e.focusOffset,isBackward:e.isBackward,isFocused:e.isFocused,marks:e.marks,isAtomic:e.isAtomic};if(c()(e)){const t={};return"anchorKey"in e&&(t.anchorKey=e.anchorKey),"anchorOffset"in e&&(t.anchorOffset=e.anchorOffset),"anchorPath"in e&&(t.anchorPath=e.anchorPath),"focusKey"in e&&(t.focusKey=e.focusKey),"focusOffset"in e&&(t.focusOffset=e.focusOffset),"focusPath"in e&&(t.focusPath=e.focusPath),"isBackward"in e&&(t.isBackward=e.isBackward),"isFocused"in e&&(t.isFocused=e.isFocused),"marks"in e&&(t.marks=null==e.marks?null:vo.createSet(e.marks)),"isAtomic"in e&&(t.isAtomic=e.isAtomic),t}throw new Error(`\`Range.createProperties\` only accepts objects or ranges, but you passed it: ${e}`)}static fromJS(e){const{anchorKey:t=null,anchorOffset:n=0,focusKey:r=null,focusOffset:i=0,isBackward:o=null,isFocused:a=!1,marks:s=null,isAtomic:c=!1}=e;return new Fo({anchorKey:t,anchorOffset:n,focusKey:r,focusOffset:i,isBackward:o,isFocused:a,marks:null==s?null:vo.createSet(s),isAtomic:c})}static isRange(e){return!(!e||!e[io.RANGE])}hasAnchorAtStartOf(e){if(0!==this.anchorOffset)return!1;const t=Uo(e);return this.anchorKey===t.key}hasAnchorAtEndOf(e){const t=zo(e);return this.anchorKey===t.key&&this.anchorOffset===t.text.length}hasAnchorBetween(e,t,n){return this.anchorOffset<=n&&t<=this.anchorOffset&&this.hasAnchorIn(e)}hasAnchorIn(e){return"text"===e.object?e.key===this.anchorKey:null!=this.anchorKey&&e.hasDescendant(this.anchorKey)}hasFocusAtEndOf(e){const t=zo(e);return this.focusKey===t.key&&this.focusOffset===t.text.length}hasFocusAtStartOf(e){if(0!==this.focusOffset)return!1;const t=Uo(e);return this.focusKey===t.key}hasFocusBetween(e,t,n){return t<=this.focusOffset&&this.focusOffset<=n&&this.hasFocusIn(e)}hasFocusIn(e){return"text"===e.object?e.key===this.focusKey:null!=this.focusKey&&e.hasDescendant(this.focusKey)}isAtStartOf(e){return this.isCollapsed&&this.hasAnchorAtStartOf(e)}isAtEndOf(e){return this.isCollapsed&&this.hasAnchorAtEndOf(e)}focus(){return this.merge({isFocused:!0})}blur(){return this.merge({isFocused:!1})}deselect(){return this.merge({anchorKey:null,anchorOffset:0,focusKey:null,focusOffset:0,isFocused:!1,isBackward:!1})}flip(){return this.merge({anchorKey:this.focusKey,anchorOffset:this.focusOffset,focusKey:this.anchorKey,focusOffset:this.anchorOffset,isBackward:null==this.isBackward?null:!this.isBackward})}moveAnchor(e=1){const{anchorKey:t,focusKey:n,focusOffset:r,isBackward:i}=this,o=this.anchorOffset+e;return this.merge({anchorOffset:o,isBackward:t===n?o>r:i})}moveFocus(e=1){const{anchorKey:t,anchorOffset:n,focusKey:r,isBackward:i}=this,o=this.focusOffset+e;return this.merge({focusOffset:o,isBackward:r===t?n>o:i})}moveAnchorTo(e,t){const{anchorKey:n,focusKey:r,focusOffset:i,isBackward:o}=this;return this.merge({anchorKey:e,anchorOffset:t,isBackward:e===r?t>i:e===n?o:null})}moveFocusTo(e,t){const{focusKey:n,anchorKey:r,anchorOffset:i,isBackward:o}=this;return this.merge({focusKey:e,focusOffset:t,isBackward:e===r?i>t:e===n?o:null})}moveAnchorOffsetTo(e){return this.merge({anchorOffset:e,isBackward:this.anchorKey===this.focusKey?e>this.focusOffset:this.isBackward})}moveFocusOffsetTo(e){return this.merge({focusOffset:e,isBackward:this.anchorKey===this.focusKey?this.anchorOffset>e:this.isBackward})}moveOffsetsTo(e,t=e){return this.moveAnchorOffsetTo(e).moveFocusOffsetTo(t)}moveToAnchor(){return this.moveFocusTo(this.anchorKey,this.anchorOffset)}moveToFocus(){return this.moveAnchorTo(this.focusKey,this.focusOffset)}moveAnchorToStartOf(e){return e=Uo(e),this.moveAnchorTo(e.key,0)}moveAnchorToEndOf(e){return e=zo(e),this.moveAnchorTo(e.key,e.text.length)}moveFocusToStartOf(e){return e=Uo(e),this.moveFocusTo(e.key,0)}moveFocusToEndOf(e){return e=zo(e),this.moveFocusTo(e.key,e.text.length)}moveToRangeOf(e,t=e){return(this.isBackward?this.flip():this).moveAnchorToStartOf(e).moveFocusToEndOf(t)}normalize(e){const t=this;let{anchorOffset:n,focusOffset:r,isBackward:i}=t;const{anchorKey:a,focusKey:s}=t,c=typeof n,u=typeof r;if("number"===c&&"number"===u||(0,o.Zc)(`The range offsets should be numbers, but they were of type "${c}" and "${u}".`),null==a||null==s)return t.merge({anchorKey:null,anchorOffset:0,focusKey:null,focusOffset:0,isBackward:!1});let l=e.getDescendant(a),d=e.getDescendant(s);if(!l||!d){(0,o.Zc)("The range was invalid and was reset. The range in question was:",t);const n=e.getFirstText();return t.merge({anchorKey:n?n.key:null,anchorOffset:0,focusKey:n?n.key:null,focusOffset:0,isBackward:!1})}if("text"!==l.object){(0,o.Zc)("The range anchor was set to a Node that is not a Text node. This should not happen and can degrade performance. The node in question was:",l);const e=l.getTextAtOffset(n);n-=l.getOffset(e.key),l=e}if("text"!==d.object){(0,o.Zc)("The range focus was set to a Node that is not a Text node. This should not happen and can degrade performance. The node in question was:",d);const e=d.getTextAtOffset(r);r-=d.getOffset(e.key),d=e}null==i&&(i=l.key===d.key?n>r:!e.areDescendantsSorted(l.key,d.key));const p=e.getDescendant(a),h=e.getDescendant(s);return n=Math.min(Math.max(0,n),p.text.length),r=Math.min(Math.max(0,r),h.text.length),t.merge({anchorKey:l.key,anchorOffset:n,focusKey:d.key,focusOffset:r,isBackward:i})}toJS(){return{object:this.object,anchorKey:this.anchorKey,anchorOffset:this.anchorOffset,focusKey:this.focusKey,focusOffset:this.focusOffset,isBackward:this.isBackward,isFocused:this.isFocused,marks:null==this.marks?null:this.marks.toArray().map(e=>e.toJS()),isAtomic:this.isAtomic}}}Fo.prototype[io.RANGE]=!0;[["move",""],["move","To"],["move","ToStartOf"],["move","ToEndOf"]].forEach(([e,t])=>{Fo.prototype[`${e}${t}`]=function(...n){return this[`${e}Anchor${t}`](...n)[`${e}Focus${t}`](...n)}});[["has","AtStartOf",!0],["has","AtEndOf",!0],["has","Between",!0],["has","In",!0],["collapseTo",""],["move",""],["moveTo",""],["move","To"],["move","OffsetTo"]].forEach(([e,t,n])=>{const r=`${e}Anchor${t}`,i=`${e}Focus${t}`;Fo.prototype[`${e}Start${t}`]=function(...e){return this.isBackward?this[i](...e):this[r](...e)},Fo.prototype[`${e}End${t}`]=function(...e){return this.isBackward?this[r](...e):this[i](...e)},n&&(Fo.prototype[`${e}Edge${t}`]=function(...e){return this[r](...e)||this[i](...e)})});function Uo(e){return"text"===e.object?e:e.getFirstText()}function zo(e){return"text"===e.object?e:e.getLastText()}[["collapseTo","moveTo"],["collapseToAnchor","moveToAnchor"],["collapseToFocus","moveToFocus"],["collapseToStart","moveToStart"],["collapseToEnd","moveToEnd"],["collapseToStartOf","moveToStartOf"],["collapseToEndOf","moveToEndOf"],["extend","moveFocus"],["extendTo","moveFocusTo"],["extendToStartOf","moveFocusToStartOf"],["extendToEndOf","moveFocusToEndOf"]].forEach(([e,t])=>{Fo.prototype[e]=function(...e){return this[t](...e)}});const $o=(0,o.ar)("slate:schema");class qo extends((0,a.Record)({validations:[],document:{},blocks:{},inlines:{}})){get object(){return"schema"}static create(e={}){return qo.isSchema(e)?e:new qo(e)}static isSchema(e){return!(!e||!e[io.SCHEMA])}static createNormalize(e){return(t,n,r)=>e[n]?e[n](t,r):void 0}combineWith(e){return Array.isArray(e)?e.reduce((e,t)=>e.combineWith(t),this):new qo({validations:[...this.validations,...e.validations],document:Ho(this.document,e.document),blocks:Go(this.blocks,e.blocks),inlines:Go(this.inlines,e.inlines)})}getFirstInvalidNode(e){if(Eo.isText(e))return this.validateNode(e)?e:null;let t=null;return e.nodes.find(e=>t=this.validateNode(e)?e:this.getFirstInvalidNode(e)),t}getRule(e){switch(e.object){case"document":return this.document;case"block":return this.blocks[e.type];case"inline":return this.inlines[e.type]}}getParentRules(){const{blocks:e,inlines:t}=this,n={};for(const r of Object.keys(e)){const t=e[r];null!=t.parent&&(n[r]=t)}for(const r of Object.keys(t)){const e=t[r];null!=e.parent&&(n[r]=e)}return 0===Object.keys(n).length?null:n}fail(e,t){return n=>{$o("normalizing",{violation:e,context:t});const{rule:r}=t,{size:i}=n.operations;r.normalize&&r.normalize(n,e,t),n.operations.size>i||this.normalize(n,e,t)}}normalize(e,t,n){switch(t){case un.ue:case un.wu:case un.EK:case un.NW:case un.ck:case un.JS:case un.J:{const{child:t,node:r}=n;return"text"===t.object&&"block"===r.object&&1===r.nodes.size?e.removeNodeByKey(r.key):e.removeNodeByKey(t.key)}case un.DS:case un.Ue:case un.jN:case un.Sd:{const{node:t}=n;return"document"===t.object?t.nodes.forEach(t=>e.removeNodeByKey(t.key)):e.removeNodeByKey(t.key)}case un.JX:{const{node:t,key:r}=n;return void 0===t.data.get(r)&&"document"!==t.object?e.removeNodeByKey(t.key):e.setNodeByKey(t.key,{data:t.data.delete(r)})}case un.he:{const{node:t}=n;return e.setNodeByKey(t.key,{isVoid:!t.isVoid})}case un.CP:{const{node:t,mark:r}=n;return t.getTexts().forEach(t=>e.removeMarkByKey(t.key,0,t.text.length,r))}}}validateNode(e){for(const s of this.validations){const t=s(e);if(null!=t)return t}if("text"===e.object)return;const t=this.getRule(e)||{},n=this.getParentRules(),r={node:e,rule:t};if(null!=t.isVoid&&e.isVoid!==t.isVoid)return this.fail(un.he,r);if(null!=t.data)for(const s of Object.keys(t.data)){const n=t.data[s],i=e.data.get(s);if(!n(i))return this.fail(un.JX,Object.assign({},r,{key:s,value:i}))}if(null!=t.marks){const n=e.getMarks().toArray();for(const e of n)if(!t.marks.some(t=>t.type===e.type))return this.fail(un.CP,Object.assign({},r,{mark:e}))}if(null!=t.text){const{text:n}=e;if(!t.text.test(n))return this.fail(un.Ue,Object.assign({},r,{text:n}))}if(null!=t.first){const{objects:n,types:i}=t.first,o=e.nodes.first();if(o&&n&&!n.includes(o.object))return this.fail(un.NW,Object.assign({},r,{child:o}));if(o&&i&&!i.includes(o.type))return this.fail(un.ck,Object.assign({},r,{child:o}))}if(null!=t.last){const{objects:n,types:i}=t.last,o=e.nodes.last();if(o&&n&&!n.includes(o.object))return this.fail(un.JS,Object.assign({},r,{child:o}));if(o&&i&&!i.includes(o.type))return this.fail(un.J,Object.assign({},r,{child:o}))}if(null!=t.nodes||null!=n){const s=e.nodes.toArray(),c=null!=t.nodes?t.nodes.slice():[];let u,l,d,p,h,f;function i(){return u=null==u?null:0,p=c.shift(),l=p&&(null==p.min?0:p.min),h=p&&(null==p.max?1/0:p.max),!!p}function o(){return u=null==u?0:u+1,f=s[d=null==d?0:d+1],null!=h&&u===h&&i(),!!f}function a(){u-=1,d-=1}for(null!=t.nodes&&i();o();){if(null!=n&&"text"!==f.object&&f.type in n){const t=n[f.type];if(null!=t.parent.objects&&!t.parent.objects.includes(e.object))return this.fail(un.jN,{node:f,parent:e,rule:t});if(null!=t.parent.types&&!t.parent.types.includes(e.type))return this.fail(un.Sd,{node:f,parent:e,rule:t})}if(null!=t.nodes){if(!p)return this.fail(un.EK,Object.assign({},r,{child:f,index:d}));if(null!=p.objects&&!p.objects.includes(f.object)){if(u>=l&&i()){a();continue}return this.fail(un.ue,Object.assign({},r,{child:f,index:d}))}if(null!=p.types&&!p.types.includes(f.type)){if(u>=l&&i()){a();continue}return this.fail(un.wu,Object.assign({},r,{child:f,index:d}))}}}if(null!=t.nodes)for(;null!=l;){if(u{const o=n.operations.size;e(n,r,i),n.operations.size>o||t(n,r,i)}:"objects"===n||"types"===n||"marks"===n?null==e?t:e.concat(t):null==t?e:t}qo.prototype[io.SCHEMA]=!0,i()(qo.prototype,["getParentRules","getFirstInvalidNode","validateNode"]);const Vo=qo.create({validations:[e=>{if("document"!==e.object)return;const t=e.nodes.filter(e=>"block"!==e.object);return t.size?e=>{t.forEach(t=>{e.removeNodeByKey(t.key,{normalize:!1})})}:void 0},e=>{if("block"!==e.object)return;const t=e.nodes.first();if(!t)return;const n="block"===t.object?["block"]:["inline","text"],r=e.nodes.filter(e=>!n.includes(e.object));return r.size?e=>{r.forEach(t=>{e.removeNodeByKey(t.key,{normalize:!1})})}:void 0},e=>{if("inline"!==e.object)return;const t=e.nodes.filter(e=>"inline"!==e.object&&"text"!==e.object);return t.size?e=>{t.forEach(t=>{e.removeNodeByKey(t.key,{normalize:!1})})}:void 0},e=>{if(!("block"!==e.object&&"inline"!==e.object||e.nodes.size>0))return t=>{const n=Eo.create();t.insertNodeByKey(e.key,0,n,{normalize:!1})}},e=>{if("inline"!==e.object&&"block"!==e.object)return;const t=e.nodes.filter(e=>"inline"===e.object&&e.isEmpty);return t.size?n=>{if(e.nodes.size===t.size){const t=Eo.create();n.insertNodeByKey(e.key,1,t,{normalize:!1})}t.forEach(e=>{n.removeNodeByKey(e.key,{normalize:!1})})}:void 0},e=>{if("block"!==e.object&&"inline"!==e.object)return;const t=e.nodes.reduce((t,n,r)=>{if("inline"!==n.object)return t;const i=r>0?e.nodes.get(r-1):null,o=e.nodes.get(r+1),a=!i,s=!o||"inline"===o.object;return(s||a)&&(t=t.push({insertAfter:s,insertBefore:a,index:r})),t},new a.List);return t.size?n=>{let r=0;t.forEach(({index:t,insertAfter:i,insertBefore:o})=>{o&&(n.insertNodeByKey(e.key,r+t,Eo.create(),{normalize:!1}),r++),i&&(n.insertNodeByKey(e.key,r+t+1,Eo.create(),{normalize:!1}),r++)})}:void 0},e=>{if("block"!==e.object&&"inline"!==e.object)return;const t=e.nodes.map((t,n)=>{const r=e.nodes.get(n+1);if("text"===t.object&&r&&"text"===r.object)return r}).filter(Boolean);return t.size?e=>{t.reverse().forEach(t=>{e.mergeNodeByKey(t.key,{normalize:!1})})}:void 0},e=>{if("block"!==e.object&&"inline"!==e.object)return;const{nodes:t}=e;if(t.size<=1)return;const n=t.filter((e,n)=>{if("text"!==e.object)return;if(e.text.length>0)return;const r=n>0?t.get(n-1):null,i=t.get(n+1);return!(!r&&"inline"===i.object||!i&&"inline"===r.object||i&&r&&"inline"===i.object&&"inline"===r.object)||void 0});return n.size?e=>{n.forEach(t=>{e.removeNodeByKey(t.key,{normalize:!1})})}:void 0}]}),Wo=(0,o.ar)("slate:operation:apply");function Yo(e,t,n){return e.selection&&t(e.selection)&&(e=e.set("selection",n(e.selection))),e}function Jo(e,t,n,r=null){return Yo(e,e=>{if(!e.isAtomic)return!1;const{startKey:i,startOffset:o,endKey:a,endOffset:s}=e;return i===t&&on)||r&&i===t&&or)},e=>e.deselect())}const Qo={add_mark(e,t){const{path:n,offset:r,length:i,mark:o}=t;let{document:a}=e,s=a.assertPath(n);return s=s.addMark(r,i,o),a=a.updateNode(s),e=e.set("document",a)},insert_node(e,t){const{path:n,node:r}=t,i=n[n.length-1],o=n.slice(0,-1);let{document:a}=e,s=a.assertPath(o);return s=s.insertNode(i,r),a=a.updateNode(s),e=e.set("document",a)},insert_text(e,t){const{path:n,offset:r,text:i,marks:o}=t;let{document:a}=e,s=a.assertPath(n);return s=s.insertText(r,i,o),a=a.updateNode(s),e=Yo(e=Jo(e=e.set("document",a),s.key,r),({anchorKey:e,anchorOffset:t,isBackward:n,isAtomic:i})=>e===s.key&&(t>r||t===r&&(!i||!n)),e=>e.moveAnchor(i.length)),e=Yo(e,({focusKey:e,focusOffset:t,isBackward:n,isAtomic:i})=>e===s.key&&(t>r||t===r&&(!i||n)),e=>e.moveFocus(i.length))},merge_node(e,t){const{path:n}=t,r=n.slice(0,n.length-1).concat([n[n.length-1]-1]);let{document:i}=e;const o=i.assertPath(r),a=i.assertPath(n);let s=i.getParent(o.key);const c=s.getChildIndex(o.key),u=s.getChildIndex(a.key);return s=s.mergeNode(c,u),i=i.updateNode(s),e=e.set("document",i),"text"===o.object&&(e=Yo(e,({anchorKey:e,focusKey:t})=>e===a.key||t===a.key,e=>(e.anchorKey===a.key&&(e=e.moveAnchorTo(o.key,o.text.length+e.anchorOffset)),e.focusKey===a.key&&(e=e.moveFocusTo(o.key,o.text.length+e.focusOffset)),e.normalize(i)))),e},move_node(e,t){const{path:n,newPath:r}=t,i=r[r.length-1],o=r.slice(0,-1),a=n.slice(0,-1),s=n[n.length-1];let{document:c}=e;const u=c.assertPath(n);let l,d=c.getParent(u.key);return d=d.removeNode(s),c=c.updateNode(d),a.every((e,t)=>e===o[t])&&a.length===o.length?l=d:a.every((e,t)=>e===o[t])&&so.hasNode(e)||o.hasNode(t),e=>{const{startKey:t,endKey:n}=e;return o.hasNode(t)&&(e=i?e.moveStartTo(i.key,i.text.length):a?e.moveStartTo(a.key,0):e.deselect()),o.hasNode(n)&&(e=i?e.moveEndTo(i.key,i.text.length):a?e.moveEndTo(a.key,0):e.deselect()),e.isSet?e.normalize(r):e})}let a=r.getParent(o.key);const s=a.getChildIndex(o.key);return a=a.removeNode(s),r=r.updateNode(a),e=e.set("document",r)},remove_text(e,t){const{path:n,offset:r,text:i}=t,{length:o}=i,a=r+o;let{document:s}=e,c=s.assertPath(n);return e=Yo(e=Jo(e,c.key,r,r+o),({anchorKey:e})=>e===c.key,e=>e.anchorOffset>=a?e.moveAnchor(-o):e.anchorOffset>r?e.moveAnchorTo(e.anchorKey,r):e),e=Yo(e,({focusKey:e})=>e===c.key,e=>e.focusOffset>=a?e.moveFocus(-o):e.focusOffset>r?e.moveFocusTo(e.focusKey,r):e),c=c.removeText(r,o),s=s.updateNode(c),e=e.set("document",s)},set_mark(e,t){const{path:n,offset:r,length:i,mark:o,properties:a}=t;let{document:s}=e,c=s.assertPath(n);return c=c.updateMark(r,i,o,a),s=s.updateNode(c),e=e.set("document",s)},set_node(e,t){const{path:n,properties:r}=t;let{document:i}=e,o=i.assertPath(n);return o=o.merge(r),i=i.updateNode(o),e=e.set("document",i)},set_selection(e,t){const{properties:n}=t,{anchorPath:r,focusPath:i}=n,o=Mo(n,["anchorPath","focusPath"]);let{selection:a}=e;const{document:s}=e;return void 0!==r&&(o.anchorKey=null==r?null:s.assertPath(r).key),void 0!==i&&(o.focusKey=null==i?null:s.assertPath(i).key),a=(a=a.merge(o)).normalize(s),e=e.set("selection",a)},set_value(e,t){const{properties:n}=t;return e=e.merge(n)},set_value_data(e,t){const{data:n}=t;return e=e.merge({data:n})},split_node(e,t){const{path:n,position:r,properties:i}=t;let{document:o}=e;const a=o.assertPath(n);let s=o.getParent(a.key);const c=s.getChildIndex(a.key);if(s=s.splitNode(c,r),i){const e=s.nodes.get(c+1);"text"!==e.object&&(s=s.updateNode(e.merge(i)))}const u=(o=o.updateNode(s)).getNextText(a.key);return e=(e=Yo(e,({startKey:e,startOffset:t,endKey:n,endOffset:i})=>a.key===e&&r<=t||a.key===n&&r<=i,e=>{const{startKey:t,startOffset:n,endKey:i,endOffset:s}=e;let c=!1;return a.key===t&&r<=n&&(e=e.moveStartTo(u.key,n-r),c=!0),a.key===i&&r<=s&&(e=e.moveEndTo(u.key,s-r),c=!0),c?e.normalize(o):e})).set("document",o)}};function Xo(e,t){const{type:n}=t,r=Qo[n];if(!r)throw new Error(`Unknown operation type: "${n}".`);return Wo(n,t),e=r(e,t)}const Zo=(0,o.ar)("slate:change");class ea{constructor(e){const{value:t}=e;this.value=t,this.operations=new a.List,this.flags=Object.assign({normalize:!0},Hn(e,["merge","save","normalize"]))}get object(){return"change"}get kind(){return(0,o.zi)("slate@0.32.0","The `kind` property of Slate objects has been renamed to `object`."),this.object}applyOperation(e,t={}){const{operations:n,flags:r}=this;let{value:i}=this,{history:o}=i;t=Object.assign({},r,t);const{merge:a=0!==n.size||null,save:s=!0,skip:c=null}=t;return Zo("apply",{operation:e,save:s,merge:a}),i=Xo(i,e),o&&s&&(o=o.save(e,{merge:a,skip:c}),i=i.set("history",o)),this.value=i,this.operations=n.push(e),this}applyOperations(e,t){return e.forEach(e=>this.applyOperation(e,t)),this}call(e,...t){return e(this,...t),this}withoutNormalization(e){const t=this.flags.normalize;this.setOperationFlag("normalize",!1);try{e(this),this.normalizeDocument()}finally{this.setOperationFlag("normalize",t)}return this}setOperationFlag(e,t){return this.flags[e]=t,this}getFlag(e,t={}){return void 0!==t[e]?t[e]:this.flags[e]}unsetOperationFlag(e){return delete this.flags[e],this}}ea.logger=Zo,ea.isChange=oo.bind(null,"CHANGE"),ea.prototype[io.CHANGE]=!0;const ta=(0,o.ar)("slate:history"),na={redos:new a.Stack,undos:new a.Stack};class ra extends((0,a.Record)(na)){get object(){return"history"}get kind(){return(0,o.zi)("slate@0.32.0","The `kind` property of Slate objects has been renamed to `object`."),this.object}static create(e={}){if(ra.isHistory(e))return e;if(c()(e))return ra.fromJS(e);throw new Error(`\`History.create\` only accepts objects or histories, but you passed it: ${e}`)}static createOperationsList(e=[]){if(a.List.isList(e))return e;if(Array.isArray(e))return new a.List(e);throw new Error(`\`History.createList\` only accepts arrays or lists, but you passed it: ${e}`)}static fromJS(e){const{redos:t=[],undos:n=[]}=e;return new ra({redos:new a.Stack(t.map(this.createOperationsList)),undos:new a.Stack(n.map(this.createOperationsList))})}static fromJSON(e){return(0,o.zi)("slate@0.35.0","fromJSON methods are deprecated, use fromJS instead"),ra.fromJS(e)}save(e,t={}){let n=this,{undos:r,redos:i}=n,{merge:o,skip:s}=t;const c=r.peek(),u=c&&c.last();if(null==s&&(s=function(e,t){if(!t)return!1;return"set_selection"===e.type&&"set_selection"===t.type}(e,u)),s)return n;if(null==o&&(o=function(e,t){if(!t)return!1;return"set_selection"===e.type&&"set_selection"===t.type||"insert_text"===e.type&&"insert_text"===t.type&&e.offset===t.offset+t.text.length&&Qr(e.path,t.path)||"remove_text"===e.type&&"remove_text"===t.type&&e.offset+e.text.length===t.offset&&Qr(e.path,t.path)}(e,u)),ta("save",{operation:e,merge:o}),o&&c){const t=c.push(e);r=(r=r.pop()).push(t)}else{const t=new a.List([e]);r=r.push(t)}return r.size>100&&(r=r.take(100)),i=i.clear(),n=n.set("undos",r).set("redos",i)}toJS(){return{object:this.object,redos:this.redos.toJS(),undos:this.undos.toJS()}}toJSON(){return(0,o.zi)("slate@0.35.0","toJSON methods are deprecated, use toJS instead"),this.toJS()}}ra.isHistory=oo.bind(null,"HISTORY"),ra.prototype[io.HISTORY]=!0;class ia extends((0,a.Record)({data:yo.create(),document:So.create(),history:ra.create(),schema:qo.create(),selection:Fo.create()})){get object(){return"value"}get hasUndos(){return this.history.undos.size>0}get hasRedos(){return this.history.redos.size>0}get isBlurred(){return this.selection.isBlurred}get isFocused(){return this.selection.isFocused}get isCollapsed(){return this.selection.isCollapsed}get isExpanded(){return this.selection.isExpanded}get isBackward(){return this.selection.isBackward}get isForward(){return this.selection.isForward}get startKey(){return this.selection.startKey}get endKey(){return this.selection.endKey}get startOffset(){return this.selection.startOffset}get endOffset(){return this.selection.endOffset}get anchorKey(){return this.selection.anchorKey}get focusKey(){return this.selection.focusKey}get anchorOffset(){return this.selection.anchorOffset}get focusOffset(){return this.selection.focusOffset}get startBlock(){return this.startKey&&this.document.getClosestBlock(this.startKey)}get endBlock(){return this.endKey&&this.document.getClosestBlock(this.endKey)}get anchorBlock(){return this.anchorKey&&this.document.getClosestBlock(this.anchorKey)}get focusBlock(){return this.focusKey&&this.document.getClosestBlock(this.focusKey)}get startInline(){return this.startKey&&this.document.getClosestInline(this.startKey)}get endInline(){return this.endKey&&this.document.getClosestInline(this.endKey)}get anchorInline(){return this.anchorKey&&this.document.getClosestInline(this.anchorKey)}get focusInline(){return this.focusKey&&this.document.getClosestInline(this.focusKey)}get startText(){const e=this.startKey&&this.document.getDescendant(this.startKey);return e?mo(e):null}get endText(){const e=this.endKey&&this.document.getDescendant(this.endKey);return e?mo(e):null}get anchorText(){const e=this.anchorKey&&this.document.getDescendant(this.anchorKey);return e?mo(e):null}get focusText(){const e=this.focusKey&&this.document.getDescendant(this.focusKey);return e?mo(e):null}get nextBlock(){const e=this.endKey&&this.document.getNextBlock(this.endKey);return e?mo(e):null}get previousBlock(){const e=this.startKey&&this.document.getPreviousBlock(this.startKey);return e?mo(e):null}get nextText(){return this.endKey&&this.document.getNextText(this.endKey)}get previousText(){return this.startKey&&this.document.getPreviousText(this.startKey)}get marks(){return this.selection.isUnset?new a.Set:this.selection.marks||this.document.getMarksAtRange(this.selection)}get activeMarks(){return this.selection.isUnset?new a.Set:this.selection.marks||this.document.getActiveMarksAtRange(this.selection)}get blocks(){return this.selection.isUnset?new a.List:this.document.getBlocksAtRange(this.selection)}get fragment(){return this.selection.isUnset?So.create():this.document.getFragmentAtRange(this.selection)}get inlines(){return this.selection.isUnset?new a.List:this.document.getInlinesAtRange(this.selection)}get texts(){return this.selection.isUnset?new a.List:this.document.getTextsAtRange(this.selection)}get isEmpty(){return!!this.isCollapsed||(0===this.endOffset||0===this.startOffset)&&this.fragment.isEmpty}get isInVoid(){return!this.isExpanded&&this.document.hasVoidParent(this.startKey)}static create(e={},t={}){if(ia.isValue(e))return e;if(c()(e))return ia.fromJS(e,t);throw new Error(`\`Value.create\` only accepts objects or values, but you passed it: ${e}`)}static createProperties(e={}){if(ia.isValue(e))return{data:e.data,schema:e.schema};if(c()(e)){const t={};return"data"in e&&(t.data=yo.create(e.data)),"schema"in e&&(t.schema=Vo.combineWith(qo.create(e.schema))),t}throw new Error(`\`Value.createProperties\` only accepts objects or values, but you passed it: ${e}`)}static fromJS(e,t={}){let{document:n={},selection:r={},schema:i={},history:o={}}=e,s=new a.Map;n=So.fromJS(n);const{anchorPath:c,focusPath:u,anchorKey:l,focusKey:d}=r;if(void 0!==c&&void 0===l&&(r.anchorKey=n.assertPath(c).key),void 0!==u&&void 0===d&&(r.focusKey=n.assertPath(u).key),r=Fo.fromJS(r),i=qo.create(i),o=ra.fromJS(o),"data"in e&&(s=s.merge(e.data)),r.isUnset){const e=n.getFirstText();e&&(r=r.collapseToStartOf(e))}let p=new ia({data:s,document:n,selection:r,schema:Vo.combineWith(i),history:o});return!1!==t.normalize&&(p=p.change({save:!1}).normalize().value),p}static isValue(e){return!(!e||!e[io.VALUE])}change(e={}){return new ea(Object.assign({},e,{value:this}))}setSchema(e){return this.merge({schema:Vo.combineWith(e)})}toJS(e={}){const t={object:this.object,document:this.document.toJS(e)};if(e.preserveData&&(t.data=this.data.toJS()),e.preserveHistory&&(t.history=this.history.toJS()),e.preserveSelection&&(t.selection=this.selection.toJS()),e.preserveSchema&&(t.schema=this.schema.toJS()),e.preserveSelection&&!e.preserveKeys){const{document:e,selection:n}=this;t.selection.anchorPath=n.isSet?e.getPath(n.anchorKey):null,t.selection.focusPath=n.isSet?e.getPath(n.focusKey):null,delete t.selection.anchorKey,delete t.selection.focusKey}return t}}ia.prototype[io.VALUE]=!0;const oa={length:void 0,mark:void 0,marks:void 0,newPath:void 0,node:void 0,offset:void 0,path:void 0,position:void 0,properties:void 0,selection:void 0,target:void 0,text:void 0,type:void 0,value:void 0,data:void 0,previousData:void 0};class aa extends((0,a.Record)(oa)){static create(e={}){if(aa.isOperation(e))return e;if(c()(e))return aa.fromJS(e);throw new Error(`\`Operation.create\` only accepts objects or operations, but you passed it: ${e}`)}static createList(e=[]){if(a.List.isList(e)||Array.isArray(e)){return new a.List(e.map(aa.create))}throw new Error(`\`Operation.createList\` only accepts arrays or lists, but you passed it: ${e}`)}static fromJS(e){if(aa.isOperation(e))return e;const{type:t,value:n}=e,r=Bo[t],i={type:t};if(!r)throw new Error(`\`Operation.fromJS\` was passed an unrecognized operation type: "${t}"`);for(const o of r){let r=e[o];if(void 0===r){if("document"===o)continue;if("selection"===o)continue;if("value"===o)continue;if("node"===o&&"insert_node"!==t)continue;throw new Error(`\`Operation.fromJS\` was passed a "${t}" operation without the required "${o}" attribute.`)}if("mark"===o&&(r=vo.create(r)),"marks"===o&&null!=r&&(r=vo.createSet(r)),"node"===o&&(r=ko.create(r)),"selection"===o&&(r=Fo.create(r)),"value"===o&&(r=ia.create(r)),"properties"===o&&"merge_node"===t&&(r=ko.createProperties(r)),"properties"===o&&"set_mark"===t&&(r=vo.createProperties(r)),"properties"===o&&"set_node"===t&&(r=ko.createProperties(r)),"properties"===o&&"set_selection"===t){const{anchorKey:e,focusKey:t}=r,i=Mo(r,["anchorKey","focusKey"]);r=Fo.createProperties(i),void 0!==e&&(r.anchorPath=null==e?null:n.document.getPath(e)),void 0!==t&&(r.focusPath=null==t?null:n.document.getPath(t))}"data"===o&&"set_value_data"===t&&(r=yo.create(r)),"previousData"===o&&"set_value_data"===t&&(r=yo.create(r)),"properties"===o&&"split_node"===t&&(r=ko.createProperties(r)),i[o]=r}return new aa(i)}static fromJSON(e){return(0,o.zi)("slate@0.35.0","fromJSON methods are deprecated, use fromJS instead"),aa.fromJS(e)}static isOperation(e){return!(!e||!e[io.OPERATION])}static isOperationList(e){return a.List.isList(e)&&e.every(e=>aa.isOperation(e))}get object(){return"operation"}get kind(){return(0,o.zi)("slate@0.32.0","The `kind` property of Slate objects has been renamed to `object`."),this.object}toJS(e={}){const{object:t,type:n}=this,r={object:t,type:n},i=Bo[n];if("set_value"===n)throw new Error('"set_value" operation cannot be serialized as JS');for(const o of i){let e=this[o];if("document"!==o&&("selection"!==o&&"value"!==o&&("node"!==o||"insert_node"===n))){if("mark"!==o&&"marks"!==o&&"node"!==o||(e=e.toJS()),"properties"===o&&"merge_node"===n){const t={};"data"in e&&(t.data=e.data.toJS()),"type"in e&&(t.type=e.type),e=t}if("properties"===o&&"set_mark"===n){const t={};"data"in e&&(t.data=e.data.toJS()),"type"in e&&(t.type=e.type),e=t}if("properties"===o&&"set_node"===n){const t={};"data"in e&&(t.data=e.data.toJS()),"isVoid"in e&&(t.isVoid=e.isVoid),"type"in e&&(t.type=e.type),e=t}if("properties"===o&&"set_selection"===n){const t={};"anchorOffset"in e&&(t.anchorOffset=e.anchorOffset),"anchorPath"in e&&(t.anchorPath=e.anchorPath),"focusOffset"in e&&(t.focusOffset=e.focusOffset),"focusPath"in e&&(t.focusPath=e.focusPath),"isBackward"in e&&(t.isBackward=e.isBackward),"isFocused"in e&&(t.isFocused=e.isFocused),"marks"in e&&(t.marks=null==e.marks?null:e.marks.toJS()),e=t}if("data"===o&&"set_value_data"===n)return e.toJS();if("previousData"===o&&"set_value_data"===n)return e.toJS();if("properties"===o&&"split_node"===n){const t={};"data"in e&&(t.data=e.data.toJS()),"type"in e&&(t.type=e.type),e=t}r[o]=e}}return r}toJSON(e){return(0,o.zi)("slate@0.35.0","toJSON methods are deprecated, use toJS instead"),this.toJS(e)}}aa.prototype[io.OPERATION]=!0;const sa={};function ca(e,t,n,r,i={}){const{value:o}=e,{document:a}=o,s=a.getParent(n);if(!s)return;let c=s.getChildIndex(n)+r;const u=s.getChildIndex(t);c!==u&&(u>=0&&(c=u<=c?c-1:c),e.moveNodeByKey(t,s.key,c,i))}sa.addMarkByKey=(e,t,n,r,i,o={})=>{i=vo.create(i);const a=e.getFlag("normalize",o),{value:s}=e,{document:c}=s,u=c.getPath(t),l=c.getNode(t).getLeaves(),d=[],p=n,h=n+r;let f=0;if(l.forEach(e=>{const t=f,n=t+e.text.length;if(f+=e.text.length,n{const o=e.getFlag("normalize",i);r.nodes.forEach((r,i)=>{e.insertNodeByKey(t,n+i,r)}),o&&e.normalizeNodeByKey(t)},sa.insertNodeByKey=(e,t,n,r,i={})=>{const o=e.getFlag("normalize",i),{value:a}=e,{document:s}=a,c=s.getPath(t);e.applyOperation(aa.create({type:"insert_node",value:a,path:[...c,n],node:r})),o&&e.normalizeNodeByKey(t)},sa.insertTextByKey=(e,t,n,r,i,o={})=>{const a=e.getFlag("normalize",o),{value:s}=e,{document:c}=s,u=c.getPath(t),l=c.getNode(t);if(i=i||l.getMarksAtIndex(n),e.applyOperation(aa.create({type:"insert_text",value:s,path:u,offset:n,text:r,marks:i})),a){const n=c.getParent(t);e.normalizeNodeByKey(n.key)}},sa.mergeNodeByKey=(e,t,n={})=>{const r=e.getFlag("normalize",n),{value:i}=e,{document:o}=i,a=o.getPath(t),s=o.getDescendant(t),c=o.getPreviousSibling(t);if(!c)throw new Error(`Unable to merge node with key "${t}", no previous key.`);const u="text"===c.object?c.text.length:c.nodes.size;if(e.applyOperation(aa.create({type:"merge_node",value:i,path:a,position:u,properties:{type:s.type,data:s.data},target:null})),r){const n=o.getParent(t);e.normalizeNodeByKey(n.key)}},sa.moveNodeByKey=(e,t,n,r,i={})=>{const o=e.getFlag("normalize",i),{value:a}=e,{document:s}=a,c=s.getPath(t),u=s.getPath(n);if(e.applyOperation(aa.create({type:"move_node",value:a,path:c,newPath:[...u,r]})),o){const r=s.getCommonAncestor(t,n);e.normalizeNodeByKey(r.key)}},sa.moveAfterNodeByKey=(e,t,n,r={})=>{ca(e,t,n,1,r)},sa.moveBeforeNodeByKey=(e,t,n,r={})=>{ca(e,t,n,0,r)},sa.removeMarkByKey=(e,t,n,r,i,o={})=>{i=vo.create(i);const a=e.getFlag("normalize",o),{value:s}=e,{document:c}=s,u=c.getPath(t),l=c.getNode(t).getLeaves(),d=[],p=n,h=n+r;let f=0;if(l.forEach(e=>{const t=f,n=t+e.text.length;if(f+=e.text.length,n{const{value:i}=e,{document:o}=i,a=o.getNode(t),s=a.getLeaves();if(!s.size)return;const c=a.getMarksAsArray().filter(e=>!n.includes(e.type));if(!c||!c.length)return;let u=0;return s.forEach(t=>{t.marks.forEach(i=>{n.includes(i.type)||e.removeMarkByKey(a.key,u,t.text.length,i,r)}),u+=t.text.length}),e},sa.removeAllMarksByKey=(e,t,n={})=>{const{value:r}=e,{document:i}=r,o=i.getNode(t);("text"===o.object?[o]:o.getTextsAsArray()).forEach(t=>{t.getMarksAsArray().forEach(r=>{e.removeMarkByKey(t.key,0,t.text.length,r,n)})})},sa.removeDataByKey=(e,t,n)=>{const{value:r}=e,{document:i}=r,o=i.getNode(t),a={isVoid:o.isVoid,type:o.type,data:o.data.deleteAll(n)};e.setNodeByKey(o.key,a)},sa.removeNodeByKey=(e,t,n={})=>{const r=e.getFlag("normalize",n),{value:i}=e,{document:o}=i,a=o.getPath(t),s=o.getNode(t);if(e.applyOperation(aa.create({type:"remove_node",value:i,path:a,node:s})),r){const n=o.getParent(t);e.normalizeNodeByKey(n.key)}},sa.setTextByKey=(e,t,n,r,i={})=>{const o=e.value.document.getDescendant(t);e.replaceTextByKey(t,0,o.text.length,n,r,i)},sa.replaceTextByKey=(e,t,n,r,i,o,a)=>{const{document:s}=e.value,c=s.getDescendant(t);r+n>c.text.length&&(r=c.text.length-n);const u=Fo.create({anchorKey:t,focusKey:t,anchorOffset:n,focusOffset:n+r});let l=s.getActiveMarksAtRange(u);e.removeTextByKey(t,n,r,{normalize:!1}),o?l&&(l=l.filter(e=>!o.find(t=>e.type===t.type)),o=l.merge(o)):o=l||[],e.insertTextByKey(t,n,i,o,a)},sa.removeTextByKey=(e,t,n,r,i={})=>{const o=e.getFlag("normalize",i),{value:a}=e,{document:s}=a,c=s.getPath(t),u=s.getNode(t),l=u.getLeaves(),{text:d}=u,p=[],h=n,f=n+r;let m=0;if(l.forEach(e=>{const t=m,n=t+e.text.length;if(m+=e.text.length,n{n=ko.create(n);const i=e.getFlag("normalize",r),{value:o}=e,{document:a}=o,s=a.getNode(t),c=a.getParent(t),u=c.getChildIndex(s.key);e.removeNodeByKey(t,{normalize:!1}),e.insertNodeByKey(c.key,u,n,{normalize:!1}),i&&e.normalizeNodeByKey(c.key)},sa.setMarkByKey=(e,t,n,r,i,o,a={})=>{i=vo.create(i),o=vo.createProperties(o);const s=e.getFlag("normalize",a),{value:c}=e,{document:u}=c,l=u.getPath(t);if(e.applyOperation(aa.create({type:"set_mark",value:c,path:l,offset:n,length:r,mark:i,properties:o})),s){const n=u.getParent(t);e.normalizeNodeByKey(n.key)}},sa.setNodeByKey=(e,t,n,r={})=>{n=ko.createProperties(n);const i=e.getFlag("normalize",r),{value:o}=e,{document:a}=o,s=a.getPath(t),c=a.getNode(t);e.applyOperation(aa.create({type:"set_node",value:o,path:s,node:c,properties:n})),i&&e.normalizeNodeByKey(c.key)},sa.splitNodeByKey=(e,t,n,r={})=>{const{normalize:i=!0,target:o=null}=r,{value:a}=e,{document:s}=a,c=s.getPath(t),u=s.getDescendantAtPath(c);if(e.applyOperation(aa.create({type:"split_node",value:a,path:c,position:n,properties:{type:u.type,data:u.data},target:o})),i){const n=s.getParent(t);e.normalizeNodeByKey(n.key)}},sa.splitDescendantsByKey=(e,t,n,r,i={})=>{if(t===n)return void e.splitNodeByKey(n,r,i);const o=e.getFlag("normalize",i),{value:a}=e,{document:s}=a,c=s.getNode(n);let u,l;if(s.getAncestors(n).skipUntil(e=>e.key===t).reverse().unshift(c).forEach(t=>{const n=null==l?null:l;l=u?t.getChildIndex(u.key)+1:r,u=t,e.splitNodeByKey(t.key,l,{normalize:!1,target:n})}),o){const n=s.getParent(t);e.normalizeNodeByKey(n.key)}},sa.unwrapInlineByKey=(e,t,n,r)=>{const{value:i}=e,{document:o,selection:a}=i,s=o.assertDescendant(t),c=s.getFirstText(),u=s.getLastText(),l=a.moveToRangeOf(c,u);e.unwrapInlineAtRange(l,n,r)},sa.unwrapBlockByKey=(e,t,n,r)=>{const{value:i}=e,{document:o,selection:a}=i,s=o.assertDescendant(t),c=s.getFirstText(),u=s.getLastText(),l=a.moveToRangeOf(c,u);e.unwrapBlockAtRange(l,n,r)},sa.unwrapNodeByKey=(e,t,n={})=>{const r=e.getFlag("normalize",n),{value:i}=e,{document:o}=i,a=o.getParent(t),s=a.getChild(t),c=a.getChildIndex(s.key),u=0===c,l=c===a.nodes.size-1,d=o.getParent(a.key),p=d.getChildIndex(a.key);1===a.nodes.size?(e.moveNodeByKey(t,d.key,p,{normalize:!1}),e.removeNodeByKey(a.key,n)):u?e.moveNodeByKey(t,d.key,p,n):l?e.moveNodeByKey(t,d.key,p+1,n):(e.splitNodeByKey(a.key,c,{normalize:!1}),e.moveNodeByKey(t,d.key,p+1,{normalize:!1}),r&&e.normalizeNodeByKey(d.key))},sa.wrapBlockByKey=(e,t,n,r)=>{n=(n=_o.create(n)).set("nodes",n.nodes.clear());const{document:i}=e.value,o=i.assertDescendant(t),a=i.getParent(o.key),s=a.getChildIndex(o.key);e.insertNodeByKey(a.key,s,n,{normalize:!1}),e.moveNodeByKey(o.key,n.key,0,r)},sa.wrapInlineByKey=(e,t,n,r)=>{n=(n=wo.create(n)).set("nodes",n.nodes.clear());const{document:i}=e.value,o=i.assertDescendant(t),a=i.getParent(o.key),s=a.getChildIndex(o.key);e.insertNodeByKey(a.key,s,n,{normalize:!1}),e.moveNodeByKey(o.key,n.key,0,r)},sa.wrapNodeByKey=(e,t,n)=>{"block"!==(n=(n=ko.create(n)).set("nodes",n.nodes.clear())).object?"inline"!==n.object||e.wrapInlineByKey(t,n):e.wrapBlockByKey(t,n)};const ua=(0,o.ar)("slate:operation:invert");function la(e){const{type:t}=e;if(ua(t,e),"insert_node"===t){return e.set("type","remove_node")}if("remove_node"===t){return e.set("type","insert_node")}if("move_node"===t){const{newPath:t,path:n}=e;let r=t,i=n;const o=n.length-1,a=t.length-1;return n.lengthe===r[t])&&n[o]e===i[t])&&t[a]<=i[a]&&(i=i.slice(0,a).concat([i[a]+1]).concat(i.slice(a+1,i.length))),e.set("path",r).set("newPath",i)}if("merge_node"===t){const{path:t}=e,{length:n}=t,r=n-1,i=t.slice(0,r).concat([t[r]-1]);return e.set("type","split_node").set("path",i)}if("split_node"===t){const{path:t}=e,{length:n}=t,r=n-1,i=t.slice(0,r).concat([t[r]+1]);return e.set("type","merge_node").set("path",i)}if("set_node"===t){const{properties:t,node:n}=e,r=n.merge(t),i=Hn(n,Object.keys(t));return e.set("node",r).set("properties",i)}if("insert_text"===t){return e.set("type","remove_text")}if("remove_text"===t){return e.set("type","insert_text")}if("add_mark"===t){return e.set("type","remove_mark")}if("remove_mark"===t){return e.set("type","add_mark")}if("set_mark"===t){const{properties:t,mark:n}=e,r=n.merge(t),i=Hn(n,Object.keys(t));return e.set("mark",r).set("properties",i)}if("set_selection"===t){const{properties:t,selection:n,value:r}=e,{anchorPath:i,focusPath:o}=t,a=Mo(t,["anchorPath","focusPath"]),{document:s}=r;void 0!==i&&(a.anchorKey=null==i?null:s.assertPath(i).key),void 0!==o&&(a.focusKey=null==o?null:s.assertPath(o).key);const c=n.merge(a),u=Hn(n,Object.keys(a));return void 0!==i&&(u.anchorPath=null==u.anchorKey?null:s.getPath(u.anchorKey),delete u.anchorKey),void 0!==o&&(u.focusPath=null==u.focusKey?null:s.getPath(u.focusKey),delete u.focusKey),e.set("selection",c).set("properties",u)}if("set_value_data"===t){const{previousData:t,data:n}=e;return e.set("previousData",n).set("data",t)}if("set_value"===t){const{properties:t,value:n}=e,r=n.merge(t),i=Hn(n,Object.keys(t));return e.set("value",r).set("properties",i)}}const da={redo:e=>{let{value:t}=e,{history:n}=t;if(!n)return;let{undos:r,redos:i}=n;const o=i.peek();o&&(i=i.pop(),r=r.push(o),o.forEach(t=>{const{type:n,properties:r}=t;"set_selection"===n&&(t=t.set("properties",to(r,"isFocused"))),e.applyOperation(t,{save:!1})}),t=e.value,n=n.set("undos",r).set("redos",i),t=t.set("history",n),e.value=t)},undo:e=>{let{value:t}=e,{history:n}=t;if(!n)return;let{undos:r,redos:i}=n;const o=r.peek();o&&(r=r.pop(),i=i.push(o),o.slice().reverse().map(la).forEach(t=>{const{type:n,properties:r}=t;"set_selection"===n&&(t=t.set("properties",to(r,"isFocused"))),e.applyOperation(t,{save:!1})}),t=e.value,n=n.set("undos",r).set("redos",i),t=t.set("history",n),e.value=t)}},pa={select:(e,t,n={})=>{t=Fo.createProperties(t);const{snapshot:r=!1}=n,{value:i}=e,{document:o,selection:a}=i,s={},c=a.toJS(),u=a.merge(t).normalize(o);t=Hn(u,Object.keys(t));for(const d in t)!1===r&&t[d]===c[d]||(s[d]=t[d]);const l=["anchorKey","anchorOffset","focusKey","focusOffset"].some(e=>s.hasOwnProperty(e));c.marks&&t.marks===c.marks&&l&&(s.marks=null),ro()(s)||e.applyOperation(aa.create({type:"set_selection",value:i,properties:s,selection:c}),r?{skip:!1,merge:!1}:{})},selectAll:e=>{const{value:t}=e,{document:n,selection:r}=t,i=r.moveToRangeOf(n);e.select(i)},snapshotSelection:e=>{const{value:t}=e,{selection:n}=t;e.select(n,{snapshot:!0})},moveAnchorCharBackward:e=>{const{value:t}=e,{document:n,selection:r,anchorText:i,anchorBlock:o}=t,{anchorOffset:a}=r,s=n.getPreviousText(i.key),c=n.hasVoidParent(i.key),u=s&&n.hasVoidParent(s.key);!c&&a>0?e.moveAnchor(-1):s&&(e.moveAnchorToEndOf(s),c||u||!o.hasNode(s.key)||e.moveAnchor(-1))},moveAnchorCharForward:e=>{const{value:t}=e,{document:n,selection:r,anchorText:i,anchorBlock:o}=t,{anchorOffset:a}=r,s=n.getNextText(i.key),c=n.hasVoidParent(i.key),u=s&&n.hasVoidParent(s.key);!c&&a{const{value:t}=e,{document:n,selection:r,focusText:i,focusBlock:o}=t,{focusOffset:a}=r,s=n.getPreviousText(i.key),c=n.hasVoidParent(i.key),u=s&&n.hasVoidParent(s.key);!c&&a>0?e.moveFocus(-1):s&&(e.moveFocusToEndOf(s),c||u||!o.hasNode(s.key)||e.moveFocus(-1))},moveFocusCharForward:e=>{const{value:t}=e,{document:n,selection:r,focusText:i,focusBlock:o}=t,{focusOffset:a}=r,s=n.getNextText(i.key),c=n.hasVoidParent(i.key),u=s&&n.hasVoidParent(s.key);!c&&a{const t=`moveAnchorChar${e}`,n=`moveFocusChar${e}`;pa[`moveChar${e}`]=e=>{e[t]()[n]()},pa[`moveStartChar${e}`]=e=>{e.value.isBackward?e[n]():e[t]()},pa[`moveEndChar${e}`]=e=>{e.value.isBackward?e[t]():e[n]()},pa[`extendChar${e}`]=t=>{t[`moveFocusChar${e}`]()},pa[`collapseChar${e}`]=t=>{t["Forward"===e?"collapseToEnd":"collapseToStart"]()[`moveChar${e}`]()}});[["collapseLineBackward","collapseToStartOfBlock"],["collapseLineForward","collapseToEndOfBlock"],["extendLineBackward","extendToStartOfBlock"],["extendLineForward","extendToEndOfBlock"]].forEach(([e,t])=>{pa[e]=(e,...n)=>{e[t](e,...n)}});["blur","collapseTo","collapseToAnchor","collapseToEnd","collapseToEndOf","collapseToFocus","collapseToStart","collapseToStartOf","extend","extendTo","extendToEndOf","extendToStartOf","flip","focus","move","moveAnchor","moveAnchorOffsetTo","moveAnchorTo","moveAnchorToEndOf","moveAnchorToStartOf","moveEnd","moveEndOffsetTo","moveEndTo","moveFocus","moveFocusOffsetTo","moveFocusTo","moveFocusToEndOf","moveFocusToStartOf","moveOffsetsTo","moveStart","moveStartOffsetTo","moveStartTo","moveTo","moveToEnd","moveToEndOf","moveToRangeOf","moveToStart","moveToStartOf","deselect"].forEach(e=>{pa[e]=(t,...n)=>{const r="deselect"!==e,{value:i}=t,{document:o,selection:a}=i;let s=a[e](...n);r&&(s=s.normalize(o)),t.select(s)}});const ha=["Next","Previous"],fa=["Block","Inline","Text"];["moveTo","moveAnchorTo","moveFocusTo","moveStartTo","moveEndTo","collapseTo","extendTo"].forEach(e=>{const t=["Start","End"];"moveTo"===e&&t.push("Range"),t.forEach(t=>{const n=`${e}${t}Of`;fa.forEach(e=>{const t="Text"===e?"getNode":`getClosest${e}`;pa[`${n}${e}`]=e=>{const{value:r}=e,{document:i,selection:o}=r,a=i[t](o.startKey);a&&e[n](a)},ha.forEach(r=>{const i=`get${r}${e}`,o="Next"===r?"startKey":"endKey";pa[`${n}${r}${e}`]=e=>{const{value:r}=e,{document:a,selection:s}=r,c=a[t](s[o]);if(!c)return;const u=a[i](c.key);u&&e[n](u)}})})})});const ma={setValueData:(e,t,n={})=>{t=yo.create(t);const{value:r}=e;e.applyOperation(aa.create({type:"set_value_data",data:t,previousData:r.data}),n)},setValue:(e,t,n={})=>{t=ia.createProperties(t);const{value:r}=e;(0,o.zi)("slate@3.3.0","change.setValue is deprecated as it doesn't support realtime collaboration, use setValueData instead."),e.applyOperation(aa.create({type:"set_value",properties:t,value:r}),n)}},ga={};function ya(e,t,n){const r=n.validations.length+1;let i=0;!function e(t,o){const a=n.validateNode(o);if(!a)return;let s=t.value.document.getPath(o.key);if(a(t),o=t.value.document.refindNode(s,o.key)){if(s=t.value.document.refindPath(s,o.key),++i>r)throw new Error("A schema rule could not be validated after sufficient iterations. This is usually due to a `rule.validate` or `rule.normalize` function of a schema being incorrectly written, causing an infinite loop.");e(t,o)}}(e,t)}ga.normalize=e=>{e.normalizeDocument()},ga.normalizeDocument=e=>{const{value:t}=e,{document:n}=t;e.normalizeNodeByKey(n.key)},ga.normalizeNodeByKey=(e,t)=>{const{value:n}=e,{schema:r}=n;let{document:i}=n;const o=i.assertNode(t);!function e(t,n,r){if("text"===n.object)return void ya(t,n,r);let i=r.getFirstInvalidNode(n),o=t.value.document.getPath(n.key);for(;n&&i;)e(t,i,r),(n=t.value.document.refindNode(o,n.key))?(o=t.value.document.refindPath(o,n.key),i=r.getFirstInvalidNode(n)):(o=[],i=null);n&&ya(t,n,r)}(e,o,r);const a=(i=e.value.document).getAncestors(t);a&&a.forEach(t=>{e.value.document.getDescendant(t.key)&&ya(e,t,r)})};var va=Object.assign({},xo,jo,sa,da,pa,ma,ga);Object.keys(va).forEach(e=>{ea.prototype[e]=function(...t){return ea.logger(e,{args:t}),this.call(va[e],...t),this}})},82038:(e,t,n)=>{"use strict";n.d(t,{Wb:()=>i,Jg:()=>a,VH:()=>d,GV:()=>u,gB:()=>l});var r=n(67294);class i{constructor(){this.listeners=new Set}setState(e){const t="function"==typeof e?e(this.state):e;null!=t&&(this.state=Object.assign({},this.state,t),this.listeners.forEach(e=>{e()}))}subscribe(e){this.listeners.add(e)}unsubscribe(e){this.listeners.delete(e)}}const o=(0,r.createContext)(null);function a(e){const{inject:t,children:n}=e,i=(0,r.useContext)(o),a=(0,r.useMemo)(()=>{const e=new Map(i);return t&&t.forEach(t=>{e.set(t.constructor,t)}),e},[i,...t||[]]);return(0,r.createElement)(o.Provider,{value:a},n)}const s=Object.prototype.hasOwnProperty;function c(e,t){return e===t&&(0!==e||0!==t||1/e==1/t)}function u(e){const t=(0,r.useContext)(o);if(null===t)throw new Error("You must wrap your hook component with a ");return(0,r.useMemo)(()=>{let n;return"object"==typeof e&&e instanceof i?n=e:(n=t.get(e))||(n=new e,t.set(e,n)),n},[t,e])}function l(e,t){const n=u(e),i=(0,r.useState)(0)[1],o=(0,r.useRef)(null),a=(0,r.useRef)(null),l=(0,r.useRef)(!1),d=(0,r.useRef)(t);return d.current=t,(0,r.useEffect)(()=>{const e=()=>{if(!d.current)return o.current!==n.state&&(o.current=n.state,!0);const e=d.current(n),t=!function(e,t){if(c(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i in n)if(!s.call(t,i)||!c(e[i],t[i]))return!1;return!0}(a.current,e);return a.current=e,t},t=()=>{e()&&(l.current||i(e=>e+1))};return n.subscribe(t),t(),()=>{l.current=!0,n.unsubscribe(t)}},[n]),o.current=n.state,n}function d(e){const{to:t,children:n}=e;return n(l(Array.isArray(t)?t[0]:t))}},13025:(e,t,n)=>{"use strict";var r=n(67294),i=n.n(r);function o(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}function a(){return(a=Object.assign||function(e){for(var t=1;tT,fj:()=>k});var p=i().createContext(),h="__LOADABLE_REQUIRED_CHUNKS__";function f(e){return""+e+h}var m=function(e){return function(t){return i().createElement(p.Consumer,null,(function(n){return i().createElement(e,Object.assign({__chunkExtractor:n},t))}))}},g=function(e){return e};function y(e){var t=e.resolve,n=void 0===t?g:t,r=e.render,c=e.onLoad;function u(e,t){void 0===t&&(t={});var u=function(e){return"function"==typeof e?{requireAsync:e}:e}(e),d={};function p(e){return t.cacheKey?t.cacheKey(e):u.resolve?u.resolve(e):null}var h=function(e){var i,h;function f(n){var r;return(r=e.call(this,n)||this).state={result:null,error:null,loading:!0,cacheKey:p(n)},r.promise=null,l(!n.__chunkExtractor||u.requireSync,"SSR requires `@loadable/babel-plugin`, please install it"),n.__chunkExtractor?!1===t.ssr?s(r):(u.requireAsync(n).catch((function(){})),r.loadSync(),n.__chunkExtractor.addChunk(u.chunkName(n)),s(r)):(u.isReady&&u.isReady(n)&&r.loadSync(),r)}h=e,(i=f).prototype=Object.create(h.prototype),i.prototype.constructor=i,i.__proto__=h,f.getDerivedStateFromProps=function(e,t){var n=p(e);return a({},t,{cacheKey:n,loading:t.loading||t.cacheKey!==n})};var m=f.prototype;return m.componentDidMount=function(){this.mounted=!0,this.state.loading?this.loadAsync():this.state.error||this.triggerOnLoad()},m.componentDidUpdate=function(e,t){t.cacheKey!==this.state.cacheKey&&(this.promise=null,this.loadAsync())},m.componentWillUnmount=function(){this.mounted=!1},m.safeSetState=function(e,t){this.mounted&&this.setState(e,t)},m.triggerOnLoad=function(){var e=this;c&&setTimeout((function(){c(e.state.result,e.props)}))},m.loadSync=function(){if(this.state.loading)try{var e=u.requireSync(this.props),t=n(e,{Loadable:g});this.state.result=t,this.state.loading=!1}catch(r){this.state.error=r}},m.getCacheKey=function(){return p(this.props)||JSON.stringify(this.props)},m.getCache=function(){return d[this.getCacheKey()]},m.setCache=function(e){d[this.getCacheKey()]=e},m.loadAsync=function(){var e=this;if(!this.promise){var r=this.props,i=(r.__chunkExtractor,r.forwardedRef,o(r,["__chunkExtractor","forwardedRef"]));this.promise=u.requireAsync(i).then((function(r){var i=n(r,{Loadable:g});t.suspense&&e.setCache(i),e.safeSetState({result:n(r,{Loadable:g}),loading:!1},(function(){return e.triggerOnLoad()}))})).catch((function(t){e.safeSetState({error:t,loading:!1})}))}return this.promise},m.render=function(){var e=this.props,n=e.forwardedRef,i=e.fallback,s=(e.__chunkExtractor,o(e,["forwardedRef","fallback","__chunkExtractor"])),c=this.state,u=c.error,l=c.loading,d=c.result;if(t.suspense){var p=this.getCache();if(!p)throw this.loadAsync();return r({loading:!1,fallback:null,result:p,options:t,props:a({},s,{ref:n})})}if(u)throw u;var h=i||t.fallback||null;return l?h:r({loading:l,fallback:h,result:d,options:t,props:a({},s,{ref:n})})},f}(i().Component),f=m(h),g=i().forwardRef((function(e,t){return i().createElement(f,Object.assign({forwardedRef:t},e))}));return g.preload=function(e){u.requireAsync(e)},g.load=function(e){return u.requireAsync(e)},g}return{loadable:u,lazy:function(e,t){return u(e,a({},t,{suspense:!0}))}}}var v=y({resolve:function(e,t){var n=t.Loadable,r=e.__esModule?e.default:e.default||e;return u()(n,r,{preload:!0}),r},render:function(e){var t=e.result,n=e.props;return i().createElement(t,n)}}),b=v.loadable,E=v.lazy,w=y({onLoad:function(e,t){e&&t.forwardedRef&&("function"==typeof t.forwardedRef?t.forwardedRef(e):t.forwardedRef.current=e)},render:function(e){var t=e.result,n=e.loading,r=e.props;return!n&&r.children?r.children(t):null}}),_=w.loadable,x=w.lazy,S="undefined"!=typeof window;function k(e,t){void 0===e&&(e=function(){});var n=(void 0===t?{}:t).namespace,r=void 0===n?"":n;if(!S)return d("`loadableReady()` must be called in browser only"),e(),Promise.resolve();var i=null;if(S){var o=document.getElementById(f(r));o&&(i=JSON.parse(o.textContent))}if(!i)return d("`loadableReady()` requires state, please use `getScriptTags` or `getScriptElements` server-side"),e(),Promise.resolve();var a=!1;return new Promise((function(t){window.__LOADABLE_LOADED_CHUNKS__=window.__LOADABLE_LOADED_CHUNKS__||[];var n=window.__LOADABLE_LOADED_CHUNKS__,r=n.push.bind(n);function o(){i.every((function(e){return n.some((function(t){return t[0].indexOf(e)>-1}))}))&&(a||(a=!0,t(),e()))}n.push=function(){r.apply(void 0,arguments),o()},o()}))}var O=b;O.lib=_,E.lib=x;const T=O},84773:(e,t,n)=>{"use strict";n.d(t,{k:()=>s,C:()=>c});var r=n(67597),i=n(62844),o=n(61130),a=n(97873);function s(e,t,n){var s;if(void 0===n&&(n={}),(0,r.hE)(e)&&e.error)return e=e.error,s=(0,o.jn)((0,a.i)(e));if((0,r.Bo)(e)||(0,r.TS)(e)){var u=e,l=u.name||((0,r.Bo)(u)?"DOMError":"DOMException"),d=u.message?l+": "+u.message:l;return s=c(d,t,n),(0,i.FT)(s,d),s}if((0,r.X)(e))return s=(0,o.jn)((0,a.i)(e));if((0,r.jG)(e)||(0,r.MJ)(e)){var p=e;return s=(0,o.MS)(p,t,n.rejection),(0,i.wU)(s,{synthetic:!0}),s}return s=c(e,t,n),(0,i.FT)(s,""+e,void 0),(0,i.wU)(s,{synthetic:!0}),s}function c(e,t,n){void 0===n&&(n={});var r={message:e};if(n.attachStacktrace&&t){var i=(0,a.i)(t),s=(0,o.Xc)(i.stack);r.stacktrace={frames:s}}return r}},86891:(e,t,n)=>{"use strict";n.d(t,{MS:()=>p,nN:()=>f,xx:()=>g,jl:()=>y});var r,i,o=n(70655),a=n(39666),s=n(38641),c=n(62844),u=n(71336),l=1e3,d=0;function p(){return d>0}function h(){d+=1,setTimeout((function(){d-=1}))}function f(e,t,n){if(void 0===t&&(t={}),"function"!=typeof e)return e;try{if(e.__sentry__)return e;if(e.__sentry_wrapped__)return e.__sentry_wrapped__}catch(s){return e}var r=function(){n&&"function"==typeof n&&n.apply(this,arguments);var r=Array.prototype.slice.call(arguments);try{var i=r.map((function(e){return f(e,t)}));return e.handleEvent?e.handleEvent.apply(this,i):e.apply(this,i)}catch(s){throw h(),(0,a.vs)((function(e){e.addEventProcessor((function(e){var n=o.__assign({},e);return t.mechanism&&((0,c.FT)(n,void 0,void 0),(0,c.wU)(n,t.mechanism)),n.extra=o.__assign({},n.extra,{arguments:(0,u.normalize)(r,3)}),n})),(0,a.Ro)(s)})),s}};try{for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}catch(l){}e.prototype=e.prototype||{},r.prototype=e.prototype,Object.defineProperty(e,"__sentry_wrapped__",{enumerable:!1,value:r}),Object.defineProperties(r,{__sentry__:{enumerable:!1,value:!0},__sentry_original__:{enumerable:!1,value:e}});try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get:function(){return e.name}})}catch(l){}return r}var m=0;function g(e,t){return void 0===t&&(t=!1),function(n){if(r=void 0,n&&i!==n){i=n;var o=function(){var t;try{t=n.target?(0,c.rl)(n.target):(0,c.rl)(n)}catch(r){t=""}0!==t.length&&(0,s.c)().addBreadcrumb({category:"ui."+e,message:t},{event:n,name:e})};m&&clearTimeout(m),t?m=setTimeout(o):o()}}}function y(){return function(e){var t;try{t=e.target}catch(i){return}var n=t&&t.tagName;n&&("INPUT"===n||"TEXTAREA"===n||t.isContentEditable)&&(r||g("input")(e),clearTimeout(r),r=setTimeout((function(){r=void 0}),l))}}},90564:(e,t,n)=>{"use strict";n.d(t,{w:()=>g});var r,i=n(70655),o=n(38641),a=n(1984),s=n(13819),c=n(62844),u=n(71336),l=n(57321),d=n(8823),p=n(67597),h=n(12343),f=n(86891),m=(0,c.DB)(),g=function(){function e(t){this.name=e.id,this._options=i.__assign({console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0},t)}return e.prototype._instrumentConsole=function(){"console"in m&&["debug","info","warn","error","log","assert"].forEach((function(t){t in m.console&&(0,u.fill)(m.console,t,(function(n){return function(){for(var r=[],i=0;i2?t[2]:void 0;return o&&n(r,String(o)),e.apply(this,t)}}},e.prototype._instrumentXHR=function(){if("XMLHttpRequest"in m){var t=XMLHttpRequest.prototype;(0,u.fill)(t,"open",(function(e){return function(){for(var t=[],n=0;n"},handled:!0,type:"instrument"}},a)})):o.onreadystatechange=a,t.apply(this,r)}}))}function n(e,t){e in t&&"function"==typeof t[e]&&(0,u.fill)(t,e,(function(t){return(0,f.nN)(t,{mechanism:{data:{function:e,handler:t&&t.name||""},handled:!0,type:"instrument"}})}))}},e.addBreadcrumb=function(t,n){(0,o.c)().getIntegration(e)&&(0,o.c)().addBreadcrumb(t,n)},e.prototype.setupOnce=function(){this._options.console&&this._instrumentConsole(),this._options.dom&&this._instrumentDOM(),this._options.xhr&&this._instrumentXHR(),this._options.fetch&&this._instrumentFetch(),this._options.history&&this._instrumentHistory()},e.id="Breadcrumbs",e}();function y(e){try{var t=JSON.parse(e);g.addBreadcrumb({category:"sentry",event_id:t.event_id,level:t.level||s.t.fromString("error"),message:(0,c.tt)(t)},{event:t})}catch(n){h.o.error("Error while adding sentry type breadcrumb")}}},52136:(e,t,n)=>{"use strict";n.d(t,{v:()=>d});var r=n(70655),i=n(38641),o=n(13819),a=n(62844),s=n(12343),c=n(67597),u=n(84773),l=n(86891),d=function(){function e(t){this.name=e.id,this._global=(0,a.DB)(),this._oldOnErrorHandler=null,this._oldOnUnhandledRejectionHandler=null,this._onErrorHandlerInstalled=!1,this._onUnhandledRejectionHandlerInstalled=!1,this._options=r.__assign({onerror:!0,onunhandledrejection:!0},t)}return e.prototype.setupOnce=function(){Error.stackTraceLimit=50,this._options.onerror&&(s.o.log("Global Handler attached: onerror"),this._installGlobalOnErrorHandler()),this._options.onunhandledrejection&&(s.o.log("Global Handler attached: onunhandledrejection"),this._installGlobalOnUnhandledRejectionHandler())},e.prototype._installGlobalOnErrorHandler=function(){if(!this._onErrorHandlerInstalled){var t=this;this._oldOnErrorHandler=this._global.onerror,this._global.onerror=function(n,r,o,s,d){var p=(0,i.c)(),h=p.getIntegration(e),f=d&&!0===d.__sentry_own_request__;if(!h||(0,l.MS)()||f)return!!t._oldOnErrorHandler&&t._oldOnErrorHandler.apply(this,arguments);var m=p.getClient(),g=(0,c.PQ)(d)?t._eventFromIncompleteOnError(n,r,o,s):t._enhanceEventWithInitialFrame((0,u.k)(d,void 0,{attachStacktrace:m&&m.getOptions().attachStacktrace,rejection:!1}),r,o,s);return(0,a.wU)(g,{handled:!1,type:"onerror"}),p.captureEvent(g,{originalException:d}),!!t._oldOnErrorHandler&&t._oldOnErrorHandler.apply(this,arguments)},this._onErrorHandlerInstalled=!0}},e.prototype._installGlobalOnUnhandledRejectionHandler=function(){if(!this._onUnhandledRejectionHandlerInstalled){var t=this;this._oldOnUnhandledRejectionHandler=this._global.onunhandledrejection,this._global.onunhandledrejection=function(n){var r=n;try{r=n&&"reason"in n?n.reason:n}catch(m){}var s=(0,i.c)(),d=s.getIntegration(e),p=r&&!0===r.__sentry_own_request__;if(!d||(0,l.MS)()||p)return!!t._oldOnUnhandledRejectionHandler&&t._oldOnUnhandledRejectionHandler.apply(this,arguments);var h=s.getClient(),f=(0,c.PQ)(r)?t._eventFromIncompleteRejection(r):(0,u.k)(r,void 0,{attachStacktrace:h&&h.getOptions().attachStacktrace,rejection:!0});return f.level=o.t.Error,(0,a.wU)(f,{handled:!1,type:"onunhandledrejection"}),s.captureEvent(f,{originalException:r}),!!t._oldOnUnhandledRejectionHandler&&t._oldOnUnhandledRejectionHandler.apply(this,arguments)},this._onUnhandledRejectionHandlerInstalled=!0}},e.prototype._eventFromIncompleteOnError=function(e,t,n,r){var i,o=(0,c.hE)(e)?e.message:e;if((0,c.Bj)(o)){var a=o.match(/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i);a&&(i=a[1],o=a[2])}var s={exception:{values:[{type:i||"Error",value:o}]}};return this._enhanceEventWithInitialFrame(s,t,n,r)},e.prototype._eventFromIncompleteRejection=function(e){return{exception:{values:[{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+e}]}}},e.prototype._enhanceEventWithInitialFrame=function(e,t,n,r){e.exception=e.exception||{},e.exception.values=e.exception.values||[],e.exception.values[0]=e.exception.values[0]||{},e.exception.values[0].stacktrace=e.exception.values[0].stacktrace||{},e.exception.values[0].stacktrace.frames=e.exception.values[0].stacktrace.frames||[];var i=isNaN(parseInt(r,10))?void 0:r,o=isNaN(parseInt(n,10))?void 0:n,s=(0,c.Bj)(t)&&t.length>0?t:(0,a.xj)();return 0===e.exception.values[0].stacktrace.frames.length&&e.exception.values[0].stacktrace.frames.push({colno:i,filename:s,function:"?",in_app:!0,lineno:o}),e},e.id="GlobalHandlers",e}()},61634:(e,t,n)=>{"use strict";n.d(t,{m:()=>l});var r=n(70655),i=n(37506),o=n(38641),a=n(61130),s=n(97873),c="cause",u=5,l=function(){function e(t){void 0===t&&(t={}),this.name=e.id,this._key=t.key||c,this._limit=t.limit||u}return e.prototype.setupOnce=function(){(0,i.s)((function(t,n){var r=(0,o.c)().getIntegration(e);return r?r._handler(t,n):t}))},e.prototype._handler=function(e,t){if(!(e.exception&&e.exception.values&&t&&t.originalException instanceof Error))return e;var n=this._walkErrorTree(t.originalException,this._key);return e.exception.values=r.__spread(n,e.exception.values),e},e.prototype._walkErrorTree=function(e,t,n){if(void 0===n&&(n=[]),!(e[t]instanceof Error)||n.length+1>=this._limit)return n;var i=(0,s.i)(e[t]),o=(0,a.Wg)(i);return this._walkErrorTree(e[t],t,r.__spread([o],n))},e.id="LinkedErrors",e}()},53692:(e,t,n)=>{"use strict";n.d(t,{x:()=>a});var r=n(62844),i=n(71336),o=n(86891),a=function(){function e(){this._ignoreOnError=0,this.name=e.id}return e.prototype._wrapTimeFunction=function(e){return function(){for(var t=[],n=0;n"}catch(t){return""}}},33931:(e,t,n)=>{"use strict";n.d(t,{j:()=>s});var r=n(70655),i=n(37506),o=n(38641),a=(0,n(62844).DB)(),s=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(){(0,i.s)((function(t){if((0,o.c)().getIntegration(e)){if(!a.navigator||!a.location)return t;var n=t.request||{};return n.url=n.url||a.location.href,n.headers=n.headers||{},n.headers["User-Agent"]=a.navigator.userAgent,r.__assign({},t,{request:n})}return t}))},e.id="UserAgent",e}()},61130:(e,t,n)=>{"use strict";n.d(t,{Wg:()=>s,MS:()=>c,jn:()=>u,Xc:()=>l});var r=n(67597),i=n(71336),o=n(97873),a=50;function s(e){var t=l(e.stack),n={type:e.name,value:e.message};return t&&t.length&&(n.stacktrace={frames:t}),void 0===n.type&&""===n.value&&(n.value="Unrecoverable error caught"),n}function c(e,t,n){var a={exception:{values:[{type:(0,r.MJ)(e)?e.constructor.name:n?"UnhandledRejection":"Error",value:"Non-Error "+(n?"promise rejection":"exception")+" captured with keys: "+(0,i.extractExceptionKeysForMessage)(e)}]},extra:{__serialized__:(0,i.normalizeToSize)(e)}};if(t){var s=l((0,o.i)(t).stack);a.stacktrace={frames:s}}return a}function u(e){return{exception:{values:[s(e)]}}}function l(e){if(!e||!e.length)return[];var t=e,n=t[0].func||"",r=t[t.length-1].func||"";return-1===n.indexOf("captureMessage")&&-1===n.indexOf("captureException")||(t=t.slice(1)),-1!==r.indexOf("sentryWrapped")&&(t=t.slice(0,-1)),t.map((function(e){return{colno:null===e.column?void 0:e.column,filename:e.url||t[0].url,function:e.func||"?",in_app:!0,lineno:null===e.line?void 0:e.line}})).slice(0,a).reverse()}},26967:(e,t,n)=>{"use strict";var r=n(6869),i=n(38641),o=n(12343);var a=n(62844),s=n(70655),c=n(1984),u=n(67597),l=n(96893),d=n(57321),p=n(9873),h=n(37506),f=[];function m(e){var t={};return function(e){var t=e.defaultIntegrations&&s.__spread(e.defaultIntegrations)||[],n=e.integrations,r=[];if(Array.isArray(n)){var i=n.map((function(e){return e.name})),o=[];t.forEach((function(e){-1===i.indexOf(e.name)&&-1===o.indexOf(e.name)&&(r.push(e),o.push(e.name))})),n.forEach((function(e){-1===o.indexOf(e.name)&&(r.push(e),o.push(e.name))}))}else"function"==typeof n?(r=n(t),r=Array.isArray(r)?r:[r]):r=s.__spread(t);var a=r.map((function(e){return e.name}));return-1!==a.indexOf("Debug")&&r.push.apply(r,s.__spread(r.splice(a.indexOf("Debug"),1))),r}(e).forEach((function(e){t[e.name]=e,function(e){-1===f.indexOf(e.name)&&(e.setupOnce(h.s,i.c),f.push(e.name),o.o.log("Integration installed: "+e.name))}(e)})),t}var g,y=function(){function e(e,t){this._integrations={},this._processing=!1,this._backend=new e(t),this._options=t,t.dsn&&(this._dsn=new p.z(t.dsn)),this._isEnabled()&&(this._integrations=m(this._options))}return e.prototype.captureException=function(e,t,n){var r=this,i=t&&t.event_id;return this._processing=!0,this._getBackend().eventFromException(e,t).then((function(e){return r._processEvent(e,t,n)})).then((function(e){i=e&&e.event_id,r._processing=!1})).then(null,(function(e){o.o.error(e),r._processing=!1})),i},e.prototype.captureMessage=function(e,t,n,r){var i=this,a=n&&n.event_id;return this._processing=!0,((0,u.PQ)(e)?this._getBackend().eventFromMessage(""+e,t,n):this._getBackend().eventFromException(e,n)).then((function(e){return i._processEvent(e,n,r)})).then((function(e){a=e&&e.event_id,i._processing=!1})).then(null,(function(e){o.o.error(e),i._processing=!1})),a},e.prototype.captureEvent=function(e,t,n){var r=this,i=t&&t.event_id;return this._processing=!0,this._processEvent(e,t,n).then((function(e){i=e&&e.event_id,r._processing=!1})).then(null,(function(e){o.o.error(e),r._processing=!1})),i},e.prototype.getDsn=function(){return this._dsn},e.prototype.getOptions=function(){return this._options},e.prototype.flush=function(e){var t=this;return this._isClientProcessing(e).then((function(n){return clearInterval(n.interval),t._getBackend().getTransport().close(e).then((function(e){return n.ready&&e}))}))},e.prototype.close=function(e){var t=this;return this.flush(e).then((function(e){return t.getOptions().enabled=!1,e}))},e.prototype.getIntegrations=function(){return this._integrations||{}},e.prototype.getIntegration=function(e){try{return this._integrations[e.id]||null}catch(t){return o.o.warn("Cannot retrieve integration "+e.id+" from the current Client"),null}},e.prototype._isClientProcessing=function(e){var t=this;return new l.s((function(n){var r=0,i=0;clearInterval(i),i=setInterval((function(){t._processing?(r+=1,e&&r>=e&&n({interval:i,ready:!1})):n({interval:i,ready:!0})}),1)}))},e.prototype._getBackend=function(){return this._backend},e.prototype._isEnabled=function(){return!1!==this.getOptions().enabled&&void 0!==this._dsn},e.prototype._prepareEvent=function(e,t,n){var r=this.getOptions(),i=r.environment,o=r.release,c=r.dist,u=r.maxValueLength,p=void 0===u?250:u,h=s.__assign({},e);void 0===h.environment&&void 0!==i&&(h.environment=i),void 0===h.release&&void 0!==o&&(h.release=o),void 0===h.dist&&void 0!==c&&(h.dist=c),h.message&&(h.message=(0,d.DE)(h.message,p));var f=h.exception&&h.exception.values&&h.exception.values[0];f&&f.value&&(f.value=(0,d.DE)(f.value,p));var m=h.request;m&&m.url&&(m.url=(0,d.DE)(m.url,p)),void 0===h.event_id&&(h.event_id=(0,a.DP)()),this._addIntegrations(h.sdk);var g=l.s.resolve(h);return t&&(g=t.applyToEvent(h,n)),g},e.prototype._addIntegrations=function(e){var t=Object.keys(this._integrations);e&&t.length>0&&(e.integrations=t)},e.prototype._processEvent=function(e,t,n){var r=this,i=this.getOptions(),a=i.beforeSend,s=i.sampleRate;return this._isEnabled()?"number"==typeof s&&Math.random()>s?l.s.reject("This event has been sampled, will not send event."):new l.s((function(i,s){r._prepareEvent(e,n,t).then((function(e){if(null!==e){var n=e;try{if(t&&t.data&&!0===t.data.__sentry__||!a)return r._getBackend().sendEvent(n),void i(n);var c=a(e,t);if(void 0===c)o.o.error("`beforeSend` method has to return `null` or a valid event.");else if((0,u.Vh)(c))r._handleAsyncBeforeSend(c,i,s);else{if(null===(n=c))return o.o.log("`beforeSend` returned `null`, will not send event."),void i(null);r._getBackend().sendEvent(n),i(n)}}catch(l){r.captureException(l,{data:{__sentry__:!0},originalException:l}),s("`beforeSend` threw an error, will not send event.")}}else s("An event processor returned null, will not send event.")})).then(null,(function(){s("`beforeSend` threw an error, will not send event.")}))})):l.s.reject("SDK not enabled, will not send event.")},e.prototype._handleAsyncBeforeSend=function(e,t,n){var r=this;e.then((function(e){null!==e?(r._getBackend().sendEvent(e),t(e)):n("`beforeSend` returned `null`, will not send event.")})).then(null,(function(e){n("beforeSend rejected with "+e)}))},e}(),v=n(21620);!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.Invalid="invalid",e.Failed="failed"}(g||(g={})),function(e){e.fromHttpCode=function(t){return t>=200&&t<300?e.Success:429===t?e.RateLimit:t>=400&&t<500?e.Invalid:t>=500?e.Failed:e.Unknown}}(g||(g={}));var b=function(){function e(){}return e.prototype.sendEvent=function(e){return l.s.resolve({reason:"NoopTransport: Event has been skipped because no Dsn is configured.",status:g.Skipped})},e.prototype.close=function(e){return l.s.resolve(!0)},e}(),E=function(){function e(e){this._options=e,this._options.dsn||o.o.warn("No DSN provided, backend will not do anything."),this._transport=this._setupTransport()}return e.prototype._setupTransport=function(){return new b},e.prototype.eventFromException=function(e,t){throw new v.v("Backend has to implement `eventFromException` method")},e.prototype.eventFromMessage=function(e,t,n){throw new v.v("Backend has to implement `eventFromMessage` method")},e.prototype.sendEvent=function(e){this._transport.sendEvent(e).then(null,(function(e){o.o.error("Error while sending event: "+e)}))},e.prototype.getTransport=function(){return this._transport},e}(),w=n(13819),_=n(8823),x=n(84773),S=function(){function e(e){this._limit=e,this._buffer=[]}return e.prototype.isReady=function(){return void 0===this._limit||this.length()0&&n(!1)}),e);l.s.all(t._buffer).then((function(){clearTimeout(r),n(!0)})).then(null,(function(){n(!0)}))}))},e}(),k=function(){function e(e){this.options=e,this._buffer=new S(30),this.url=new c.v(this.options.dsn).getStoreEndpointWithUrlEncodedAuth()}return e.prototype.sendEvent=function(e){throw new v.v("Transport Class has to implement `sendEvent` method")},e.prototype.close=function(e){return this._buffer.drain(e)},e}(),O=(0,a.DB)(),T=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._disabledUntil=new Date(Date.now()),t}return s.__extends(t,e),t.prototype.sendEvent=function(e){var t=this;if(new Date(Date.now())M,Bc:()=>B,Cw:()=>F});var j=[new r.TL.InboundFilters,new r.TL.FunctionToString,new C.x,new P.w,new R.v,new N.m,new L.j];function M(e){if(void 0===e&&(e={}),void 0===e.defaultIntegrations&&(e.defaultIntegrations=j),void 0===e.release){var t=(0,a.DB)();t.SENTRY_RELEASE&&t.SENTRY_RELEASE.id&&(e.release=t.SENTRY_RELEASE.id)}!function(e,t){!0===t.debug&&o.o.enable(),(0,i.c)().bindClient(new e(t))}(D,e)}function B(e){void 0===e&&(e={}),e.eventId||(e.eventId=(0,i.c)().lastEventId());var t=(0,i.c)().getClient();t&&t.showReportDialog(e)}function F(){return(0,i.c)().lastEventId()}},97873:(e,t,n)=>{"use strict";n.d(t,{i:()=>l});var r=n(70655),i="?",o=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|native|eval|webpack||[-a-z]+:|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,a=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i,s=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,c=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,u=/\((\S*)(?::(\d+))(?::(\d+))\)/;function l(e){var t=null,n=e&&e.framesToPop;try{if(t=function(e){if(!e||!e.stacktrace)return null;for(var t,n=e.stacktrace,r=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,o=/ line (\d+), column (\d+)\s*(?:in (?:]+)>|([^\)]+))\((.*)\))? in (.*):\s*$/i,a=n.split("\n"),s=[],c=0;c eval")>-1&&(t=c.exec(n[3]))?(n[1]=n[1]||"eval",n[3]=t[1],n[4]=t[2],n[5]=""):0!==h||n[5]||void 0===e.columnNumber||(l[0].column=e.columnNumber+1),r={url:n[3],func:n[1]||i,args:n[2]?n[2].split(","):[],line:n[4]?+n[4]:null,column:n[5]?+n[5]:null}}!r.func&&r.line&&(r.func=i),l.push(r)}if(!l.length)return null;return{message:p(e),name:e.name,stack:l}}(e))return d(t,n)}catch(r){}return{message:p(e),name:e&&e.name,stack:[],failed:!0}}function d(e,t){try{return r.__assign({},e,{stack:e.stack.slice(t)})}catch(n){return e}}function p(e){var t=e&&e.message;return t?t.error&&"string"==typeof t.error.message?t.error.message:t:"No error message"}},1984:(e,t,n)=>{"use strict";n.d(t,{v:()=>o});var r=n(71336),i=n(9873),o=function(){function e(e){this.dsn=e,this._dsnObject=new i.z(e)}return e.prototype.getDsn=function(){return this._dsnObject},e.prototype.getStoreEndpoint=function(){return""+this._getBaseUrl()+this.getStoreEndpointPath()},e.prototype.getStoreEndpointWithUrlEncodedAuth=function(){var e={sentry_key:this._dsnObject.user,sentry_version:"7"};return this.getStoreEndpoint()+"?"+(0,r.urlEncode)(e)},e.prototype._getBaseUrl=function(){var e=this._dsnObject,t=e.protocol?e.protocol+":":"",n=e.port?":"+e.port:"";return t+"//"+e.host+n},e.prototype.getStoreEndpointPath=function(){var e=this._dsnObject;return(e.path?"/"+e.path:"")+"/api/"+e.projectId+"/store/"},e.prototype.getRequestHeaders=function(e,t){var n=this._dsnObject,r=["Sentry sentry_version=7"];return r.push("sentry_timestamp="+(new Date).getTime()),r.push("sentry_client="+e+"/"+t),r.push("sentry_key="+n.user),n.pass&&r.push("sentry_secret="+n.pass),{"Content-Type":"application/json","X-Sentry-Auth":r.join(", ")}},e.prototype.getReportDialogEndpoint=function(e){void 0===e&&(e={});var t=this._dsnObject,n=this._getBaseUrl()+(t.path?"/"+t.path:"")+"/api/embed/error-page/",r=[];for(var i in r.push("dsn="+t.toString()),e)if("user"===i){if(!e.user)continue;e.user.name&&r.push("name="+encodeURIComponent(e.user.name)),e.user.email&&r.push("email="+encodeURIComponent(e.user.email))}else r.push(encodeURIComponent(i)+"="+encodeURIComponent(e[i]));return r.length?n+"?"+r.join("&"):n},e}()},9873:(e,t,n)=>{"use strict";n.d(t,{z:()=>a});var r=n(70655),i=n(21620),o=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w\.-]+)(?::(\d+))?\/(.+)/,a=function(){function e(e){"string"==typeof e?this._fromString(e):this._fromComponents(e),this._validate()}return e.prototype.toString=function(e){void 0===e&&(e=!1);var t=this,n=t.host,r=t.path,i=t.pass,o=t.port,a=t.projectId;return t.protocol+"://"+t.user+(e&&i?":"+i:"")+"@"+n+(o?":"+o:"")+"/"+(r?r+"/":r)+a},e.prototype._fromString=function(e){var t=o.exec(e);if(!t)throw new i.v("Invalid Dsn");var n=r.__read(t.slice(1),6),a=n[0],s=n[1],c=n[2],u=void 0===c?"":c,l=n[3],d=n[4],p=void 0===d?"":d,h="",f=n[5],m=f.split("/");m.length>1&&(h=m.slice(0,-1).join("/"),f=m.pop()),this._fromComponents({host:l,pass:u,path:h,projectId:f,port:p,protocol:a,user:s})},e.prototype._fromComponents=function(e){this.protocol=e.protocol,this.user=e.user,this.pass=e.pass||"",this.host=e.host,this.port=e.port||"",this.path=e.path||"",this.projectId=e.projectId},e.prototype._validate=function(){var e=this;if(["protocol","user","host","projectId"].forEach((function(t){if(!e[t])throw new i.v("Invalid Dsn")})),"http"!==this.protocol&&"https"!==this.protocol)throw new i.v("Invalid Dsn");if(this.port&&isNaN(parseInt(this.port,10)))throw new i.v("Invalid Dsn")},e}()},6869:(e,t,n)=>{"use strict";var r,i={};n.r(i),n.d(i,{FunctionToString:()=>o,InboundFilters:()=>h});var o=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(){r=Function.prototype.toString,Function.prototype.toString=function(){for(var e=[],t=0;ti})},38641:(e,t,n)=>{"use strict";n.d(t,{c:()=>d});var r=n(70655),i=n(62844),o=n(12343),a=n(37506);e=n.hmd(e);var s=3,c=function(){function e(e,t,n){void 0===t&&(t=new a.i),void 0===n&&(n=s),this._version=n,this._stack=[],this._stack.push({client:e,scope:t})}return e.prototype._invokeClient=function(e){for(var t,n=[],i=1;i0?e[e.length-1].scope:void 0,n=a.i.clone(t);return this.getStack().push({client:this.getClient(),scope:n}),n},e.prototype.popScope=function(){return void 0!==this.getStack().pop()},e.prototype.withScope=function(e){var t=this.pushScope();try{e(t)}finally{this.popScope()}},e.prototype.getClient=function(){return this.getStackTop().client},e.prototype.getScope=function(){return this.getStackTop().scope},e.prototype.getStack=function(){return this._stack},e.prototype.getStackTop=function(){return this._stack[this._stack.length-1]},e.prototype.captureException=function(e,t){var n=this._lastEventId=(0,i.DP)(),o=t;if(!t){var a=void 0;try{throw new Error("Sentry syntheticException")}catch(e){a=e}o={originalException:e,syntheticException:a}}return this._invokeClient("captureException",e,r.__assign({},o,{event_id:n})),n},e.prototype.captureMessage=function(e,t,n){var o=this._lastEventId=(0,i.DP)(),a=n;if(!n){var s=void 0;try{throw new Error(e)}catch(c){s=c}a={originalException:e,syntheticException:s}}return this._invokeClient("captureMessage",e,t,r.__assign({},a,{event_id:o})),o},e.prototype.captureEvent=function(e,t){var n=this._lastEventId=(0,i.DP)();return this._invokeClient("captureEvent",e,r.__assign({},t,{event_id:n})),n},e.prototype.lastEventId=function(){return this._lastEventId},e.prototype.addBreadcrumb=function(e,t){var n=this.getStackTop();if(n.scope&&n.client){var o=n.client.getOptions&&n.client.getOptions()||{},a=o.beforeBreadcrumb,s=void 0===a?null:a,c=o.maxBreadcrumbs,u=void 0===c?30:c;if(!(u<=0)){var l=(new Date).getTime()/1e3,d=r.__assign({timestamp:l},e),p=s?(0,i.Ep)((function(){return s(d,t)})):d;null!==p&&n.scope.addBreadcrumb(p,Math.min(u,100))}}},e.prototype.setUser=function(e){var t=this.getStackTop();t.scope&&t.scope.setUser(e)},e.prototype.setTags=function(e){var t=this.getStackTop();t.scope&&t.scope.setTags(e)},e.prototype.setExtras=function(e){var t=this.getStackTop();t.scope&&t.scope.setExtras(e)},e.prototype.setTag=function(e,t){var n=this.getStackTop();n.scope&&n.scope.setTag(e,t)},e.prototype.setExtra=function(e,t){var n=this.getStackTop();n.scope&&n.scope.setExtra(e,t)},e.prototype.setContext=function(e,t){var n=this.getStackTop();n.scope&&n.scope.setContext(e,t)},e.prototype.configureScope=function(e){var t=this.getStackTop();t.scope&&t.client&&e(t.scope)},e.prototype.run=function(e){var t=l(this);try{e(this)}finally{l(t)}},e.prototype.getIntegration=function(e){var t=this.getClient();if(!t)return null;try{return t.getIntegration(e)}catch(n){return o.o.warn("Cannot retrieve integration "+e.id+" from the current Hub"),null}},e.prototype.traceHeaders=function(){var e=this.getStackTop();if(e.scope&&e.client){var t=e.scope.getSpan();if(t)return{"sentry-trace":t.toTraceparent()}}return{}},e}();function u(){var e=(0,i.DB)();return e.__SENTRY__=e.__SENTRY__||{hub:void 0},e}function l(e){var t=u(),n=h(t);return f(t,e),n}function d(){var t=u();return p(t)&&!h(t).isOlderThan(s)||f(t,new c),(0,i.AH)()?function(t){try{var n=(0,i.Pl)(e,"domain").active;if(!n)return h(t);if(!p(n)||h(n).isOlderThan(s)){var r=h(t).getStackTop();f(n,new c(r.client,a.i.clone(r.scope)))}return h(n)}catch(o){return h(t)}}(t):h(t)}function p(e){return!!(e&&e.__SENTRY__&&e.__SENTRY__.hub)}function h(e){return e&&e.__SENTRY__&&e.__SENTRY__.hub?e.__SENTRY__.hub:(e.__SENTRY__=e.__SENTRY__||{},e.__SENTRY__.hub=new c,e.__SENTRY__.hub)}function f(e,t){return!!e&&(e.__SENTRY__=e.__SENTRY__||{},e.__SENTRY__.hub=t,!0)}},37506:(e,t,n)=>{"use strict";var r=n(70655),i=n(96893),o=n(67597),a=n(71336),s=n(62844),c=/^[ \t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \t]*$/,u=function(){function e(e,t,n,r){void 0===e&&(e=(0,s.DP)()),void 0===t&&(t=(0,s.DP)().substring(16)),this._traceId=e,this._spanId=t,this._sampled=n,this._parent=r}return e.prototype.setParent=function(e){return this._parent=e,this},e.prototype.setSampled=function(e){return this._sampled=e,this},e.fromTraceparent=function(t){var n=t.match(c);if(n){var r=void 0;"1"===n[3]?r=!0:"0"===n[3]&&(r=!1);var i=new e(n[1],n[2],r);return new e(n[1],void 0,r,i)}},e.prototype.toTraceparent=function(){var e="";return!0===this._sampled?e="-1":!1===this._sampled&&(e="-0"),this._traceId+"-"+this._spanId+e},e.prototype.toJSON=function(){return{parent:this._parent&&this._parent.toJSON()||void 0,sampled:this._sampled,span_id:this._spanId,trace_id:this._traceId}},e}();n.d(t,{i:()=>l,s:()=>p});var l=function(){function e(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._user={},this._tags={},this._extra={},this._context={}}return e.prototype.addScopeListener=function(e){this._scopeListeners.push(e)},e.prototype.addEventProcessor=function(e){return this._eventProcessors.push(e),this},e.prototype._notifyScopeListeners=function(){var e=this;this._notifyingListeners||(this._notifyingListeners=!0,setTimeout((function(){e._scopeListeners.forEach((function(t){t(e)})),e._notifyingListeners=!1})))},e.prototype._notifyEventProcessors=function(e,t,n,a){var s=this;return void 0===a&&(a=0),new i.s((function(i,c){var u=e[a];if(null===t||"function"!=typeof u)i(t);else{var l=u(r.__assign({},t),n);(0,o.Vh)(l)?l.then((function(t){return s._notifyEventProcessors(e,t,n,a+1).then(i)})).then(null,c):s._notifyEventProcessors(e,l,n,a+1).then(i).then(null,c)}}))},e.prototype.setUser=function(e){return this._user=(0,a.normalize)(e),this._notifyScopeListeners(),this},e.prototype.setTags=function(e){return this._tags=r.__assign({},this._tags,(0,a.normalize)(e)),this._notifyScopeListeners(),this},e.prototype.setTag=function(e,t){var n;return this._tags=r.__assign({},this._tags,((n={})[e]=(0,a.normalize)(t),n)),this._notifyScopeListeners(),this},e.prototype.setExtras=function(e){return this._extra=r.__assign({},this._extra,(0,a.normalize)(e)),this._notifyScopeListeners(),this},e.prototype.setExtra=function(e,t){var n;return this._extra=r.__assign({},this._extra,((n={})[e]=(0,a.normalize)(t),n)),this._notifyScopeListeners(),this},e.prototype.setFingerprint=function(e){return this._fingerprint=(0,a.normalize)(e),this._notifyScopeListeners(),this},e.prototype.setLevel=function(e){return this._level=(0,a.normalize)(e),this._notifyScopeListeners(),this},e.prototype.setTransaction=function(e){return this._transaction=e,this._notifyScopeListeners(),this},e.prototype.setContext=function(e,t){return this._context[e]=t?(0,a.normalize)(t):void 0,this._notifyScopeListeners(),this},e.prototype.setSpan=function(e){return this._span=e,this._notifyScopeListeners(),this},e.prototype.startSpan=function(e){var t=new u;return t.setParent(e),this.setSpan(t),t},e.prototype.getSpan=function(){return this._span},e.clone=function(t){var n=new e;return t&&(n._breadcrumbs=r.__spread(t._breadcrumbs),n._tags=r.__assign({},t._tags),n._extra=r.__assign({},t._extra),n._context=r.__assign({},t._context),n._user=t._user,n._level=t._level,n._span=t._span,n._transaction=t._transaction,n._fingerprint=t._fingerprint,n._eventProcessors=r.__spread(t._eventProcessors)),n},e.prototype.clear=function(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._context={},this._level=void 0,this._transaction=void 0,this._fingerprint=void 0,this._span=void 0,this._notifyScopeListeners(),this},e.prototype.addBreadcrumb=function(e,t){var n=(new Date).getTime()/1e3,i=r.__assign({timestamp:n},e);return this._breadcrumbs=void 0!==t&&t>=0?r.__spread(this._breadcrumbs,[(0,a.normalize)(i)]).slice(-t):r.__spread(this._breadcrumbs,[(0,a.normalize)(i)]),this._notifyScopeListeners(),this},e.prototype.clearBreadcrumbs=function(){return this._breadcrumbs=[],this._notifyScopeListeners(),this},e.prototype._applyFingerprint=function(e){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],this._fingerprint&&(e.fingerprint=e.fingerprint.concat(this._fingerprint)),e.fingerprint&&!e.fingerprint.length&&delete e.fingerprint},e.prototype.applyToEvent=function(e,t){return this._extra&&Object.keys(this._extra).length&&(e.extra=r.__assign({},this._extra,e.extra)),this._tags&&Object.keys(this._tags).length&&(e.tags=r.__assign({},this._tags,e.tags)),this._user&&Object.keys(this._user).length&&(e.user=r.__assign({},this._user,e.user)),this._context&&Object.keys(this._context).length&&(e.contexts=r.__assign({},this._context,e.contexts)),this._level&&(e.level=this._level),this._transaction&&(e.transaction=this._transaction),this._span&&(e.contexts=e.contexts||{},e.contexts.trace=this._span),this._applyFingerprint(e),e.breadcrumbs=r.__spread(e.breadcrumbs||[],this._breadcrumbs),e.breadcrumbs=e.breadcrumbs.length>0?e.breadcrumbs:void 0,this._notifyEventProcessors(r.__spread(d(),this._eventProcessors),e,t)},e}();function d(){var e=(0,s.DB)();return e.__SENTRY__=e.__SENTRY__||{},e.__SENTRY__.globalEventProcessors=e.__SENTRY__.globalEventProcessors||[],e.__SENTRY__.globalEventProcessors}function p(e){d().push(e)}},39666:(e,t,n)=>{"use strict";n.d(t,{Ro:()=>a,em:()=>s,Pk:()=>c,vs:()=>u});var r=n(70655),i=n(38641);function o(e){for(var t=[],n=1;n{"use strict";var r;n.d(t,{t:()=>r}),function(e){e.Fatal="fatal",e.Error="error",e.Warning="warning",e.Log="log",e.Info="info",e.Debug="debug",e.Critical="critical"}(r||(r={})),function(e){e.fromString=function(t){switch(t){case"debug":return e.Debug;case"info":return e.Info;case"warn":case"warning":return e.Warning;case"error":return e.Error;case"fatal":return e.Fatal;case"critical":return e.Critical;case"log":default:return e.Log}}}(r||(r={}))},21620:(e,t,n)=>{"use strict";var r=n(70655),i=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){return e.__proto__=t,e}:function(e,t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n]);return e});n.d(t,{v:()=>o});var o=function(e){function t(t){var n=this.constructor,r=e.call(this,t)||this;return r.message=t,r.name=n.prototype.constructor.name,i(r,n.prototype),r}return r.__extends(t,e),t}(Error)},67597:(e,t,n)=>{"use strict";function r(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return e instanceof Error}}function i(e){return"[object ErrorEvent]"===Object.prototype.toString.call(e)}function o(e){return"[object DOMError]"===Object.prototype.toString.call(e)}function a(e){return"[object DOMException]"===Object.prototype.toString.call(e)}function s(e){return"[object String]"===Object.prototype.toString.call(e)}function c(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function u(e){return"[object Object]"===Object.prototype.toString.call(e)}function l(e){return"undefined"!=typeof Event&&e instanceof Event}function d(e){return"undefined"!=typeof Element&&e instanceof Element}function p(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function h(e){return Boolean(e&&e.then&&"function"==typeof e.then)}function f(e){return u(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e}n.d(t,{X:()=>r,hE:()=>i,Bo:()=>o,TS:()=>a,Bj:()=>s,PQ:()=>c,jG:()=>u,MJ:()=>l,Ez:()=>d,Aq:()=>p,Vh:()=>h,my:()=>f})},12343:(e,t,n)=>{"use strict";n.d(t,{o:()=>s});var r=n(62844),i=(0,r.DB)(),o="Sentry Logger ",a=function(){function e(){this._enabled=!1}return e.prototype.disable=function(){this._enabled=!1},e.prototype.enable=function(){this._enabled=!0},e.prototype.log=function(){for(var e=[],t=0;t{"use strict";n.d(t,{Pl:()=>o,AH:()=>a,DB:()=>c,DP:()=>u,IO:()=>l,tt:()=>d,Ep:()=>p,FT:()=>h,wU:()=>f,xj:()=>m,rl:()=>g,VG:()=>b});var r=n(67597),i=n(34155);function o(e,t){return e.require(t)}function a(){return"[object process]"===Object.prototype.toString.call(void 0!==i?i:0)}var s={};function c(){return a()?n.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:s}function u(){var e=c(),t=e.crypto||e.msCrypto;if(void 0!==t&&t.getRandomValues){var n=new Uint16Array(8);t.getRandomValues(n),n[3]=4095&n[3]|16384,n[4]=16383&n[4]|32768;var r=function(e){for(var t=e.toString(16);t.length<4;)t="0"+t;return t};return r(n[0])+r(n[1])+r(n[2])+r(n[3])+r(n[4])+r(n[5])+r(n[6])+r(n[7])}return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function l(e){if(!e)return{};var t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};var n=t[6]||"",r=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],relative:t[5]+n+r}}function d(e){if(e.message)return e.message;if(e.exception&&e.exception.values&&e.exception.values[0]){var t=e.exception.values[0];return t.type&&t.value?t.type+": "+t.value:t.type||t.value||e.event_id||""}return e.event_id||""}function p(e){var t=c();if(!("console"in t))return e();var n=t.console,r={};["debug","info","warn","error","log","assert"].forEach((function(e){e in t.console&&n[e].__sentry__&&(r[e]=n[e].__sentry_wrapped__,n[e]=n[e].__sentry_original__)}));var i=e();return Object.keys(r).forEach((function(e){n[e]=r[e]})),i}function h(e,t,n){e.exception=e.exception||{},e.exception.values=e.exception.values||[],e.exception.values[0]=e.exception.values[0]||{},e.exception.values[0].value=e.exception.values[0].value||t||"",e.exception.values[0].type=e.exception.values[0].type||n||"Error"}function f(e,t){void 0===t&&(t={});try{e.exception.values[0].mechanism=e.exception.values[0].mechanism||{},Object.keys(t).forEach((function(n){e.exception.values[0].mechanism[n]=t[n]}))}catch(n){}}function m(){try{return document.location.href}catch(e){return""}}function g(e){try{for(var t=e,n=[],r=0,i=0,o=" > ".length,a=void 0;t&&r++<5&&!("html"===(a=y(t))||r>1&&i+n.length*o+a.length>=80);)n.push(a),i+=a.length,t=t.parentNode;return n.reverse().join(" > ")}catch(s){return""}}function y(e){var t,n,i,o,a,s=e,c=[];if(!s||!s.tagName)return"";if(c.push(s.tagName.toLowerCase()),s.id&&c.push("#"+s.id),(t=s.className)&&(0,r.Bj)(t))for(n=t.split(/\s+/),a=0;a{"use strict";var r=n(67597),i=function(){function e(){this._hasWeakSet="function"==typeof WeakSet,this._inner=this._hasWeakSet?new WeakSet:[]}return e.prototype.memoize=function(e){if(this._hasWeakSet)return!!this._inner.has(e)||(this._inner.add(e),!1);for(var t=0;t"}try{s.currentTarget=(0,r.Ez)(a.currentTarget)?(0,o.rl)(a.currentTarget):Object.prototype.toString.call(a.currentTarget)}catch(c){s.currentTarget=""}for(var i in"undefined"!=typeof CustomEvent&&e instanceof CustomEvent&&(s.detail=a.detail),a)Object.prototype.hasOwnProperty.call(a,i)&&(s[i]=a);return s}return e}function l(e){return function(e){return~-encodeURI(e).split(/%..|./).length}(JSON.stringify(e))}function d(e,t,n){void 0===t&&(t=3),void 0===n&&(n=102400);var r=f(e,t);return l(r)>n?d(e,t-1,n):r}function p(e,t){return"domain"===t&&e&&"object"==typeof e&&e._events?"[Domain]":"domainEmitter"===t?"[DomainEmitter]":void 0!==n.g&&e===n.g?"[Global]":"undefined"!=typeof window&&e===window?"[Window]":"undefined"!=typeof document&&e===document?"[Document]":(0,r.my)(e)?"[SyntheticEvent]":"number"==typeof e&&e!=e?"[NaN]":void 0===e?"[undefined]":"function"==typeof e?"[Function: "+(e.name||"")+"]":e}function h(e,t,n,o){if(void 0===n&&(n=1/0),void 0===o&&(o=new i),0===n)return function(e){var t=Object.prototype.toString.call(e);if("string"==typeof e)return e;if("[object Object]"===t)return"[Object]";if("[object Array]"===t)return"[Array]";var n=p(e);return(0,r.PQ)(n)?n:t}(t);if(null!=t&&"function"==typeof t.toJSON)return t.toJSON();var a=p(t,e);if((0,r.PQ)(a))return a;var s=u(t),c=Array.isArray(t)?[]:{};if(o.memoize(t))return"[Circular ~]";for(var l in s)Object.prototype.hasOwnProperty.call(s,l)&&(c[l]=h(l,s[l],n-1,o));return o.unmemoize(t),c}function f(e,t){try{return JSON.parse(JSON.stringify(e,(function(e,n){return h(e,n,t)})))}catch(n){return"**non-serializable**"}}function m(e,t){void 0===t&&(t=40);var n=Object.keys(u(e));if(n.sort(),!n.length)return"[object has no keys]";if(n[0].length>=t)return(0,a.DE)(n[0],t);for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(", ");if(!(i.length>t))return r===n.length?i:(0,a.DE)(i,t)}return""}n.d(t,{fill:()=>s,urlEncode:()=>c,normalizeToSize:()=>d,normalize:()=>f,extractExceptionKeysForMessage:()=>m})},57321:(e,t,n)=>{"use strict";n.d(t,{DE:()=>i,Tc:()=>o,Xi:()=>a});var r=n(67597);function i(e,t){return void 0===t&&(t=0),"string"!=typeof e||0===t?e:e.length<=t?e:e.substr(0,t)+"..."}function o(e,t){if(!Array.isArray(e))return"";for(var n=[],r=0;r{"use strict";n.d(t,{cf:()=>o,fo:()=>a,Pd:()=>s,rk:()=>c});var r=n(12343),i=n(62844);function o(){if(!("fetch"in(0,i.DB)()))return!1;try{return new Headers,new Request(""),new Response,!0}catch(e){return!1}}function a(){if(!o())return!1;var e=function(e){return-1!==e.toString().indexOf("native")},t=(0,i.DB)(),n=null,a=t.document;if(a){var s=a.createElement("iframe");s.hidden=!0;try{a.head.appendChild(s),s.contentWindow&&s.contentWindow.fetch&&(n=e(s.contentWindow.fetch)),a.head.removeChild(s)}catch(c){r.o.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",c)}}return null===n&&(n=e(t.fetch)),n}function s(){if(!o())return!1;try{return new Request("_",{referrerPolicy:"origin"}),!0}catch(e){return!1}}function c(){var e=(0,i.DB)(),t=e.chrome,n=t&&t.app&&t.app.runtime,r="history"in e&&!!e.history.pushState&&!!e.history.replaceState;return!n&&r}},96893:(e,t,n)=>{"use strict";n.d(t,{s:()=>o});var r,i=n(67597);!function(e){e.PENDING="PENDING",e.RESOLVED="RESOLVED",e.REJECTED="REJECTED"}(r||(r={}));var o=function(){function e(e){var t=this;this._state=r.PENDING,this._handlers=[],this._resolve=function(e){t._setResult(r.RESOLVED,e)},this._reject=function(e){t._setResult(r.REJECTED,e)},this._setResult=function(e,n){t._state===r.PENDING&&((0,i.Vh)(n)?n.then(t._resolve,t._reject):(t._state=e,t._value=n,t._executeHandlers()))},this._attachHandler=function(e){t._handlers=t._handlers.concat(e),t._executeHandlers()},this._executeHandlers=function(){t._state!==r.PENDING&&(t._state===r.REJECTED?t._handlers.forEach((function(e){e.onrejected&&e.onrejected(t._value)})):t._handlers.forEach((function(e){e.onfulfilled&&e.onfulfilled(t._value)})),t._handlers=[])};try{e(this._resolve,this._reject)}catch(n){this._reject(n)}}return e.prototype.toString=function(){return"[object SyncPromise]"},e.resolve=function(t){return new e((function(e){e(t)}))},e.reject=function(t){return new e((function(e,n){n(t)}))},e.all=function(t){return new e((function(n,r){if(Array.isArray(t))if(0!==t.length){var i=t.length,o=[];t.forEach((function(t,a){e.resolve(t).then((function(e){o[a]=e,0===(i-=1)&&n(o)})).then(null,r)}))}else n([]);else r(new TypeError("Promise.all requires an array as input."))}))},e.prototype.then=function(t,n){var r=this;return new e((function(e,i){r._attachHandler({onfulfilled:function(n){if(t)try{return void e(t(n))}catch(r){return void i(r)}else e(n)},onrejected:function(t){if(n)try{return void e(n(t))}catch(r){return void i(r)}else i(t)}})}))},e.prototype.catch=function(e){return this.then((function(e){return e}),e)},e.prototype.finally=function(t){var n=this;return new e((function(e,r){var i,o;return n.then((function(e){o=!1,i=e,t&&t()}),(function(e){o=!0,i=e,t&&t()})).then((function(){o?r(i):e(i)}))}))},e}()},35096:e=>{"use strict";const t=e=>{let t=2166136261;for(let n=0;n>>0};e.exports=t,e.exports.default=t},46831:(e,t,n)=>{"use strict";const r=n(66688),i=n(28808),o=n(43854),a=n(73126),s=(e,t)=>{if("string"!=typeof e)throw new TypeError(`Expected a string, got \`${typeof e}\``);t=Object.assign({},{separator:"-",lowercase:!0,decamelize:!0,customReplacements:[]},t);const n=i(t.separator);e=((e,t)=>{for(const[n,r]of t)e=e.replace(new RegExp(i(n),"g"),r);return e})(e,new Map([...a,...t.customReplacements,...o])),e=(e=r(e)).normalize("NFKD"),t.decamelize&&(e=(e=>e.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1 $2"))(e));let s=/[^a-zA-Z\d]+/g;return t.lowercase&&(e=e.toLowerCase(),s=/[^a-z\d]+/g),e=((e,t)=>e.replace(new RegExp(`${t}{2,}`,"g"),t).replace(new RegExp(`^${t}|${t}$`,"g"),""))(e=(e=e.replace(s,n)).replace(/\\/g,""),n)};e.exports=s,e.exports.default=s},28808:e=>{"use strict";const t=/[|\\{}()[\]^$+*?.-]/g;e.exports=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(t,"\\$&")}},73126:e=>{"use strict";e.exports=[["&"," and "],["🦄"," unicorn "],["♥"," love "]]},43854:e=>{"use strict";e.exports=[["ß","ss"],["ä","ae"],["Ä","Ae"],["ö","oe"],["Ö","Oe"],["ü","ue"],["Ü","Ue"],["à","a"],["À","A"],["á","a"],["Á","A"],["â","a"],["Â","A"],["ã","a"],["Ã","A"],["è","e"],["È","E"],["é","e"],["É","E"],["ê","e"],["Ê","E"],["ì","i"],["Ì","I"],["í","i"],["Í","I"],["ò","o"],["Ò","O"],["ó","o"],["Ó","O"],["ô","o"],["Ô","O"],["õ","o"],["Õ","O"],["ù","u"],["Ù","U"],["ú","u"],["Ú","U"],["ý","y"],["Ý","Y"],["ă","a"],["Ă","A"],["Đ","D"],["đ","d"],["ĩ","i"],["Ĩ","I"],["ũ","u"],["Ũ","U"],["ơ","o"],["Ơ","O"],["ư","u"],["Ư","U"],["ạ","a"],["Ạ","A"],["ả","a"],["Ả","A"],["ấ","a"],["Ấ","A"],["ầ","a"],["Ầ","A"],["ẩ","a"],["Ẩ","A"],["ẫ","a"],["Ẫ","A"],["ậ","a"],["Ậ","A"],["ắ","a"],["Ắ","A"],["ằ","a"],["Ằ","A"],["ẳ","a"],["Ẳ","A"],["ẵ","a"],["Ẵ","A"],["ặ","a"],["Ặ","A"],["ẹ","e"],["Ẹ","E"],["ẻ","e"],["Ẻ","E"],["ẽ","e"],["Ẽ","E"],["ế","e"],["Ế","E"],["ề","e"],["Ề","E"],["ể","e"],["Ể","E"],["ễ","e"],["Ễ","E"],["ệ","e"],["Ệ","E"],["ỉ","i"],["Ỉ","I"],["ị","i"],["Ị","I"],["ọ","o"],["Ọ","O"],["ỏ","o"],["Ỏ","O"],["ố","o"],["Ố","O"],["ồ","o"],["Ồ","O"],["ổ","o"],["Ổ","O"],["ỗ","o"],["Ỗ","O"],["ộ","o"],["Ộ","O"],["ớ","o"],["Ớ","O"],["ờ","o"],["Ờ","O"],["ở","o"],["Ở","O"],["ỡ","o"],["Ỡ","O"],["ợ","o"],["Ợ","O"],["ụ","u"],["Ụ","U"],["ủ","u"],["Ủ","U"],["ứ","u"],["Ứ","U"],["ừ","u"],["Ừ","U"],["ử","u"],["Ử","U"],["ữ","u"],["Ữ","U"],["ự","u"],["Ự","U"],["ỳ","y"],["Ỳ","Y"],["ỵ","y"],["Ỵ","Y"],["ỷ","y"],["Ỷ","Y"],["ỹ","y"],["Ỹ","Y"],["ء","e"],["آ","a"],["أ","a"],["ؤ","w"],["إ","i"],["ئ","y"],["ا","a"],["ب","b"],["ة","t"],["ت","t"],["ث","th"],["ج","j"],["ح","h"],["خ","kh"],["د","d"],["ذ","dh"],["ر","r"],["ز","z"],["س","s"],["ش","sh"],["ص","s"],["ض","d"],["ط","t"],["ظ","z"],["ع","e"],["غ","gh"],["ـ","_"],["ف","f"],["ق","q"],["ك","k"],["ل","l"],["م","m"],["ن","n"],["ه","h"],["و","w"],["ى","a"],["ي","y"],["َ‎","a"],["ُ","u"],["ِ‎","i"],["٠","0"],["١","1"],["٢","2"],["٣","3"],["٤","4"],["٥","5"],["٦","6"],["٧","7"],["٨","8"],["٩","9"],["چ","ch"],["ک","k"],["گ","g"],["پ","p"],["ژ","zh"],["ی","y"],["۰","0"],["۱","1"],["۲","2"],["۳","3"],["۴","4"],["۵","5"],["۶","6"],["۷","7"],["۸","8"],["۹","9"],["ټ","p"],["ځ","z"],["څ","c"],["ډ","d"],["ﺫ","d"],["ﺭ","r"],["ړ","r"],["ﺯ","z"],["ږ","g"],["ښ","x"],["ګ","g"],["ڼ","n"],["ۀ","e"],["ې","e"],["ۍ","ai"],["ٹ","t"],["ڈ","d"],["ڑ","r"],["ں","n"],["ہ","h"],["ھ","h"],["ے","e"],["А","A"],["а","a"],["Б","B"],["б","b"],["В","V"],["в","v"],["Г","G"],["г","g"],["Д","D"],["д","d"],["Е","E"],["е","e"],["Ж","Zh"],["ж","zh"],["З","Z"],["з","z"],["И","I"],["и","i"],["Й","J"],["й","j"],["К","K"],["к","k"],["Л","L"],["л","l"],["М","M"],["м","m"],["Н","N"],["н","n"],["О","O"],["о","o"],["П","P"],["п","p"],["Р","R"],["р","r"],["С","S"],["с","s"],["Т","T"],["т","t"],["У","U"],["у","u"],["Ф","F"],["ф","f"],["Х","H"],["х","h"],["Ц","Cz"],["ц","cz"],["Ч","Ch"],["ч","ch"],["Ш","Sh"],["ш","sh"],["Щ","Shh"],["щ","shh"],["Ъ",""],["ъ",""],["Ы","Y"],["ы","y"],["Ь",""],["ь",""],["Э","E"],["э","e"],["Ю","Yu"],["ю","yu"],["Я","Ya"],["я","ya"],["Ё","Yo"],["ё","yo"],["ș","s"],["Ș","s"],["ț","t"],["Ț","t"],["ş","s"],["Ş","s"],["ç","c"],["Ç","c"],["ğ","g"],["Ğ","g"],["ı","i"],["İ","i"]]},82152:(e,t,n)=>{"use strict";n.d(t,{P:()=>s});var r=Object.prototype,i=r.toString,o=r.hasOwnProperty,a=new Map;function s(e,t){try{return function e(t,n){if(t===n)return!0;var r=i.call(t),a=i.call(n);if(r!==a)return!1;switch(r){case"[object Array]":if(t.length!==n.length)return!1;case"[object Object]":if(c(t,n))return!0;var s=Object.keys(t),u=Object.keys(n),l=s.length;if(l!==u.length)return!1;for(var d=0;d{var t={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==t.call(e)}},21:(e,t,n)=>{e.exports=u;var r=n(56362),i=n(93043),o=n(10137),a=n(51580),s=n(35717),c=n(23733);function u(){a.apply(this,arguments)}function l(){throw new c.AlgoliaSearchError("Not implemented in this environment.\nIf you feel this is a mistake, write to support@algolia.com")}s(u,a),u.prototype.deleteIndex=function(e,t){return this._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(e),hostType:"write",callback:t})},u.prototype.moveIndex=function(e,t,n){var r={operation:"move",destination:t};return this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(e)+"/operation",body:r,hostType:"write",callback:n})},u.prototype.copyIndex=function(e,t,n,r){var i={operation:"copy",destination:t},o=r;if("function"==typeof n)o=n;else if(Array.isArray(n)&&n.length>0)i.scope=n;else if(void 0!==n)throw new Error("the scope given to `copyIndex` was not an array with settings, synonyms or rules");return this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(e)+"/operation",body:i,hostType:"write",callback:o})},u.prototype.getLogs=function(e,t,r){var i=n(82882),o={};return"object"==typeof e?(o=i(e),r=t):0===arguments.length||"function"==typeof e?r=e:1===arguments.length||"function"==typeof t?(r=t,o.offset=e):(o.offset=e,o.length=t),void 0===o.offset&&(o.offset=0),void 0===o.length&&(o.length=10),this._jsonRequest({method:"GET",url:"/1/logs?"+this._getSearchParams(o,""),hostType:"read",callback:r})},u.prototype.listIndexes=function(e,t){var n="";return void 0===e||"function"==typeof e?t=e:n="?page="+e,this._jsonRequest({method:"GET",url:"/1/indexes"+n,hostType:"read",callback:t})},u.prototype.initIndex=function(e){return new r(this,e)},u.prototype.initAnalytics=function(e){return n(97181)(this.applicationID,this.apiKey,e)},u.prototype.listUserKeys=i((function(e){return this.listApiKeys(e)}),o("client.listUserKeys()","client.listApiKeys()")),u.prototype.listApiKeys=function(e){return this._jsonRequest({method:"GET",url:"/1/keys",hostType:"read",callback:e})},u.prototype.getUserKeyACL=i((function(e,t){return this.getApiKey(e,t)}),o("client.getUserKeyACL()","client.getApiKey()")),u.prototype.getApiKey=function(e,t){return this._jsonRequest({method:"GET",url:"/1/keys/"+e,hostType:"read",callback:t})},u.prototype.deleteUserKey=i((function(e,t){return this.deleteApiKey(e,t)}),o("client.deleteUserKey()","client.deleteApiKey()")),u.prototype.deleteApiKey=function(e,t){return this._jsonRequest({method:"DELETE",url:"/1/keys/"+e,hostType:"write",callback:t})},u.prototype.addUserKey=i((function(e,t,n){return this.addApiKey(e,t,n)}),o("client.addUserKey()","client.addApiKey()")),u.prototype.addApiKey=function(e,t,r){var i=n(77055),o="Usage: client.addApiKey(arrayOfAcls[, params, callback])";if(!i(e))throw new Error(o);1!==arguments.length&&"function"!=typeof t||(r=t,t=null);var a={acl:e};return t&&(a.validity=t.validity,a.maxQueriesPerIPPerHour=t.maxQueriesPerIPPerHour,a.maxHitsPerQuery=t.maxHitsPerQuery,a.indexes=t.indexes,a.description=t.description,t.queryParameters&&(a.queryParameters=this._getSearchParams(t.queryParameters,"")),a.referers=t.referers),this._jsonRequest({method:"POST",url:"/1/keys",body:a,hostType:"write",callback:r})},u.prototype.addUserKeyWithValidity=i((function(e,t,n){return this.addApiKey(e,t,n)}),o("client.addUserKeyWithValidity()","client.addApiKey()")),u.prototype.updateUserKey=i((function(e,t,n,r){return this.updateApiKey(e,t,n,r)}),o("client.updateUserKey()","client.updateApiKey()")),u.prototype.updateApiKey=function(e,t,r,i){var o=n(77055),a="Usage: client.updateApiKey(key, arrayOfAcls[, params, callback])";if(!o(t))throw new Error(a);2!==arguments.length&&"function"!=typeof r||(i=r,r=null);var s={acl:t};return r&&(s.validity=r.validity,s.maxQueriesPerIPPerHour=r.maxQueriesPerIPPerHour,s.maxHitsPerQuery=r.maxHitsPerQuery,s.indexes=r.indexes,s.description=r.description,r.queryParameters&&(s.queryParameters=this._getSearchParams(r.queryParameters,"")),s.referers=r.referers),this._jsonRequest({method:"PUT",url:"/1/keys/"+e,body:s,hostType:"write",callback:i})},u.prototype.startQueriesBatch=i((function(){this._batch=[]}),o("client.startQueriesBatch()","client.search()")),u.prototype.addQueryInBatch=i((function(e,t,n){this._batch.push({indexName:e,query:t,params:n})}),o("client.addQueryInBatch()","client.search()")),u.prototype.sendQueriesBatch=i((function(e){return this.search(this._batch,e)}),o("client.sendQueriesBatch()","client.search()")),u.prototype.batch=function(e,t){if(!n(77055)(e))throw new Error("Usage: client.batch(operations[, callback])");return this._jsonRequest({method:"POST",url:"/1/indexes/*/batch",body:{requests:e},hostType:"write",callback:t})},u.prototype.assignUserID=function(e,t){if(!e.userID||!e.cluster)throw new c.AlgoliaSearchError("You have to provide both a userID and cluster",e);return this._jsonRequest({method:"POST",url:"/1/clusters/mapping",hostType:"write",body:{cluster:e.cluster},callback:t,headers:{"x-algolia-user-id":e.userID}})},u.prototype.getTopUserID=function(e){return this._jsonRequest({method:"GET",url:"/1/clusters/mapping/top",hostType:"read",callback:e})},u.prototype.getUserID=function(e,t){if(!e.userID)throw new c.AlgoliaSearchError("You have to provide a userID",{debugData:e});return this._jsonRequest({method:"GET",url:"/1/clusters/mapping/"+e.userID,hostType:"read",callback:t})},u.prototype.listClusters=function(e){return this._jsonRequest({method:"GET",url:"/1/clusters",hostType:"read",callback:e})},u.prototype.listUserIDs=function(e,t){return this._jsonRequest({method:"GET",url:"/1/clusters/mapping",body:e,hostType:"read",callback:t})},u.prototype.removeUserID=function(e,t){if(!e.userID)throw new c.AlgoliaSearchError("You have to provide a userID",{debugData:e});return this._jsonRequest({method:"DELETE",url:"/1/clusters/mapping",hostType:"write",callback:t,headers:{"x-algolia-user-id":e.userID}})},u.prototype.searchUserIDs=function(e,t){return this._jsonRequest({method:"POST",url:"/1/clusters/mapping/search",body:e,hostType:"read",callback:t})},u.prototype.setPersonalizationStrategy=function(e,t){return this._jsonRequest({method:"POST",url:"/1/recommendation/personalization/strategy",body:e,hostType:"write",callback:t})},u.prototype.getPersonalizationStrategy=function(e){return this._jsonRequest({method:"GET",url:"/1/recommendation/personalization/strategy",hostType:"read",callback:e})},u.prototype.destroy=l,u.prototype.enableRateLimitForward=l,u.prototype.disableRateLimitForward=l,u.prototype.useSecuredAPIKey=l,u.prototype.disableSecuredAPIKey=l,u.prototype.generateSecuredApiKey=l},51580:(e,t,n)=>{var r=n(34155);e.exports=u;var i=n(23733),o=n(93753),a=n(99437),s=n(44475),c=r.env.RESET_APP_DATA_TIMER&&parseInt(r.env.RESET_APP_DATA_TIMER,10)||12e4;function u(e,t,r){var o=n(11227)("algoliasearch"),a=n(82882),s=n(77055),c=n(37164),u="Usage: algoliasearch(applicationID, apiKey, opts)";if(!0!==r._allowEmptyCredentials&&!e)throw new i.AlgoliaSearchError("Please provide an application ID. "+u);if(!0!==r._allowEmptyCredentials&&!t)throw new i.AlgoliaSearchError("Please provide an API key. "+u);this.applicationID=e,this.apiKey=t,this.hosts={read:[],write:[]},r=r||{},this._timeouts=r.timeouts||{connect:1e3,read:2e3,write:3e4},r.timeout&&(this._timeouts.connect=this._timeouts.read=this._timeouts.write=r.timeout);var d=r.protocol||"https:";if(/:$/.test(d)||(d+=":"),"http:"!==d&&"https:"!==d)throw new i.AlgoliaSearchError("protocol must be `http:` or `https:` (was `"+r.protocol+"`)");if(this._checkAppIdData(),r.hosts)s(r.hosts)?(this.hosts.read=a(r.hosts),this.hosts.write=a(r.hosts)):(this.hosts.read=a(r.hosts.read),this.hosts.write=a(r.hosts.write));else{var p=c(this._shuffleResult,(function(t){return e+"-"+t+".algolianet.com"})),h=(!1===r.dsn?"":"-dsn")+".algolia.net";this.hosts.read=[this.applicationID+h].concat(p),this.hosts.write=[this.applicationID+".algolia.net"].concat(p)}this.hosts.read=c(this.hosts.read,l(d)),this.hosts.write=c(this.hosts.write,l(d)),this.extraHeaders={},this.cache=r._cache||{},this._ua=r._ua,this._useCache=!(void 0!==r._useCache&&!r._cache)||r._useCache,this._useRequestCache=this._useCache&&r._useRequestCache,this._useFallback=void 0===r.useFallback||r.useFallback,this._setTimeout=r._setTimeout,o("init done, %j",this)}function l(e){return function(t){return e+"//"+t.toLowerCase()}}function d(e){if(void 0===Array.prototype.toJSON)return JSON.stringify(e);var t=Array.prototype.toJSON;delete Array.prototype.toJSON;var n=JSON.stringify(e);return Array.prototype.toJSON=t,n}function p(e){var t={};for(var n in e){var r;if(Object.prototype.hasOwnProperty.call(e,n))r="x-algolia-api-key"===n||"x-algolia-application-id"===n?"**hidden for security purposes**":e[n],t[n]=r}return t}u.prototype.initIndex=function(e){return new a(this,e)},u.prototype.setExtraHeader=function(e,t){this.extraHeaders[e.toLowerCase()]=t},u.prototype.getExtraHeader=function(e){return this.extraHeaders[e.toLowerCase()]},u.prototype.unsetExtraHeader=function(e){delete this.extraHeaders[e.toLowerCase()]},u.prototype.addAlgoliaAgent=function(e){-1===this._ua.indexOf(";"+e)&&(this._ua+=";"+e)},u.prototype._jsonRequest=function(e){this._checkAppIdData();var t,r,a,s=n(11227)("algoliasearch:"+e.url),c=e.additionalUA||"",u=e.cache,l=this,h=0,f=!1,m=l._useFallback&&l._request.fallback&&e.fallback;this.apiKey.length>500&&void 0!==e.body&&(void 0!==e.body.params||void 0!==e.body.requests)?(e.body.apiKey=this.apiKey,a=this._computeRequestHeaders({additionalUA:c,withApiKey:!1,headers:e.headers})):a=this._computeRequestHeaders({additionalUA:c,headers:e.headers}),void 0!==e.body&&(t=d(e.body)),s("request start");var g=[];function y(e,t,n){return l._useCache&&e&&t&&void 0!==t[n]}function v(t,n){if(y(l._useRequestCache,u,r)&&t.catch((function(){delete u[r]})),"function"!=typeof e.callback)return t.then(n);t.then((function(t){o((function(){e.callback(null,n(t))}),l._setTimeout||setTimeout)}),(function(t){o((function(){e.callback(t)}),l._setTimeout||setTimeout)}))}if(l._useCache&&l._useRequestCache&&(r=e.url),l._useCache&&l._useRequestCache&&t&&(r+="_body_"+t),y(l._useRequestCache,u,r)){s("serving request from cache");var b=u[r];return v("function"!=typeof b.then?l._promise.resolve({responseText:b}):b,(function(e){return JSON.parse(e.responseText)}))}var E=function n(o,v){l._checkAppIdData();var b=new Date;if(l._useCache&&!l._useRequestCache&&(r=e.url),l._useCache&&!l._useRequestCache&&t&&(r+="_body_"+v.body),y(!l._useRequestCache,u,r)){s("serving response from cache");var E=u[r];return l._promise.resolve({body:JSON.parse(E),responseText:E})}if(h>=l.hosts[e.hostType].length)return!m||f?(s("could not get any response"),l._promise.reject(new i.AlgoliaSearchError("Cannot connect to the AlgoliaSearch API. Send an email to support@algolia.com to report and resolve the issue. Application id was: "+l.applicationID,{debugData:g}))):(s("switching to fallback"),h=0,v.method=e.fallback.method,v.url=e.fallback.url,v.jsonBody=e.fallback.body,v.jsonBody&&(v.body=d(v.jsonBody)),a=l._computeRequestHeaders({additionalUA:c,headers:e.headers}),v.timeouts=l._getTimeoutsForRequest(e.hostType),l._setHostIndexByType(0,e.hostType),f=!0,n(l._request.fallback,v));var w=l._getHostByType(e.hostType),_=w+v.url,x={body:v.body,jsonBody:v.jsonBody,method:v.method,headers:a,timeouts:v.timeouts,debug:s,forceAuthHeaders:v.forceAuthHeaders};return s("method: %s, url: %s, headers: %j, timeouts: %d",x.method,_,x.headers,x.timeouts),o===l._request.fallback&&s("using fallback"),o.call(l,_,x).then((function(e){var n=e&&e.body&&e.body.message&&e.body.status||e.statusCode||e&&e.body&&200;s("received response: statusCode: %s, computed statusCode: %d, headers: %j",e.statusCode,n,e.headers);var o=2===Math.floor(n/100),c=new Date;if(g.push({currentHost:w,headers:p(a),content:t||null,contentLength:void 0!==t?t.length:null,method:v.method,timeouts:v.timeouts,url:v.url,startTime:b,endTime:c,duration:c-b,statusCode:n}),o)return l._useCache&&!l._useRequestCache&&u&&(u[r]=e.responseText),{responseText:e.responseText,body:e.body};if(4!==Math.floor(n/100))return h+=1,S();s("unrecoverable error");var d=new i.AlgoliaSearchError(e.body&&e.body.message,{debugData:g,statusCode:n});return l._promise.reject(d)}),(function(r){s("error: %s, stack: %s",r.message,r.stack);var c=new Date;g.push({currentHost:w,headers:p(a),content:t||null,contentLength:void 0!==t?t.length:null,method:v.method,timeouts:v.timeouts,url:v.url,startTime:b,endTime:c,duration:c-b}),r instanceof i.AlgoliaSearchError||(r=new i.Unknown(r&&r.message,r));if(h+=1,r instanceof i.Unknown||r instanceof i.UnparsableJSON||h>=l.hosts[e.hostType].length&&(f||!m))return r.debugData=g,l._promise.reject(r);if(r instanceof i.RequestTimeout)return s("retrying request with higher timeout"),l._incrementHostIndex(e.hostType),l._incrementTimeoutMultipler(),v.timeouts=l._getTimeoutsForRequest(e.hostType),n(o,v);return S()}));function S(){return s("retrying request"),l._incrementHostIndex(e.hostType),n(o,v)}}(l._request,{url:e.url,method:e.method,body:t,jsonBody:e.body,timeouts:l._getTimeoutsForRequest(e.hostType),forceAuthHeaders:e.forceAuthHeaders});return l._useCache&&l._useRequestCache&&u&&(u[r]=E),v(E,(function(e){return e.body}))},u.prototype._getSearchParams=function(e,t){if(null==e)return t;for(var n in e)null!==n&&void 0!==e[n]&&e.hasOwnProperty(n)&&(t+=""===t?"":"&",t+=n+"="+encodeURIComponent("[object Array]"===Object.prototype.toString.call(e[n])?d(e[n]):e[n]));return t},u.prototype._computeRequestHeaders=function(e){var t=n(49804),r={"x-algolia-agent":e.additionalUA?this._ua+";"+e.additionalUA:this._ua,"x-algolia-application-id":this.applicationID};return!1!==e.withApiKey&&(r["x-algolia-api-key"]=this.apiKey),this.userToken&&(r["x-algolia-usertoken"]=this.userToken),this.securityTags&&(r["x-algolia-tagfilters"]=this.securityTags),t(this.extraHeaders,(function(e,t){r[t]=e})),e.headers&&t(e.headers,(function(e,t){r[t]=e})),r},u.prototype.search=function(e,t,r){var i=n(77055),o=n(37164);if(!i(e))throw new Error("Usage: client.search(arrayOfQueries[, callback])");"function"==typeof t?(r=t,t={}):void 0===t&&(t={});var a=this,s={requests:o(e,(function(e){var t="";return void 0!==e.query&&(t+="query="+encodeURIComponent(e.query)),{indexName:e.indexName,params:a._getSearchParams(e.params,t)}}))},c=o(s.requests,(function(e,t){return t+"="+encodeURIComponent("/1/indexes/"+encodeURIComponent(e.indexName)+"?"+e.params)})).join("&");return void 0!==t.strategy&&(s.strategy=t.strategy),this._jsonRequest({cache:this.cache,method:"POST",url:"/1/indexes/*/queries",body:s,hostType:"read",fallback:{method:"GET",url:"/1/indexes/*",body:{params:c}},callback:r})},u.prototype.searchForFacetValues=function(e){var t=n(77055),r=n(37164),i="Usage: client.searchForFacetValues([{indexName, params: {facetName, facetQuery, ...params}}, ...queries])";if(!t(e))throw new Error(i);var o=this;return o._promise.all(r(e,(function(e){if(!e||void 0===e.indexName||void 0===e.params.facetName||void 0===e.params.facetQuery)throw new Error(i);var t=n(82882),r=n(33076),a=e.indexName,s=e.params,c=s.facetName,u=r(t(s),(function(e){return"facetName"===e})),l=o._getSearchParams(u,"");return o._jsonRequest({cache:o.cache,method:"POST",url:"/1/indexes/"+encodeURIComponent(a)+"/facets/"+encodeURIComponent(c)+"/query",hostType:"read",body:{params:l}})})))},u.prototype.setSecurityTags=function(e){if("[object Array]"===Object.prototype.toString.call(e)){for(var t=[],n=0;nc?this._resetInitialAppIdData(e):e},u.prototype._resetInitialAppIdData=function(e){var t=e||{};return t.hostIndexes={read:0,write:0},t.timeoutMultiplier=1,t.shuffleResult=t.shuffleResult||function(e){var t,n,r=e.length;for(;0!==r;)n=Math.floor(Math.random()*r),t=e[r-=1],e[r]=e[n],e[n]=t;return e}([1,2,3]),this._setAppIdData(t)},u.prototype._cacheAppIdData=function(e){this._hostIndexes=e.hostIndexes,this._timeoutMultiplier=e.timeoutMultiplier,this._shuffleResult=e.shuffleResult},u.prototype._partialAppIdDataUpdate=function(e){var t=n(49804),r=this._getAppIdData();return t(e,(function(e,t){r[t]=e})),this._setAppIdData(r)},u.prototype._getHostByType=function(e){return this.hosts[e][this._getHostIndexByType(e)]},u.prototype._getTimeoutMultiplier=function(){return this._timeoutMultiplier},u.prototype._getHostIndexByType=function(e){return this._hostIndexes[e]},u.prototype._setHostIndexByType=function(e,t){var r=n(82882)(this._hostIndexes);return r[t]=e,this._partialAppIdDataUpdate({hostIndexes:r}),e},u.prototype._incrementHostIndex=function(e){return this._setHostIndexByType((this._getHostIndexByType(e)+1)%this.hosts[e].length,e)},u.prototype._incrementTimeoutMultipler=function(){var e=Math.max(this._timeoutMultiplier+1,4);return this._partialAppIdDataUpdate({timeoutMultiplier:e})},u.prototype._getTimeoutsForRequest=function(e){return{connect:this._timeouts.connect*this._timeoutMultiplier,complete:this._timeouts[e]*this._timeoutMultiplier}}},56362:(e,t,n)=>{var r=n(35717),i=n(99437),o=n(93043),a=n(10137),s=n(93753),c=n(23733),u=o((function(){}),a("forwardToSlaves","forwardToReplicas"));function l(){i.apply(this,arguments)}function d(e,t,n){return function n(r,i){var o={page:r||0,hitsPerPage:t||100},a=i||[];return e(o).then((function(e){var t=e.hits,r=e.nbHits,i=t.map((function(e){return delete e._highlightResult,e})),s=a.concat(i);return s.lengthr&&(o=r),"published"!==e.status?a._promise.delay(o).then(t):e}))}();if(!t)return c;c.then((function(e){s((function(){t(null,e)}),a._setTimeout||setTimeout)}),(function(e){s((function(){t(e)}),a._setTimeout||setTimeout)}))},l.prototype.clearIndex=function(e){return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/clear",hostType:"write",callback:e})},l.prototype.getSettings=function(e,t){1===arguments.length&&"function"==typeof e&&(t=e,e={}),e=e||{};var n=encodeURIComponent(this.indexName);return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+n+"/settings?getVersion=2"+(e.advanced?"&advanced="+e.advanced:""),hostType:"read",callback:t})},l.prototype.searchSynonyms=function(e,t){return"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/search",body:e,hostType:"read",callback:t})},l.prototype.exportSynonyms=function(e,t){return d(this.searchSynonyms.bind(this),e,t)},l.prototype.saveSynonym=function(e,t,n){"function"==typeof t?(n=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&u();var r=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e.objectID)+"?forwardToReplicas="+r,body:e,hostType:"write",callback:n})},l.prototype.getSynonym=function(e,t){return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e),hostType:"read",callback:t})},l.prototype.deleteSynonym=function(e,t,n){"function"==typeof t?(n=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&u();var r=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e)+"?forwardToReplicas="+r,hostType:"write",callback:n})},l.prototype.clearSynonyms=function(e,t){"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),void 0!==e.forwardToSlaves&&u();var n=e.forwardToSlaves||e.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/clear?forwardToReplicas="+n,hostType:"write",callback:t})},l.prototype.batchSynonyms=function(e,t,n){"function"==typeof t?(n=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&u();var r=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/batch?forwardToReplicas="+r+"&replaceExistingSynonyms="+(t.replaceExistingSynonyms?"true":"false"),hostType:"write",body:e,callback:n})},l.prototype.searchRules=function(e,t){return"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/search",body:e,hostType:"read",callback:t})},l.prototype.exportRules=function(e,t){return d(this.searchRules.bind(this),e,t)},l.prototype.saveRule=function(e,t,n){if("function"==typeof t?(n=t,t={}):void 0===t&&(t={}),!e.objectID)throw new c.AlgoliaSearchError("Missing or empty objectID field for rule");var r=!0===t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e.objectID)+"?forwardToReplicas="+r,body:e,hostType:"write",callback:n})},l.prototype.getRule=function(e,t){return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e),hostType:"read",callback:t})},l.prototype.deleteRule=function(e,t,n){"function"==typeof t?(n=t,t={}):void 0===t&&(t={});var r=!0===t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e)+"?forwardToReplicas="+r,hostType:"write",callback:n})},l.prototype.clearRules=function(e,t){"function"==typeof e?(t=e,e={}):void 0===e&&(e={});var n=!0===e.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/clear?forwardToReplicas="+n,hostType:"write",callback:t})},l.prototype.batchRules=function(e,t,n){"function"==typeof t?(n=t,t={}):void 0===t&&(t={});var r=!0===t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/batch?forwardToReplicas="+r+"&clearExistingRules="+(!0===t.clearExistingRules?"true":"false"),hostType:"write",body:e,callback:n})},l.prototype.setSettings=function(e,t,n){1!==arguments.length&&"function"!=typeof t||(n=t,t={}),void 0!==t.forwardToSlaves&&u();var r=t.forwardToSlaves||t.forwardToReplicas?"true":"false",i=this;return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(i.indexName)+"/settings?forwardToReplicas="+r,hostType:"write",body:e,callback:n})},l.prototype.listUserKeys=o((function(e){return this.listApiKeys(e)}),a("index.listUserKeys()","client.listApiKeys()")),l.prototype.listApiKeys=o((function(e){return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/keys",hostType:"read",callback:e})}),a("index.listApiKeys()","client.listApiKeys()")),l.prototype.getUserKeyACL=o((function(e,t){return this.getApiKey(e,t)}),a("index.getUserKeyACL()","client.getApiKey()")),l.prototype.getApiKey=o((function(e,t){return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/keys/"+e,hostType:"read",callback:t})}),a("index.getApiKey()","client.getApiKey()")),l.prototype.deleteUserKey=o((function(e,t){return this.deleteApiKey(e,t)}),a("index.deleteUserKey()","client.deleteApiKey()")),l.prototype.deleteApiKey=o((function(e,t){return this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/keys/"+e,hostType:"write",callback:t})}),a("index.deleteApiKey()","client.deleteApiKey()")),l.prototype.addUserKey=o((function(e,t,n){return this.addApiKey(e,t,n)}),a("index.addUserKey()","client.addApiKey()")),l.prototype.addApiKey=o((function(e,t,r){var i=n(77055),o="Usage: index.addApiKey(arrayOfAcls[, params, callback])";if(!i(e))throw new Error(o);1!==arguments.length&&"function"!=typeof t||(r=t,t=null);var a={acl:e};return t&&(a.validity=t.validity,a.maxQueriesPerIPPerHour=t.maxQueriesPerIPPerHour,a.maxHitsPerQuery=t.maxHitsPerQuery,a.description=t.description,t.queryParameters&&(a.queryParameters=this.as._getSearchParams(t.queryParameters,"")),a.referers=t.referers),this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/keys",body:a,hostType:"write",callback:r})}),a("index.addApiKey()","client.addApiKey()")),l.prototype.addUserKeyWithValidity=o((function(e,t,n){return this.addApiKey(e,t,n)}),a("index.addUserKeyWithValidity()","client.addApiKey()")),l.prototype.updateUserKey=o((function(e,t,n,r){return this.updateApiKey(e,t,n,r)}),a("index.updateUserKey()","client.updateApiKey()")),l.prototype.updateApiKey=o((function(e,t,r,i){var o=n(77055),a="Usage: index.updateApiKey(key, arrayOfAcls[, params, callback])";if(!o(t))throw new Error(a);2!==arguments.length&&"function"!=typeof r||(i=r,r=null);var s={acl:t};return r&&(s.validity=r.validity,s.maxQueriesPerIPPerHour=r.maxQueriesPerIPPerHour,s.maxHitsPerQuery=r.maxHitsPerQuery,s.description=r.description,r.queryParameters&&(s.queryParameters=this.as._getSearchParams(r.queryParameters,"")),s.referers=r.referers),this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/keys/"+e,body:s,hostType:"write",callback:i})}),a("index.updateApiKey()","client.updateApiKey()"))},1026:(e,t,n)=>{"use strict";function r(){}e.exports=r,n(35717)(r,n(17187).EventEmitter),r.prototype.stop=function(){this._stopped=!0,this._clean()},r.prototype._end=function(){this.emit("end"),this._clean()},r.prototype._error=function(e){this.emit("error",e),this._clean()},r.prototype._result=function(e){this.emit("result",e)},r.prototype._clean=function(){this.removeAllListeners("stop"),this.removeAllListeners("end"),this.removeAllListeners("error"),this.removeAllListeners("result")}},99437:(e,t,n)=>{var r=n(10148),i=n(93043),o=n(10137);function a(e,t){this.indexName=t,this.as=e,this.typeAheadArgs=null,this.typeAheadValueOption=null,this.cache={}}e.exports=a,a.prototype.clearCache=function(){this.cache={}},a.prototype.search=r("query"),a.prototype.similarSearch=i(r("similarQuery"),o("index.similarSearch(query[, callback])","index.search({ similarQuery: query }[, callback])")),a.prototype.browse=function(e,t,r){var i,o,a=n(51004),s=this;0===arguments.length||1===arguments.length&&"function"==typeof arguments[0]?(i=0,r=arguments[0],e=void 0):"number"==typeof arguments[0]?(i=arguments[0],"number"==typeof arguments[1]?o=arguments[1]:"function"==typeof arguments[1]&&(r=arguments[1],o=void 0),e=void 0,t=void 0):"object"==typeof arguments[0]?("function"==typeof arguments[1]&&(r=arguments[1]),t=arguments[0],e=void 0):"string"==typeof arguments[0]&&"function"==typeof arguments[1]&&(r=arguments[1],t=void 0),t=a({},t||{},{page:i,hitsPerPage:o,query:e});var c=this.as._getSearchParams(t,"");return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(s.indexName)+"/browse",body:{params:c},hostType:"read",callback:r})},a.prototype.browseFrom=function(e,t){return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/browse",body:{cursor:e},hostType:"read",callback:t})},a.prototype.searchForFacetValues=function(e,t){var r=n(82882),i=n(33076);if(void 0===e.facetName||void 0===e.facetQuery)throw new Error("Usage: index.searchForFacetValues({facetName, facetQuery, ...params}[, callback])");var o=e.facetName,a=i(r(e),(function(e){return"facetName"===e})),s=this.as._getSearchParams(a,"");return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/facets/"+encodeURIComponent(o)+"/query",hostType:"read",body:{params:s},callback:t})},a.prototype.searchFacet=i((function(e,t){return this.searchForFacetValues(e,t)}),o("index.searchFacet(params[, callback])","index.searchForFacetValues(params[, callback])")),a.prototype._search=function(e,t,n,r){return this.as._jsonRequest({cache:this.cache,method:"POST",url:t||"/1/indexes/"+encodeURIComponent(this.indexName)+"/query",body:{params:e},hostType:"read",fallback:{method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName),body:{params:e}},callback:n,additionalUA:r})},a.prototype.getObject=function(e,t,n){var r=this;1!==arguments.length&&"function"!=typeof t||(n=t,t=void 0);var i="";if(void 0!==t){i="?attributes=";for(var o=0;o{"use strict";var r=n(21),i=n(8779);e.exports=i(r)},8779:(e,t,n)=>{"use strict";var r=n(58908),i=r.Promise||n(82702).Promise;e.exports=function(e,t){var o=n(35717),a=n(23733),s=n(80660),c=n(53970),u=n(94504);function l(e,t,r){return(r=n(82882)(r||{}))._ua=r._ua||l.ua,new p(e,t,r)}t=t||"",l.version=n(4572),l.ua="Algolia for vanilla JavaScript "+t+l.version,l.initPlaces=u(l),r.__algolia={debug:n(11227),algoliasearch:l};var d={hasXMLHttpRequest:"XMLHttpRequest"in r,hasXDomainRequest:"XDomainRequest"in r};function p(){e.apply(this,arguments)}return d.hasXMLHttpRequest&&(d.cors="withCredentials"in new XMLHttpRequest),o(p,e),p.prototype._request=function(e,t){return new i((function(n,r){if(d.cors||d.hasXDomainRequest){e=s(e,t.headers);var i,o,c=t.body,u=d.cors?new XMLHttpRequest:new XDomainRequest,l=!1;i=setTimeout(p,t.timeouts.connect),u.onprogress=function(){l||h()},"onreadystatechange"in u&&(u.onreadystatechange=function(){!l&&u.readyState>1&&h()}),u.onload=function(){if(o)return;var e;clearTimeout(i);try{e={body:JSON.parse(u.responseText),responseText:u.responseText,statusCode:u.status,headers:u.getAllResponseHeaders&&u.getAllResponseHeaders()||{}}}catch(t){e=new a.UnparsableJSON({more:u.responseText})}e instanceof a.UnparsableJSON?r(e):n(e)},u.onerror=function(e){if(o)return;clearTimeout(i),r(new a.Network({more:e}))},u instanceof XMLHttpRequest?(u.open(t.method,e,!0),t.forceAuthHeaders&&(u.setRequestHeader("x-algolia-application-id",t.headers["x-algolia-application-id"]),u.setRequestHeader("x-algolia-api-key",t.headers["x-algolia-api-key"]))):u.open(t.method,e),d.cors&&(c&&("POST"===t.method?u.setRequestHeader("content-type","application/x-www-form-urlencoded"):u.setRequestHeader("content-type","application/json")),u.setRequestHeader("accept","application/json")),c?u.send(c):u.send()}else r(new a.Network("CORS not supported"));function p(){o=!0,u.abort(),r(new a.RequestTimeout)}function h(){l=!0,clearTimeout(i),i=setTimeout(p,t.timeouts.complete)}}))},p.prototype._request.fallback=function(e,t){return e=s(e,t.headers),new i((function(n,r){c(e,t,(function(e,t){e?r(e):n(t)}))}))},p.prototype._promise={reject:function(e){return i.reject(e)},resolve:function(e){return i.resolve(e)},delay:function(e){return new i((function(t){setTimeout(t,e)}))},all:function(e){return i.all(e)}},l}},80660:(e,t,n)=>{"use strict";e.exports=function(e,t){/\?/.test(e)?e+="&":e+="?";return e+r(t)};var r=n(68795)},53970:(e,t,n)=>{"use strict";e.exports=function(e,t,n){if("GET"!==t.method)return void n(new Error("Method "+t.method+" "+e+" is not supported by JSONP."));t.debug("JSONP: start");var o=!1,a=!1;i+=1;var s=document.getElementsByTagName("head")[0],c=document.createElement("script"),u="algoliaJSONP_"+i,l=!1;window[u]=function(e){!function(){try{delete window[u],delete window[u+"_loaded"]}catch(e){window[u]=window[u+"_loaded"]=void 0}}(),a?t.debug("JSONP: Late answer, ignoring"):(o=!0,h(),n(null,{body:e,responseText:JSON.stringify(e)}))},e+="&callback="+u,t.jsonBody&&t.jsonBody.params&&(e+="&"+t.jsonBody.params);var d=setTimeout((function(){t.debug("JSONP: Script timeout"),a=!0,h(),n(new r.RequestTimeout)}),t.timeouts.complete);function p(){t.debug("JSONP: success"),l||a||(l=!0,o||(t.debug("JSONP: Fail. Script loaded but did not call the callback"),h(),n(new r.JSONPScriptFail)))}function h(){clearTimeout(d),c.onload=null,c.onreadystatechange=null,c.onerror=null,s.removeChild(c)}c.onreadystatechange=function(){"loaded"!==this.readyState&&"complete"!==this.readyState||p()},c.onload=p,c.onerror=function(){t.debug("JSONP: Script error"),l||a||(h(),n(new r.JSONPScriptError))},c.async=!0,c.defer=!0,c.src=e,s.appendChild(c)};var r=n(23733),i=0},10148:(e,t,n)=>{e.exports=function(e,t){return function(n,i,o){if("function"==typeof n&&"object"==typeof i||"object"==typeof o)throw new r.AlgoliaSearchError("index.search usage is index.search(query, params, cb)");0===arguments.length||"function"==typeof n?(o=n,n=""):1!==arguments.length&&"function"!=typeof i||(o=i,i=void 0),"object"==typeof n&&null!==n?(i=n,n=void 0):null==n&&(n="");var a,s="";return void 0!==n&&(s+=e+"="+encodeURIComponent(n)),void 0!==i&&(i.additionalUA&&(a=i.additionalUA,delete i.additionalUA),s=this.as._getSearchParams(i,s)),this._search(s,t,o,a)}};var r=n(23733)},82882:e=>{e.exports=function(e){return JSON.parse(JSON.stringify(e))}},97181:(e,t,n)=>{e.exports=function(e,t,n){var i={};return(n=n||{}).hosts=n.hosts||["analytics.algolia.com","analytics.algolia.com","analytics.algolia.com","analytics.algolia.com"],n.protocol=n.protocol||"https:",i.as=r(e,t,n),i.getABTests=function(e,t){var n=n||{},r=n.offset||0,i=n.limit||10;return this.as._jsonRequest({method:"GET",url:"/2/abtests?offset="+encodeURIComponent(r)+"&limit="+encodeURIComponent(i),hostType:"read",forceAuthHeaders:!0,callback:t})},i.getABTest=function(e,t){return this.as._jsonRequest({method:"GET",url:"/2/abtests/"+encodeURIComponent(e),hostType:"read",forceAuthHeaders:!0,callback:t})},i.addABTest=function(e,t){return this.as._jsonRequest({method:"POST",url:"/2/abtests",body:e,hostType:"read",forceAuthHeaders:!0,callback:t})},i.stopABTest=function(e,t){return this.as._jsonRequest({method:"POST",url:"/2/abtests/"+encodeURIComponent(e)+"/stop",hostType:"read",forceAuthHeaders:!0,callback:t})},i.deleteABTest=function(e,t){return this.as._jsonRequest({method:"DELETE",url:"/2/abtests/"+encodeURIComponent(e),hostType:"write",forceAuthHeaders:!0,callback:t})},i.waitTask=function(e,t,n){return this.as.initIndex(e).waitTask(t,n)},i};var r=n(39272)},93043:e=>{e.exports=function(e,t){var n=!1;return function(){return n||(console.warn(t),n=!0),e.apply(this,arguments)}}},10137:e=>{e.exports=function(e,t){var n=e.toLowerCase().replace(/[\.\(\)]/g,"");return"algoliasearch: `"+e+"` was replaced by `"+t+"`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#"+n}},23733:(e,t,n)=>{"use strict";var r=n(35717);function i(e,t){var r=n(49804),i=this;"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):i.stack=(new Error).stack||"Cannot get a stacktrace, browser is too old",this.name="AlgoliaSearchError",this.message=e||"Unknown error",t&&r(t,(function(e,t){i[t]=e}))}function o(e,t){function n(){var n=Array.prototype.slice.call(arguments,0);"string"!=typeof n[0]&&n.unshift(t),i.apply(this,n),this.name="AlgoliaSearch"+e+"Error"}return r(n,i),n}r(i,Error),e.exports={AlgoliaSearchError:i,UnparsableJSON:o("UnparsableJSON","Could not parse the incoming response as JSON, see err.more for details"),RequestTimeout:o("RequestTimeout","Request timedout before getting a response"),Network:o("Network","Network issue, see err.more for details"),JSONPScriptFail:o("JSONPScriptFail","