diff --git a/packages/mobile/package.json b/packages/mobile/package.json index f01b60265..ac0082a95 100644 --- a/packages/mobile/package.json +++ b/packages/mobile/package.json @@ -32,7 +32,7 @@ "@react-navigation/elements": "^1.3.3", "@react-navigation/native": "^6.0.10", "@react-navigation/stack": "^6.2.1", - "@standardnotes/components": "^1.9.0", + "@standardnotes/components": "^1.9.1", "@standardnotes/filepicker": "^1.16.14", "@standardnotes/icons": "^1.3.0", "@standardnotes/react-native-aes": "^1.4.3", diff --git a/packages/web-server/public/components/checksums.json b/packages/web-server/public/components/checksums.json index f305754ae..77f4dbf08 100644 --- a/packages/web-server/public/components/checksums.json +++ b/packages/web-server/public/components/checksums.json @@ -95,9 +95,9 @@ "binary": "88d4b9a6ff94b1f6cba884787e051cda3cd8073022984b63f7d3b13157aa6e2a" }, "org.standardnotes.markdown-visual-editor": { - "version": "1.0.6", - "base64": "13497d3939fbec67cf0baa0f7c182112f0d13474a3e7f4750790823f78688a47", - "binary": "fc6e37d7250d14b245facb760aece51d006fd321d9ac2f153c5a571565411311" + "version": "1.0.7", + "base64": "cc6cdd05685accb9bdbf34ea4faa2fd9324183b4d55312b60234b8e611cec71f", + "binary": "a7cf6e82a4ae7cc9e3c5c4efc24bcc69bd4ff17039123e9c0b883d1989f908c9" }, "org.standardnotes.advanced-checklist": { "version": "0.0.1", diff --git a/packages/web-server/public/components/org.standardnotes.markdown-visual-editor/build/asset-manifest.json b/packages/web-server/public/components/org.standardnotes.markdown-visual-editor/build/asset-manifest.json index fb2e8cb99..fbc3c664c 100644 --- a/packages/web-server/public/components/org.standardnotes.markdown-visual-editor/build/asset-manifest.json +++ b/packages/web-server/public/components/org.standardnotes.markdown-visual-editor/build/asset-manifest.json @@ -1,7 +1,7 @@ { "files": { "main.css": "./static/css/main.904cd38b.css", - "main.js": "./static/js/main.330241d2.js", + "main.js": "./static/js/main.ad13c3af.js", "static/media/material-icons-two-tone.woff": "./static/media/material-icons-two-tone.ee71463e28071436d096.woff", "static/media/material-icons-two-tone.woff2": "./static/media/material-icons-two-tone.7e94e72135150c6b387c.woff2", "static/media/material-icons-round.woff": "./static/media/material-icons-round.159dc8004e17a33f287f.woff", @@ -74,10 +74,10 @@ "static/media/KaTeX_Size3-Regular.woff2": "./static/media/KaTeX_Size3-Regular.e1951519f6f0596f7356.woff2", "index.html": "./index.html", "main.904cd38b.css.map": "./static/css/main.904cd38b.css.map", - "main.330241d2.js.map": "./static/js/main.330241d2.js.map" + "main.ad13c3af.js.map": "./static/js/main.ad13c3af.js.map" }, "entrypoints": [ "static/css/main.904cd38b.css", - "static/js/main.330241d2.js" + "static/js/main.ad13c3af.js" ] } \ No newline at end of file diff --git a/packages/web-server/public/components/org.standardnotes.markdown-visual-editor/build/index.html b/packages/web-server/public/components/org.standardnotes.markdown-visual-editor/build/index.html index 46283b976..7254e5fad 100644 --- a/packages/web-server/public/components/org.standardnotes.markdown-visual-editor/build/index.html +++ b/packages/web-server/public/components/org.standardnotes.markdown-visual-editor/build/index.html @@ -1 +1 @@ -Markdown Visual
\ No newline at end of file +Markdown Visual
\ No newline at end of file diff --git a/packages/web-server/public/components/org.standardnotes.markdown-visual-editor/build/static/js/main.ad13c3af.js b/packages/web-server/public/components/org.standardnotes.markdown-visual-editor/build/static/js/main.ad13c3af.js new file mode 100644 index 000000000..3ca7f345f --- /dev/null +++ b/packages/web-server/public/components/org.standardnotes.markdown-visual-editor/build/static/js/main.ad13c3af.js @@ -0,0 +1,3 @@ +/*! For license information please see main.ad13c3af.js.LICENSE.txt */ +!function(){var t={228:function(t){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){u=!0,a=t},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}},t.exports.__esModule=!0,t.exports.default=t.exports},713:function(t){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},t.exports.__esModule=!0,t.exports.default=t.exports},379:function(t,e,n){var r=n(228);t.exports=function(t,e){if(t){if("string"===typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}},t.exports.__esModule=!0,t.exports.default=t.exports},757:function(t,e,n){t.exports=n(727)},613:function(t,e,n){var r,i=n(757),o=n(926).default,a=n(269).default,s=n(575).default,u=n(913).default,l=n(713).default;self,t.exports=(r=n(634),function(){var t,e,n={156:function(t){self,t.exports=function(){"use strict";var t,e,n,r,i,o={d:function(t,e){for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},c={};o.d(c,{default:function(){return A}}),function(t){t.SetSize="set-size",t.StreamItems="stream-items",t.StreamContextItem="stream-context-item",t.SaveItems="save-items",t.SelectItem="select-item",t.AssociateItem="associate-item",t.DeassociateItem="deassociate-item",t.ClearSelection="clear-selection",t.CreateItem="create-item",t.CreateItems="create-items",t.DeleteItems="delete-items",t.SetComponentData="set-component-data",t.InstallLocalComponent="install-local-component",t.ToggleActivateComponent="toggle-activate-component",t.RequestPermissions="request-permissions",t.PresentConflictResolution="present-conflict-resolution",t.DuplicateItem="duplicate-item",t.ComponentRegistered="component-registered",t.ActivateThemes="themes",t.Reply="reply",t.SaveSuccess="save-success",t.SaveError="save-error",t.ThemesActivated="themes-activated",t.KeyDown="key-down",t.KeyUp="key-up",t.Click="click"}(t||(t={})),function(t){t[t.Web=1]="Web",t[t.Desktop=2]="Desktop",t[t.Mobile=3]="Mobile"}(e||(e={})),function(t){t.Any="*",t.Item="SF|Item",t.RootKey="SN|RootKey|NoSync",t.ItemsKey="SN|ItemsKey",t.EncryptedStorage="SN|EncryptedStorage",t.Note="Note",t.Tag="Tag",t.SmartTag="SN|SmartTag",t.Component="SN|Component",t.Editor="SN|Editor",t.ActionsExtension="Extension",t.UserPrefs="SN|UserPreferences",t.HistorySession="SN|HistorySession",t.Theme="SN|Theme",t.Mfa="SF|MFA",t.ServerExtension="SF|Extension",t.FilesafeCredentials="SN|FileSafe|Credentials",t.FilesafeFileMetadata="SN|FileSafe|FileMetadata",t.FilesafeIntegration="SN|FileSafe|Integration",t.ExtensionRepo="SN|ExtensionRepo"}(n||(n={})),function(t){t.Pinned="pinned",t.Archived="archived",t.Locked="locked",t.UserModifiedDate="client_updated_at",t.DefaultEditor="defaultEditor",t.MobileRules="mobileRules",t.NotAvailableOnMobile="notAvailableOnMobile",t.MobileActive="mobileActive",t.LastSize="lastSize",t.PrefersPlainEditor="prefersPlainEditor",t.ComponentInstallError="installError"}(r||(r={}));var h=new Uint8Array(16);function f(){if(!i&&!(i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(h)}for(var d=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,p=function(t){return"string"==typeof t&&d.test(t)},g=[],m=0;m<256;++m)g.push((m+256).toString(16).substr(1));var v,y,b,k,x=function(t,e,n){var r=(t=t||{}).random||(t.rng||f)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){n=n||0;for(var i=0;i<16;++i)e[n+i]=r[i];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(g[t[e+0]]+g[t[e+1]]+g[t[e+2]]+g[t[e+3]]+"-"+g[t[e+4]]+g[t[e+5]]+"-"+g[t[e+6]]+g[t[e+7]]+"-"+g[t[e+8]]+g[t[e+9]]+"-"+g[t[e+10]]+g[t[e+11]]+g[t[e+12]]+g[t[e+13]]+g[t[e+14]]+g[t[e+15]]).toLowerCase();if(!p(n))throw TypeError("Stringified UUID is invalid");return n}(r)},w=function(t){var n,r,i=(l(n={},e.Web,"web"),l(n,e.Desktop,"desktop"),l(n,e.Mobile,"mobile"),n);return null!==(r=i[t])&&void 0!==r?r:i[e.Web]},O=function(t){return null!=t},S=function(){},_=function(){function t(){s(this,t)}return u(t,null,[{key:"isSupported",get:function(){return!(!window.console&&!console)}},{key:"info",get:function(){return t.isSupported&&this.enabled?console.log.bind(console):S}},{key:"error",get:function(){return t.isSupported?console.error.bind(console):S}}]),t}();function T(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function C(t){for(var e=1;e0&&(this.initialPermissions=r),O(null==i?void 0:i.coallesedSaving)&&(this.coallesedSaving=i.coallesedSaving),O(null==i?void 0:i.coallesedSavingDelay)&&(this.coallesedSavingDelay=i.coallesedSavingDelay),O(null==i?void 0:i.acceptsThemes)&&(this.component.acceptsThemes=null===(n=null==i?void 0:i.acceptsThemes)||void 0===n||n),O(o)&&(this.onReadyCallback=o),O(a)&&(this.onThemesChangeCallback=a),_.enabled=null!==(e=null==i?void 0:i.debug)&&void 0!==e&&e}},{key:"deinit",value:function(){this.onReadyCallback=void 0,this.component={acceptsThemes:!0,activeThemes:[]},this.messageQueue=[],this.sentMessages=[],this.lastStreamedItem=void 0,this.pendingSaveItems=void 0,this.pendingSaveTimeout=void 0,this.pendingSaveParams=void 0,this.messageHandler&&(this.contentWindow.document.removeEventListener("message",this.messageHandler),this.contentWindow.removeEventListener("message",this.messageHandler)),this.keyDownEventListener&&this.contentWindow.removeEventListener("keydown",this.keyDownEventListener),this.keyUpEventListener&&this.contentWindow.removeEventListener("keyup",this.keyUpEventListener),this.clickEventListener&&this.contentWindow.removeEventListener("click",this.clickEventListener)}},{key:"registerMessageHandler",value:function(){var e=this;this.messageHandler=function(n){if(_.info("Components API Message received:",n.data),!document.referrer||new URL(document.referrer).origin===new URL(n.origin).origin){var r=n.data,i=function(t){if("string"!=typeof t)return!1;try{var e=JSON.parse(t),n=Object.prototype.toString.call(e);return"[object Object]"===n||"[object Array]"===n}catch(t){return!1}}(r)?JSON.parse(r):r;if(i){if(void 0===e.component.origin&&i.action===t.ComponentRegistered)e.component.origin=n.origin;else if(n.origin!==e.component.origin)return;e.handleMessage(i)}else _.error("Invalid data received. Skipping...")}},this.contentWindow.document.addEventListener("message",this.messageHandler,!1),this.contentWindow.addEventListener("message",this.messageHandler,!1),_.info("Waiting for messages...")}},{key:"registerKeyboardEventListeners",value:function(){var t=this;this.keyDownEventListener=function(e){_.info("A key has been pressed: ".concat(e.key)),e.ctrlKey?t.keyDownEvent(k.Ctrl):e.shiftKey?t.keyDownEvent(k.Shift):(e.metaKey||"Meta"===e.key)&&t.keyDownEvent(k.Meta)},this.keyUpEventListener=function(e){_.info("A key has been released: ".concat(e.key)),"Control"===e.key?t.keyUpEvent(k.Ctrl):"Shift"===e.key?t.keyUpEvent(k.Shift):"Meta"===e.key&&t.keyUpEvent(k.Meta)},this.contentWindow.addEventListener("keydown",this.keyDownEventListener,!1),this.contentWindow.addEventListener("keyup",this.keyUpEventListener,!1)}},{key:"registerMouseEventListeners",value:function(){var t=this;this.clickEventListener=function(e){_.info("A click has been performed."),t.mouseClickEvent()},this.contentWindow.addEventListener("click",this.clickEventListener,!1)}},{key:"handleMessage",value:function(e){switch(e.action){case t.ComponentRegistered:this.component.sessionKey=e.sessionKey,e.componentData&&(this.component.data=e.componentData),this.onReady(e.data),_.info("Component successfully registered with payload:",e);break;case t.ActivateThemes:this.activateThemes(e.data.themes);break;default:var n,r;if(!e.original)return;var i=null===(n=this.sentMessages)||void 0===n?void 0:n.filter((function(t){var n;return t.messageId===(null===(n=e.original)||void 0===n?void 0:n.messageId)}))[0];if(!i){var o=this.contentWindow.document.title,a=("The extension '".concat(o,"' is attempting to communicate with Standard Notes, ")+"but an error is preventing it from doing so. Please restart this extension and try again.").replace(" "," ");return void _.info(a)}null==i||null===(r=i.callback)||void 0===r||r.call(i,e.data)}}},{key:"onReady",value:function(e){this.component.environment=e.environment,this.component.platform=e.platform,this.component.uuid=e.uuid,this.initialPermissions&&this.initialPermissions.length>0&&this.requestPermissions(this.initialPermissions);var n,r=a(this.messageQueue);try{for(r.s();!(n=r.n()).done;){var i=n.value;this.postMessage(i.action,i.data,i.callback)}}catch(o){r.e(o)}finally{r.f()}this.messageQueue=[],_.info("Data passed to onReady:",e),this.activateThemes(e.activeThemeUrls||[]),this.postMessage(t.ThemesActivated,{}),this.onReadyCallback&&this.onReadyCallback()}},{key:"getSelfComponentUUID",value:function(){return this.component.uuid}},{key:"isRunningInDesktopApplication",value:function(){return this.component.environment===w(e.Desktop)}},{key:"isRunningInMobileApplication",value:function(){return this.component.environment===w(e.Mobile)}},{key:"getComponentDataValueForKey",value:function(t){if(this.component.data)return this.component.data[t]}},{key:"setComponentDataValueForKey",value:function(e,n){if(!this.component.data)throw new Error("The component has not been initialized.");if(!e||e&&0===e.length)throw new Error("The key for the data value should be a valid string.");this.component.data=C(C({},this.component.data),{},l({},e,n)),this.postMessage(t.SetComponentData,{componentData:this.component.data})}},{key:"clearComponentData",value:function(){this.component.data={},this.postMessage(t.SetComponentData,{componentData:this.component.data})}},{key:"postMessage",value:function(t,e,n){if(this.component.sessionKey){var r,i={action:t,data:e,messageId:this.generateUUID(),sessionKey:this.component.sessionKey,api:b.Component},o=JSON.parse(JSON.stringify(i));o.callback=n,this.sentMessages.push(o),r=this.isRunningInMobileApplication()?JSON.stringify(i):i,_.info("Posting message:",r),this.contentWindow.parent.postMessage(r,this.component.origin)}else this.messageQueue.push({action:t,data:e,api:b.Component,callback:n})}},{key:"requestPermissions",value:function(e,n){this.postMessage(t.RequestPermissions,{permissions:e},(function(){n&&n()}))}},{key:"activateThemes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(this.component.acceptsThemes){_.info("Incoming themes:",t);var e=this.component.activeThemes;if(!e||e.sort().toString()!=t.sort().toString()){var n,r=t,i=[],o=a(e);try{var s=function(){var e=n.value;t.includes(e)?r=r.filter((function(t){return t!==e})):i.push(e)};for(o.s();!(n=o.n()).done;)s()}catch(g){o.e(g)}finally{o.f()}_.info("Deactivating themes:",i),_.info("Activating themes:",r);for(var u=0,l=i;u0&&(e=t.items[0]),r.associateItem(e),n&&n(e)}))}},{key:"createItems",value:function(e,n){var r=this,i=e.map((function(t){return r.jsonObjectForItem(t)}));this.postMessage(t.CreateItems,{items:i},(function(t){n&&n(t.items)}))}},{key:"associateItem",value:function(e){this.postMessage(t.AssociateItem,{item:this.jsonObjectForItem(e)})}},{key:"deassociateItem",value:function(e){this.postMessage(t.DeassociateItem,{item:this.jsonObjectForItem(e)})}},{key:"deleteItem",value:function(t,e){this.deleteItems([t],e)}},{key:"deleteItems",value:function(e,n){var r=this,i={items:e.map((function(t){return r.jsonObjectForItem(t)}))};this.postMessage(t.DeleteItems,i,(function(t){n&&n(t)}))}},{key:"sendCustomEvent",value:function(t,e,n){this.postMessage(t,e,(function(t){n&&n(t)}))}},{key:"saveItem",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.saveItems([t],e,n)}},{key:"saveItemWithPresave",value:function(t,e,n){this.saveItemsWithPresave([t],e,n)}},{key:"saveItemsWithPresave",value:function(t,e,n){this.saveItems(t,n,!1,e)}},{key:"performSavingOfItems",value:function(e){var n=this,r=e.items,i=e.presave,o=e.callback,s=setTimeout((function(){n.concernTimeouts.forEach((function(t){return clearTimeout(t)})),alert("This editor is unable to communicate with Standard Notes. Your changes may not be saved. Please backup your changes, then restart the application and try again.")}),5e3);this.concernTimeouts.push(s),i&&i();var u,l=[],c=a(r);try{for(c.s();!(u=c.n()).done;){var h=u.value;l.push(this.jsonObjectForItem(h))}}catch(f){c.e(f)}finally{c.f()}this.postMessage(t.SaveItems,{items:l},(function(){n.concernTimeouts.forEach((function(t){return clearTimeout(t)})),null==o||o()}))}},{key:"saveItems",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0;if(this.pendingSaveItems||(this.pendingSaveItems=[]),this.coallesedSaving&&!r){this.pendingSaveTimeout&&clearTimeout(this.pendingSaveTimeout);var o=t.map((function(t){return t.uuid})),a=this.pendingSaveItems.filter((function(t){return!o.includes(t.uuid)}));this.pendingSaveItems=a.concat(t),this.pendingSaveParams={items:this.pendingSaveItems,presave:i,callback:e},this.pendingSaveTimeout=setTimeout((function(){n.performSavingOfItems(n.pendingSaveParams),n.pendingSaveItems=[],n.pendingSaveTimeout=void 0,n.pendingSaveParams=null}),this.coallesedSavingDelay)}else this.performSavingOfItems({items:t,presave:i,callback:e})}},{key:"setSize",value:function(e,n){this.postMessage(t.SetSize,{type:"container",width:e,height:n})}},{key:"keyDownEvent",value:function(e){this.postMessage(t.KeyDown,{keyboardModifier:e})}},{key:"keyUpEvent",value:function(e){this.postMessage(t.KeyUp,{keyboardModifier:e})}},{key:"mouseClickEvent",value:function(){this.postMessage(t.Click,{})}},{key:"jsonObjectForItem",value:function(t){var e=Object.assign({},t);return e.children=null,e.parent=null,e}},{key:"getItemAppDataValue",value:function(t,e){var n,r;return null==t||null===(n=t.content)||void 0===n||null===(r=n.appData)||void 0===r?void 0:r["org.standardnotes.sn"][e]}}]),r}();return c.default}()},695:function(t){"use strict";t.exports=r}},c={};function h(t){var e=c[t];if(void 0!==e)return e.exports;var r=c[t]={exports:{}};return n[t](r,r.exports,h),r.exports}h.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return h.d(e,{a:e}),e},e=Object.getPrototypeOf?function(t){return Object.getPrototypeOf(t)}:function(t){return t.__proto__},h.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var i=Object.create(null);h.r(i);var o={};t=t||[null,e({}),e([]),e(e)];for(var a=2&r&&n;"object"==typeof a&&!~t.indexOf(a);a=e(a))Object.getOwnPropertyNames(a).forEach((function(t){return o[t]=function(){return n[t]}}));return o.default=function(){return n},h.d(i,o),i},h.d=function(t,e){for(var n in e)h.o(e,n)&&!h.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},h.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},h.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var f={};return function(){"use strict";h.d(f,{default:function(){return y}});var t=h(156),e=h.n(t),n=function(){var t=o(i.mark((function t(e){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t){return setTimeout(t,1e3*e)}));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var l=function(){function t(e){s(this,t),this.options=e,r(this,"uuidToFileTempUrlAndTypeMapping",{}),r(this,"currentlyLoadingIds",[]),r(this,"statusElementMapping",{}),r(this,"fileTypeToElementType",{"image/png":"img","image/jpg":"img","image/jpeg":"img","image/gif":"img","image/tiff":"img","image/bmp":"img","video/mp4":"video","audio/mpeg":"audio","audio/mp3":"audio"})}return u(t,[{key:"fileTypeForElementType",value:function(t){return this.fileTypeToElementType[t.toLowerCase()]}},{key:"loadFileSafeElements",value:function(){var t,e=this.options.getElementsBySelector("*[fsplaceholder]"),n=a(e);try{for(n.s();!(t=n.n()).done;){var r=t.value;this.loadFileSafeElement(r)}}catch(i){n.e(i)}finally{n.f()}}},{key:"loadFileSafeElement",value:function(){var t=o(i.mark((function t(e){var r,o,a,s,u,l,c,h,f,d,p,g,m=this;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=this.options.fileSafeInstance,a=e.getAttribute("fsid"),s=null!==(r=e.getAttribute("fsName"))&&void 0!==r?r:"",u=s&&"undefined"!=s?s:"file",a){t.next=3;break}return t.abrupt("return",!1);case 3:if(!(l=this.uuidToFileTempUrlAndTypeMapping[a])){t.next=6;break}return t.abrupt("return",(this.insertMediaElement({fsid:a,fsElement:e,url:l.url,fileType:l.fileType,fsName:l.fsName}),!1));case 6:if(!this.currentlyLoadingIds.includes(a)){t.next=8;break}return t.abrupt("return",!1);case 8:if(c=o.findFileDescriptor(a)){t.next=11;break}return t.abrupt("return",(this.setStatus({fsElement:e,fsid:a,status:"Unable to find ".concat(u," ").concat(a,"."),removable:!0}),!1));case 11:if(h='[fsid="'.concat(c.uuid,'"][fscollapsable]'),!(document.querySelectorAll("img".concat(h,", figure").concat(h,", video").concat(h,", audio").concat(h)).length>0)){t.next=14;break}return t.abrupt("return",!1);case 14:return this.currentlyLoadingIds.push(a),this.setStatus({fsElement:e,fsid:a,status:"Downloading ".concat(u,"...")}),t.next=18,n(.05);case 18:return t.next=20,o.downloadFileFromDescriptor(c).catch((function(){m.setStatus({fsElement:e,fsid:a,status:"Unable to download ".concat(u," ").concat(a,".")})}));case 20:if(f=t.sent){t.next=23;break}return t.abrupt("return",!1);case 23:return this.setStatus({fsElement:e,fsid:a,status:"Decrypting ".concat(u,"...")}),t.next=26,n(.05);case 26:return t.next=28,o.decryptFile({fileDescriptor:c,fileItem:f}).catch((function(){m.setStatus({fsElement:e,fsid:a,status:"Unable to decrypt ".concat(u," ").concat(a,".")})}));case 28:if(d=t.sent){t.next=31;break}return t.abrupt("return",!1);case 31:return this.setStatus({fsElement:e,fsid:a}),t.next=34,n(.05);case 34:return p=c.content.fileType,g=o.createTemporaryFileUrl({base64Data:d.decryptedData,dataType:p}),t.abrupt("return",(this.insertMediaElement({fsid:a,fileType:p,fsName:s,fsElement:e,url:g}),m.currentlyLoadingIds.splice(m.currentlyLoadingIds.indexOf(a),1),this.uuidToFileTempUrlAndTypeMapping[a]={fileType:p,url:g,fsName:s},!0));case 36:case"end":return t.stop()}}),t,this)})));function e(e){return t.apply(this,arguments)}return e}()},{key:"insertMediaElement",value:function(t){var e,n=t.url,r=t.fsid,i=t.fsName,o=t.fileType,a=t.fsElement;switch(this.fileTypeForElementType(o)){case"img":e=this.createImageElement({url:n,fsid:r,fsName:i,fsElement:a});break;case"video":e=this.createVideoElement({url:n,fsid:r,fileType:o,fsName:i,fsElement:a});break;case"audio":e=this.createAudioElement({url:n,fsid:r,fsName:i});break;default:e=this.createDownloadElement({url:n,fsid:r,fsName:i})}this.insertElementNearElement(e,a),a.remove()}},{key:"wrapElementInTag",value:function(t){var e=t.element,n=t.tagName,r=t.fsid,i=t.fsName,o=document.createElement(n);return o.setAttribute("fsid",r),o.setAttribute("fsName",i),o.setAttribute("fscollapsable","true"),o.setAttribute("contenteditable","true"),o.append(e),o}},{key:"createImageElement",value:function(t){var e=t.url,n=t.fsid,r=t.fsName,i=t.fsElement,o=document.createElement("img");o.setAttribute("src",e),o.setAttribute("srcset","".concat(e," 2x")),o.setAttribute("fsid",n),o.setAttribute("fsName",r),o.setAttribute("fscollapsable","true");var a=i.getAttribute("width");a&&o.setAttribute("width",a);var s=i.getAttribute("height");return s&&o.setAttribute("height",s),o}},{key:"createVideoElement",value:function(t){var e=t.url,n=t.fsid,r=t.fileType,i=t.fsName,o=t.fsElement,a=document.createElement("video");a.setAttribute("controls","true"),a.setAttribute("fsid",n),a.setAttribute("fsName",i),a.setAttribute("fscollapsable","true");var s=o.getAttribute("width");s&&a.setAttribute("width",s);var u=o.getAttribute("height");u&&a.setAttribute("height",u);var l=document.createElement("source");return l.setAttribute("src",e),l.setAttribute("type",r),a.append(l),this.wrapElementInTag({fsid:n,fsName:i,element:a,tagName:"p"})}},{key:"createDownloadElement",value:function(t){var e=t.url,n=t.fsid,r=t.fsName,i=document.createElement("a");return i.setAttribute("fsid",n),i.setAttribute("fsName",r),i.setAttribute("ghost","true"),i.setAttribute("fscollapsable","true"),i.setAttribute("href",e),i.textContent="".concat(r),i}},{key:"createAudioElement",value:function(t){var e=t.url,n=t.fsid,r=t.fsName,i=document.createElement("audio");return i.setAttribute("src",e),i.setAttribute("controls","true"),i.setAttribute("fsid",n),i.setAttribute("fsName",r),i.setAttribute("fscollapsable","true"),this.wrapElementInTag({fsid:n,fsName:r,element:i,tagName:"p"})}},{key:"setStatus",value:function(t){var e=t.status,n=t.fsElement,r=t.fsid,i=t.removable,o=void 0!==i&&i;if(r){var a=this.statusElementMapping[r];a&&(a.remove(),delete this.statusElementMapping[r])}if(e){var s=document.createElement("label");return s.setAttribute("id",r),s.setAttribute("ghost","true"),s.setAttribute("contenteditable","false"),s.style.fontWeight="bold",s.textContent=e,o&&(s.style.userSelect="all"),s=this.insertElementNearElement(s,n),r&&(this.statusElementMapping[r]=s),s}}},{key:"insertStatusAtCursor",value:function(t){var e=Math.random().toString(36).substring(7);return this.setStatus({status:t,fsid:e,fsElement:null}),e}},{key:"removeCursorStatus",value:function(t){var e=this.options.getElementsBySelector("#".concat(t));e.length>0&&e[0].remove()}},{key:"insertElementNearElement",value:function(t,e){var n=this.options.preprocessElement(t),r="child";if(e&&"figure"==n.tagName.toLowerCase()){var i=e.closest("p");i&&(e=i,r="afterend")}return this.options.insertElement(n,e,r),n}}]),t}(),c=function(){function t(e){s(this,t),this.options=e}return u(t,[{key:"onKeyUp",value:function(t){var e=t.isEnter,n=t.isPaste,r=t.isSpace;(e||n||r)&&this.searchPatterns({searchPreviousLine:null!=e&&e})}},{key:"searchPatterns",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{searchPreviousLine:!1},n=e.searchPreviousLine?this.options.getPreviousLineText():this.options.getCurrentLineText(),r=a(this.options.patterns);try{for(r.s();!(t=r.n()).done;){var i=t.value,o=i.regex.exec(n);if(o){var s=o[0];if(s){var u=i.callback(s);this.replaceSelection(i.regex,u,e.searchPreviousLine)}}}}catch(l){r.e(l)}finally{r.f()}}},{key:"replaceSelection",value:function(t,e,n){var r,i,o;null!==(r=this.options)&&void 0!==r&&r.beforeExpand&&this.options.beforeExpand(),this.options.replaceText({regex:t,replacement:e,searchPreviousLine:n}),null!==(i=this.options)&&void 0!==i&&i.afterExpand&&(null===(o=this.options)||void 0===o||o.afterExpand())}}]),t}(),d=/(

)?\[FileSafe[^\]]*\](<\/p>)?/g,p=function(t){return t.replace(d,(function(t){return m(t)}))},g=function(t){return"[FileSafe:".concat(t.uuid,":").concat(t.content.fileName,"]")},m=function(t){var e=(t=(t=(t=t.replace("

","")).replace("

","")).replace("[","").replace("]","")).split(":"),n=e[1],r=e[2],i=e[3],o="";if(i){var a=i.split("x");o="width=".concat(a[0]," height=").concat(a[1])}return"

")};function v(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var y=function(){function t(e,n){s(this,t),this.delegate=e,this.options=n,v(this,"fileIdsPendingAssociation",[]),v(this,"componentRelay",void 0),v(this,"fileLoader",void 0),v(this,"textExpander",void 0),v(this,"fileSafeLoading",void 0),v(this,"fileSafeClass",void 0),v(this,"fileSafeInstance",void 0),v(this,"note",void 0),v(this,"ignoreNextTextChange",void 0),v(this,"needsFileSafeElementLoad",void 0),v(this,"previousText",void 0),this.connectToBridge(),this.options.supportsFileSafe&&(this.fileSafeLoading=this.importFileSafe())}return u(t,[{key:"connectToBridge",value:function(){var t=this,n=this.options,r=n.coallesedSaving,a=n.coallesedSavingDelay,s=n.mode,u=n.supportsFileSafe;this.componentRelay=new(e())({targetWindow:window,options:{coallesedSaving:r,coallesedSavingDelay:a},onReady:function(){var e=t.componentRelay.platform;e&&document.documentElement.classList.add(e)},onThemesChange:this.delegate.onThemesChange}),this.componentRelay.streamContextItem(function(){var e=o(i.mark((function e(n){var r,o,a,l,c,h,f,d,g,m;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=!0,t.note&&t.note.uuid==n.uuid&&(r=!1),o=t.note,u?(a=t.fileSafeClass.getSFItemClass(),t.note=new a(n),t.fileSafeInstance.setCurrentNote(t.note)):t.note=n,!n.isMetadataUpdate){e.next=6;break}return e.abrupt("return");case 6:if(l=n.content.text,"html"===s&&r&&(/<[a-z][\s\S]*>/i.test(l)||(t.ignoreNextTextChange=!0)),t.previousText=l,u&&(t.needsFileSafeElementLoad=!0,l=p(l)),e.t0=t.delegate.onNoteValueChange,!e.t0){e.next=14;break}return e.next=14,t.delegate.onNoteValueChange(n);case 14:if(t.delegate.setEditorRawText(l),!t.delegate.onNoteLockToggle){e.next=18;break}f=null!==(c=t.componentRelay.getItemAppDataValue(o,"locked"))&&void 0!==c&&c,d=null!==(h=t.componentRelay.getItemAppDataValue(t.note,"locked"))&&void 0!==h&&h,f!==d&&t.delegate.onNoteLockToggle(d);case 18:r&&(null===(g=(m=t.delegate).clearUndoHistory)||void 0===g||g.call(m));case 19:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}},{key:"importFileSafe",value:function(){var t=o(i.mark((function t(){var e=this;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.abrupt("return",Promise.resolve().then(h.t.bind(h,695,23)).then((function(t){return e.fileSafeClass=t.default,e.configureFileSafe(),e.fileSafeInstance})));case 4:t.prev=4,t.t0=t.catch(0),console.warn("[EditorKit] Could not import filesafe-js");case 7:case"end":return t.stop()}}),t,null,[[0,4]])})));function e(){return t.apply(this,arguments)}return e}()},{key:"configureFileSafe",value:function(){for(var t=this,e=0,n=["getCurrentLineText","getPreviousLineText","replaceText","getElementsBySelector","insertElement","preprocessElement","insertRawText"];e0){var n,r=!1,i=a(t.fileIdsPendingAssociation.slice());try{var o=function(){var i=n.value,o=e.find((function(t){return t.uuid==i}));if(!o)return"continue";r=!0,t.fileIdsPendingAssociation.splice(t.fileIdsPendingAssociation.indexOf(i),1);var a=g(o);t.delegate.insertRawText(a)};for(i.s();!(n=i.n()).done;)o()}catch(s){i.e(s)}finally{i.f()}r&&t.textExpander.searchPatterns()}e.length>0&&t.fileLoader.loadFileSafeElements()})),this.fileSafeInstance.addNewFileDescriptorHandler((function(e){t.fileIdsPendingAssociation.push(e.uuid)})),this.fileLoader=new l({fileSafeInstance:this.fileSafeInstance,getElementsBySelector:this.delegate.getElementsBySelector,insertElement:this.delegate.insertElement,preprocessElement:this.delegate.preprocessElement}),this.textExpander=new c({afterExpand:function(){return t.fileLoader.loadFileSafeElements()},getCurrentLineText:this.delegate.getCurrentLineText,getPreviousLineText:this.delegate.getPreviousLineText,replaceText:this.delegate.replaceText,patterns:[{regex:d,callback:function(t){return p(t)}}]})}},{key:"getFileSafe",value:function(){var t=o(i.mark((function t(){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",!this.fileSafeInstance&&this.fileSafeLoading?this.fileSafeLoading:this.importFileSafe());case 1:case"end":return t.stop()}}),t,this)})));function e(){return t.apply(this,arguments)}return e}()},{key:"onEditorKeyUp",value:function(t){var e=t.isSpace,n=t.isEnter;this.textExpander.onKeyUp({isSpace:e,isEnter:n})}},{key:"onEditorPaste",value:function(){this.textExpander.onKeyUp({isPaste:!0})}},{key:"onEditorValueChanged",value:function(t){var e=this,n=this.options,r=n.mode,i=n.supportsFileSafe;if(this.needsFileSafeElementLoad&&(this.needsFileSafeElementLoad=!1,this.fileLoader.loadFileSafeElements()),this.ignoreNextTextChange)this.ignoreNextTextChange=!1;else if((!i||(t=function(t){var e,n=(new DOMParser).parseFromString(t,"text/html"),r=n.querySelectorAll("*[fscollapsable]"),i=a(r);try{for(i.s();!(e=i.n()).done;){var o=e.value,s=o.getAttribute("fsid"),u=o.getAttribute("fsname"),l=o.getAttribute("width"),c=o.getAttribute("height"),h=["FileSafe",s,u];if(l&&c){var f="".concat(l,"x").concat(c);h.push(f)}var d="

[".concat(h.join(":"),"]

");o.insertAdjacentHTML("afterend",d),o.remove()}}catch(p){i.e(p)}finally{i.f()}return n.querySelectorAll("*[ghost]").forEach((function(t){return t.remove()})),n.body.innerHTML}(t),this.previousText!=t))&&(this.previousText=t,this.note)){var o=this.note;this.componentRelay.saveItemWithPresave(o,(function(){if(o.content.text=t,e.delegate.generateCustomPreview){var n,i=e.delegate.generateCustomPreview(t);o.content.preview_plain=null!==(n=i.plain)&&void 0!==n?n:" ",o.content.preview_html=i.html}else{if("html"===r){var a=t.replace(d,(function(t){return""}));a=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:90;return t.length<=e?t:t.substring(0,e)+"..."}(function(t){var e=document.implementation.createHTMLDocument().body;return e.innerHTML=t,e.textContent||e.innerText||""}(a)),o.content.preview_plain=a.length>0?a:" "}else o.content.preview_plain=t;o.content.preview_html=null}}))}}},{key:"canUploadFiles",value:function(){var t=this.fileSafeInstance.getAllCredentials(),e=this.fileSafeInstance.getAllIntegrations();return t.length>0&&e.length>0}},{key:"uploadJSFileObject",value:function(){var t=o(i.mark((function t(e){var n,r=this;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.fileLoader.insertStatusAtCursor("Processing file..."),t.abrupt("return",this.fileSafeInstance.encryptAndUploadJavaScriptFileObject(e).then((function(){r.fileLoader.removeCursorStatus(n)})));case 2:case"end":return t.stop()}}),t,this)})));function e(e){return t.apply(this,arguments)}return e}()},{key:"saveItemWithPresave",value:function(t,e){this.componentRelay.saveItemWithPresave(t,e)}},{key:"platform",get:function(){return this.componentRelay.platform}},{key:"environment",get:function(){return this.componentRelay.environment}},{key:"canUseFileSafe",value:function(){return this.fileSafeInstance.hasLegacyAccess()}}]),t}()}(),f.default}())},132:function(t){"use strict";var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(t){return"function"===typeof Array.isArray?Array.isArray(t):"[object Array]"===n.call(t)},a=function(t){if(!t||"[object Object]"!==n.call(t))return!1;var r,i=e.call(t,"constructor"),o=t.constructor&&t.constructor.prototype&&e.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!i&&!o)return!1;for(r in t);return"undefined"===typeof r||e.call(t,r)},s=function(t,e){r&&"__proto__"===e.name?r(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},u=function(t,n){if("__proto__"===n){if(!e.call(t,n))return;if(i)return i(t,n).value}return t[n]};t.exports=function t(){var e,n,r,i,l,c,h=arguments[0],f=1,d=arguments.length,p=!1;for("boolean"===typeof h&&(p=h,h=arguments[1]||{},f=2),(null==h||"object"!==typeof h&&"function"!==typeof h)&&(h={});f>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else e.push.apply(e,n);return this.sigBytes+=t,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new a.init(n,e/2)}},l=s.Latin1={stringify:function(t){var e=t.words;t=t.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new a.init(n,e)}},c=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(l.stringify(t)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(t){return l.parse(unescape(encodeURIComponent(t)))}},h=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=c.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,s=i/(4*o);if(e=(s=e?t.ceil(s):t.max((0|s)-this._minBufferSize,0))*o,i=t.min(4*e,i),e){for(var u=0;u>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;4>a&&i+.75*a>>6*(3-a)&63));if(e=r.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var e=t.length,r=this._map;(i=r.charAt(64))&&-1!=(i=t.indexOf(i))&&(e=i);for(var i=[],o=0,a=0;a>>6-a%4*2;i[o>>>2]|=(s|u)<<24-o%4*8,o++}return n.create(i,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(t){function e(t,e,n,r,i,o,a){return((t=t+(e&n|~e&r)+i+a)<>>32-o)+e}function n(t,e,n,r,i,o,a){return((t=t+(e&r|n&~r)+i+a)<>>32-o)+e}function r(t,e,n,r,i,o,a){return((t=t+(e^n^r)+i+a)<>>32-o)+e}function i(t,e,n,r,i,o,a){return((t=t+(n^(e|~r))+i+a)<>>32-o)+e}for(var o=l,a=(u=o.lib).WordArray,s=u.Hasher,u=o.algo,c=[],h=0;64>h;h++)c[h]=4294967296*t.abs(t.sin(h+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,o){for(var a=0;16>a;a++){var s=t[u=o+a];t[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=t[o+0],l=(s=t[o+1],t[o+2]),h=t[o+3],f=t[o+4],d=t[o+5],p=t[o+6],g=t[o+7],m=t[o+8],v=t[o+9],y=t[o+10],b=t[o+11],k=t[o+12],x=t[o+13],w=t[o+14],O=t[o+15],S=e(S=a[0],C=a[1],T=a[2],_=a[3],u,7,c[0]),_=e(_,S,C,T,s,12,c[1]),T=e(T,_,S,C,l,17,c[2]),C=e(C,T,_,S,h,22,c[3]);S=e(S,C,T,_,f,7,c[4]),_=e(_,S,C,T,d,12,c[5]),T=e(T,_,S,C,p,17,c[6]),C=e(C,T,_,S,g,22,c[7]),S=e(S,C,T,_,m,7,c[8]),_=e(_,S,C,T,v,12,c[9]),T=e(T,_,S,C,y,17,c[10]),C=e(C,T,_,S,b,22,c[11]),S=e(S,C,T,_,k,7,c[12]),_=e(_,S,C,T,x,12,c[13]),T=e(T,_,S,C,w,17,c[14]),S=n(S,C=e(C,T,_,S,O,22,c[15]),T,_,s,5,c[16]),_=n(_,S,C,T,p,9,c[17]),T=n(T,_,S,C,b,14,c[18]),C=n(C,T,_,S,u,20,c[19]),S=n(S,C,T,_,d,5,c[20]),_=n(_,S,C,T,y,9,c[21]),T=n(T,_,S,C,O,14,c[22]),C=n(C,T,_,S,f,20,c[23]),S=n(S,C,T,_,v,5,c[24]),_=n(_,S,C,T,w,9,c[25]),T=n(T,_,S,C,h,14,c[26]),C=n(C,T,_,S,m,20,c[27]),S=n(S,C,T,_,x,5,c[28]),_=n(_,S,C,T,l,9,c[29]),T=n(T,_,S,C,g,14,c[30]),S=r(S,C=n(C,T,_,S,k,20,c[31]),T,_,d,4,c[32]),_=r(_,S,C,T,m,11,c[33]),T=r(T,_,S,C,b,16,c[34]),C=r(C,T,_,S,w,23,c[35]),S=r(S,C,T,_,s,4,c[36]),_=r(_,S,C,T,f,11,c[37]),T=r(T,_,S,C,g,16,c[38]),C=r(C,T,_,S,y,23,c[39]),S=r(S,C,T,_,x,4,c[40]),_=r(_,S,C,T,u,11,c[41]),T=r(T,_,S,C,h,16,c[42]),C=r(C,T,_,S,p,23,c[43]),S=r(S,C,T,_,v,4,c[44]),_=r(_,S,C,T,k,11,c[45]),T=r(T,_,S,C,O,16,c[46]),S=i(S,C=r(C,T,_,S,l,23,c[47]),T,_,u,6,c[48]),_=i(_,S,C,T,g,10,c[49]),T=i(T,_,S,C,w,15,c[50]),C=i(C,T,_,S,d,21,c[51]),S=i(S,C,T,_,k,6,c[52]),_=i(_,S,C,T,h,10,c[53]),T=i(T,_,S,C,y,15,c[54]),C=i(C,T,_,S,s,21,c[55]),S=i(S,C,T,_,m,6,c[56]),_=i(_,S,C,T,O,10,c[57]),T=i(T,_,S,C,p,15,c[58]),C=i(C,T,_,S,x,21,c[59]),S=i(S,C,T,_,f,6,c[60]),_=i(_,S,C,T,b,10,c[61]),T=i(T,_,S,C,l,15,c[62]),C=i(C,T,_,S,v,21,c[63]),a[0]=a[0]+S|0,a[1]=a[1]+C|0,a[2]=a[2]+T|0,a[3]=a[3]+_|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;n[i>>>5]|=128<<24-i%32;var o=t.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(n.length+1),this._process(),n=(e=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return e},clone:function(){var t=s.clone.call(this);return t._hash=this._hash.clone(),t}}),o.MD5=s._createHelper(u),o.HmacMD5=s._createHmacHelper(u)}(Math),function(){var t,e=l,n=(t=e.lib).Base,r=t.WordArray,i=(t=e.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var n=(s=this.cfg).hasher.create(),i=r.create(),o=i.words,a=s.keySize,s=s.iterations;o.length>>2]}},e.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:h}),reset:function(){s.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=e.createEncryptor;else n=e.createDecryptor,this._minBufferSize=1;this._mode=n.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var f=e.CipherParams=n.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),d=(u=(p.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?r.create([1398893684,1701076831]).concat(t).concat(e):e).toString(o)},parse:function(t){var e=(t=o.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var n=r.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return f.create({ciphertext:t,salt:n})}},e.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(t,e,n,r){r=this.cfg.extend(r);var i=t.createEncryptor(n,r);return e=i.finalize(e),i=i.cfg,f.create({ciphertext:e,key:n,iv:i.iv,algorithm:t,mode:i.mode,padding:i.padding,blockSize:t.blockSize,formatter:r.format})},decrypt:function(t,e,n,r){return r=this.cfg.extend(r),e=this._parse(e,r.format),t.createDecryptor(n,r).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),p=(p.kdf={}).OpenSSL={execute:function(t,e,n,i){return i||(i=r.random(8)),t=a.create({keySize:e+n}).compute(t,i),n=r.create(t.words.slice(e),4*n),t.sigBytes=4*e,f.create({key:t,iv:n,salt:i})}},g=e.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:p}),encrypt:function(t,e,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,t.keySize,t.ivSize),r.iv=n.iv,(t=d.encrypt.call(this,t,e,n.key,r)).mixIn(n),t},decrypt:function(t,e,n,r){return r=this.cfg.extend(r),e=this._parse(e,r.format),n=r.kdf.execute(n,t.keySize,t.ivSize,e.salt),r.iv=n.iv,d.decrypt.call(this,t,e,n.key,r)}})}(),function(){for(var t=l,e=t.lib.BlockCipher,n=t.algo,r=[],i=[],o=[],a=[],s=[],u=[],c=[],h=[],f=[],d=[],p=[],g=0;256>g;g++)p[g]=128>g?g<<1:g<<1^283;var m=0,v=0;for(g=0;256>g;g++){var y=(y=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&y^99;r[m]=y,i[y]=m;var b=p[m],k=p[b],x=p[k],w=257*p[y]^16843008*y;o[m]=w<<24|w>>>8,a[m]=w<<16|w>>>16,s[m]=w<<8|w>>>24,u[m]=w,w=16843009*x^65537*k^257*b^16843008*m,c[y]=w<<24|w>>>8,h[y]=w<<16|w>>>16,f[y]=w<<8|w>>>24,d[y]=w,m?(m=b^p[p[p[x^b]]],v^=p[p[v]]):m=v=1}var O=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=e.extend({_doReset:function(){for(var t=(n=this._key).words,e=n.sigBytes/4,n=4*((this._nRounds=e+6)+1),i=this._keySchedule=[],o=0;o>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=O[o/e|0]<<24),i[o]=i[o-e]^a}for(t=this._invKeySchedule=[],e=0;ee||4>=o?a:c[r[a>>>24]]^h[r[a>>>16&255]]^f[r[a>>>8&255]]^d[r[255&a]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,o,a,s,u,r)},decryptBlock:function(t,e){var n=t[e+1];t[e+1]=t[e+3],t[e+3]=n,this._doCryptBlock(t,e,this._invKeySchedule,c,h,f,d,i),n=t[e+1],t[e+1]=t[e+3],t[e+3]=n},_doCryptBlock:function(t,e,n,r,i,o,a,s){for(var u=this._nRounds,l=t[e]^n[0],c=t[e+1]^n[1],h=t[e+2]^n[2],f=t[e+3]^n[3],d=4,p=1;p>>24]^i[c>>>16&255]^o[h>>>8&255]^a[255&f]^n[d++],m=r[c>>>24]^i[h>>>16&255]^o[f>>>8&255]^a[255&l]^n[d++],v=r[h>>>24]^i[f>>>16&255]^o[l>>>8&255]^a[255&c]^n[d++];f=r[f>>>24]^i[l>>>16&255]^o[c>>>8&255]^a[255&h]^n[d++],l=g,c=m,h=v}g=(s[l>>>24]<<24|s[c>>>16&255]<<16|s[h>>>8&255]<<8|s[255&f])^n[d++],m=(s[c>>>24]<<24|s[h>>>16&255]<<16|s[f>>>8&255]<<8|s[255&l])^n[d++],v=(s[h>>>24]<<24|s[f>>>16&255]<<16|s[l>>>8&255]<<8|s[255&c])^n[d++],f=(s[f>>>24]<<24|s[l>>>16&255]<<16|s[c>>>8&255]<<8|s[255&h])^n[d++],t[e]=g,t[e+1]=m,t[e+2]=v,t[e+3]=f},keySize:8}),t.AES=e._createHelper(n)}(),l=l||function(t,e){var n={},r=n.lib={},i=function(){},o=r.Base={extend:function(t){i.prototype=this;var e=new i;return t&&e.mixIn(t),e.hasOwnProperty("init")||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},a=r.WordArray=o.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||u).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes;if(t=t.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 e.push.apply(e,n);return this.sigBytes+=t,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new a.init(n,e/2)}},l=s.Latin1={stringify:function(t){var e=t.words;t=t.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new a.init(n,e)}},c=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(l.stringify(t)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(t){return l.parse(unescape(encodeURIComponent(t)))}},h=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=c.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,s=i/(4*o);if(e=(s=e?t.ceil(s):t.max((0|s)-this._minBufferSize,0))*o,i=t.min(4*e,i),e){for(var u=0;uc;){var h;t:{h=u;for(var f=t.sqrt(h),d=2;d<=f;d++)if(!(h%d)){h=!1;break t}h=!0}h&&(8>c&&(o[c]=s(t.pow(u,.5))),a[c]=s(t.pow(u,1/3)),c++),u++}var p=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],s=n[3],u=n[4],l=n[5],c=n[6],h=n[7],f=0;64>f;f++){if(16>f)p[f]=0|t[e+f];else{var d=p[f-15],g=p[f-2];p[f]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+p[f-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+p[f-16]}d=h+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&l^~u&c)+a[f]+p[f],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),h=c,c=l,l=u,u=s+d|0,s=o,o=i,i=r,r=d+g|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+l|0,n[6]=n[6]+c|0,n[7]=n[7]+h|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=t.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA256=r._createHelper(i),e.HmacSHA256=r._createHmacHelper(i)}(Math),a=(o=l).enc.Utf8,o.algo.HMAC=o.lib.Base.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=a.parse(e));var n=t.blockSize,r=4*n;e.sigBytes>r&&(e=t.finalize(e)),e.clamp();for(var i=this._oKey=e.clone(),o=this._iKey=e.clone(),s=i.words,u=o.words,l=0;l>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else e.push.apply(e,n);return this.sigBytes+=t,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new a.init(n,e/2)}},l=s.Latin1={stringify:function(t){var e=t.words;t=t.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new a.init(n,e)}},c=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(l.stringify(t)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(t){return l.parse(unescape(encodeURIComponent(t)))}},h=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=c.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,s=i/(4*o);if(e=(s=e?t.ceil(s):t.max((0|s)-this._minBufferSize,0))*o,i=t.min(4*e,i),e){for(var u=0;uu;u++)s[u]=t();o=o.SHA512=n.extend({_doReset:function(){this._hash=new i.init([new r.init(1779033703,4089235720),new r.init(3144134277,2227873595),new r.init(1013904242,4271175723),new r.init(2773480762,1595750129),new r.init(1359893119,2917565137),new r.init(2600822924,725511199),new r.init(528734635,4215389547),new r.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var n=(h=this._hash.words)[0],r=h[1],i=h[2],o=h[3],u=h[4],l=h[5],c=h[6],h=h[7],f=n.high,d=n.low,p=r.high,g=r.low,m=i.high,v=i.low,y=o.high,b=o.low,k=u.high,x=u.low,w=l.high,O=l.low,S=c.high,_=c.low,T=h.high,C=h.low,E=f,A=d,D=p,M=g,N=m,R=v,P=y,I=b,L=k,F=x,B=w,Q=O,z=S,$=_,j=T,W=C,U=0;80>U;U++){var q=s[U];if(16>U)var V=q.high=0|t[e+2*U],H=q.low=0|t[e+2*U+1];else{V=((H=(V=s[U-15]).high)>>>1|(Y=V.low)<<31)^(H>>>8|Y<<24)^H>>>7;var Y=(Y>>>1|H<<31)^(Y>>>8|H<<24)^(Y>>>7|H<<25),X=((H=(X=s[U-2]).high)>>>19|(G=X.low)<<13)^(H<<3|G>>>29)^H>>>6,G=(G>>>19|H<<13)^(G<<3|H>>>29)^(G>>>6|H<<26),Z=(H=s[U-7]).high,K=(J=s[U-16]).high,J=J.low;V=(V=(V=V+Z+((H=Y+H.low)>>>0>>0?1:0))+X+((H+=G)>>>0>>0?1:0))+K+((H+=J)>>>0>>0?1:0),q.high=V,q.low=H}Z=L&B^~L&z,J=F&Q^~F&$,q=E&D^E&N^D&N;var tt=A&M^A&R^M&R,et=(Y=(E>>>28|A<<4)^(E<<30|A>>>2)^(E<<25|A>>>7),X=(A>>>28|E<<4)^(A<<30|E>>>2)^(A<<25|E>>>7),(G=a[U]).high),nt=G.low;K=j+((L>>>14|F<<18)^(L>>>18|F<<14)^(L<<23|F>>>9))+((G=W+((F>>>14|L<<18)^(F>>>18|L<<14)^(F<<23|L>>>9)))>>>0>>0?1:0),j=z,W=$,z=B,$=Q,B=L,Q=F,L=P+(K=(K=(K=K+Z+((G+=J)>>>0>>0?1:0))+et+((G+=nt)>>>0>>0?1:0))+V+((G+=H)>>>0>>0?1:0))+((F=I+G|0)>>>0>>0?1:0)|0,P=N,I=R,N=D,R=M,D=E,M=A,E=K+(q=Y+q+((H=X+tt)>>>0>>0?1:0))+((A=G+H|0)>>>0>>0?1:0)|0}d=n.low=d+A,n.high=f+E+(d>>>0>>0?1:0),g=r.low=g+M,r.high=p+D+(g>>>0>>0?1:0),v=i.low=v+R,i.high=m+N+(v>>>0>>0?1:0),b=o.low=b+I,o.high=y+P+(b>>>0>>0?1:0),x=u.low=x+F,u.high=k+L+(x>>>0>>0?1:0),O=l.low=O+Q,l.high=w+B+(O>>>0>>0?1:0),_=c.low=_+$,c.high=S+z+(_>>>0<$>>>0?1:0),C=h.low=C+W,h.high=T+j+(C>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[30+(r+128>>>10<<5)]=Math.floor(n/4294967296),e[31+(r+128>>>10<<5)]=n,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=n._createHelper(o),e.HmacSHA512=n._createHmacHelper(o)}(),u=(s=l).enc.Utf8,s.algo.HMAC=s.lib.Base.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=u.parse(e));var n=t.blockSize,r=4*n;e.sigBytes>r&&(e=t.finalize(e)),e.clamp();for(var i=this._oKey=e.clone(),o=this._iKey=e.clone(),a=i.words,s=o.words,l=0;l>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else e.push.apply(e,n);return this.sigBytes+=t,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new a.init(n,e/2)}},l=s.Latin1={stringify:function(t){var e=t.words;t=t.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new a.init(n,e)}},c=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(l.stringify(t)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(t){return l.parse(unescape(encodeURIComponent(t)))}},h=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=c.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,s=i/(4*o);if(e=(s=e?t.ceil(s):t.max((0|s)-this._minBufferSize,0))*o,i=t.min(4*e,i),e){for(var u=0;ul;l++){if(16>l)r[l]=0|t[e+l];else{var c=r[l-3]^r[l-8]^r[l-14]^r[l-16];r[l]=c<<1|c>>>31}c=(i<<5|i>>>27)+u+r[l],c=20>l?c+(1518500249+(o&a|~o&s)):40>l?c+(1859775393+(o^a^s)):60>l?c+((o&a|o&s|a&s)-1894007588):c+((o^a^s)-899497514),u=s,s=a,a=o<<30|o>>>2,o=i,i=c}n[0]=n[0]+i|0,n[1]=n[1]+o|0,n[2]=n[2]+a|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),e[15+(r+64>>>9<<4)]=n,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=n._createHelper(i),t.HmacSHA1=n._createHmacHelper(i)}(),function(){var t=l,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,n){t=this._hasher=new t.init,"string"==typeof n&&(n=e.parse(n));var r=t.blockSize,i=4*r;n.sigBytes>i&&(n=t.finalize(n)),n.clamp();for(var o=this._oKey=n.clone(),a=this._iKey=n.clone(),s=o.words,u=a.words,l=0;l>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else e.push.apply(e,n);return this.sigBytes+=t,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new a.init(n,e/2)}},l=s.Latin1={stringify:function(t){var e=t.words;t=t.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new a.init(n,e)}},c=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(l.stringify(t)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(t){return l.parse(unescape(encodeURIComponent(t)))}},h=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=c.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,s=i/(4*o);if(e=(s=e?t.ceil(s):t.max((0|s)-this._minBufferSize,0))*o,i=t.min(4*e,i),e){for(var u=0;ul;l++){if(16>l)r[l]=0|t[e+l];else{var c=r[l-3]^r[l-8]^r[l-14]^r[l-16];r[l]=c<<1|c>>>31}c=(i<<5|i>>>27)+u+r[l],c=20>l?c+(1518500249+(o&a|~o&s)):40>l?c+(1859775393+(o^a^s)):60>l?c+((o&a|o&s|a&s)-1894007588):c+((o^a^s)-899497514),u=s,s=a,a=o<<30|o>>>2,o=i,i=c}n[0]=n[0]+i|0,n[1]=n[1]+o|0,n[2]=n[2]+a|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),e[15+(r+64>>>9<<4)]=n,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=n._createHelper(i),t.HmacSHA1=n._createHmacHelper(i)}(),Object.defineProperty(i,"__esModule",{value:!0}),i.StandardFile=i.SFItemTransformer=i.SFCryptoWeb=i.SFCryptoJS=i.SFAbstractCrypto=i.SFItemHistoryEntry=i.SFItemHistory=i.SFHistorySession=i.SFPrivileges=i.SFPredicate=i.SFItemParams=i.SFItem=i.SFSyncManager=i.SFStorageManager=i.SFSingletonManager=i.SFSessionHistoryManager=i.SFPrivilegesManager=i.SFModelManager=i.SFMigrationManager=i.SFHttpManager=i.SFAuthManager=i.SFAlertManager=void 0;var x=function(){function t(){y(this,t)}var e,n;return k(t,[{key:"alert",value:(n=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){window.alert(e.text),t()})));case 1:case"end":return t.stop()}}),t)}))),function(t){return n.apply(this,arguments)})},{key:"confirm",value:(e=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){window.confirm(e.text)?t():n()})));case 1:case"end":return t.stop()}}),t)}))),function(t){return e.apply(this,arguments)})}]),t}();i.SFAlertManager=x;var w=function(){function t(e,n,r,i){y(this,t),t.DidSignOutEvent="DidSignOutEvent",t.WillSignInEvent="WillSignInEvent",t.DidSignInEvent="DidSignInEvent",this.httpManager=n,this.storageManager=e,this.alertManager=r||new x,this.$timeout=i||setTimeout.bind(window),this.eventHandlers=[]}var e,n,i,o,a,s,u,l,c,h;return k(t,[{key:"addEventHandler",value:function(t){return this.eventHandlers.push(t),t}},{key:"removeEventHandler",value:function(t){_.pull(this.eventHandlers,t)}},{key:"notifyEvent",value:function(t,e){var n=!0,r=!1,i=void 0;try{for(var o,a=this.eventHandlers[Symbol.iterator]();!(n=(o=a.next()).done);n=!0)(0,o.value)(t,e||{})}catch(t){r=!0,i=t}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}}},{key:"saveKeys",value:(h=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._keys=e,t.next=3,this.storageManager.setItem("mk",e.mk);case 3:return t.next=5,this.storageManager.setItem("ak",e.ak);case 5:case"end":return t.stop()}}),t,this)}))),function(t){return h.apply(this,arguments)})},{key:"signout",value:(c=v(r.mark((function e(n){var i=this;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._keys=null,this._authParams=null,!n){e.next=6;break}return e.abrupt("return",this.storageManager.clearAllData().then((function(){i.notifyEvent(t.DidSignOutEvent)})));case 6:this.notifyEvent(t.DidSignOutEvent);case 7:case"end":return e.stop()}}),e,this)}))),function(t){return c.apply(this,arguments)})},{key:"keys",value:(l=v(r.mark((function t(){var e;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._keys){t.next=11;break}return t.next=3,this.storageManager.getItem("mk");case 3:if(e=t.sent){t.next=6;break}return t.abrupt("return",null);case 6:return t.t0=e,t.next=9,this.storageManager.getItem("ak");case 9:t.t1=t.sent,this._keys={mk:t.t0,ak:t.t1};case 11:return t.abrupt("return",this._keys);case 12:case"end":return t.stop()}}),t,this)}))),function(){return l.apply(this,arguments)})},{key:"getAuthParams",value:(u=v(r.mark((function t(){var e;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._authParams){t.next=5;break}return t.next=3,this.storageManager.getItem("auth_params");case 3:e=t.sent,this._authParams=JSON.parse(e);case 5:if(!this._authParams||this._authParams.version){t.next=9;break}return t.next=8,this.defaultProtocolVersion();case 8:this._authParams.version=t.sent;case 9:return t.abrupt("return",this._authParams);case 10:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"defaultProtocolVersion",value:(s=v(r.mark((function t(){var e;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.keys();case 2:if(!(e=t.sent)||!e.ak){t.next=7;break}return t.abrupt("return","002");case 7:return t.abrupt("return","001");case 8:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)})},{key:"protocolVersion",value:(a=v(r.mark((function t(){var e;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAuthParams();case 2:if(!(e=t.sent)||!e.version){t.next=5;break}return t.abrupt("return",e.version);case 5:return t.abrupt("return",this.defaultProtocolVersion());case 6:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"getAuthParamsForEmail",value:(o=v(r.mark((function t(e,n,i){var o,a=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(o=_.merge({email:n},i)).api=S.getApiVersion(),t.abrupt("return",new Promise((function(t,n){var r=e+"/auth/params";a.httpManager.getAbsolute(r,o,(function(e){t(e)}),(function(e){console.error("Error getting auth params",e),"object"!==g(e)&&(e={error:{message:"A server error occurred while trying to sign in. Please try again."}}),t(e)}))})));case 3:case"end":return t.stop()}}),t)}))),function(t,e,n){return o.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(t,e){this.unlock(),t(e)}},{key:"login",value:(i=v(r.mark((function e(n,i,o,a,s){var u=this;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(){var e=v(r.mark((function e(l,c){var h,f,d,p,m,y,b,k,x,w;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.keys();case 2:if(null==e.sent){e.next=6;break}return l({error:{message:"Cannot log in because already signed in."}}),e.abrupt("return");case 6:if(!u.isLocked()){e.next=9;break}return l({error:{message:"Login already in progress."}}),e.abrupt("return");case 9:return u.lock(),u.notifyEvent(t.WillSignInEvent),e.next=13,u.getAuthParamsForEmail(n,i,s);case 13:if((h=e.sent).identifier=i,!h.error){e.next=18;break}return u.unlockAndResolve(l,h),e.abrupt("return");case 18:if(h&&h.pw_cost){e.next=21;break}return u.unlockAndResolve(l,{error:{message:"Invalid email or password."}}),e.abrupt("return");case 21:if(SFJS.supportedVersions().includes(h.version)){e.next=25;break}return f=SFJS.isVersionNewerThanLibraryVersion(h.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.",u.unlockAndResolve(l,{error:{message:f}}),e.abrupt("return");case 25:if(!SFJS.isProtocolVersionOutdated(h.version)){e.next=32;break}return d="The encryption version for your account, ".concat(h.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."),p=!1,e.next=30,u.alertManager.confirm({title:"Update Needed",text:d,confirmButtonText:"Sign In"}).catch((function(){u.unlockAndResolve(l,{error:{}}),p=!0}));case 30:if(!p){e.next=32;break}return e.abrupt("return");case 32:if(SFJS.supportsPasswordDerivationCost(h.pw_cost)){e.next=36;break}return u.unlockAndResolve(l,{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(m=SFJS.costMinimumForVersion(h.version),!(h.pw_cost5&&void 0!==l[5]&&l[5],t.abrupt("return",new Promise(function(){var t=v(r.mark((function t(l,c){var h;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((h=new XMLHttpRequest).onreadystatechange=function(){if(4==h.readyState){var t=h.responseText;if(t)try{t=JSON.parse(t)}catch(t){}h.status>=200&&h.status<=299?u.$timeout((function(){o(t),l(t)})):(console.error("Request error:",t),u.$timeout((function(){a(t,h.status),c(t)})))}},"get"==e&&Object.keys(i).length>0&&(n=u.urlForUrlAndParams(n,i)),h.open(e,n,!0),h.setRequestHeader("Content-type","application/json"),!s){t.next=8;break}return t.next=8,u.setAuthHeadersForRequest(h);case 8:"post"==e||"patch"==e?h.send(JSON.stringify(i)):h.send();case 9:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()));case 2:case"end":return t.stop()}}),t)}))),function(t,n,r,i,o){return e.apply(this,arguments)})},{key:"urlForUrlAndParams",value:function(t,e){var n=Object.keys(e).map((function(t){return t+"="+encodeURIComponent(e[t])})).join("&");return t.includes("?")?t+"&"+n:t+"?"+n}}]),t}();i.SFHttpManager=S;var T=function(){function t(e,n,i,o){var a=this;y(this,t),this.modelManager=e,this.syncManager=n,this.storageManager=i,this.completionHandlers=[],this.loadMigrations();var s=!1,u=o.addEventHandler((function(t){t==w.DidSignInEvent&&(s=!0)}));this.receivedLocalDataEvent=n.initialDataLoaded(),this.syncManager.addEventHandler(function(){var t=v(r.mark((function t(e,n){var i,l,c,h,f,d,p,g,m;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(l="sync:completed"==e,!(i="local-data-loaded"==e)&&!l){t.next=40;break}if(i?a.receivedLocalDataEvent=!0:l&&(a.receivedSyncCompletedEvent=!0),!a.receivedLocalDataEvent||!a.receivedSyncCompletedEvent){t.next=40;break}if(!s){t.next=39;break}return s=!1,o.removeEventHandler(u),t.next=10,a.getCompletedMigrations();case 10:c=t.sent.slice(),h=!0,f=!1,d=void 0,t.prev=14,p=c[Symbol.iterator]();case 16:if(h=(g=p.next()).done){t.next=25;break}return m=g.value,t.next=20,a.migrationForEncodedName(m);case 20:t.sent.runOnlyOnce||_.pull(a._completed,m);case 22:h=!0,t.next=16;break;case 25:t.next=31;break;case 27:t.prev=27,t.t0=t.catch(14),f=!0,d=t.t0;case 31:t.prev=31,t.prev=32,h||null==p.return||p.return();case 34:if(t.prev=34,!f){t.next=37;break}throw d;case 37:return t.finish(34);case 38:return t.finish(31);case 39:a.runPendingMigrations();case 40:case"end":return t.stop()}}),t,null,[[14,27,31,39],[32,,34,38]])})));return function(e,n){return t.apply(this,arguments)}}())}var e,n,i,o,a,s,u,l;return k(t,[{key:"addCompletionHandler",value:function(t){this.completionHandlers.push(t)}},{key:"removeCompletionHandler",value:function(t){_.pull(this.completionHandlers,t)}},{key:"migrationForEncodedName",value:(l=v(r.mark((function t(e){var n;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.decode(e);case 2:return n=t.sent,t.abrupt("return",this.migrations.find((function(t){return t.name==n})));case 4:case"end":return t.stop()}}),t,this)}))),function(t){return l.apply(this,arguments)})},{key:"loadMigrations",value:function(){this.migrations=this.registeredMigrations()}},{key:"registeredMigrations",value:function(){}},{key:"runPendingMigrations",value:(u=v(r.mark((function t(){var e,n,i,o,a,s,u,l,c,h,f,d,p,g,m,v,y,b,k,x,w,O,S,_,T,C,E,A;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPendingMigrations();case 2:for(e=t.sent,n=!0,i=!1,o=void 0,t.prev=6,a=e[Symbol.iterator]();!(n=(s=a.next()).done);n=!0)(u=s.value).items=[];t.next=14;break;case 10:t.prev=10,t.t0=t.catch(6),i=!0,o=t.t0;case 14:t.prev=14,t.prev=15,n||null==a.return||a.return();case 17:if(t.prev=17,!i){t.next=20;break}throw o;case 20:return t.finish(17);case 21:return t.finish(14);case 22:l=!0,c=!1,h=void 0,t.prev=25,f=this.modelManager.allNondummyItems[Symbol.iterator]();case 27:if(l=(d=f.next()).done){t.next=51;break}for(p=d.value,g=!0,m=!1,v=void 0,t.prev=32,y=e[Symbol.iterator]();!(g=(b=y.next()).done);g=!0)u=b.value,p.content_type==u.content_type&&u.items.push(p);t.next=40;break;case 36:t.prev=36,t.t1=t.catch(32),m=!0,v=t.t1;case 40:t.prev=40,t.prev=41,g||null==y.return||y.return();case 43:if(t.prev=43,!m){t.next=46;break}throw v;case 46:return t.finish(43);case 47:return t.finish(40);case 48:l=!0,t.next=27;break;case 51:t.next=57;break;case 53:t.prev=53,t.t2=t.catch(25),c=!0,h=t.t2;case 57:t.prev=57,t.prev=58,l||null==f.return||f.return();case 60:if(t.prev=60,!c){t.next=63;break}throw h;case 63:return t.finish(60);case 64:return t.finish(57);case 65:k=!0,x=!1,w=void 0,t.prev=68,O=e[Symbol.iterator]();case 70:if(k=(S=O.next()).done){t.next=81;break}if(!((u=S.value).items&&u.items.length>0||u.customHandler)){t.next=77;break}return t.next=75,this.runMigration(u,u.items);case 75:t.next=78;break;case 77:this.markMigrationCompleted(u);case 78:k=!0,t.next=70;break;case 81:t.next=87;break;case 83:t.prev=83,t.t3=t.catch(68),x=!0,w=t.t3;case 87:t.prev=87,t.prev=88,k||null==O.return||O.return();case 90:if(t.prev=90,!x){t.next=93;break}throw w;case 93:return t.finish(90);case 94:return t.finish(87);case 95:for(_=!0,T=!1,C=void 0,t.prev=98,E=this.completionHandlers[Symbol.iterator]();!(_=(A=E.next()).done);_=!0)(0,A.value)();t.next=106;break;case 102:t.prev=102,t.t4=t.catch(98),T=!0,C=t.t4;case 106:t.prev=106,t.prev=107,_||null==E.return||E.return();case 109:if(t.prev=109,!T){t.next=112;break}throw C;case 112:return t.finish(109);case 113:return t.finish(106);case 114:case"end":return t.stop()}}),t,this,[[6,10,14,22],[15,,17,21],[25,53,57,65],[32,36,40,48],[41,,43,47],[58,,60,64],[68,83,87,95],[88,,90,94],[98,102,106,114],[107,,109,113]])}))),function(){return u.apply(this,arguments)})},{key:"encode",value:(s=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",window.btoa(e));case 1:case"end":return t.stop()}}),t)}))),function(t){return s.apply(this,arguments)})},{key:"decode",value:(a=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",window.atob(e));case 1:case"end":return t.stop()}}),t)}))),function(t){return a.apply(this,arguments)})},{key:"getCompletedMigrations",value:(o=v(r.mark((function t(){var e;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._completed){t.next=5;break}return t.next=3,this.storageManager.getItem("migrations");case 3:e=t.sent,this._completed=e?JSON.parse(e):[];case 5:return t.abrupt("return",this._completed);case 6:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"getPendingMigrations",value:(i=v(r.mark((function t(){var e,n,i,o,a,s,u,l;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getCompletedMigrations();case 2:e=t.sent,n=[],i=!0,o=!1,a=void 0,t.prev=7,s=this.migrations[Symbol.iterator]();case 9:if(i=(u=s.next()).done){t.next=22;break}return l=u.value,t.t0=e,t.next=14,this.encode(l.name);case 14:if(t.t1=t.sent,t.t2=t.t0.indexOf.call(t.t0,t.t1),t.t3=-1,t.t2!=t.t3){t.next=19;break}n.push(l);case 19:i=!0,t.next=9;break;case 22:t.next=28;break;case 24:t.prev=24,t.t4=t.catch(7),o=!0,a=t.t4;case 28:t.prev=28,t.prev=29,i||null==s.return||s.return();case 31:if(t.prev=31,!o){t.next=34;break}throw a;case 34:return t.finish(31);case 35:return t.finish(28);case 36:return t.abrupt("return",n);case 37:case"end":return t.stop()}}),t,this,[[7,24,28,36],[29,,31,35]])}))),function(){return i.apply(this,arguments)})},{key:"markMigrationCompleted",value:(n=v(r.mark((function t(e){var n;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getCompletedMigrations();case 2:return n=t.sent,t.t0=n,t.next=6,this.encode(e.name);case 6:t.t1=t.sent,t.t0.push.call(t.t0,t.t1),this.storageManager.setItem("migrations",JSON.stringify(n)),e.running=!1;case 10:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"runMigration",value:(e=v(r.mark((function t(e,n){var i=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.running){t.next=2;break}return t.abrupt("return");case 2:if(console.log("Running migration:",e.name),e.running=!0,!e.customHandler){t.next=8;break}return t.abrupt("return",e.customHandler().then((function(){i.markMigrationCompleted(e)})));case 8:return t.abrupt("return",e.handler(n).then((function(){i.markMigrationCompleted(e)})));case 9:case"end":return t.stop()}}),t)}))),function(t,n){return e.apply(this,arguments)})}]),t}();i.SFMigrationManager=T;var C=function(){function t(e){y(this,t),t.MappingSourceRemoteRetrieved="MappingSourceRemoteRetrieved",t.MappingSourceRemoteSaved="MappingSourceRemoteSaved",t.MappingSourceLocalSaved="MappingSourceLocalSaved",t.MappingSourceLocalRetrieved="MappingSourceLocalRetrieved",t.MappingSourceLocalDirtied="MappingSourceLocalDirtied",t.MappingSourceComponentRetrieved="MappingSourceComponentRetrieved",t.MappingSourceDesktopInstalled="MappingSourceDesktopInstalled",t.MappingSourceRemoteActionRetrieved="MappingSourceRemoteActionRetrieved",t.MappingSourceFileImport="MappingSourceFileImport",t.isMappingSourceRetrieved=function(e){return[t.MappingSourceRemoteRetrieved,t.MappingSourceComponentRetrieved,t.MappingSourceRemoteActionRetrieved].includes(e)},this.$timeout=e||setTimeout.bind(window),this.itemSyncObservers=[],this.items=[],this.itemsHash={},this.missedReferences={},this.uuidChangeObservers=[]}var e,n,i,o,a,s,u,l,c,h,f,d;return k(t,[{key:"handleSignout",value:function(){this.items.length=0,this.itemsHash={},this.missedReferences={}}},{key:"addModelUuidChangeObserver",value:function(t,e){this.uuidChangeObservers.push({id:t,callback:e})}},{key:"notifyObserversOfUuidChange",value:function(t,e){var n=!0,r=!1,i=void 0;try{for(var o,a=this.uuidChangeObservers[Symbol.iterator]();!(n=(o=a.next()).done);n=!0){var s=o.value;try{s.callback(t,e)}catch(t){console.error("Notify observers of uuid change exception:",t)}}}catch(t){r=!0,i=t}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}}},{key:"alternateUUIDForItem",value:(d=v(r.mark((function e(n){var i,o,a,s,u,l,c;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=this.createItem(n),e.next=3,SFJS.crypto.generateUUID();case 3:for(i.uuid=e.sent,i.informReferencesOfUUIDChange(n.uuid,i.uuid),this.informModelsOfUUIDChangeForItem(i,n.uuid,i.uuid),o=!0,a=!1,s=void 0,e.prev=9,u=n.referencingObjects[Symbol.iterator]();!(o=(l=u.next()).done);o=!0)(c=l.value).setIsNoLongerBeingReferencedBy(n),n.setIsNoLongerBeingReferencedBy(c),c.addItemAsRelationship(i);e.next=17;break;case 13:e.prev=13,e.t0=e.catch(9),a=!0,s=e.t0;case 17:e.prev=17,e.prev=18,o||null==u.return||u.return();case 20:if(e.prev=20,!a){e.next=23;break}throw s;case 23:return e.finish(20);case 24:return e.finish(17);case 25:return this.setItemsDirty(n.referencingObjects,!0),this.resolveReferencesForItem(i),this.loggingEnabled&&console.log(n.uuid,"--\x3e",i.uuid),n.deleted=!0,n.content.references=[],this.setItemDirty(n,!1,!1,t.MappingSourceLocalSaved),e.next=33,this.mapResponseItemsToLocalModels([n],t.MappingSourceLocalSaved);case 33:return this.addItem(i),this.setItemDirty(i,!0,!0,t.MappingSourceLocalSaved),this.notifyObserversOfUuidChange(n,i),e.abrupt("return",i);case 37:case"end":return e.stop()}}),e,this,[[9,13,17,25],[18,,20,24]])}))),function(t){return d.apply(this,arguments)})},{key:"informModelsOfUUIDChangeForItem",value:function(t,e,n){var r=!0,i=!1,o=void 0;try{for(var a,s=this.items[Symbol.iterator]();!(r=(a=s.next()).done);r=!0)a.value.potentialItemOfInterestHasChangedItsUUID(t,e,n)}catch(t){i=!0,o=t}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}}},{key:"didSyncModelsOffline",value:function(e){this.notifySyncObserversOfModels(e,t.MappingSourceLocalSaved)}},{key:"mapResponseItemsToLocalModels",value:(f=v(r.mark((function t(e,n,i){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.mapResponseItemsToLocalModelsWithOptions({items:e,source:n,sourceKey:i}));case 1:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return f.apply(this,arguments)})},{key:"mapResponseItemsToLocalModelsOmittingFields",value:(h=v(r.mark((function t(e,n,i,o){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.mapResponseItemsToLocalModelsWithOptions({items:e,omitFields:n,source:i,sourceKey:o}));case 1:case"end":return t.stop()}}),t,this)}))),function(t,e,n,r){return h.apply(this,arguments)})},{key:"mapResponseItemsToLocalModelsWithOptions",value:(c=v(r.mark((function t(e){var n,i,o,a,s,u,l,c,h,f,d,g,m,v,y,b,k,x,w,O,S,_,T,C,E,A,D,M,N,R,P,I,L,F,B,Q,z,$,j;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.items,i=e.omitFields,o=e.source,a=e.sourceKey,e.options,s=[],u=[],l=[],c=!0,h=!1,f=void 0,t.prev=5,d=n[Symbol.iterator]();case 7:if(c=(g=d.next()).done){t.next=58;break}if(m=g.value){t.next=11;break}return t.abrupt("continue",55);case 11:if(v=!m.content&&!m.errorDecrypting,m.content_type&&m.uuid&&!v||m.deleted){t.next=16;break}return console.error("Server response item is corrupt:",m),t.abrupt("continue",55);case 16:if(!Array.isArray(i)){t.next=36;break}for(y=!0,b=!1,k=void 0,t.prev=20,x=i[Symbol.iterator]();!(y=(w=x.next()).done);y=!0)O=w.value,delete m[O];t.next=28;break;case 24:t.prev=24,t.t0=t.catch(20),b=!0,k=t.t0;case 28:t.prev=28,t.prev=29,y||null==x.return||x.return();case 31:if(t.prev=31,!b){t.next=34;break}throw k;case 34:return t.finish(31);case 35:return t.finish(28);case 36:if((S=this.findItem(m.uuid))&&(S.updateFromJSON(m),S.dummy=!1),_=m.content_type||S&&S.content_type,!this.acceptableContentTypes||this.acceptableContentTypes.includes(_)){t.next=42;break}return t.abrupt("continue",55);case 42:if(T=!1,1!=m.deleted){t.next=50;break}if(!m.dirty){t.next=48;break}T=!0,t.next=50;break;case 48:return S&&(s.push(S),l.push(S),this.removeItemLocally(S)),t.abrupt("continue",55);case 50:S||(S=this.createItem(m)),this.addItem(S,T),S.errorDecrypting||l.push(S),s.push(S),u.push(m);case 55:c=!0,t.next=7;break;case 58:t.next=64;break;case 60:t.prev=60,t.t1=t.catch(5),h=!0,f=t.t1;case 64:t.prev=64,t.prev=65,c||null==d.return||d.return();case 67:if(t.prev=67,!h){t.next=70;break}throw f;case 70:return t.finish(67);case 71:return t.finish(64);case 72:for(C=!0,E=!1,A=void 0,t.prev=75,D=u.entries()[Symbol.iterator]();!(C=(M=D.next()).done);C=!0)N=p(M.value,2),R=N[0],P=N[1],I=s[R],P.content&&this.resolveReferencesForItem(I),I.didFinishSyncing();t.next=83;break;case 79:t.prev=79,t.t2=t.catch(75),E=!0,A=t.t2;case 83:t.prev=83,t.prev=84,C||null==D.return||D.return();case 86:if(t.prev=86,!E){t.next=89;break}throw A;case 89:return t.finish(86);case 90:return t.finish(83);case 91:for(L=this.popMissedReferenceStructsForObjects(u),F=!0,B=!1,Q=void 0,t.prev=95,z=function(){var t=j.value,e=s.find((function(e){return e.uuid==t.reference_uuid}));e&&t.for_item.addItemAsRelationship(e)},$=L[Symbol.iterator]();!(F=(j=$.next()).done);F=!0)z();t.next=104;break;case 100:t.prev=100,t.t3=t.catch(95),B=!0,Q=t.t3;case 104:t.prev=104,t.prev=105,F||null==$.return||$.return();case 107:if(t.prev=107,!B){t.next=110;break}throw Q;case 110:return t.finish(107);case 111:return t.finish(104);case 112:return t.next=114,this.notifySyncObserversOfModels(l,o,a);case 114:return t.abrupt("return",s);case 115:case"end":return t.stop()}}),t,this,[[5,60,64,72],[20,24,28,36],[29,,31,35],[65,,67,71],[75,79,83,91],[84,,86,90],[95,100,104,112],[105,,107,111]])}))),function(t){return c.apply(this,arguments)})},{key:"missedReferenceBuildKey",value:function(t,e){return"".concat(t,":").concat(e)}},{key:"popMissedReferenceStructsForObjects",value:function(t){if(!t||0==t.length)return[];for(var e=[],n=[],r=t.map((function(t){return t.uuid})),i=r[0].length,o=0,a=Object.keys(this.missedReferences);o1&&void 0!==arguments[1]&&arguments[1];if(!t.errorDecrypting){var n=t.contentObject;if(t.updateLocalRelationships(),n.references){var r=n.references.slice(),i=r.map((function(t){return t.uuid})),o=!0,a=this.findItems(i,o),s=!0,u=!1,l=void 0;try{for(var c,h=a.entries()[Symbol.iterator]();!(s=(c=h.next()).done);s=!0){var f=p(c.value,2),d=f[0],g=f[1];if(g)t.addItemAsRelationship(g),e&&this.setItemDirty(g,!0);else{var m=i[d],v=this.missedReferenceBuildKey(m,t.uuid);if(!this.missedReferences[v]){var y={reference_uuid:m,for_item:t};this.missedReferences[v]=y}}}}catch(t){u=!0,l=t}finally{try{s||null==h.return||h.return()}finally{if(u)throw l}}}}}},{key:"notifySyncObserversOfModels",value:(l=v(r.mark((function t(e,n,i){var o,a,s,u,l,c,h,f=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=this.itemSyncObservers.sort((function(t,e){return t.priority0)){t.next=25;break}return t.next=25,f._callSyncObserverCallbackWithTimeout(o,a,s,u,n,i);case 25:case"end":return t.stop()}}),t,null,[[6,10,14,22],[15,,17,21]])})),c=o[Symbol.iterator]();case 7:if(a=(h=c.next()).done){t.next=12;break}return t.delegateYield(l(),"t0",9);case 9:a=!0,t.next=7;break;case 12:t.next=18;break;case 14:t.prev=14,t.t1=t.catch(4),s=!0,u=t.t1;case 18:t.prev=18,t.prev=19,a||null==c.return||c.return();case 21:if(t.prev=21,!s){t.next=24;break}throw u;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}}),t,this,[[4,14,18,26],[19,,21,25]])}))),function(t,e,n){return l.apply(this,arguments)})},{key:"_callSyncObserverCallbackWithTimeout",value:(u=v(r.mark((function t(e,n,i,o,a,s){var u=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,r){u.$timeout((function(){try{e.callback(n,i,o,a,s)}catch(t){console.error("Sync observer exception",t)}finally{t()}}))})));case 1:case"end":return t.stop()}}),t)}))),function(t,e,n,r,i,o){return u.apply(this,arguments)})},{key:"setItemDirty",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0;this.setItemsDirty([t],e,n,r,i)}},{key:"setItemsDirty",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,a=!0,s=!1,u=void 0;try{for(var l,c=e[Symbol.iterator]();!(a=(l=c.next()).done);a=!0){var h=l.value;h.setDirty(n,r)}}catch(t){s=!0,u=t}finally{try{a||null==c.return||c.return()}finally{if(s)throw u}}this.notifySyncObserversOfModels(e,i||t.MappingSourceLocalDirtied,o)}},{key:"createItem",value:function(e){var n=t.ContentTypeClassMapping&&t.ContentTypeClassMapping[e.content_type];return n||(n=P),new n(e)}},{key:"createDuplicateItemFromResponseItem",value:(s=v(r.mark((function t(e){var n,i;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("function"!=typeof e.setDirty){t.next=3;break}return console.error("Attempting to create conflicted copy of non-response item."),t.abrupt("return",null);case 3:return n=JSON.parse(JSON.stringify(e)),t.next=6,SFJS.crypto.generateUUID();case 6:return n.uuid=t.sent,i=this.createItem(n),t.abrupt("return",i);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return s.apply(this,arguments)})},{key:"duplicateItemAndAddAsConflict",value:function(t){return this.duplicateItemWithCustomContentAndAddAsConflict({content:t.content,duplicateOf:t})}},{key:"duplicateItemWithCustomContentAndAddAsConflict",value:function(t){var e=t.content,n=t.duplicateOf,r=this.duplicateItemWithCustomContent({content:e,duplicateOf:n});return this.addDuplicatedItemAsConflict({duplicate:r,duplicateOf:n}),r}},{key:"addDuplicatedItemAsConflict",value:function(t){var e=t.duplicate,n=t.duplicateOf;this.addDuplicatedItem(e,n),e.content.conflict_of=n.uuid}},{key:"duplicateItemWithCustomContent",value:function(t){var e=t.content,n=t.duplicateOf,r=new n.constructor({content:e});return r.created_at=n.created_at,r.content_type||(r.content_type=n.content_type),r}},{key:"duplicateItemAndAdd",value:function(t){var e=this.duplicateItemWithoutAdding(t);return this.addDuplicatedItem(e,t),e}},{key:"duplicateItemWithoutAdding",value:function(t){var e=new t.constructor({content:t.content});return e.created_at=t.created_at,e.content_type||(e.content_type=t.content_type),e}},{key:"addDuplicatedItem",value:function(t,e){this.addItem(t);var n=!0,r=!1,i=void 0;try{for(var o,a=e.referencingObjects[Symbol.iterator]();!(n=(o=a.next()).done);n=!0){var s=o.value;s.addItemAsRelationship(t),this.setItemDirty(s,!0)}}catch(t){r=!0,i=t}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}this.resolveReferencesForItem(t),this.setItemDirty(t,!0)}},{key:"addItem",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.addItems([t],e)}},{key:"addItems",value:function(t){var e=this;t.forEach((function(t){e.itemsHash[t.uuid]||(e.itemsHash[t.uuid]=t,e.items.push(t))}))}},{key:"addItemSyncObserver",value:function(t,e,n){this.addItemSyncObserverWithPriority({id:t,types:e,callback:n,priority:1})}},{key:"addItemSyncObserverWithPriority",value:function(t){var e=t.id,n=t.priority,r=t.types,i=t.callback;Array.isArray(r)||(r=[r]),this.itemSyncObservers.push({id:e,types:r,priority:n,callback:i})}},{key:"removeItemSyncObserver",value:function(t){_.remove(this.itemSyncObservers,_.find(this.itemSyncObservers,{id:t}))}},{key:"getDirtyItems",value:function(){return this.items.filter((function(t){return 1==t.dirty&&!t.dummy&&(!t.errorDecrypting||t.deleted)}))}},{key:"clearDirtyItems",value:function(t){var e=!0,n=!1,r=void 0;try{for(var i,o=t[Symbol.iterator]();!(e=(i=o.next()).done);e=!0)i.value.setDirty(!1)}catch(t){n=!0,r=t}finally{try{e||null==o.return||o.return()}finally{if(n)throw r}}}},{key:"removeAndDirtyAllRelationshipsForItem",value:function(t){if(!t.errorDecrypting){var e=!0,n=!1,r=void 0;try{for(var i,o=t.content.references[Symbol.iterator]();!(e=(i=o.next()).done);e=!0){var a=i.value,s=this.findItem(a.uuid);s&&(t.removeItemAsRelationship(s),s.hasRelationshipWithItem(t)&&(s.removeItemAsRelationship(t),this.setItemDirty(s,!0)))}}catch(t){n=!0,r=t}finally{try{e||null==o.return||o.return()}finally{if(n)throw r}}}var u=!0,l=!1,c=void 0;try{for(var h,f=t.referencingObjects[Symbol.iterator]();!(u=(h=f.next()).done);u=!0){var d=h.value;d.removeItemAsRelationship(t),this.setItemDirty(d,!0)}}catch(t){l=!0,c=t}finally{try{u||null==f.return||f.return()}finally{if(l)throw c}}t.referencingObjects=[]}},{key:"setAllItemsDirty",value:function(){var t=this.allItems;this.setItemsDirty(t,!0)}},{key:"setItemToBeDeleted",value:function(t){t.deleted=!0,t.dummy||this.setItemDirty(t,!0),this.removeAndDirtyAllRelationshipsForItem(t)}},{key:"removeItemLocally",value:(a=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:_.remove(this.items,{uuid:e.uuid}),delete this.itemsHash[e.uuid],e.isBeingRemovedLocally();case 3:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"allItemsMatchingTypes",value:function(t){return this.allItems.filter((function(e){return(_.includes(t,e.content_type)||_.includes(t,"*"))&&!e.dummy}))}},{key:"invalidItems",value:function(){return this.allItems.filter((function(t){return t.errorDecrypting}))}},{key:"validItemsForContentType",value:function(t){return this.allItems.filter((function(e){return e.content_type==t&&!e.errorDecrypting}))}},{key:"findItem",value:function(t){return this.itemsHash[t]}},{key:"findItems",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var u=a.value,l=this.itemsHash[u];(l||e)&&n.push(l)}}catch(t){i=!0,o=t}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}},{key:"itemsMatchingPredicate",value:function(t){return this.itemsMatchingPredicates([t])}},{key:"itemsMatchingPredicates",value:function(t){return this.filterItemsWithPredicates(this.allItems,t)}},{key:"filterItemsWithPredicates",value:function(t,e){return t.filter((function(t){var n=!0,r=!1,i=void 0;try{for(var o,a=e[Symbol.iterator]();!(n=(o=a.next()).done);n=!0){var s=o.value;if(!t.satisfiesPredicate(s))return!1}}catch(t){r=!0,i=t}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}return!0}))}},{key:"importItems",value:(o=v(r.mark((function e(n){var i,o,a,s,u,l,c,h,f,d,p,g,m,v,y,b,k,x,w,O,S,_,T,C,E,A,D;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=[],o={},a=!0,s=!1,u=void 0,e.prev=5,l=n[Symbol.iterator]();case 7:if(a=(c=l.next()).done){e.next=18;break}if(h=c.value,f=this.findItem(h.uuid)){e.next=13;break}return o[h.uuid]={},e.abrupt("continue",15);case 13:d=this.duplicateItemWithoutAdding(f),o[h.uuid]={frozenValue:d,itemRef:f};case 15:a=!0,e.next=7;break;case 18:e.next=24;break;case 20:e.prev=20,e.t0=e.catch(5),s=!0,u=e.t0;case 24:e.prev=24,e.prev=25,a||null==l.return||l.return();case 27:if(e.prev=27,!s){e.next=30;break}throw u;case 30:return e.finish(27);case 31:return e.finish(24);case 32:p=!0,g=!1,m=void 0,e.prev=35,v=n[Symbol.iterator]();case 37:if(p=(y=v.next()).done){e.next=52;break}if(b=y.value,k=o[b.uuid],x=k.frozenValue,w=k.itemRef,!x||w.errorDecrypting){e.next=47;break}return e.next=43,this.createDuplicateItemFromResponseItem(b);case 43:O=e.sent,b.deleted||x.isItemContentEqualWith(O)||(this.addDuplicatedItemAsConflict({duplicate:O,duplicateOf:w}),i.push(O)),e.next=49;break;case 47:i.push(b),w&&w.errorDecrypting&&(w.errorDecrypting=!1);case 49:p=!0,e.next=37;break;case 52:e.next=58;break;case 54:e.prev=54,e.t1=e.catch(35),g=!0,m=e.t1;case 58:e.prev=58,e.prev=59,p||null==v.return||v.return();case 61:if(e.prev=61,!g){e.next=64;break}throw m;case 64:return e.finish(61);case 65:return e.finish(58);case 66:return e.next=68,this.mapResponseItemsToLocalModels(i,t.MappingSourceFileImport);case 68:for(S=e.sent,_=!0,T=!1,C=void 0,e.prev=72,E=S[Symbol.iterator]();!(_=(A=E.next()).done);_=!0)D=A.value,this.setItemDirty(D,!0,!1),D.deleted=!1;e.next=80;break;case 76:e.prev=76,e.t2=e.catch(72),T=!0,C=e.t2;case 80:e.prev=80,e.prev=81,_||null==E.return||E.return();case 83:if(e.prev=83,!T){e.next=86;break}throw C;case 86:return e.finish(83);case 87:return e.finish(80);case 88:return e.abrupt("return",S);case 89:case"end":return e.stop()}}),e,this,[[5,20,24,32],[25,,27,31],[35,54,58,66],[59,,61,65],[72,76,80,88],[81,,83,87]])}))),function(t){return o.apply(this,arguments)})},{key:"getAllItemsJSONData",value:(i=v(r.mark((function t(e,n,i){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getJSONDataForItems(this.allItems,e,n,i));case 1:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return i.apply(this,arguments)})},{key:"getJSONDataForItems",value:(n=v(r.mark((function t(e,n,i,o){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Promise.all(e.map((function(t){return new I(t,n,i).paramsForExportFile()}))).then((function(t){if(o&&0==t.length)return null;var e={items:t};return n&&(e.auth_params=i),JSON.stringify(e,null,2)})));case 1:case"end":return t.stop()}}),t)}))),function(t,e,r,i){return n.apply(this,arguments)})},{key:"computeDataIntegrityHash",value:(e=v(r.mark((function t(){var e,n,i,o;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,e=this.allNondummyItems.sort((function(t,e){return e.updated_at-t.updated_at})),n=e.map((function(t){return t.updatedAtTimestamp()})),i=n.join(","),t.next=6,SFJS.crypto.sha256(i);case 6:return o=t.sent,t.abrupt("return",o);case 10:return t.prev=10,t.t0=t.catch(0),console.error("Error computing data integrity hash",t.t0),t.abrupt("return",null);case 14:case"end":return t.stop()}}),t,this,[[0,10]])}))),function(){return e.apply(this,arguments)})},{key:"allItems",get:function(){return this.items.slice()}},{key:"allNondummyItems",get:function(){return this.items.filter((function(t){return!t.dummy}))}}]),t}();i.SFModelManager=C;var E=function(){function t(e,n,r){y(this,t),this.modelManager=e,this.syncManager=n,this.singletonManager=r,this.loadPrivileges(),t.CredentialAccountPassword="CredentialAccountPassword",t.CredentialLocalPasscode="CredentialLocalPasscode",t.ActionManageExtensions="ActionManageExtensions",t.ActionManageBackups="ActionManageBackups",t.ActionViewProtectedNotes="ActionViewProtectedNotes",t.ActionManagePrivileges="ActionManagePrivileges",t.ActionManagePasscode="ActionManagePasscode",t.ActionDeleteNote="ActionDeleteNote",t.SessionExpiresAtKey="SessionExpiresAtKey",t.SessionLengthKey="SessionLengthKey",t.SessionLengthNone=0,t.SessionLengthFiveMinutes=300,t.SessionLengthOneHour=3600,t.SessionLengthOneWeek=604800,this.availableActions=[t.ActionViewProtectedNotes,t.ActionDeleteNote,t.ActionManagePasscode,t.ActionManageBackups,t.ActionManageExtensions,t.ActionManagePrivileges],this.availableCredentials=[t.CredentialAccountPassword,t.CredentialLocalPasscode],this.sessionLengths=[t.SessionLengthNone,t.SessionLengthFiveMinutes,t.SessionLengthOneHour,t.SessionLengthOneWeek,t.SessionLengthIndefinite]}var e,n,i,o,a,s,u,l,c,h,f,d;return k(t,[{key:"setDelegate",value:function(t){this.delegate=t}},{key:"getAvailableActions",value:function(){return this.availableActions}},{key:"getAvailableCredentials",value:function(){return this.availableCredentials}},{key:"netCredentialsForAction",value:(d=v(r.mark((function e(n){var i,o,a,s,u,l,c,h;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPrivileges();case 2:e.t0=n,i=e.sent.getCredentialsForAction(e.t0),o=[],a=!0,s=!1,u=void 0,e.prev=8,l=i[Symbol.iterator]();case 10:if(a=(c=l.next()).done){e.next=27;break}if((h=c.value)!=t.CredentialAccountPassword){e.next=19;break}return e.next=15,this.delegate.isOffline();case 15:e.sent||o.push(h),e.next=24;break;case 19:if(h!=t.CredentialLocalPasscode){e.next=24;break}return e.next=22,this.delegate.hasLocalPasscode();case 22:e.sent&&o.push(h);case 24:a=!0,e.next=10;break;case 27:e.next=33;break;case 29:e.prev=29,e.t1=e.catch(8),s=!0,u=e.t1;case 33:e.prev=33,e.prev=34,a||null==l.return||l.return();case 36:if(e.prev=36,!s){e.next=39;break}throw u;case 39:return e.finish(36);case 40:return e.finish(33);case 41:return e.abrupt("return",o);case 42:case"end":return e.stop()}}),e,this,[[8,29,33,41],[34,,36,40]])}))),function(t){return d.apply(this,arguments)})},{key:"loadPrivileges",value:(f=v(r.mark((function t(){var e=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.loadPromise){t.next=2;break}return t.abrupt("return",this.loadPromise);case 2:return this.loadPromise=new Promise((function(t,n){var i=F.contentType(),o=new L("content_type","=",i);e.singletonManager.registerSingleton([o],(function(n){e.privileges=n,t(n)}),function(){var n=v(r.mark((function n(o){var a;return r.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(a=new F({content_type:i}),SFJS.crypto.generateUUIDSync){n.next=4;break}return n.next=4,a.initUUID();case 4:e.modelManager.addItem(a),e.modelManager.setItemDirty(a,!0),e.syncManager.sync(),o(a),t(a);case 9:case"end":return n.stop()}}),n)})));return function(t){return n.apply(this,arguments)}}())})),t.abrupt("return",this.loadPromise);case 4:case"end":return t.stop()}}),t,this)}))),function(){return f.apply(this,arguments)})},{key:"getPrivileges",value:(h=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.privileges){t.next=4;break}return t.abrupt("return",this.privileges);case 4:return t.abrupt("return",this.loadPrivileges());case 5:case"end":return t.stop()}}),t,this)}))),function(){return h.apply(this,arguments)})},{key:"displayInfoForCredential",value:function(e){var n={};return n[t.CredentialAccountPassword]={label:"Account Password",prompt:"Please enter your account password."},n[t.CredentialLocalPasscode]={label:"Local Passcode",prompt:"Please enter your local passcode."},n[e]}},{key:"displayInfoForAction",value:function(e){var n={};return n[t.ActionManageExtensions]={label:"Manage Extensions"},n[t.ActionManageBackups]={label:"Download/Import Backups"},n[t.ActionViewProtectedNotes]={label:"View Protected Notes"},n[t.ActionManagePrivileges]={label:"Manage Privileges"},n[t.ActionManagePasscode]={label:"Manage Passcode"},n[t.ActionDeleteNote]={label:"Delete Notes"},n[e]}},{key:"getSessionLengthOptions",value:function(){return[{value:t.SessionLengthNone,label:"Don't Remember"},{value:t.SessionLengthFiveMinutes,label:"5 Minutes"},{value:t.SessionLengthOneHour,label:"1 Hour"},{value:t.SessionLengthOneWeek,label:"1 Week"}]}},{key:"setSessionLength",value:(c=v(r.mark((function e(n){var i;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n,o=void 0,(o=new Date).setSeconds(o.getSeconds()+r),i=o,e.abrupt("return",Promise.all([this.delegate.saveToStorage(t.SessionExpiresAtKey,JSON.stringify(i)),this.delegate.saveToStorage(t.SessionLengthKey,JSON.stringify(n))]));case 3:case"end":return e.stop()}var r,o}),e,this)}))),function(t){return c.apply(this,arguments)})},{key:"clearSession",value:(l=v(r.mark((function e(){return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.setSessionLength(t.SessionLengthNone));case 1:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getSelectedSessionLength",value:(u=v(r.mark((function e(){var n;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.delegate.getFromStorage(t.SessionLengthKey);case 2:if(!(n=e.sent)){e.next=7;break}return e.abrupt("return",JSON.parse(n));case 7:return e.abrupt("return",t.SessionLengthNone);case 8:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getSessionExpirey",value:(s=v(r.mark((function e(){var n;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.delegate.getFromStorage(t.SessionExpiresAtKey);case 2:if(!(n=e.sent)){e.next=7;break}return e.abrupt("return",new Date(JSON.parse(n)));case 7:return e.abrupt("return",new Date);case 8:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"actionHasPrivilegesConfigured",value:(a=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.netCredentialsForAction(e);case 2:return t.t0=t.sent.length,t.abrupt("return",t.t0>0);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"actionRequiresPrivilege",value:(o=v(r.mark((function t(e){var n;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getSessionExpirey();case 2:if(!(t.sent>new Date)){t.next=5;break}return t.abrupt("return",!1);case 5:return t.next=7,this.netCredentialsForAction(e);case 7:return n=t.sent,t.abrupt("return",n.length>0);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"savePrivileges",value:(i=v(r.mark((function t(){var e;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPrivileges();case 2:e=t.sent,this.modelManager.setItemDirty(e,!0),this.syncManager.sync();case 5:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"authenticateAction",value:(n=v(r.mark((function t(e,n){var i,o,a,s,u,l,c,h,f;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.netCredentialsForAction(e);case 2:i=t.sent,o=[],a=[],s=!0,u=!1,l=void 0,t.prev=7,c=i[Symbol.iterator]();case 9:if(s=(h=c.next()).done){t.next=18;break}return f=h.value,t.next=13,this._verifyAuthenticationParameters(f,n[f]);case 13:t.sent?o.push(f):a.push(f);case 15:s=!0,t.next=9;break;case 18:t.next=24;break;case 20:t.prev=20,t.t0=t.catch(7),u=!0,l=t.t0;case 24:t.prev=24,t.prev=25,s||null==c.return||c.return();case 27:if(t.prev=27,!u){t.next=30;break}throw l;case 30:return t.finish(27);case 31:return t.finish(24);case 32:return t.abrupt("return",{success:0==a.length,successfulCredentials:o,failedCredentials:a});case 33:case"end":return t.stop()}}),t,this,[[7,20,24,32],[25,,27,31]])}))),function(t,e){return n.apply(this,arguments)})},{key:"_verifyAuthenticationParameters",value:(e=v(r.mark((function e(n,i){var o,a,s=this;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=function(){var t=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",s.delegate.verifyAccountPassword(e));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),a=function(){var t=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",s.delegate.verifyLocalPasscode(e));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),n!=t.CredentialAccountPassword){e.next=6;break}return e.abrupt("return",o(i));case 6:if(n!=t.CredentialLocalPasscode){e.next=8;break}return e.abrupt("return",a(i));case 8:case"end":return e.stop()}}),e)}))),function(t,n){return e.apply(this,arguments)})}]),t}();i.SFPrivilegesManager=E;var A=function(){function t(e,n,r,i,o){var a=this;y(this,t),this.modelManager=e,this.storageManager=n,this.$timeout=o||setTimeout.bind(window),this.keyRequestHandler=r,this.loadFromDisk().then((function(){a.modelManager.addItemSyncObserver("session-history",i,(function(t,e,n,r,i){if(r!==C.MappingSourceLocalDirtied){var o=!0,s=!1,u=void 0;try{for(var l,c=t[Symbol.iterator]();!(o=(l=c.next()).done);o=!0){var h=l.value;try{a.addHistoryEntryForItem(h)}catch(t){console.log("Caught exception while trying to add item history entry",t)}}}catch(t){s=!0,u=t}finally{try{o||null==c.return||c.return()}finally{if(s)throw u}}}}))}))}var e,n,i,o,a,s,u;return k(t,[{key:"encryptionParams",value:(u=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.keyRequestHandler());case 1:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"addHistoryEntryForItem",value:function(t){var e=this,n={uuid:t.uuid,content_type:t.content_type,updated_at:t.updated_at,content:t.getContentCopy()},r=this.historySession.addEntryForItem(n);this.autoOptimize&&this.historySession.optimizeHistoryForItem(t),r&&this.diskEnabled&&(this.diskTimeout&&(this.$timeout.hasOwnProperty("cancel")?this.$timeout.cancel(this.diskTimeout):clearTimeout(this.diskTimeout)),this.diskTimeout=this.$timeout((function(){e.saveToDisk()}),2e3))}},{key:"historyForItem",value:function(t){return this.historySession.historyForItem(t)}},{key:"clearHistoryForItem",value:(s=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.historySession.clearItemHistory(e),t.abrupt("return",this.saveToDisk());case 2:case"end":return t.stop()}}),t,this)}))),function(t){return s.apply(this,arguments)})},{key:"clearAllHistory",value:(a=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.historySession.clearAllHistory(),t.abrupt("return",this.storageManager.removeItem("sessionHistory_revisions"));case 2:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"toggleDiskSaving",value:(o=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.diskEnabled=!this.diskEnabled,!this.diskEnabled){t.next=6;break}this.storageManager.setItem("sessionHistory_persist",JSON.stringify(!0)),this.saveToDisk(),t.next=8;break;case 6:return this.storageManager.setItem("sessionHistory_persist",JSON.stringify(!1)),t.abrupt("return",this.storageManager.removeItem("sessionHistory_revisions"));case 8:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"saveToDisk",value:(i=v(r.mark((function t(){var e,n=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.diskEnabled){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this.encryptionParams();case 4:e=t.sent,new I(this.historySession,e.keys,e.auth_params).paramsForSync().then((function(t){n.storageManager.setItem("sessionHistory_revisions",JSON.stringify(t))}));case 7:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"loadFromDisk",value:(n=v(r.mark((function t(){var e,n,i,o,a;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.storageManager.getItem("sessionHistory_persist");case 2:return(e=t.sent)&&(this.diskEnabled=JSON.parse(e)),t.next=6,this.storageManager.getItem("sessionHistory_revisions");case 6:if(!(n=t.sent)){t.next=18;break}return n=JSON.parse(n),t.next=11,this.encryptionParams();case 11:return i=t.sent,t.next=14,SFJS.itemTransformer.decryptItem(n,i.keys);case 14:o=new B(n),this.historySession=o,t.next=19;break;case 18:this.historySession=new B;case 19:return t.next=21,this.storageManager.getItem("sessionHistory_autoOptimize");case 21:a=t.sent,this.autoOptimize=!a||JSON.parse(a);case 23:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"toggleAutoOptimize",value:(e=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.autoOptimize=!this.autoOptimize,this.autoOptimize?this.storageManager.setItem("sessionHistory_autoOptimize",JSON.stringify(!0)):this.storageManager.setItem("sessionHistory_autoOptimize",JSON.stringify(!1));case 2:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})}]),t}();i.SFSessionHistoryManager=A;var D=function(){function t(e,n){var r=this;y(this,t),this.syncManager=n,this.modelManager=e,this.singletonHandlers=[],e.addItemSyncObserverWithPriority({id:"sf-singleton-manager",types:"*",priority:-1,callback:function(t,n,i,o,a){o!==C.MappingSourceLocalDirtied&&r.resolveSingletons(e.allNondummyItems,null,!0)}}),n.addEventHandler((function(t,n){if("local-data-loaded"==t)r.resolveSingletons(e.allNondummyItems,null,!0),r.initialDataLoaded=!0;else if("sync:completed"==t){if(!r.initialDataLoaded)return;r.resolveSingletons(n.retrievedItems,n.savedItems)}})),e.addModelUuidChangeObserver("singleton-manager",(function(t,e){var n=!0,i=!1,o=void 0;try{for(var a,s=r.singletonHandlers[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;u.singleton&&L.ItemSatisfiesPredicates(e,u.predicates)&&(u.singleton=null,r.resolveSingletons([e]))}}catch(t){i=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}}))}return k(t,[{key:"registerSingleton",value:function(t,e,n){this.singletonHandlers.push({predicates:t,resolutionCallback:e,createBlock:n})}},{key:"resolveSingletons",value:function(t,e,n){var r=this;t=t||[],e=e||[];var i=!0,o=!1,a=void 0;try{for(var s,u=function(){var i=s.value,o=i.predicates.slice(),a=r.modelManager.filterItemsWithPredicates(t,o),u=function(){i.createBlock&&(i.pendingCreateBlockCallback=!0,i.createBlock((function(t){i.singleton=t,i.pendingCreateBlockCallback=!1,i.resolutionCallback&&i.resolutionCallback(t)})))},l=r.modelManager.filterItemsWithPredicates(e,o).length;if(a.length>0||l>0){var c=r.modelManager.itemsMatchingPredicates(o);if(c.length>=2){var h=c.sort((function(t,e){return t.errorDecrypting?1:e.errorDecrypting||t.created_at=this.MaxDiscordanceBeforeOutOfSync&&(this.outOfSync||(this.outOfSync=!0,this.notifyEvent("enter-out-of-sync"))),t.abrupt("return",!1);case 13:return this.outOfSync&&(this.outOfSync=!1,this.notifyEvent("exit-out-of-sync")),this.syncDiscordance=0,t.abrupt("return",!0);case 16:case"end":return t.stop()}}),t,this)}))),function(t){return D.apply(this,arguments)})},{key:"isOutOfSync",value:function(){return this.outOfSync}},{key:"getServerURL",value:(A=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.storageManager.getItem("server");case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=window._default_sf_server;case 5:return t.abrupt("return",t.t0);case 6:case"end":return t.stop()}}),t,this)}))),function(){return A.apply(this,arguments)})},{key:"getSyncURL",value:(E=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getServerURL();case 2:return t.t0=t.sent,t.abrupt("return",t.t0+"/items/sync");case 4:case"end":return t.stop()}}),t,this)}))),function(){return E.apply(this,arguments)})},{key:"registerSyncStatusObserver",value:function(t){var e={key:new Date,callback:t};return this.syncStatusObservers.push(e),e}},{key:"removeSyncStatusObserver",value:function(t){_.pull(this.syncStatusObservers,t)}},{key:"syncStatusDidChange",value:function(){var t=this;this.syncStatusObservers.forEach((function(e){e.callback(t.syncStatus)}))}},{key:"addEventHandler",value:function(t){return this.eventHandlers.push(t),t}},{key:"removeEventHandler",value:function(t){_.pull(this.eventHandlers,t)}},{key:"notifyEvent",value:function(t,e){var n=!0,r=!1,i=void 0;try{for(var o,a=this.eventHandlers[Symbol.iterator]();!(n=(o=a.next()).done);n=!0)(0,o.value)(t,e||{})}catch(t){r=!0,i=t}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}}},{key:"setKeyRequestHandler",value:function(t){this.keyRequestHandler=t}},{key:"getActiveKeyInfo",value:(T=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.keyRequestHandler(e));case 1:case"end":return t.stop()}}),t,this)}))),function(t){return T.apply(this,arguments)})},{key:"initialDataLoaded",value:function(){return!0===this._initialDataLoaded}},{key:"_sortLocalItems",value:function(t){var e=this;return t.sort((function(t,n){var r=new Date(n.updated_at)-new Date(t.updated_at),i=e.contentTypeLoadPriority,o=0,a=0;return i&&(o=i.indexOf(t.content_type),a=i.indexOf(n.content_type),-1==o&&(o=i.length),-1==a&&(a=i.length)),o==a?r:o0&&void 0!==l[0]?l[0]:{},i=n.incrementalCallback,o=n.batchSize,!(a=n.options)||!a.simulateHighLatency){e.next=5;break}return s=a.simulatedLatency||1e3,e.next=5,this._awaitSleep(s);case 5:if(!this.loadLocalDataPromise){e.next=7;break}return e.abrupt("return",this.loadLocalDataPromise);case 7:return o||(o=100),this.loadLocalDataPromise=this.storageManager.getAllModels().then((function(e){var n=(e=(e=u._sortLocalItems(e)).filter((function(t){var e=u.modelManager.findItem(t.uuid);return!e||new Date(t.dirtiedDate)>e.dirtiedDate}))).length,a=0,s=[],l=function(){var c=v(r.mark((function c(){var h,f;return r.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return h=e.slice(a,a+o),r.next=3,u.handleItemsResponse(h,null,C.MappingSourceLocalRetrieved,t.KeyRequestLoadLocal);case 3:if(f=r.sent,s.push(f),!((a+=h.length)0)){e.next=23;break}return e.next=23,Promise.all(l.map(function(){var t=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",o.storageManager.deleteModel(e));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 23:return e.next=25,o.getActiveKeyInfo(t.KeyRequestSaveLocal);case 25:if(m=e.sent,!(u.length>0)){e.next=33;break}return e.next=29,Promise.all(u.map(function(){var t=v(r.mark((function t(e){var n;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new I(e,m.keys,m.auth_params),t.next=3,n.paramsForLocalStorage();case 3:return n=t.sent,i&&delete n.dirty,t.abrupt("return",n);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())).catch((function(t){return s(t)}));case 29:return y=e.sent,e.next=32,o.storageManager.saveModels(y).catch((function(t){console.error("Error writing items",t),o.syncStatus.localError=t,o.syncStatusDidChange(),s()}));case 32:o.syncStatus.localError&&(o.syncStatus.localError=null,o.syncStatusDidChange());case 33:a();case 34:case"end":return e.stop()}}),e,null,[[4,8,12,20],[13,,15,19]])})));return function(t,n){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)}))),function(t,e){return w.apply(this,arguments)})},{key:"syncOffline",value:(x=v(r.mark((function t(e){var n,i,o,a,s,u=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=!0,i=!1,o=void 0,t.prev=3,a=e[Symbol.iterator]();!(n=(s=a.next()).done);n=!0)s.value.updated_at=new Date;t.next=11;break;case 7:t.prev=7,t.t0=t.catch(3),i=!0,o=t.t0;case 11:t.prev=11,t.prev=12,n||null==a.return||a.return();case 14:if(t.prev=14,!i){t.next=17;break}throw o;case 17:return t.finish(14);case 18:return t.finish(11);case 19:return t.abrupt("return",this.writeItemsToLocalStorage(e,!0).then((function(t){var n=!0,r=!1,i=void 0;try{for(var o,a=e[Symbol.iterator]();!(n=(o=a.next()).done);n=!0){var s=o.value;s.deleted&&u.modelManager.removeItemLocally(s)}}catch(t){r=!0,i=t}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}return u.modelManager.clearDirtyItems(e),u.modelManager.didSyncModelsOffline(e),u.notifyEvent("sync:completed",{savedItems:e}),{saved_items:e}})));case 20:case"end":return t.stop()}}),t,this,[[3,7,11,19],[12,,14,18]])}))),function(t){return x.apply(this,arguments)})},{key:"markAllItemsDirtyAndSaveOffline",value:(b=v(r.mark((function t(e){var n,i,o,a,s,u,l,c,h,f,d,p,g;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e){t.next=28;break}n=this.modelManager.allNondummyItems.filter((function(t){return!t.errorDecrypting})).slice(),i=!0,o=!1,a=void 0,t.prev=5,s=n[Symbol.iterator]();case 7:if(i=(u=s.next()).done){t.next=14;break}return l=u.value,t.next=11,this.modelManager.alternateUUIDForItem(l);case 11:i=!0,t.next=7;break;case 14:t.next=20;break;case 16:t.prev=16,t.t0=t.catch(5),o=!0,a=t.t0;case 20:t.prev=20,t.prev=21,i||null==s.return||s.return();case 23:if(t.prev=23,!o){t.next=26;break}throw a;case 26:return t.finish(23);case 27:return t.finish(20);case 28:for(c=this.modelManager.allNondummyItems,h=!0,f=!1,d=void 0,t.prev=32,p=c[Symbol.iterator]();!(h=(g=p.next()).done);h=!0)g.value.setDirty(!0);t.next=40;break;case 36:t.prev=36,t.t1=t.catch(32),f=!0,d=t.t1;case 40:t.prev=40,t.prev=41,h||null==p.return||p.return();case 43:if(t.prev=43,!f){t.next=46;break}throw d;case 46:return t.finish(43);case 47:return t.finish(40);case 48:return t.abrupt("return",this.writeItemsToLocalStorage(c,!1));case 49:case"end":return t.stop()}}),t,this,[[5,16,20,28],[21,,23,27],[32,36,40,48],[41,,43,47]])}))),function(t){return b.apply(this,arguments)})},{key:"setSyncToken",value:(m=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._syncToken=e,t.next=3,this.storageManager.setItem("syncToken",e);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return m.apply(this,arguments)})},{key:"getSyncToken",value:(g=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._syncToken){t.next=4;break}return t.next=3,this.storageManager.getItem("syncToken");case 3:this._syncToken=t.sent;case 4:return t.abrupt("return",this._syncToken);case 5:case"end":return t.stop()}}),t,this)}))),function(){return g.apply(this,arguments)})},{key:"setCursorToken",value:(p=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._cursorToken=e,!e){t.next=6;break}return t.next=4,this.storageManager.setItem("cursorToken",e);case 4:t.next=8;break;case 6:return t.next=8,this.storageManager.removeItem("cursorToken");case 8:case"end":return t.stop()}}),t,this)}))),function(t){return p.apply(this,arguments)})},{key:"getCursorToken",value:(d=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._cursorToken){t.next=4;break}return t.next=3,this.storageManager.getItem("cursorToken");case 3:this._cursorToken=t.sent;case 4:return t.abrupt("return",this._cursorToken);case 5:case"end":return t.stop()}}),t,this)}))),function(){return d.apply(this,arguments)})},{key:"clearQueuedCallbacks",value:function(){this._queuedCallbacks=[]}},{key:"callQueuedCallbacks",value:function(t){var e=this.queuedCallbacks;if(e.length){var n=!0,r=!1,i=void 0;try{for(var o,a=e[Symbol.iterator]();!(n=(o=a.next()).done);n=!0)(0,o.value)(t)}catch(t){r=!0,i=t}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}this.clearQueuedCallbacks()}}},{key:"beginCheckingIfSyncIsTakingTooLong",value:function(){this.syncStatus.checker&&this.stopCheckingIfSyncIsTakingTooLong(),this.syncStatus.checker=this.$interval(function(){(new Date-this.syncStatus.syncStart)/1e3>5&&(this.notifyEvent("sync:taking-too-long"),this.stopCheckingIfSyncIsTakingTooLong())}.bind(this),500)}},{key:"stopCheckingIfSyncIsTakingTooLong",value:function(){this.$interval.hasOwnProperty("cancel")?this.$interval.cancel(this.syncStatus.checker):clearInterval(this.syncStatus.checker),this.syncStatus.checker=null}},{key:"lockSyncing",value:function(){this.syncLocked=!0}},{key:"unlockSyncing",value:function(){this.syncLocked=!1}},{key:"sync",value:(f=v(r.mark((function e(){var n,i=this,o=arguments;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>0&&void 0!==o[0]?o[0]:{},!this.syncLocked){e.next=4;break}return console.log("Sync Locked, Returning;"),e.abrupt("return");case 4:return e.abrupt("return",new Promise(function(){var e=v(r.mark((function e(o,a){var s,u,l,c,h,f,d,p,g,m,v,y,b,k;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n||(n={}),s=i.modelManager.getDirtyItems(),u=s.filter((function(t){return!i.lastDirtyItemsSave||t.dirtiedDate>i.lastDirtyItemsSave})),e.next=5,i.getActiveKeyInfo(t.KeyRequestLoadSaveAccount);case 5:if(l=e.sent,c=i.syncStatus.syncOpInProgress,h=i.initialDataLoaded(),!c&&h){e.next=16;break}return i.performSyncAgainOnCompletion=!0,i.lastDirtyItemsSave=new Date,e.next=13,i.writeItemsToLocalStorage(u,!1);case 13:return c&&(i.queuedCallbacks.push(o),i.loggingEnabled&&console.warn("Attempting to sync while existing sync is in progress.")),h||(i.loggingEnabled&&console.warn("(1) Attempting to perform online sync before local data has loaded"),o()),e.abrupt("return");case 16:if(i.syncStatus.syncOpInProgress=!0,!l.offline){e.next=19;break}return e.abrupt("return",i.syncOffline(s).then((function(t){i.syncStatus.syncOpInProgress=!1,o(t)})).catch((function(t){i.notifyEvent("sync-exception",t)})));case 19:if(i.initialDataLoaded()){e.next=22;break}return console.error("Attempting to perform online sync before local data has loaded"),e.abrupt("return");case 22:return i.loggingEnabled&&console.log("Syncing online user."),f=i.syncStatus.needsMoreSync,i.syncStatus.syncStart=new Date,i.beginCheckingIfSyncIsTakingTooLong(),d=i.PerSyncItemUploadLimit,(p=s.slice(0,d)).lengthi.syncStatus.total&&(i.syncStatus.total=i.syncStatus.current),i.syncStatusDidChange(),e.next=34,i.writeItemsToLocalStorage(u,!1);case 34:return i.lastDirtyItemsSave=new Date,n.onPreSyncSave&&n.onPreSyncSave(),i.allRetreivedItems||(i.allRetreivedItems=[]),i.allSavedItems||(i.allSavedItems=[]),(g={}).limit=i.ServerItemDownloadLimit,n.performIntegrityCheck&&(g.compute_integrity=!0),e.prev=41,e.next=44,Promise.all(p.map((function(t){var e=new I(t,l.keys,l.auth_params);return e.additionalFields=n.additionalFields,e.paramsForSync()}))).then((function(t){g.items=t}));case 44:e.next=49;break;case 46:e.prev=46,e.t0=e.catch(41),i.notifyEvent("sync-exception",e.t0);case 49:for(m=!0,v=!1,y=void 0,e.prev=52,b=p[Symbol.iterator]();!(m=(k=b.next()).done);m=!0)k.value.dirtyCount=0;e.next=60;break;case 56:e.prev=56,e.t1=e.catch(52),v=!0,y=e.t1;case 60:e.prev=60,e.prev=61,m||null==b.return||b.return();case 63:if(e.prev=63,!v){e.next=66;break}throw y;case 66:return e.finish(63);case 67:return e.finish(60);case 68:return e.next=70,i.getSyncToken();case 70:return g.sync_token=e.sent,e.next=73,i.getCursorToken();case 73:return g.cursor_token=e.sent,g.api=S.getApiVersion(),i.loggingEnabled&&console.log("Syncing with params",g),e.prev=76,e.t2=i.httpManager,e.next=80,i.getSyncURL();case 80:e.t3=e.sent,e.t4=g,e.t5=function(t){i.handleSyncSuccess(p,t,n).then((function(){o(t)})).catch((function(t){console.log("Caught sync success exception:",t),i.handleSyncError(t,null,s).then((function(e){i.notifyEvent("sync-exception",t),o(e)}))}))},e.t6=function(t,e){i.handleSyncError(t,e,s).then((function(t){o(t)}))},e.t2.postAuthenticatedAbsolute.call(e.t2,e.t3,e.t4,e.t5,e.t6),e.next=90;break;case 87:e.prev=87,e.t7=e.catch(76),console.log("Sync exception caught:",e.t7);case 90:case"end":return e.stop()}}),e,null,[[41,46],[52,56,60,68],[61,,63,67],[76,87]])})));return function(t,n){return e.apply(this,arguments)}}()));case 5:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"_awaitSleep",value:(h=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.warn("Simulating high latency sync request",e),t.abrupt("return",new Promise((function(t,n){setTimeout((function(){t()}),e)})));case 2:case"end":return t.stop()}}),t)}))),function(t){return h.apply(this,arguments)})},{key:"handleSyncSuccess",value:(c=v(r.mark((function e(n,i,o){var a,s,u,l,c,h,f,d,p,g,m,v,y,b,k,x,w=this;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!o.simulateHighLatency){e.next=4;break}return a=o.simulatedLatency||1e3,e.next=4,this._awaitSleep(a);case 4:for(this.syncStatus.error=null,this.loggingEnabled&&console.log("Sync response",i),s=this.allSavedItems.map((function(t){return t.uuid})),u=i.saved_items.map((function(t){return t.uuid})),i.retrieved_items=i.retrieved_items.filter((function(t){var e=s.includes(t.uuid),n=u.includes(t.uuid);if(e||n)return!1;var r=w.modelManager.findItem(t.uuid);return!r||!r.dirty})),l=[],c=!0,h=!1,f=void 0,e.prev=13,d=n[Symbol.iterator]();!(c=(p=d.next()).done);c=!0)0==(g=p.value).dirtyCount&&l.push(g);e.next=21;break;case 17:e.prev=17,e.t0=e.catch(13),h=!0,f=e.t0;case 21:e.prev=21,e.prev=22,c||null==d.return||d.return();case 24:if(e.prev=24,!h){e.next=27;break}throw f;case 27:return e.finish(24);case 28:return e.finish(21);case 29:return this.modelManager.clearDirtyItems(l),e.next=32,this.handleItemsResponse(i.retrieved_items,null,C.MappingSourceRemoteRetrieved,t.KeyRequestLoadSaveAccount);case 32:return m=e.sent,this.allRetreivedItems=this.allRetreivedItems.concat(m),this.syncStatus.retrievedCount=this.allRetreivedItems.length,v=["content","auth_hash"],e.next=38,this.handleItemsResponse(i.saved_items,v,C.MappingSourceRemoteSaved,t.KeyRequestLoadSaveAccount);case 38:return y=e.sent,this.allSavedItems=this.allSavedItems.concat(y),b=i.unsaved,e.next=43,this.deprecated_handleUnsavedItemsResponse(b);case 43:return e.next=45,this.handleConflictsResponse(i.conflicts);case 45:if(k=e.sent,x=k&&k.length>0,!k){e.next=50;break}return e.next=50,this.writeItemsToLocalStorage(k,!1);case 50:return e.next=52,this.writeItemsToLocalStorage(y,!1);case 52:return e.next=54,this.writeItemsToLocalStorage(m,!1);case 54:if(!i.integrity_hash||i.cursor_token){e.next=59;break}return e.next=57,this.handleServerIntegrityHash(i.integrity_hash);case 57:e.sent||this.syncDiscordance=this.majorDataChangeThreshold||y.length>=this.majorDataChangeThreshold||b&&b.length>=this.majorDataChangeThreshold||k&&k.length>=this.majorDataChangeThreshold)&&this.notifyEvent("major-data-change"),this.callQueuedCallbacks(i),this.notifyEvent("sync:completed",{retrievedItems:this.allRetreivedItems,savedItems:this.allSavedItems}),this.allRetreivedItems=[],this.allSavedItems=[],this.performSyncAgainOnCompletion&&(this.performSyncAgainOnCompletion=!1,setTimeout((function(){w.sync(o)}),10)),e.abrupt("return",i);case 88:case"end":return e.stop()}}),e,this,[[13,17,21,29],[22,,24,28]])}))),function(t,e,n){return c.apply(this,arguments)})},{key:"handleSyncError",value:(l=v(r.mark((function t(e,n,i){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Sync error: ",e),401==n&&this.notifyEvent("sync-session-invalid"),e?"string"==typeof e&&(e={error:{message:e}}):e={error:{message:"Could not connect to server."}},this.syncStatus.syncOpInProgress=!1,this.syncStatus.error=e.error,this.syncStatusDidChange(),this.writeItemsToLocalStorage(i,!1),this.modelManager.didSyncModelsOffline(i),this.stopCheckingIfSyncIsTakingTooLong(),this.notifyEvent("sync:error",e.error),this.callQueuedCallbacks({error:"Sync error"}),t.abrupt("return",e);case 12:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return l.apply(this,arguments)})},{key:"handleItemsResponse",value:(u=v(r.mark((function t(e,n,i,o){var a,s,u;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getActiveKeyInfo(o);case 2:return a=t.sent.keys,t.next=5,SFJS.itemTransformer.decryptMultipleItems(e,a);case 5:return t.next=7,this.modelManager.mapResponseItemsToLocalModelsOmittingFields(e,n,i);case 7:return s=t.sent,(u=s.filter((function(t){var e=t.errorDecryptingValueChanged;return t.errorDecryptingValueChanged=!1,e}))).length>0&&this.writeItemsToLocalStorage(u,!1),t.abrupt("return",s);case 11:case"end":return t.stop()}}),t,this)}))),function(t,e,n,r){return u.apply(this,arguments)})},{key:"refreshErroredItems",value:(s=v(r.mark((function e(){var n;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((n=this.modelManager.allNondummyItems.filter((function(t){return 1==t.errorDecrypting}))).length>0)){e.next=3;break}return e.abrupt("return",this.handleItemsResponse(n,null,C.MappingSourceLocalRetrieved,t.KeyRequestLoadSaveAccount));case 3:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"handleConflictsResponse",value:(a=v(r.mark((function e(n){var i,o,a,s,u,l,c,h,f,d,p,g,m,v,y,b,k,x,w,O,S,_,T,E,A,D,M,N,R,I,L;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n&&0!=n.length){e.next=2;break}return e.abrupt("return");case 2:this.loggingEnabled&&console.log("Handle Conflicted Items:",n),i={},o=!0,a=!1,s=void 0,e.prev=7,u=n[Symbol.iterator]();case 9:if(o=(l=u.next()).done){e.next=21;break}if(c=l.value,h=c.server_item||c.unsaved_item,f=this.modelManager.findItem(h.uuid)){e.next=16;break}return i[h.uuid]={},e.abrupt("continue",18);case 16:d=f.getContentCopy(),i[h.uuid]={frozenContent:d,itemRef:f};case 18:o=!0,e.next=9;break;case 21:e.next=27;break;case 23:e.prev=23,e.t0=e.catch(7),a=!0,s=e.t0;case 27:e.prev=27,e.prev=28,o||null==u.return||u.return();case 30:if(e.prev=30,!a){e.next=33;break}throw s;case 33:return e.finish(30);case 34:return e.finish(27);case 35:p=[],g=!0,m=!1,v=void 0,e.prev=39,y=n[Symbol.iterator]();case 41:if(g=(b=y.next()).done){e.next=91;break}return k=b.value,x=k.server_item||k.unsaved_item,e.t1=SFJS.itemTransformer,e.t2=[x],e.next=48,this.getActiveKeyInfo(t.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(w=i[x.uuid],O=w.frozenContent,S=w.itemRef){e.next=54;break}return e.abrupt("continue",88);case 54:if(p.push(S),"uuid_conflict"!==k.type){e.next=62;break}return e.next=58,this.modelManager.alternateUUIDForItem(S);case 58:_=e.sent,p.push(_),e.next=88;break;case 62:if("sync_conflict"!==k.type){e.next=86;break}return e.next=65,this.modelManager.createDuplicateItemFromResponseItem(x);case 65:if(T=e.sent,E=this.modelManager.duplicateItemWithCustomContent({content:O,duplicateOf:S}),A=!E.isItemContentEqualWith(T),D=!S.isItemContentEqualWith(T),M=!1,N=!1,R=!1,I=!1,x.deleted||S.deleted?I=!0:A?(new Date-S.client_updated_at)/1e3<20?(R=!0,N=!0):(M=!0,I=!0):D?P.AreItemContentsEqual({leftContent:S.content,rightContent:T.content,keysToIgnore:S.keysToIgnoreWhenCheckingContentEquality().concat(["references"]),appDataKeysToIgnore:S.appDataKeysToIgnoreWhenCheckingContentEquality()})?R=!0:(M=!0,I=!0):I=!0,!M){e.next=79;break}return e.next=77,this.modelManager.duplicateItemWithCustomContentAndAddAsConflict({content:O,duplicateOf:S});case 77:L=e.sent,p.push(L);case 79:if(N&&(this.modelManager.addDuplicatedItemAsConflict({duplicate:T,duplicateOf:S}),p.push(T)),!I){e.next=83;break}return e.next=83,this.modelManager.mapResponseItemsToLocalModelsOmittingFields([x],null,C.MappingSourceRemoteRetrieved);case 83:R&&(S.updated_at=T.updated_at,S.setDirty(!0)),e.next=88;break;case 86:return console.error("Unsupported conflict type",k.type),e.abrupt("continue",88);case 88:g=!0,e.next=41;break;case 91:e.next=97;break;case 93:e.prev=93,e.t4=e.catch(39),m=!0,v=e.t4;case 97:e.prev=97,e.prev=98,g||null==y.return||y.return();case 100:if(e.prev=100,!m){e.next=103;break}throw v;case 103:return e.finish(100);case 104:return e.finish(97);case 105:return e.abrupt("return",p);case 106:case"end":return e.stop()}}),e,this,[[7,23,27,35],[28,,30,34],[39,93,97,105],[98,,100,104]])}))),function(t){return a.apply(this,arguments)})},{key:"deprecated_handleUnsavedItemsResponse",value:(o=v(r.mark((function e(n){var i,o,a,s,u,l,c,h,f,d;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n&&0!=n.length){e.next=2;break}return e.abrupt("return");case 2:this.loggingEnabled&&console.log("Handle Unsaved Items:",n),i=!0,o=!1,a=void 0,e.prev=6,s=n[Symbol.iterator]();case 8:if(i=(u=s.next()).done){e.next=35;break}return l=u.value,c=l.item,e.t0=SFJS.itemTransformer,e.t1=[c],e.next=15,this.getActiveKeyInfo(t.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(h=this.modelManager.findItem(c.uuid)){e.next=21;break}return e.abrupt("continue",32);case 21:if("uuid_conflict"!==(f=l.error).tag){e.next=27;break}return e.next=25,this.modelManager.alternateUUIDForItem(h);case 25:e.next=32;break;case 27:if("sync_conflict"!==f.tag){e.next=32;break}return e.next=30,this.modelManager.createDuplicateItemFromResponseItem(c);case 30:d=e.sent,c.deleted||h.isItemContentEqualWith(d)||this.modelManager.addDuplicatedItemAsConflict({duplicate:d,duplicateOf:h});case 32:i=!0,e.next=8;break;case 35:e.next=41;break;case 37:e.prev=37,e.t3=e.catch(6),o=!0,a=e.t3;case 41:e.prev=41,e.prev=42,i||null==s.return||s.return();case 44:if(e.prev=44,!o){e.next=47;break}throw a;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(t){return o.apply(this,arguments)})},{key:"stateless_downloadAllItems",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(){var i=v(r.mark((function i(o,a){var s;return r.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s={limit:n.limit||500,sync_token:n.syncToken,cursor_token:n.cursorToken,content_type:n.contentType,event:n.event,api:S.getApiVersion()},i.prev=1,i.t0=e.httpManager,i.next=5,e.getSyncURL();case 5:i.t1=i.sent,i.t2=s,i.t3=function(){var i=v(r.mark((function i(a){var s,u;return r.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n.retrievedItems||(n.retrievedItems=[]),s=a.retrieved_items,r.next=4,e.getActiveKeyInfo(t.KeyRequestLoadSaveAccount);case 4:return u=r.sent.keys,r.next=7,SFJS.itemTransformer.decryptMultipleItems(s,u);case 7:n.retrievedItems=n.retrievedItems.concat(s.map((function(t){return e.modelManager.createItem(t)}))),n.syncToken=a.sync_token,n.cursorToken=a.cursor_token,n.cursorToken?e.stateless_downloadAllItems(n).then(o):o(n.retrievedItems);case 11:case"end":return r.stop()}}),i)})));return function(t){return i.apply(this,arguments)}}(),i.t4=function(t,e){a(t)},i.t0.postAuthenticatedAbsolute.call(i.t0,i.t1,i.t2,i.t3,i.t4),i.next=16;break;case 12:i.prev=12,i.t5=i.catch(1),console.log("Download all items exception caught:",i.t5),a(i.t5);case 16:case"end":return i.stop()}}),i,null,[[1,12]])})));return function(t,e){return i.apply(this,arguments)}}())}},{key:"resolveOutOfSync",value:(i=v(r.mark((function t(){var e=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.stateless_downloadAllItems({event:"resolve-out-of-sync"}).then(function(){var t=v(r.mark((function t(n){var i,o,a,s,u,l,c,h;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=[],o=!0,a=!1,s=void 0,t.prev=4,u=n[Symbol.iterator]();case 6:if(o=(l=u.next()).done){t.next=18;break}if(c=l.value,!(h=e.modelManager.findItem(c.uuid))){t.next=14;break}if(c.isItemContentEqualWith(h)){t.next=14;break}return t.next=14,e.modelManager.duplicateItemAndAddAsConflict(h);case 14:i.push(c);case 15:o=!0,t.next=6;break;case 18:t.next=24;break;case 20:t.prev=20,t.t0=t.catch(4),a=!0,s=t.t0;case 24:t.prev=24,t.prev=25,o||null==u.return||u.return();case 27:if(t.prev=27,!a){t.next=30;break}throw s;case 30:return t.finish(27);case 31:return t.finish(24);case 32:return t.next=34,e.modelManager.mapResponseItemsToLocalModelsWithOptions({items:i,source:C.MappingSourceRemoteRetrieved});case 34:return t.next=36,e.writeItemsToLocalStorage(e.modelManager.allNondummyItems);case 36:return t.abrupt("return",e.sync({performIntegrityCheck:!0}));case 37:case"end":return t.stop()}}),t,null,[[4,20,24,32],[25,,27,31]])})));return function(e){return t.apply(this,arguments)}}()));case 1:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"handleSignout",value:(n=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.outOfSync=!1,this.loadLocalDataPromise=null,this.performSyncAgainOnCompletion=!1,this.syncStatus.syncOpInProgress=!1,this._queuedCallbacks=[],this.syncStatus={},t.abrupt("return",this.clearSyncToken());case 7:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"clearSyncToken",value:(e=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._syncToken=null,this._cursorToken=null,t.abrupt("return",this.storageManager.removeItem("syncToken"));case 3:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"__setLocalDataNotLoaded",value:function(){this.loadLocalDataPromise=null,this._initialDataLoaded=!1}},{key:"queuedCallbacks",get:function(){return this._queuedCallbacks||(this._queuedCallbacks=[]),this._queuedCallbacks}}]),t}();i.SFSyncManager=R;var P=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y(this,t),this.content={},this.referencingObjects=[],this.updateFromJSON(e),this.uuid||"undefined"!=typeof SFJS&&SFJS.crypto.generateUUIDSync&&(this.uuid=SFJS.crypto.generateUUIDSync()),"object"!==g(this.content)||this.content.references||(this.content.references=[])}var e;return k(t,[{key:"initUUID",value:(e=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.uuid){t.next=4;break}return t.next=3,SFJS.crypto.generateUUID();case 3:this.uuid=t.sent;case 4:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"updateFromJSON",value:function(e){if(e){this.deleted=e.deleted,this.uuid=e.uuid,this.enc_item_key=e.enc_item_key,this.auth_hash=e.auth_hash,this.auth_params=e.auth_params;for(var n=0,r=["errorDecrypting","dirty","dirtyCount","dirtiedDate","dummy"];n"==n.operator?g>p:"<="==n.operator?g<=p:">="==n.operator?g>=p:"startsWith"==n.operator?g.startsWith(p):"in"==n.operator?-1!=p.indexOf(g):"includes"==n.operator?this.resolveIncludesPredicate(g,p):"matches"==n.operator&&new RegExp(p).test(g)}},{key:"resolveIncludesPredicate",value:function(e,n){if("string"==typeof n)return e.includes(n);var r;r=Array.isArray(n)?t.fromArray(n):n;var i=!0,o=!1,a=void 0;try{for(var s,u=e[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;if(this.ObjectSatisfiesPredicate(l,r))return!0}}catch(t){o=!0,a=t}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}return!1}},{key:"ItemSatisfiesPredicate",value:function(e,n){return Array.isArray(n)&&(n=t.fromArray(n)),this.ObjectSatisfiesPredicate(e,n)}},{key:"ItemSatisfiesPredicates",value:function(t,e){var n=!0,r=!1,i=void 0;try{for(var o,a=e[Symbol.iterator]();!(n=(o=a.next()).done);n=!0){var s=o.value;if(!this.ItemSatisfiesPredicate(t,s))return!1}}catch(t){r=!0,i=t}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}return!0}},{key:"DateFromString",value:function(t){var e=t.split("."),n=e[1],r=new Date,i=parseInt(e[0]);return"days"==n?r.setDate(r.getDate()-i):"hours"==n&&r.setHours(r.getHours()-i),r}},{key:"IsRecursiveOperator",value:function(t){return["and","or"].includes(t)}}]),t}();i.SFPredicate=L;var F=function(t){function e(t){var n;return y(this,e),(n=c(this,h(e).call(this,t))).content.desktopPrivileges||(n.content.desktopPrivileges={}),n}return f(e,t),k(e,null,[{key:"contentType",value:function(){return"SN|Privileges"}}]),k(e,[{key:"setCredentialsForAction",value:function(t,e){this.content.desktopPrivileges[t]=e}},{key:"getCredentialsForAction",value:function(t){return this.content.desktopPrivileges[t]||[]}},{key:"toggleCredentialForAction",value:function(t,e){this.isCredentialRequiredForAction(t,e)?this.removeCredentialForAction(t,e):this.addCredentialForAction(t,e)}},{key:"removeCredentialForAction",value:function(t,e){_.pull(this.content.desktopPrivileges[t],e)}},{key:"addCredentialForAction",value:function(t,e){var n=this.getCredentialsForAction(t);n.push(e),this.setCredentialsForAction(t,n)}},{key:"isCredentialRequiredForAction",value:function(t,e){return this.getCredentialsForAction(t).includes(e)}}]),e}(P);i.SFPrivileges=F;var B=function(t){function e(t){var n;return y(this,e),(n=c(this,h(e).call(this,t))).content.itemUUIDToItemHistoryMapping||(n.content.itemUUIDToItemHistoryMapping={}),Object.keys(n.content.itemUUIDToItemHistoryMapping).forEach((function(t){var e=n.content.itemUUIDToItemHistoryMapping[t];n.content.itemUUIDToItemHistoryMapping[t]=new Q(e)})),n}return f(e,t),k(e,[{key:"addEntryForItem",value:function(t){return this.historyForItem(t).addHistoryEntryForItem(t)}},{key:"historyForItem",value:function(t){var e=this.content.itemUUIDToItemHistoryMapping[t.uuid];return e||(e=this.content.itemUUIDToItemHistoryMapping[t.uuid]=new Q),e}},{key:"clearItemHistory",value:function(t){this.historyForItem(t).clear()}},{key:"clearAllHistory",value:function(){this.content.itemUUIDToItemHistoryMapping={}}},{key:"optimizeHistoryForItem",value:function(t){var n=this.historyForItem(t);n.entries.length>e.LargeItemEntryAmountThreshold&&n.optimize()}}]),e}(P);i.SFHistorySession=B,B.LargeItemEntryAmountThreshold=60;var Q=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(y(this,t),this.entries||(this.entries=[]),e.entries){var n=!0,r=!1,i=void 0;try{for(var o,a=e.entries[Symbol.iterator]();!(n=(o=a.next()).done);n=!0){var s=o.value,u=this.createEntryForItem(s.item);u.setPreviousEntry(this.getLastEntry()),this.entries.push(u)}}catch(t){r=!0,i=t}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}}}return k(t,[{key:"createEntryForItem",value:function(e){var n=t.HistoryEntryClassMapping&&t.HistoryEntryClassMapping[e.content_type];return n||(n=z),new n(e)}},{key:"getLastEntry",value:function(){return this.entries[this.entries.length-1]}},{key:"addHistoryEntryForItem",value:function(t){var e=this.createEntryForItem(t),n=this.getLastEntry();if(e.setPreviousEntry(n),!e.isSameAsEntry(n))return this.entries.push(e),e}},{key:"clear",value:function(){this.entries.length=0}},{key:"optimize",value:function(){var e=this,n=[],r=function(e){return e.deltaSize()>t.LargeEntryDeltaThreshold},i=function(t,i,o){if(o?n.push(t):-1!==(i=n.indexOf(t))&&n.splice(i,1),o&&r(t)&&-1==t.operationVector()){var a=e.entries[i-1];a&&n.push(a)}};this.entries.forEach((function(t,n){if(0==n||n==e.entries.length-1)i(t,n,!0);else{var o=r(t);i(t,n,o)}})),this.entries=this.entries.filter((function(t,e){return-1!==n.indexOf(t)}))}}]),t}();i.SFItemHistory=Q,Q.LargeEntryDeltaThreshold=15;var z=function(){function t(e){y(this,t),this.item=P.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 k(t,[{key:"setPreviousEntry",value:function(t){this.hasPreviousEntry=null!=t,this.item.content[this.defaultContentKeyToDiffOn]&&(this.textCharDiffLength=t?this.item.content[this.defaultContentKeyToDiffOn].length-t.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(t){if(!t)return!1;var e=new P(this.item),n=new P(t.item);return e.isItemContentEqualWith(n)}}]),t}();i.SFItemHistoryEntry=z,O="undefined"!=typeof window?window:void 0!==t?t:null;var $=function(){function t(){y(this,t),this.DefaultPBKDF2Length=768}var e,n,i,o,a,s,u,c,h,f,d,p,g,m,b;return k(t,[{key:"generateUUIDSync",value:function(){var t=O.crypto||O.msCrypto;if(t){var e=new Uint32Array(4);t.getRandomValues(e);var n=-1;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){n++;var r=e[n>>3]>>n%8*4&15;return("x"==t?r:3&r|8).toString(16)}))}var r=(new Date).getTime();return O.performance&&"function"==typeof O.performance.now&&(r+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==t?e:3&e|8).toString(16)}))}},{key:"generateUUID",value:(b=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.generateUUIDSync());case 1:case"end":return t.stop()}}),t,this)}))),function(){return b.apply(this,arguments)})},{key:"timingSafeEqual",value:function(t,e){var n=String(t),r=String(e),i=n.length,o=0;i!==r.length&&(r=n,o=1);for(var a=0;a0&&void 0!==p[0]?p[0]:{},n=e.ciphertextToAuth,i=e.contentCiphertext,o=e.encryptionKey,a=e.iv,s=e.authHash,u=e.authKey,!(p.length>1?p[1]:void 0)||s){t.next=5;break}return console.error("Auth hash is required."),t.abrupt("return");case 5:if(!s){t.next=12;break}return t.next=8,this.hmac256(n,u);case 8:if(c=t.sent,!1!==this.timingSafeEqual(s,c)){t.next=12;break}return console.error("Auth hash does not match, returning null."),t.abrupt("return",null);case 12:return h=l.enc.Hex.parse(o),f=l.enc.Hex.parse(a||""),d=l.AES.decrypt(i,h,{iv:f,mode:l.mode.CBC,padding:l.pad.Pkcs7}),t.abrupt("return",d.toString(l.enc.Utf8));case 16:case"end":return t.stop()}}),t,this)}))),function(){return m.apply(this,arguments)})},{key:"encryptText",value:(g=v(r.mark((function t(e,n,i){var o,a,s;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=l.enc.Hex.parse(n),a=l.enc.Hex.parse(i||""),s=l.AES.encrypt(e,o,{iv:a,mode:l.mode.CBC,padding:l.pad.Pkcs7}),t.abrupt("return",s.toString());case 4:case"end":return t.stop()}}),t)}))),function(t,e,n){return g.apply(this,arguments)})},{key:"generateRandomKey",value:(p=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",l.lib.WordArray.random(e/8).toString());case 1:case"end":return t.stop()}}),t)}))),function(t){return p.apply(this,arguments)})},{key:"generateItemEncryptionKey",value:(d=v(r.mark((function t(){var e,n,i,o;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=512,n=1,t.next=4,this.generateRandomKey(e);case 4:return i=t.sent,t.next=7,this.generateRandomKey(e);case 7:return o=t.sent,t.abrupt("return",this.pbkdf2(o,i,n,e));case 9:case"end":return t.stop()}}),t,this)}))),function(){return d.apply(this,arguments)})},{key:"firstHalfOfKey",value:(f=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(0,e.length/2));case 1:case"end":return t.stop()}}),t)}))),function(t){return f.apply(this,arguments)})},{key:"secondHalfOfKey",value:(h=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(e.length/2,e.length));case 1:case"end":return t.stop()}}),t)}))),function(t){return h.apply(this,arguments)})},{key:"base64",value:(c=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",O.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(function(t,e){return String.fromCharCode("0x"+e)}))));case 1:case"end":return t.stop()}}),t)}))),function(t){return c.apply(this,arguments)})},{key:"base64Decode",value:(u=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",O.atob(e));case 1:case"end":return t.stop()}}),t)}))),function(t){return u.apply(this,arguments)})},{key:"sha256",value:(s=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",l.SHA256(e).toString());case 1:case"end":return t.stop()}}),t)}))),function(t){return s.apply(this,arguments)})},{key:"hmac256",value:(a=v(r.mark((function t(e,n){var i,o,a;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=l.enc.Hex.parse(n),o=l.enc.Utf8.parse(e),a=l.HmacSHA256(o,i).toString(),t.abrupt("return",a);case 4:case"end":return t.stop()}}),t)}))),function(t,e){return a.apply(this,arguments)})},{key:"generateSalt",value:(o=v(r.mark((function t(e,n,i,o){var a;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sha256([e,"SF",n,i,o].join(":"));case 2:return a=t.sent,t.abrupt("return",a);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e,n,r){return o.apply(this,arguments)})},{key:"generateSymmetricKeyPair",value:(i=v(r.mark((function t(){var e,n,i,o,a,s,u,l,c,h,f=arguments;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=f.length>0&&void 0!==f[0]?f[0]:{},n=e.password,i=e.pw_salt,o=e.pw_cost,t.next=3,this.pbkdf2(n,i,o,this.DefaultPBKDF2Length);case 3:return a=t.sent,s=a.length,u=s/3,l=a.slice(0,u),c=a.slice(u,2*u),h=a.slice(2*u,3*u),t.abrupt("return",[l,c,h]);case 10:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"computeEncryptionKeysForUser",value:(n=v(r.mark((function t(e,n){var i;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("003"!=n.version){t.next=9;break}if(n.identifier){t.next=4;break}return console.error("authParams is missing identifier."),t.abrupt("return");case 4:return t.next=6,this.generateSalt(n.identifier,n.version,n.pw_cost,n.pw_nonce);case 6:i=t.sent,t.next=10;break;case 9:i=n.pw_salt;case 10:return t.abrupt("return",this.generateSymmetricKeyPair({password:e,pw_salt:i,pw_cost:n.pw_cost}).then((function(t){return{pw:t[0],mk:t[1],ak:t[2]}})));case 11:case"end":return t.stop()}}),t,this)}))),function(t,e){return n.apply(this,arguments)})},{key:"generateInitialKeysAndAuthParamsForUser",value:(e=v(r.mark((function t(e,n){var i,o,a,s;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=this.SFJS.version,o=this.SFJS.defaultPasswordGenerationCost,t.next=4,this.generateRandomKey(256);case 4:return a=t.sent,t.next=7,this.generateSalt(e,i,o,a);case 7:return s=t.sent,t.abrupt("return",this.generateSymmetricKeyPair({password:n,pw_salt:s,pw_cost:o}).then((function(t){var n={pw_nonce:a,pw_cost:o,identifier:e,version:i};return{keys:{pw:t[0],mk:t[1],ak:t[2]},authParams:n}})));case 9:case"end":return t.stop()}}),t,this)}))),function(t,n){return e.apply(this,arguments)})}]),t}();i.SFAbstractCrypto=$;var j=function(t){function e(){return y(this,e),c(this,h(e).apply(this,arguments))}var n;return f(e,t),k(e,[{key:"pbkdf2",value:(n=v(r.mark((function t(e,n,i,o){var a;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={keySize:o/32,hasher:l.algo.SHA512,iterations:i},t.abrupt("return",l.PBKDF2(e,n,a).toString());case 2:case"end":return t.stop()}}),t)}))),function(t,e,r,i){return n.apply(this,arguments)})}]),e}($);i.SFCryptoJS=j;var W=(O="undefined"!=typeof window?window:void 0!==t?t:null).crypto?O.crypto.subtle:null,U=function(t){function e(){return y(this,e),c(this,h(e).apply(this,arguments))}var n,i,o,a,s,u,l,d,p,g,m,b,x,w;return f(e,t),k(e,[{key:"pbkdf2",value:(w=v(r.mark((function t(e,n,i,o){var a;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.webCryptoImportKey(e,"PBKDF2",["deriveBits"]);case 2:if(a=t.sent){t.next=6;break}return console.log("Key is null, unable to continue"),t.abrupt("return",null);case 6:return t.abrupt("return",this.webCryptoDeriveBits(a,n,i,o));case 7:case"end":return t.stop()}}),t,this)}))),function(t,e,n,r){return w.apply(this,arguments)})},{key:"generateRandomKey",value:(x=v(r.mark((function t(e){var n=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",W.generateKey({name:"AES-CBC",length:e},!0,["encrypt","decrypt"]).then((function(t){return W.exportKey("raw",t).then(function(){var t=v(r.mark((function t(e){var i;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.arrayBufferToHexString(new Uint8Array(e));case 2:return i=t.sent,t.abrupt("return",i);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()).catch((function(t){console.error("Error exporting key",t)}))})).catch((function(t){console.error("Error generating key",t)})));case 2:case"end":return t.stop()}}),t)}))),function(t){return x.apply(this,arguments)})},{key:"generateItemEncryptionKey",value:(b=v(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Promise.all([this.generateRandomKey(256),this.generateRandomKey(256)]).then((function(t){return t.join("")})));case 2:case"end":return t.stop()}}),t,this)}))),function(){return b.apply(this,arguments)})},{key:"encryptText",value:(m=v(r.mark((function t(e,n,i){var o,a,s,u,l,c=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!i){t.next=6;break}return t.next=3,this.hexStringToArrayBuffer(i);case 3:t.t0=t.sent,t.next=7;break;case 6:t.t0=new ArrayBuffer(16);case 7:return o=t.t0,a={name:"AES-CBC",iv:o},t.next=11,this.hexStringToArrayBuffer(n);case 11:return s=t.sent,t.next=14,this.webCryptoImportKey(s,a.name,["encrypt"]);case 14:return u=t.sent,t.next=17,this.stringToArrayBuffer(e);case 17:return l=t.sent,t.abrupt("return",crypto.subtle.encrypt(a,u,l).then(function(){var t=v(r.mark((function t(e){var n;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.arrayBufferToBase64(e);case 2:return n=t.sent,t.abrupt("return",n);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 19:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return m.apply(this,arguments)})},{key:"decryptText",value:(g=v(r.mark((function t(){var e,n,i,o,a,s,u,l,c,h,f,d,p,g=this,m=arguments;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=m.length>0&&void 0!==m[0]?m[0]:{},n=e.ciphertextToAuth,i=e.contentCiphertext,o=e.encryptionKey,a=e.iv,s=e.authHash,u=e.authKey,!(m.length>1?m[1]:void 0)||s){t.next=5;break}return console.error("Auth hash is required."),t.abrupt("return");case 5:if(!s){t.next=12;break}return t.next=8,this.hmac256(n,u);case 8:if(l=t.sent,!1!==this.timingSafeEqual(s,l)){t.next=12;break}return console.error("Auth hash does not match, returning null. ".concat(s," != ").concat(l)),t.abrupt("return",null);case 12:if(!a){t.next=18;break}return t.next=15,this.hexStringToArrayBuffer(a);case 15:t.t0=t.sent,t.next=19;break;case 18:t.t0=new ArrayBuffer(16);case 19:return c=t.t0,h={name:"AES-CBC",iv:c},t.next=23,this.hexStringToArrayBuffer(o);case 23:return f=t.sent,t.next=26,this.webCryptoImportKey(f,h.name,["decrypt"]);case 26:return d=t.sent,t.next=29,this.base64ToArrayBuffer(i);case 29:return p=t.sent,t.abrupt("return",crypto.subtle.decrypt(h,d,p).then(function(){var t=v(r.mark((function t(e){var n;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,g.arrayBufferToString(e);case 2:return n=t.sent,t.abrupt("return",n);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()).catch((function(t){console.error("Error decrypting:",t)})));case 31:case"end":return t.stop()}}),t,this)}))),function(){return g.apply(this,arguments)})},{key:"hmac256",value:(p=v(r.mark((function t(e,n){var i,o,a,s=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.hexStringToArrayBuffer(n);case 2:return i=t.sent,t.next=5,this.webCryptoImportKey(i,"HMAC",["sign"],{name:"SHA-256"});case 5:return o=t.sent,t.next=8,this.stringToArrayBuffer(e);case 8:return a=t.sent,t.abrupt("return",crypto.subtle.sign({name:"HMAC"},o,a).then(function(){var t=v(r.mark((function t(e){var n;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.arrayBufferToHexString(e);case 2:return n=t.sent,t.abrupt("return",n);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()).catch((function(t){console.error("Error computing hmac",t)})));case 10:case"end":return t.stop()}}),t,this)}))),function(t,e){return p.apply(this,arguments)})},{key:"webCryptoImportKey",value:(d=v(r.mark((function t(e,n,i,o){var a;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof e){t.next=6;break}return t.next=3,this.stringToArrayBuffer(e);case 3:t.t0=t.sent,t.next=7;break;case 6:t.t0=e;case 7:return a=t.t0,t.abrupt("return",W.importKey("raw",a,{name:n,hash:o},!1,i).then((function(t){return t})).catch((function(t){return console.error(t),null})));case 9:case"end":return t.stop()}}),t,this)}))),function(t,e,n,r){return d.apply(this,arguments)})},{key:"webCryptoDeriveBits",value:(l=v(r.mark((function t(e,n,i,o){var a,s=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.stringToArrayBuffer(n);case 2:return t.t0=t.sent,t.t1=i,t.t2={name:"SHA-512"},a={name:"PBKDF2",salt:t.t0,iterations:t.t1,hash:t.t2},t.abrupt("return",W.deriveBits(a,e,o).then(function(){var t=v(r.mark((function t(e){var n;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.arrayBufferToHexString(new Uint8Array(e));case 2:return n=t.sent,t.abrupt("return",n);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()).catch((function(t){return console.error(t),null})));case 7:case"end":return t.stop()}}),t,this)}))),function(t,e,n,r){return l.apply(this,arguments)})},{key:"stringToArrayBuffer",value:(u=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){var r=new Blob([e]),i=new FileReader;i.onload=function(e){t(e.target.result)},i.readAsArrayBuffer(r)})));case 1:case"end":return t.stop()}}),t)}))),function(t){return u.apply(this,arguments)})},{key:"arrayBufferToString",value:(s=v(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){var r=new Blob([e]),i=new FileReader;i.onload=function(e){t(e.target.result)},i.readAsText(r)})));case 1:case"end":return t.stop()}}),t)}))),function(t){return s.apply(this,arguments)})},{key:"arrayBufferToHexString",value:(a=v(r.mark((function t(e){var n,i,o,a;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=new Uint8Array(e),i="",a=0;a5e3)||this.crypto instanceof U}},{key:"supportedVersions",value:function(){return["001","002","003"]}},{key:"isVersionNewerThanLibraryVersion",value:function(t){var e=this.version();return parseInt(t)>parseInt(e)}},{key:"isProtocolVersionOutdated",value:function(t){var e={"001":Date.parse("2018-01-01"),"002":Date.parse("2020-01-01")}[t];return!!e&&new Date>e}},{key:"costMinimumForVersion",value:function(t){return{"001":3e3,"002":3e3,"003":11e4}[t]}},{key:"defaultPasswordGenerationCost",value:function(){return this.costMinimumForVersion(this.version())}}]),t}();if(i.StandardFile=V,O)try{O.StandardFile=V,O.SFJS=new V,O.SFCryptoWeb=U,O.SFCryptoJS=j,O.SFItemTransformer=q,O.SFModelManager=C,O.SFItem=P,O.SFItemParams=I,O.SFHttpManager=S,O.SFStorageManager=M,O.SFSyncManager=R,O.SFAuthManager=w,O.SFMigrationManager=T,O.SFAlertManager=x,O.SFPredicate=L,O.SFHistorySession=B,O.SFSessionHistoryManager=A,O.SFItemHistory=Q,O.SFItemHistoryEntry=z,O.SFPrivilegesManager=E,O.SFPrivileges=F,O.SFSingletonManager=D}catch(t){console.log("Exception while exporting window variables",t)}}).call(this,void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}).call(this,n(2))},function(t,e){!function(e){"use strict";var n=Object.prototype,r=n.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag",u="object"==typeof t,l=e.regeneratorRuntime;if(l)u&&(t.exports=l);else{(l=e.regeneratorRuntime=u?t.exports:{}).wrap=g;var c={},h={};h[o]=function(){return this};var f=Object.getPrototypeOf,d=f&&f(f(T([])));d&&d!==n&&r.call(d,o)&&(h=d);var p=b.prototype=v.prototype=Object.create(h);y.prototype=p.constructor=b,b.constructor=y,b[s]=y.displayName="GeneratorFunction",l.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},l.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s in t||(t[s]="GeneratorFunction")),t.prototype=Object.create(p),t},l.awrap=function(t){return{__await:t}},k(x.prototype),x.prototype[a]=function(){return this},l.AsyncIterator=x,l.async=function(t,e,n,r){var i=new x(g(t,e,n,r));return l.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},k(p),p[s]="Generator",p[o]=function(){return this},p.toString=function(){return"[object Generator]"},l.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},l.values=T,_.prototype={constructor:_,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),c}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:T(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}}}function g(t,e,n,r){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),a=new _(r||[]);return o._invoke=function(t,e,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=w(a,n);if(s){if(s===c)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 u=m(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(t,n,a),o}function m(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function v(){}function y(){}function b(){}function k(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function x(t){var e;this._invoke=function(n,i){function o(){return new Promise((function(e,o){!function e(n,i,o,a){var s=m(t[n],t,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==typeof l&&r.call(l,"__await")?Promise.resolve(l.__await).then((function(t){e("next",t,o,a)}),(function(t){e("throw",t,o,a)})):Promise.resolve(l).then((function(t){u.value=t,o(u)}),a)}a(s.arg)}(n,i,e,o)}))}return e=e?e.then(o,o):o()}}function w(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return c;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var r=m(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,c;var i=r.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,c):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,c)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function T(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n(e=q(e,t)).length)n=t;else{var r=0,i=-1,o=-1,a=(n=e).length;for(0>r&&(r=-r>a?0:a+r),0>(i=i>a?a:i)&&(i+=a),a=r>i?0:i-r>>>0,r>>>=0,i=Array(a);++oo?Yt:a,o=1),e=Object(e);++is))return!1;if((u=o.get(t))&&o.get(e))return u==e;var u=-1,l=!0,c=2&n?new _:Yt;for(o.set(t,e),o.set(e,t);++u(n=null==n?0:Nt(n))&&(n=qe(r+n,0)),p(t,rt(e,3),n)):-1}function vt(t){return null!=t&&t.length?function t(e,n,r,i,o){var a=-1,s=e.length;for(r||(r=ut),o||(o=[]);++a=t}function Tt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ct(t){return null!=t&&"object"==typeof t}function Et(t){return!(!Ct(t)||"[object Object]"!=L(t))&&(null===(t=Pe(t))||"function"==typeof(t=_e.call(t,"constructor")&&t.constructor)&&t instanceof t&&Se.call(t)==Ee)}function At(t){return"string"==typeof t||!wn(t)&&Ct(t)&&"[object String]"==L(t)}function Dt(t){return"symbol"==typeof t||Ct(t)&&"[object Symbol]"==L(t)}function Mt(t){return t?(t=Rt(t))===Xt||t===-Xt?17976931348623157e292*(0>t?-1:1):t==t?t:0:0===t?t:0}function Nt(t){var e=(t=Mt(t))%1;return t==t?e?t-e:t:0}function Rt(t){if("number"==typeof t)return t;if(Dt(t))return Gt;if(Tt(t)&&(t=Tt(t="function"==typeof t.valueOf?t.valueOf():t)?t+"":t),"string"!=typeof t)return 0===t?t:+t;t=t.replace(ee,"");var e=oe.test(t);return e||se.test(t)?fe(t.slice(2),e?2:8):ie.test(t)?Gt:+t}function Pt(t){return G(t,Qt(t))}function It(t){return null==t?"":W(t)}function Lt(t,e,n){return(t=null==t?Yt:P(t,e))===Yt?n:t}function Ft(t,e){var n;if(n=null!=t){for(var r,i=-1,o=(r=q(e,n=t)).length,a=!1;++i(t=D(e,t))||(t==e.length-1?e.pop():Fe.call(e,t,1),--this.size,0))},O.prototype.get=function(t){var e=this.__data__;return 0>(t=D(e,t))?Yt:e[t][1]},O.prototype.has=function(t){return-1r?(++this.size,n.push([t,e])):n[r][1]=e,this},S.prototype.clear=function(){this.size=0,this.__data__={hash:new w,map:new(Xe||O),string:new w}},S.prototype.delete=function(t){return t=it(this,t).delete(t),this.size-=t?1:0,t},S.prototype.get=function(t){return it(this,t).get(t)},S.prototype.has=function(t){return it(this,t).has(t)},S.prototype.set=function(t,e){var n=it(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},_.prototype.add=_.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},_.prototype.has=function(t){return this.__data__.has(t)},T.prototype.clear=function(){this.__data__=new O,this.size=0},T.prototype.delete=function(t){var e=this.__data__;return t=e.delete(t),this.size=e.size,t},T.prototype.get=function(t){return this.__data__.get(t)},T.prototype.has=function(t){return this.__data__.has(t)},T.prototype.set=function(t,e){var n=this.__data__;if(n instanceof O){var r=n.__data__;if(!Xe||199>r.length)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new S(r)}return n.set(t,e),this.size=n.size,this};var cn=function(t,e){if(null==t)return t;if(!wt(t))return function(t,e){return t&&hn(t,e,Bt)}(t,e);for(var n=t.length,r=-1,i=Object(t);++rn&&(n=qe(r+n,0)),At(t)?n<=r&&-1=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n=0?this.items[l]=u:this.items.push(u);case 13:e.next=3;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(1),o.e(e.t0);case 20:return e.prev=20,o.f(),e.finish(20);case 23:this.notifyObserversOfEvent(t.BridgeEventReceivedItems);case 24:case"end":return e.stop()}}),e,this,[[1,17,20,23]])}))),function(t){return c.apply(this,arguments)})},{key:"indexOfItem",value:function(t){for(var e in this.items)if(this.items[e].uuid==t.uuid)return e;return-1}},{key:"removeItemFromItems",value:function(t){this.items=this.items.filter((function(e){return e.uuid!==t.uuid}))}},{key:"createItem",value:function(t,e){this.createItems([t],e)}},{key:"createItems",value:function(t,e){this.componentManager.createItems(t,(function(t){e&&e(t.map((function(t){return new i.SFItem(t)})))}))}},{key:"saveItem",value:(u=a(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.saveItems([e]));case 1:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"saveItems",value:(o=a(r.mark((function e(n){var i=this;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,r){i.componentManager.saveItems(n,(function(n){e(n),i.notifyObserversOfEvent(t.BridgeEventSavedItem)}))})));case 1:case"end":return e.stop()}}),e)}))),function(t){return o.apply(this,arguments)})},{key:"indexOfItem",value:function(t){for(var e in this.items)if(this.items[e].uuid==t.uuid)return e;return-1}},{key:"deleteItem",value:function(t,e){this.deleteItems([t],e)}},{key:"deleteItems",value:function(t,e){this.componentManager.deleteItems(t,e)}},{key:"removeItemFromItems",value:function(t){this.items=this.items.filter((function(e){return e.uuid!==t.uuid}))}}])&&l(e.prototype,n),t}();function f(t,e,n,r,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,i)}function d(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(t){f(o,r,i,a,s,"next",t)}function s(t){f(o,r,i,a,s,"throw",t)}a(void 0)}))}}function p(t,e){for(var n=0;n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0){var i,o=m(e.integrations);try{for(o.s();!(i=o.n()).done;){var a=i.value;if(a!=t){e.setIntegrationAsDefault(a);break}}}catch(t){o.e(t)}finally{o.f()}}}))}},{key:"integrations",get:function(){return this.extensionBridge.filterItems(h.FileSafeIntegrationContentTypeKey)}}])&&b(e.prototype,n),t}();function x(t,e,n,r,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,i)}function w(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&(t=n.credentials[0]),t})),S(this,"setCredentialAsDefault",(function(t){var e=n.getDefaultCredentials();e&&(e.content.isDefault=!1),t.content.isDefault=!0,n.extensionBridge.saveItems([e,t])})),S(this,"deleteCredential",(function(t){n.extensionBridge.deleteItem(t)})),this.extensionBridge=r,this.onCredentialLoad=i,this.credentials=[],this.extensionBridge.addEventHandler((function(t){t==h.BridgeEventReceivedItems&&n.reloadCredentials()}))}var e,n,o,a;return e=t,(n=[{key:"reloadCredentials",value:function(){var t=this;this.credentials=[];var e=this.extensionBridge.filterItems(h.FileSafeCredentialsContentType);if(0!=e.length){var n,r=function(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return w(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(e);try{var i=function(){var e=n.value;t.credentials.find((function(t){t.uuid,e.uuid}))||t.credentials.push(e)};for(r.s();!(n=r.n()).done;)i()}catch(t){r.e(t)}finally{r.f()}this.onCredentialLoad(),this.credentials.length>0&&this.didLoadCredentials()}}},{key:"createNewCredentials",value:(o=r.mark((function t(){var e,n,o,a,s;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=256,t.next=3,SFJS.crypto.generateRandomKey(e);case 3:return n=t.sent,t.next=6,SFJS.crypto.generateRandomKey(e);case 6:return o=t.sent,t.next=9,SFJS.crypto.generateInitialKeysAndAuthParamsForUser(n,o);case 9:return(a=t.sent).isDefault=0==this.credentials.length,s=new i.SFItem({content_type:h.FileSafeCredentialsContentType,content:a}),this.extensionBridge.saveItem(s),this.didLoadCredentials(),t.abrupt("return",s);case 15:case"end":return t.stop()}}),t,this)})),a=function(){var t=this,e=arguments;return new Promise((function(n,r){var i=o.apply(t,e);function a(t){x(i,n,r,a,s,"next",t)}function s(t){x(i,n,r,a,s,"throw",t)}a(void 0)}))},function(){return a.apply(this,arguments)})},{key:"didLoadCredentials",value:function(){this.extensionBridge.notifyObserversOfEvent(h.BridgeEventLoadedCredentials)}},{key:"credentialForFileDescriptor",value:function(t){return this.credentials.find((function(e){return t.content.references.find((function(t){return t.uuid==e.uuid}))}))}},{key:"getAllCredentials",value:function(){return this.credentials}},{key:"saveCredential",value:function(t){this.extensionBridge.saveItem(t)}}])&&O(e.prototype,n),t}(),T=function(){return new Worker(n.p+"filesafe-js/EncryptionWorker.js")};function C(t,e,n,r,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,i)}function E(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(t){C(o,r,i,a,s,"next",t)}function s(t){C(o,r,i,a,s,"throw",t)}a(void 0)}))}}function A(t,e){for(var n=0;n3&&void 0!==arguments[3]&&arguments[3],o=document.createElement("a");o.setAttribute("download",e);var a=this.tempUrlForData(t,n);o.href=a,o.setAttribute("target","_blank"),i?window.location.href=o.href:(document.body.appendChild(o),o.click(),o.remove()),setTimeout((function(){r.revokeTempUrl(a)}),500)}},{key:"tempUrlForData",value:function(t,e){return window.URL.createObjectURL(new Blob([t],{type:e||"text/json"}))}},{key:"revokeTempUrl",value:function(t){window.URL.revokeObjectURL(t)}},{key:"copyTextToClipboard",value:function(t){if(window.clipboardData&&window.clipboardData.setData)return clipboardData.setData("Text",t);var e;if(document.queryCommandSupported&&document.queryCommandSupported("copy"))try{(e=document.createElement("textarea")).setAttribute("readonly",!0),e.setAttribute("contenteditable",!0),e.style.position="fixed",e.value=t,document.body.appendChild(e),e.focus(),e.select();var n=document.createRange();n.selectNodeContents(e);var r=window.getSelection();r.removeAllRanges(),r.addRange(n),e.setSelectionRange(0,e.value.length),document.execCommand("copy")}catch(t){console.error(t)}finally{document.body.removeChild(e)}}}],null&&N(e.prototype,null),n&&N(e,n),t}();function P(t,e,n,r,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,i)}function I(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(t){P(o,r,i,a,s,"next",t)}function s(t){P(o,r,i,a,s,"throw",t)}a(void 0)}))}}function L(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return F(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?F(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function F(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&this.getAllIntegrations().length>0),e=Boolean(this.getAllFileDescriptors().length>0);return t||e}}]),t}()}])},586:function(t){t.exports=function(t){return null!=t&&null!=t.constructor&&"function"===typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}},725:function(t){"use strict";var e=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function i(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(t){r[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(i){return!1}}()?Object.assign:function(t,o){for(var a,s,u=i(t),l=1;l