From 6b9f63073767d49ec64fe1445547e451ebaf4ecc Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Mon, 28 Oct 2019 12:29:16 -0500 Subject: [PATCH] Activate cached themes on desktop set of application path --- Gruntfile.js | 3 ++- .../javascripts/app/services/desktopManager.js | 1 + .../javascripts/app/services/themeManager.js | 12 +++++++----- dist/javascripts/compiled.js | 18 +++++++++++------- dist/javascripts/compiled.min.js | 2 +- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 2a10c782f..0ec6cd275 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -13,7 +13,8 @@ module.exports = function(grunt) { js: { files: ['app/assets/javascripts/**/*.js'], - tasks: [ 'concat:app', 'babel', 'browserify', 'concat:dist', 'clean'], + tasks: ['haml', 'ngtemplates', 'sass', 'concat:app', 'babel', 'browserify', + 'concat:lib', 'concat:dist', 'concat:css', 'uglify', 'ngconstant:build', 'clean'], options: { spawn: false, }, diff --git a/app/assets/javascripts/app/services/desktopManager.js b/app/assets/javascripts/app/services/desktopManager.js index ad4f816e9..68bdf6ed3 100644 --- a/app/assets/javascripts/app/services/desktopManager.js +++ b/app/assets/javascripts/app/services/desktopManager.js @@ -154,6 +154,7 @@ class DesktopManager { /* Used to resolve "sn://" */ desktop_setApplicationDataPath(path) { this.applicationDataPath = path; + this.$rootScope.$broadcast("desktop-did-set-application-path"); } desktop_setComponentInstallationSyncHandler(handler) { diff --git a/app/assets/javascripts/app/services/themeManager.js b/app/assets/javascripts/app/services/themeManager.js index 84921e12e..4fec13392 100644 --- a/app/assets/javascripts/app/services/themeManager.js +++ b/app/assets/javascripts/app/services/themeManager.js @@ -1,6 +1,6 @@ class ThemeManager { - constructor(componentManager, desktopManager, storageManager, passcodeManager) { + constructor(componentManager, desktopManager, storageManager, passcodeManager, $rootScope) { this.componentManager = componentManager; this.storageManager = storageManager; this.desktopManager = desktopManager; @@ -17,11 +17,13 @@ class ThemeManager { this.cacheThemes(); }) - // The desktop application won't have its applicationDataPath until the angular document is ready, - // so it wont be able to resolve local theme urls until thats ready - angular.element(document).ready(() => { + if(desktopManager.isDesktop) { + $rootScope.$on("desktop-did-set-application-path", () => { + this.activateCachedThemes(); + }) + } else { this.activateCachedThemes(); - }); + } } activateCachedThemes() { diff --git a/dist/javascripts/compiled.js b/dist/javascripts/compiled.js index 3c06d89a4..63ee14c1d 100644 --- a/dist/javascripts/compiled.js +++ b/dist/javascripts/compiled.js @@ -58896,6 +58896,7 @@ function () { key: "desktop_setApplicationDataPath", value: function desktop_setApplicationDataPath(path) { this.applicationDataPath = path; + this.$rootScope.$broadcast("desktop-did-set-application-path"); } }, { key: "desktop_setComponentInstallationSyncHandler", @@ -61723,9 +61724,9 @@ angular.module('app').service('syncManager', SyncManager); var ThemeManager = /*#__PURE__*/ function () { - ThemeManager.$inject = ["componentManager", "desktopManager", "storageManager", "passcodeManager"]; + ThemeManager.$inject = ["componentManager", "desktopManager", "storageManager", "passcodeManager", "$rootScope"]; - function ThemeManager(componentManager, desktopManager, storageManager, passcodeManager) { + function ThemeManager(componentManager, desktopManager, storageManager, passcodeManager, $rootScope) { var _this89 = this; (0, _classCallCheck3["default"])(this, ThemeManager); @@ -61740,12 +61741,15 @@ function () { passcodeManager.addPasscodeChangeObserver(function () { _this89.cacheThemes(); - }); // The desktop application won't have its applicationDataPath until the angular document is ready, - // so it wont be able to resolve local theme urls until thats ready - - angular.element(document).ready(function () { - _this89.activateCachedThemes(); }); + + if (desktopManager.isDesktop) { + $rootScope.$on("desktop-did-set-application-path", function () { + _this89.activateCachedThemes(); + }); + } else { + this.activateCachedThemes(); + } } (0, _createClass3["default"])(ThemeManager, [{ diff --git a/dist/javascripts/compiled.min.js b/dist/javascripts/compiled.min.js index 74d6a8a96..13c8f4fdb 100644 --- a/dist/javascripts/compiled.min.js +++ b/dist/javascripts/compiled.min.js @@ -1 +1 @@ -!function(e){"use strict";var c,t=Object.prototype,u=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag",o="object"==typeof module,s=e.regeneratorRuntime;if(s)o&&(module.exports=s);else{(s=e.regeneratorRuntime=o?module.exports:{}).wrap=k;var l="suspendedStart",d="suspendedYield",f="executing",p="completed",h={},m={};m[i]=function(){return this};var v=Object.getPrototypeOf,g=v&&v(v(D([])));g&&g!==t&&u.call(g,i)&&(m=g);var y=S.prototype=w.prototype=Object.create(m);x.prototype=y.constructor=S,S.constructor=x,S[a]=x.displayName="GeneratorFunction",s.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===x||"GeneratorFunction"===(t.displayName||t.name))},s.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,a in e||(e[a]="GeneratorFunction")),e.prototype=Object.create(y),e},s.awrap=function(e){return{__await:e}},$(_.prototype),_.prototype[r]=function(){return this},s.AsyncIterator=_,s.async=function(e,t,n,r){var i=new _(k(e,t,n,r));return s.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},$(y),y[a]="Generator",y[i]=function(){return this},y.toString=function(){return"[object Generator]"},s.keys=function(n){var r=[];for(var e in n)r.push(e);return r.reverse(),function e(){for(;r.length;){var t=r.pop();if(t in n)return e.value=t,e.done=!1,e}return e.done=!0,e}},s.values=D,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=c,this.done=!1,this.delegate=null,this.method="next",this.arg=c,this.tryEntries.forEach(C),!e)for(var t in this)"t"===t.charAt(0)&&u.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=c)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function e(e,t){return a.type="throw",a.arg=n,r.next=e,t&&(r.method="next",r.arg=c),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var i=this.tryEntries[t],a=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var o=u.call(i,"catchLoc"),s=u.call(i,"finallyLoc");if(o&&s){if(this.prev>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=s.ceil(t/4)},clone:function(){var e=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},o=i.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},u=i.Utf8={stringify:function(e){try{return decodeURIComponent(escape(o.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return o.parse(unescape(encodeURIComponent(e)))}},l=t.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,n=t.words,r=t.sigBytes,i=this.blockSize,a=r/(4*i);if(e=(a=e?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*i,r=s.min(4*e,r),e){for(var o=0;o>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,o=0;o<4&&i+.75*o>>6*(3-o)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;!(r=n.charAt(64))||-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,a=0;a>>6-a%4*2;r[i>>>2]|=(o|s)<<24-i%4*8,i++}return c.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(a){function S(e,t,n,r,i,a,o){return((e=e+(t&n|~t&r)+i+o)<>>32-a)+t}function $(e,t,n,r,i,a,o){return((e=e+(t&r|n&~r)+i+o)<>>32-a)+t}function _(e,t,n,r,i,a,o){return((e=e+(t^n^r)+i+o)<>>32-a)+t}function M(e,t,n,r,i,a,o){return((e=e+(n^(t|~r))+i+o)<>>32-a)+t}for(var e=C,t=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,I=[],i=0;i<64;i++)I[i]=4294967296*a.abs(a.sin(i+1))|0;r=r.MD5=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var r=e[o=t+n];e[o]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}n=this._hash.words;var i,a,o=e[t+0],s=(r=e[t+1],e[t+2]),c=e[t+3],u=e[t+4],l=e[t+5],d=e[t+6],f=e[t+7],p=e[t+8],h=e[t+9],m=e[t+10],v=e[t+11],g=e[t+12],y=e[t+13],k=e[t+14],b=e[t+15],w=n[0],x=M(x=M(x=M(x=M(x=_(x=_(x=_(x=_(x=$(x=$(x=$(x=$(x=S(x=S(x=S(x=S(x=n[1],a=S(a=n[2],i=S(i=n[3],w=S(w,x,a,i,o,7,I[0]),x,a,r,12,I[1]),w,x,s,17,I[2]),i,w,c,22,I[3]),a=S(a,i=S(i,w=S(w,x,a,i,u,7,I[4]),x,a,l,12,I[5]),w,x,d,17,I[6]),i,w,f,22,I[7]),a=S(a,i=S(i,w=S(w,x,a,i,p,7,I[8]),x,a,h,12,I[9]),w,x,m,17,I[10]),i,w,v,22,I[11]),a=S(a,i=S(i,w=S(w,x,a,i,g,7,I[12]),x,a,y,12,I[13]),w,x,k,17,I[14]),i,w,b,22,I[15]),a=$(a,i=$(i,w=$(w,x,a,i,r,5,I[16]),x,a,d,9,I[17]),w,x,v,14,I[18]),i,w,o,20,I[19]),a=$(a,i=$(i,w=$(w,x,a,i,l,5,I[20]),x,a,m,9,I[21]),w,x,b,14,I[22]),i,w,u,20,I[23]),a=$(a,i=$(i,w=$(w,x,a,i,h,5,I[24]),x,a,k,9,I[25]),w,x,c,14,I[26]),i,w,p,20,I[27]),a=$(a,i=$(i,w=$(w,x,a,i,y,5,I[28]),x,a,s,9,I[29]),w,x,f,14,I[30]),i,w,g,20,I[31]),a=_(a,i=_(i,w=_(w,x,a,i,l,4,I[32]),x,a,p,11,I[33]),w,x,v,16,I[34]),i,w,k,23,I[35]),a=_(a,i=_(i,w=_(w,x,a,i,r,4,I[36]),x,a,u,11,I[37]),w,x,f,16,I[38]),i,w,m,23,I[39]),a=_(a,i=_(i,w=_(w,x,a,i,y,4,I[40]),x,a,o,11,I[41]),w,x,c,16,I[42]),i,w,d,23,I[43]),a=_(a,i=_(i,w=_(w,x,a,i,h,4,I[44]),x,a,g,11,I[45]),w,x,b,16,I[46]),i,w,s,23,I[47]),a=M(a,i=M(i,w=M(w,x,a,i,o,6,I[48]),x,a,f,10,I[49]),w,x,k,15,I[50]),i,w,l,21,I[51]),a=M(a,i=M(i,w=M(w,x,a,i,g,6,I[52]),x,a,c,10,I[53]),w,x,m,15,I[54]),i,w,r,21,I[55]),a=M(a,i=M(i,w=M(w,x,a,i,p,6,I[56]),x,a,b,10,I[57]),w,x,d,15,I[58]),i,w,y,21,I[59]),a=M(a,i=M(i,w=M(w,x,a,i,u,6,I[60]),x,a,v,10,I[61]),w,x,s,15,I[62]),i,w,h,21,I[63]);n[0]=n[0]+w|0,n[1]=n[1]+x|0,n[2]=n[2]+a|0,n[3]=n[3]+i|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32;var i=a.floor(n/4294967296);for(t[15+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(t.length+1),this._process(),t=(e=this._hash).words,n=0;n<4;n++)r=t[n],t[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}}),e.MD5=n._createHelper(r),e.HmacMD5=n._createHmacHelper(r)}(Math),i=(n=(r=C).lib).Base,u=n.WordArray,a=(n=r.algo).EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:n.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(o=this.cfg).hasher.create(),r=u.create(),i=r.words,a=o.keySize,o=o.iterations;i.length>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:c,padding:u}),reset:function(){a.reset.call(this);var e=(t=this.cfg).iv,t=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=t.createEncryptor;else n=t.createDecryptor,this._minBufferSize=1;this._mode=n.call(t,this,e&&e.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var l=e.CipherParams=t.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),d=(c=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?o.create([1398893684,1701076831]).concat(e).concat(t):t).toString(r)},parse:function(e){var t=(e=r.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=o.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return l.create({ciphertext:e,salt:n})}},e.SerializableCipher=t.extend({cfg:t.extend({format:c}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,l.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,r){return r=r||o.random(8),e=i.create({keySize:t+n}).compute(e,r),n=o.create(e.words.slice(t),4*n),e.sigBytes=4*t,l.create({key:e,iv:n,salt:r})}},p=e.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=d.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,d.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=C,t=e.lib.BlockCipher,n=e.algo,o=[],r=[],i=[],a=[],s=[],c=[],u=[],l=[],d=[],f=[],p=[],h=0;h<256;h++)p[h]=h<128?h<<1:h<<1^283;var m=0,v=0;for(h=0;h<256;h++){var g=(g=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&g^99;o[m]=g;var y=p[r[g]=m],k=p[y],b=p[k],w=257*p[g]^16843008*g;i[m]=w<<24|w>>>8,a[m]=w<<16|w>>>16,s[m]=w<<8|w>>>24,c[m]=w,w=16843009*b^65537*k^257*y^16843008*m,u[g]=w<<24|w>>>8,l[g]=w<<16|w>>>16,d[g]=w<<8|w>>>24,f[g]=w,m?(m=y^p[p[p[b^y]]],v^=p[p[v]]):m=v=1}var x=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),r=this._keySchedule=[],i=0;i>>24]<<24|o[a>>>16&255]<<16|o[a>>>8&255]<<8|o[255&a]):(a=o[(a=a<<8|a>>>24)>>>24]<<24|o[a>>>16&255]<<16|o[a>>>8&255]<<8|o[255&a],a^=x[i/t|0]<<24),r[i]=r[i-t]^a}for(e=this._invKeySchedule=[],t=0;t>>24]]^l[o[a>>>16&255]]^d[o[a>>>8&255]]^f[o[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,c,o)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,u,l,d,f,r),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,a,o,s){for(var c=this._nRounds,u=e[t]^n[0],l=e[t+1]^n[1],d=e[t+2]^n[2],f=e[t+3]^n[3],p=4,h=1;h>>24]^i[l>>>16&255]^a[d>>>8&255]^o[255&f]^n[p++],v=r[l>>>24]^i[d>>>16&255]^a[f>>>8&255]^o[255&u]^n[p++],g=r[d>>>24]^i[f>>>16&255]^a[u>>>8&255]^o[255&l]^n[p++];f=r[f>>>24]^i[u>>>16&255]^a[l>>>8&255]^o[255&d]^n[p++],u=m,l=v,d=g}m=(s[u>>>24]<<24|s[l>>>16&255]<<16|s[d>>>8&255]<<8|s[255&f])^n[p++],v=(s[l>>>24]<<24|s[d>>>16&255]<<16|s[f>>>8&255]<<8|s[255&u])^n[p++],g=(s[d>>>24]<<24|s[f>>>16&255]<<16|s[u>>>8&255]<<8|s[255&l])^n[p++],f=(s[f>>>24]<<24|s[u>>>16&255]<<16|s[l>>>8&255]<<8|s[255&d])^n[p++],e[t]=m,e[t+1]=v,e[t+2]=g,e[t+3]=f},keySize:8});e.AES=t._createHelper(n)}();var o,l;C=C||function(s){function n(){}var e={},t=e.lib={},r=t.Base={extend:function(e){n.prototype=this;var t=new n;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),(t.init.prototype=t).$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=t.WordArray=r.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||a).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=s.ceil(t/4)},clone:function(){var e=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},o=i.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},u=i.Utf8={stringify:function(e){try{return decodeURIComponent(escape(o.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return o.parse(unescape(encodeURIComponent(e)))}},l=t.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,n=t.words,r=t.sigBytes,i=this.blockSize,a=r/(4*i);if(e=(a=e?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*i,r=s.min(4*e,r),e){for(var o=0;o>>7)^(f<<14|f>>>18)^f>>>3)+m[d-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+m[d-16]}f=l+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&c^~s&u)+h[d]+m[d],p=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&a^i&a),l=u,u=c,c=s,s=o+f|0,o=a,a=i,i=r,r=f+p|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+s|0,n[5]=n[5]+c|0,n[6]=n[6]+u|0,n[7]=n[7]+l|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(64+r>>>9<<4)]=i.floor(n/4294967296),t[15+(64+r>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(a),t.HmacSHA256=r._createHmacHelper(a)}(Math),l=(o=C).enc.Utf8,o.algo.HMAC=o.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=l.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),a=this._iKey=t.clone(),o=i.words,s=a.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=s.ceil(t/4)},clone:function(){var e=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},o=i.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},u=i.Utf8={stringify:function(e){try{return decodeURIComponent(escape(o.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return o.parse(unescape(encodeURIComponent(e)))}},l=t.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,n=t.words,r=t.sigBytes,i=this.blockSize,a=r/(4*i);if(e=(a=e?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*i,r=s.min(4*e,r),e){for(var o=0;o>>1|(q=V.low)<<31)^(K>>>8|q<<24)^K>>>7;var q=(q>>>1|K<<31)^(q>>>8|K<<24)^(q>>>7|K<<25),W=((K=(W=ne[j-2]).high)>>>19|(J=W.low)<<13)^(K<<3|J>>>29)^K>>>6,J=(J>>>19|K<<13)^(J<<3|K>>>29)^(J>>>6|K<<26),G=(K=ne[j-7]).high,Y=(X=ne[j-16]).high,X=X.low;V=(V=(V=V+G+((K=q+K.low)>>>0>>0?1:0))+W+((K=K+J)>>>0>>0?1:0))+Y+((K=K+X)>>>0>>0?1:0);z.high=V,z.low=K}G=O&F^~O&L,X=T&N^~T&B,z=M&C^M&D^C&D;var Z=I&A^I&R^A&R,Q=(q=(M>>>28|I<<4)^(M<<30|I>>>2)^(M<<25|I>>>7),W=(I>>>28|M<<4)^(I<<30|M>>>2)^(I<<25|M>>>7),(J=te[j]).high),ee=J.low;Y=H+((O>>>14|T<<18)^(O>>>18|T<<14)^(O<<23|T>>>9))+((J=U+((T>>>14|O<<18)^(T>>>18|O<<14)^(T<<23|O>>>9)))>>>0>>0?1:0),H=L,U=B,L=F,B=N,F=O,N=T,O=E+(Y=(Y=(Y=Y+G+((J=J+X)>>>0>>0?1:0))+Q+((J=J+ee)>>>0>>0?1:0))+V+((J=J+K)>>>0>>0?1:0))+((T=P+J|0)>>>0

>>0?1:0)|0,E=D,P=R,D=C,R=A,C=M,A=I,M=Y+(z=q+z+((K=W+Z)>>>0>>0?1:0))+((I=J+K|0)>>>0>>0?1:0)|0}d=n.low=d+I,n.high=l+M+(d>>>0>>0?1:0),p=r.low=p+A,r.high=f+C+(p>>>0>>0?1:0),m=i.low=m+R,i.high=h+D+(m>>>0>>0?1:0),g=a.low=g+P,a.high=v+E+(g>>>0

>>0?1:0),k=o.low=k+T,o.high=y+O+(k>>>0>>0?1:0),w=s.low=w+N,s.high=b+F+(w>>>0>>0?1:0),S=c.low=S+B,c.high=x+L+(S>>>0>>0?1:0),_=u.low=_+U,u.high=$+H+(_>>>0>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(128+r>>>10<<5)]=Math.floor(n/4294967296),t[31+(128+r>>>10<<5)]=n,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32}),t.SHA512=n._createHelper(a),t.HmacSHA512=n._createHmacHelper(a)}(),m=(h=C).enc.Utf8,h.algo.HMAC=h.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=m.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),a=this._iKey=t.clone(),o=i.words,s=a.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=s.ceil(t/4)},clone:function(){var e=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},o=i.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},u=i.Utf8={stringify:function(e){try{return decodeURIComponent(escape(o.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return o.parse(unescape(encodeURIComponent(e)))}},l=t.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,n=t.words,r=t.sigBytes,i=this.blockSize,a=r/(4*i);if(e=(a=e?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*i,r=s.min(4*e,r),e){for(var o=0;o>>31}u=(r<<5|r>>>27)+s+k[c],u=c<20?u+(1518500249+(i&a|~i&o)):c<40?u+(1859775393+(i^a^o)):c<60?u+((i&a|i&o|a&o)-1894007588):u+((i^a^o)-899497514),s=o,o=a,a=i<<30|i>>>2,i=r,r=u}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+s|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(64+r>>>9<<4)]=Math.floor(n/4294967296),t[15+(64+r>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=y.clone.call(this);return e._hash=this._hash.clone(),e}}),v.SHA1=y._createHelper(b),v.HmacSHA1=y._createHmacHelper(b),x=(w=C).enc.Utf8,w.algo.HMAC=w.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=x.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),a=this._iKey=t.clone(),o=i.words,s=a.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=s.ceil(t/4)},clone:function(){var e=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},o=i.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},u=i.Utf8={stringify:function(e){try{return decodeURIComponent(escape(o.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return o.parse(unescape(encodeURIComponent(e)))}},l=t.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,n=t.words,r=t.sigBytes,i=this.blockSize,a=r/(4*i);if(e=(a=e?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*i,r=s.min(4*e,r),e){for(var o=0;o>>31}u=(r<<5|r>>>27)+s+O[c],u=c<20?u+(1518500249+(i&a|~i&o)):c<40?u+(1859775393+(i^a^o)):c<60?u+((i&a|i&o|a&o)-1894007588):u+((i^a^o)-899497514),s=o,o=a,a=i<<30|i>>>2,i=r,r=u}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+s|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(64+r>>>9<<4)]=Math.floor(n/4294967296),t[15+(64+r>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=P.clone.call(this);return e._hash=this._hash.clone(),e}}),R.SHA1=P._createHelper(T),R.HmacSHA1=P._createHmacHelper(T),Object.defineProperty(we,"__esModule",{value:!0}),we.StandardFile=we.SFItemTransformer=we.SFCryptoWeb=we.SFCryptoJS=we.SFAbstractCrypto=we.SFItemHistoryEntry=we.SFItemHistory=we.SFHistorySession=we.SFPrivileges=we.SFPredicate=we.SFItemParams=we.SFItem=we.SFSyncManager=we.SFStorageManager=we.SFSingletonManager=we.SFSessionHistoryManager=we.SFPrivilegesManager=we.SFModelManager=we.SFMigrationManager=we.SFHttpManager=we.SFAuthManager=we.SFAlertManager=void 0;var W=function(){function e(){V(this,e)}var t,n;return q(e,[{key:"alert",value:(n=z(regeneratorRuntime.mark(function e(n){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,t){window.alert(n.text),e()}));case 1:case"end":return e.stop()}},e)})),function(e){return n.apply(this,arguments)})},{key:"confirm",value:(t=z(regeneratorRuntime.mark(function e(n){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,t){window.confirm(n.text)?e():t()}));case 1:case"end":return e.stop()}},e)})),function(e){return t.apply(this,arguments)})}]),e}();we.SFAlertManager=W;var J=function(){function k(e,t,n,r){V(this,k),k.DidSignOutEvent="DidSignOutEvent",k.WillSignInEvent="WillSignInEvent",k.DidSignInEvent="DidSignInEvent",this.httpManager=t,this.storageManager=e,this.alertManager=n||new W,this.$timeout=r||setTimeout.bind(window),this.eventHandlers=[]}var a,o,s,r,e,t,n,i,c,u;return q(k,[{key:"addEventHandler",value:function(e){return this.eventHandlers.push(e),e}},{key:"removeEventHandler",value:function(e){_.pull(this.eventHandlers,e)}},{key:"notifyEvent",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.eventHandlers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){(0,a.value)(e,t||{})}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}}},{key:"saveKeys",value:(u=z(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._keys=t,e.next=3,this.storageManager.setItem("mk",t.mk);case 3:return e.next=5,this.storageManager.setItem("ak",t.ak);case 5:case"end":return e.stop()}},e,this)})),function(e){return u.apply(this,arguments)})},{key:"signout",value:(c=z(regeneratorRuntime.mark(function e(t){var n=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._keys=null,this._authParams=null,t)return e.abrupt("return",this.storageManager.clearAllData().then(function(){n.notifyEvent(k.DidSignOutEvent)}));e.next=6;break;case 6:this.notifyEvent(k.DidSignOutEvent);case 7:case"end":return e.stop()}},e,this)})),function(e){return c.apply(this,arguments)})},{key:"keys",value:(i=z(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._keys){e.next=11;break}return e.next=3,this.storageManager.getItem("mk");case 3:if(t=e.sent){e.next=6;break}return e.abrupt("return",null);case 6:return e.t0=t,e.next=9,this.storageManager.getItem("ak");case 9:e.t1=e.sent,this._keys={mk:e.t0,ak:e.t1};case 11:return e.abrupt("return",this._keys);case 12:case"end":return e.stop()}},e,this)})),function(){return i.apply(this,arguments)})},{key:"getAuthParams",value:(n=z(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._authParams){e.next=5;break}return e.next=3,this.storageManager.getItem("auth_params");case 3:t=e.sent,this._authParams=JSON.parse(t);case 5:if(this._authParams&&!this._authParams.version)return e.next=8,this.defaultProtocolVersion();e.next=9;break;case 8:this._authParams.version=e.sent;case 9:return e.abrupt("return",this._authParams);case 10:case"end":return e.stop()}},e,this)})),function(){return n.apply(this,arguments)})},{key:"defaultProtocolVersion",value:(t=z(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.keys();case 2:if((t=e.sent)&&t.ak)return e.abrupt("return","002");e.next=7;break;case 7:return e.abrupt("return","001");case 8:case"end":return e.stop()}},e,this)})),function(){return t.apply(this,arguments)})},{key:"protocolVersion",value:(e=z(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getAuthParams();case 2:if((t=e.sent)&&t.version)return e.abrupt("return",t.version);e.next=5;break;case 5:return e.abrupt("return",this.defaultProtocolVersion());case 6:case"end":return e.stop()}},e,this)})),function(){return e.apply(this,arguments)})},{key:"getAuthParamsForEmail",value:(r=z(regeneratorRuntime.mark(function e(r,t,n){var i,a=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return(i=_.merge({email:t},n)).api=Y.getApiVersion(),e.abrupt("return",new Promise(function(t,e){var n=r+"/auth/params";a.httpManager.getAbsolute(n,i,function(e){t(e)},function(e){console.error("Error getting auth params",e),"object"!==H(e)&&(e={error:{message:"A server error occurred while trying to sign in. Please try again."}}),t(e)})}));case 3:case"end":return e.stop()}},e)})),function(e,t,n){return r.apply(this,arguments)})},{key:"lock",value:function(){this.locked=!0}},{key:"unlock",value:function(){this.locked=!1}},{key:"isLocked",value:function(){return 1==this.locked}},{key:"unlockAndResolve",value:function(e,t){this.unlock(),e(t)}},{key:"login",value:(s=z(regeneratorRuntime.mark(function e(p,h,m,v,g){var y=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(){var n=z(regeneratorRuntime.mark(function e(n,t){var r,i,a,o,s,c,u,l,d,f;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,y.keys();case 2:if(null!=e.sent)return n({error:{message:"Cannot log in because already signed in."}}),e.abrupt("return");e.next=6;break;case 6:if(y.isLocked())return n({error:{message:"Login already in progress."}}),e.abrupt("return");e.next=9;break;case 9:return y.lock(),y.notifyEvent(k.WillSignInEvent),e.next=13,y.getAuthParamsForEmail(p,h,g);case 13:if((r=e.sent).identifier=h,r.error)return y.unlockAndResolve(n,r),e.abrupt("return");e.next=18;break;case 18:if(r&&r.pw_cost){e.next=21;break}return y.unlockAndResolve(n,{error:{message:"Invalid email or password."}}),e.abrupt("return");case 21:if(SFJS.supportedVersions().includes(r.version)){e.next=25;break}return i=SFJS.isVersionNewerThanLibraryVersion(r.version)?"This version of the application does not support your newer account type. Please upgrade to the latest version of Standard Notes to sign in.":"The protocol version associated with your account is outdated and no longer supported by this application. Please visit standardnotes.org/help/security for more information.",y.unlockAndResolve(n,{error:{message:i}}),e.abrupt("return");case 25:if(SFJS.isProtocolVersionOutdated(r.version))return a="The encryption version for your account, ".concat(r.version,", is outdated and requires upgrade. You may proceed with login, but are advised to perform a security update using the web or desktop application. Please visit standardnotes.org/help/security for more information."),o=!1,e.next=30,y.alertManager.confirm({title:"Update Needed",text:a,confirmButtonText:"Sign In"}).catch(function(){y.unlockAndResolve(n,{error:{}}),o=!0});e.next=32;break;case 30:if(o)return e.abrupt("return");e.next=32;break;case 32:if(SFJS.supportsPasswordDerivationCost(r.pw_cost)){e.next=36;break}return"Your account was created on a platform with higher security capabilities than this browser supports. If we attempted to generate your login keys here, it would take hours. Please use a browser with more up to date security capabilities, like Google Chrome or Firefox, to log in.",y.unlockAndResolve(n,{error:{message:"Your account was created on a platform with higher security capabilities than this browser supports. If we attempted to generate your login keys here, it would take hours. Please use a browser with more up to date security capabilities, like Google Chrome or Firefox, to log in."}}),e.abrupt("return");case 36:if(s=SFJS.costMinimumForVersion(r.version),r.pw_costnew Date)return e.abrupt("return",!1);e.next=5;break;case 5:return e.next=7,this.netCredentialsForAction(t);case 7:return n=e.sent,e.abrupt("return",0=this.MaxDiscordanceBeforeOutOfSync&&(this.outOfSync||(this.outOfSync=!0,this.notifyEvent("enter-out-of-sync"))),e.abrupt("return",!1);e.next=13;break;case 13:return this.outOfSync&&(this.outOfSync=!1,this.notifyEvent("exit-out-of-sync")),this.syncDiscordance=0,e.abrupt("return",!0);case 16:case"end":return e.stop()}},e,this)})),function(e){return x.apply(this,arguments)})},{key:"isOutOfSync",value:function(){return this.outOfSync}},{key:"getServerURL",value:(w=z(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.storageManager.getItem("server");case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0=window._default_sf_server;case 5:return e.abrupt("return",e.t0);case 6:case"end":return e.stop()}},e,this)})),function(){return w.apply(this,arguments)})},{key:"getSyncURL",value:(b=z(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getServerURL();case 2:return e.t0=e.sent,e.abrupt("return",e.t0+"/items/sync");case 4:case"end":return e.stop()}},e,this)})),function(){return b.apply(this,arguments)})},{key:"registerSyncStatusObserver",value:function(e){var t={key:new Date,callback:e};return this.syncStatusObservers.push(t),t}},{key:"removeSyncStatusObserver",value:function(e){_.pull(this.syncStatusObservers,e)}},{key:"syncStatusDidChange",value:function(){var t=this;this.syncStatusObservers.forEach(function(e){e.callback(t.syncStatus)})}},{key:"addEventHandler",value:function(e){return this.eventHandlers.push(e),e}},{key:"removeEventHandler",value:function(e){_.pull(this.eventHandlers,e)}},{key:"notifyEvent",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.eventHandlers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){(0,a.value)(e,t||{})}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}}},{key:"setKeyRequestHandler",value:function(e){this.keyRequestHandler=e}},{key:"getActiveKeyInfo",value:(k=z(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.keyRequestHandler(t));case 1:case"end":return e.stop()}},e,this)})),function(e){return k.apply(this,arguments)})},{key:"initialDataLoaded",value:function(){return!0===this._initialDataLoaded}},{key:"_sortLocalItems",value:function(e){var o=this;return e.sort(function(e,t){var n=new Date(t.updated_at)-new Date(e.updated_at),r=o.contentTypeLoadPriority,i=0,a=0;return r&&(i=r.indexOf(e.content_type),a=r.indexOf(t.content_type),-1==i&&(i=r.length),-1==a&&(a=r.length)),i==a?n:it.dirtiedDate})).length,a=0,o=[],s=function(){var e=z(regeneratorRuntime.mark(function e(){var t,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.slice(a,a+u),e.next=3,l.handleItemsResponse(t,null,Z.MappingSourceLocalRetrieved,O.KeyRequestLoadLocal);case 3:if(n=e.sent,o.push(n),(a+=t.length)y.lastDirtyItemsSave}),e.next=5,y.getActiveKeyInfo(O.KeyRequestLoadSaveAccount);case 5:if(a=e.sent,o=y.syncStatus.syncOpInProgress,s=y.initialDataLoaded(),o||!s)return y.performSyncAgainOnCompletion=!0,y.lastDirtyItemsSave=new Date,e.next=13,y.writeItemsToLocalStorage(i,!1);e.next=16;break;case 13:return o&&(y.queuedCallbacks.push(n),y.loggingEnabled&&console.warn("Attempting to sync while existing sync is in progress.")),s||(y.loggingEnabled&&console.warn("(1) Attempting to perform online sync before local data has loaded"),n()),e.abrupt("return");case 16:if(y.syncStatus.syncOpInProgress=!0,a.offline)return e.abrupt("return",y.syncOffline(r).then(function(e){y.syncStatus.syncOpInProgress=!1,n(e)}).catch(function(e){y.notifyEvent("sync-exception",e)}));e.next=19;break;case 19:if(y.initialDataLoaded()){e.next=22;break}return console.error("Attempting to perform online sync before local data has loaded"),e.abrupt("return");case 22:return y.loggingEnabled&&console.log("Syncing online user."),c=y.syncStatus.needsMoreSync,y.syncStatus.syncStart=new Date,y.beginCheckingIfSyncIsTakingTooLong(),u=y.PerSyncItemUploadLimit,(l=r.slice(0,u)).lengthy.syncStatus.total&&(y.syncStatus.total=y.syncStatus.current),y.syncStatusDidChange(),e.next=34,y.writeItemsToLocalStorage(i,!1);case 34:return y.lastDirtyItemsSave=new Date,g.onPreSyncSave&&g.onPreSyncSave(),y.allRetreivedItems||(y.allRetreivedItems=[]),y.allSavedItems||(y.allSavedItems=[]),(d={}).limit=y.ServerItemDownloadLimit,g.performIntegrityCheck&&(d.compute_integrity=!0),e.prev=41,e.next=44,Promise.all(l.map(function(e){var t=new ue(e,a.keys,a.auth_params);return t.additionalFields=g.additionalFields,t.paramsForSync()})).then(function(e){d.items=e});case 44:e.next=49;break;case 46:e.prev=46,e.t0=e.catch(41),y.notifyEvent("sync-exception",e.t0);case 49:for(p=!(f=!0),h=void 0,e.prev=52,m=l[Symbol.iterator]();!(f=(v=m.next()).done);f=!0)v.value.dirtyCount=0;e.next=60;break;case 56:e.prev=56,e.t1=e.catch(52),p=!0,h=e.t1;case 60:e.prev=60,e.prev=61,f||null==m.return||m.return();case 63:if(e.prev=63,p)throw h;e.next=66;break;case 66:return e.finish(63);case 67:return e.finish(60);case 68:return e.next=70,y.getSyncToken();case 70:return d.sync_token=e.sent,e.next=73,y.getCursorToken();case 73:return d.cursor_token=e.sent,d.api=Y.getApiVersion(),e.prev=75,e.t2=y.httpManager,e.next=79,y.getSyncURL();case 79:e.t3=e.sent,e.t4=d,e.t5=function(e){y.handleSyncSuccess(l,e,g).then(function(){n(e)}).catch(function(t){console.log("Caught sync success exception:",t),y.handleSyncError(t,null,r).then(function(e){y.notifyEvent("sync-exception",t),n(e)})})},e.t6=function(e,t){y.handleSyncError(e,t,r).then(function(e){n(e)})},e.t2.postAuthenticatedAbsolute.call(e.t2,e.t3,e.t4,e.t5,e.t6),e.next=89;break;case 86:e.prev=86,e.t7=e.catch(75),console.log("Sync exception caught:",e.t7);case 89:case"end":return e.stop()}},e,null,[[41,46],[52,56,60,68],[61,,63,67],[75,86]])}));return function(e,t){return n.apply(this,arguments)}}()));case 5:case"end":return e.stop()}},e,this)})),function(){return l.apply(this,arguments)})},{key:"_awaitSleep",value:(u=z(regeneratorRuntime.mark(function e(n){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.warn("Simulating high latency sync request",n),e.abrupt("return",new Promise(function(e,t){setTimeout(function(){e()},n)}));case 2:case"end":return e.stop()}},e)})),function(e){return u.apply(this,arguments)})},{key:"handleSyncSuccess",value:(c=z(regeneratorRuntime.mark(function e(t,n,r){var i,a,o,s,c,u,l,d,f,p,h,m,v,g,y,k,b=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r.simulateHighLatency)return i=r.simulatedLatency||1e3,e.next=4,this._awaitSleep(i);e.next=4;break;case 4:for(this.syncStatus.error=null,this.loggingEnabled&&console.log("Sync response",n),a=this.allSavedItems.map(function(e){return e.uuid}),o=n.saved_items.map(function(e){return e.uuid}),n.retrieved_items=n.retrieved_items.filter(function(e){var t=a.includes(e.uuid),n=o.includes(e.uuid);if(t||n)return!1;var r=b.modelManager.findItem(e.uuid);return!r||!r.dirty}),s=[],u=!(c=!0),l=void 0,e.prev=13,d=t[Symbol.iterator]();!(c=(f=d.next()).done);c=!0)0==(p=f.value).dirtyCount&&s.push(p);e.next=21;break;case 17:e.prev=17,e.t0=e.catch(13),u=!0,l=e.t0;case 21:e.prev=21,e.prev=22,c||null==d.return||d.return();case 24:if(e.prev=24,u)throw l;e.next=27;break;case 27:return e.finish(24);case 28:return e.finish(21);case 29:return this.modelManager.clearDirtyItems(s),e.next=32,this.handleItemsResponse(n.retrieved_items,null,Z.MappingSourceRemoteRetrieved,O.KeyRequestLoadSaveAccount);case 32:return h=e.sent,this.allRetreivedItems=this.allRetreivedItems.concat(h),this.syncStatus.retrievedCount=this.allRetreivedItems.length,m=["content","auth_hash"],e.next=38,this.handleItemsResponse(n.saved_items,m,Z.MappingSourceRemoteSaved,O.KeyRequestLoadSaveAccount);case 38:return v=e.sent,this.allSavedItems=this.allSavedItems.concat(v),g=n.unsaved,e.next=43,this.deprecated_handleUnsavedItemsResponse(g);case 43:return e.next=45,this.handleConflictsResponse(n.conflicts);case 45:if(y=e.sent,k=y&&0=this.majorDataChangeThreshold||v.length>=this.majorDataChangeThreshold||g&&g.length>=this.majorDataChangeThreshold||y&&y.length>=this.majorDataChangeThreshold)&&this.notifyEvent("major-data-change"),this.callQueuedCallbacks(n),this.notifyEvent("sync:completed",{retrievedItems:this.allRetreivedItems,savedItems:this.allSavedItems}),this.allRetreivedItems=[],this.allSavedItems=[],this.performSyncAgainOnCompletion&&(this.performSyncAgainOnCompletion=!1,setTimeout(function(){b.sync(r)},10)),e.abrupt("return",n);case 88:case"end":return e.stop()}},e,this,[[13,17,21,29],[22,,24,28]])})),function(e,t,n){return c.apply(this,arguments)})},{key:"handleSyncError",value:(s=z(regeneratorRuntime.mark(function e(t,n,r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("Sync error: ",t),401==n&&this.notifyEvent("sync-session-invalid"),t?"string"==typeof t&&(t={error:{message:t}}):t={error:{message:"Could not connect to server."}},this.syncStatus.syncOpInProgress=!1,this.syncStatus.error=t.error,this.syncStatusDidChange(),this.writeItemsToLocalStorage(r,!1),this.modelManager.didSyncModelsOffline(r),this.stopCheckingIfSyncIsTakingTooLong(),this.notifyEvent("sync:error",t.error),this.callQueuedCallbacks({error:"Sync error"}),e.abrupt("return",t);case 12:case"end":return e.stop()}},e,this)})),function(e,t,n){return s.apply(this,arguments)})},{key:"handleItemsResponse",value:(o=z(regeneratorRuntime.mark(function e(t,n,r,i){var a,o,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getActiveKeyInfo(i);case 2:return a=e.sent.keys,e.next=5,SFJS.itemTransformer.decryptMultipleItems(t,a);case 5:return e.next=7,this.modelManager.mapResponseItemsToLocalModelsOmittingFields(t,n,r);case 7:return o=e.sent,0<(s=o.filter(function(e){var t=e.errorDecryptingValueChanged;return e.errorDecryptingValueChanged=!1,t})).length&&this.writeItemsToLocalStorage(s,!1),e.abrupt("return",o);case 11:case"end":return e.stop()}},e,this)})),function(e,t,n,r){return o.apply(this,arguments)})},{key:"refreshErroredItems",value:(a=z(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(0<(t=this.modelManager.allNondummyItems.filter(function(e){return 1==e.errorDecrypting})).length)return e.abrupt("return",this.handleItemsResponse(t,null,Z.MappingSourceLocalRetrieved,O.KeyRequestLoadSaveAccount));e.next=3;break;case 3:case"end":return e.stop()}},e,this)})),function(){return a.apply(this,arguments)})},{key:"handleConflictsResponse",value:(i=z(regeneratorRuntime.mark(function e(t){var n,r,i,a,o,s,c,u,l,d,f,p,h,m,v,g,y,k,b,w,x,S,$,_,M,I,C,A,D,R,E,P;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&0!=t.length){e.next=2;break}return e.abrupt("return");case 2:this.loggingEnabled&&console.log("Handle Conflicted Items:",t),n={},i=!(r=!0),a=void 0,e.prev=7,o=t[Symbol.iterator]();case 9:if(r=(s=o.next()).done){e.next=21;break}if(c=s.value,u=c.server_item||c.unsaved_item,l=this.modelManager.findItem(u.uuid)){e.next=16;break}return n[u.uuid]={},e.abrupt("continue",18);case 16:d=l.getContentCopy(),n[u.uuid]={frozenContent:d,itemRef:l};case 18:r=!0,e.next=9;break;case 21:e.next=27;break;case 23:e.prev=23,e.t0=e.catch(7),i=!0,a=e.t0;case 27:e.prev=27,e.prev=28,r||null==o.return||o.return();case 30:if(e.prev=30,i)throw a;e.next=33;break;case 33:return e.finish(30);case 34:return e.finish(27);case 35:f=[],h=!(p=!0),m=void 0,e.prev=39,v=t[Symbol.iterator]();case 41:if(p=(g=v.next()).done){e.next=91;break}return y=g.value,k=y.server_item||y.unsaved_item,e.t1=SFJS.itemTransformer,e.t2=[k],e.next=48,this.getActiveKeyInfo(O.KeyRequestLoadSaveAccount);case 48:return e.t3=e.sent.keys,e.next=51,e.t1.decryptMultipleItems.call(e.t1,e.t2,e.t3);case 51:if(b=n[k.uuid],w=b.frozenContent,x=b.itemRef){e.next=54;break}return e.abrupt("continue",88);case 54:if(f.push(x),"uuid_conflict"===y.type)return e.next=58,this.modelManager.alternateUUIDForItem(x);e.next=62;break;case 58:S=e.sent,f.push(S),e.next=88;break;case 62:if("sync_conflict"===y.type)return e.next=65,this.modelManager.createDuplicateItemFromResponseItem(k);e.next=86;break;case 65:if($=e.sent,_=this.modelManager.duplicateItemWithCustomContent({content:w,duplicateOf:x}),M=!_.isItemContentEqualWith($),I=!x.isItemContentEqualWith($),R=D=A=C=!1,k.deleted||x.deleted?R=!0:M?(20,(new Date-x.client_updated_at)/1e3<20?A=D=!0:R=C=!0):I?(E=!ce.AreItemContentsEqual({leftContent:x.content,rightContent:$.content,keysToIgnore:x.keysToIgnoreWhenCheckingContentEquality().concat(["references"]),appDataKeysToIgnore:x.appDataKeysToIgnoreWhenCheckingContentEquality()}),!E?D=!0:R=C=!0):R=!0,C)return e.next=77,this.modelManager.duplicateItemWithCustomContentAndAddAsConflict({content:w,duplicateOf:x});e.next=79;break;case 77:P=e.sent,f.push(P);case 79:if(A&&(this.modelManager.addDuplicatedItemAsConflict({duplicate:$,duplicateOf:x}),f.push($)),R)return e.next=83,this.modelManager.mapResponseItemsToLocalModelsOmittingFields([k],null,Z.MappingSourceRemoteRetrieved);e.next=83;break;case 83:D&&(x.updated_at=$.updated_at,x.setDirty(!0)),e.next=88;break;case 86:return console.error("Unsupported conflict type",y.type),e.abrupt("continue",88);case 88:p=!0,e.next=41;break;case 91:e.next=97;break;case 93:e.prev=93,e.t4=e.catch(39),h=!0,m=e.t4;case 97:e.prev=97,e.prev=98,p||null==v.return||v.return();case 100:if(e.prev=100,h)throw m;e.next=103;break;case 103:return e.finish(100);case 104:return e.finish(97);case 105:return e.abrupt("return",f);case 106:case"end":return e.stop()}},e,this,[[7,23,27,35],[28,,30,34],[39,93,97,105],[98,,100,104]])})),function(e){return i.apply(this,arguments)})},{key:"deprecated_handleUnsavedItemsResponse",value:(r=z(regeneratorRuntime.mark(function e(t){var n,r,i,a,o,s,c,u,l,d;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&0!=t.length){e.next=2;break}return e.abrupt("return");case 2:this.loggingEnabled&&console.log("Handle Unsaved Items:",t),r=!(n=!0),i=void 0,e.prev=6,a=t[Symbol.iterator]();case 8:if(n=(o=a.next()).done){e.next=35;break}return s=o.value,c=s.item,e.t0=SFJS.itemTransformer,e.t1=[c],e.next=15,this.getActiveKeyInfo(O.KeyRequestLoadSaveAccount);case 15:return e.t2=e.sent.keys,e.next=18,e.t0.decryptMultipleItems.call(e.t0,e.t1,e.t2);case 18:if(u=this.modelManager.findItem(c.uuid)){e.next=21;break}return e.abrupt("continue",32);case 21:if("uuid_conflict"===(l=s.error).tag)return e.next=25,this.modelManager.alternateUUIDForItem(u);e.next=27;break;case 25:e.next=32;break;case 27:if("sync_conflict"===l.tag)return e.next=30,this.modelManager.createDuplicateItemFromResponseItem(c);e.next=32;break;case 30:d=e.sent,c.deleted||u.isItemContentEqualWith(d)||this.modelManager.addDuplicatedItemAsConflict({duplicate:d,duplicateOf:u});case 32:n=!0,e.next=8;break;case 35:e.next=41;break;case 37:e.prev=37,e.t3=e.catch(6),r=!0,i=e.t3;case 41:e.prev=41,e.prev=42,n||null==a.return||a.return();case 44:if(e.prev=44,r)throw i;e.next=47;break;case 47:return e.finish(44);case 48:return e.finish(41);case 49:case"end":return e.stop()}},e,this,[[6,37,41,49],[42,,44,48]])})),function(e){return r.apply(this,arguments)})},{key:"stateless_downloadAllItems",value:function(e){var a=this,o=0"==t.operator?p="==t.operator?p<=h:"startsWith"==t.operator?h.startsWith(p):"in"==t.operator?-1!=p.indexOf(h):"includes"==t.operator?this.resolveIncludesPredicate(h,p):"matches"==t.operator&&new RegExp(p).test(h)}},{key:"resolveIncludesPredicate",value:function(e,t){if("string"==typeof t)return e.includes(t);var n;n=Array.isArray(t)?v.fromArray(t):t;var 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;if(this.ObjectSatisfiesPredicate(c,n))return!0}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return!1}},{key:"ItemSatisfiesPredicate",value:function(e,t){return Array.isArray(t)&&(t=v.fromArray(t)),this.ObjectSatisfiesPredicate(e,t)}},{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)}}]),v}();we.SFPredicate=le;var de=function(){function n(e){var t;return V(this,n),(t=F(this,N(n).call(this,e))).content.desktopPrivileges||(t.content.desktopPrivileges={}),t}return L(n,ce),q(n,null,[{key:"contentType",value:function(){return"SN|Privileges"}}]),q(n,[{key:"setCredentialsForAction",value:function(e,t){this.content.desktopPrivileges[e]=t}},{key:"getCredentialsForAction",value:function(e){return this.content.desktopPrivileges[e]||[]}},{key:"toggleCredentialForAction",value:function(e,t){this.isCredentialRequiredForAction(e,t)?this.removeCredentialForAction(e,t):this.addCredentialForAction(e,t)}},{key:"removeCredentialForAction",value:function(e,t){_.pull(this.content.desktopPrivileges[e],t)}},{key:"addCredentialForAction",value:function(e,t){var n=this.getCredentialsForAction(e);n.push(t),this.setCredentialsForAction(e,n)}},{key:"isCredentialRequiredForAction",value:function(e,t){return this.getCredentialsForAction(e).includes(t)}}]),n}();we.SFPrivileges=de;var fe=function(){function r(e){var n;return V(this,r),(n=F(this,N(r).call(this,e))).content.itemUUIDToItemHistoryMapping||(n.content.itemUUIDToItemHistoryMapping={}),Object.keys(n.content.itemUUIDToItemHistoryMapping).forEach(function(e){var t=n.content.itemUUIDToItemHistoryMapping[e];n.content.itemUUIDToItemHistoryMapping[e]=new pe(t)}),n}return L(r,ce),q(r,[{key:"addEntryForItem",value:function(e){return this.historyForItem(e).addHistoryEntryForItem(e)}},{key:"historyForItem",value:function(e){var t=this.content.itemUUIDToItemHistoryMapping[e.uuid];return t=t||(this.content.itemUUIDToItemHistoryMapping[e.uuid]=new pe)}},{key:"clearItemHistory",value:function(e){this.historyForItem(e).clear()}},{key:"clearAllHistory",value:function(){this.content.itemUUIDToItemHistoryMapping={}}},{key:"optimizeHistoryForItem",value:function(e){var t=this.historyForItem(e);t.entries.length>r.LargeItemEntryAmountThreshold&&t.optimize()}}]),r}();(we.SFHistorySession=fe).LargeItemEntryAmountThreshold=60;var pe=function(){function c(){var e=0c.LargeEntryDeltaThreshold}function r(e,t,n){if(n?o.push(e):-1!==(t=o.indexOf(e))&&o.splice(t,1),n&&i(e)&&-1==e.operationVector()){var r=a.entries[t-1];r&&o.push(r)}}var a=this,o=[];this.entries.forEach(function(e,t){if(0==t||t==a.entries.length-1)r(e,t,!0);else{var n=i(e);r(e,t,n)}}),this.entries=this.entries.filter(function(e,t){return-1!==o.indexOf(e)})}}]),c}();(we.SFItemHistory=pe).LargeEntryDeltaThreshold=15;var he=function(){function t(e){V(this,t),this.item=ce.deepMerge({},e),this.defaultContentKeyToDiffOn="text",this.textCharDiffLength=0,"string"==typeof this.item.updated_at&&(this.item.updated_at=new Date(this.item.updated_at))}return q(t,[{key:"setPreviousEntry",value:function(e){this.hasPreviousEntry=null!=e,this.item.content[this.defaultContentKeyToDiffOn]&&(this.textCharDiffLength=e?this.item.content[this.defaultContentKeyToDiffOn].length-e.item.content[this.defaultContentKeyToDiffOn].length:this.item.content[this.defaultContentKeyToDiffOn].length)}},{key:"operationVector",value:function(){return null!=this.textCharDiffLength?this.hasPreviousEntry&&0!=this.textCharDiffLength?this.textCharDiffLength<0?-1:1:0:1}},{key:"deltaSize",value:function(){return null!=this.textCharDiffLength?Math.abs(this.textCharDiffLength):1}},{key:"isSameAsEntry",value:function(e){if(!e)return!1;var t=new ce(this.item),n=new ce(e.item);return t.isItemContentEqualWith(n)}}]),t}();we.SFItemHistoryEntry=he;G="undefined"!=typeof window?window:void 0!==e?e:null;var me=function(){function e(){V(this,e),this.DefaultPBKDF2Length=768}var n,r,t,i,a,o,s,c,u,l,d,f,p,h,m;return q(e,[{key:"generateUUIDSync",value:function(){var e=G.crypto||G.msCrypto;if(e){var n=new Uint32Array(4);e.getRandomValues(n);var r=-1;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=n[++r>>3]>>r%8*4&15;return("x"==e?t:3&t|8).toString(16)})}var i=(new Date).getTime();return G.performance&&"function"==typeof G.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)})}},{key:"generateUUID",value:(m=z(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.generateUUIDSync());case 1:case"end":return e.stop()}},e,this)})),function(){return m.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;oparseInt(t)}},{key:"isProtocolVersionOutdated",value:function(e){var t={"001":Date.parse("2018-01-01"),"002":Date.parse("2020-01-01")}[e];return!!t&&new Date>t}},{key:"costMinimumForVersion",value:function(e){return{"001":3e3,"002":3e3,"003":11e4}[e]}},{key:"defaultPasswordGenerationCost",value:function(){return this.costMinimumForVersion(this.version())}}]),t}();if(we.StandardFile=be,G)try{G.StandardFile=be,G.SFJS=new be,G.SFCryptoWeb=ye,G.SFCryptoJS=ve,G.SFItemTransformer=ke,G.SFModelManager=Z,G.SFItem=ce,G.SFItemParams=ue,G.SFHttpManager=Y,G.SFStorageManager=ae,G.SFSyncManager=se,G.SFAuthManager=J,G.SFMigrationManager=X,G.SFAlertManager=W,G.SFPredicate=le,G.SFHistorySession=fe,G.SFSessionHistoryManager=re,G.SFItemHistory=pe,G.SFItemHistoryEntry=he,G.SFPrivilegesManager=Q,G.SFPrivileges=de,G.SFSingletonManager=ie}catch(e){console.log("Exception while exporting window variables",e)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}),function(le){"use strict";var l={objectMaxDepth:5,urlErrorParamsEnabled:!0};function e(e){if(!xe(e))return l;E(e.objectMaxDepth)&&(l.objectMaxDepth=r(e.objectMaxDepth)?e.objectMaxDepth:NaN),E(e.urlErrorParamsEnabled)&&Ce(e.urlErrorParamsEnabled)&&(l.urlErrorParamsEnabled=e.urlErrorParamsEnabled)}function r(e){return x(e)&&0").append(e).html();try{return e[0].nodeType===je?he(t):t.match(/^(<[^>]+>)/)[1].replace(/^<([\w-]+)/,function(e,t){return"<"+he(t)})}catch(e){return he(t)}}function G(e){try{return decodeURIComponent(e)}catch(e){}}function Y(e){var i={};return ve((e||"").split("&"),function(e){var t,n,r;e&&(n=e=e.replace(/\+/g,"%20"),-1!==(t=e.indexOf("="))&&(n=e.substring(0,t),r=e.substring(t+1)),E(n=G(n))&&(r=!E(r)||G(r),pe.call(i,n)?$e(i[n])?i[n].push(r):i[n]=[i[n],r]:i[n]=r))}),i}function X(e){return Z(e,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function Z(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 Q=["ng-","data-ng-","ng:","x-ng-"];var ee=function(n){var e=n.currentScript;if(!e)return!0;if(!(e instanceof le.HTMLScriptElement||e instanceof le.SVGScriptElement))return!1;var t=e.attributes;return[t.getNamedItem("src"),t.getNamedItem("href"),t.getNamedItem("xlink:href")].every(function(e){if(!e)return!0;if(!e.value)return!1;var t=n.createElement("a");if(t.href=e.value,n.location.origin===t.origin)return!0;switch(t.protocol){case"http:":case"https:":case"ftp:":case"blob:":case"file:":case"data:":return!0;default:return!1}})}(le.document);function te(r,e){var i,a,t={};if(ve(Q,function(e){var t=e+"app";!i&&r.hasAttribute&&r.hasAttribute(t)&&(a=(i=r).getAttribute(t))}),ve(Q,function(e){var t,n=e+"app";!i&&(t=r.querySelector("["+n.replace(":","\\:")+"]"))&&(a=(i=t).getAttribute(n))}),i){if(!ee)return void le.console.error("AngularJS: disabling automatic bootstrap.