!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=211)}([function(e,t,n){e.exports=n(90)},function(e,t){function n(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise((function(i,a){var o=e.apply(t,r);function s(e){n(o,i,a,s,c,"next",e)}function c(e){n(o,i,a,s,c,"throw",e)}s(void 0)}))}}},function(e,t,n){window,e.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=211)}([function(e,t,n){e.exports=n(94)},function(e,t,n){"use strict";(function(e){n.d(t,"h",(function(){return d})),n.d(t,"o",(function(){return v})),n.d(t,"g",(function(){return y})),n.d(t,"m",(function(){return m})),n.d(t,"k",(function(){return g})),n.d(t,"l",(function(){return b})),n.d(t,"n",(function(){return w})),n.d(t,"i",(function(){return k})),n.d(t,"z",(function(){return x})),n.d(t,"q",(function(){return S})),n.d(t,"f",(function(){return _})),n.d(t,"x",(function(){return $})),n.d(t,"u",(function(){return P})),n.d(t,"b",(function(){return O})),n.d(t,"v",(function(){return C})),n.d(t,"c",(function(){return E})),n.d(t,"s",(function(){return A})),n.d(t,"r",(function(){return I})),n.d(t,"p",(function(){return j})),n.d(t,"a",(function(){return D})),n.d(t,"e",(function(){return M})),n.d(t,"t",(function(){return T})),n.d(t,"d",(function(){return R})),n.d(t,"j",(function(){return L})),n.d(t,"y",(function(){return N})),n.d(t,"w",(function(){return F}));var r=n(0),i=n.n(r),a=n(4),o=n.n(a),s=n(90),c=n.n(s),u=n(91),l=n.n(u);function f(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function p(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){f(a,r,i,o,s,"next",e)}function s(e){f(a,r,i,o,s,"throw",e)}o(void 0)}))}}function h(e){return(h="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 d(){return"undefined"!=typeof window?window:void 0!==e?e:null}function v(){return null!==d()}function y(e,t,n){return e.find((function(e){return e[t]===n}))}function m(e){return null!==e&&("function"==typeof e||"object"===h(e))}function g(e){return null!==e&&"function"==typeof e}function b(e){return null==e}function w(e){return"string"==typeof e||e instanceof String}function k(e,t){return e>t?e:t}function x(e,t,n){return l()(e.concat(t),(function(e,t){var r=!0,i=!1,a=void 0;try{for(var o,s=n[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var c=o.value;if(e[c]!==t[c])return!1}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return!0}))}function S(e){return e[e.length-1]}function _(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;e.push(s)}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}}function $(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;e.splice(e.indexOf(s),1)}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}}function P(e,t){e.splice(e.indexOf(t),1)}function O(e,t){return e.filter((function(e){return!t.includes(e)})).concat(t.filter((function(t){return!e.includes(t)})))}function C(e,t){e.splice(t,1)}function E(e,t){var n=e.slice();return C(n,t),n}function A(e,t){if(e){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0)delete e[a.value]}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}}}function I(e,t){var n=Object.assign({},e),r=!0,i=!1,a=void 0;try{for(var o,s=t[Symbol.iterator]();!(r=(o=s.next()).done);r=!0)delete n[o.value]}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return n}function j(){for(var e=arguments.length,t=new Array(e),n=0;n>3]>>r%8*4&15;return("x"===e?t:3&t|8).toString(16)}))}var i=(new Date).getTime();return e.performance&&"function"==typeof e.performance.now&&(i+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=(i+16*Math.random())%16|0;return i=Math.floor(i/16),("x"===e?t:3&t|8).toString(16)}))}function h(e){return"string"==typeof e||e instanceof String}function d(e){return v.apply(this,arguments)}function v(){return(v=o(i.a.mark((function e(t){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){var r=new Blob([t]),i=new FileReader;i.onload=function(t){e(t.target.result)},i.readAsArrayBuffer(r)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function y(e){return m.apply(this,arguments)}function m(){return(m=o(i.a.mark((function e(t){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){var r=new Blob([t]),i=new FileReader;i.onload=function(t){e(t.target.result)},i.readAsText(r)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function g(e){return b.apply(this,arguments)}function b(){return(b=o(i.a.mark((function e(t){var n,r,a,o;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=new Uint8Array(t),r="",o=0;o1&&void 0!==r[1]?r[1]:"binary",!c.isBuffer(t)){e.next=5;break}return e.abrupt("return",t);case 5:if(null!==t){e.next=9;break}return e.abrupt("return",null);case 9:if("string"!=typeof t){e.next=13;break}return e.abrupt("return",c.from(t,n));case 13:if(!(t instanceof Uint8Array)){e.next=17;break}return e.abrupt("return",s(t));case 17:if(!(t instanceof Promise)){e.next=21;break}return e.abrupt("return",t);case 21:throw new TypeError("Invalid type; string or buffer expected");case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}}).call(this,n(3))},function(e,t,n){"use strict";(function(e){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ var r=n(8),i=n(9),a=n(5);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,t){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function d(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return K(e).length;default:if(r)return U(e).length;t=(""+t).toLowerCase(),r=!0}}function v(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return E(this,t,n);case"utf8":case"utf-8":return P(this,t,n);case"ascii":return O(this,t,n);case"latin1":case"binary":return C(this,t,n);case"base64":return $(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function y(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function m(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:g(e,t,n,r,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):g(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function g(e,t,n,r,i){var a,o=1,s=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,s/=2,c/=2,n/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var l=-1;for(a=n;as&&(n=s-c),a=n;a>=0;a--){for(var f=!0,p=0;pi&&(r=i):r=i;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");r>a/2&&(r=a/2);for(var o=0;o>8,i=n%256,a.push(i),a.push(r);return a}(t,e.length-n),e,n,r)}function $(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function P(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i239?4:u>223?3:u>191?2:1;if(i+f<=n)switch(f){case 1:u<128&&(l=u);break;case 2:128==(192&(a=e[i+1]))&&(c=(31&u)<<6|63&a)>127&&(l=c);break;case 3:a=e[i+1],o=e[i+2],128==(192&a)&&128==(192&o)&&(c=(15&u)<<12|(63&a)<<6|63&o)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:a=e[i+1],o=e[i+2],s=e[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&(c=(15&u)<<18|(63&a)<<12|(63&o)<<6|63&s)>65535&&c<1114112&&(l=c)}null===l?(l=65533,f=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=f}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);for(var n="",r=0;rr)&&(n=r);for(var i="",a=t;an)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,n,r,i,a){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function D(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-n,2);i>>8*(r?i:1-i)}function M(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-n,4);i>>8*(r?i:3-i)&255}function T(e,t,n,r,i,a){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function R(e,t,n,r,a){return a||T(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function L(e,t,n,r,a){return a||T(e,0,n,8),i.write(e,t,n,r,52,8),n+8}t.Buffer=c,t.SlowBuffer=function(e){return+e!=e&&(e=0),c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=o(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return function(e,t,n,r){return l(t),t<=0?s(e,t):void 0!==n?"string"==typeof r?s(e,t).fill(n,r):s(e,t).fill(n):s(e,t)}(null,e,t,n)},c.allocUnsafe=function(e){return f(null,e)},c.allocUnsafeSlow=function(e){return f(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,a=Math.min(n,r);i0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},c.prototype.compare=function(e,t,n,r,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var a=(i>>>=0)-(r>>>=0),o=(n>>>=0)-(t>>>=0),s=Math.min(a,o),u=this.slice(r,i),l=e.slice(t,n),f=0;fi)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var a=!1;;)switch(r){case"hex":return b(this,e,t,n);case"utf8":case"utf-8":return w(this,e,t,n);case"ascii":return k(this,e,t,n);case"latin1":case"binary":return x(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,t,n);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),a=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},c.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(i*=256);)r+=this[e+--t]*i;return r},c.prototype.readUInt8=function(e,t){return t||I(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||I(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||I(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||I(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||I(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||I(e,t,this.length);for(var r=this[e],i=1,a=0;++a=(i*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||I(e,t,this.length);for(var r=t,i=1,a=this[e+--r];r>0&&(i*=256);)a+=this[e+--r]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*t)),a},c.prototype.readInt8=function(e,t){return t||I(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||I(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||I(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||I(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||I(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||I(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||I(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||I(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||I(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||j(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+i]=e/a&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||j(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||j(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||j(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||j(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||j(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);j(this,e,t,n,i-1,-i)}var a=0,o=1,s=0;for(this[t]=255&e;++a>0)-s&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);j(this,e,t,n,i-1,-i)}var a=n-1,o=1,s=0;for(this[t+a]=255&e;--a>=0&&(o*=256);)e<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(e/o>>0)-s&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||j(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||j(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||j(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||j(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||j(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return R(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return R(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return L(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return L(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--i)e[i+t]=this[i+n];else if(a<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(a=t;a55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function K(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function V(e,t,n,r){for(var i=0;i=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this,n(3))},function(e,t){function n(e){return(n="function"==typeof Symbol&&"symbol"==o(Symbol.iterator)?function(e){return o(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":o(e)})(e)}var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"===("undefined"==typeof window?"undefined":n(window))&&(r=window)}e.exports=r},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){(function(e){function t(e){return(t="function"==typeof Symbol&&"symbol"==o(Symbol.iterator)?function(e){return o(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":o(e)})(e)}var n=function(e){"use strict";var n=Object.prototype,r=n.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,n,r){var i=t&&t.prototype instanceof f?t:f,a=Object.create(i.prototype),o=new S(r||[]);return a._invoke=function(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return{value:void 0,done:!0}}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=w(o,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=u(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(e,n,o),a}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var l={};function f(){}function p(){}function h(){}var d={};d[a]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(_([])));y&&y!==n&&r.call(y,a)&&(d=y);var m=h.prototype=f.prototype=Object.create(d);function g(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function b(e,n){var i;this._invoke=function(a,o){function s(){return new n((function(i,s){!function i(a,o,s,c){var l=u(e[a],e,o);if("throw"!==l.type){var f=l.arg,p=f.value;return p&&"object"===t(p)&&r.call(p,"__await")?n.resolve(p.__await).then((function(e){i("next",e,s,c)}),(function(e){i("throw",e,s,c)})):n.resolve(p).then((function(e){f.value=e,s(f)}),(function(e){return i("throw",e,s,c)}))}c(l.arg)}(a,o,i,s)}))}return i=i?i.then(s,s):s()}}function w(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function _(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;x(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:_(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}("object"===t(e)?e.exports:{});try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}}).call(this,n(4)(e))},function(e,t,n){(function(t){var r=n(10).strict;e.exports=function(e){if(r(e)){var n=t.from(e.buffer);return e.byteLength!==e.buffer.byteLength&&(n=n.slice(e.byteOffset,e.byteOffset+e.byteLength)),n}return t.from(e)}}).call(this,n(2).Buffer)},function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=u(e),o=r[0],s=r[1],c=new a(function(e,t,n){return 3*(t+n)/4-n}(0,o,s)),l=0,f=s>0?o-4:o;for(n=0;n>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===s&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,c[l++]=255&t),1===s&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t),c},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,a=[],o=0,s=n-i;os?s:o+16383));return 1===i?(t=e[n-1],a.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],a.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),a.join("")};for(var r=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){for(var i,a,o=[],s=t;s>18&63]+r[a>>12&63]+r[a>>6&63]+r[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,n,r,i){var a,o,s=8*i-r-1,c=(1<>1,l=-7,f=n?i-1:0,p=n?-1:1,h=e[t+f];for(f+=p,a=h&(1<<-l)-1,h>>=-l,l+=s;l>0;a=256*a+e[t+f],f+=p,l-=8);for(o=a&(1<<-l)-1,a>>=-l,l+=r;l>0;o=256*o+e[t+f],f+=p,l-=8);if(0===a)a=1-u;else{if(a===c)return o?NaN:1/0*(h?-1:1);o+=Math.pow(2,r),a-=u}return(h?-1:1)*o*Math.pow(2,a-r)},t.write=function(e,t,n,r,i,a){var o,s,c,u=8*a-i-1,l=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:a-1,d=r?1:-1,v=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+f>=1?p/c:p*Math.pow(2,1-f))*c>=2&&(o++,c/=2),o+f>=l?(s=0,o=l):o+f>=1?(s=(t*c-1)*Math.pow(2,i),o+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;e[n+h]=255&s,h+=d,s/=256,i-=8);for(o=o<0;e[n+h]=255&o,h+=d,o/=256,u-=8);e[n+h-d]|=128*v}},function(e,t){e.exports=i,i.strict=a,i.loose=o;var n=Object.prototype.toString,r={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function i(e){return a(e)||o(e)}function a(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function o(e){return r[n.call(e)]}},function(e,t,n){"use strict";n.r(t),n.d(t,"SNPureCrypto",(function(){return c})),n.d(t,"SNWebCrypto",(function(){return w})),n.d(t,"isWebCryptoAvailable",(function(){return a.o})),n.d(t,"Buffer",(function(){return a.a})),n.d(t,"base64Encode",(function(){return a.f})),n.d(t,"base64Decode",(function(){return a.e})),n.d(t,"base64ToHex",(function(){return a.h})),n.d(t,"hexToBase64",(function(){return a.m}));var r=n(0),i=n.n(r),a=n(1);function s(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}var c=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,r,o;return t=e,(n=[{key:"generateUUIDSync",value:function(){return Object(a.i)()}},{key:"generateUUID",value:(r=i.a.mark((function e(){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Object(a.i)());case 1:case"end":return e.stop()}}),e)})),o=function(){var e=this,t=arguments;return new Promise((function(n,i){var a=r.apply(e,t);function o(e){s(a,n,i,o,c,"next",e)}function c(e){s(a,n,i,o,c,"throw",e)}o(void 0)}))},function(){return o.apply(this,arguments)})},{key:"timingSafeEqual",value:function(e,t){var n=String(e),r=String(t),i=n.length,a=0;i!==r.length&&(r=n,a=1);for(var o=0;o-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}},function(e,t,n){var r=n(129),i=n(29),a=n(46),o=a&&a.isTypedArray,s=o?i(o):r;e.exports=s},function(e,t,n){(function(e){function r(e){return(r="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)}var i=n(56),a="object"==r(t)&&t&&!t.nodeType&&t,o=a&&"object"==r(e)&&e&&!e.nodeType&&e,s=o&&o.exports===a&&i.process,c=function(){try{return o&&o.require&&o.require("util").types||s&&s.binding&&s.binding("util")}catch(e){}}();e.exports=c}).call(this,n(16)(e))},function(e,t){e.exports=function(e){return e}},function(e,t){e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}},function(e,t){e.exports=function(e,t){for(var n=-1,r=t.length,i=e.length;++n1?n[a-1]:void 0,s=a>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(a--,o):void 0,s&&i(n[0],n[1],s)&&(o=a<3?void 0:o,a=1),t=Object(t);++r=200){var v=t?null:s(e);if(v)return c(v);p=!1,l=o,d=new r}else d=t?[]:h;e:for(;++ul))return!1;var p=c.get(e);if(p&&c.get(t))return p==t;var h=-1,d=!0,v=2&n?new r:void 0;for(c.set(e,t),c.set(t,e);++h1),t})),s(e,l(e),n),u&&(n=i(n,7,c));for(var f=t.length;f--;)a(n,t[f]);return n}));e.exports=f},function(e,t,n){(function(e){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)}var n=function(e){"use strict";var n=Object.prototype,r=n.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,n,r){var i=t&&t.prototype instanceof f?t:f,a=Object.create(i.prototype),o=new S(r||[]);return a._invoke=function(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return{value:void 0,done:!0}}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=w(o,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=u(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(e,n,o),a}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var l={};function f(){}function p(){}function h(){}var d={};d[a]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(_([])));y&&y!==n&&r.call(y,a)&&(d=y);var m=h.prototype=f.prototype=Object.create(d);function g(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function b(e,n){var i;this._invoke=function(a,o){function s(){return new n((function(i,s){!function i(a,o,s,c){var l=u(e[a],e,o);if("throw"!==l.type){var f=l.arg,p=f.value;return p&&"object"===t(p)&&r.call(p,"__await")?n.resolve(p.__await).then((function(e){i("next",e,s,c)}),(function(e){i("throw",e,s,c)})):n.resolve(p).then((function(e){f.value=e,s(f)}),(function(e){return i("throw",e,s,c)}))}c(l.arg)}(a,o,i,s)}))}return i=i?i.then(s,s):s()}}function w(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function _(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;x(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:_(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}("object"===t(e)?e.exports:{});try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}}).call(this,n(16)(e))},function(e,t){e.exports=function(){this.__data__=[],this.size=0}},function(e,t,n){var r=n(24),i=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0||(n==t.length-1?t.pop():i.call(t,n,1),--this.size,0))}},function(e,t,n){var r=n(24);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},function(e,t,n){var r=n(24);e.exports=function(e){return r(this.__data__,e)>-1}},function(e,t,n){var r=n(24);e.exports=function(e,t){var n=this.__data__,i=r(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}},function(e,t,n){var r=n(23);e.exports=function(){this.__data__=new r,this.size=0}},function(e,t){e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},function(e,t){e.exports=function(e){return this.__data__.get(e)}},function(e,t){e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){var r=n(23),i=n(36),a=n(38);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var o=n.__data__;if(!i||o.length<199)return o.push([e,t]),this.size=++n.size,this;n=this.__data__=new a(o)}return n.set(e,t),this.size=n.size,this}},function(e,t,n){var r=n(37),i=n(108),a=n(8),o=n(57),s=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,l=c.toString,f=u.hasOwnProperty,p=RegExp("^"+l.call(f).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!a(e)||i(e))&&(r(e)?p:s).test(o(e))}},function(e,t,n){var r=n(13),i=Object.prototype,a=i.hasOwnProperty,o=i.toString,s=r?r.toStringTag:void 0;e.exports=function(e){var t=a.call(e,s),n=e[s];try{e[s]=void 0;var r=!0}catch(e){}var i=o.call(e);return r&&(t?e[s]=n:delete e[s]),i}},function(e,t){var n=Object.prototype.toString;e.exports=function(e){return n.call(e)}},function(e,t,n){var r,i=n(109),a=(r=/[^.]+$/.exec(i&&i.keys&&i.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!a&&a in e}},function(e,t,n){var r=n(7)["__core-js_shared__"];e.exports=r},function(e,t){e.exports=function(e,t){return null==e?void 0:e[t]}},function(e,t,n){var r=n(112),i=n(23),a=n(36);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(a||i),string:new r}}},function(e,t,n){var r=n(113),i=n(114),a=n(115),o=n(116),s=n(117);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}},function(e,t,n){function r(e){return(r="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)}var i=n(17),a=n(11),o=n(31),s=n(8);e.exports=function(e,t,n){if(!s(n))return!1;var c=r(t);return!!("number"==c?a(n)&&o(t,n.length):"string"==c&&t in n)&&i(n[t],e)}},function(e,t){e.exports=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this}},function(e,t){e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){var r=n(76);e.exports=function(e,t){return!(null==e||!e.length)&&r(e,t,0)>-1}},function(e,t){e.exports=function(e){return e!=e}},function(e,t){e.exports=function(e,t,n){for(var r=n-1,i=e.length;++r-1?s[c?t[u]:u]:void 0}}},function(e,t,n){var r=n(77),i=n(18),a=n(180),o=Math.max;e.exports=function(e,t,n){var s=null==e?0:e.length;if(!s)return-1;var c=null==n?0:a(n);return c<0&&(c=o(s+c,0)),r(e,i(t,3),c)}},function(e,t,n){var r=n(181);e.exports=function(e){var t=r(e),n=t%1;return t==t?n?t-n:t:0}},function(e,t,n){var r=n(182);e.exports=function(e){return e?(e=r(e))===1/0||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}},function(e,t,n){var r=n(8),i=n(19),a=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(r(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=r(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(a,"");var n=s.test(e);return n||c.test(e)?u(e.slice(2),n?2:8):o.test(e)?NaN:+e}},function(e,t,n){var r=n(184);e.exports=function(e,t){return e&&e.length&&t&&t.length?r(e,t):e}},function(e,t,n){var r=n(32),i=n(76),a=n(185),o=n(29),s=n(41),c=Array.prototype.splice;e.exports=function(e,t,n,u){var l=u?a:i,f=-1,p=t.length,h=e;for(e===t&&(t=s(t)),n&&(h=r(e,o(n)));++f-1;)h!==e&&c.call(h,d,1),c.call(e,d,1);return e}},function(e,t){e.exports=function(e,t,n,r){for(var i=n-1,a=e.length;++ii?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Array(i);++r0&&a(l)?n>1?e(l,n-1,a,o,s):r(s,l):o||(s[s.length]=l)}return s}},function(e,t,n){var r=n(13),i=n(27),a=n(4),o=r?r.isConcatSpreadable:void 0;e.exports=function(e){return a(e)||i(e)||!!(o&&e&&e[o])}},function(e,t,n){var r=n(19),i=Math.floor,a=Math.min;e.exports=function(e,t,n,o){t=n(t);for(var s=0,c=null==e?0:e.length,u=t!=t,l=null===t,f=r(t),p=void 0===t;s0&&void 0!==arguments[0]?arguments[0]:{},n=t.payloads,r=void 0===n?[]:n,i=t.source;u(this,e),this.source=i,this.payloadMap={},this.allPayloads=r;var a=!0,o=!1,s=void 0;try{for(var c,l=r[Symbol.iterator]();!(a=(c=l.next()).done);a=!0){var f=c.value;this.payloadMap[f.uuid]=f}}catch(e){o=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(o)throw s}}Object.freeze(this)}var t,n;return t=e,(n=[{key:"findPayload",value:function(e){return this.payloadMap[e]}},{key:"concat",value:function(t){var n=t.allPayloads.slice(),r=!0,i=!1,a=void 0;try{for(var s,c=this.allPayloads[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var u=s.value;Object(o.g)(t.allPayloads,"uuid",u.uuid)||n.push(u)}}catch(e){i=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(i)throw a}}return new e({payloads:n,source:this.source})}},{key:"payloadsThatReferencePayload",value:function(e){for(var t=[],n=0,r=Object.keys(this.payloadMap);n"===n.operator?y>v:"<="===n.operator?y<=v:">="===n.operator?y>=v:"startsWith"===n.operator?y.startsWith(v):"in"===n.operator?-1!==v.indexOf(y):"includes"===n.operator?this.resolveIncludesPredicate(y,v):"matches"===n.operator&&new RegExp(v).test(y)}},{key:"resolveIncludesPredicate",value:function(t,n){if("string"==typeof n)return t.includes(n);var r;r=Array.isArray(n)?e.FromArray(n):n;var i=!0,a=!1,o=void 0;try{for(var s,c=t[Symbol.iterator]();!(i=(s=c.next()).done);i=!0){var u=s.value;if(this.ObjectSatisfiesPredicate(u,r))return!0}}catch(e){a=!0,o=e}finally{try{i||null==c.return||c.return()}finally{if(a)throw o}}return!1}},{key:"ItemSatisfiesPredicate",value:function(t,n){return Array.isArray(n)&&(n=e.FromArray(n)),this.ObjectSatisfiesPredicate(t,n)}},{key:"ItemSatisfiesPredicates",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(!this.ItemSatisfiesPredicate(e,s))return!1}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}return!0}},{key:"DateFromString",value:function(e){var t=e.split("."),n=t[1],r=new Date,i=parseInt(t[0]);return"days"===n?r.setDate(r.getDate()-i):"hours"===n&&r.setHours(r.getHours()-i),r}},{key:"IsRecursiveOperator",value:function(e){return["and","or"].includes(e)}}])&&d(t,n),e}(),y={FullSyncCompleted:"sync:full-completed",SingleSyncCompleted:"sync:single-completed",DownloadFirstSyncCompleted:"sync:initial-completed",SyncTakingTooLong:"sync:taking-too-long",SyncError:"sync:error",SyncException:"sync:sync-exception",InvalidSession:"sync:invalid-session",MajorDataChange:"major-data-change",LocalDataIncrementalLoad:"local-data-incremental-load",EnterOutOfSync:"enter-out-of-sync",ExitOutOfSync:"exit-out-of-sync"};function m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var g={SignedIn:2,SignedOut:3,CompletedSync:5,FailedSync:6,HighLatencySync:7,EnteredOutOfSync:8,ExitedOutOfSync:9,Started:10,Launched:11,KeyStatusChanged:12};function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w={Web:1,Desktop:2,Mobile:3},k={Ios:1,Android:2,MacWeb:3,MacDesktop:4,WindowsWeb:5,WindowsDesktop:6,LinuxWeb:7,LinuxDesktop:8};function x(e){return{"mac-web":k.MacWeb,"mac-desktop":k.MacDesktop,"linux-web":k.LinuxWeb,"linux-desktop":k.LinuxDesktop,"windows-web":k.WindowsWeb,"windows-desktop":k.WindowsDesktop,ios:k.Ios,android:k.Android}[e]}function S(e){return e===w.Web||e===w.Desktop}function _(e){return e===w.Mobile}var $={LocalPasscode:1,AccountPassword:2,Biometric:3},P={RootKeyParams:"ROOT_KEY_PARAMS",WrappedRootKey:"WRAPPED_ROOT_KEY",RootKeyWrapperKeyParams:"ROOT_KEY_WRAPPER_KEY_PARAMS",Session:"session",User:"user",ServerHost:"server",LegacyUuid:"uuid",LastSyncToken:"syncToken",PaginationToken:"cursorToken",StorageObject:"storage",BiometricPrefs:"biometrics_prefs",MobilePasscodeTiming:"passcode_timing",PrivilegesExpirey:"SessionExpiresAtKey",PrivilegesSessionLength:"SessionLengthKey",SessionHistoryPersistable:"sessionHistory_persist",SessionHistoryRevisions:"sessionHistory_revisions",SessionHistoryOptimize:"sessionHistory_autoOptimize"};function O(e,t){return e?"".concat(e,"-").concat(t):t}function C(e){var t=e.leftContent,n=e.rightContent,r=e.keysToIgnore,i=e.appDataKeysToIgnore;if((t=JSON.parse(JSON.stringify(t))).appData){var a=t.appData["org.standardnotes.sn"];Object(o.s)(a,i),a?0===Object.keys(a).length&&delete t.appData:delete t.appData}if(Object(o.s)(t,r),(n=JSON.parse(JSON.stringify(n))).appData){var s=n.appData["org.standardnotes.sn"];Object(o.s)(s,i),s?0===Object.keys(s).length&&delete n.appData:delete n.appData}return Object(o.s)(n,r),JSON.stringify(t)===JSON.stringify(n)}function E(e,t,n){return n||(n=[]),!C({leftContent:e.content,rightContent:t.content,keysToIgnore:e.contentKeysToIgnoreWhenCheckingEquality().concat(n),appDataKeysToIgnore:e.appDatacontentKeysToIgnoreWhenCheckingEquality()})}function A(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function I(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=e.override;return Ri({object:this,override:t})}},{key:"populateDefaultContentValues",value:function(){this.errorDecrypting||this.deleted||(this.content.references||(this.content.references=[]),this.content.appData||(this.content.appData=M({},"org.standardnotes.sn",{})))}},{key:"initUUID",value:(r=a.a.mark((function t(){return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.uuid){t.next=4;break}return t.next=3,e.GenerateUuid();case 3:this.uuid=t.sent;case 4:case"end":return t.stop()}}),t,this)})),i=function(){var e=this,t=arguments;return new Promise((function(n,i){var a=r.apply(e,t);function o(e){D(a,n,i,o,s,"next",e)}function s(e){D(a,n,i,o,s,"throw",e)}o(void 0)}))},function(){return i.apply(this,arguments)})},{key:"updateFromPayload",value:function(e){if(e){var t=[ne.Content],n=!0,r=!1,i=void 0;try{for(var a,s=e.fields()[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var c=a.value;if(!Object(o.j)(this,c)){var u=e[c];if(t.includes(c)){var l=Object(o.a)(u||null);this[c]=l}else this[c]=u}}}catch(e){r=!0,i=e}finally{try{n||null==s.return||s.return()}finally{if(r)throw i}}this.content?this.mapContentToLocalProperties(this.content):!0===e.deleted&&this.handleDeletedContent(),this.dirtiedDate&&"string"==typeof this.dirtiedDate&&(this.dirtiedDate=new Date(this.dirtiedDate)),this.lastSyncBegan&&"string"==typeof this.lastSyncBegan&&(this.lastSyncBegan=new Date(this.lastSyncBegan)),this.lastSyncEnd&&"string"==typeof this.lastSyncEnd&&(this.lastSyncEnd=new Date(this.lastSyncEnd)),this.created_at?this.created_at=new Date(this.created_at):this.created_at=new Date,this.updated_at?this.updated_at=new Date(this.updated_at):this.updated_at=new Date(0),this._client_updated_at=null,this.populateDefaultContentValues()}}},{key:"mapContentToLocalProperties",value:function(e){}},{key:"collapseContent",value:function(){var e=this.structureParams();return Object(o.e)(this.content,e),e}},{key:"structureParams",value:function(){return this.getContentCopy()}},{key:"handleDeletedContent",value:function(){}},{key:"setDirty",value:function(e){var t=e.dirty,n=e.updateClientDate;if(!e.authorized)throw"Do not call setDirty directly. Use modelManager.setItemDirty";this.dirty=t,this.dirtiedDate=new Date,t&&n?this.client_updated_at=new Date:this.hasRawClientUpdatedAtValue()||(this.client_updated_at=new Date(this.updated_at)),this.collapseContent()}},{key:"updateLocalRelationships",value:function(){for(var e=this.content.references.map((function(e){return e.uuid})),t=0,n=Object.keys(this._referencedItems);t=0?Object(o.r)(this.content,["pw_cost"]):this.content}},{key:"isKeyParamsObject",get:function(){return!0}},{key:"kdfIterations",get:function(){return this.content.pw_cost}},{key:"seed",get:function(){return this.content.pw_nonce}},{key:"identifier",get:function(){return this.content.identifier||this.content.email}},{key:"salt",get:function(){return this.content.pw_salt}},{key:"version",get:function(){return this.content.version}}])&&G(t.prototype,n),e}(),Q={EncryptedString:0,DecryptedBareObject:1,DecryptedBase64String:2},Z=n(6);function X(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function ee(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){X(a,r,i,o,s,"next",e)}function s(e){X(a,r,i,o,s,"throw",e)}o(void 0)}))}}function te(e,t){for(var n=0;n0&&void 0!==u[0]?u[0]:{},n=t.password,r=t.pwSalt,i=t.pwCost,e.next=3,this.crypto.pbkdf2(n,r,i,512);case 3:return o=e.sent,e.next=6,this.splitKey({key:o,numParts:2});case 6:return s=e.sent,e.next=9,q.Create({content:{serverPassword:s[0],masterKey:s[1],version:this.constructor.versionString()}});case 9:return c=e.sent,e.abrupt("return",c);case 11:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})}],i=[{key:"pwCost",value:function(){return 3e3}},{key:"versionString",value:function(){return L.V001}}],r&&ce(n.prototype,r),i&&ce(n,i),t}(function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.crypto=t}var t,n,r,i,o,s,c,u,l;return t=e,(n=[{key:"firstHalfOfKey",value:(l=ee(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.substring(0,t.length/2));case 1:case"end":return e.stop()}}),e)}))),function(e){return l.apply(this,arguments)})},{key:"secondHalfOfKey",value:(u=ee(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.substring(t.length/2,t.length));case 1:case"end":return e.stop()}}),e)}))),function(e){return u.apply(this,arguments)})},{key:"splitKey",value:(c=ee(a.a.mark((function e(t){var n,r,i,o,s,c,u;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=t.key,r=t.numParts,i=n.length,o=i/r,s=[],c=0;c0&&void 0!==u[0]?u[0]:{},n=t.password,r=t.pwSalt,(i=t.pwCost)&&r&&n){e.next=3;break}throw"Attempting to 003.deriveKey with invalid parameters";case 3:return e.next=5,this.crypto.pbkdf2(n,r,i,768);case 5:return o=e.sent,e.next=8,this.splitKey({key:o,numParts:3});case 8:return s=e.sent,e.next=11,q.Create({content:{serverPassword:s[0],masterKey:s[1],dataAuthenticationKey:s[2],version:this.constructor.versionString()}});case 11:return c=e.sent,e.abrupt("return",c);case 13:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"encryptionComponentsFromString",value:function(e,t,n){var r=e.split(":");return{encryptionVersion:r[0],authHash:r[1],uuid:r[2],iv:r[3],contentCiphertext:r[4],ciphertextToAuth:[r[0],r[2],r[3],r[4]].join(":"),encryptionKey:t,authKey:n}}}],i=[{key:"pwCost",value:function(){return 3e3}},{key:"versionString",value:function(){return L.V002}}],r&&we(n.prototype,r),i&&we(n,i),t}(de);function Pe(e){return(Pe="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 Oe(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function Ce(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Oe(a,r,i,o,s,"next",e)}function s(e){Oe(a,r,i,o,s,"throw",e)}o(void 0)}))}}function Ee(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ae(e,t){for(var n=0;n0&&void 0!==l[0]?l[0]:{},n=t.password,r=t.salt,(i=t.iterations)&&r&&n){e.next=3;break}throw"Attempting to 004.deriveKey with invalid parameters";case 3:return e.next=5,this.crypto.argon2(n,r,i,67108864,64);case 5:return o=e.sent,e.next=8,this.splitKey({key:o,numParts:2});case 8:return s=e.sent,c=s[0],u=s[1],e.abrupt("return",q.Create({content:{masterKey:c,serverPassword:u,version:this.constructor.versionString()}}));case 12:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})}],i=[{key:"versionString",value:function(){return L.V004}},{key:"kdfIterations",value:function(){return 5}}],r&&Ue(n.prototype,r),i&&Ue(n,i),t}(Me);function We(e){return(We="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 qe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ge(e,t){for(var n=0;nt.title})).map((function(e,t){return"#"+e.title})).join(" ")}}],(r=[{key:"mapContentToLocalProperties",value:function(e){Rt(Lt(t.prototype),"mapContentToLocalProperties",this).call(this,e),this.title=e.title}},{key:"structureParams",value:function(){var e={title:this.title},n=Rt(Lt(t.prototype),"structureParams",this).call(this);return Object.assign(n,e),n}},{key:"addItemAsRelationship",value:function(e){e.content_type===c.Note&&(Object(o.g)(this.notes,"uuid",e.uuid)||this.notes.push(e)),Rt(Lt(t.prototype),"addItemAsRelationship",this).call(this,e)}},{key:"removeItemAsRelationship",value:function(e){e.content_type===c.Note&&yt()(this.notes,{uuid:e.uuid}),Rt(Lt(t.prototype),"removeItemAsRelationship",this).call(this,e)}},{key:"updateLocalRelationships",value:function(){var e=this,t=this.content.references.map((function(e){return e.uuid}));this.notes.slice().forEach((function(n){t.includes(n.uuid)||(yt()(e.notes,{uuid:n.uuid}),n.setIsNoLongerReferencedBy(e))}))}},{key:"isBeingRemovedLocally",value:function(){var e=this;this.notes.forEach((function(t){t.setIsNoLongerReferencedBy(e)})),this.notes.length=0,Rt(Lt(t.prototype),"isBeingRemovedLocally",this).call(this)}},{key:"didCompleteMapping",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=this.notes[Symbol.iterator]();!(t=(i=a.next()).done);t=!0)i.value.tagDidCompleteMapping(this)}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}}},{key:"isSmartTag",value:function(){return this.content_type===c.SmartTag}}])&&Tt(n.prototype,r),i&&Tt(n,i),t}(R);function Ut(e){return(Ut="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 Kt(e,t){for(var n=0;n1?a-1:0),s=1;s0&&o!==Ln.RemoteSaved&&e.isDesktop&&e.desktopManager.syncComponentsInstallation(u),l=!0,f=!1,p=void 0,t.prev=5,h=u[Symbol.iterator]();case 7:if(l=(d=h.next()).done){t.next=21;break}if(v=d.value,y=pt()(e.activeComponents,{uuid:v.uuid}),!v.active||v.deleted||y){t.next=15;break}return t.next=13,e.activateComponent(v);case 13:t.next=18;break;case 15:if(v.active||!y){t.next=18;break}return t.next=18,e.deactivateComponent(v);case 18:l=!0,t.next=7;break;case 21:t.next=27;break;case 23:t.prev=23,t.t0=t.catch(5),f=!0,p=t.t0;case 27:t.prev=27,t.prev=28,l||null==h.return||h.return();case 30:if(t.prev=30,!f){t.next=33;break}throw p;case 33:return t.finish(30);case 34:return t.finish(27);case 35:m=!0,g=!1,b=void 0,t.prev=38,w=function(){var t=x.value;if(s&&s===t.component.uuid)return"continue";var r=n.filter((function(e){return-1!==t.contentTypes.indexOf(e.content_type)}));if(0===r.length)return"continue";var i=[{name:Ma,content_types:t.contentTypes.sort()}];e.runWithPermissions(t.component,i,(function(){e.sendItemsInReply(t.component,r,t.originalMessage)}))},k=e.streamObservers[Symbol.iterator]();case 41:if(m=(x=k.next()).done){t.next=48;break}if("continue"!==w()){t.next=45;break}return t.abrupt("continue",45);case 45:m=!0,t.next=41;break;case 48:t.next=54;break;case 50:t.prev=50,t.t1=t.catch(38),g=!0,b=t.t1;case 54:t.prev=54,t.prev=55,m||null==k.return||k.return();case 57:if(t.prev=57,!g){t.next=60;break}throw b;case 60:return t.finish(57);case 61:return t.finish(54);case 62:S=[{name:Ta}],_=!0,$=!1,P=void 0,t.prev=66,O=function(){var t=E.value;if(s&&s===t.component.uuid)return"continue";var r=!0,i=!1,a=void 0;try{for(var c,u=e.handlers[Symbol.iterator]();!(r=(c=u.next()).done);r=!0){var l=c.value;if((l.areas.includes(t.component.area)||l.areas.includes("*"))&&l.contextRequestHandler){var f=l.contextRequestHandler(t.component);f&&function(){var r=pt()(n,{uuid:f.uuid});r&&e.runWithPermissions(t.component,S,(function(){e.sendContextItemInReply(t.component,r,t.originalMessage,o)}))}()}}}catch(e){i=!0,a=e}finally{try{r||null==u.return||u.return()}finally{if(i)throw a}}},C=e.contextStreamObservers[Symbol.iterator]();case 69:if(_=(E=C.next()).done){t.next=76;break}if("continue"!==O()){t.next=73;break}return t.abrupt("continue",73);case 73:_=!0,t.next=69;break;case 76:t.next=82;break;case 78:t.prev=78,t.t2=t.catch(66),$=!0,P=t.t2;case 82:t.prev=82,t.prev=83,_||null==C.return||C.return();case 85:if(t.prev=85,!$){t.next=88;break}throw P;case 88:return t.finish(85);case 89:return t.finish(82);case 90:case"end":return t.stop()}}),t,null,[[5,23,27,35],[28,,30,34],[38,50,54,62],[55,,57,61],[66,78,82,90],[83,,85,89]])})));return function(e,n,r,i,a){return t.apply(this,arguments)}}())}},{key:"isNativeExtension",value:function(e){var t=[window._extensions_manager_location,window._batch_manager_location],n=e.content.hosted_url,r=e.content.local_url&&e.content.local_url.replace("sn://","");return t.includes(n)||t.includes(r)}},{key:"deinit",value:(v=Oa(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Aa(Ia(t.prototype),"deinit",this).call(this),window&&(window.removeEventListener("focus",this.detectFocusChange,!0),window.removeEventListener("blur",this.detectFocusChange,!0),window.removeEventListener("message",this.onWindowMessage));case 2:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"configureForNonMobileUsage",value:function(){window.addEventListener?window.addEventListener("focus",this.detectFocusChange,!0):window.attachEvent("onfocusout",this.detectFocusChange),window.addEventListener?window.addEventListener("blur",this.detectFocusChange,!0):window.attachEvent("onblur",this.detectFocusChange),window.addEventListener("message",this.onWindowMessage)}},{key:"configureForDesktop",value:function(){var e=this;this.desktopManager.registerUpdateObserver((function(t){t.active&&t.isTheme()&&e.postActiveThemesToAllComponents()}))}},{key:"postActiveThemesToAllComponents",value:function(){var e=!0,t=!1,n=void 0;try{for(var r,i=this.components[Symbol.iterator]();!(e=(r=i.next()).done);e=!0){var a=r.value;!a.isTheme()&&a.active&&a.window&&this.postActiveThemesToComponent(a)}}catch(e){t=!0,n=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw n}}}},{key:"getActiveThemes",value:function(){return this.componentsForArea(ot).filter((function(e){return e.active}))}},{key:"urlsForActiveThemes",value:function(){var e=this;return this.getActiveThemes().map((function(t){return e.urlForComponent(t)}))}},{key:"postActiveThemesToComponent",value:function(e){var t={themes:this.urlsForActiveThemes()};this.sendMessageToComponent(e,{action:"themes",data:t})}},{key:"contextItemDidChangeInArea",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=this.handlers[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;if(!1!==o.areas.includes(e)||o.areas.includes("*")){var s=this.contextStreamObservers.filter((function(t){return t.component.area===e})),c=!0,u=!1,l=void 0;try{for(var f,p=s[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var h=f.value;if(o.contextRequestHandler){var d=o.contextRequestHandler(h.component);d&&this.sendContextItemInReply(h.component,d,h.originalMessage)}}}catch(e){u=!0,l=e}finally{try{c||null==p.return||p.return()}finally{if(u)throw l}}}}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}}},{key:"setComponentHidden",value:function(e,t){if(t)e.hidden=!0;else if(e.hidden){e.hidden=!1;var n=pt()(this.contextStreamObservers,{identifier:e.uuid});n&&this.handleStreamContextItemMessage(e,n.originalMessage);var r=pt()(this.streamObservers,{identifier:e.uuid});r&&this.handleStreamItemsMessage(e,r.originalMessage)}}},{key:"jsonForItem",value:function(e,n,r){var i={uuid:e.uuid,content_type:e.content_type,created_at:e.created_at,updated_at:e.updated_at,deleted:e.deleted};return i.content=e.collapseContent(),i.clientData=e.getDomainDataItem(n.getClientDataKey(),t.ClientDataDomain)||{},!r||r!==Ln.RemoteSaved&&r!==Ln.LocalSaved||(i.isMetadataUpdate=!0),this.removePrivatePropertiesFromResponseItems([i],n),i}},{key:"sendItemsInReply",value:function(e,t,n,r){var i=this;this.log("Web|componentManager|sendItemsInReply",e,t,n);var a={items:{}},o=t.map((function(t){return i.jsonForItem(t,e,r)}));a.items=o,this.replyToMessage(e,n,a)}},{key:"sendContextItemInReply",value:function(e,t,n,r){this.log("Web|componentManager|sendContextItemInReply",e,t,n);var i={item:this.jsonForItem(t,e,r)};this.replyToMessage(e,n,i)}},{key:"replyToMessage",value:function(e,t,n){var r={action:"reply",original:t,data:n};this.sendMessageToComponent(e,r)}},{key:"sendMessageToComponent",value:function(e,t){var n=[Ka,"themes"];if(!e.hidden||n.includes(t.action)){this.log("Web|sendMessageToComponent",e,t);var r=this.urlForComponent(e);r.startsWith("http")||r.startsWith("file")||(r=window.location.href+r),e.window||this.alertService.alert({text:"Standard Notes is trying to communicate with ".concat(e.name,", \n but an error is occurring. Please restart this extension and try again.")}),this.isMobile&&(t=JSON.stringify(t)),e.window.postMessage(t,r)}else this.log("Component disabled for current item, ignoring messages.",e.name)}},{key:"componentsForArea",value:function(e){return this.components.filter((function(t){return t.area===e}))}},{key:"urlForComponent",value:function(e){if(e.offlineOnly&&!this.isDesktop)return null;if(e.offlineOnly||this.isDesktop&&e.local_url)return e.local_url&&e.local_url.replace("sn://",this.desktopManager.getExtServerHost());var t=e.hosted_url||e.legacy_url;if(this.isMobile){var n=this.platform===k.Ios?"localhost":"10.0.2.2";t=t.replace("localhost",n).replace("sn.local",n)}return t}},{key:"componentForUrl",value:function(e){return this.components.filter((function(t){return t.hosted_url===e||t.legacy_url===e}))[0]}},{key:"componentForSessionKey",value:function(e){var t=pt()(this.components,{sessionKey:e});if(!t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.handlers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(s.componentForSessionKeyHandler&&(t=s.componentForSessionKeyHandler(e)))break}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}}return t}},{key:"handleMessage",value:function(e,t){var n=this;if(!e)return this.log("Component not defined for message, returning",t),void this.alertService.alert({text:"An extension is trying to communicate with Standard Notes,but there is an error establishing a bridge. Please restart the app and try again."});var r=[Ra,"associate-item","deassociate-item",La,Na,Fa,Ua];if(e.readonly&&r.includes(t.action))this.alertService.alert({text:"The extension ".concat(e.name," is trying to save, but it is in a locked state and cannot accept changes.")});else{if(t.action===Ma)this.handleStreamItemsMessage(e,t);else if(t.action===Ta)this.handleStreamContextItemMessage(e,t);else if(t.action===Ua)this.handleSetComponentDataMessage(e,t);else if(t.action===Fa)this.handleDeleteItemsMessage(e,t);else if(t.action===Na||t.action===La)this.handleCreateItemsMessage(e,t);else if(t.action===Ra)this.handleSaveItemsMessage(e,t);else if("toggle-activate-component"===t.action){var i=this.modelManager.findItem(t.data.uuid);this.handleToggleComponentMessage(e,i,t)}else"request-permissions"===t.action?this.handleRequestPermissionsMessage(e,t):"install-local-component"===t.action?this.handleInstallLocalComponentMessage(e,t):"duplicate-item"===t.action&&this.handleDuplicateItemMessage(e,t);var a=!0,o=!1,s=void 0;try{for(var c,u=function(){var r=c.value;r.actionHandler&&(r.areas.includes(e.area)||r.areas.includes("*"))&&n.timeout((function(){r.actionHandler(e,t.action,t.data)}))},l=this.handlers[Symbol.iterator]();!(a=(c=l.next()).done);a=!0)u()}catch(e){o=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(o)throw s}}}}},{key:"removePrivatePropertiesFromResponseItems",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(n.incoming){var r=["updated_at"],i=!0,a=!1,o=void 0;try{for(var s,c=e[Symbol.iterator]();!(i=(s=c.next()).done);i=!0){var u=s.value;if(u.isItem)console.error("Attempting to pass object. Use JSON.");else{var l=!0,f=!1,p=void 0;try{for(var h,d=r[Symbol.iterator]();!(l=(h=d.next()).done);l=!0){var v=h.value;delete u[v]}}catch(e){f=!0,p=e}finally{try{l||null==d.return||d.return()}finally{if(f)throw p}}}}}catch(e){a=!0,o=e}finally{try{i||null==c.return||c.return()}finally{if(a)throw o}}}if(!t||!this.isNativeExtension(t)){var y=["autoupdateDisabled","permissions","active"];n&&n.includeUrls&&(y=y.concat(["url","hosted_url","local_url"]));var m=!0,g=!1,b=void 0;try{for(var w,k=e[Symbol.iterator]();!(m=(w=k.next()).done);m=!0){var x=w.value;if(x.isItem)console.error("Attempting to pass object. Use JSON.");else{var S=!0,_=!1,$=void 0;try{for(var P,O=y[Symbol.iterator]();!(S=(P=O.next()).done);S=!0){var C=P.value;delete x.content[C]}}catch(e){_=!0,$=e}finally{try{S||null==O.return||O.return()}finally{if(_)throw $}}}}}catch(e){g=!0,b=e}finally{try{m||null==k.return||k.return()}finally{if(g)throw b}}}}},{key:"handleStreamItemsMessage",value:function(e,t){var n=this,r=[{name:Ma,content_types:t.data.content_types.sort()}];this.runWithPermissions(e,r,(function(){pt()(n.streamObservers,{identifier:e.uuid})||n.streamObservers.push({identifier:e.uuid,component:e,originalMessage:t,contentTypes:t.data.content_types});var r=[],i=!0,a=!1,o=void 0;try{for(var s,c=t.data.content_types[Symbol.iterator]();!(i=(s=c.next()).done);i=!0){var u=s.value;r=r.concat(n.modelManager.validItemsForContentType(u))}}catch(e){a=!0,o=e}finally{try{i||null==c.return||c.return()}finally{if(a)throw o}}n.sendItemsInReply(e,r,t)}))}},{key:"handleStreamContextItemMessage",value:function(e,t){var n=this,r=[{name:Ta}];this.runWithPermissions(e,r,(function(){pt()(n.contextStreamObservers,{identifier:e.uuid})||n.contextStreamObservers.push({identifier:e.uuid,component:e,originalMessage:t});var r=!0,i=!1,a=void 0;try{for(var o,s=n.handlersForArea(e.area)[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var c=o.value;if(c.contextRequestHandler){var u=c.contextRequestHandler(e);u&&n.sendContextItemInReply(e,u,t)}}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}}))}},{key:"isItemIdWithinComponentContextJurisdiction",value:function(e,t){return this.itemIdsInContextJurisdictionForComponent(t).includes(e)}},{key:"itemIdsInContextJurisdictionForComponent",value:function(e){var t=[],n=!0,r=!1,i=void 0;try{for(var a,o=this.handlersForArea(e.area)[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(s.contextRequestHandler){var c=s.contextRequestHandler(e);c&&t.push(c.uuid)}}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}return t}},{key:"handlersForArea",value:function(e){return this.handlers.filter((function(t){return t.areas.includes(e)}))}},{key:"handleSaveItemsMessage",value:(d=Oa(a.a.mark((function e(n,r){var i,o,s,c,u,l,f,p,h,d,v,y=this;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=r.data.items,o=[],s=this.itemIdsInContextJurisdictionForComponent(n),c=i.slice(),u=!0,l=!1,f=void 0,e.prev=7,p=i.slice()[Symbol.iterator]();case 9:if(u=(h=p.next()).done){e.next=18;break}if(d=h.value,!s.includes(d.uuid)){e.next=15;break}return o.push({name:Ta}),dt()(c,d),e.abrupt("break",18);case 15:u=!0,e.next=9;break;case 18:e.next=24;break;case 20:e.prev=20,e.t0=e.catch(7),l=!0,f=e.t0;case 24:e.prev=24,e.prev=25,u||null==p.return||p.return();case 27:if(e.prev=27,!l){e.next=30;break}throw f;case 30:return e.finish(27);case 31:return e.finish(24);case 32:c.length>0&&(v=_a()(c.map((function(e){return e.content_type}))).sort(),o.push({name:Ma,content_types:v})),this.runWithPermissions(n,o,Oa(a.a.mark((function e(){var o,s,c,u,l,f,p,h,d,v,m,g,b,w,k,x,S,_,$,P;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(y.removePrivatePropertiesFromResponseItems(i,n,{includeUrls:!0,incoming:!0}),o=i.map((function(e){return e.uuid})),s=y.modelManager.findItems(o),c=0,u=!0,l=!1,f=void 0,e.prev=7,p=s[Symbol.iterator]();!(u=(h=p.next()).done);u=!0)(d=h.value).locked&&(yt()(i,{uuid:d.uuid}),c++);e.next=15;break;case 11:e.prev=11,e.t0=e.catch(7),l=!0,f=e.t0;case 15:e.prev=15,e.prev=16,u||null==p.return||p.return();case 18:if(e.prev=18,!l){e.next=21;break}throw f;case 21:return e.finish(18);case 22:return e.finish(15);case 23:return c>0&&(v=1===c?"item":"items",m=1===c?"is":"are",y.alertService.alert({title:"Items Locked",text:"".concat(c," ").concat(v," you are attempting to save ").concat(m," locked and cannot be edited.")})),g=i.map((function(e){return Ri({object:e})})),e.next=27,y.modelManager.mapPayloadsToLocalItems({paylods:g,source:Ln.ComponentRetrieved,sourceKey:n.uuid});case 27:b=e.sent,w=!0,k=!1,x=void 0,e.prev=31,S=i[Symbol.iterator]();case 33:if(w=(_=S.next()).done){e.next=46;break}if($=_.value,P=pt()(b,{uuid:$.uuid})){e.next=39;break}return y.alertService.alert({text:"The extension ".concat(n.name," is trying to save an item with type")+"".concat($.content_type,", but that item does not exist. Please restart this extension and try again.")}),e.abrupt("continue",43);case 39:if(P.locked){e.next=43;break}return $.clientData&&P.setDomainDataItem(n.getClientDataKey(),$.clientData,t.ClientDataDomain),e.next=43,y.modelManager.setItemDirty(P,!0,!0,Ln.ComponentRetrieved,n.uuid);case 43:w=!0,e.next=33;break;case 46:e.next=52;break;case 48:e.prev=48,e.t1=e.catch(31),k=!0,x=e.t1;case 52:e.prev=52,e.prev=53,w||null==S.return||S.return();case 55:if(e.prev=55,!k){e.next=58;break}throw x;case 58:return e.finish(55);case 59:return e.finish(52);case 60:y.syncService.sync().then((function(e){var t=Object.assign({},r);t.action=e&&e.error?"save-error":"save-success",y.replyToMessage(n,r,{error:e&&e.error}),y.handleMessage(n,t)}));case 61:case"end":return e.stop()}}),e,null,[[7,11,15,23],[16,,18,22],[31,48,52,60],[53,,55,59]])}))));case 34:case"end":return e.stop()}}),e,this,[[7,20,24,32],[25,,27,31]])}))),function(e,t){return d.apply(this,arguments)})},{key:"handleDuplicateItemMessage",value:function(e,t){var n=this,r=t.data.item,i=this.modelManager.findItem(r.uuid),o=[{name:Ma,content_types:[i.content_type]}];this.runWithPermissions(e,o,Oa(a.a.mark((function r(){var o;return a.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,n.modelManager.duplicateItem({item:i});case 2:o=r.sent,n.syncService.sync(),n.replyToMessage(e,t,{item:n.jsonForItem(o,e)});case 5:case"end":return r.stop()}}),r)}))))}},{key:"handleCreateItemsMessage",value:function(e,n){var r=this,i=n.data.item?[n.data.item]:n.data.items,o=_a()(i.map((function(e){return e.content_type}))),s=[{name:Ma,content_types:o}];this.runWithPermissions(e,s,Oa(a.a.mark((function o(){var s,c,u,l,f,p,h,d,v,y;return a.a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:r.removePrivatePropertiesFromResponseItems(i,e,{incoming:!0}),s=[],c=!0,u=!1,l=void 0,a.prev=5,f=i[Symbol.iterator]();case 7:if(c=(p=f.next()).done){a.next=21;break}return h=p.value,d=Ni({object:h,source:Ln.RemoteRetrieved}),v=Cn(d),h.clientData&&v.setDomainDataItem(e.getClientDataKey(),h.clientData,t.ClientDataDomain),r.modelManager.addItem(v),a.next=15,r.modelManager.resolveReferencesForItem(v,!0);case 15:return a.next=17,r.modelManager.setItemDirty(v,!0);case 17:s.push(v);case 18:c=!0,a.next=7;break;case 21:a.next=27;break;case 23:a.prev=23,a.t0=a.catch(5),u=!0,l=a.t0;case 27:a.prev=27,a.prev=28,c||null==f.return||f.return();case 30:if(a.prev=30,!u){a.next=33;break}throw l;case 33:return a.finish(30);case 34:return a.finish(27);case 35:r.syncService.sync(),y=n.action===La?{item:r.jsonForItem(s[0],e)}:{items:s.map((function(t){return r.jsonForItem(t,e)}))},r.replyToMessage(e,n,y);case 38:case"end":return a.stop()}}),o,null,[[5,23,27,35],[28,,30,34]])}))))}},{key:"handleDeleteItemsMessage",value:function(e,t){var n=this,r=_a()(t.data.items.map((function(e){return e.content_type}))).sort(),i=[{name:Ma,content_types:r}];this.runWithPermissions(e,i,Oa(a.a.mark((function r(){var i,o,s,u,l,f,p,h,d,v,y;return a.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=t.data.items,o=1===i.length?"item":"items",s=null,u=!0,r.next=6,n.alertService.confirm({text:"Are you sure you want to delete ".concat(i.length," ").concat(o,"?")}).catch((function(){u=!1}));case 6:if(!u){r.next=45;break}l=!0,f=!1,p=void 0,r.prev=10,h=i[Symbol.iterator]();case 12:if(l=(d=h.next()).done){r.next=27;break}if(v=d.value,y=n.modelManager.findItem(v.uuid)){r.next=18;break}return n.alertService.alert({text:"The item you are trying to delete cannot be found."}),r.abrupt("continue",24);case 18:if(![c.Component,c.Theme].includes(y.content_type)){r.next=21;break}return r.next=21,n.deactivateComponent(y,!0);case 21:return r.next=23,n.modelManager.setItemToBeDeleted(y);case 23:n.modelManager.notifyMappingObservers([y],Ln.RemoteSaved);case 24:l=!0,r.next=12;break;case 27:r.next=33;break;case 29:r.prev=29,r.t0=r.catch(10),f=!0,p=r.t0;case 33:r.prev=33,r.prev=34,l||null==h.return||h.return();case 36:if(r.prev=36,!f){r.next=39;break}throw p;case 39:return r.finish(36);case 40:return r.finish(33);case 41:n.syncService.sync(),s={deleted:!0},r.next=46;break;case 45:s={deleted:!1};case 46:n.replyToMessage(e,t,s);case 47:case"end":return r.stop()}}),r,null,[[10,29,33,41],[34,,36,40]])}))))}},{key:"handleRequestPermissionsMessage",value:function(e,t){var n=this;this.runWithPermissions(e,t.data.permissions,(function(){n.replyToMessage(e,t,{approved:!0})}))}},{key:"handleSetComponentDataMessage",value:function(e,t){var n=this;this.runWithPermissions(e,[],Oa(a.a.mark((function r(){return a.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return e.componentData=t.data.componentData,r.next=3,n.modelManager.setItemDirty(e,!0);case 3:n.syncService.sync();case 4:case"end":return r.stop()}}),r)}))))}},{key:"handleToggleComponentMessage",value:function(e,t,n){this.toggleComponent(t)}},{key:"toggleComponent",value:(h=Oa(a.a.mark((function e(t){var n,r=this;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("modal"!==t.area){e.next=4;break}this.openModalComponent(t),e.next=18;break;case 4:if(!t.active){e.next=9;break}return e.next=7,this.deactivateComponent(t);case 7:e.next=18;break;case 9:if(t.content_type!==c.Theme){e.next=16;break}return n=this.getActiveThemes(),e.next=13,this.activateComponent(t);case 13:t.isLayerable()||setTimeout(Oa(a.a.mark((function e(){var t,i,o,s,c,u;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=!0,i=!1,o=void 0,e.prev=3,s=n[Symbol.iterator]();case 5:if(t=(c=s.next()).done){e.next=13;break}if(!(u=c.value)||u.isLayerable()){e.next=10;break}return e.next=10,r.deactivateComponent(u);case 10:t=!0,e.next=5;break;case 13:e.next=19;break;case 15:e.prev=15,e.t0=e.catch(3),i=!0,o=e.t0;case 19:e.prev=19,e.prev=20,t||null==s.return||s.return();case 22:if(e.prev=22,!i){e.next=25;break}throw o;case 25:return e.finish(22);case 26:return e.finish(19);case 27:case"end":return e.stop()}}),e,null,[[3,15,19,27],[20,,22,26]])}))),10),e.next=18;break;case 16:return e.next=18,this.activateComponent(t);case 18:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"handleInstallLocalComponentMessage",value:function(e,t){if(this.isNativeExtension(e)){var n=this.modelManager.findItem(t.data.uuid);this.desktopManager.installComponent(n)}}},{key:"runWithPermissions",value:function(e,t,n){e.permissions||(e.permissions=[]),t=Object(o.a)(t);var r=e.permissions,i=!0,a=!1,s=void 0;try{for(var c,u=function(){var e=c.value,n=r.find((function(t){return t.name===e.name}));if(!n)return"continue";var i=e.content_types;if(!i)return dt()(t,e),"continue";var a=!0,o=!1,s=void 0;try{for(var u,l=n.content_types[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var f=u.value;dt()(i,f)}}catch(e){o=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(o)throw s}}0===i.length&&dt()(t,e)},l=t.slice()[Symbol.iterator]();!(i=(c=l.next()).done);i=!0)u()}catch(e){a=!0,s=e}finally{try{i||null==l.return||l.return()}finally{if(a)throw s}}t.length>0?this.promptForPermissions(e,t,(function(e){e&&n()})):n()}},{key:"promptForPermissions",value:function(e,t,n){var r=this,i={};i.component=e,i.permissions=t,i.permissionsString=this.permissionsStringForPermissions(t,e),i.actionBlock=n,i.callback=function(){var n=Oa(a.a.mark((function n(o){var s,c,u,l,f,p;return a.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!o){n.next=24;break}for(s=!0,c=!1,u=void 0,n.prev=4,l=function(){var t=p.value,n=e.permissions.find((function(e){return e.name===t.name}));if(n){var r=n.content_types||[];n.content_types=_a()(r.concat(t.content_types))}else e.permissions.push(t)},f=t[Symbol.iterator]();!(s=(p=f.next()).done);s=!0)l();n.next=13;break;case 9:n.prev=9,n.t0=n.catch(4),c=!0,u=n.t0;case 13:n.prev=13,n.prev=14,s||null==f.return||f.return();case 16:if(n.prev=16,!c){n.next=19;break}throw u;case 19:return n.finish(16);case 20:return n.finish(13);case 21:return n.next=23,r.modelManager.setItemDirty(e,!0);case 23:r.syncService.sync();case 24:r.permissionDialogs=r.permissionDialogs.filter((function(n){return n===i?(n.actionBlock&&n.actionBlock(o),!1):!!(n.component!==e||n.permissions!==t&&(r=t,n.permissions.some((function(e){return!r.find((function(t){return JSON.stringify(t)===JSON.stringify(e)}))}))))||(o&&n.actionBlock&&n.actionBlock(o),!1);var r})),r.permissionDialogs.length>0&&r.presentPermissionsDialog(r.permissionDialogs[0]);case 26:case"end":return n.stop()}}),n,null,[[4,9,13,21],[14,,16,20]])})));return function(e){return n.apply(this,arguments)}}();var o=pt()(this.permissionDialogs,{component:e});this.permissionDialogs.push(i),o?this.log("Existing dialog, not presenting."):this.presentPermissionsDialog(i)}},{key:"presentPermissionsDialog",value:function(e){throw"Must override SNComponentManager.presentPermissionsDialog"}},{key:"openModalComponent",value:function(e){throw"Must override SNComponentManager.presentPermissionsDialog"}},{key:"registerHandler",value:function(e){this.handlers.push(e)}},{key:"deregisterHandler",value:function(e){var t=pt()(this.handlers,{identifier:e});t?this.handlers.splice(this.handlers.indexOf(t),1):this.log("Attempting to deregister non-existing handler")}},{key:"registerComponentWindow",value:(p=Oa(a.a.mark((function e(t,n){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.window===n&&this.log("Web|componentManager","attempting to re-register same component window."),this.log("Web|componentManager|registerComponentWindow",t),t.window=n,e.next=5,j.GenerateUuid();case 5:t.sessionKey=e.sent,this.sendMessageToComponent(t,{action:Ka,sessionKey:t.sessionKey,componentData:t.componentData,data:{uuid:t.uuid,environment:(a=this.environment,(b(o={},w.Web,"web"),b(o,w.Desktop,"desktop"),b(o,w.Mobile,"mobile"),o)[a]),platform:(r=this.platform,(b(i={},k.MacWeb,"mac-web"),b(i,k.MacDesktop,"mac-desktop"),b(i,k.LinuxWeb,"linux-web"),b(i,k.LinuxDesktop,"linux-desktop"),b(i,k.WindowsWeb,"windows-web"),b(i,k.WindowsDesktop,"windows-desktop"),b(i,k.Ios,"ios"),b(i,k.Android,"android"),i)[r]),activeThemeUrls:this.urlsForActiveThemes()}}),this.postActiveThemesToComponent(t),this.desktopManager&&this.desktopManager.notifyComponentActivation(t);case 9:case"end":return e.stop()}var r,i,a,o}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"activateComponent",value:(f=Oa(a.a.mark((function e(t){var n,r,i,o,s,c,u,l,f=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=f.length>1&&void 0!==f[1]&&f[1],r=!0!==t.active,t.active=!0,i=!0,o=!1,s=void 0,e.prev=6,c=this.handlers[Symbol.iterator]();!(i=(u=c.next()).done);i=!0)((l=u.value).areas.includes(t.area)||l.areas.includes("*"))&&l.activationHandler&&l.activationHandler(t);e.next=14;break;case 10:e.prev=10,e.t0=e.catch(6),o=!0,s=e.t0;case 14:e.prev=14,e.prev=15,i||null==c.return||c.return();case 17:if(e.prev=17,!o){e.next=20;break}throw s;case 20:return e.finish(17);case 21:return e.finish(14);case 22:if(!r||n){e.next=26;break}return e.next=25,this.modelManager.setItemDirty(t,!0);case 25:this.syncService.sync();case 26:this.activeComponents.includes(t)||this.activeComponents.push(t),t.area===ot&&this.postActiveThemesToAllComponents();case 28:case"end":return e.stop()}}),e,this,[[6,10,14,22],[15,,17,21]])}))),function(e){return f.apply(this,arguments)})},{key:"deactivateComponent",value:(l=Oa(a.a.mark((function e(t){var n,r,i,o,s,c,u,l,f=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=f.length>1&&void 0!==f[1]&&f[1],r=!1!==t.active,t.active=!1,t.sessionKey=null,i=!0,o=!1,s=void 0,e.prev=7,c=this.handlers[Symbol.iterator]();!(i=(u=c.next()).done);i=!0)((l=u.value).areas.includes(t.area)||l.areas.includes("*"))&&l.activationHandler&&l.activationHandler(t);e.next=15;break;case 11:e.prev=11,e.t0=e.catch(7),o=!0,s=e.t0;case 15:e.prev=15,e.prev=16,i||null==c.return||c.return();case 18:if(e.prev=18,!o){e.next=21;break}throw s;case 21:return e.finish(18);case 22:return e.finish(15);case 23:if(!r||n){e.next=27;break}return e.next=26,this.modelManager.setItemDirty(t,!0);case 26:this.syncService.sync();case 27:dt()(this.activeComponents,t),this.streamObservers=this.streamObservers.filter((function(e){return e.component!==t})),this.contextStreamObservers=this.contextStreamObservers.filter((function(e){return e.component!==t})),t.area===ot&&this.postActiveThemesToAllComponents();case 31:case"end":return e.stop()}}),e,this,[[7,11,15,23],[16,,18,22]])}))),function(e){return l.apply(this,arguments)})},{key:"reloadComponent",value:(u=Oa(a.a.mark((function e(t){var n,r,i,o,s,c,u=this;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t.active=!1,n=!0,r=!1,i=void 0,e.prev=4,o=this.handlers[Symbol.iterator]();!(n=(s=o.next()).done);n=!0)((c=s.value).areas.includes(t.area)||c.areas.includes("*"))&&c.activationHandler&&c.activationHandler(t);e.next=12;break;case 8:e.prev=8,e.t0=e.catch(4),r=!0,i=e.t0;case 12:e.prev=12,e.prev=13,n||null==o.return||o.return();case 15:if(e.prev=15,!r){e.next=18;break}throw i;case 18:return e.finish(15);case 19:return e.finish(12);case 20:return this.streamObservers=this.streamObservers.filter((function(e){return e.component!==t})),this.contextStreamObservers=this.contextStreamObservers.filter((function(e){return e.component!==t})),t.area===ot&&this.postActiveThemesToAllComponents(),e.abrupt("return",new Promise((function(e,n){u.timeout((function(){t.active=!0;var n=!0,r=!1,i=void 0;try{for(var a,o=u.handlers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;(s.areas.includes(t.area)||s.areas.includes("*"))&&(s.activationHandler&&s.activationHandler(t),e())}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}u.activeComponents.includes(t)||u.activeComponents.push(t),t.area===ot&&u.postActiveThemesToAllComponents(),e()}))})));case 24:case"end":return e.stop()}}),e,this,[[4,8,12,20],[13,,15,19]])}))),function(e){return u.apply(this,arguments)})},{key:"deleteComponent",value:(i=Oa(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.modelManager.setItemToBeDeleted(t);case 2:this.syncService.sync();case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"isComponentActive",value:function(e){return e.active}},{key:"iframeForComponent",value:function(e){for(var t=0,n=Array.from(document.getElementsByTagName("iframe"));t0?e===t-1?2===t?" and ":", and ":", ":""};return e.forEach((function(e,a){if(e.name===Ma){for(var o=e.content_types.map((function(e){var t,n,r=(t=e,(n={},s(n,c.Note,"note"),s(n,c.Tag,"tag"),s(n,c.SmartTag,"smart tag"),s(n,c.ActionsExtension,"action-based extension"),s(n,c.Component,"component"),s(n,c.Editor,"editor"),s(n,c.Theme,"theme"),s(n,c.ServerExtension,"server extension"),s(n,c.Mfa,"two-factor authentication setting"),s(n,c.FilesafeCredentials,"FileSafe credential"),s(n,c.FilesafeFileMetadata,"FileSafe file"),s(n,c.FilesafeIntegration,"FileSafe integration"),n)[t]);return r?r+"s":"items of type "+e})),u="",l=0;l=2&&a0&&(n=this.urlForUrlAndParams(n,r)),a.open(t,n,!0),a.setRequestHeader("Content-type","application/json"),i&&a.setRequestHeader("Authorization","Bearer "+i),a}},{key:"runRequest",value:(i=za(a.a.mark((function e(t){var n,r,i,o=this;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.request,r=t.verb,i=t.params,e.abrupt("return",new Promise((function(e,t){n.onreadystatechange=function(){o.stateChangeHandlerForRequest(n,e,t)},"post"===r||"patch"===r?n.send(JSON.stringify(i)):n.send()})));case 2:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"stateChangeHandlerForRequest",value:function(e,t,n){if(4===e.readyState){var r=e.responseText;if(r)try{r=JSON.parse(r)}catch(e){}Object(o.m)(r)||(r={});var i=e.status;i>=200&&i<=299?(r.status=i,t(r)):(console.error("Request error:",r),Object(o.n)(r)&&(r={error:{message:r}}),r.error||(r.error={status:i}),r.status=i,n(r))}}},{key:"urlForUrlAndParams",value:function(e,t){var n=Object.keys(t).map((function(e){return e+"="+encodeURIComponent(t[e])})).join("&");return e.includes("?")?e+"&"+n:e+"?"+n}}])&&qa(n.prototype,r),t}(qi),Za=n(53),Xa=n.n(Za);function eo(e){return(eo="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 to(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return n}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function no(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function ro(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){no(a,r,i,o,s,"next",e)}function s(e){no(a,r,i,o,s,"throw",e)}o(void 0)}))}}function io(e,t){for(var n=0;n0)){e.next=94;break}return e.next=94,this.notifyCreationObservers(s,r,i);case 94:return e.next=96,this.notifyMappingObservers(o,r,i);case 96:return e.abrupt("return",b);case 97:case"end":return e.stop()}}),e,this,[[7,42,46,54],[47,,49,53],[69,73,77,85],[78,,80,84]])}))),function(e){return $.apply(this,arguments)})},{key:"insertItem",value:function(e){var t=e.item;this.insertItems({items:[t]})}},{key:"insertItems",value:function(e){var t=e.items,n=e.globalOnly,r=!0,i=!1,a=void 0;try{for(var o,s=t[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;if(!this.itemsHash[u.uuid]&&(this.itemsHash[u.uuid]=u,this.items.push(u),!n))if(u.content_type===c.ItemsKey)this.itemsKeys.unshift(u);else if(u.content_type===c.Tag){var l=Xa()(this.tags,u,(function(e){return e.title?e.title.toLowerCase():""}));this.tags.splice(l,0,u)}else u.content_type===c.Note?this.notes.unshift(u):u.content_type===c.Component&&this.components.unshift(u)}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}}},{key:"addItem",value:(_=ro(a.a.mark((function e(t){var n,r=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.length>1&&void 0!==r[1]&&r[1],e.abrupt("return",this.addItems([t],n));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"addItems",value:(S=ro(a.a.mark((function e(t){var n,r=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r.length>1&&void 0!==r[1]&&r[1],console.warn("ModelManager.addItems is depracated. Use mapPayloadsToLocalItems instead."),n=t.map((function(e){return Ri({object:e})})),e.next=5,this.mapPayloadsToLocalItems({payloads:n});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"resolveRelationshipWhenItemAvailable",value:function(e){var t=e.interestedItem,n=e.missingItemId,r=this.resolveQueue[n]||[];r.push(t),this.resolveQueue[n]=r}},{key:"popItemsInterestedInMissingItem",value:function(e){var t=e.item,n=this.resolveQueue[t.uuid];return delete this.resolveQueue[t.uuid],n||[]}},{key:"resolveReferencesForItem",value:(x=ro(a.a.mark((function e(t){var n,r,i,o,s,c,u,l,f,p,h,d,v,y,m,g=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=g.length>1&&void 0!==g[1]&&g[1],!t.errorDecrypting){e.next=3;break}return e.abrupt("return");case 3:if(r=t.content,t.updateLocalRelationships(),r.references&&!t.deleted){e.next=7;break}return e.abrupt("return");case 7:i=r.references.slice(),o=i.map((function(e){return e.uuid})),s=!0,c=this.findItems(o,s),u=!0,l=!1,f=void 0,e.prev=14,p=c.entries()[Symbol.iterator]();case 16:if(u=(h=p.next()).done){e.next=30;break}if(d=to(h.value,2),v=d[0],!(y=d[1])){e.next=25;break}if(t.addItemAsRelationship(y),!n){e.next=23;break}return e.next=23,this.setItemDirty(y,!0);case 23:e.next=27;break;case 25:m=o[v],this.resolveRelationshipWhenItemAvailable({interestedItem:t,missingItemId:m});case 27:u=!0,e.next=16;break;case 30:e.next=36;break;case 32:e.prev=32,e.t0=e.catch(14),l=!0,f=e.t0;case 36:e.prev=36,e.prev=37,u||null==p.return||p.return();case 39:if(e.prev=39,!l){e.next=42;break}throw f;case 42:return e.finish(39);case 43:return e.finish(36);case 44:case"end":return e.stop()}}),e,this,[[14,32,36,44],[37,,39,43]])}))),function(e){return x.apply(this,arguments)})},{key:"addCreationObserver",value:function(e){var t=this;return this.creationObservers.push(e),function(){yt()(t.creationObservers,e)}}},{key:"notifyCreationObservers",value:(k=ro(a.a.mark((function e(t,n,r){var i,o,s,c,u,l;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=!0,o=!1,s=void 0,e.prev=3,c=this.creationObservers[Symbol.iterator]();case 5:if(i=(u=c.next()).done){e.next=12;break}return l=u.value,e.next=9,l.callback({items:t,source:n,sourceKey:r});case 9:i=!0,e.next=5;break;case 12:e.next=18;break;case 14:e.prev=14,e.t0=e.catch(3),o=!0,s=e.t0;case 18:e.prev=18,e.prev=19,i||null==c.return||c.return();case 21:if(e.prev=21,!o){e.next=24;break}throw s;case 24:return e.finish(21);case 25:return e.finish(18);case 26:case"end":return e.stop()}}),e,this,[[3,14,18,26],[19,,21,25]])}))),function(e,t,n){return k.apply(this,arguments)})},{key:"addMappingObserver",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;Array.isArray(e)||(e=[e]);var i={types:e,priority:r,callback:t};return this.mappingObservers.push(i),function(){dt()(n.mappingObservers,i)}}},{key:"notifyMappingObservers",value:(w=ro(a.a.mark((function e(t,n,r){var i,o,s,c,u,l,f;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=this.mappingObservers.sort((function(e,t){return e.priority0)){e.next=26;break}return e.next=26,i.callback(o,s,c,n,r);case 26:case"end":return e.stop()}}),e,null,[[7,11,15,23],[16,,18,22]])})),l=i[Symbol.iterator]();case 7:if(o=(f=l.next()).done){e.next=12;break}return e.delegateYield(u(),"t0",9);case 9:o=!0,e.next=7;break;case 12:e.next=18;break;case 14:e.prev=14,e.t1=e.catch(4),s=!0,c=e.t1;case 18:e.prev=18,e.prev=19,o||null==l.return||l.return();case 21:if(e.prev=21,!s){e.next=24;break}throw c;case 24:return e.finish(21);case 25:return e.finish(18);case 26:case"end":return e.stop()}}),e,this,[[4,14,18,26],[19,,21,25]])}))),function(e,t,n){return w.apply(this,arguments)})},{key:"setItemDirty",value:(b=ro(a.a.mark((function e(t){var n,r,i,o,s=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=!(s.length>1&&void 0!==s[1])||s[1],r=s.length>2?s[2]:void 0,i=s.length>3?s[3]:void 0,o=s.length>4?s[4]:void 0,t.content_type===c.Tag&&this.reorderTagLocation(t),e.abrupt("return",this.setItemsDirty([t],n,r,i,o));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"setItemsDirty",value:(g=ro(a.a.mark((function e(t){var n,r,i,o,s,c,u,l,f,p,h=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=!(h.length>1&&void 0!==h[1])||h[1],r=h.length>2?h[2]:void 0,i=h.length>3?h[3]:void 0,o=h.length>4?h[4]:void 0,s=!0,c=!1,u=void 0,e.prev=7,l=t[Symbol.iterator]();case 9:if(s=(f=l.next()).done){e.next=17;break}if((p=f.value).isItem){e.next=13;break}throw"Attempting to dirty non-item object.";case 13:p.setDirty({dirty:n,updateClientDate:r,authorized:!0});case 14:s=!0,e.next=9;break;case 17:e.next=23;break;case 19:e.prev=19,e.t0=e.catch(7),c=!0,u=e.t0;case 23:e.prev=23,e.prev=24,s||null==l.return||l.return();case 26:if(e.prev=26,!c){e.next=29;break}throw u;case 29:return e.finish(26);case 30:return e.finish(23);case 31:return e.abrupt("return",this.mapItems({items:t,source:i||Ln.LocalDirtied,sourceKey:o}));case 32:case"end":return e.stop()}}),e,this,[[7,19,23,31],[24,,26,30]])}))),function(e){return g.apply(this,arguments)})},{key:"duplicateItem",value:(m=ro(a.a.mark((function e(t){var n,r,i,o,s,c;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.item,r=t.isConflict,n.isItem){e.next=3;break}throw"Attempting to duplicate non-item object.";case 3:return i=Ri({object:n}),e.next=6,In({payload:i,baseCollection:this.getMasterCollection(),isConflict:r});case 6:return o=e.sent,e.next=9,this.mapPayloadsToLocalItems({payloads:o});case 9:return s=e.sent,c=s.find((function(e){return e.uuid===o[0].uuid})),e.abrupt("return",c);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"createItem",value:(y=ro(a.a.mark((function e(t){var n,r,i,o,s,c;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.contentType,r=t.content,i=t.add,o=t.needsSync,n){e.next=3;break}throw"Attempting to create item with no contentType";case 3:return e.t0=Ri,e.next=6,j.GenerateUuid();case 6:if(e.t1=e.sent,e.t2=n,e.t3=r,e.t4={uuid:e.t1,content_type:e.t2,content:e.t3},e.t5={object:e.t4},s=(0,e.t0)(e.t5),c=Cn(s),!i){e.next=20;break}if(this.insertItem({item:c}),!o){e.next=18;break}return e.next=18,this.setItemDirty(c);case 18:return e.next=20,this.notifyCreationObservers([c]);case 20:return e.abrupt("return",c);case 21:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"getDirtyItems",value:function(){return this.items.filter((function(e){return e.dirty&&!e.dummy&&(!e.errorDecrypting||e.deleted)}))}},{key:"setItemToBeDeleted",value:(d=ro(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.deleted=!0,t.dummy){e.next=4;break}return e.next=4,this.setItemDirty(t,!0);case 4:return e.next=6,this.handleReferencesForItemDeletion(t);case 6:this.removeItemFromRespectiveArray(t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"setItemsToBeDeleted",value:(h=ro(a.a.mark((function e(t){var n,r,i,o,s,c;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=!0,r=!1,i=void 0,e.prev=3,o=t[Symbol.iterator]();case 5:if(n=(s=o.next()).done){e.next=12;break}return c=s.value,e.next=9,this.setItemToBeDeleted(c);case 9:n=!0,e.next=5;break;case 12:e.next=18;break;case 14:e.prev=14,e.t0=e.catch(3),r=!0,i=e.t0;case 18:e.prev=18,e.prev=19,n||null==o.return||o.return();case 21:if(e.prev=21,!r){e.next=24;break}throw i;case 24:return e.finish(21);case 25:return e.finish(18);case 26:case"end":return e.stop()}}),e,this,[[3,14,18,26],[19,,21,25]])}))),function(e){return h.apply(this,arguments)})},{key:"handleReferencesForItemDeletion",value:(p=ro(a.a.mark((function e(t){var n,r,i,o,s,c,u,l,f,p,h,d,v,y;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.errorDecrypting){e.next=32;break}n=!0,r=!1,i=void 0,e.prev=4,o=t.content.references[Symbol.iterator]();case 6:if(n=(s=o.next()).done){e.next=18;break}if(c=s.value,!(u=this.findItem(c.uuid))){e.next=15;break}if(t.removeItemAsRelationship(u),!u.hasRelationshipWithItem(t)){e.next=15;break}return u.removeItemAsRelationship(t),e.next=15,this.setItemDirty(u,!0);case 15:n=!0,e.next=6;break;case 18:e.next=24;break;case 20:e.prev=20,e.t0=e.catch(4),r=!0,i=e.t0;case 24:e.prev=24,e.prev=25,n||null==o.return||o.return();case 27:if(e.prev=27,!r){e.next=30;break}throw i;case 30:return e.finish(27);case 31:return e.finish(24);case 32:l=t.allReferencingItems,f=!0,p=!1,h=void 0,e.prev=36,d=l[Symbol.iterator]();case 38:if(f=(v=d.next()).done){e.next=46;break}return(y=v.value).removeItemAsRelationship(t),e.next=43,this.setItemDirty(y,!0);case 43:f=!0,e.next=38;break;case 46:e.next=52;break;case 48:e.prev=48,e.t1=e.catch(36),p=!0,h=e.t1;case 52:e.prev=52,e.prev=53,f||null==d.return||d.return();case 55:if(e.prev=55,!p){e.next=58;break}throw h;case 58:return e.finish(55);case 59:return e.finish(52);case 60:t.resetLocalReferencePointers();case 61:case"end":return e.stop()}}),e,this,[[4,20,24,32],[25,,27,31],[36,48,52,60],[53,,55,59]])}))),function(e){return p.apply(this,arguments)})},{key:"removeItemLocally",value:(l=ro(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:yt()(this.items,{uuid:t.uuid}),delete this.itemsHash[t.uuid],this.removeItemFromRespectiveArray(t),t.isBeingRemovedLocally();case 4:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"removeItemFromRespectiveArray",value:function(e){e.content_type===c.Tag?yt()(this.tags,{uuid:e.uuid}):e.content_type===c.Note?yt()(this.notes,{uuid:e.uuid}):e.content_type===c.Component?yt()(this.components,{uuid:e.uuid}):e.content_type===c.ItemsKey&&yt()(this.itemsKeys,{uuid:e.uuid})}},{key:"getItems",value:function(e){return Array.isArray(e)?this.allItems.filter((function(t){return!t.dummy&&(e.includes(t.content_type)||e.includes("*"))})):this.managedItemsForContentType(e)||this.getItems([e])}},{key:"managedItemsForContentType",value:function(e){return e===c.Note?this.notes:e===c.Component?this.components:e===c.Tag?this.tags:null}},{key:"invalidItems",value:function(){return this.allItems.filter((function(e){return e.errorDecrypting}))}},{key:"validItemsForContentType",value:function(e){return(this.managedItemsForContentType(e)||this.allItems).filter((function(t){return!t.errorDecrypting&&(Array.isArray(e)?e.includes(t.content_type):t.content_type===e)}))}},{key:"findItem",value:function(e){return this.itemsHash[e]}},{key:"findItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var c=o.value,u=this.itemsHash[c];(u||t)&&n.push(u)}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return n}},{key:"itemsMatchingPredicate",value:function(e){return this.itemsMatchingPredicates([e])}},{key:"itemsMatchingPredicates",value:function(e){return this.filterItemsWithPredicates(this.allItems,e)}},{key:"filterItemsWithPredicates",value:function(e,t){return e.filter((function(e){if(e.deleted)return!1;var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(!e.satisfiesPredicate(s))return!1}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}return!0}))}},{key:"importPayloads",value:(u=ro(a.a.mark((function e(t){var n,r,i,o,s,c,u,l,p;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new ti({baseCollection:this.getMasterCollection(),applyCollection:new f({payloads:t,source:Ln.FileImport})}),e.next=3,n.resultingCollection();case 3:return r=e.sent,e.next=6,this.mapCollectionToLocalItems({collection:r});case 6:i=e.sent,o=!0,s=!1,c=void 0,e.prev=10,u=i[Symbol.iterator]();case 12:if(o=(l=u.next()).done){e.next=20;break}return p=l.value,e.next=16,this.setItemDirty(p,!0,!1);case 16:p.deleted=!1;case 17:o=!0,e.next=12;break;case 20:e.next=26;break;case 22:e.prev=22,e.t0=e.catch(10),s=!0,c=e.t0;case 26:e.prev=26,e.prev=27,o||null==u.return||u.return();case 29:if(e.prev=29,!s){e.next=32;break}throw c;case 32:return e.finish(29);case 33:return e.finish(26);case 34:return e.abrupt("return",i);case 35:case"end":return e.stop()}}),e,this,[[10,22,26,34],[27,,29,33]])}))),function(e){return u.apply(this,arguments)})},{key:"noteCount",value:function(){return this.notes.filter((function(e){return!e.dummy})).length}},{key:"removeAllItemsFromMemory",value:function(){var e=!0,t=!1,n=void 0;try{for(var r,i=this.items[Symbol.iterator]();!(e=(r=i.next()).done);e=!0)r.value.deleted=!0}catch(e){t=!0,n=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw n}}this.notifyMappingObservers(this.items),this.resetState()}},{key:"findTagByTitle",value:function(e){return Object(o.g)(this.tags,"title",e)}},{key:"findOrCreateTagByTitle",value:(s=ro(a.a.mark((function e(t){var n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.findTagByTitle(t)){e.next=5;break}return e.next=4,this.createItem({contentType:"Tag",content:{title:t},add:!0,needsSync:!0});case 4:n=e.sent;case 5:return e.abrupt("return",n);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"reorderTagLocation",value:function(e){dt()(this.tags,e),this.tags.splice(Xa()(this.tags,e,(function(e){return e.title?e.title.toLowerCase():""})),0,e)}},{key:"notesMatchingSmartTag",value:function(e){var t=[new v("content_type","=","Note"),e.content.predicate];if(!e.content.isTrashTag){var n=new v("content.trashed","=",!1);t.push(n)}return this.itemsMatchingPredicates(t)}},{key:"trashSmartTag",value:function(){return this.systemSmartTags.find((function(e){return e.content.isTrashTag}))}},{key:"trashedItems",value:function(){return this.notesMatchingSmartTag(this.trashSmartTag())}},{key:"emptyTrash",value:(i=ro(a.a.mark((function e(){var t;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.trashedItems(),e.abrupt("return",this.setItemsToBeDeleted(t));case 2:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getSmartTags",value:function(){var e=this.validItemsForContentType(c.SmartTag).sort((function(e,t){return e.content.title0&&n===y.FullSyncCompleted&&setTimeout((function(){m.syncService.sync()}));case 37:case"end":return e.stop()}}),e,this,[[7,24,28,36],[29,,31,35]])}))),function(e,t){return c.apply(this,arguments)})},{key:"handleStrategy",value:(s=fo(a.a.mark((function e(t){var n,r,i;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.items,1===t.strategy){e.next=3;break}throw"Unhandled singleton strategy";case 3:return r=n.sort((function(e,t){return e.errorDecrypting?1:t.errorDecrypting||e.created_at0)){e.next=4;break}return e.abrupt("return",i[0]);case 4:if(this.syncService.getLastSyncDate()){e.next=7;break}return e.next=7,this.syncService.sync();case 7:if(!((o=this.validItemsMatchingPredicate(n)).length>0)){e.next=10;break}return e.abrupt("return",o[0]);case 10:return s=this.modelManager.itemsMatchingPredicate(n).filter((function(e){return e.errorDecrypting})),e.next=13,this.modelManager.setItemsToBeDeleted(s);case 13:return e.t0=Ui,e.t1=r,e.next=17,j.GenerateUuid();case 17:return e.t2=e.sent,e.t3={uuid:e.t2,dirty:!0},e.t4={payload:e.t1,override:e.t3},c=(0,e.t0)(e.t4),e.next=23,this.modelManager.mapPayloadToLocalItem({payload:c});case 23:return u=e.sent,e.next=26,this.syncService.sync();case 26:return e.abrupt("return",u);case 27:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})}])&&po(n.prototype,r),t}(qi);function mo(e){return(mo="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 go(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function bo(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){go(a,r,i,o,s,"next",e)}function s(e){go(a,r,i,o,s,"throw",e)}o(void 0)}))}}function wo(e,t){for(var n=0;n0}))}},{key:"loadExtensionInContextOfItem",value:(d=bo(a.a.mark((function e(t,n){var r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={content_type:n.content_type,item_uuid:n.uuid},e.abrupt("return",this.httpService.getAbsolute({url:t.url,params:r}).then((function(e){return e.description&&(t.description=e.description),e.supported_types&&(t.supported_types=e.supported_types),e.actions?t.actions=e.actions.map((function(e){return new Ot(e)})):t.actions=[],t})).catch((function(e){return console.error("Error loading extension",e),null})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"runAction",value:(h=bo(a.a.mark((function e(t){var n,r,i,o;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.action,r=t.item,i=t.passwordRequestHandler,n.running=!0,e.t0=n.verb,e.next="get"===e.t0?5:"render"===e.t0?9:"show"===e.t0?13:"post"===e.t0?17:21;break;case 5:return e.next=7,this.handleGetAction({action:n,passwordRequestHandler:i});case 7:return o=e.sent,e.abrupt("break",22);case 9:return e.next=11,this.handleRenderAction({action:n,passwordRequestHandler:i});case 11:return o=e.sent,e.abrupt("break",22);case 13:return e.next=15,this.handleShowAction(n);case 15:return o=e.sent,e.abrupt("break",22);case 17:return e.next=19,this.handlePostAction(n,r);case 19:return o=e.sent,e.abrupt("break",22);case 21:return e.abrupt("break",22);case 22:return n.lastExecuted=new Date,n.running=!1,e.abrupt("return",o);case 25:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"handleGetAction",value:(p=bo(a.a.mark((function e(t){var n,r,i=this;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.action,r=t.passwordRequestHandler,e.abrupt("return",new Promise((function(e,t){i.alertService.confirm({text:"Are you sure you want to replace the current note contents with this action's results?",onConfirm:function(){i.runConfirmedGetAction({action:n,passwordRequestHandler:r}).then(e)}})})));case 2:case"end":return e.stop()}}),e)}))),function(e){return p.apply(this,arguments)})},{key:"runConfirmedGetAction",value:(f=bo(a.a.mark((function e(t){var n,r,i,o,s,c,u,l,f,p,h,d=this;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.action,r=t.passwordRequestHandler,e.next=3,this.httpService.getAbsolute({url:n.url}).catch((function(e){var t=e&&e.error||{message:"An issue occurred while processing this action. Please try again."};return d.alertService.alert({text:t.message}),n.error=!0,{error:t}}));case 3:if(!(i=e.sent).error){e.next=6;break}return e.abrupt("return",i);case 6:return n.error=!1,e.next=9,this.payloadByDecryptingResponse({response:i,passwordRequestHandler:r});case 9:return o=e.sent,e.next=12,this.modelManager.mapPayload({payload:o,source:Ln.RemoteActionRetrieved});case 12:for(s=e.sent,c=!0,u=!1,l=void 0,e.prev=16,f=s[Symbol.iterator]();!(c=(p=f.next()).done);c=!0)h=p.value,this.modelManager.setItemDirty(h,!0);e.next=24;break;case 20:e.prev=20,e.t0=e.catch(16),u=!0,l=e.t0;case 24:e.prev=24,e.prev=25,c||null==f.return||f.return();case 27:if(e.prev=27,!u){e.next=30;break}throw l;case 30:return e.finish(27);case 31:return e.finish(24);case 32:return this.syncService.sync(),e.abrupt("return",{response:i,item:i.item});case 34:case"end":return e.stop()}}),e,this,[[16,20,24,32],[25,,27,31]])}))),function(e){return f.apply(this,arguments)})},{key:"handleRenderAction",value:(l=bo(a.a.mark((function e(t){var n,r,i=this;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.action,r=t.passwordRequestHandler,e.abrupt("return",this.httpService.getAbsolute({url:n.url}).then(function(){var e=bo(a.a.mark((function e(t){var o,s;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.error=!1,e.next=3,i.payloadByDecryptingResponse({response:t,passwordRequestHandler:r});case 3:if(!(o=e.sent)){e.next=7;break}return s=i.modelManager.mapPayload({payload:o}),e.abrupt("return",{response:t,item:s});case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){var t=e&&e.error||{message:"An issue occurred while processing this action. Please try again."};return i.alertService.alert({text:t.message}),n.error=!0,{error:t}})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"payloadByDecryptingResponse",value:(u=bo(a.a.mark((function e(t){var n,r,i,o,s,c,u,l,f,p,h,d,v,y,m;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.response,r=t.key,i=t.passwordRequestHandler,o=Ri({object:n.item}),e.next=4,this.protocolService.payloadByDecryptingPayload({payload:o,key:r});case 4:if((s=e.sent).errorDecrypting){e.next=7;break}return e.abrupt("return",s);case 7:if(n.auth_params){e.next=10;break}return this.alertService.alert({text:"We were unable to decrypt this revision using your current keys, \n and this revision is missing metadata that would allow us to try different \n keys to decrypt it. This can likely be fixed with some manual intervention. \n Please email hello@standardnotes.org for assistance."}),e.abrupt("return",null);case 10:c=[],u=!0,l=!1,f=void 0,e.prev=14,p=this.previousPasswords[Symbol.iterator]();case 16:if(u=(h=p.next()).done){e.next=34;break}if(d=h.value,!c.includes(d)){e.next=20;break}return e.abrupt("continue",31);case 20:return c.push(d),e.next=23,this.protocolService.computeRootKey({password:d,keyParams:n.auth_params});case 23:if(v=e.sent){e.next=26;break}return e.abrupt("continue",31);case 26:return e.next=28,this.payloadByDecryptingResponse({response:n,key:v,passwordRequestHandler:i});case 28:if(!(y=e.sent)){e.next=31;break}return e.abrupt("return",y);case 31:u=!0,e.next=16;break;case 34:e.next=40;break;case 36:e.prev=36,e.t0=e.catch(14),l=!0,f=e.t0;case 40:e.prev=40,e.prev=41,u||null==p.return||p.return();case 43:if(e.prev=43,!l){e.next=46;break}throw f;case 46:return e.finish(43);case 47:return e.finish(40);case 48:return e.next=50,i();case 50:return m=e.sent,this.previousPasswords.push(m),e.abrupt("return",this.payloadByDecryptingResponse({response:n,key:r,passwordRequestHandler:i}));case 53:case"end":return e.stop()}}),e,this,[[14,36,40,48],[41,,43,47]])}))),function(e){return u.apply(this,arguments)})},{key:"handlePostAction",value:(s=bo(a.a.mark((function e(t,n){var r,i,o,s=this;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="decrypted"===t.access_type,e.next=3,this.outgoingPayloadForItem({item:n,decrypted:r});case 3:return i=e.sent,o={items:[i]},e.abrupt("return",this.httpService.postAbsolute({url:t.url,params:o}).then((function(e){return t.error=!1,{response:e}})).catch((function(e){return t.error=!0,console.error("Action error response:",e),s.alertService.alert({text:"An issue occurred while processing this action. Please try again."}),{response:e}})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleShowAction",value:(o=bo(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.deviceInterface.openUrl(t.url),e.abrupt("return",{response:null});case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"outgoingPayloadForItem",value:(i=bo(a.a.mark((function e(t){var n,r,i;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.item,r=t.decrypted,i=void 0!==r&&r?F.FileDecrypted:F.FileEncrypted,e.abrupt("return",this.protocolService.payloadByEncryptingPayload({payload:n.payloadRepresentation(),intent:i}));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})}])&&wo(n.prototype,r),t}(qi);function _o(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function $o(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){_o(a,r,i,o,s,"next",e)}function s(e){_o(a,r,i,o,s,"throw",e)}o(void 0)}))}}function Po(e,t){for(var n=0;n0}},{key:"canDecryptWithKey",value:(S=Io(a.a.mark((function e(t){var n,r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.values[Fo.Wrapped],e.next=3,this.decryptWrappedValue({wrappedValue:n,key:t,throws:!1});case 3:return r=e.sent,e.abrupt("return",!r.errorDecrypting);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"decryptWrappedValue",value:(x=Io(a.a.mark((function e(t){var n,r,i,o;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.wrappedValue,r=t.key,n.content_type){e.next=3;break}throw"Attempting to decrypt nonexistent wrapped value";case 3:return i=Ri({object:n,override:{content_type:c.EncryptedStorage}}),e.next=6,this.protocolService.payloadByDecryptingPayload({payload:i,key:r});case 6:return o=e.sent,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return x.apply(this,arguments)})},{key:"decryptStorage",value:(k=Io(a.a.mark((function e(){var t,n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.values[Fo.Wrapped],e.next=3,this.decryptWrappedValue({wrappedValue:t});case 3:if(!(n=e.sent).errorDecrypting){e.next=6;break}throw"Unable to decrypt storage.";case 6:this.values[Fo.Unwrapped]=Object(o.a)(n.content),delete this.values[Fo.Wrapped];case 8:case"end":return e.stop()}}),e,this)}))),function(){return k.apply(this,arguments)})},{key:"generatePersistenceValue",value:(w=Io(a.a.mark((function e(){var t,n,r,i;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Object.assign({},this.values),n=t[Fo.Unwrapped],e.t0=Ri,e.next=5,j.GenerateUuid();case 5:return e.t1=e.sent,e.t2=n,e.t3=c.EncryptedStorage,e.t4={uuid:e.t1,content:e.t2,content_type:e.t3},e.t5={object:e.t4},r=(0,e.t0)(e.t5),e.next=13,this.protocolService.payloadByEncryptingPayload({payload:r,intent:F.LocalStoragePreferEncrypted});case 13:return i=e.sent,t[Fo.Wrapped]=i,t[Fo.Unwrapped]=null,e.abrupt("return",t);case 17:case"end":return e.stop()}}),e,this)}))),function(){return w.apply(this,arguments)})},{key:"repersistToDisk",value:(b=Io(a.a.mark((function e(){var t;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.storagePersistable){e.next=2;break}return e.abrupt("return");case 2:if(this.persistencePolicy!==Ro.Ephemeral){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,this.generatePersistenceValue();case 6:return t=e.sent,this.values[Fo.Wrapped]=t[Fo.Wrapped],e.abrupt("return",this.persistAsValueToDisk(t));case 9:case"end":return e.stop()}}),e,this)}))),function(){return b.apply(this,arguments)})},{key:"setValue",value:(g=Io(a.a.mark((function e(t,n){var r,i=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>2&&void 0!==i[2]?i[2]:No.Default,this.values){e.next=3;break}throw"Attempting to set storage key ".concat(t," before loading local storage.");case 3:return this.values[this.domainKeyForMode(r)][t]=n,e.abrupt("return",this.repersistToDisk());case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return g.apply(this,arguments)})},{key:"getValue",value:(m=Io(a.a.mark((function e(t){var n,r=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.length>1&&void 0!==r[1]?r[1]:No.Default,this.values){e.next=3;break}throw"Attempting to get storage key ".concat(t," before loading local storage.");case 3:if(this.values[this.domainKeyForMode(n)]){e.next=5;break}throw"Storage domain mode not available ".concat(n," for key ").concat(t);case 5:return e.abrupt("return",this.values[this.domainKeyForMode(n)][t]);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"removeValue",value:(y=Io(a.a.mark((function e(t){var n,r=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.length>1&&void 0!==r[1]?r[1]:No.Default,this.values){e.next=3;break}throw"Attempting to remove storage key ".concat(t," before loading local storage.");case 3:return delete this.values[this.domainKeyForMode(n)][t],e.abrupt("return",this.repersistToDisk());case 5:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"getPersistenceKey",value:function(){return O(this.namespace,P.StorageObject)}},{key:"defaultValuesObject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.wrapped,n=e.unwrapped,r=e.nonwrapped;return this.constructor.defaultValuesObject({wrapped:t,unwrapped:n,nonwrapped:r})}},{key:"domainKeyForMode",value:function(e){return this.constructor.domainKeyForMode(e)}},{key:"clearValues",value:(v=Io(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setInitialValues(),e.next=3,this.repersistToDisk();case 3:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"getAllRawPayloads",value:(d=Io(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.getAllRawDatabasePayloads());case 1:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"savePayload",value:(h=Io(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.savePayloads([t]));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"savePayloads",value:(p=Io(a.a.mark((function e(t){var n,r,i,o,s,c,u,l,f;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.persistencePolicy!==Ro.Ephemeral){e.next=2;break}return e.abrupt("return");case 2:n=[],r=[],i=!0,o=!1,s=void 0,e.prev=7,c=t[Symbol.iterator]();case 9:if(i=(u=c.next()).done){e.next=22;break}if(!(l=u.value).discardable){e.next=15;break}n.push(l),e.next=19;break;case 15:return e.next=17,this.protocolService.payloadByEncryptingPayload({payload:l,intent:this.encryptionPolicy===Lo.Default?F.LocalStoragePreferEncrypted:F.LocalStorageDecrypted});case 17:f=e.sent,r.push(f);case 19:i=!0,e.next=9;break;case 22:e.next=28;break;case 24:e.prev=24,e.t0=e.catch(7),o=!0,s=e.t0;case 28:e.prev=28,e.prev=29,i||null==c.return||c.return();case 31:if(e.prev=31,!o){e.next=34;break}throw s;case 34:return e.finish(31);case 35:return e.finish(28);case 36:if(!(n.length>0)){e.next=39;break}return e.next=39,this.deletePayloads(n);case 39:return e.next=41,this.deviceInterface.saveRawDatabasePayloads(r);case 41:case"end":return e.stop()}}),e,this,[[7,24,28,36],[29,,31,35]])}))),function(e){return p.apply(this,arguments)})},{key:"deletePayloads",value:(f=Io(a.a.mark((function e(t){var n,r,i,o,s,c;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=!0,r=!1,i=void 0,e.prev=3,o=t[Symbol.iterator]();case 5:if(n=(s=o.next()).done){e.next=12;break}return c=s.value,e.next=9,this.deletePayloadWithId(c.uuid);case 9:n=!0,e.next=5;break;case 12:e.next=18;break;case 14:e.prev=14,e.t0=e.catch(3),r=!0,i=e.t0;case 18:e.prev=18,e.prev=19,n||null==o.return||o.return();case 21:if(e.prev=21,!r){e.next=24;break}throw i;case 24:return e.finish(21);case 25:return e.finish(18);case 26:case"end":return e.stop()}}),e,this,[[3,14,18,26],[19,,21,25]])}))),function(e){return f.apply(this,arguments)})},{key:"deletePayloadWithId",value:(l=Io(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.removeRawDatabasePayloadWithId(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"clearAllPayloads",value:(u=Io(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.removeAllRawDatabasePayloads());case 1:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"clearAllData",value:(s=Io(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.all([this.clearValues(),this.clearAllPayloads()]));case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})}],i=[{key:"defaultValuesObject",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.wrapped,r=void 0===n?{}:n,i=t.unwrapped,a=void 0===i?{}:i,o=t.nonwrapped,s=void 0===o?{}:o;return Eo(e={},Fo.Wrapped,r),Eo(e,Fo.Unwrapped,a),Eo(e,Fo.Nonwrapped,s),e}},{key:"domainKeyForMode",value:function(e){if(e===No.Default)return Fo.Unwrapped;if(e===No.Nonwrapped)return Fo.Nonwrapped;throw"Invalid mode"}}],r&&jo(n.prototype,r),i&&jo(n,i),t}(qi);function Ko(e){return(Ko="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 Vo(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Bo(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function Ho(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Bo(a,r,i,o,s,"next",e)}function s(e){Bo(a,r,i,o,s,"throw",e)}o(void 0)}))}}function zo(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Wo(e,t){for(var n=0;n0&&(t=Object(o.q)(this.activeMigrations)).onDone(cs(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.saveLastMigrationTimestamp(t.constructor.timestamp());case 2:case"end":return e.stop()}}),e)}))));case 6:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"handleApplicationStage",value:(p=cs(a.a.mark((function e(n){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ls(fs(t.prototype),"handleApplicationStage",this).call(this,n);case 2:return.5===n&&(this.addLoginObserver(),this.addSyncObserver()),e.next=5,this.handleStage(n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"runBaseMigration",value:(f=cs(a.a.mark((function e(){var t;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new as({application:this.application}),e.next=3,t.handleStage(0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"getRequiredMigrations",value:(l=cs(a.a.mark((function e(){var t,n,i,o,s,c,u,l,f;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getLastMigrationTimestamp();case 2:for(t=e.sent,n=[],i=Object.keys(r).map((function(e){return r[e]})).sort((function(e,t){var n=e.timestamp(),r=t.timestamp();return nr?1:0})),o=!0,s=!1,c=void 0,e.prev=8,u=i[Symbol.iterator]();!(o=(l=u.next()).done);o=!0)(f=l.value).timestamp()>t&&n.push(new f({application:this.application,challengeResponder:this.challengeResponder}));e.next=16;break;case 12:e.prev=12,e.t0=e.catch(8),s=!0,c=e.t0;case 16:e.prev=16,e.prev=17,o||null==u.return||u.return();case 19:if(e.prev=19,!s){e.next=22;break}throw c;case 22:return e.finish(19);case 23:return e.finish(16);case 24:return e.abrupt("return",n);case 25:case"end":return e.stop()}}),e,this,[[8,12,16,24],[17,,19,23]])}))),function(){return l.apply(this,arguments)})},{key:"getTimeStampKey",value:function(){return O(this.application.namespace,"last_migration_timestamp")}},{key:"getLastMigrationTimestamp",value:(u=cs(a.a.mark((function e(){var t;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.application.deviceInterface.getRawStorageValue(this.getTimeStampKey());case 2:if(t=e.sent,!Object(o.l)(t)){e.next=5;break}throw"Timestamp should not be null. Be sure to run base migration first.";case 5:return e.abrupt("return",JSON.parse(t));case 6:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"saveLastMigrationTimestamp",value:(c=cs(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.application.deviceInterface.setRawStorageValue(this.getTimeStampKey(),JSON.stringify(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"addLoginObserver",value:function(){var e=this;this.application.addEventObserver(function(){var t=cs(a.a.mark((function t(n,r){return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==g.SignedIn){t.next=3;break}return t.next=3,e.handleStage(3);case 3:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}())}},{key:"addSyncObserver",value:function(){var e=this;this.application.syncService.addEventObserver(function(){var t=cs(a.a.mark((function t(n,r){return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==y.FullSyncCompleted){t.next=3;break}return t.next=3,e.handleStage(1.3);case 3:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}())}},{key:"handleStage",value:(s=cs(a.a.mark((function e(t){var n,r,i,o,s,c;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=!0,r=!1,i=void 0,e.prev=3,o=this.activeMigrations[Symbol.iterator]();case 5:if(n=(s=o.next()).done){e.next=12;break}return c=s.value,e.next=9,c.handleStage(t);case 9:n=!0,e.next=5;break;case 12:e.next=18;break;case 14:e.prev=14,e.t0=e.catch(3),r=!0,i=e.t0;case 18:e.prev=18,e.prev=19,n||null==o.return||o.return();case 21:if(e.prev=21,!r){e.next=24;break}throw i;case 24:return e.finish(21);case 25:return e.finish(18);case 26:case"end":return e.stop()}}),e,this,[[3,14,18,26],[19,,21,25]])}))),function(e){return s.apply(this,arguments)})}])&&us(n.prototype,i),t}(qi);function ds(e){return(ds="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 vs(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ys(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function ms(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){ys(a,r,i,o,s,"next",e)}function s(e){ys(a,r,i,o,s,"throw",e)}o(void 0)}))}}function gs(e,t){for(var n=0;n=0||!!Object(Z.isWebCryptoAvailable)()}},{key:"supportedVersions",value:function(){return[L.V001,L.V002,L.V003,L.V004]}},{key:"isVersionNewerThanLibraryVersion",value:function(e){return 1===N(e,this.getLatestVersion())}},{key:"isProtocolVersionOutdated",value:function(e){var t={};t[L.V001]=Date.parse("2018-01-01"),t[L.V002]=Date.parse("2020-01-01");var n=t[e];return!!n&&new Date>n}},{key:"costMinimumForVersion",value:function(e){if(N(e,L.V003)>=0)throw"Cost minimums only apply to versions <= 002";if(e===L.V001)return de.pwCost();if(e===L.V002)return $e.pwCost();throw"Invalid version for cost minimum: ".concat(e)}},{key:"createOperatorForLatestVersion",value:function(){return this.createOperatorForVersion(this.getLatestVersion())}},{key:"createOperatorForVersion",value:function(e){if(e===L.V001)return new de(this.crypto);if(e===L.V002)return new $e(this.crypto);if(e===L.V003)return new Me(this.crypto);if(e===L.V004)return new ze(this.crypto);if(e===L.V000Base64Decrypted)return this.createOperatorForLatestVersion();throw"Unable to find operator for version ".concat(e)}},{key:"operatorForVersion",value:function(e){var t=e,n=this.operators[t];return n||(n=this.createOperatorForVersion(e),this.operators[t]=n),n}},{key:"defaultOperator",value:function(){return this.operatorForVersion(this.getLatestVersion())}},{key:"computeRootKey",value:(d=ms(a.a.mark((function e(t){var n,r,i,o;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.password,r=t.keyParams,i=r.version,o=this.operatorForVersion(i),e.abrupt("return",o.computeRootKey({password:n,keyParams:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"createRootKey",value:(h=ms(a.a.mark((function e(t){var n,r,i;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.identifier,r=t.password,i=this.defaultOperator(),e.abrupt("return",i.createRootKey({identifier:n,password:r}));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"payloadContentFormatForIntent",value:function(e){var t=e.key,n=e.intent;if(t){if(n===F.Sync||n===F.FileEncrypted||n===F.FilePreferEncrypted||n===F.LocalStorageEncrypted||n===F.LocalStoragePreferEncrypted)return Q.EncryptedString;throw"Unhandled encrypted case in protocolService.payloadContentFormatForIntent."}if(n===F.LocalStorageDecrypted||n===F.LocalStoragePreferEncrypted||n===F.FileDecrypted||n===F.FilePreferEncrypted)return Q.DecryptedBareObject;if(n===F.SyncDecrypted)return Q.DecryptedBase64String;throw"Unhandled decrypted case in protocolService.payloadContentFormatForIntent."}},{key:"payloadByEncryptingPayload",value:(p=ms(a.a.mark((function e(t){var n,r,i,s,c,u,l;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.payload,r=t.key,i=t.intent,!n.errorDecrypting){e.next=3;break}return e.abrupt("return",n);case 3:if(!Object(o.l)(i)){e.next=5;break}throw"Attempting to encrypt payload with null intent";case 5:if(r||V(i)){e.next=9;break}return e.next=8,this.keyManager.keyToUseForEncryptionOfPayload({payload:n,intent:i});case 8:r=e.sent;case 9:if(r||!B(i)){e.next=11;break}throw"Attempting to generate encrypted payload with no key.";case 11:if(n.getFormat()===Q.DecryptedBareObject){e.next=13;break}throw"Attempting to encrypt already encrypted payload.";case 13:if(n.isPayload){e.next=15;break}throw"Attempting to encrypt non-payload.";case 15:if(n.content){e.next=17;break}throw"Attempting to encrypt payload with no content.";case 17:if(n.uuid){e.next=19;break}throw"Attempting to encrypt payload with no uuid.";case 19:return s=r?r.version:this.getLatestVersion(),c=this.payloadContentFormatForIntent({key:r,intent:i}),u=this.operatorForVersion(s),e.next=24,u.generateEncryptionParameters({payload:n,key:r,format:c});case 24:if(l=e.sent){e.next=27;break}throw"Unable to generate encryption parameters";case 27:return e.abrupt("return",Li({object:n,override:l,intent:i}));case 28:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"payloadsByEncryptingPayloads",value:(f=ms(a.a.mark((function e(t){var n,r,i,s,c,u,l,f,p,h,d;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.payloads,r=t.intent,i=[],s=!0,c=!1,u=void 0,e.prev=5,l=n[Symbol.iterator]();case 7:if(s=(f=l.next()).done){e.next=17;break}return p=f.value,h=Object(o.k)(r)?r(p):r,e.next=12,this.payloadByEncryptingPayload({payload:p,intent:h});case 12:d=e.sent,i.push(d);case 14:s=!0,e.next=7;break;case 17:e.next=23;break;case 19:e.prev=19,e.t0=e.catch(5),c=!0,u=e.t0;case 23:e.prev=23,e.prev=24,s||null==l.return||l.return();case 26:if(e.prev=26,!c){e.next=29;break}throw u;case 29:return e.finish(26);case 30:return e.finish(23);case 31:return e.abrupt("return",i);case 32:case"end":return e.stop()}}),e,this,[[5,19,23,31],[24,,26,30]])}))),function(e){return f.apply(this,arguments)})},{key:"payloadByDecryptingPayload",value:(l=ms(a.a.mark((function e(t){var n,r,i,o,s,c,u;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.payload,r=t.key,n.content){e.next=3;break}throw"Attempting to decrypt payload that has no content.";case 3:if(n.isPayload){e.next=5;break}throw"Attempting to decrypt non-payload.";case 5:if((i=n.getFormat())!==Q.DecryptedBareObject){e.next=8;break}return e.abrupt("return",n);case 8:if(r||i!==Q.EncryptedString){e.next=14;break}return e.next=11,this.keyManager.keyToUseForDecryptionOfPayload({payload:n});case 11:if(r=e.sent){e.next=14;break}return e.abrupt("return",Ri({object:n,override:{waitingForKey:!0,errorDecrypting:!0}}));case 14:return o=n.version,s=this.operatorForVersion(o),c=Ki(n),e.next=19,s.generateDecryptedParameters({encryptedParameters:c,key:r});case 19:return u=e.sent,e.abrupt("return",Ri({object:n,override:u}));case 21:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"payloadsByDecryptingPayloads",value:(u=ms(a.a.mark((function e(t){var n,r,i,s,c,u,l,f,p,h,d;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.payloads,r=t.key,i=[],s=!0,c=!1,u=void 0,e.prev=5,l=n[Symbol.iterator]();case 7:if(s=(f=l.next()).done){e.next=35;break}if(p=f.value){e.next=12;break}return i.push(p),e.abrupt("continue",32);case 12:if(p.isPayload){e.next=14;break}throw"Attempting to decrypt non-payload object in payloadsByDecryptingPayloads.";case 14:if(!0!==p.deleted||!Object(o.l)(p.content)){e.next=17;break}return i.push(p),e.abrupt("continue",32);case 17:if(Object(o.n)(p.content)){e.next=21;break}return i.push(p),e.abrupt("continue",32);case 21:return e.prev=21,e.next=24,this.payloadByDecryptingPayload({payload:p,key:r});case 24:h=e.sent,i.push(h),e.next=32;break;case 28:e.prev=28,e.t0=e.catch(21),i.push(Ri({object:p,override:(d={},vs(d,ne.ErrorDecrypting,!0),vs(d,ne.ErrorDecryptingChanged,!p.errorDecrypting),d)})),console.error("Error decrypting payload",p,e.t0);case 32:s=!0,e.next=7;break;case 35:e.next=41;break;case 37:e.prev=37,e.t1=e.catch(5),c=!0,u=e.t1;case 41:e.prev=41,e.prev=42,s||null==l.return||l.return();case 44:if(e.prev=44,!c){e.next=47;break}throw u;case 47:return e.finish(44);case 48:return e.finish(41);case 49:return e.abrupt("return",i);case 50:case"end":return e.stop()}}),e,this,[[5,37,41,49],[21,28],[42,,44,48]])}))),function(e){return u.apply(this,arguments)})},{key:"decryptErroredItems",value:(c=ms(a.a.mark((function e(){var t,n,r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==(t=this.modelManager.allItems.filter((function(e){return e.waitingForKey||e.errorDecrypting}))).length){e.next=3;break}return e.abrupt("return");case 3:return n=t.map((function(e){return e.payloadRepresentation()})),e.next=6,this.payloadsByDecryptingPayloads({payloads:n});case 6:return r=e.sent,e.next=9,this.modelManager.mapPayloadsToLocalItems({payloads:r});case 9:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"payloadsByDecryptingBackupFile",value:(s=ms(a.a.mark((function e(t){var n,r,i,o,s,c,u;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.data,r=t.password,i=n.keyParams||n.auth_params,o=n.items,s=o.map((function(e){return Ni({object:e,source:Ln.FileImport})})),!i){e.next=13;break}return e.next=7,this.computeRootKey({password:r,keyParams:i});case 7:return u=e.sent,e.next=10,this.payloadsByDecryptingPayloads({payloads:s,key:u});case 10:c=e.sent,e.next=14;break;case 13:c=s;case 14:return e.abrupt("return",c);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"createKeyParams",value:function(e){if(e.isKeyParamsObject)throw"Attempting to create key params from non-raw value.";return e.version||(e.version=L.V002),Y(e)}},{key:"createBackupFile",value:(i=ms(a.a.mark((function e(){var t,n,r,i,o,s,c,u,l,f,p=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=p.length>0&&void 0!==p[0]?p[0]:{},n=t.subItems,r=t.intent,i=t.returnIfEmpty,o=n||this.modelManager.allItems,!i||0!==o.length){e.next=4;break}return e.abrupt("return",null);case 4:return r||(r=F.FilePreferEncrypted),s=o.map((function(e){return Ri({object:e})})),e.next=8,this.payloadsByEncryptingPayloads({payloads:s,intent:r});case 8:return c=e.sent,u={items:c},e.next=12,this.keyManager.getRootKeyParams();case 12:return(l=e.sent)&&r!==F.FileDecrypted&&(u.keyParams=l.getPortableValue()),f=2,e.abrupt("return",JSON.stringify(u,null,f));case 16:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})}])&&gs(n.prototype,r),t}(qi);function Ss(e,t){for(var n=0;n0?"".concat(this.textCharDiffLength," characters added"):"Title or metadata changed":"".concat(this.textCharDiffLength," characters loaded")}}])&&Os(n.prototype,r),t}(_s);function js(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ds(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};if(js(this,e),this.entries||(this.entries=[]),t.entries){var n=!0,r=!1,i=void 0;try{for(var a,o=t.entries[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value,c=this.createEntryForItem(s.item);c.setPreviousEntry(this.getLastEntry()),this.entries.push(c)}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}}}var t,n;return t=e,(n=[{key:"createEntryForItem",value:function(e){return function(e){var t,n,r,i=(t={},n=c.Note,r=Is,n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t)[e.content_type];if(!i)throw"Invalid item history class";return new i(e)}(e)}},{key:"getLastEntry",value:function(){return this.entries[this.entries.length-1]}},{key:"addHistoryEntryForItem",value:function(e){var t=this.createEntryForItem(e),n=this.getLastEntry();if(t.setPreviousEntry(n),!t.isSameAsEntry(n))return this.entries.push(t),t}},{key:"clear",value:function(){this.entries.length=0}},{key:"optimize",value:function(){var e=this,t=[],n=function(e){return e.deltaSize()>15},r=function(r,i,a){if(a)t.push(r);else{var o=t.indexOf(r);-1!==o&&t.splice(o,1)}if(a&&n(r)&&-1===r.operationVector()){var s=e.entries[i-1];s&&t.push(s)}};this.entries.forEach((function(t,i){if(0===i||i===e.entries.length-1)r(t,i,!0);else{var a=n(t);r(t,i,a)}})),this.entries=this.entries.filter((function(e,n){return-1!==t.indexOf(e)}))}}])&&Ds(t.prototype,n),e}();function Ts(e,t){for(var n=0;nthis.itemRevisionThreshold&&t.optimize()}}])&&Ts(t.prototype,n),e}();function Ls(e){return(Ls="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 Ns(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function Fs(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Ns(a,r,i,o,s,"next",e)}function s(e){Ns(a,r,i,o,s,"throw",e)}o(void 0)}))}}function Us(e,t){for(var n=0;n0);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"actionRequiresPrivilege",value:(s=Ws(a.a.mark((function e(t){var n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getSessionExpirey();case 2:if(!(e.sent>new Date)){e.next=5;break}return e.abrupt("return",!1);case 5:return e.next=7,this.netCredentialsForAction(t);case 7:return n=e.sent,e.abrupt("return",n.length>0);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"authenticateAction",value:(o=Ws(a.a.mark((function e(t,n){var r,i,o,s,c,u,l,f,p;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.netCredentialsForAction(t);case 2:r=e.sent,i=[],o=[],s=!0,c=!1,u=void 0,e.prev=8,l=r[Symbol.iterator]();case 10:if(s=(f=l.next()).done){e.next=19;break}return p=f.value,e.next=14,this.verifyAuthenticationParameters(p,n[p]);case 14:e.sent?i.push(p):o.push(p);case 16:s=!0,e.next=10;break;case 19:e.next=25;break;case 21:e.prev=21,e.t0=e.catch(8),c=!0,u=e.t0;case 25:e.prev=25,e.prev=26,s||null==l.return||l.return();case 28:if(e.prev=28,!c){e.next=31;break}throw u;case 31:return e.finish(28);case 32:return e.finish(25);case 33:return e.abrupt("return",{success:0===o.length,successfulCredentials:i,failedCredentials:o});case 34:case"end":return e.stop()}}),e,this,[[8,21,25,33],[26,,28,32]])}))),function(e,t){return o.apply(this,arguments)})},{key:"verifyAuthenticationParameters",value:(i=Ws(a.a.mark((function e(t,n){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t!==Qs.AccountPassword){e.next=4;break}return e.abrupt("return",this.keyManager.validateAccountPassword(n));case 4:if(t!==Qs.LocalPasscode){e.next=6;break}return e.abrupt("return",this.keyManager.validatePasscode(n));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"displayInfoForCredential",value:function(e){var t={};return t[Qs.AccountPassword]={label:"Account Password",prompt:"Please enter your account password."},t[Qs.LocalPasscode]={label:"Local Passcode",prompt:"Please enter your local passcode."},t[e]}},{key:"displayInfoForAction",value:function(e){var t={};return t[Js.ManageExtensions]={label:"Manage Extensions"},t[Js.ManageBackups]={label:"Download/Import Backups"},t[Js.ViewProtectedNotes]={label:"View Protected Notes"},t[Js.ManagePrivileges]={label:"Manage Privileges"},t[Js.ManagePasscode]={label:"Manage Passcode"},t[Js.DeleteNote]={label:"Delete Notes"},t[e]}},{key:"getSessionLengthOptions",value:function(){return[{value:Zs,label:"Don't Remember"},{value:Xs,label:"5 Minutes"},{value:ec,label:"1 Hour"},{value:tc,label:"1 Week"}]}}])&&qs(n.prototype,r),t}(qi);function rc(e){return(rc="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 ic(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function ac(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){ic(a,r,i,o,s,"next",e)}function s(e){ic(a,r,i,o,s,"throw",e)}o(void 0)}))}}function oc(e,t){for(var n=0;n0)){e.next=17;break}return e.next=17,this.modelManager.setItemsToBeDeleted(s);case 17:if(0!==t.length){e.next=20;break}return e.next=20,this.createNewDefaultItemsKey();case 20:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"handleFullSyncCompletion",value:(l=mc(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getDefaultItemsKey()){e.next=6;break}return e.next=4,this.createNewDefaultItemsKey();case 4:if(this.keyManager.keyMode!==hc){e.next=6;break}return e.abrupt("return",this.syncService.repersistAllItems());case 6:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"itemsKeyForPayload",value:function(e){return this.allItemsKeys.find((function(t){return t.uuid===e.items_key_id}))}},{key:"getDefaultItemsKey",value:function(){return 1===this.allItemsKeys.length?this.allItemsKeys[0]:this.allItemsKeys.find((function(e){return e.isDefault}))}},{key:"reencryptItemsKeys",value:(u=mc(a.a.mark((function e(){var t;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((t=this.allItemsKeys).length>0)){e.next=4;break}return e.next=4,this.modelManager.setItemsDirty(t);case 4:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"defaultItemsKeyForItemVersion",value:(s=mc(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.allItemsKeys.find((function(e){return e.version===t})));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"createNewDefaultItemsKey",value:(i=mc(a.a.mark((function e(){var t,n,r,i,o;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.keyManager.getRootKey();case 2:if(t=e.sent,!(N(n=t?t.version:this.protocolService.getLatestVersion(),kc)<=0)){e.next=10;break}return r=Xe.FromRaw({itemsKey:t.masterKey,dataAuthenticationKey:t.dataAuthenticationKey,version:n}),e.next=8,r.initUUID();case 8:e.next=13;break;case 10:return e.next=12,this.protocolService.operatorForVersion(n).createItemsKey();case 12:r=e.sent;case 13:if(!(i=this.getDefaultItemsKey())){e.next=18;break}return i.content.isDefault=!1,e.next=18,this.modelManager.setItemDirty(i);case 18:return r.content.isDefault=!0,o=r.payloadRepresentation({override:{dirty:!0}}),e.next=22,this.modelManager.mapPayloadToLocalItem({payload:o});case 22:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"allItemsKeys",get:function(){return this.modelManager.itemsKeys}}])&&gc(n.prototype,r),t}(qi);function Sc(e,t){return e.sort((function(e,n){var r=new Date(n.updated_at)-new Date(e.updated_at),i=0,a=0;return t&&(i=t.indexOf(e.content_type),a=t.indexOf(n.content_type),-1===i&&(i=t.length),-1===a&&(a=t.length)),i===a?r:i5&&(e.receiver(y.SyncTakingTooLong),e.stopTimingMonitor())}),500)}},{key:"stopTimingMonitor",value:function(){this.interval.hasOwnProperty("cancel")?this.interval.cancel(this.timingMonitor):clearInterval(this.timingMonitor),this.timingMonitor=null}},{key:"hasError",value:function(){return this.error}},{key:"setError",value:function(e){this.error=e}},{key:"clearError",value:function(){this.error=null}},{key:"reset",value:function(){this.downloaded=0,this.completedUpload=0,this.totalUpload=0,this.inProgress=!1,this.syncing=!1,this.error=null}},{key:"syncInProgress",get:function(){return!0===this.syncing}},{key:"secondsSinceSyncStart",get:function(){return(new Date-this.syncStart)/1e3}}])&&_c(t.prototype,n),e}();function Pc(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function Oc(e,t){for(var n=0;n=this.maxDiscordance&&!this.outOfSync&&(this.outOfSync=!0,this.receiver(y.EnterOutOfSync))):(this.outOfSync&&(this.outOfSync=!1,this.receiver(y.ExitOutOfSync)),this.discordance=0);case 5:case"end":return e.stop()}}),e,this)})),i=function(){var e=this,t=arguments;return new Promise((function(n,i){var a=r.apply(e,t);function o(e){Pc(a,n,i,o,s,"next",e)}function s(e){Pc(a,n,i,o,s,"throw",e)}o(void 0)}))},function(e){return i.apply(this,arguments)})},{key:"lastPreSyncSaveDate",get:function(){return this._lastPreSyncSave}},{key:"lastSyncDate",get:function(){return this._lastSyncDate}},{key:"needsSync",get:function(){return this.discordance>0&&this.discordancet.lastSyncBegan:e.dirty}}])&&Tc(t.prototype,n),e}();function Lc(e,t){for(var n=0;n0&&void 0!==h[0]?h[0]:{},n=t.alternateUuids,this.log("Marking all items as needing sync"),!n){e.next=30;break}r=this.modelManager.allNondummyItems.filter((function(e){return!e.errorDecrypting})).slice(),i=!0,o=!1,s=void 0,e.prev=7,c=r[Symbol.iterator]();case 9:if(i=(u=c.next()).done){e.next=16;break}return l=u.value,e.next=13,this.alternateUuidForItem(l);case 13:i=!0,e.next=9;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(7),o=!0,s=e.t0;case 22:e.prev=22,e.prev=23,i||null==c.return||c.return();case 25:if(e.prev=25,!o){e.next=28;break}throw s;case 28:return e.finish(25);case 29:return e.finish(22);case 30:return f=this.modelManager.allNondummyItems,p=f.map((function(e){return Ri({object:e,override:{dirty:!0}})})),e.next=34,this.modelManager.mapPayloadsToLocalItems({payloads:p});case 34:return e.next=36,this.persistPayloads({decryptedPayloads:p});case 36:case"end":return e.stop()}}),e,this,[[7,18,22,30],[23,,25,29]])}))),function(){return _.apply(this,arguments)})},{key:"repersistAllItems",value:(S=Jc(a.a.mark((function e(){var t,n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.modelManager.allItems,n=t.map((function(e){return Ri({object:e})})),e.abrupt("return",this.persistPayloads({decryptedPayloads:n}));case 3:case"end":return e.stop()}}),e,this)}))),function(){return S.apply(this,arguments)})},{key:"popPayloadsNeedingPreSyncSave",value:(x=Jc(a.a.mark((function e(t){var n,r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.state.lastPreSyncSaveDate){e.next=3;break}return e.abrupt("return",t);case 3:return r=t.filter((function(e){return!e.dirtiedDate||e.dirtiedDate>n})),this.state.setLastPresaveSyncDate(new Date),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return x.apply(this,arguments)})},{key:"timingStrategyResolveOnNext",value:function(){var e=this;return new Promise((function(t,n){e.resolveQueue.push({resolve:t,reject:n})}))}},{key:"timingStrategyForceSpawnNew",value:function(e){var t=this;return new Promise((function(n,r){t.spawnQueue.push({resolve:n,reject:r,options:e})}))}},{key:"popSpawnQueue",value:function(){if(0===this.spawnQueue.length)return null;var e=this.spawnQueue[0];return Object(o.v)(this.spawnQueue,0),this.log("Syncing again from spawn queue"),this.sync(function(e){for(var t=1;t0&&void 0!==j[0]?j[0]:{},n=t.timingStrategy,r=t.mode,i=t.checkIntegrity,s=t.source,!this.locked){e.next=4;break}return this.log("Sync Locked"),e.abrupt("return");case 4:return c=function(){return I.syncLock},u=function(){I.syncLock=!0},l=function(){I.syncLock=!1},f=this.opStatus.syncInProgress,p=this.databaseLoaded,(h=!c())&&p&&!f&&u(),s||(s=iu.External),e.next=14,this.itemsNeedingSync();case 14:return d=e.sent,v=d.filter((function(e){return e.neverSynced&&e.deleted})),Object(o.x)(d,v),m=d.map((function(e){return e.payloadRepresentation()})),e.next=20,this.popPayloadsNeedingPreSyncSave(m);case 20:return g=e.sent,e.next=23,this.persistPayloads({decryptedPayloads:g});case 23:if(b=this.resolveQueue.slice(),w=Object(o.l)(n)?tu:n,!f&&p&&h){e.next=36;break}if(this.log(h?f?"Attempting to sync while existing sync in progress.":"Attempting to sync before local database has loaded.":"Another function call has begun preparing for sync."),w!==tu){e.next=31;break}return e.abrupt("return",this.timingStrategyResolveOnNext());case 31:if(w!==nu){e.next=35;break}return e.abrupt("return",this.timingStrategyForceSpawnNew({mode:r,checkIntegrity:i,source:s}));case 35:throw"Unhandled timing strategy ".concat(w);case 36:return this.opStatus.setDidBegin(),k=new Date,e.next=40,this.modelManager.setItemsProperties({items:d,properties:Gc({},ne.LastSyncBegan,k)});case 40:return x=Object(o.l)(r)?ru.Default:r,e.next=43,this.sessionManager.online();case 43:if(S=e.sent,x!==ru.Default){e.next=56;break}if(this.completedInitialSync){e.next=47;break}throw"Attempting to default mode sync without having completed initial.";case 47:if(!S){e.next=53;break}return e.next=50,this.payloadsByPreparingForServer(m);case 50:_=e.sent,e.next=54;break;case 53:_=m;case 54:e.next=57;break;case 56:x===ru.DownloadFirst&&(_=[]);case 57:if(!S){e.next=63;break}return e.next=60,this.syncOnlineOperation({payloads:_,checkIntegrity:i,source:s,mode:x});case 60:$=e.sent,e.next=66;break;case 63:return e.next=65,this.syncOfflineOperation({payloads:_});case 65:$=e.sent;case 66:return e.next=68,$.run();case 68:for(this.opStatus.setDidEnd(),l(),P=!0,O=!1,C=void 0,e.prev=73,E=b[Symbol.iterator]();!(P=(A=E.next()).done);P=!0)A.value.resolve();e.next=81;break;case 77:e.prev=77,e.t0=e.catch(73),O=!0,C=e.t0;case 81:e.prev=81,e.prev=82,P||null==E.return||E.return();case 84:if(e.prev=84,!O){e.next=87;break}throw C;case 87:return e.finish(84);case 88:return e.finish(81);case 89:if(Object(o.x)(this.resolveQueue,b),!this.opStatus.hasError()){e.next=92;break}return e.abrupt("return");case 92:return this.opStatus.reset(),this.state.setLastSyncDate(new Date),$.numberOfItemsInvolved>=this.majorChangeThreshold&&this.notifyEvent(y.MajorDataChange),e.next=97,this.handleNeverSyncedDeleted(v);case 97:if(x===ru.DownloadFirst){e.next=100;break}return e.next=100,this.notifyEvent(y.FullSyncCompleted,{source:s});case 100:if(x!==ru.DownloadFirst){e.next=107;break}return this.completedInitialSync=!0,e.next=104,this.notifyEvent(y.DownloadFirstSyncCompleted);case 104:return e.abrupt("return",this.sync({source:iu.AfterDownloadFirst,checkIntegrity:!0}));case 107:if(this.popSpawnQueue()||!(this.resolveQueue.length>0)){e.next=112;break}this.log("Syncing again from resolve queue"),this.sync({source:iu.ResolveQueue}),e.next=125;break;case 112:return e.next=114,this.itemsNeedingSync();case 114:if(e.t1=e.sent.length,!(e.t1>0)){e.next=119;break}return e.abrupt("return",this.sync({source:iu.MoreDirtyItems}));case 119:if(!$.checkIntegrity){e.next=123;break}this.state.needsSync&&$.done&&(this.log("Syncing again from integrity check"),this.sync({checkIntegrity:!0,timingStrategy:nu,source:iu.IntegrityCheck})),e.next=125;break;case 123:return e.next=125,this.state.clearIntegrityHashes();case 125:case"end":return e.stop()}}),e,this,[[73,77,81,89],[82,,84,88]])}))),function(){return k.apply(this,arguments)})},{key:"syncOnlineOperation",value:(w=Jc(a.a.mark((function e(t){var n,r,i,o,s,c=this;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.payloads,r=t.checkIntegrity,i=t.source,o=t.mode,this.log("Syncing online user","source:",i,"mode:",o,"payloads:",n),e.t0=Kc,e.t1=this.apiService,e.t2=n,e.t3=r,e.next=8,this.getLastSyncToken();case 8:return e.t4=e.sent,e.next=11,this.getPaginationToken();case 11:return e.t5=e.sent,e.t6=function(){var e=Jc(a.a.mark((function e(t,n){var r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1!==n){e.next=11;break}if(!(r=t).hasError){e.next=7;break}return e.next=5,c.handleErrorServerResponse({operation:s,response:r});case 5:e.next=9;break;case 7:return e.next=9,c.handleSuccessServerResponse({operation:s,response:r});case 9:e.next=14;break;case 11:if(2!==n){e.next=14;break}return e.next=14,c.handleStatusChange({operation:s});case 14:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),e.t7={apiService:e.t1,payloads:e.t2,checkIntegrity:e.t3,lastSyncToken:e.t4,paginationToken:e.t5,receiver:e.t6},s=new e.t0(e.t7),e.abrupt("return",s);case 16:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"syncOfflineOperation",value:(b=Jc(a.a.mark((function e(t){var n,r,i=this;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.payloads,this.log("Syncing offline user",n),r=new zc({payloads:n,receiver:function(){var e=Jc(a.a.mark((function e(t,n){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1!==n){e.next=5;break}return e.next=3,i.handleOfflineResponse(t);case 3:e.next=8;break;case 5:if(2!==n){e.next=8;break}return e.next=8,i.handleStatusChange({operation:r});case 8:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()}),e.abrupt("return",r);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"handleStatusChange",value:(g=Jc(a.a.mark((function e(t){var n,r,i,o;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.operation,r=n.pendingUploadCount(),i=n.totalUploadCount(),o=i-r,this.opStatus.setUploadStatus({completed:o,total:i});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"handleOfflineResponse",value:(m=Jc(a.a.mark((function e(t){var n,r,i;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.payloads,r=this.modelManager.getMasterCollection(),i=n.map((function(e){return r.findPayload(e.uuid).mergedWith(e)})),e.next=5,this.persistPayloads({decryptedPayloads:i});case 5:return e.next=7,this.modelManager.mapPayloadsToLocalItems({payloads:n,source:Ln.LocalSaved});case 7:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"handleErrorServerResponse",value:(v=Jc(a.a.mark((function e(t){var n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.operation,n=t.response,this.log("Sync Error",n),401===n.status&&this.notifyEvent(y.InvalidSession),this.opStatus.setError(n.error),this.notifyEvent(y.SyncError,n.error);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"handleSuccessServerResponse",value:(d=Jc(a.a.mark((function e(t){var n,r,i,s,c,u,l,f,p,h,d,v,m,g,b,w,k,x,S,_,$,P;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.operation,r=t.response,!this._simulate_latency){e.next=4;break}return e.next=4,Object(o.w)(this._simulate_latency.latency);case 4:this.log("Online Sync Response",r.rawResponse),this.setLastSyncToken(r.lastSyncToken),this.setPaginationToken(r.paginationToken),this.opStatus.clearError(),this.opStatus.setDownloadStatus({downloaded:r.allProcessedPayloads.length}),i=[],s=!0,c=!1,u=void 0,e.prev=13,l=r.allProcessedPayloads[Symbol.iterator]();case 15:if(s=(f=l.next()).done){e.next=26;break}if(!(p=f.value).deleted&&p.fields().includes(ne.Content)){e.next=19;break}return e.abrupt("continue",23);case 19:return e.next=21,this.protocolService.payloadByDecryptingPayload({payload:p});case 21:h=e.sent,i.push(h);case 23:s=!0,e.next=15;break;case 26:e.next=32;break;case 28:e.prev=28,e.t0=e.catch(13),c=!0,u=e.t0;case 32:e.prev=32,e.prev=33,s||null==l.return||l.return();case 35:if(e.prev=35,!c){e.next=38;break}throw u;case 38:return e.finish(35);case 39:return e.finish(32);case 40:return d=this.modelManager.getMasterCollection(),v=new Rc({response:r,decryptedResponsePayloads:i,payloadsSavedOrSaving:n.payloadsSavedOrSaving,baseCollection:d}),e.next=44,v.collectionsByProcessingResponse();case 44:m=e.sent,g=!0,b=!1,w=void 0,e.prev=48,k=m[Symbol.iterator]();case 50:if(g=(x=k.next()).done){e.next=62;break}return S=x.value,e.next=54,this.modelManager.mapCollectionToLocalItems({collection:S});case 54:return $=Bi(S.source),_=$.fields().includes(ne.Content)?S.allPayloads:S.allPayloads.map((function(e){return d.findPayload(e.uuid).mergedWith(e)})),e.next=59,this.persistPayloads({decryptedPayloads:_});case 59:g=!0,e.next=50;break;case 62:e.next=68;break;case 64:e.prev=64,e.t1=e.catch(48),b=!0,w=e.t1;case 68:e.prev=68,e.prev=69,g||null==k.return||k.return();case 71:if(e.prev=71,!b){e.next=74;break}throw w;case 74:return e.finish(71);case 75:return e.finish(68);case 76:return e.next=78,this.notifyEvent(y.SingleSyncCompleted,r);case 78:if(!r.checkIntegrity){e.next=84;break}return e.next=81,this.computeDataIntegrityHash();case 81:return P=e.sent,e.next=84,this.state.setIntegrityHashes({clientHash:P,serverHash:r.integrityHash});case 84:case"end":return e.stop()}}),e,this,[[13,28,32,40],[33,,35,39],[48,64,68,76],[69,,71,75]])}))),function(e){return d.apply(this,arguments)})},{key:"handleNeverSyncedDeleted",value:(h=Jc(a.a.mark((function e(t){var n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.map((function(e){return e.payloadRepresentation({override:{dirty:!1}})})),e.next=3,this.modelManager.mapPayloadsToLocalItems({payloads:n});case 3:return e.next=5,this.persistPayloads({decryptedPayloads:n});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"persistPayloads",value:(p=Jc(a.a.mark((function e(t){var n,r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.decryptedPayloads,0!==(r=void 0===n?[]:n).length){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,this.storageService.savePayloads(r);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"computeDataIntegrityHash",value:(l=Jc(a.a.mark((function e(){var t,n,r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=this.modelManager.nonDeletedItems.sort((function(e,t){return t.updated_at-e.updated_at})),n=t.map((function(e){return e.updatedAtTimestamp()})),r=n.join(","),e.abrupt("return",this.protocolService.crypto.sha256(r));case 7:return e.prev=7,e.t0=e.catch(0),console.error("Error computing data integrity hash",e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}}),e,this,[[0,7]])}))),function(){return l.apply(this,arguments)})},{key:"deinit",value:(u=Jc(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Zc(Xc(t.prototype),"deinit",this).call(this),this.state.reset(),this.opStatus.reset(),this.resolveQueue=[],this.spawnQueue=[],e.next=7,this.clearSyncPositionTokens();case 7:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"resolveOutOfSync",value:(s=Jc(a.a.mark((function e(){var t,n,r,i;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new Ic({apiService:this.apiService,protocolService:this.protocolService,customEvent:"resolve-out-of-sync"}),e.next=3,t.run();case 3:return n=e.sent,r=new ui({baseCollection:this.modelManager.getMasterCollection(),applyCollection:new f({payloads:n,source:Ln.RemoteRetrieved})}),e.next=7,r.resultingCollection();case 7:return i=e.sent,e.next=10,this.modelManager.mapCollectionToLocalItems({collection:i});case 10:return e.next=12,this.persistPayloads({decryptedPayloads:i.payloads});case 12:return e.abrupt("return",this.sync({checkIntegrity:!0,source:iu.ResolveOutOfSync}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"statelessDownloadAllItems",value:(i=Jc(a.a.mark((function e(){var t,n,r,i,o,s=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=s.length>0&&void 0!==s[0]?s[0]:{},n=t.contentType,r=t.customEvent,i=new Ic({apiService:this.apiService,protocolService:this.protocolService,contentType:n,customEvent:r}),e.next=4,i.run();case 4:return o=e.sent,e.abrupt("return",o.map((function(e){return Cn(e)})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"ut_setDatabaseLoaded",value:function(e){this.databaseLoaded=e}},{key:"ut_beginLatencySimulator",value:function(e){this._simulate_latency={latency:e||1e3,enabled:!0}}},{key:"ut_endLatencySimulator",value:function(){this._simulate_latency=null}}])&&Qc(n.prototype,r),t}(qi);function ou(e){return(ou="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 su(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function cu(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){su(a,r,i,o,s,"next",e)}function s(e){su(a,r,i,o,s,"throw",e)}o(void 0)}))}}function uu(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=t.environment,r=t.platform,i=t.namespace,a=t.host,o=t.deviceInterface,s=t.swapClasses,c=t.skipClasses,u=t.crypto;if(vu(this,e),!o)throw"Device Interface must be supplied.";if(!n)throw"Environment must be supplied when creating an application.";if(!r)throw"Platform must be supplied when creating an application.";this.environment=n,this.platform=r,this.namespace=i||"",this.host=a,this.deviceInterface=o,this.crypto=u,this.swapClasses=s,this.skipClasses=c,this.eventHandlers=[],this.services=[],this.streamObservers=[],this.serviceObservers=[],this.managedSubscribers=[],this.constructServices()}var t,n,r,i,s,u,l,f,p,h,d,v,b,w,k,x,S,_,$,P,O,C,E,A,I,j,D,M,T,R,L,N,F,U,K,V,B,H,z,W,q,G,Y,J,Q,Z,X,ee;return t=e,(n=[{key:"prepareForLaunch",value:(ee=du(a.a.mark((function e(t){var n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.callbacks).requiresChallengeResponses){e.next=3;break}throw"Application.launch callbacks are not properly configured.";case 3:return this.launchCallbacks=n,e.next=6,this.deviceInterface.openDatabase();case 6:return e.next=8,this.migrationService.initialize();case 8:return e.next=10,this.handleStage(0);case 10:return e.next=12,this.storageService.initializeFromDisk();case 12:return e.next=14,this.keyManager.initialize();case 14:return e.next=16,this.handleStage(.5);case 16:return this.started=!0,e.next=19,this.notifyEvent(g.Started);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return ee.apply(this,arguments)})},{key:"launch",value:(X=du(a.a.mark((function e(){var t,n,r,i,o=this,s=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=s.length>0&&void 0!==s[0]?s[0]:{},n=t.awaitDatabaseLoad,e.next=3,this.handleLaunchAuthentication();case 3:return e.next=5,this.storageService.isStorageWrapped();case 5:if(!e.sent){e.next=8;break}return e.next=8,this.storageService.decryptStorage();case 8:return e.next=10,this.handleStage(.9);case 10:return e.next=12,this.sessionManager.initializeFromDisk();case 12:return this.historyManager.initializeFromDisk(),this.unlocked=!0,e.next=16,this.notifyEvent(g.Launched);case 16:return e.next=18,this.handleStage(1);case 18:return e.next=20,this.syncService.getDatabasePayloads();case 20:return r=e.sent,e.next=23,this.handleStage(1.1);case 23:if(i=this.syncService.loadDatabasePayloads(r).then(du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!o.dealloced){e.next=2;break}throw"Application has been destroyed.";case 2:return e.next=4,o.handleStage(1.2);case 4:return o.beginAutoSyncTimer(),e.abrupt("return",o.syncService.sync({mode:ru.DownloadFirst}));case 6:case"end":return e.stop()}}),e)})))),!n){e.next=27;break}return e.next=27,i;case 27:case"end":return e.stop()}}),e,this)}))),function(){return X.apply(this,arguments)})},{key:"beginAutoSyncTimer",value:function(){var e=this;this.autoSyncInterval=this.deviceInterface.interval((function(){e.syncService.log("Syncing from autosync"),e.sync()}),3e4)}},{key:"handleLaunchAuthentication",value:(Z=du(a.a.mark((function e(){var t;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deviceAuthService.getLaunchChallenges();case 2:return t=e.sent,e.next=5,this.handleLaunchChallenge(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return Z.apply(this,arguments)})},{key:"handleLaunchChallenge",value:(Q=du(a.a.mark((function e(t){var n,r,i,s,c,u,l,f,p;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.slice();case 1:if(!(n.length>0)){e.next=43;break}return e.next=4,this.launchCallbacks.requiresChallengeResponses(n);case 4:r=e.sent,i=Array.isArray(r)?r:[r],s=!0,c=!1,u=void 0,e.prev=9,l=i[Symbol.iterator]();case 11:if(s=(f=l.next()).done){e.next=27;break}return p=f.value,e.next=15,this.deviceAuthService.validateChallengeResponse(p);case 15:if(!e.sent){e.next=22;break}return e.next=19,this.deviceAuthService.handleChallengeResponse(p);case 19:Object(o.u)(n,p.challenge),e.next=24;break;case 22:return e.next=24,this.launchCallbacks.handleChallengeFailures([p]);case 24:s=!0,e.next=11;break;case 27:e.next=33;break;case 29:e.prev=29,e.t0=e.catch(9),c=!0,u=e.t0;case 33:e.prev=33,e.prev=34,s||null==l.return||l.return();case 36:if(e.prev=36,!c){e.next=39;break}throw u;case 39:return e.finish(36);case 40:return e.finish(33);case 41:e.next=1;break;case 43:case"end":return e.stop()}}),e,this,[[9,29,33,41],[34,,36,40]])}))),function(e){return Q.apply(this,arguments)})},{key:"getMigrationChallengeResponder",value:function(){var e=this;return function(){var t=du(a.a.mark((function t(n){var r;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.launchCallbacks.requiresChallengeResponses([n]);case 2:return r=t.sent,t.abrupt("return",r[0]);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()}},{key:"handleStage",value:(J=du(a.a.mark((function e(t){var n,r,i,o,s,c;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=!0,r=!1,i=void 0,e.prev=3,o=this.services[Symbol.iterator]();case 5:if(n=(s=o.next()).done){e.next=12;break}return c=s.value,e.next=9,c.handleApplicationStage(t);case 9:n=!0,e.next=5;break;case 12:e.next=18;break;case 14:e.prev=14,e.t0=e.catch(3),r=!0,i=e.t0;case 18:e.prev=18,e.prev=19,n||null==o.return||o.return();case 21:if(e.prev=21,!r){e.next=24;break}throw i;case 24:return e.finish(21);case 25:return e.finish(18);case 26:case"end":return e.stop()}}),e,this,[[3,14,18,26],[19,,21,25]])}))),function(e){return J.apply(this,arguments)})},{key:"addEventObserver",value:function(e,t){var n=this,r={callback:e,singleEvent:t};return this.eventHandlers.push(r),function(){Object(o.u)(n.eventHandlers,r)}}},{key:"addSingleEventObserver",value:function(e,t){return this.addEventObserver((function(n){n===e&&t()}),e)}},{key:"notifyEvent",value:(Y=du(a.a.mark((function e(t,n){var r,i,o,s,c,u;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=!0,i=!1,o=void 0,e.prev=3,s=this.eventHandlers.slice()[Symbol.iterator]();case 5:if(r=(c=s.next()).done){e.next=18;break}if(!(u=c.value).singleEvent||u.singleEvent!==t){e.next=12;break}return e.next=10,u.callback(t,n||{});case 10:e.next=15;break;case 12:if(u.singleEvent){e.next=15;break}return e.next=15,u.callback(t,n||{});case 15:r=!0,e.next=5;break;case 18:e.next=24;break;case 20:e.prev=20,e.t0=e.catch(3),i=!0,o=e.t0;case 24:e.prev=24,e.prev=25,r||null==s.return||s.return();case 27:if(e.prev=27,!i){e.next=30;break}throw o;case 30:return e.finish(27);case 31:return e.finish(24);case 32:case"end":return e.stop()}}),e,this,[[3,20,24,32],[25,,27,31]])}))),function(e,t){return Y.apply(this,arguments)})},{key:"isDatabaseLoaded",value:function(){return this.syncService.isDatabaseLoaded()}},{key:"savePayload",value:(G=du(a.a.mark((function e(t){var n,r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.payload,r=Ui({payload:n,override:{dirty:!0}}),e.next=4,this.modelManager.mapPayloadToLocalItem({payload:r});case 4:return e.next=6,this.syncService.sync();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return G.apply(this,arguments)})},{key:"findItem",value:function(e){var t=e.uuid;return this.modelManager.findItem(t)}},{key:"findItems",value:function(e){var t=e.predicate;return this.modelManager.itemsMatchingPredicate(t)}},{key:"mergeItem",value:(q=du(a.a.mark((function e(t){var n,r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.item,r=t.source,e.abrupt("return",this.modelManager.mapItem({item:n,source:r}));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return q.apply(this,arguments)})},{key:"createItem",value:(W=du(a.a.mark((function e(t){var n,r,i,o,s;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.contentType,r=t.content,i=t.add,o=t.needsSync,e.next=3,this.modelManager.createItem({contentType:n,content:r,add:i,needsSync:o});case 3:return s=e.sent,e.abrupt("return",s);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return W.apply(this,arguments)})},{key:"saveItem",value:(z=du(a.a.mark((function e(t){var n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.item,e.next=3,this.modelManager.setItemDirty(n,!0);case 3:return e.next=5,this.syncService.sync();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return z.apply(this,arguments)})},{key:"saveItems",value:(H=du(a.a.mark((function e(t){var n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.items,e.next=3,this.modelManager.setItemsDirty(n);case 3:return e.next=5,this.syncService.sync();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return H.apply(this,arguments)})},{key:"setItemNeedsSync",value:(B=du(a.a.mark((function e(t){var n,r;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.item,r=t.updateUserModifiedDate,e.abrupt("return",this.modelManager.setItemDirty(n,!0,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return B.apply(this,arguments)})},{key:"setItemsNeedsSync",value:(V=du(a.a.mark((function e(t){var n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.items,e.abrupt("return",this.modelManager.setItemsDirty(n));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return V.apply(this,arguments)})},{key:"deleteItem",value:(K=du(a.a.mark((function e(t){var n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.item,this.modelManager.setItemToBeDeleted(n),this.sync();case 3:case"end":return e.stop()}}),e,this)}))),function(e){return K.apply(this,arguments)})},{key:"deleteItemLocally",value:(U=du(a.a.mark((function e(t){var n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.item,this.modelManager.removeItemLocally(n);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return U.apply(this,arguments)})},{key:"emptyTrash",value:(F=du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.modelManager.emptyTrash();case 2:return e.abrupt("return",this.sync());case 3:case"end":return e.stop()}}),e,this)}))),function(){return F.apply(this,arguments)})},{key:"getTrashedItems",value:function(){return this.modelManager.trashedItems()}},{key:"getItems",value:function(e){var t=e.contentType;return this.modelManager.getItems(t)}},{key:"getDisplayableItems",value:function(e){var t=e.contentType;return this.modelManager.validItemsForContentType(t)}},{key:"getNotesMatchingSmartTag",value:function(e){var t=e.smartTag;return this.modelManager.notesMatchingSmartTag(t)}},{key:"findTag",value:function(e){var t=e.title;return this.modelManager.findTagByTitle(t)}},{key:"findOrCreateTag",value:(N=du(a.a.mark((function e(t){var n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.title,e.abrupt("return",this.modelManager.findOrCreateTagByTitle(n));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return N.apply(this,arguments)})},{key:"getSmartTags",value:function(){return this.modelManager.getSmartTags()}},{key:"getNoteCount",value:function(){return this.modelManager.noteCount()}},{key:"streamItems",value:function(e){var t=this,n=e.contentType,r=e.stream,i=this.modelManager.addMappingObserver(n,(function(e,t,n,i,a){var o=e.map((function(e){return e.content_type}));r({items:e,contentTypes:o,source:i,sourceKey:a})}));return this.streamObservers.push(i),function(){Object(o.u)(t.streamObservers,i)}}},{key:"setHost",value:(L=du(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.apiService.setHost(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"getHost",value:(R=du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.apiService.getHost());case 1:case"end":return e.stop()}}),e,this)}))),function(){return R.apply(this,arguments)})},{key:"getUser",value:function(){if(!this.unlocked)throw"Attempting to access user before application unlocked";return this.sessionManager.getUser()}},{key:"getUserVersion",value:(T=du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.getUserVersion());case 1:case"end":return e.stop()}}),e,this)}))),function(){return T.apply(this,arguments)})},{key:"protocolUpgradeAvailable",value:(M=du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.upgradeAvailable());case 1:case"end":return e.stop()}}),e,this)}))),function(){return M.apply(this,arguments)})},{key:"noAccount",value:function(){var e=this.getUser();return Object(o.l)(e)}},{key:"importData",value:(D=du(a.a.mark((function e(t){var n,r,i,o,s,c,u;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.data,r=t.password,i=t.awaitSync,e.next=3,this.protocolService.payloadsByDecryptingBackupFile({data:n,password:r});case 3:return o=e.sent,s=o.filter((function(e){return!e.errorDecrypting})),e.next=7,this.modelManager.importPayloads(s);case 7:if(c=e.sent,u=this.sync(),!i){e.next=12;break}return e.next=12,u;case 12:return e.abrupt("return",{affectedItems:c,errorCount:o.length-s.length});case 13:case"end":return e.stop()}}),e,this)}))),function(e){return D.apply(this,arguments)})},{key:"createBackupFile",value:(j=du(a.a.mark((function e(){var t,n,r,i,o=arguments;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.length>0&&void 0!==o[0]?o[0]:{},n=t.subItems,r=t.intent,i=t.returnIfEmpty,e.abrupt("return",this.protocolService.createBackupFile({subItems:n,intent:r,returnIfEmpty:i}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return j.apply(this,arguments)})},{key:"isEphemeralSession",value:function(){return this.storageService.isEphemeralSession()}},{key:"lockSyncing",value:function(){this.syncService.lockSyncing()}},{key:"unlockSyncing",value:function(){this.syncService.unlockSyncing()}},{key:"getSyncStatus",value:(I=du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.syncService.status);case 1:case"end":return e.stop()}}),e,this)}))),function(){return I.apply(this,arguments)})},{key:"sync",value:(A=du(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.syncService.sync(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return A.apply(this,arguments)})},{key:"resolveOutOfSync",value:(E=du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.syncService.resolveOutOfSync());case 1:case"end":return e.stop()}}),e,this)}))),function(){return E.apply(this,arguments)})},{key:"setValue",value:(C=du(a.a.mark((function e(t,n,r){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.setValue(t,n,r));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return C.apply(this,arguments)})},{key:"getValue",value:(O=du(a.a.mark((function e(t,n){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.getValue(t,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return O.apply(this,arguments)})},{key:"removeValue",value:(P=du(a.a.mark((function e(t,n){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.removeValue(t,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return P.apply(this,arguments)})},{key:"clearDatabase",value:($=du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.clearAllPayloads());case 1:case"end":return e.stop()}}),e,this)}))),function(){return $.apply(this,arguments)})},{key:"rewriteItemsKeys",value:(_=du(a.a.mark((function e(){var t,n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.itemsKeyManager.allItemsKeys,n=t.map((function(e){return e.payloadRepresentation()})),e.next=4,this.storageService.deletePayloads(n);case 4:return e.next=6,this.syncService.persistPayloads({decryptedPayloads:n});case 6:case"end":return e.stop()}}),e,this)}))),function(){return _.apply(this,arguments)})},{key:"restart",value:(S=du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deinit();case 2:return this.dealloced=!1,this.constructServices(),e.next=6,this.prepareForLaunch({callbacks:this.launchCallbacks});case 6:return e.next=8,this.launch({awaitDatabaseLoad:!0});case 8:case"end":return e.stop()}}),e,this)}))),function(){return S.apply(this,arguments)})},{key:"deinit",value:(x=du(a.a.mark((function e(){var t,n,r,i,o,s,c,u,l,f,p,h,d,v,y,m;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(clearInterval(this.autoSyncInterval),t=!0,n=!1,r=void 0,e.prev=4,i=this.serviceObservers[Symbol.iterator]();!(t=(o=i.next()).done);t=!0)(0,o.value)();e.next=12;break;case 8:e.prev=8,e.t0=e.catch(4),n=!0,r=e.t0;case 12:e.prev=12,e.prev=13,t||null==i.return||i.return();case 15:if(e.prev=15,!n){e.next=18;break}throw r;case 18:return e.finish(15);case 19:return e.finish(12);case 20:for(s=!0,c=!1,u=void 0,e.prev=23,l=this.managedSubscribers[Symbol.iterator]();!(s=(f=l.next()).done);s=!0)(0,f.value)();e.next=31;break;case 27:e.prev=27,e.t1=e.catch(23),c=!0,u=e.t1;case 31:e.prev=31,e.prev=32,s||null==l.return||l.return();case 34:if(e.prev=34,!c){e.next=37;break}throw u;case 37:return e.finish(34);case 38:return e.finish(31);case 39:p=!0,h=!1,d=void 0,e.prev=42,v=this.services[Symbol.iterator]();case 44:if(p=(y=v.next()).done){e.next=52;break}if(!(m=y.value).deinit){e.next=49;break}return e.next=49,m.deinit();case 49:p=!0,e.next=44;break;case 52:e.next=58;break;case 54:e.prev=54,e.t2=e.catch(42),h=!0,d=e.t2;case 58:e.prev=58,e.prev=59,p||null==v.return||v.return();case 61:if(e.prev=61,!h){e.next=64;break}throw d;case 64:return e.finish(61);case 65:return e.finish(58);case 66:this.streamObservers=[],this.clearServices(),this.dealloced=!0,this.started=!1;case 70:case"end":return e.stop()}}),e,this,[[4,8,12,20],[13,,15,19],[23,27,31,39],[32,,34,38],[42,54,58,66],[59,,61,65]])}))),function(){return x.apply(this,arguments)})},{key:"registerService",value:function(e){this.services.push(e)}},{key:"register",value:(k=du(a.a.mark((function e(t){var n,r,i,o,s;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.email,r=t.password,i=t.ephemeral,o=t.mergeLocal,this.lockSyncing(),e.next=4,this.sessionManager.register({email:n,password:r});case 4:if((s=e.sent).response.error){e.next=27;break}return e.next=8,this.keyManager.setNewRootKey({key:s.rootKey,keyParams:s.keyParams});case 8:return this.syncService.resetSyncState(),e.next=11,this.storageService.setPersistencePolicy(i?Ro.Ephemeral:Ro.Default);case 11:if(!o){e.next=16;break}return e.next=14,this.syncService.markAllItemsAsNeedingSync({alternateUuids:!0});case 14:e.next=19;break;case 16:return this.modelManager.removeAllItemsFromMemory(),e.next=19,this.clearDatabase();case 19:return e.next=21,this.notifyEvent(g.SignedIn);case 21:return this.unlockSyncing(),e.next=24,this.syncService.sync({mode:ru.DownloadFirst,timingStrategy:nu});case 24:this.protocolService.decryptErroredItems(),e.next=28;break;case 27:this.unlockSyncing();case 28:return e.abrupt("return",s.response);case 29:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"signIn",value:(w=du(a.a.mark((function e(t){var n,r,i,o,s,c,u,l,f;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.email,r=t.password,i=t.strict,o=t.ephemeral,s=t.mfaKeyPath,c=t.mfaCode,u=t.mergeLocal,l=void 0===u||u,this.lockSyncing(),e.next=4,this.sessionManager.signIn({email:n,password:r,strict:i,mfaKeyPath:s,mfaCode:c});case 4:if((f=e.sent).response.error){e.next=27;break}return e.next=8,this.keyManager.setNewRootKey({key:f.rootKey,keyParams:f.keyParams});case 8:return this.syncService.resetSyncState(),e.next=11,this.storageService.setPersistencePolicy(o?Ro.Ephemeral:Ro.Default);case 11:if(!l){e.next=16;break}return e.next=14,this.syncService.markAllItemsAsNeedingSync({alternateUuids:!0});case 14:e.next=19;break;case 16:return this.modelManager.removeAllItemsFromMemory(),e.next=19,this.clearDatabase();case 19:return e.next=21,this.notifyEvent(g.SignedIn);case 21:return this.unlockSyncing(),e.next=24,this.syncService.sync({mode:ru.DownloadFirst,checkIntegrity:!0,timingStrategy:nu});case 24:this.protocolService.decryptErroredItems(),e.next=28;break;case 27:this.unlockSyncing();case 28:return e.abrupt("return",f.response);case 29:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"changePassword",value:(b=du(a.a.mark((function e(t){var n,r,i,o,s;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.email,r=t.currentPassword,i=t.newPassword,e.next=3,this.keyManager.getRootKeyParams();case 3:return o=e.sent,this.lockSyncing(),e.next=7,this.sessionManager.changePassword({email:n,currentPassword:r,currentKeyParams:o,newPassword:i});case 7:if((s=e.sent).response.error){e.next=18;break}return e.next=11,this.keyManager.setNewRootKey({key:s.rootKey,keyParams:s.keyParams});case 11:return e.next=13,this.itemsKeyManager.createNewDefaultItemsKey();case 13:return this.unlockSyncing(),e.next=16,this.syncService.sync();case 16:e.next=19;break;case 18:this.unlockSyncing();case 19:return e.abrupt("return",s.response);case 20:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"signOut",value:(v=du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sessionManager.signOut();case 2:return e.next=4,this.keyManager.clearLocalKeyState();case 4:return e.next=6,this.storageService.clearAllData();case 6:return e.next=8,this.notifyEvent(g.SignedOut);case 8:return e.next=10,this.restart();case 10:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"validateAccountPassword",value:(d=du(a.a.mark((function e(t){var n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.password,e.abrupt("return",this.keyManager.validateAccountPassword(n));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"isStarted",value:function(){return this.started}},{key:"hasPasscode",value:function(){return this.keyManager.hasPasscode()}},{key:"isLocked",value:(h=du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.started){e.next=2;break}return e.abrupt("return",!0);case 2:return e.abrupt("return",this.deviceAuthService.isPasscodeLocked());case 3:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"lock",value:(p=du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.restart());case 1:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"setPasscode",value:(f=du(a.a.mark((function e(t){var n,r,i,o;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.protocolService.crypto.generateUUID();case 2:return n=e.sent,e.next=5,this.protocolService.createRootKey({identifier:n,password:t});case 5:return r=e.sent,i=r.key,o=r.keyParams,e.next=10,this.keyManager.setNewRootKeyWrapper({wrappingKey:i,keyParams:o});case 10:return e.next=12,this.rewriteItemsKeys();case 12:return e.next=14,this.syncService.sync();case 14:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"removePasscode",value:(l=du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.keyManager.removeRootKeyWrapper();case 2:return e.next=4,this.rewriteItemsKeys();case 4:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"changePasscode",value:(u=du(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.removePasscode();case 2:return e.abrupt("return",this.setPasscode(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"setStorageEncryptionPolicy",value:(s=du(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.storageService.setEncryptionPolicy(t);case 2:return e.abrupt("return",this.syncService.repersistAllItems());case 3:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"generateUuid",value:(i=du(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.crypto.generateUUID());case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"changeDeviceInterface",value:(r=du(a.a.mark((function e(t){var n,r,i,o,s,c;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(this.deviceInterface=t,n=!0,r=!1,i=void 0,e.prev=4,o=this.services[Symbol.iterator]();!(n=(s=o.next()).done);n=!0)(c=s.value).deviceInterface&&(c.deviceInterface=t);e.next=12;break;case 8:e.prev=8,e.t0=e.catch(4),r=!0,i=e.t0;case 12:e.prev=12,e.prev=13,n||null==o.return||o.return();case 15:if(e.prev=15,!r){e.next=18;break}throw i;case 18:return e.finish(15);case 19:return e.finish(12);case 20:case"end":return e.stop()}}),e,this,[[4,8,12,20],[13,,15,19]])}))),function(e){return r.apply(this,arguments)})},{key:"constructServices",value:function(){this.createModelManager(),this.createProtocolService(this.modelManager),this.createMigrationService(),this.createAlertManager(),this.createHttpManager(),this.createStorageManager(),this.createApiService(),this.createSessionManager(),this.createSyncManager(),this.createItemsKeyManager(),this.createKeyManager(),this.protocolService.setKeyManager(this.keyManager),this.protocolService.setItemsKeyManager(this.itemsKeyManager),this.itemsKeyManager.setKeyManager(this.keyManager),this.createDeviceAuthService(),this.createSingletonManager(),this.createComponentManager(),this.createPrivilegesManager(),this.createHistoryManager(),this.createActionsManager()}},{key:"clearServices",value:function(){this.migrationService=null,this.alertService=null,this.httpService=null,this.modelManager=null,this.protocolService=null,this.storageService=null,this.apiService=null,this.sessionManager=null,this.syncService=null,this.keyManager=null,this.itemsKeyManager=null,this.deviceAuthService=null,this.singletonManager=null,this.componentManager=null,this.privilegesService=null,this.actionsManager=null,this.services=[]}},{key:"createMigrationService",value:function(){this.migrationService=new(this.getClass(hs))({application:this,challengeResponder:this.getMigrationChallengeResponder()}),this.services.push(this.migrationService)}},{key:"createAlertManager",value:function(){this.shouldSkipClass(ea)||(this.alertService=new(this.getClass(ea))({deviceInterface:this.deviceInterface}),this.services.push(this.alertService))}},{key:"createApiService",value:function(){this.apiService=new(this.getClass(xa))({storageService:this.storageService,httpService:this.httpService,host:this.host}),this.services.push(this.apiService)}},{key:"createComponentManager",value:function(){this.shouldSkipClass(Va)||(this.componentManager=new(this.getClass(Va))({modelManager:this.modelManager,syncService:this.syncService,alertService:this.alertService,timeout:this.deviceInterface.timeout,environment:this.environment,platform:this.platform}),this.services.push(this.componentManager))}},{key:"createHttpManager",value:function(){this.httpService=new(this.getClass(Qa)),this.services.push(this.httpService)}},{key:"createKeyManager",value:function(){var e=this;this.keyManager=new(this.getClass(dc))({modelManager:this.modelManager,storageService:this.storageService,protocolService:this.protocolService,itemsKeyManager:this.itemsKeyManager,deviceInterface:this.deviceInterface}),this.keyManager.onStatusChange(du(a.a.mark((function t(){return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.notifyEvent(g.KeyStatusChanged);case 2:case"end":return t.stop()}}),t)})))),this.services.push(this.keyManager)}},{key:"createItemsKeyManager",value:function(){this.itemsKeyManager=new(this.getClass(xc))({modelManager:this.modelManager,syncService:this.syncService,protocolService:this.protocolService}),this.services.push(this.itemsKeyManager)}},{key:"createModelManager",value:function(){this.modelManager=new(this.getClass(co)),this.services.push(this.modelManager)}},{key:"createSingletonManager",value:function(){this.singletonManager=new(this.getClass(yo))({modelManager:this.modelManager,syncService:this.syncService}),this.services.push(this.singletonManager)}},{key:"createStorageManager",value:function(){this.storageService=new(this.getClass(Uo))({protocolService:this.protocolService,namespace:this.namespace,deviceInterface:this.deviceInterface}),this.services.push(this.storageService)}},{key:"createProtocolService",value:function(e){this.protocolService=new(this.getClass(xs))({modelManager:e,crypto:this.crypto}),this.services.push(this.protocolService)}},{key:"createSessionManager",value:function(){this.sessionManager=new(this.getClass(la))({storageService:this.storageService,alertService:this.alertService,protocolService:this.protocolService,apiService:this.apiService,timeout:this.deviceInterface.timeout}),this.services.push(this.sessionManager)}},{key:"createSyncManager",value:function(){var e=this;this.syncService=new(this.getClass(au))({modelManager:this.modelManager,storageService:this.storageService,sessionManager:this.sessionManager,protocolService:this.protocolService,apiService:this.apiService,interval:this.deviceInterface.interval});var t=this.syncService.addEventObserver(function(){var t=du(a.a.mark((function t(n){var r;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=n,!(r=(a={},m(a,y.FullSyncCompleted,g.CompletedSync),m(a,y.SyncError,g.FailedSync),m(a,y.SyncTakingTooLong,g.HighLatencySync),m(a,y.EnterOutOfSync,g.EnteredOutOfSync),m(a,y.ExitOutOfSync,g.ExitedOutOfSync),a)[i])){t.next=4;break}return t.next=4,e.notifyEvent(r);case 4:case"end":return t.stop()}var i,a}),t)})));return function(e){return t.apply(this,arguments)}}());this.serviceObservers.push(t),this.services.push(this.syncService)}},{key:"createDeviceAuthService",value:function(){this.deviceAuthService=new(this.getClass(pu))({storageService:this.storageService,protocolService:this.protocolService,keyManager:this.keyManager}),this.services.push(this.deviceAuthService)}},{key:"createPrivilegesManager",value:function(){this.privilegesService=new(this.getClass(nc))({storageService:this.storageService,keyManager:this.keyManager,modelManager:this.modelManager,syncService:this.syncService,sessionManager:this.sessionManager,singletonManager:this.singletonManager}),this.services.push(this.privilegesService)}},{key:"createHistoryManager",value:function(){this.historyManager=new(this.getClass(Bs))({storageService:this.storageService,modelManager:this.modelManager,contentTypes:[c.Note],timeout:this.deviceInterface.timeout}),this.services.push(this.historyManager)}},{key:"createActionsManager",value:function(){this.actionsManager=new(this.getClass(So))({alertService:this.alertService,deviceInterface:this.deviceInterface,httpService:this.httpService,modelManager:this.modelManager,protocolService:this.protocolService,syncService:this.syncService}),this.services.push(this.actionsManager)}},{key:"shouldSkipClass",value:function(e){return this.skipClasses&&this.skipClasses.includes(e)}},{key:"getClass",value:function(e){var t=this.swapClasses&&this.swapClasses.find((function(t){return t.swap===e}));return t?t.with:e}}])&&yu(t.prototype,n),e}();function gu(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function bu(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){gu(a,r,i,o,s,"next",e)}function s(e){gu(a,r,i,o,s,"throw",e)}o(void 0)}))}}function wu(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ku(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=t.namespace,r=t.timeout,i=t.interval;if(wu(this,e),!r||!i)throw"'timeout' and 'interval' are required to initialize device interface.";this.namespace=n,this.timeout=r||setTimeout.bind(Object(o.h)()),this.interval=i||setInterval.bind(Object(o.h)())}var t,n,r,i,s,c,u,l,f,p,h,d,v,y,m,g,b;return t=e,(n=[{key:"getRawStorageValue",value:(b=bu(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.getRawStorageValue";case 1:case"end":return e.stop()}}),e)}))),function(e){return b.apply(this,arguments)})},{key:"getJsonParsedStorageValue",value:(g=bu(a.a.mark((function e(t){var n;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getRawStorageValue(t);case 2:return n=e.sent,e.abrupt("return",n?JSON.parse(n):n);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"getAllRawStorageKeyValues",value:(m=bu(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.getAllRawStorageKeyValues";case 1:case"end":return e.stop()}}),e)}))),function(){return m.apply(this,arguments)})},{key:"setRawStorageValue",value:(y=bu(a.a.mark((function e(t,n){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.setRawStorageValue";case 1:case"end":return e.stop()}}),e)}))),function(e,t){return y.apply(this,arguments)})},{key:"removeRawStorageValue",value:(v=bu(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.removeRawStorageValue";case 1:case"end":return e.stop()}}),e)}))),function(e){return v.apply(this,arguments)})},{key:"removeAllRawStorageValues",value:(d=bu(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.removeAllRawStorageValues";case 1:case"end":return e.stop()}}),e)}))),function(){return d.apply(this,arguments)})},{key:"openDatabase",value:(h=bu(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.openDatabase";case 1:case"end":return e.stop()}}),e)}))),function(){return h.apply(this,arguments)})},{key:"getAllRawDatabasePayloads",value:(p=bu(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.getAllRawDatabasePayloads";case 1:case"end":return e.stop()}}),e)}))),function(){return p.apply(this,arguments)})},{key:"saveRawDatabasePayload",value:(f=bu(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.saveRawDatabasePayload";case 1:case"end":return e.stop()}}),e)}))),function(e){return f.apply(this,arguments)})},{key:"saveRawDatabasePayloads",value:(l=bu(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.saveRawDatabasePayloads";case 1:case"end":return e.stop()}}),e)}))),function(e){return l.apply(this,arguments)})},{key:"removeRawDatabasePayloadWithId",value:(u=bu(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.removeRawDatabasePayloadWithId";case 1:case"end":return e.stop()}}),e)}))),function(e){return u.apply(this,arguments)})},{key:"removeAllRawDatabasePayloads",value:(c=bu(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.removeAllRawDatabasePayloads";case 1:case"end":return e.stop()}}),e)}))),function(){return c.apply(this,arguments)})},{key:"getKeychainValue",value:(s=bu(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.getKeychainValue";case 1:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"setKeychainValue",value:(i=bu(a.a.mark((function e(t){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.setKeychainValue";case 1:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"clearKeychainValue",value:(r=bu(a.a.mark((function e(){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw"Must override DeviceInterface.clearKeychainValue";case 1:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)})}])&&ku(t.prototype,n),e}(),Su=function e(t){var n=t.challenge,r=t.value;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.challenge=n,this.value=r,Object.freeze(this)}}])},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(e,t){for(var n=0;n]/;function c(e){var t=""+e,n=s.exec(t);if(!n)return e;var r,i,a,o="";for(r=n.index,i=0;r ":" ")+n+"| "+e})).join("\n");throw t.path=r,t.message=(r||"Pug")+":"+i+"\n"+o+"\n\n"+t.message,t}},function(e,t){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}},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},function(e,t,n){var r=n(38),i="object"==typeof self&&self&&self.Object===Object&&self,a=r||i||Function("return this")();e.exports=a},function(e,t,n){(function(e,r){var i; /** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */(function(){var a="Expected a function",o="__lodash_placeholder__",s=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]],c="[object Arguments]",u="[object Array]",l="[object Boolean]",f="[object Date]",p="[object Error]",h="[object Function]",d="[object GeneratorFunction]",v="[object Map]",y="[object Number]",m="[object Object]",g="[object RegExp]",b="[object Set]",w="[object String]",k="[object Symbol]",x="[object WeakMap]",S="[object ArrayBuffer]",_="[object DataView]",$="[object Float32Array]",P="[object Float64Array]",O="[object Int8Array]",C="[object Int16Array]",E="[object Int32Array]",A="[object Uint8Array]",I="[object Uint16Array]",j="[object Uint32Array]",D=/\b__p \+= '';/g,M=/\b(__p \+=) '' \+/g,T=/(__e\(.*?\)|\b__t\)) \+\n'';/g,R=/&(?:amp|lt|gt|quot|#39);/g,L=/[&<>"']/g,N=RegExp(R.source),F=RegExp(L.source),U=/<%-([\s\S]+?)%>/g,K=/<%([\s\S]+?)%>/g,V=/<%=([\s\S]+?)%>/g,B=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,H=/^\w*$/,z=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,W=/[\\^$.*+?()[\]{}|]/g,q=RegExp(W.source),G=/^\s+|\s+$/g,Y=/^\s+/,J=/\s+$/,Q=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Z=/\{\n\/\* \[wrapped with (.+)\] \*/,X=/,? & /,ee=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,te=/\\(\\)?/g,ne=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,re=/\w*$/,ie=/^[-+]0x[0-9a-f]+$/i,ae=/^0b[01]+$/i,oe=/^\[object .+?Constructor\]$/,se=/^0o[0-7]+$/i,ce=/^(?:0|[1-9]\d*)$/,ue=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,le=/($^)/,fe=/['\n\r\u2028\u2029\\]/g,pe="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",he="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",de="[\\ud800-\\udfff]",ve="["+he+"]",ye="["+pe+"]",me="\\d+",ge="[\\u2700-\\u27bf]",be="[a-z\\xdf-\\xf6\\xf8-\\xff]",we="[^\\ud800-\\udfff"+he+me+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",ke="\\ud83c[\\udffb-\\udfff]",xe="[^\\ud800-\\udfff]",Se="(?:\\ud83c[\\udde6-\\uddff]){2}",_e="[\\ud800-\\udbff][\\udc00-\\udfff]",$e="[A-Z\\xc0-\\xd6\\xd8-\\xde]",Pe="(?:"+be+"|"+we+")",Oe="(?:"+$e+"|"+we+")",Ce="(?:"+ye+"|"+ke+")"+"?",Ee="[\\ufe0e\\ufe0f]?"+Ce+("(?:\\u200d(?:"+[xe,Se,_e].join("|")+")[\\ufe0e\\ufe0f]?"+Ce+")*"),Ae="(?:"+[ge,Se,_e].join("|")+")"+Ee,Ie="(?:"+[xe+ye+"?",ye,Se,_e,de].join("|")+")",je=RegExp("['’]","g"),De=RegExp(ye,"g"),Me=RegExp(ke+"(?="+ke+")|"+Ie+Ee,"g"),Te=RegExp([$e+"?"+be+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[ve,$e,"$"].join("|")+")",Oe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[ve,$e+Pe,"$"].join("|")+")",$e+"?"+Pe+"+(?:['’](?:d|ll|m|re|s|t|ve))?",$e+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",me,Ae].join("|"),"g"),Re=RegExp("[\\u200d\\ud800-\\udfff"+pe+"\\ufe0e\\ufe0f]"),Le=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ne=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Fe=-1,Ue={};Ue[$]=Ue[P]=Ue[O]=Ue[C]=Ue[E]=Ue[A]=Ue["[object Uint8ClampedArray]"]=Ue[I]=Ue[j]=!0,Ue[c]=Ue[u]=Ue[S]=Ue[l]=Ue[_]=Ue[f]=Ue[p]=Ue[h]=Ue[v]=Ue[y]=Ue[m]=Ue[g]=Ue[b]=Ue[w]=Ue[x]=!1;var Ke={};Ke[c]=Ke[u]=Ke[S]=Ke[_]=Ke[l]=Ke[f]=Ke[$]=Ke[P]=Ke[O]=Ke[C]=Ke[E]=Ke[v]=Ke[y]=Ke[m]=Ke[g]=Ke[b]=Ke[w]=Ke[k]=Ke[A]=Ke["[object Uint8ClampedArray]"]=Ke[I]=Ke[j]=!0,Ke[p]=Ke[h]=Ke[x]=!1;var Ve={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Be=parseFloat,He=parseInt,ze="object"==typeof e&&e&&e.Object===Object&&e,We="object"==typeof self&&self&&self.Object===Object&&self,qe=ze||We||Function("return this")(),Ge=t&&!t.nodeType&&t,Ye=Ge&&"object"==typeof r&&r&&!r.nodeType&&r,Je=Ye&&Ye.exports===Ge,Qe=Je&&ze.process,Ze=function(){try{var e=Ye&&Ye.require&&Ye.require("util").types;return e||Qe&&Qe.binding&&Qe.binding("util")}catch(e){}}(),Xe=Ze&&Ze.isArrayBuffer,et=Ze&&Ze.isDate,tt=Ze&&Ze.isMap,nt=Ze&&Ze.isRegExp,rt=Ze&&Ze.isSet,it=Ze&&Ze.isTypedArray;function at(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function ot(e,t,n,r){for(var i=-1,a=null==e?0:e.length;++i-1}function pt(e,t,n){for(var r=-1,i=null==e?0:e.length;++r-1;);return n}function Mt(e,t){for(var n=e.length;n--&&kt(t,e[n],0)>-1;);return n}function Tt(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var Rt=Pt({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Lt=Pt({"&":"&","<":"<",">":">",'"':""","'":"'"});function Nt(e){return"\\"+Ve[e]}function Ft(e){return Re.test(e)}function Ut(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function Kt(e,t){return function(n){return e(t(n))}}function Vt(e,t){for(var n=-1,r=e.length,i=0,a=[];++n",""":'"',"'":"'"});var Gt=function e(t){var n,r=(t=null==t?qe:Gt.defaults(qe.Object(),t,Gt.pick(qe,Ne))).Array,i=t.Date,pe=t.Error,he=t.Function,de=t.Math,ve=t.Object,ye=t.RegExp,me=t.String,ge=t.TypeError,be=r.prototype,we=he.prototype,ke=ve.prototype,xe=t["__core-js_shared__"],Se=we.toString,_e=ke.hasOwnProperty,$e=0,Pe=(n=/[^.]+$/.exec(xe&&xe.keys&&xe.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Oe=ke.toString,Ce=Se.call(ve),Ee=qe._,Ae=ye("^"+Se.call(_e).replace(W,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ie=Je?t.Buffer:void 0,Me=t.Symbol,Re=t.Uint8Array,Ve=Ie?Ie.allocUnsafe:void 0,ze=Kt(ve.getPrototypeOf,ve),We=ve.create,Ge=ke.propertyIsEnumerable,Ye=be.splice,Qe=Me?Me.isConcatSpreadable:void 0,Ze=Me?Me.iterator:void 0,gt=Me?Me.toStringTag:void 0,Pt=function(){try{var e=Xi(ve,"defineProperty");return e({},"",{}),e}catch(e){}}(),Yt=t.clearTimeout!==qe.clearTimeout&&t.clearTimeout,Jt=i&&i.now!==qe.Date.now&&i.now,Qt=t.setTimeout!==qe.setTimeout&&t.setTimeout,Zt=de.ceil,Xt=de.floor,en=ve.getOwnPropertySymbols,tn=Ie?Ie.isBuffer:void 0,nn=t.isFinite,rn=be.join,an=Kt(ve.keys,ve),on=de.max,sn=de.min,cn=i.now,un=t.parseInt,ln=de.random,fn=be.reverse,pn=Xi(t,"DataView"),hn=Xi(t,"Map"),dn=Xi(t,"Promise"),vn=Xi(t,"Set"),yn=Xi(t,"WeakMap"),mn=Xi(ve,"create"),gn=yn&&new yn,bn={},wn=Pa(pn),kn=Pa(hn),xn=Pa(dn),Sn=Pa(vn),_n=Pa(yn),$n=Me?Me.prototype:void 0,Pn=$n?$n.valueOf:void 0,On=$n?$n.toString:void 0;function Cn(e){if(Ho(e)&&!Do(e)&&!(e instanceof jn)){if(e instanceof In)return e;if(_e.call(e,"__wrapped__"))return Oa(e)}return new In(e)}var En=function(){function e(){}return function(t){if(!Bo(t))return{};if(We)return We(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function An(){}function In(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}function jn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}function Dn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Jn(e,t,n,r,i,a){var o,s=1&t,u=2&t,p=4&t;if(n&&(o=i?n(e,r,i,a):n(e)),void 0!==o)return o;if(!Bo(e))return e;var x=Do(e);if(x){if(o=function(e){var t=e.length,n=new e.constructor(t);t&&"string"==typeof e[0]&&_e.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!s)return mi(e,o)}else{var D=na(e),M=D==h||D==d;if(Lo(e))return fi(e,s);if(D==m||D==c||M&&!i){if(o=u||M?{}:ia(e),!s)return u?function(e,t){return gi(e,ta(e),t)}(e,function(e,t){return e&&gi(t,ks(t),e)}(o,e)):function(e,t){return gi(e,ea(e),t)}(e,Wn(o,e))}else{if(!Ke[D])return i?e:{};o=function(e,t,n){var r=e.constructor;switch(t){case S:return pi(e);case l:case f:return new r(+e);case _:return function(e,t){var n=t?pi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case $:case P:case O:case C:case E:case A:case"[object Uint8ClampedArray]":case I:case j:return hi(e,n);case v:return new r;case y:case w:return new r(e);case g:return function(e){var t=new e.constructor(e.source,re.exec(e));return t.lastIndex=e.lastIndex,t}(e);case b:return new r;case k:return i=e,Pn?ve(Pn.call(i)):{}}var i}(e,D,s)}}a||(a=new Ln);var T=a.get(e);if(T)return T;a.set(e,o),Yo(e)?e.forEach((function(r){o.add(Jn(r,t,n,r,e,a))})):zo(e)&&e.forEach((function(r,i){o.set(i,Jn(r,t,n,i,e,a))}));var R=x?void 0:(p?u?Wi:zi:u?ks:ws)(e);return st(R||e,(function(r,i){R&&(r=e[i=r]),Bn(o,i,Jn(r,t,n,i,e,a))})),o}function Qn(e,t,n){var r=n.length;if(null==e)return!r;for(e=ve(e);r--;){var i=n[r],a=t[i],o=e[i];if(void 0===o&&!(i in e)||!a(o))return!1}return!0}function Zn(e,t,n){if("function"!=typeof e)throw new ge(a);return ba((function(){e.apply(void 0,n)}),t)}function Xn(e,t,n,r){var i=-1,a=ft,o=!0,s=e.length,c=[],u=t.length;if(!s)return c;n&&(t=ht(t,At(n))),r?(a=pt,o=!1):t.length>=200&&(a=jt,o=!1,t=new Rn(t));e:for(;++i-1},Mn.prototype.set=function(e,t){var n=this.__data__,r=Hn(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Tn.prototype.clear=function(){this.size=0,this.__data__={hash:new Dn,map:new(hn||Mn),string:new Dn}},Tn.prototype.delete=function(e){var t=Qi(this,e).delete(e);return this.size-=t?1:0,t},Tn.prototype.get=function(e){return Qi(this,e).get(e)},Tn.prototype.has=function(e){return Qi(this,e).has(e)},Tn.prototype.set=function(e,t){var n=Qi(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Rn.prototype.add=Rn.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Rn.prototype.has=function(e){return this.__data__.has(e)},Ln.prototype.clear=function(){this.__data__=new Mn,this.size=0},Ln.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Ln.prototype.get=function(e){return this.__data__.get(e)},Ln.prototype.has=function(e){return this.__data__.has(e)},Ln.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Mn){var r=n.__data__;if(!hn||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Tn(r)}return n.set(e,t),this.size=n.size,this};var er=ki(cr),tr=ki(ur,!0);function nr(e,t){var n=!0;return er(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function rr(e,t,n){for(var r=-1,i=e.length;++r0&&n(s)?t>1?ar(s,t-1,n,r,i):dt(i,s):r||(i[i.length]=s)}return i}var or=xi(),sr=xi(!0);function cr(e,t){return e&&or(e,t,ws)}function ur(e,t){return e&&sr(e,t,ws)}function lr(e,t){return lt(t,(function(t){return Uo(e[t])}))}function fr(e,t){for(var n=0,r=(t=si(t,e)).length;null!=e&&nt}function vr(e,t){return null!=e&&_e.call(e,t)}function yr(e,t){return null!=e&&t in ve(e)}function mr(e,t,n){for(var i=n?pt:ft,a=e[0].length,o=e.length,s=o,c=r(o),u=1/0,l=[];s--;){var f=e[s];s&&t&&(f=ht(f,At(t))),u=sn(f.length,u),c[s]=!n&&(t||a>=120&&f.length>=120)?new Rn(s&&f):void 0}f=e[0];var p=-1,h=c[0];e:for(;++p=s)return c;var u=n[r];return c*("desc"==u?-1:1)}}return e.index-t.index}(e,t,n)}))}function Dr(e,t,n){for(var r=-1,i=t.length,a={};++r-1;)s!==e&&Ye.call(s,c,1),Ye.call(e,c,1);return e}function Tr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==a){var a=i;oa(i)?Ye.call(e,i,1):Xr(e,i)}}return e}function Rr(e,t){return e+Xt(ln()*(t-e+1))}function Lr(e,t){var n="";if(!e||t<1||t>9007199254740991)return n;do{t%2&&(n+=e),(t=Xt(t/2))&&(e+=e)}while(t);return n}function Nr(e,t){return wa(da(e,t,Ws),e+"")}function Fr(e){return Fn(Es(e))}function Ur(e,t){var n=Es(e);return Sa(n,Yn(t,0,n.length))}function Kr(e,t,n,r){if(!Bo(e))return e;for(var i=-1,a=(t=si(t,e)).length,o=a-1,s=e;null!=s&&++ia?0:a+t),(n=n>a?a:n)<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var o=r(a);++i>>1,o=e[a];null!==o&&!Qo(o)&&(n?o<=t:o=200){var u=t?null:Li(e);if(u)return Bt(u);o=!1,i=jt,c=new Rn}else c=t?[]:s;e:for(;++r=r?e:zr(e,t,n)}var li=Yt||function(e){return qe.clearTimeout(e)};function fi(e,t){if(t)return e.slice();var n=e.length,r=Ve?Ve(n):new e.constructor(n);return e.copy(r),r}function pi(e){var t=new e.constructor(e.byteLength);return new Re(t).set(new Re(e)),t}function hi(e,t){var n=t?pi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function di(e,t){if(e!==t){var n=void 0!==e,r=null===e,i=e==e,a=Qo(e),o=void 0!==t,s=null===t,c=t==t,u=Qo(t);if(!s&&!u&&!a&&e>t||a&&o&&c&&!s&&!u||r&&o&&c||!n&&c||!i)return 1;if(!r&&!a&&!u&&e1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(a=e.length>3&&"function"==typeof a?(i--,a):void 0,o&&sa(n[0],n[1],o)&&(a=i<3?void 0:a,i=1),t=ve(t);++r-1?i[a?t[o]:o]:void 0}}function Oi(e){return Hi((function(t){var n=t.length,r=n,i=In.prototype.thru;for(e&&t.reverse();r--;){var o=t[r];if("function"!=typeof o)throw new ge(a);if(i&&!s&&"wrapper"==Gi(o))var s=new In([],!0)}for(r=s?r:n;++r1&&b.reverse(),f&&us))return!1;var u=a.get(e);if(u&&a.get(t))return u==t;var l=-1,f=!0,p=2&n?new Rn:void 0;for(a.set(e,t),a.set(t,e);++l-1&&e%1==0&&e1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(Q,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return st(s,(function(n){var r="_."+n[0];t&n[1]&&!ft(e,r)&&e.push(r)})),e.sort()}(function(e){var t=e.match(Z);return t?t[1].split(X):[]}(r),n)))}function xa(e){var t=0,n=0;return function(){var r=cn(),i=16-(r-n);if(n=r,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function Sa(e,t){var n=-1,r=e.length,i=r-1;for(t=void 0===t?r:t;++n1?e[t-1]:void 0;return n="function"==typeof n?(e.pop(),n):void 0,qa(e,n)}));function eo(e){var t=Cn(e);return t.__chain__=!0,t}function to(e,t){return t(e)}var no=Hi((function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,i=function(t){return Gn(t,e)};return!(t>1||this.__actions__.length)&&r instanceof jn&&oa(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:to,args:[i],thisArg:void 0}),new In(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(void 0),e}))):this.thru(i)}));var ro=bi((function(e,t,n){_e.call(e,n)?++e[n]:qn(e,n,1)}));var io=Pi(Ia),ao=Pi(ja);function oo(e,t){return(Do(e)?st:er)(e,Ji(t,3))}function so(e,t){return(Do(e)?ct:tr)(e,Ji(t,3))}var co=bi((function(e,t,n){_e.call(e,n)?e[n].push(t):qn(e,n,[t])}));var uo=Nr((function(e,t,n){var i=-1,a="function"==typeof t,o=To(e)?r(e.length):[];return er(e,(function(e){o[++i]=a?at(t,e,n):gr(e,t,n)})),o})),lo=bi((function(e,t,n){qn(e,n,t)}));function fo(e,t){return(Do(e)?ht:Or)(e,Ji(t,3))}var po=bi((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]}));var ho=Nr((function(e,t){if(null==e)return[];var n=t.length;return n>1&&sa(e,t[0],t[1])?t=[]:n>2&&sa(t[0],t[1],t[2])&&(t=[t[0]]),jr(e,ar(t,1),[])})),vo=Jt||function(){return qe.Date.now()};function yo(e,t,n){return t=n?void 0:t,Fi(e,128,void 0,void 0,void 0,void 0,t=e&&null==t?e.length:t)}function mo(e,t){var n;if("function"!=typeof t)throw new ge(a);return e=rs(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=void 0),n}}var go=Nr((function(e,t,n){var r=1;if(n.length){var i=Vt(n,Yi(go));r|=32}return Fi(e,r,t,n,i)})),bo=Nr((function(e,t,n){var r=3;if(n.length){var i=Vt(n,Yi(bo));r|=32}return Fi(t,r,e,n,i)}));function wo(e,t,n){var r,i,o,s,c,u,l=0,f=!1,p=!1,h=!0;if("function"!=typeof e)throw new ge(a);function d(t){var n=r,a=i;return r=i=void 0,l=t,s=e.apply(a,n)}function v(e){return l=e,c=ba(m,t),f?d(e):s}function y(e){var n=e-u;return void 0===u||n>=t||n<0||p&&e-l>=o}function m(){var e=vo();if(y(e))return g(e);c=ba(m,function(e){var n=t-(e-u);return p?sn(n,o-(e-l)):n}(e))}function g(e){return c=void 0,h&&r?d(e):(r=i=void 0,s)}function b(){var e=vo(),n=y(e);if(r=arguments,i=this,u=e,n){if(void 0===c)return v(u);if(p)return li(c),c=ba(m,t),d(u)}return void 0===c&&(c=ba(m,t)),s}return t=as(t)||0,Bo(n)&&(f=!!n.leading,o=(p="maxWait"in n)?on(as(n.maxWait)||0,t):o,h="trailing"in n?!!n.trailing:h),b.cancel=function(){void 0!==c&&li(c),l=0,r=u=i=c=void 0},b.flush=function(){return void 0===c?s:g(vo())},b}var ko=Nr((function(e,t){return Zn(e,1,t)})),xo=Nr((function(e,t,n){return Zn(e,as(t)||0,n)}));function So(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new ge(a);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(So.Cache||Tn),n}function _o(e){if("function"!=typeof e)throw new ge(a);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}So.Cache=Tn;var $o=ci((function(e,t){var n=(t=1==t.length&&Do(t[0])?ht(t[0],At(Ji())):ht(ar(t,1),At(Ji()))).length;return Nr((function(r){for(var i=-1,a=sn(r.length,n);++i=t})),jo=br(function(){return arguments}())?br:function(e){return Ho(e)&&_e.call(e,"callee")&&!Ge.call(e,"callee")},Do=r.isArray,Mo=Xe?At(Xe):function(e){return Ho(e)&&hr(e)==S};function To(e){return null!=e&&Vo(e.length)&&!Uo(e)}function Ro(e){return Ho(e)&&To(e)}var Lo=tn||ac,No=et?At(et):function(e){return Ho(e)&&hr(e)==f};function Fo(e){if(!Ho(e))return!1;var t=hr(e);return t==p||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!qo(e)}function Uo(e){if(!Bo(e))return!1;var t=hr(e);return t==h||t==d||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Ko(e){return"number"==typeof e&&e==rs(e)}function Vo(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function Bo(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Ho(e){return null!=e&&"object"==typeof e}var zo=tt?At(tt):function(e){return Ho(e)&&na(e)==v};function Wo(e){return"number"==typeof e||Ho(e)&&hr(e)==y}function qo(e){if(!Ho(e)||hr(e)!=m)return!1;var t=ze(e);if(null===t)return!0;var n=_e.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Se.call(n)==Ce}var Go=nt?At(nt):function(e){return Ho(e)&&hr(e)==g};var Yo=rt?At(rt):function(e){return Ho(e)&&na(e)==b};function Jo(e){return"string"==typeof e||!Do(e)&&Ho(e)&&hr(e)==w}function Qo(e){return"symbol"==typeof e||Ho(e)&&hr(e)==k}var Zo=it?At(it):function(e){return Ho(e)&&Vo(e.length)&&!!Ue[hr(e)]};var Xo=Mi(Pr),es=Mi((function(e,t){return e<=t}));function ts(e){if(!e)return[];if(To(e))return Jo(e)?Wt(e):mi(e);if(Ze&&e[Ze])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Ze]());var t=na(e);return(t==v?Ut:t==b?Bt:Es)(e)}function ns(e){return e?(e=as(e))===1/0||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function rs(e){var t=ns(e),n=t%1;return t==t?n?t-n:t:0}function is(e){return e?Yn(rs(e),0,4294967295):0}function as(e){if("number"==typeof e)return e;if(Qo(e))return NaN;if(Bo(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Bo(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(G,"");var n=ae.test(e);return n||se.test(e)?He(e.slice(2),n?2:8):ie.test(e)?NaN:+e}function os(e){return gi(e,ks(e))}function ss(e){return null==e?"":Qr(e)}var cs=wi((function(e,t){if(fa(t)||To(t))gi(t,ws(t),e);else for(var n in t)_e.call(t,n)&&Bn(e,n,t[n])})),us=wi((function(e,t){gi(t,ks(t),e)})),ls=wi((function(e,t,n,r){gi(t,ks(t),e,r)})),fs=wi((function(e,t,n,r){gi(t,ws(t),e,r)})),ps=Hi(Gn);var hs=Nr((function(e,t){e=ve(e);var n=-1,r=t.length,i=r>2?t[2]:void 0;for(i&&sa(t[0],t[1],i)&&(r=1);++n1),t})),gi(e,Wi(e),n),r&&(n=Jn(n,7,Vi));for(var i=t.length;i--;)Xr(n,t[i]);return n}));var $s=Hi((function(e,t){return null==e?{}:function(e,t){return Dr(e,t,(function(t,n){return ys(e,n)}))}(e,t)}));function Ps(e,t){if(null==e)return{};var n=ht(Wi(e),(function(e){return[e]}));return t=Ji(t),Dr(e,n,(function(e,n){return t(e,n[0])}))}var Os=Ni(ws),Cs=Ni(ks);function Es(e){return null==e?[]:It(e,ws(e))}var As=_i((function(e,t,n){return t=t.toLowerCase(),e+(n?Is(t):t)}));function Is(e){return Fs(ss(e).toLowerCase())}function js(e){return(e=ss(e))&&e.replace(ue,Rt).replace(De,"")}var Ds=_i((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ms=_i((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Ts=Si("toLowerCase");var Rs=_i((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}));var Ls=_i((function(e,t,n){return e+(n?" ":"")+Fs(t)}));var Ns=_i((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Fs=Si("toUpperCase");function Us(e,t,n){return e=ss(e),void 0===(t=n?void 0:t)?function(e){return Le.test(e)}(e)?function(e){return e.match(Te)||[]}(e):function(e){return e.match(ee)||[]}(e):e.match(t)||[]}var Ks=Nr((function(e,t){try{return at(e,void 0,t)}catch(e){return Fo(e)?e:new pe(e)}})),Vs=Hi((function(e,t){return st(t,(function(t){t=$a(t),qn(e,t,go(e[t],e))})),e}));function Bs(e){return function(){return e}}var Hs=Oi(),zs=Oi(!0);function Ws(e){return e}function qs(e){return Sr("function"==typeof e?e:Jn(e,1))}var Gs=Nr((function(e,t){return function(n){return gr(n,e,t)}})),Ys=Nr((function(e,t){return function(n){return gr(e,n,t)}}));function Js(e,t,n){var r=ws(t),i=lr(t,r);null!=n||Bo(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=lr(t,ws(t)));var a=!(Bo(n)&&"chain"in n&&!n.chain),o=Uo(e);return st(i,(function(n){var r=t[n];e[n]=r,o&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__),i=n.__actions__=mi(this.__actions__);return i.push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,dt([this.value()],arguments))})})),e}function Qs(){}var Zs=Ii(ht),Xs=Ii(ut),ec=Ii(mt);function tc(e){return ca(e)?$t($a(e)):function(e){return function(t){return fr(t,e)}}(e)}var nc=Di(),rc=Di(!0);function ic(){return[]}function ac(){return!1}var oc=Ai((function(e,t){return e+t}),0),sc=Ri("ceil"),cc=Ai((function(e,t){return e/t}),1),uc=Ri("floor");var lc,fc=Ai((function(e,t){return e*t}),1),pc=Ri("round"),hc=Ai((function(e,t){return e-t}),0);return Cn.after=function(e,t){if("function"!=typeof t)throw new ge(a);return e=rs(e),function(){if(--e<1)return t.apply(this,arguments)}},Cn.ary=yo,Cn.assign=cs,Cn.assignIn=us,Cn.assignInWith=ls,Cn.assignWith=fs,Cn.at=ps,Cn.before=mo,Cn.bind=go,Cn.bindAll=Vs,Cn.bindKey=bo,Cn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Do(e)?e:[e]},Cn.chain=eo,Cn.chunk=function(e,t,n){t=(n?sa(e,t,n):void 0===t)?1:on(rs(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var a=0,o=0,s=r(Zt(i/t));ai?0:i+n),(r=void 0===r||r>i?i:rs(r))<0&&(r+=i),r=n>r?0:is(r);n>>0)?(e=ss(e))&&("string"==typeof t||null!=t&&!Go(t))&&!(t=Qr(t))&&Ft(e)?ui(Wt(e),0,n):e.split(t,n):[]},Cn.spread=function(e,t){if("function"!=typeof e)throw new ge(a);return t=null==t?0:on(rs(t),0),Nr((function(n){var r=n[t],i=ui(n,0,t);return r&&dt(i,r),at(e,this,i)}))},Cn.tail=function(e){var t=null==e?0:e.length;return t?zr(e,1,t):[]},Cn.take=function(e,t,n){return e&&e.length?zr(e,0,(t=n||void 0===t?1:rs(t))<0?0:t):[]},Cn.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?zr(e,(t=r-(t=n||void 0===t?1:rs(t)))<0?0:t,r):[]},Cn.takeRightWhile=function(e,t){return e&&e.length?ti(e,Ji(t,3),!1,!0):[]},Cn.takeWhile=function(e,t){return e&&e.length?ti(e,Ji(t,3)):[]},Cn.tap=function(e,t){return t(e),e},Cn.throttle=function(e,t,n){var r=!0,i=!0;if("function"!=typeof e)throw new ge(a);return Bo(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),wo(e,t,{leading:r,maxWait:t,trailing:i})},Cn.thru=to,Cn.toArray=ts,Cn.toPairs=Os,Cn.toPairsIn=Cs,Cn.toPath=function(e){return Do(e)?ht(e,$a):Qo(e)?[e]:mi(_a(ss(e)))},Cn.toPlainObject=os,Cn.transform=function(e,t,n){var r=Do(e),i=r||Lo(e)||Zo(e);if(t=Ji(t,4),null==n){var a=e&&e.constructor;n=i?r?new a:[]:Bo(e)&&Uo(a)?En(ze(e)):{}}return(i?st:cr)(e,(function(e,r,i){return t(n,e,r,i)})),n},Cn.unary=function(e){return yo(e,1)},Cn.union=Ba,Cn.unionBy=Ha,Cn.unionWith=za,Cn.uniq=function(e){return e&&e.length?Zr(e):[]},Cn.uniqBy=function(e,t){return e&&e.length?Zr(e,Ji(t,2)):[]},Cn.uniqWith=function(e,t){return t="function"==typeof t?t:void 0,e&&e.length?Zr(e,void 0,t):[]},Cn.unset=function(e,t){return null==e||Xr(e,t)},Cn.unzip=Wa,Cn.unzipWith=qa,Cn.update=function(e,t,n){return null==e?e:ei(e,t,oi(n))},Cn.updateWith=function(e,t,n,r){return r="function"==typeof r?r:void 0,null==e?e:ei(e,t,oi(n),r)},Cn.values=Es,Cn.valuesIn=function(e){return null==e?[]:It(e,ks(e))},Cn.without=Ga,Cn.words=Us,Cn.wrap=function(e,t){return Po(oi(t),e)},Cn.xor=Ya,Cn.xorBy=Ja,Cn.xorWith=Qa,Cn.zip=Za,Cn.zipObject=function(e,t){return ii(e||[],t||[],Bn)},Cn.zipObjectDeep=function(e,t){return ii(e||[],t||[],Kr)},Cn.zipWith=Xa,Cn.entries=Os,Cn.entriesIn=Cs,Cn.extend=us,Cn.extendWith=ls,Js(Cn,Cn),Cn.add=oc,Cn.attempt=Ks,Cn.camelCase=As,Cn.capitalize=Is,Cn.ceil=sc,Cn.clamp=function(e,t,n){return void 0===n&&(n=t,t=void 0),void 0!==n&&(n=(n=as(n))==n?n:0),void 0!==t&&(t=(t=as(t))==t?t:0),Yn(as(e),t,n)},Cn.clone=function(e){return Jn(e,4)},Cn.cloneDeep=function(e){return Jn(e,5)},Cn.cloneDeepWith=function(e,t){return Jn(e,5,t="function"==typeof t?t:void 0)},Cn.cloneWith=function(e,t){return Jn(e,4,t="function"==typeof t?t:void 0)},Cn.conformsTo=function(e,t){return null==t||Qn(e,t,ws(t))},Cn.deburr=js,Cn.defaultTo=function(e,t){return null==e||e!=e?t:e},Cn.divide=cc,Cn.endsWith=function(e,t,n){e=ss(e),t=Qr(t);var r=e.length,i=n=void 0===n?r:Yn(rs(n),0,r);return(n-=t.length)>=0&&e.slice(n,i)==t},Cn.eq=Eo,Cn.escape=function(e){return(e=ss(e))&&F.test(e)?e.replace(L,Lt):e},Cn.escapeRegExp=function(e){return(e=ss(e))&&q.test(e)?e.replace(W,"\\$&"):e},Cn.every=function(e,t,n){var r=Do(e)?ut:nr;return n&&sa(e,t,n)&&(t=void 0),r(e,Ji(t,3))},Cn.find=io,Cn.findIndex=Ia,Cn.findKey=function(e,t){return bt(e,Ji(t,3),cr)},Cn.findLast=ao,Cn.findLastIndex=ja,Cn.findLastKey=function(e,t){return bt(e,Ji(t,3),ur)},Cn.floor=uc,Cn.forEach=oo,Cn.forEachRight=so,Cn.forIn=function(e,t){return null==e?e:or(e,Ji(t,3),ks)},Cn.forInRight=function(e,t){return null==e?e:sr(e,Ji(t,3),ks)},Cn.forOwn=function(e,t){return e&&cr(e,Ji(t,3))},Cn.forOwnRight=function(e,t){return e&&ur(e,Ji(t,3))},Cn.get=vs,Cn.gt=Ao,Cn.gte=Io,Cn.has=function(e,t){return null!=e&&ra(e,t,vr)},Cn.hasIn=ys,Cn.head=Ma,Cn.identity=Ws,Cn.includes=function(e,t,n,r){e=To(e)?e:Es(e),n=n&&!r?rs(n):0;var i=e.length;return n<0&&(n=on(i+n,0)),Jo(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&kt(e,t,n)>-1},Cn.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:rs(n);return i<0&&(i=on(r+i,0)),kt(e,t,i)},Cn.inRange=function(e,t,n){return t=ns(t),void 0===n?(n=t,t=0):n=ns(n),function(e,t,n){return e>=sn(t,n)&&e=-9007199254740991&&e<=9007199254740991},Cn.isSet=Yo,Cn.isString=Jo,Cn.isSymbol=Qo,Cn.isTypedArray=Zo,Cn.isUndefined=function(e){return void 0===e},Cn.isWeakMap=function(e){return Ho(e)&&na(e)==x},Cn.isWeakSet=function(e){return Ho(e)&&"[object WeakSet]"==hr(e)},Cn.join=function(e,t){return null==e?"":rn.call(e,t)},Cn.kebabCase=Ds,Cn.last=Na,Cn.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=r;return void 0!==n&&(i=(i=rs(n))<0?on(r+i,0):sn(i,r-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,i):wt(e,St,i,!0)},Cn.lowerCase=Ms,Cn.lowerFirst=Ts,Cn.lt=Xo,Cn.lte=es,Cn.max=function(e){return e&&e.length?rr(e,Ws,dr):void 0},Cn.maxBy=function(e,t){return e&&e.length?rr(e,Ji(t,2),dr):void 0},Cn.mean=function(e){return _t(e,Ws)},Cn.meanBy=function(e,t){return _t(e,Ji(t,2))},Cn.min=function(e){return e&&e.length?rr(e,Ws,Pr):void 0},Cn.minBy=function(e,t){return e&&e.length?rr(e,Ji(t,2),Pr):void 0},Cn.stubArray=ic,Cn.stubFalse=ac,Cn.stubObject=function(){return{}},Cn.stubString=function(){return""},Cn.stubTrue=function(){return!0},Cn.multiply=fc,Cn.nth=function(e,t){return e&&e.length?Ir(e,rs(t)):void 0},Cn.noConflict=function(){return qe._===this&&(qe._=Ee),this},Cn.noop=Qs,Cn.now=vo,Cn.pad=function(e,t,n){e=ss(e);var r=(t=rs(t))?zt(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return ji(Xt(i),n)+e+ji(Zt(i),n)},Cn.padEnd=function(e,t,n){e=ss(e);var r=(t=rs(t))?zt(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var i=ln();return sn(e+i*(t-e+Be("1e-"+((i+"").length-1))),t)}return Rr(e,t)},Cn.reduce=function(e,t,n){var r=Do(e)?vt:Ot,i=arguments.length<3;return r(e,Ji(t,4),n,i,er)},Cn.reduceRight=function(e,t,n){var r=Do(e)?yt:Ot,i=arguments.length<3;return r(e,Ji(t,4),n,i,tr)},Cn.repeat=function(e,t,n){return t=(n?sa(e,t,n):void 0===t)?1:rs(t),Lr(ss(e),t)},Cn.replace=function(){var e=arguments,t=ss(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Cn.result=function(e,t,n){var r=-1,i=(t=si(t,e)).length;for(i||(i=1,e=void 0);++r9007199254740991)return[];var n=4294967295,r=sn(e,4294967295);e-=4294967295;for(var i=Et(r,t=Ji(t));++n=a)return e;var s=n-zt(r);if(s<1)return r;var c=o?ui(o,0,s).join(""):e.slice(0,s);if(void 0===i)return c+r;if(o&&(s+=c.length-s),Go(i)){if(e.slice(s).search(i)){var u,l=c;for(i.global||(i=ye(i.source,ss(re.exec(i))+"g")),i.lastIndex=0;u=i.exec(l);)var f=u.index;c=c.slice(0,void 0===f?s:f)}}else if(e.indexOf(Qr(i),s)!=s){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+r},Cn.unescape=function(e){return(e=ss(e))&&N.test(e)?e.replace(R,qt):e},Cn.uniqueId=function(e){var t=++$e;return ss(e)+t},Cn.upperCase=Ns,Cn.upperFirst=Fs,Cn.each=oo,Cn.eachRight=so,Cn.first=Ma,Js(Cn,(lc={},cr(Cn,(function(e,t){_e.call(Cn.prototype,t)||(lc[t]=e)})),lc),{chain:!1}),Cn.VERSION="4.17.15",st(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Cn[e].placeholder=Cn})),st(["drop","take"],(function(e,t){jn.prototype[e]=function(n){n=void 0===n?1:on(rs(n),0);var r=this.__filtered__&&!t?new jn(this):this.clone();return r.__filtered__?r.__takeCount__=sn(n,r.__takeCount__):r.__views__.push({size:sn(n,4294967295),type:e+(r.__dir__<0?"Right":"")}),r},jn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),st(["filter","map","takeWhile"],(function(e,t){var n=t+1,r=1==n||3==n;jn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:Ji(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}})),st(["head","last"],(function(e,t){var n="take"+(t?"Right":"");jn.prototype[e]=function(){return this[n](1).value()[0]}})),st(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");jn.prototype[e]=function(){return this.__filtered__?new jn(this):this[n](1)}})),jn.prototype.compact=function(){return this.filter(Ws)},jn.prototype.find=function(e){return this.filter(e).head()},jn.prototype.findLast=function(e){return this.reverse().find(e)},jn.prototype.invokeMap=Nr((function(e,t){return"function"==typeof e?new jn(this):this.map((function(n){return gr(n,e,t)}))})),jn.prototype.reject=function(e){return this.filter(_o(Ji(e)))},jn.prototype.slice=function(e,t){e=rs(e);var n=this;return n.__filtered__&&(e>0||t<0)?new jn(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),void 0!==t&&(n=(t=rs(t))<0?n.dropRight(-t):n.take(t-e)),n)},jn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},jn.prototype.toArray=function(){return this.take(4294967295)},cr(jn.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),i=Cn[r?"take"+("last"==t?"Right":""):t],a=r||/^find/.test(t);i&&(Cn.prototype[t]=function(){var t=this.__wrapped__,o=r?[1]:arguments,s=t instanceof jn,c=o[0],u=s||Do(t),l=function(e){var t=i.apply(Cn,dt([e],o));return r&&f?t[0]:t};u&&n&&"function"==typeof c&&1!=c.length&&(s=u=!1);var f=this.__chain__,p=!!this.__actions__.length,h=a&&!f,d=s&&!p;if(!a&&u){t=d?t:new jn(this);var v=e.apply(t,o);return v.__actions__.push({func:to,args:[l],thisArg:void 0}),new In(v,f)}return h&&d?e.apply(this,o):(v=this.thru(l),h?r?v.value()[0]:v.value():v)})})),st(["pop","push","shift","sort","splice","unshift"],(function(e){var t=be[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);Cn.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(Do(i)?i:[],e)}return this[n]((function(n){return t.apply(Do(n)?n:[],e)}))}})),cr(jn.prototype,(function(e,t){var n=Cn[t];if(n){var r=n.name+"";_e.call(bn,r)||(bn[r]=[]),bn[r].push({name:t,func:n})}})),bn[Ci(void 0,2).name]=[{name:"wrapper",func:void 0}],jn.prototype.clone=function(){var e=new jn(this.__wrapped__);return e.__actions__=mi(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=mi(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=mi(this.__views__),e},jn.prototype.reverse=function(){if(this.__filtered__){var e=new jn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},jn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Do(e),r=t<0,i=n?e.length:0,a=function(e,t,n){var r=-1,i=n.length;for(;++r=this.__values__.length;return{done:e,value:e?void 0:this.__values__[this.__index__++]}},Cn.prototype.plant=function(e){for(var t,n=this;n instanceof An;){var r=Oa(n);r.__index__=0,r.__values__=void 0,t?i.__wrapped__=r:t=r;var i=r;n=n.__wrapped__}return i.__wrapped__=e,t},Cn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof jn){var t=e;return this.__actions__.length&&(t=new jn(this)),(t=t.reverse()).__actions__.push({func:to,args:[Va],thisArg:void 0}),new In(t,this.__chain__)}return this.thru(Va)},Cn.prototype.toJSON=Cn.prototype.valueOf=Cn.prototype.value=function(){return ni(this.__wrapped__,this.__actions__)},Cn.prototype.first=Cn.prototype.head,Ze&&(Cn.prototype[Ze]=function(){return this}),Cn}();qe._=Gt,void 0===(i=function(){return Gt}.call(t,n,t,r))||(r.exports=i)}).call(this)}).call(this,n(39),n(32)(e))},function(e,t){var n=Array.isArray;e.exports=n},function(e,t,n){var r=n(98),i=n(103);e.exports=function(e,t){var n=i(e,t);return r(n)?n:void 0}},function(e,t,n){var r=n(20),i=n(99),a=n(100),o=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":o&&o in Object(e)?i(e):a(e)}},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t,n){var r=n(91)(n(105));e.exports=r},function(e,t,n){var r=n(13).Symbol;e.exports=r},function(e,t){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},function(e,t,n){var r=n(116),i=n(117),a=n(118),o=n(119),s=n(120);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e<=9007199254740991}},function(e,t,n){var r=n(15),i=n(26),a=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,o=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!i(e))||(o.test(e)||!a.test(e)||null!=t&&e in Object(t))}},function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=n=function(e){return typeof e}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(t)}e.exports=n},function(e,t,n){var r;window,r=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";function r(e,t){for(var n=0;n\n
").concat(e.text,"
\n \n ")}(e,t)})).join("");return"\n
\n ".concat(e,"\n
\n ")}},{key:"templateString",value:function(){var e=this.buttonsString(),t=this.title?"
".concat(this.title,"
"):"",n=this.text?"

".concat(this.text,"

"):"";return'\n
\n
\n
\n
\n
\n
\n
\n '.concat(t,'\n\n
\n ').concat(n,"\n
\n\n
\n ").concat(e,"\n
\n
\n
\n
\n
\n
\n
\n ")}},{key:"dismiss",value:function(){this.onElement.removeChild(this.element),document.removeEventListener("keyup",this.keyupListener)}},{key:"primaryButton",value:function(){var e=this.buttons.find((function(e){return!0===e.primary}));return e||(e=this.buttons[this.buttons.length-1]),e}},{key:"present",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onElement;n||(n=document.body),this.onElement=n,this.element=document.createElement("div"),this.element.className="sn-component",this.element.innerHTML=this.templateString().trim(),document.addEventListener("keyup",this.keyupListener),this.buttons.forEach((function(t,n){e.element.querySelector("#button-".concat(n)).onclick=function(){t.action&&t.action(),e.dismiss()}})),n.appendChild(this.element)}}])&&r(t.prototype,n),i&&r(t,i),e}();n.d(t,"SKAlert",(function(){return i}))}])},e.exports=r()},function(e,t,n){var r=n(17),i=n(21);e.exports=function(e){if(!i(e))return!1;var t=r(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},function(e,t,n){(function(t){var n="object"==typeof t&&t&&t.Object===Object&&t;e.exports=n}).call(this,n(39))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){var n=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return n.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++nl))return!1;var p=c.get(e);if(p&&c.get(t))return p==t;var h=-1,d=!0,v=2&n?new r:void 0;for(c.set(e,t),c.set(t,e);++h-1&&e%1==0&&e0}function i(e,n){n=n||Error;var r="https://errors.angularjs.org/1.7.9/",i=r.replace(".","\\.")+"[\\s\\S]*",a=new RegExp(i,"g");return function(){var i,o,s=arguments[0],c=arguments[1],u="["+(e?e+":":"")+s+"] ",l=fe(arguments,2).map((function(e){return Ve(e,t.objectMaxDepth)}));if(u+=c.replace(/\{\d+\}/g,(function(e){var t=+e.slice(1,-1);return t=0&&t-1 in e||"function"==typeof e.item)}function x(e,t,n){var r,i;if(e)if(W(e))for(r in e)"prototype"!==r&&"length"!==r&&"name"!==r&&e.hasOwnProperty(r)&&t.call(n,e[r],r,e);else if(H(e)||k(e)){var a="object"!=typeof e;for(r=0,i=e.length;r=0&&e.splice(n,1),n}function ae(e,t,n){var i,a,o=[],s=[];if(n=r(n)?n:NaN,t){if((a=t)&&V(a.length)&&Z.test(y.call(a))||(i=t,"[object ArrayBuffer]"===y.call(i)))throw g("cpta","Can't copy! TypedArray destination cannot be mutated.");if(e===t)throw g("cpi","Can't copy! Source and destination are identical.");return H(t)?t.length=0:x(t,(function(e,n){"$$hashKey"!==n&&delete t[n]})),o.push(e),s.push(t),c(e,t,n)}return u(e,n);function c(e,t,n){if(--n<0)return"...";var r,i=t.$$hashKey;if(H(e))for(var a=0,o=e.length;a2?fe(arguments,2):[];return!W(t)||t instanceof RegExp?t:n.length?function(){return arguments.length?t.apply(e,le(n,arguments,0)):t.apply(e,n)}:function(){return arguments.length?t.apply(e,arguments):t.call(e)}}function he(t,n){var r=n;return"string"==typeof t&&"$"===t.charAt(0)&&"$"===t.charAt(1)?r=void 0:G(n)?r="$WINDOW":n&&e.document===n?r="$DOCUMENT":Y(n)&&(r="$SCOPE"),r}function de(e,t){if(!L(e))return V(t)||(t=t?2:null),JSON.stringify(e,he,t)}function ve(e){return K(e)?JSON.parse(e):e}var ye=/:/g;function me(e,t){e=e.replace(ye,"");var n=Date.parse("Jan 01, 1970 00:00:00 "+e)/6e4;return I(n)?t:n}function ge(e,t){return(e=new Date(e.getTime())).setMinutes(e.getMinutes()+t),e}function be(e,t,n){n=n?-1:1;var r=e.getTimezoneOffset();return ge(e,n*(me(t,r)-r))}function we(e){e=o(e).clone().empty();var t=o("
").append(e).html();try{return e[0].nodeType===Ue?f(t):t.match(/^(<[^>]+>)/)[1].replace(/^<([\w-]+)/,(function(e,t){return"<"+f(t)}))}catch(e){return f(t)}}function ke(e){try{return decodeURIComponent(e)}catch(e){}}function xe(e){var t={};return x((e||"").split("&"),(function(e){var n,r,i;e&&(r=e=e.replace(/\+/g,"%20"),-1!==(n=e.indexOf("="))&&(r=e.substring(0,n),i=e.substring(n+1)),N(r=ke(r))&&(i=!N(i)||ke(i),l.call(t,r)?H(t[r])?t[r].push(i):t[r]=[t[r],i]:t[r]=i))})),t}function Se(e){return _e(e,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function _e(e,t){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%3B/gi,";").replace(/%20/g,t?"%20":"+")}var $e=["ng-","data-ng-","ng:","x-ng-"];var Pe=function(t){var n=t.currentScript;if(!n)return!0;if(!(n instanceof e.HTMLScriptElement||n instanceof e.SVGScriptElement))return!1;var r=n.attributes;return[r.getNamedItem("src"),r.getNamedItem("href"),r.getNamedItem("xlink:href")].every((function(e){if(!e)return!0;if(!e.value)return!1;var n=t.createElement("a");if(n.href=e.value,t.location.origin===n.origin)return!0;switch(n.protocol){case"http:":case"https:":case"ftp:":case"blob:":case"file:":case"data:":return!0;default:return!1}}))}(e.document);function Oe(t,n){var r,i,a={};if(x($e,(function(e){var n=e+"app";!r&&t.hasAttribute&&t.hasAttribute(n)&&(r=t,i=t.getAttribute(n))})),x($e,(function(e){var n,a=e+"app";!r&&(n=t.querySelector("["+a.replace(":","\\:")+"]"))&&(r=n,i=n.getAttribute(a))})),r){if(!Pe)return void e.console.error("AngularJS: disabling automatic bootstrap.