diff --git a/app/App.js b/app/App.js index 5b4485a..9b2f47f 100644 --- a/app/App.js +++ b/app/App.js @@ -82,8 +82,8 @@ export default class App extends React.Component {
-
-
{this.state.expanded ? "Collapse" : "Expand"}
+
+
{this.state.expanded ? "▲" : "▼"}
); diff --git a/app/stylesheets/main.scss b/app/stylesheets/main.scss index 7a8d7b6..521e35b 100644 --- a/app/stylesheets/main.scss +++ b/app/stylesheets/main.scss @@ -21,4 +21,5 @@ html, body { position: absolute; top: 1.1rem; right: 2rem; + box-shadow: #00000036 0 0 10px; } diff --git a/dist/dist.css b/dist/dist.css index 316376a..e5cda7f 100644 --- a/dist/dist.css +++ b/dist/dist.css @@ -2055,4 +2055,5 @@ html, body { #expand-button { position: absolute; top: 1.1rem; - right: 2rem; } + right: 2rem; + box-shadow: #00000036 0 0 10px; } diff --git a/dist/dist.js b/dist/dist.js index e8a1806..3ef96f5 100644 --- a/dist/dist.js +++ b/dist/dist.js @@ -1153,11 +1153,11 @@ var App = function (_React$Component) { _react2.default.createElement("div", { id: "embed" }), _react2.default.createElement( "div", - { id: "expand-button", className: "sk-button neutral no-border", onClick: this.toggleHeight.bind(this) }, + { id: "expand-button", className: "sk-button sk-secondary no-border", onClick: this.toggleHeight.bind(this) }, _react2.default.createElement( "div", { className: "sk-label" }, - this.state.expanded ? "Collapse" : "Expand" + this.state.expanded ? "▲" : "▼" ) ) ); diff --git a/dist/dist.min.js b/dist/dist.min.js index a06339a..4f54d00 100644 --- a/dist/dist.min.js +++ b/dist/dist.min.js @@ -3,4 +3,4 @@ object-assign (c) Sindre Sorhus @license MIT */ -var i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,s,u=r(e),c=1;cD.length&&D.push(e)}function p(e,t,n,i){var a=typeof e;if("undefined"!==a&&"boolean"!==a||(e=null),null===e||"string"===a||"number"===a||"object"===a&&e.$$typeof===F)return n(i,e,""===t?"."+h(e,0):t),1;var o=0;if(t=""===t?".":t+":",Array.isArray(e))for(var s=0;s=V(e.last.priorityLevel,t))n=e.last;else for(e=e.first;null!==e&&0>=V(e.priorityLevel,t);)n=e,e=e.next;return n}function G(e,t){var n=e.alternate,r=e.updateQueue;null===r&&(r=e.updateQueue=J()),null!==n?null===(e=n.updateQueue)&&(e=n.updateQueue=J()):e=null,Tr=r,Nr=e!==r?e:null;var i=Tr;n=Nr;var a=$(i,t),o=null!==a?a.next:i.first;return null===n?(q(i,t,a,o),null):(r=$(n,t),e=null!==r?r.next:n.first,q(i,t,a,o),o===e&&null!==o||a===r&&null!==a?(null===r&&(n.first=t),null===e&&(n.last=null),null):(t={priorityLevel:t.priorityLevel,partialState:t.partialState,callback:t.callback,isReplace:t.isReplace,isForced:t.isForced,isTopLevelUnmount:t.isTopLevelUnmount,next:null},q(n,t,r,e),t))}function Q(e,t,n,r){return e=e.partialState,"function"==typeof e?e.call(t,n,r):e}function Y(e,t,n){e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=n}function X(e){return e.tag===zr&&null!=e.type.childContextTypes}function Z(e,t){var n=e.stateNode,i=e.type.childContextTypes;if("function"!=typeof n.getChildContext)return t;n=n.getChildContext();for(var a in n)a in i||r("108",p(e)||"Unknown",a);return gt({},t,n)}function ee(e,t,n){this.tag=e,this.key=t,this.stateNode=this.type=null,this.sibling=this.child=this.return=null,this.index=0,this.memoizedState=this.updateQueue=this.memoizedProps=this.pendingProps=this.ref=null,this.internalContextTag=n,this.effectTag=ci,this.lastEffect=this.firstEffect=this.nextEffect=null,this.pendingWorkPriority=si,this.alternate=null}function te(e,t,n){var i=void 0;return"function"==typeof e?(i=e.prototype&&e.prototype.isReactComponent?new ee(Zr,t,n):new ee(Xr,t,n),i.type=e):"string"==typeof e?(i=new ee(ti,t,n),i.type=e):"object"==typeof e&&null!==e&&"number"==typeof e.tag?i=e:r("130",null==e?e:typeof e,""),i}function ne(e){return null===e||void 0===e?null:(e=Hi&&e[Hi]||e["@@iterator"],"function"==typeof e?e:null)}function re(e,t){var n=t.ref;if(null!==n&&"function"!=typeof n){if(t._owner){t=t._owner;var i=void 0;t&&("number"==typeof t.tag?(t.tag!==Di&&r("110"),i=t.stateNode):i=t.getPublicInstance()),i||r("147",n);var a=""+n;return null!==e&&null!==e.ref&&e.ref._stringRef===a?e.ref:(e=function(e){var t=i.refs===kt?i.refs={}:i.refs;null===e?delete t[a]:t[a]=e},e._stringRef=a,e)}"string"!=typeof n&&r("148"),t._owner||r("149",n)}return n}function ie(e,t){"textarea"!==e.type&&r("31","[object Object]"===Object.prototype.toString.call(t)?"object with keys {"+Object.keys(t).join(", ")+"}":t,"")}function ae(e,t){function n(n,r){if(t){if(!e){if(null===r.alternate)return;r=r.alternate}var i=n.lastEffect;null!==i?(i.nextEffect=r,n.lastEffect=r):n.firstEffect=n.lastEffect=r,r.nextEffect=null,r.effectTag=Li}}function i(e,r){if(!t)return null;for(;null!==r;)n(e,r),r=r.sibling;return null}function a(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function o(t,n){return e?(t=xi(t,n),t.index=0,t.sibling=null,t):(t.pendingWorkPriority=n,t.effectTag=ji,t.index=0,t.sibling=null,t)}function s(e,n,r){return e.index=r,t?null!==(r=e.alternate)?(r=r.index,rp?(h=f,f=null):h=f.sibling;var d=v(e,f,o[p],u);if(null===d){null===f&&(f=h);break}t&&f&&null===d.alternate&&n(e,f),r=s(d,r,p),null===l?c=d:l.sibling=d,l=d,f=h}if(p===o.length)return i(e,f),c;if(null===f){for(;ph?(d=p,p=null):d=p.sibling;var b=v(e,p,m.value,c);if(null===b){p||(p=d);break}t&&p&&null===b.alternate&&n(e,p),o=s(b,o,h),null===f?l=b:f.sibling=b,f=b,p=d}if(m.done)return i(e,p),l;if(null===p){for(;!m.done;h++,m=u.next())null!==(m=y(e,m.value,c))&&(o=s(m,o,h),null===f?l=m:f.sibling=m,f=m);return l}for(p=a(e,p);!m.done;h++,m=u.next())null!==(m=g(p,e,h,m.value,c))&&(t&&null!==m.alternate&&p.delete(null===m.key?h:m.key),o=s(m,o,h),null===f?l=m:f.sibling=m,f=m);return t&&p.forEach(function(t){return n(e,t)}),l}return function(e,t,a,s){var c="object"==typeof a&&null!==a;if(c)switch(a.$$typeof){case Ui:e:{var l=a.key;for(c=t;null!==c;){if(c.key===l){if(c.type===a.type){i(e,c.sibling),t=o(c,s),t.ref=re(c,a),t.pendingProps=a.props,t.return=e,e=t;break e}i(e,c);break}n(e,c),c=c.sibling}s=Si(a,e.internalContextTag,s),s.ref=re(t,a),s.return=e,e=s}return u(e);case bi:e:{for(c=a.key;null!==t;){if(t.key===c){if(t.tag===Ai){i(e,t.sibling),t=o(t,s),t.pendingProps=a,t.return=e,e=t;break e}i(e,t);break}n(e,t),t=t.sibling}a=Ii(a,e.internalContextTag,s),a.return=e,e=a}return u(e);case ki:e:{if(null!==t){if(t.tag===Ti){i(e,t.sibling),t=o(t,s),t.type=a.value,t.return=e,e=t;break e}i(e,t)}t=Ri(a,e.internalContextTag,s),t.type=a.value,t.return=e,e=t}return u(e);case wi:e:{for(c=a.key;null!==t;){if(t.key===c){if(t.tag===Mi&&t.stateNode.containerInfo===a.containerInfo&&t.stateNode.implementation===a.implementation){i(e,t.sibling),t=o(t,s),t.pendingProps=a.children||[],t.return=e,e=t;break e}i(e,t);break}n(e,t),t=t.sibling}a=Ei(a,e.internalContextTag,s),a.return=e,e=a}return u(e)}if("string"==typeof a||"number"==typeof a)return a=""+a,null!==t&&t.tag===Oi?(i(e,t.sibling),t=o(t,s),t.pendingProps=a,t.return=e,e=t):(i(e,t),a=Ci(a,e.internalContextTag,s),a.return=e,e=a),u(e);if(Fi(a))return m(e,t,a,s);if(ne(a))return b(e,t,a,s);if(c&&ie(e,a),void 0===a)switch(e.tag){case Di:case Pi:a=e.type,r("152",a.displayName||a.name||"Component")}return i(e,t)}}function oe(e,t,n,i){function a(e,t){t.updater=o,e.stateNode=t,$t.set(t,e)}var o={isMounted:ra,enqueueSetState:function(n,r,i){n=$t.get(n);var a=t(n,!1);Xi(n,r,void 0===i?null:i,a),e(n,a)},enqueueReplaceState:function(n,r,i){n=$t.get(n);var a=t(n,!1);Zi(n,r,void 0===i?null:i,a),e(n,a)},enqueueForceUpdate:function(n,r){n=$t.get(n);var i=t(n,!1);ea(n,void 0===r?null:r,i),e(n,i)}};return{adoptClassInstance:a,constructClassInstance:function(e,t){var n=e.type,r=Qi(e),i=Yi(e),o=i?Gi(e,r):kt;return t=new n(t,o),a(e,t),i&&$i(e,r,o),t},mountClassInstance:function(e,t){var n=e.alternate,i=e.stateNode,a=i.state||null,s=e.pendingProps;s||r("158");var u=Qi(e);i.props=s,i.state=a,i.refs=kt,i.context=Gi(e,u),Rr.enableAsyncSubtreeAPI&&null!=e.type&&null!=e.type.prototype&&!0===e.type.prototype.unstable_isAsyncReactComponent&&(e.internalContextTag|=qi),"function"==typeof i.componentWillMount&&(u=i.state,i.componentWillMount(),u!==i.state&&o.enqueueReplaceState(i,i.state,null),null!==(u=e.updateQueue)&&(i.state=ta(n,e,u,i,a,s,t))),"function"==typeof i.componentDidMount&&(e.effectTag|=Ji)},updateClassInstance:function(e,t,a){var s=t.stateNode;s.props=t.memoizedProps,s.state=t.memoizedState;var u=t.memoizedProps,c=t.pendingProps;c||null==(c=u)&&r("159");var l=s.context,f=Qi(t);if(f=Gi(t,f),"function"!=typeof s.componentWillReceiveProps||u===c&&l===f||(l=s.state,s.componentWillReceiveProps(c,f),s.state!==l&&o.enqueueReplaceState(s,s.state,null)),l=t.memoizedState,a=null!==t.updateQueue?ta(e,t,t.updateQueue,s,l,c,a):l,!(u!==c||l!==a||na()||null!==t.updateQueue&&t.updateQueue.hasForceUpdate))return"function"!=typeof s.componentDidUpdate||u===e.memoizedProps&&l===e.memoizedState||(t.effectTag|=Ji),!1;var p=c;if(null===u||null!==t.updateQueue&&t.updateQueue.hasForceUpdate)p=!0;else{var h=t.stateNode,d=t.type;p="function"==typeof h.shouldComponentUpdate?h.shouldComponentUpdate(p,a,f):!d.prototype||!d.prototype.isPureReactComponent||(!wt(u,p)||!wt(l,a))}return p?("function"==typeof s.componentWillUpdate&&s.componentWillUpdate(c,a,f),"function"==typeof s.componentDidUpdate&&(t.effectTag|=Ji)):("function"!=typeof s.componentDidUpdate||u===e.memoizedProps&&l===e.memoizedState||(t.effectTag|=Ji),n(t,c),i(t,a)),s.props=c,s.state=a,s.context=f,p}}}function se(e,t,n,i,a){function o(e,t,n){s(e,t,n,t.pendingWorkPriority)}function s(e,t,n,r){t.child=null===e?ia(t,t.child,n,r):e.child===t.child?aa(t,t.child,n,r):oa(t,t.child,n,r)}function u(e,t){var n=t.ref;null===n||e&&e.ref===n||(t.effectTag|=Oa)}function c(e,t,n,r){if(u(e,t),!n)return r&&da(t,!1),f(e,t);n=t.stateNode,Ma.current=t;var i=n.render();return t.effectTag|=Ea,o(e,t,i),t.memoizedState=n.state,t.memoizedProps=n.props,r&&da(t,!0),t.child}function l(e){var t=e.stateNode;t.pendingContext?ha(e,t.pendingContext,t.pendingContext!==t.context):t.context&&ha(e,t.context,!1),g(e,t.containerInfo)}function f(e,t){return sa(e,t),t.child}function p(e,t){switch(t.tag){case ma:l(t);break;case ga:pa(t);break;case wa:g(t,t.stateNode.containerInfo)}return null}var h=e.shouldSetTextContent,d=e.useSyncScheduling,y=e.shouldDeprioritizeSubtree,v=t.pushHostContext,g=t.pushHostContainer,m=n.enterHydrationState,b=n.resetHydrationState,k=n.tryToClaimNextHydratableInstance;e=oe(i,a,function(e,t){e.memoizedProps=t},function(e,t){e.memoizedState=t});var w=e.adoptClassInstance,x=e.constructClassInstance,S=e.mountClassInstance,_=e.updateClassInstance;return{beginWork:function(e,t,n){if(t.pendingWorkPriority===Ia||t.pendingWorkPriority>n)return p(e,t);switch(t.tag){case ya:null!==e&&r("155");var i=t.type,a=t.pendingProps,s=la(t);return s=ca(t,s),i=i(a,s),t.effectTag|=Ea,"object"==typeof i&&null!==i&&"function"==typeof i.render?(t.tag=ga,a=pa(t),w(t,i),S(t,n),t=c(e,t,!0,a)):(t.tag=va,o(e,t,i),t.memoizedProps=a,t=t.child),t;case va:e:{if(a=t.type,n=t.pendingProps,i=t.memoizedProps,fa())null===n&&(n=i);else if(null===n||i===n){t=f(e,t);break e}i=la(t),i=ca(t,i),a=a(n,i),t.effectTag|=Ea,o(e,t,a),t.memoizedProps=n,t=t.child}return t;case ga:return a=pa(t),i=void 0,null===e?t.stateNode?r("153"):(x(t,t.pendingProps),S(t,n),i=!0):i=_(e,t,n),c(e,t,i,a);case ma:return l(t),i=t.updateQueue,null!==i?(a=t.memoizedState,i=ua(e,t,i,null,a,null,n),a===i?(b(),t=f(e,t)):(a=i.element,null!==e&&null!==e.child||!m(t)?(b(),o(e,t,a)):(t.effectTag|=Fa,t.child=ia(t,t.child,a,n)),t.memoizedState=i,t=t.child)):(b(),t=f(e,t)),t;case ba:v(t),null===e&&k(t),a=t.type;var C=t.memoizedProps;return i=t.pendingProps,null===i&&null===(i=C)&&r("154"),s=null!==e?e.memoizedProps:null,fa()||null!==i&&C!==i?(C=i.children,h(a,i)?C=null:s&&h(a,s)&&(t.effectTag|=Pa),u(e,t),n!==Ra&&!d&&y(a,i)?(t.pendingWorkPriority=Ra,t=null):(o(e,t,C),t.memoizedProps=i,t=t.child)):t=f(e,t),t;case ka:return null===e&&k(t),e=t.pendingProps,null===e&&(e=t.memoizedProps),t.memoizedProps=e,null;case Sa:t.tag=xa;case xa:return n=t.pendingProps,fa()?null===n&&null===(n=e&&e.memoizedProps)&&r("154"):null!==n&&t.memoizedProps!==n||(n=t.memoizedProps),a=n.children,i=t.pendingWorkPriority,t.stateNode=null===e?ia(t,t.stateNode,a,i):e.child===t.child?aa(t,t.stateNode,a,i):oa(t,t.stateNode,a,i),t.memoizedProps=n,t.stateNode;case _a:return null;case wa:e:{if(g(t,t.stateNode.containerInfo),n=t.pendingWorkPriority,a=t.pendingProps,fa())null===a&&null==(a=e&&e.memoizedProps)&&r("154");else if(null===a||t.memoizedProps===a){t=f(e,t);break e}null===e?t.child=oa(t,t.child,a,n):o(e,t,a),t.memoizedProps=a,t=t.child}return t;case Ca:e:{if(n=t.pendingProps,fa())null===n&&(n=t.memoizedProps);else if(null===n||t.memoizedProps===n){t=f(e,t);break e}o(e,t,n),t.memoizedProps=n,t=t.child}return t;default:r("156")}},beginFailedWork:function(e,t,n){switch(t.tag){case ga:pa(t);break;case ma:l(t);break;default:r("157")}return t.effectTag|=Da,null===e?t.child=null:t.child!==e.child&&(t.child=e.child),t.pendingWorkPriority===Ia||t.pendingWorkPriority>n?p(e,t):(t.firstEffect=null,t.lastEffect=null,s(e,t,null,n),t.tag===ga&&(e=t.stateNode,t.memoizedProps=e.props,t.memoizedState=e.state),t.child)}}}function ue(e,t,n){var i=e.createInstance,a=e.createTextInstance,o=e.appendInitialChild,s=e.finalizeInitialChildren,u=e.prepareUpdate,c=t.getRootHostContainer,l=t.popHostContext,f=t.getHostContext,p=t.popHostContainer,h=n.prepareToHydrateHostInstance,d=n.prepareToHydrateHostTextInstance,y=n.popHydrationState;return{completeWork:function(e,t,n){var v=t.pendingProps;switch(null===v?v=t.memoizedProps:t.pendingWorkPriority===Ya&&n!==Ya||(t.pendingProps=null),t.tag){case Ba:return null;case La:return Ta(t),null;case Ha:return p(t),Na(t),v=t.stateNode,v.pendingContext&&(v.context=v.pendingContext,v.pendingContext=null),null!==e&&null!==e.child||(y(t),t.effectTag&=~$a),null;case Ua:l(t),n=c();var g=t.type;if(null!==e&&null!=t.stateNode){var m=e.memoizedProps,b=t.stateNode,k=f();v=u(b,g,m,v,n,k),(t.updateQueue=v)&&(t.effectTag|=Qa),e.ref!==t.ref&&(t.effectTag|=Ga)}else{if(!v)return null===t.stateNode&&r("166"),null;if(e=f(),y(t))h(t,n,e)&&(t.effectTag|=Qa);else{e=i(g,v,n,e,t);e:for(m=t.child;null!==m;){if(m.tag===Ua||m.tag===za)o(e,m.stateNode);else if(m.tag!==Ka&&null!==m.child){m=m.child;continue}if(m===t)break e;for(;null===m.sibling;){if(null===m.return||m.return===t)break e;m=m.return}m=m.sibling}s(e,g,v,n)&&(t.effectTag|=Qa),t.stateNode=e}null!==t.ref&&(t.effectTag|=Ga)}return null;case za:if(e&&null!=t.stateNode)e.memoizedProps!==v&&(t.effectTag|=Qa);else{if("string"!=typeof v)return null===t.stateNode&&r("166"),null;e=c(),n=f(),y(t)?d(t)&&(t.effectTag|=Qa):t.stateNode=a(v,e,n,t)}return null;case Wa:(v=t.memoizedProps)||r("165"),t.tag=Va,n=[];e:for((g=t.stateNode)&&(g.return=t);null!==g;){if(g.tag===Ua||g.tag===za||g.tag===Ka)r("164");else if(g.tag===Ja)n.push(g.type);else if(null!==g.child){g.child.return=g,g=g.child;continue}for(;null===g.sibling;){if(null===g.return||g.return===t)break e;g=g.return}g.sibling.return=g.return,g=g.sibling}return g=v.handler,v=g(v.props,n),t.child=Aa(t,null!==e?e.child:null,v,t.pendingWorkPriority),t.child;case Va:return t.tag=Wa,null;case Ja:case qa:return null;case Ka:return t.effectTag|=Qa,p(t),null;case ja:r("167");default:r("156")}}}}function ce(e){return function(t){try{return e(t)}catch(e){}}}function le(e,t){function n(e){var n=e.ref;if(null!==n)try{n(null)}catch(n){t(e,n)}}function i(e){return e.tag===ro||e.tag===no||e.tag===ao}function a(e){for(var t=e;;)if(s(t),null!==t.child&&t.tag!==ao)t.child.return=t,t=t.child;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return;t=t.return}t.sibling.return=t.return,t=t.sibling}}function o(e){for(var t=e,n=!1,i=void 0,o=void 0;;){if(!n){n=t.return;e:for(;;){switch(null===n&&r("160"),n.tag){case ro:i=n.stateNode,o=!1;break e;case no:case ao:i=n.stateNode.containerInfo,o=!0;break e}n=n.return}n=!0}if(t.tag===ro||t.tag===io)a(t),o?g(i,t.stateNode):v(i,t.stateNode);else if(t.tag===ao?i=t.stateNode.containerInfo:s(t),null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return;t=t.return,t.tag===ao&&(n=!1)}t.sibling.return=t.return,t=t.sibling}}function s(e){switch("function"==typeof uo&&uo(e),e.tag){case to:n(e);var r=e.stateNode;if("function"==typeof r.componentWillUnmount)try{r.props=e.memoizedProps,r.state=e.memoizedState,r.componentWillUnmount()}catch(n){t(e,n)}break;case ro:n(e);break;case oo:a(e.stateNode);break;case ao:o(e)}}var u=e.commitMount,c=e.commitUpdate,l=e.resetTextContent,f=e.commitTextUpdate,p=e.appendChild,h=e.appendChildToContainer,d=e.insertBefore,y=e.insertInContainerBefore,v=e.removeChild,g=e.removeChildFromContainer,m=e.getPublicInstance;return{commitPlacement:function(e){e:{for(var t=e.return;null!==t;){if(i(t)){var n=t;break e}t=t.return}r("160"),n=void 0}var a=t=void 0;switch(n.tag){case ro:t=n.stateNode,a=!1;break;case no:case ao:t=n.stateNode.containerInfo,a=!0;break;default:r("161")}n.effectTag&po&&(l(t),n.effectTag&=~po);e:t:for(n=e;;){for(;null===n.sibling;){if(null===n.return||i(n.return)){n=null;break e}n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==ro&&n.tag!==io;){if(n.effectTag&co)continue t;if(null===n.child||n.tag===ao)continue t;n.child.return=n,n=n.child}if(!(n.effectTag&co)){n=n.stateNode;break e}}for(var o=e;;){if(o.tag===ro||o.tag===io)n?a?y(t,o.stateNode,n):d(t,o.stateNode,n):a?h(t,o.stateNode):p(t,o.stateNode);else if(o.tag!==ao&&null!==o.child){o.child.return=o,o=o.child;continue}if(o===e)break;for(;null===o.sibling;){if(null===o.return||o.return===e)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},commitDeletion:function(e){o(e),e.return=null,e.child=null,e.alternate&&(e.alternate.child=null,e.alternate.return=null)},commitWork:function(e,t){switch(t.tag){case to:break;case ro:var n=t.stateNode;if(null!=n){var i=t.memoizedProps;e=null!==e?e.memoizedProps:i;var a=t.type,o=t.updateQueue;t.updateQueue=null,null!==o&&c(n,o,a,e,i,t)}break;case io:null===t.stateNode&&r("162"),n=t.memoizedProps,f(t.stateNode,null!==e?e.memoizedProps:n,n);break;case no:case ao:break;default:r("163")}},commitLifeCycles:function(e,t){switch(t.tag){case to:var n=t.stateNode;if(t.effectTag&lo)if(null===e)n.props=t.memoizedProps,n.state=t.memoizedState,n.componentDidMount();else{var i=e.memoizedProps;e=e.memoizedState,n.props=t.memoizedProps,n.state=t.memoizedState,n.componentDidUpdate(i,e)}t.effectTag&fo&&null!==t.updateQueue&&so(t,t.updateQueue,n);break;case no:e=t.updateQueue,null!==e&&so(t,e,t.child&&t.child.stateNode);break;case ro:n=t.stateNode,null===e&&t.effectTag&lo&&u(n,t.type,t.memoizedProps,t);break;case io:case ao:break;default:r("163")}},commitAttachRef:function(e){var t=e.ref;if(null!==t){var n=e.stateNode;switch(e.tag){case ro:t(m(n));break;default:t(n)}}},commitDetachRef:function(e){null!==(e=e.ref)&&e(null)}}}function fe(e){function t(e){return e===go&&r("174"),e}var n=e.getChildHostContext,i=e.getRootHostContext,a=ho(go),o=ho(go),s=ho(go);return{getHostContext:function(){return t(a.current)},getRootHostContainer:function(){return t(s.current)},popHostContainer:function(e){yo(a,e),yo(o,e),yo(s,e)},popHostContext:function(e){o.current===e&&(yo(a,e),yo(o,e))},pushHostContainer:function(e,t){vo(s,t,e),t=i(t),vo(o,e,e),vo(a,t,e)},pushHostContext:function(e){var r=t(s.current),i=t(a.current);r=n(i,e.type,r),i!==r&&(vo(o,e,e),vo(a,r,e))},resetHostContainer:function(){a.current=go,s.current=go}}}function pe(e){function t(e,t){var n=So();n.stateNode=t,n.return=e,n.effectTag=wo,null!==e.lastEffect?(e.lastEffect.nextEffect=n,e.lastEffect=n):e.firstEffect=e.lastEffect=n}function n(e,t){switch(e.tag){case mo:return o(t,e.type,e.pendingProps);case bo:return s(t,e.pendingProps);default:return!1}}function i(e){for(e=e.return;null!==e&&e.tag!==mo&&e.tag!==ko;)e=e.return;d=e}var a=e.shouldSetTextContent,o=e.canHydrateInstance,s=e.canHydrateTextInstance,u=e.getNextHydratableSibling,c=e.getFirstHydratableChild,l=e.hydrateInstance,f=e.hydrateTextInstance,p=e.didNotHydrateInstance,h=e.didNotFindHydratableInstance;if(e=e.didNotFindHydratableTextInstance,!(o&&s&&u&&c&&l&&f&&p&&h&&e))return{enterHydrationState:function(){return!1},resetHydrationState:function(){},tryToClaimNextHydratableInstance:function(){},prepareToHydrateHostInstance:function(){r("175")},prepareToHydrateHostTextInstance:function(){r("176")},popHydrationState:function(){return!1}};var d=null,y=null,v=!1;return{enterHydrationState:function(e){return y=c(e.stateNode.containerInfo),d=e,v=!0},resetHydrationState:function(){y=d=null,v=!1},tryToClaimNextHydratableInstance:function(e){if(v){var r=y;if(r){if(!n(e,r)){if(!(r=u(r))||!n(e,r))return e.effectTag|=xo,v=!1,void(d=e);t(d,y)}e.stateNode=r,d=e,y=c(r)}else e.effectTag|=xo,v=!1,d=e}},prepareToHydrateHostInstance:function(e,t,n){return t=l(e.stateNode,e.type,e.memoizedProps,t,n,e),e.updateQueue=t,null!==t},prepareToHydrateHostTextInstance:function(e){return f(e.stateNode,e.memoizedProps,e)},popHydrationState:function(e){if(e!==d)return!1;if(!v)return i(e),v=!0,!1;var n=e.type;if(e.tag!==mo||"head"!==n&&"body"!==n&&!a(n,e.memoizedProps))for(n=y;n;)t(e,n),n=u(n);return i(e),y=d?u(e.stateNode):null,!0}}}function he(e){function t(){for(;null!==J&&J.current.pendingWorkPriority===Po;){J.isScheduled=!1;var e=J.nextScheduledRoot;if(J.nextScheduledRoot=null,J===q)return q=J=null,K=Po,null;J=e}e=J;for(var t=null,n=Po;null!==e;)e.current.pendingWorkPriority!==Po&&(n===Po||n>e.current.pendingWorkPriority)&&(n=e.current.pendingWorkPriority,t=e),e=e.nextScheduledRoot;null!==t?(K=n,Co(),Yo(),x(),z=Ro(t.current,n),t!==ie&&(re=0,ie=t)):(K=Po,ie=z=null)}function n(n){ee=!0,V=null;var i=n.stateNode;if(i.current===n&&r("177"),K!==Do&&K!==Oo||re++,Io.current=null,n.effectTag>jo)if(null!==n.lastEffect){n.lastEffect.nextEffect=n;var a=n.firstEffect}else a=n;else a=n.firstEffect;for(T(),W=a;null!==W;){var o=!1,s=void 0;try{for(;null!==W;){var u=W.effectTag;if(u&zo&&e.resetTextContent(W.stateNode),u&Vo){var c=W.alternate;null!==c&&O(c)}switch(u&~(Ko|Wo|zo|Vo|jo)){case Bo:R(W),W.effectTag&=~Bo;break;case Ho:R(W),W.effectTag&=~Bo,F(W.alternate,W);break;case Lo:F(W.alternate,W);break;case Uo:te=!0,E(W),te=!1}W=W.nextEffect}}catch(e){o=!0,s=e}o&&(null===W&&r("178"),f(W,s),null!==W&&(W=W.nextEffect))}for(N(),i.current=n,W=a;null!==W;){i=!1,a=void 0;try{for(;null!==W;){var l=W.effectTag;if(l&(Lo|Ko)&&P(W.alternate,W),l&Vo&&D(W),l&Wo)switch(o=W,s=void 0,null!==G&&(s=G.get(o),G.delete(o),null==s&&null!==o.alternate&&(o=o.alternate,s=G.get(o),G.delete(o))),null==s&&r("184"),o.tag){case Go:o.stateNode.componentDidCatch(s.error,{componentStack:s.componentStack});break;case Jo:null===X&&(X=s.error);break;default:r("157")}var p=W.nextEffect;W.nextEffect=null,W=p}}catch(e){i=!0,a=e}i&&(null===W&&r("178"),f(W,a),null!==W&&(W=W.nextEffect))}ee=!1,"function"==typeof Fo&&Fo(n.stateNode),Y&&(Y.forEach(g),Y=null),t()}function i(e){for(;;){var t=I(e.alternate,e,K),n=e.return,r=e.sibling,i=e;if(!(i.pendingWorkPriority!==Po&&i.pendingWorkPriority>K)){for(var a=Qo(i),o=i.child;null!==o;)a=Eo(a,o.pendingWorkPriority),o=o.sibling;i.pendingWorkPriority=a}if(null!==t)return t;if(null!==n&&(null===n.firstEffect&&(n.firstEffect=e.firstEffect),null!==e.lastEffect&&(null!==n.lastEffect&&(n.lastEffect.nextEffect=e.firstEffect),n.lastEffect=e.lastEffect),e.effectTag>jo&&(null!==n.lastEffect?n.lastEffect.nextEffect=e:n.firstEffect=e,n.lastEffect=e)),null!==r)return r;if(null===n){V=e;break}e=n}return null}function a(e){var t=_(e.alternate,e,K);return null===t&&(t=i(e)),Io.current=null,t}function o(e){var t=C(e.alternate,e,K);return null===t&&(t=i(e)),Io.current=null,t}function s(e){l(To,e)}function u(){if(null!==G&&0e)){j=K;e:for(;;){if(K<=Oo)for(;null!==z&&!(null===(z=a(z))&&(null===V&&r("179"),j=Oo,n(V),j=K,u(),K===Po||K>e||K>Oo)););else if(null!==i)for(;null!==z&&!L;)if(1e||KOo&&!$&&(M(s),$=!0),e=X,Z=L=B=!1,ie=Q=G=X=null,re=0,null!==e)throw e}function f(e,t){var n=Io.current=null,r=!1,i=!1,a=null;if(e.tag===Jo)n=e,h(e)&&(Z=!0);else for(var o=e.return;null!==o&&null===n;){if(o.tag===Go?"function"==typeof o.stateNode.componentDidCatch&&(r=!0,a=p(o),n=o,i=!0):o.tag===Jo&&(n=o),h(o)){if(te||null!==Y&&(Y.has(o)||null!==o.alternate&&Y.has(o.alternate)))return null;n=null,i=!1}o=o.return}if(null!==n){null===Q&&(Q=new Set),Q.add(n);var s="";o=e;do{e:switch(o.tag){case pi:case hi:case di:case yi:var u=o._debugOwner,c=o._debugSource,l=p(o),f=null;u&&(f=p(u)),u=c,l="\n in "+(l||"Unknown")+(u?" (at "+u.fileName.replace(/^.*[\\\/]/,"")+":"+u.lineNumber+")":f?" (created by "+f+")":"");break e;default:l=""}s+=l,o=o.return}while(o);o=s,e=p(e),null===G&&(G=new Map),t={componentName:e,componentStack:o,error:t,errorBoundary:r?n.stateNode:null,errorBoundaryFound:r,errorBoundaryName:a,willRetry:i},G.set(n,t);try{console.error(t.error)}catch(e){console.error(e)}return ee?(null===Y&&(Y=new Set),Y.add(n)):g(n),n}return null===X&&(X=t),null}function h(e){return null!==Q&&(Q.has(e)||null!==e.alternate&&Q.has(e.alternate))}function d(e,t){return y(e,t,!1)}function y(e,t){re>ne&&(Z=!0,r("185")),!B&&t<=K&&(z=null);for(var n=!0;null!==e&&n;){if(n=!1,(e.pendingWorkPriority===Po||e.pendingWorkPriority>t)&&(n=!0,e.pendingWorkPriority=t),null!==e.alternate&&(e.alternate.pendingWorkPriority===Po||e.alternate.pendingWorkPriority>t)&&(n=!0,e.alternate.pendingWorkPriority=t),null===e.return){if(e.tag!==Jo)break;var i=e.stateNode;if(t===Po||i.isScheduled||(i.isScheduled=!0,q?q.nextScheduledRoot=i:J=i,q=i),!B)switch(t){case Do:U?l(Do,null):l(Oo,null);break;case Oo:H||r("186");break;default:$||(M(s),$=!0)}}e=e.return}}function v(e,t){var n=j;return n===Po&&(n=!A||e.internalContextTag&No||t?Ao:Do),n===Do&&(B||H)?Oo:n}function g(e){y(e,Oo,!0)}var m=fe(e),b=pe(e),k=m.popHostContainer,w=m.popHostContext,x=m.resetHostContainer,S=se(e,m,b,d,v),_=S.beginWork,C=S.beginFailedWork,I=ue(e,m,b).completeWork;m=le(e,f);var R=m.commitPlacement,E=m.commitDeletion,F=m.commitWork,P=m.commitLifeCycles,D=m.commitAttachRef,O=m.commitDetachRef,M=e.scheduleDeferredCallback,A=e.useSyncScheduling,T=e.prepareForCommit,N=e.resetAfterCommit,j=Po,B=!1,L=!1,H=!1,U=!1,z=null,K=Po,W=null,V=null,J=null,q=null,$=!1,G=null,Q=null,Y=null,X=null,Z=!1,ee=!1,te=!1,ne=1e3,re=0,ie=null;return{scheduleUpdate:d,getPriorityContext:v,batchedUpdates:function(e,t){var n=H;H=!0;try{return e(t)}finally{H=n,B||H||l(Oo,null)}},unbatchedUpdates:function(e){var t=U,n=H;U=H,H=!1;try{return e()}finally{H=n,U=t}},flushSync:function(e){var t=H,n=j;H=!0,j=Do;try{return e()}finally{H=t,j=n,B&&r("187"),l(Oo,null)}},deferredUpdates:function(e){var t=j;j=Ao;try{return e()}finally{j=t}}}}function de(){r("196")}function ye(e){return e?(e=$t.get(e),"number"==typeof e.tag?de(e):e._processChildContext(e._context)):kt}function ve(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ge(e,t){var n=ve(e);e=0;for(var r;n;){if(n.nodeType===as){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ve(n)}}function me(){return!os&&vt.canUseDOM&&(os="textContent"in document.documentElement?"textContent":"innerText"),os}function be(){r("211")}function ke(){r("212")}function we(e){if(null==e)return null;if(e.nodeType===fs)return e;var t=$t.get(e);if(t)return"number"==typeof t.tag?be(t):ke(t);"function"==typeof e.render?r("188"):r("213",Object.keys(e))}function xe(e){if(void 0!==e._hostParent)return e._hostParent;if("number"==typeof e.tag){do{e=e.return}while(e&&e.tag!==ps);if(e)return e}return null}function Se(e,t){for(var n=0,r=e;r;r=xe(r))n++;r=0;for(var i=t;i;i=xe(i))r++;for(;0this.eventPool.length&&this.eventPool.push(e)}function Oe(e){e.eventPool=[],e.getPooled=Pe,e.release=De}function Me(e,t,n,r){return Fe.call(this,e,t,n,r)}function Ae(e,t,n,r){return Fe.call(this,e,t,n,r)}function Te(e,t){switch(e){case"topKeyUp":return-1!==ws.indexOf(t.keyCode);case"topKeyDown":return 229!==t.keyCode;case"topKeyPress":case"topMouseDown":case"topBlur":return!0;default:return!1}}function Ne(e){return e=e.detail,"object"==typeof e&&"data"in e?e.data:null}function je(e,t){switch(e){case"topCompositionEnd":return Ne(t);case"topKeyPress":return 32!==t.which?null:(Ps=!0,Es);case"topTextInput":return e=t.data,e===Es&&Ps?null:e;default:return null}}function Be(e,t){if(Ds)return"topCompositionEnd"===e||!xs&&Te(e,t)?(e=ms.getData(),ms.reset(),Ds=!1,e):null;switch(e){case"topPaste":return null;case"topKeyPress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=u.hasBooleanValue+u.hasNumericValue+u.hasOverloadedBooleanValue||r("50",o),a.hasOwnProperty(o)&&(u.attributeName=a[o]),i.hasOwnProperty(o)&&(u.attributeNamespace=i[o]),e.hasOwnProperty(o)&&(u.mutationMethod=e[o]),At.properties[o]=u}}},At={ID_ATTRIBUTE_NAME:"data-reactid",ROOT_ATTRIBUTE_NAME:"data-reactroot",ATTRIBUTE_NAME_START_CHAR:":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",ATTRIBUTE_NAME_CHAR:":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",properties:{},shouldSetAttribute:function(e,t){if(At.isReservedProp(e)||!("o"!==e[0]&&"O"!==e[0]||"n"!==e[1]&&"N"!==e[1]))return!1;if(null===t)return!0;switch(typeof t){case"boolean":return At.shouldAttributeAcceptBooleanValue(e);case"undefined":case"number":case"string":case"object":return!0;default:return!1}},getPropertyInfo:function(e){return At.properties.hasOwnProperty(e)?At.properties[e]:null},shouldAttributeAcceptBooleanValue:function(e){if(At.isReservedProp(e))return!0;var t=At.getPropertyInfo(e);return t?t.hasBooleanValue||t.hasStringBooleanValue||t.hasOverloadedBooleanValue:"data-"===(e=e.toLowerCase().slice(0,5))||"aria-"===e},isReservedProp:function(e){return Ot.hasOwnProperty(e)},injection:Mt},Tt=At,Nt={IndeterminateComponent:0,FunctionalComponent:1,ClassComponent:2,HostRoot:3,HostPortal:4,HostComponent:5,HostText:6,CoroutineComponent:7,CoroutineHandlerPhase:8,YieldComponent:9,Fragment:10},jt={ELEMENT_NODE:1,TEXT_NODE:3,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_FRAGMENT_NODE:11},Bt=Nt.HostComponent,Lt=Nt.HostText,Ht=jt.ELEMENT_NODE,Ut=jt.COMMENT_NODE,zt=Tt.ID_ATTRIBUTE_NAME,Kt={hasCachedChildNodes:1},Wt=Math.random().toString(36).slice(2),Vt="__reactInternalInstance$"+Wt,Jt="__reactEventHandlers$"+Wt,qt={getClosestInstanceFromNode:f,getInstanceFromNode:function(e){var t=e[Vt];return t?t.tag===Bt||t.tag===Lt?t:t._hostNode===e?t:null:(t=f(e),null!=t&&t._hostNode===e?t:null)},getNodeFromInstance:function(e){if(e.tag===Bt||e.tag===Lt)return e.stateNode;if(void 0===e._hostNode&&r("33"),e._hostNode)return e._hostNode;for(var t=[];!e._hostNode;)t.push(e),e._hostParent||r("34"),e=e._hostParent;for(;t.length;e=t.pop())l(e,e._hostNode);return e._hostNode},precacheChildNodes:l,precacheNode:c,uncacheNode:function(e){var t=e._hostNode;t&&(delete t[Vt],e._hostNode=null)},precacheFiberNode:function(e,t){t[Vt]=e},getFiberCurrentPropsFromNode:function(e){return e[Jt]||null},updateFiberProps:function(e,t){e[Jt]=t}},$t={remove:function(e){e._reactInternalFiber=void 0},get:function(e){return e._reactInternalFiber},has:function(e){return void 0!==e._reactInternalFiber},set:function(e,t){e._reactInternalFiber=t}},Gt={ReactCurrentOwner:yt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner},Qt={NoEffect:0,PerformedWork:1,Placement:2,Update:4,PlacementAndUpdate:6,Deletion:8,ContentReset:16,Callback:32,Err:64,Ref:128},Yt=Nt.HostComponent,Xt=Nt.HostRoot,Zt=Nt.HostPortal,en=Nt.HostText,tn=Qt.NoEffect,nn=Qt.Placement,rn={isFiberMounted:function(e){return 2===h(e)},isMounted:function(e){return!!(e=$t.get(e))&&2===h(e)},findCurrentFiberUsingSlowPath:y,findCurrentHostFiber:function(e){if(!(e=y(e)))return null;for(var t=e;;){if(t.tag===Yt||t.tag===en)return t;if(t.child)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null},findCurrentHostFiberWithNoPortals:function(e){if(!(e=y(e)))return null;for(var t=e;;){if(t.tag===Yt||t.tag===en)return t;if(t.child&&t.tag!==Zt)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null}},an={_caughtError:null,_hasCaughtError:!1,_rethrowError:null,_hasRethrowError:!1,injection:{injectErrorUtils:function(e){"function"!=typeof e.invokeGuardedCallback&&r("197"),v=e.invokeGuardedCallback}},invokeGuardedCallback:function(e,t,n,r,i,a,o,s,u){v.apply(an,arguments)},invokeGuardedCallbackAndCatchFirstError:function(e,t,n,r,i,a,o,s,u){if(an.invokeGuardedCallback.apply(this,arguments),an.hasCaughtError()){var c=an.clearCaughtError();an._hasRethrowError||(an._hasRethrowError=!0,an._rethrowError=c)}},rethrowCaughtError:function(){return g.apply(an,arguments)},hasCaughtError:function(){return an._hasCaughtError},clearCaughtError:function(){if(an._hasCaughtError){var e=an._caughtError;return an._caughtError=null,an._hasCaughtError=!1,e}r("198")}},on=an,sn={isEndish:function(e){return"topMouseUp"===e||"topTouchEnd"===e||"topTouchCancel"===e},isMoveish:function(e){return"topMouseMove"===e||"topTouchMove"===e},isStartish:function(e){return"topMouseDown"===e||"topTouchStart"===e},executeDirectDispatch:function(e){var t=e._dispatchListeners,n=e._dispatchInstances;return Array.isArray(t)&&r("103"),e.currentTarget=t?sn.getNodeFromInstance(n):null,t=t?t(e):null,e.currentTarget=null,e._dispatchListeners=null,e._dispatchInstances=null,t},executeDispatchesInOrder:function(e,t){var n=e._dispatchListeners,r=e._dispatchInstances;if(Array.isArray(n))for(var i=0;ign.length&&gn.push(e)}}}},bn=mn,kn=null,wn={injection:{injectEventPluginOrder:Dt.injectEventPluginOrder,injectEventPluginsByName:Dt.injectEventPluginsByName},getListener:function(e,t){if("number"==typeof e.tag){var n=e.stateNode;if(!n)return null;var i=un.getFiberCurrentPropsFromNode(n);if(!i)return null;if(n=i[t],P(t,e.type,i))return null}else{if("string"==typeof(i=e._currentElement)||"number"==typeof i||!e._rootNodeID)return null;if(e=i.props,n=e[t],P(t,i.type,e))return null}return n&&"function"!=typeof n&&r("231",t,typeof n),n},extractEvents:function(e,t,n,r){for(var i,a=Dt.plugins,o=0;on||r.hasOverloadedBooleanValue&&!1===n?Un.deleteValueForProperty(e,t):r.mustUseProperty?e[r.propertyName]=n:(t=r.attributeName,(i=r.attributeNamespace)?e.setAttributeNS(i,t,""+n):r.hasBooleanValue||r.hasOverloadedBooleanValue&&!0===n?e.setAttribute(t,""):e.setAttribute(t,""+n))}else Un.setValueForAttribute(e,t,Tt.shouldSetAttribute(t,n)?n:null)},setValueForAttribute:function(e,t,n){T(t)&&(null==n?e.removeAttribute(t):e.setAttribute(t,""+n))},deleteValueForAttribute:function(e,t){e.removeAttribute(t)},deleteValueForProperty:function(e,t){var n=Tt.getPropertyInfo(t);n?(t=n.mutationMethod)?t(e,void 0):n.mustUseProperty?e[n.propertyName]=!n.hasBooleanValue&&"":e.removeAttribute(n.attributeName):e.removeAttribute(t)}},zn=Un,Kn=Gt.ReactDebugCurrentFrame,Wn={current:null,phase:null,resetCurrentFiber:function(){Kn.getCurrentStack=null,Wn.current=null,Wn.phase=null},setCurrentFiber:function(e,t){Kn.getCurrentStack=N,Wn.current=e,Wn.phase=t},getCurrentFiberOwnerName:function(){return null},getCurrentFiberStackAddendum:N},Vn=Wn,Jn={getHostProps:function(e,t){var n=t.value,r=t.checked;return gt({type:void 0,step:void 0,min:void 0,max:void 0},t,{defaultChecked:void 0,defaultValue:void 0,value:null!=n?n:e._wrapperState.initialValue,checked:null!=r?r:e._wrapperState.initialChecked})},initWrapperState:function(e,t){var n=t.defaultValue;e._wrapperState={initialChecked:null!=t.checked?t.checked:t.defaultChecked,initialValue:null!=t.value?t.value:n,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}},updateWrapper:function(e,t){var n=t.checked;null!=n&&zn.setValueForProperty(e,"checked",n||!1),n=t.value,null!=n?0===n&&""===e.value?e.value="0":"number"===t.type?(t=parseFloat(e.value)||0,(n!=t||n==t&&e.value!=n)&&(e.value=""+n)):e.value!==""+n&&(e.value=""+n):(null==t.value&&null!=t.defaultValue&&e.defaultValue!==""+t.defaultValue&&(e.defaultValue=""+t.defaultValue),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked))},postMountWrapper:function(e,t){switch(t.type){case"submit":case"reset":break;case"color":case"date":case"datetime":case"datetime-local":case"month":case"time":case"week":e.value="",e.value=e.defaultValue;break;default:e.value=e.value}t=e.name,""!==t&&(e.name=""),e.defaultChecked=!e.defaultChecked,e.defaultChecked=!e.defaultChecked,""!==t&&(e.name=t)},restoreControlledState:function(e,t){Jn.updateWrapper(e,t);var n=t.name;if("radio"===t.type&&null!=n){for(t=e;t.parentNode;)t=t.parentNode;for(n=t.querySelectorAll("input[name="+JSON.stringify(""+n)+'][type="radio"]'),t=0;t=t.length||r("93"),t=t[0]),n=""+t),null==n&&(n=""),i=n),e._wrapperState={initialValue:""+i}},updateWrapper:function(e,t){var n=t.value;null!=n&&(n=""+n,n!==e.value&&(e.value=n),null==t.defaultValue&&(e.defaultValue=n)),null!=t.defaultValue&&(e.defaultValue=t.defaultValue)},postMountWrapper:function(e){var t=e.textContent;t===e._wrapperState.initialValue&&(e.value=t)},restoreControlledState:function(e,t){Qn.updateWrapper(e,t)}},Yn=Qn,Xn=gt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),Zn={_getTrackerFromNode:function(e){return e._valueTracker},track:function(e){e._valueTracker||(e._valueTracker=U(e))},updateValueIfChanged:function(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=H(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)},stopTracking:function(e){(e=e._valueTracker)&&e.stopTracking()}},er=Rt.Namespaces,tr=function(e){return"undefined"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n)})}:e}(function(e,t){if(e.namespaceURI!==er.svg||"innerHTML"in e)e.innerHTML=t;else for(Nn=Nn||document.createElement("div"),Nn.innerHTML=""+t+"",t=Nn.firstChild;t.firstChild;)e.appendChild(t.firstChild)}),nr=/["'&<>]/,rr=jt.TEXT_NODE;vt.canUseDOM&&("textContent"in document.documentElement||(K=function(e,t){if(e.nodeType===rr)e.nodeValue=t;else{if("boolean"==typeof t||"number"==typeof t)t=""+t;else{t=""+t;var n=nr.exec(t);if(n){var r,i="",a=0;for(r=n.index;r<\/script>",e=e.removeChild(e.firstChild)):e="string"==typeof t.is?n.createElement(e,{is:t.is}):n.createElement(e):e=n.createElementNS(r,e),e},createTextNode:function(e,t){return(t.nodeType===ar?t:t.ownerDocument).createTextNode(e)},setInitialProperties:function(e,t,n,r){var i=z(t,n);switch(t){case"iframe":case"object":Fn.trapBubbledEvent("topLoad","load",e);var a=n;break;case"video":case"audio":for(a in fr)fr.hasOwnProperty(a)&&Fn.trapBubbledEvent(a,fr[a],e);a=n;break;case"source":Fn.trapBubbledEvent("topError","error",e),a=n;break;case"img":case"image":Fn.trapBubbledEvent("topError","error",e),Fn.trapBubbledEvent("topLoad","load",e),a=n;break;case"form":Fn.trapBubbledEvent("topReset","reset",e),Fn.trapBubbledEvent("topSubmit","submit",e),a=n;break;case"details":Fn.trapBubbledEvent("topToggle","toggle",e),a=n;break;case"input":qn.initWrapperState(e,n),a=qn.getHostProps(e,n),Fn.trapBubbledEvent("topInvalid","invalid",e),W(r,"onChange");break;case"option":$n.validateProps(e,n),a=$n.getHostProps(e,n);break;case"select":Gn.initWrapperState(e,n),a=Gn.getHostProps(e,n),Fn.trapBubbledEvent("topInvalid","invalid",e),W(r,"onChange");break;case"textarea":Yn.initWrapperState(e,n),a=Yn.getHostProps(e,n),Fn.trapBubbledEvent("topInvalid","invalid",e),W(r,"onChange");break;default:a=n}L(t,a);var o,s=a;for(o in s)if(s.hasOwnProperty(o)){var u=s[o];"style"===o?jn.setValueForStyles(e,u):"dangerouslySetInnerHTML"===o?null!=(u=u?u.__html:void 0)&&tr(e,u):"children"===o?"string"==typeof u?ir(e,u):"number"==typeof u&&ir(e,""+u):"suppressContentEditableWarning"!==o&&(ur.hasOwnProperty(o)?null!=u&&W(r,o):i?zn.setValueForAttribute(e,o,u):null!=u&&zn.setValueForProperty(e,o,u))}switch(t){case"input":Zn.track(e),qn.postMountWrapper(e,n);break;case"textarea":Zn.track(e),Yn.postMountWrapper(e,n);break;case"option":$n.postMountWrapper(e,n);break;case"select":Gn.postMountWrapper(e,n);break;default:"function"==typeof a.onClick&&(e.onclick=bt)}},diffProperties:function(e,t,n,r,i){var a=null;switch(t){case"input":n=qn.getHostProps(e,n),r=qn.getHostProps(e,r),a=[];break;case"option":n=$n.getHostProps(e,n),r=$n.getHostProps(e,r),a=[];break;case"select":n=Gn.getHostProps(e,n),r=Gn.getHostProps(e,r),a=[];break;case"textarea":n=Yn.getHostProps(e,n),r=Yn.getHostProps(e,r),a=[];break;default:"function"!=typeof n.onClick&&"function"==typeof r.onClick&&(e.onclick=bt)}L(t,r);var o,s;e=null;for(o in n)if(!r.hasOwnProperty(o)&&n.hasOwnProperty(o)&&null!=n[o])if("style"===o)for(s in t=n[o])t.hasOwnProperty(s)&&(e||(e={}),e[s]="");else"dangerouslySetInnerHTML"!==o&&"children"!==o&&"suppressContentEditableWarning"!==o&&(ur.hasOwnProperty(o)?a||(a=[]):(a=a||[]).push(o,null));for(o in r){var u=r[o];if(t=null!=n?n[o]:void 0,r.hasOwnProperty(o)&&u!==t&&(null!=u||null!=t))if("style"===o)if(t){for(s in t)!t.hasOwnProperty(s)||u&&u.hasOwnProperty(s)||(e||(e={}),e[s]="");for(s in u)u.hasOwnProperty(s)&&t[s]!==u[s]&&(e||(e={}),e[s]=u[s])}else e||(a||(a=[]),a.push(o,e)),e=u;else"dangerouslySetInnerHTML"===o?(u=u?u.__html:void 0,t=t?t.__html:void 0,null!=u&&t!==u&&(a=a||[]).push(o,""+u)):"children"===o?t===u||"string"!=typeof u&&"number"!=typeof u||(a=a||[]).push(o,""+u):"suppressContentEditableWarning"!==o&&(ur.hasOwnProperty(o)?(null!=u&&W(i,o),a||t===u||(a=[])):(a=a||[]).push(o,u))}return e&&(a=a||[]).push("style",e),a},updateProperties:function(e,t,n,r,i){z(n,r),r=z(n,i);for(var a=0;at&&(t=8),kr=t=V(c.priorityLevel,o);){n.first=c.next,null===n.first&&(n.last=null);var l;c.isReplace?(i=Q(c,r,i,a),u=!0):(l=Q(c,r,i,a))&&(i=u?gt({},i,l):gt(i,l),u=!1),c.isForced&&(s=!0),null===c.callback||c.isTopLevelUnmount&&null!==c.next||(e=null!==e?e:[],e.push(c.callback),t.effectTag|=Fr),c=c.next}return n.callbackList=e,n.hasForceUpdate=s,null!==n.first||null!==e||s||(t.updateQueue=null),i},commitCallbacks:function(e,t,n){if(null!==(e=t.callbackList))for(t.callbackList=null,t=0;tLr||(e.current=Br[Lr],Br[Lr]=null,Lr--)},push:function(e,t){Lr++,Br[Lr]=e.current,e.current=t},reset:function(){for(;-1e)?e:t}},fi=li.createHostRootFiber,pi=Nt.IndeterminateComponent,hi=Nt.FunctionalComponent,di=Nt.ClassComponent,yi=Nt.HostComponent;"function"==typeof Symbol&&Symbol.for?(_r=Symbol.for("react.coroutine"),Cr=Symbol.for("react.yield")):(_r=60104,Cr=60105);var vi={createCoroutine:function(e,t,n){var r=3t&&(r=t,t=i,i=r),r=ge(e,i),e=ge(e,t),r&&e){var a=document.createRange();a.setStart(r.node,r.offset),n.removeAllRanges(),i>t?(n.addRange(a),n.extend(e.node,e.offset)):(a.setEnd(e.node,e.offset),n.addRange(a))}}}},us=jt.ELEMENT_NODE,cs={hasSelectionCapabilities:function(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&"text"===e.type||"textarea"===t||"true"===e.contentEditable)},getSelectionInformation:function(){var e=_t();return{focusedElem:e,selectionRange:cs.hasSelectionCapabilities(e)?cs.getSelection(e):null}},restoreSelection:function(e){var t=_t(),n=e.focusedElem;if(e=e.selectionRange,t!==n&&xt(document.documentElement,n)){for(cs.hasSelectionCapabilities(n)&&cs.setSelection(n,e),t=[],e=n;e=e.parentNode;)e.nodeType===us&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(St(n),n=0;n=parseInt(Cs.version(),10))}var Is=_s,Rs=vt.canUseDOM&&(!xs||Ss&&8=Ss),Es=String.fromCharCode(32),Fs={beforeInput:{phasedRegistrationNames:{bubbled:"onBeforeInput",captured:"onBeforeInputCapture"},dependencies:["topCompositionEnd","topKeyPress","topTextInput","topPaste"]},compositionEnd:{phasedRegistrationNames:{bubbled:"onCompositionEnd",captured:"onCompositionEndCapture"},dependencies:"topBlur topCompositionEnd topKeyDown topKeyPress topKeyUp topMouseDown".split(" ")},compositionStart:{phasedRegistrationNames:{bubbled:"onCompositionStart",captured:"onCompositionStartCapture"},dependencies:"topBlur topCompositionStart topKeyDown topKeyPress topKeyUp topMouseDown".split(" ")},compositionUpdate:{phasedRegistrationNames:{bubbled:"onCompositionUpdate",captured:"onCompositionUpdateCapture"},dependencies:"topBlur topCompositionUpdate topKeyDown topKeyPress topKeyUp topMouseDown".split(" ")}},Ps=!1,Ds=!1,Os={eventTypes:Fs,extractEvents:function(e,t,n,r){var i;if(xs)e:{switch(e){case"topCompositionStart":var a=Fs.compositionStart;break e;case"topCompositionEnd":a=Fs.compositionEnd;break e;case"topCompositionUpdate":a=Fs.compositionUpdate;break e}a=void 0}else Ds?Te(e,n)&&(a=Fs.compositionEnd):"topKeyDown"===e&&229===n.keyCode&&(a=Fs.compositionStart);return a?(Rs&&(Ds||a!==Fs.compositionStart?a===Fs.compositionEnd&&Ds&&(i=ms.getData()):Ds=ms.initialize(r)),a=Me.getPooled(a,t,n,r),i?a.data=i:null!==(i=Ne(n))&&(a.data=i),ys.accumulateTwoPhaseDispatches(a),i=a):i=null,(e=Is?je(e,n):Be(e,n))?(t=Ae.getPooled(Fs.beforeInput,t,n,r),t.data=e,ys.accumulateTwoPhaseDispatches(t)):t=null,[i,t]}},Ms={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0},As={change:{phasedRegistrationNames:{bubbled:"onChange",captured:"onChangeCapture"},dependencies:"topBlur topChange topClick topFocus topInput topKeyDown topKeyUp topSelectionChange".split(" ")}},Ts=null,Ns=null,js=!1;vt.canUseDOM&&(js=D("input")&&(!document.documentMode||9=document.documentMode,Ws={select:{phasedRegistrationNames:{bubbled:"onSelect",captured:"onSelectCapture"},dependencies:"topBlur topContextMenu topFocus topKeyDown topKeyUp topMouseDown topMouseUp topSelectionChange".split(" ")}},Vs=null,Js=null,qs=null,$s=!1,Gs=Fn.isListeningToAllDependencies,Qs={eventTypes:Ws,extractEvents:function(e,t,n,r){var i=r.window===r?r.document:r.nodeType===zs?r:r.ownerDocument;if(!i||!Gs("onSelect",i))return null;switch(i=t?qt.getNodeFromInstance(t):window,e){case"topFocus":(Le(i)||"true"===i.contentEditable)&&(Vs=i,Js=t,qs=null);break;case"topBlur":qs=Js=Vs=null;break;case"topMouseDown":$s=!0;break;case"topContextMenu":case"topMouseUp":return $s=!1,et(n,r);case"topSelectionChange":if(Ks)break;case"topKeyDown":case"topKeyUp":return et(n,r)}return null}};Fe.augmentClass(tt,{animationName:null,elapsedTime:null,pseudoElement:null}),Fe.augmentClass(nt,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Qe.augmentClass(rt,{relatedTarget:null});var Ys={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Xs={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"};Qe.augmentClass(at,{key:function(e){if(e.key){var t=Ys[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?(e=it(e),13===e?"Enter":String.fromCharCode(e)):"keydown"===e.type||"keyup"===e.type?Xs[e.keyCode]||"Unidentified":""},location:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,repeat:null,locale:null,getModifierState:Xe,charCode:function(e){return"keypress"===e.type?it(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?it(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}}),Ze.augmentClass(ot,{dataTransfer:null}),Qe.augmentClass(st,{touches:null,targetTouches:null,changedTouches:null,altKey:null,metaKey:null,ctrlKey:null,shiftKey:null,getModifierState:Xe}),Fe.augmentClass(ut,{propertyName:null,elapsedTime:null,pseudoElement:null}),Ze.augmentClass(ct,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:null,deltaMode:null});var Zs={},eu={};"abort animationEnd animationIteration animationStart blur cancel canPlay canPlayThrough click close contextMenu copy cut doubleClick drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error focus input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing progress rateChange reset scroll seeked seeking stalled submit suspend timeUpdate toggle touchCancel touchEnd touchMove touchStart transitionEnd volumeChange waiting wheel".split(" ").forEach(function(e){var t=e[0].toUpperCase()+e.slice(1),n="on"+t;t="top"+t,n={phasedRegistrationNames:{bubbled:n,captured:n+"Capture"},dependencies:[t]},Zs[e]=n,eu[t]=n});var tu={eventTypes:Zs,extractEvents:function(e,t,n,i){var a=eu[e];if(!a)return null;switch(e){case"topAbort":case"topCancel":case"topCanPlay":case"topCanPlayThrough":case"topClose":case"topDurationChange":case"topEmptied":case"topEncrypted":case"topEnded":case"topError":case"topInput":case"topInvalid":case"topLoad":case"topLoadedData":case"topLoadedMetadata":case"topLoadStart":case"topPause":case"topPlay":case"topPlaying":case"topProgress":case"topRateChange":case"topReset":case"topSeeked":case"topSeeking":case"topStalled":case"topSubmit":case"topSuspend":case"topTimeUpdate":case"topToggle":case"topVolumeChange":case"topWaiting":var o=Fe;break;case"topKeyPress":if(0===it(n))return null;case"topKeyDown":case"topKeyUp":o=at;break;case"topBlur":case"topFocus":o=rt;break;case"topClick":if(2===n.button)return null;case"topDoubleClick":case"topMouseDown":case"topMouseMove":case"topMouseUp":case"topMouseOut":case"topMouseOver":case"topContextMenu":o=Ze;break;case"topDrag":case"topDragEnd":case"topDragEnter":case"topDragExit":case"topDragLeave":case"topDragOver":case"topDragStart":case"topDrop":o=ot;break;case"topTouchCancel":case"topTouchEnd":case"topTouchMove":case"topTouchStart":o=st;break;case"topAnimationEnd":case"topAnimationIteration":case"topAnimationStart":o=tt;break;case"topTransitionEnd":o=ut;break;case"topScroll":o=Qe;break;case"topWheel":o=ct;break;case"topCopy":case"topCut":case"topPaste":o=nt}return o||r("86",e),e=o.getPooled(a,t,n,i),ys.accumulateTwoPhaseDispatches(e),e}};bn.setHandleTopLevel(Fn.handleTopLevel),wn.injection.injectEventPluginOrder("ResponderEventPlugin SimpleEventPlugin TapEventPlugin EnterLeaveEventPlugin ChangeEventPlugin SelectEventPlugin BeforeInputEventPlugin".split(" ")),un.injection.injectComponentTree(qt),wn.injection.injectEventPluginsByName({SimpleEventPlugin:tu,EnterLeaveEventPlugin:Us,ChangeEventPlugin:Bs,SelectEventPlugin:Qs,BeforeInputEventPlugin:Os});var nu=Tt.injection.MUST_USE_PROPERTY,ru=Tt.injection.HAS_BOOLEAN_VALUE,iu=Tt.injection.HAS_NUMERIC_VALUE,au=Tt.injection.HAS_POSITIVE_NUMERIC_VALUE,ou=Tt.injection.HAS_STRING_BOOLEAN_VALUE,su={Properties:{allowFullScreen:ru,allowTransparency:ou,async:ru,autoPlay:ru,capture:ru,checked:nu|ru,cols:au,contentEditable:ou,controls:ru,default:ru,defer:ru,disabled:ru,download:Tt.injection.HAS_OVERLOADED_BOOLEAN_VALUE,draggable:ou,formNoValidate:ru,hidden:ru,loop:ru,multiple:nu|ru,muted:nu|ru,noValidate:ru,open:ru,playsInline:ru,readOnly:ru,required:ru,reversed:ru,rows:au,rowSpan:iu,scoped:ru,seamless:ru,selected:nu|ru,size:au,start:iu,span:au,spellCheck:ou,style:0,itemScope:ru,acceptCharset:0,className:0,htmlFor:0,httpEquiv:0,value:ou},DOMAttributeNames:{acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv"},DOMMutationMethods:{value:function(e,t){if(null==t)return e.removeAttribute("value");"number"!==e.type||!1===e.hasAttribute("value")?e.setAttribute("value",""+t):e.validity&&!e.validity.badInput&&e.ownerDocument.activeElement!==e&&e.setAttribute("value",""+t)}}},uu=Tt.injection.HAS_STRING_BOOLEAN_VALUE,cu={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},lu={Properties:{autoReverse:uu,externalResourcesRequired:uu,preserveAlpha:uu},DOMAttributeNames:{autoReverse:"autoReverse",externalResourcesRequired:"externalResourcesRequired",preserveAlpha:"preserveAlpha"},DOMAttributeNamespaces:{xlinkActuate:cu.xlink,xlinkArcrole:cu.xlink,xlinkHref:cu.xlink,xlinkRole:cu.xlink,xlinkShow:cu.xlink,xlinkTitle:cu.xlink,xlinkType:cu.xlink,xmlBase:cu.xml,xmlLang:cu.xml,xmlSpace:cu.xml}},fu=/[\-\:]([a-z])/g;"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode x-height xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xmlns:xlink xml:lang xml:space".split(" ").forEach(function(e){var t=e.replace(fu,lt);lu.Properties[t]=0,lu.DOMAttributeNames[t]=e}),Tt.injection.injectDOMPropertyConfig(su),Tt.injection.injectDOMPropertyConfig(lu);var pu=eo.injectInternals,hu=jt.ELEMENT_NODE,du=jt.TEXT_NODE,yu=jt.COMMENT_NODE,vu=jt.DOCUMENT_NODE,gu=jt.DOCUMENT_FRAGMENT_NODE,mu=Tt.ROOT_ATTRIBUTE_NAME,bu=Rt.getChildNamespace,ku=pr.createElement,wu=pr.createTextNode,xu=pr.setInitialProperties,Su=pr.diffProperties,_u=pr.updateProperties,Cu=pr.diffHydratedProperties,Iu=pr.diffHydratedText,Ru=pr.warnForDeletedHydratableElement,Eu=pr.warnForDeletedHydratableText,Fu=pr.warnForInsertedHydratedElement,Pu=pr.warnForInsertedHydratedText,Du=qt.precacheFiberNode,Ou=qt.updateFiberProps;pn.injection.injectFiberControlledHostComponent(pr),we._injectFiber(function(e){return Tu.findHostInstance(e)});var Mu=null,Au=null,Tu=function(e){var t=e.getPublicInstance;e=he(e);var n=e.scheduleUpdate,r=e.getPriorityContext;return{createContainer:function(e){var t=fi();return e={current:t,containerInfo:e,isScheduled:!1,nextScheduledRoot:null,context:null,pendingContext:null},t.stateNode=e},updateContainer:function(e,t,i,a){var o=t.current;i=ye(i),null===t.context?t.context=i:t.pendingContext=i,t=a,a=r(o,Rr.enableAsyncSubtreeAPI&&null!=e&&null!=e.type&&null!=e.type.prototype&&!0===e.type.prototype.unstable_isAsyncReactComponent),e={element:e},Xo(o,e,void 0===t?null:t,a),n(o,a)},batchedUpdates:e.batchedUpdates,unbatchedUpdates:e.unbatchedUpdates,deferredUpdates:e.deferredUpdates,flushSync:e.flushSync,getPublicRootInstance:function(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case ns:return t(e.child.stateNode);default:return e.child.stateNode}},findHostInstance:function(e){return e=rs(e),null===e?null:e.stateNode},findHostInstanceWithNoPortals:function(e){return e=is(e),null===e?null:e.stateNode}}}({getRootHostContext:function(e){if(e.nodeType===vu)e=(e=e.documentElement)?e.namespaceURI:bu(null,"");else{var t=e.nodeType===yu?e.parentNode:e;e=t.namespaceURI||null,t=t.tagName,e=bu(e,t)}return e},getChildHostContext:function(e,t){return bu(e,t)},getPublicInstance:function(e){return e},prepareForCommit:function(){Mu=Fn.isEnabled(),Au=ls.getSelectionInformation(),Fn.setEnabled(!1)},resetAfterCommit:function(){ls.restoreSelection(Au),Au=null,Fn.setEnabled(Mu),Mu=null},createInstance:function(e,t,n,r,i){return e=ku(e,t,n,r),Du(i,e),Ou(e,t),e},appendInitialChild:function(e,t){e.appendChild(t)},finalizeInitialChildren:function(e,t,n,r){xu(e,t,n,r);e:{switch(t){case"button":case"input":case"select":case"textarea":e=!!n.autoFocus;break e}e=!1}return e},prepareUpdate:function(e,t,n,r,i){return Su(e,t,n,r,i)},commitMount:function(e){e.focus()},commitUpdate:function(e,t,n,r,i){Ou(e,i),_u(e,t,n,r,i)},shouldSetTextContent:function(e,t){return"textarea"===e||"string"==typeof t.children||"number"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&"string"==typeof t.dangerouslySetInnerHTML.__html},resetTextContent:function(e){e.textContent=""},shouldDeprioritizeSubtree:function(e,t){return!!t.hidden},createTextInstance:function(e,t,n,r){return e=wu(e,t),Du(r,e),e},commitTextUpdate:function(e,t,n){e.nodeValue=n},appendChild:function(e,t){e.appendChild(t)},appendChildToContainer:function(e,t){e.nodeType===yu?e.parentNode.insertBefore(t,e):e.appendChild(t)},insertBefore:function(e,t,n){e.insertBefore(t,n)},insertInContainerBefore:function(e,t,n){e.nodeType===yu?e.parentNode.insertBefore(t,n):e.insertBefore(t,n)},removeChild:function(e,t){e.removeChild(t)},removeChildFromContainer:function(e,t){e.nodeType===yu?e.parentNode.removeChild(t):e.removeChild(t)},canHydrateInstance:function(e,t){return e.nodeType===hu&&t===e.nodeName.toLowerCase()},canHydrateTextInstance:function(e,t){return""!==t&&e.nodeType===du},getNextHydratableSibling:function(e){for(e=e.nextSibling;e&&e.nodeType!==hu&&e.nodeType!==du;)e=e.nextSibling;return e},getFirstHydratableChild:function(e){for(e=e.firstChild;e&&e.nodeType!==hu&&e.nodeType!==du;)e=e.nextSibling;return e},hydrateInstance:function(e,t,n,r,i,a){return Du(a,e),Ou(e,n),Cu(e,t,n,i,r)},hydrateTextInstance:function(e,t,n){return Du(n,e),Iu(e,t)},didNotHydrateInstance:function(e,t){1===t.nodeType?Ru(e,t):Eu(e,t)},didNotFindHydratableInstance:function(e,t,n){Fu(e,t,n)},didNotFindHydratableTextInstance:function(e,t){Pu(e,t)},scheduleDeferredCallback:Ir.rIC,useSyncScheduling:!0});dn.injection.injectFiberBatchedUpdates(Tu.batchedUpdates);var Nu={createPortal:dt,hydrate:function(e,t,n){return ht(null,e,t,!0,n)},render:function(e,t,n){return ht(null,e,t,!1,n)},unstable_renderSubtreeIntoContainer:function(e,t,n,i){return null!=e&&$t.has(e)||r("38"),ht(e,t,n,!1,i)},unmountComponentAtNode:function(e){return ft(e)||r("40"),!!e._reactRootContainer&&(Tu.unbatchedUpdates(function(){ht(null,null,e,!1,function(){e._reactRootContainer=null})}),!0)},findDOMNode:we,unstable_createPortal:dt,unstable_batchedUpdates:dn.batchedUpdates,unstable_deferredUpdates:Tu.deferredUpdates,flushSync:Tu.flushSync,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{EventPluginHub:wn,EventPluginRegistry:Dt,EventPropagators:ys,ReactControlledComponent:pn,ReactDOMComponentTree:qt,ReactDOMEventListener:bn}};pu({findFiberByHostInstance:qt.getClosestInstanceFromNode,findHostInstanceByFiber:Tu.findHostInstance,bundleType:0,version:"16.0.1",rendererPackageName:"react-dom"}),e.exports=Nu},function(e,t,n){"use strict";var r=!("undefined"==typeof window||!window.document||!window.document.createElement),i={canUseDOM:r,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:r&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:r&&!!window.screen,isInWorker:!r};e.exports=i},function(e,t,n){"use strict";var r=n(1),i={listen:function(e,t,n){return e.addEventListener?(e.addEventListener(t,n,!1),{remove:function(){e.removeEventListener(t,n,!1)}}):e.attachEvent?(e.attachEvent("on"+t,n),{remove:function(){e.detachEvent("on"+t,n)}}):void 0},capture:function(e,t,n){return e.addEventListener?(e.addEventListener(t,n,!0),{remove:function(){e.removeEventListener(t,n,!0)}}):{remove:r}},registerDefault:function(){}};e.exports=i},function(e,t,n){"use strict";function r(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!==e&&t!==t}function i(e,t){if(r(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var o=0;o0&&(r=r.concat(i)),r}},{key:"isMobile",get:function(){return g.a.get().filesafe.isMobile()}}]),t}(v.a.Component)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=n.n(r),a=n(2),o=n.n(a),s=n(5);t.default={FilesafeEmbed:s.a,React:i.a,ReactDOM:o.a}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?o(e):t}function o(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){for(var n=0;n1&&!t.content.isDefault&&d.a.createElement("a",{className:"info",onClick:function(){e.setCredentialAsDefault(t)}},"Make Default"),d.a.createElement("a",{className:"info",onClick:function(){e.exportCredential(t)}},"Export"),d.a.createElement("a",{className:"danger",onClick:function(){e.deleteCredential(t)}},"Delete")))))})))}}]),t}(d.a.Component)},function(e,t){e.exports=function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,n){(function(t){var n,n;!function(t){e.exports=t()}(function(){return function(){function e(t,r,i){function a(s,u){if(!r[s]){if(!t[s]){var c="function"==typeof n&&n;if(!u&&c)return n(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var f=r[s]={exports:{}};t[s][0].call(f.exports,function(e){return a(t[s][1][e]||e)},f,f.exports,e,t,r,i)}return r[s].exports}for(var o="function"==typeof n&&n,s=0;s>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,o=0;4>o&&i+.75*o>>6*(3-o)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var n=e.length,r=this._map,i=r.charAt(64);i&&-1!=(i=e.indexOf(i))&&(n=i);for(var i=[],a=0,o=0;o>>6-o%4*2;i[a>>>2]|=(s|u)<<24-a%4*8,a++}return t.create(i,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){function t(e,t,n,r,i,a,o){return((e=e+(t&n|~t&r)+i+o)<>>32-a)+t}function n(e,t,n,r,i,a,o){return((e=e+(t&r|n&~r)+i+o)<>>32-a)+t}function r(e,t,n,r,i,a,o){return((e=e+(t^n^r)+i+o)<>>32-a)+t}function i(e,t,n,r,i,a,o){return((e=e+(n^(t|~r))+i+o)<>>32-a)+t}for(var a=o,s=a.lib,u=s.WordArray,c=s.Hasher,s=a.algo,l=[],f=0;64>f;f++)l[f]=4294967296*e.abs(e.sin(f+1))|0;s=s.MD5=c.extend({_doReset:function(){this._hash=new u.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,a){for(var o=0;16>o;o++){var s=a+o,u=e[s];e[s]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}var o=this._hash.words,s=e[a+0],u=e[a+1],c=e[a+2],f=e[a+3],p=e[a+4],h=e[a+5],d=e[a+6],y=e[a+7],v=e[a+8],g=e[a+9],m=e[a+10],b=e[a+11],k=e[a+12],w=e[a+13],x=e[a+14],S=e[a+15],_=o[0],C=o[1],I=o[2],R=o[3],_=t(_,C,I,R,s,7,l[0]),R=t(R,_,C,I,u,12,l[1]),I=t(I,R,_,C,c,17,l[2]),C=t(C,I,R,_,f,22,l[3]),_=t(_,C,I,R,p,7,l[4]),R=t(R,_,C,I,h,12,l[5]),I=t(I,R,_,C,d,17,l[6]),C=t(C,I,R,_,y,22,l[7]),_=t(_,C,I,R,v,7,l[8]),R=t(R,_,C,I,g,12,l[9]),I=t(I,R,_,C,m,17,l[10]),C=t(C,I,R,_,b,22,l[11]),_=t(_,C,I,R,k,7,l[12]),R=t(R,_,C,I,w,12,l[13]),I=t(I,R,_,C,x,17,l[14]),C=t(C,I,R,_,S,22,l[15]),_=n(_,C,I,R,u,5,l[16]),R=n(R,_,C,I,d,9,l[17]),I=n(I,R,_,C,b,14,l[18]),C=n(C,I,R,_,s,20,l[19]),_=n(_,C,I,R,h,5,l[20]),R=n(R,_,C,I,m,9,l[21]),I=n(I,R,_,C,S,14,l[22]),C=n(C,I,R,_,p,20,l[23]),_=n(_,C,I,R,g,5,l[24]),R=n(R,_,C,I,x,9,l[25]),I=n(I,R,_,C,f,14,l[26]),C=n(C,I,R,_,v,20,l[27]),_=n(_,C,I,R,w,5,l[28]),R=n(R,_,C,I,c,9,l[29]),I=n(I,R,_,C,y,14,l[30]),C=n(C,I,R,_,k,20,l[31]),_=r(_,C,I,R,h,4,l[32]),R=r(R,_,C,I,v,11,l[33]),I=r(I,R,_,C,b,16,l[34]),C=r(C,I,R,_,x,23,l[35]),_=r(_,C,I,R,u,4,l[36]),R=r(R,_,C,I,p,11,l[37]),I=r(I,R,_,C,y,16,l[38]),C=r(C,I,R,_,m,23,l[39]),_=r(_,C,I,R,w,4,l[40]),R=r(R,_,C,I,s,11,l[41]),I=r(I,R,_,C,f,16,l[42]),C=r(C,I,R,_,d,23,l[43]),_=r(_,C,I,R,g,4,l[44]),R=r(R,_,C,I,k,11,l[45]),I=r(I,R,_,C,S,16,l[46]),C=r(C,I,R,_,c,23,l[47]),_=i(_,C,I,R,s,6,l[48]),R=i(R,_,C,I,y,10,l[49]),I=i(I,R,_,C,x,15,l[50]),C=i(C,I,R,_,h,21,l[51]),_=i(_,C,I,R,k,6,l[52]),R=i(R,_,C,I,f,10,l[53]),I=i(I,R,_,C,m,15,l[54]),C=i(C,I,R,_,u,21,l[55]),_=i(_,C,I,R,v,6,l[56]),R=i(R,_,C,I,S,10,l[57]),I=i(I,R,_,C,d,15,l[58]),C=i(C,I,R,_,w,21,l[59]),_=i(_,C,I,R,p,6,l[60]),R=i(R,_,C,I,b,10,l[61]),I=i(I,R,_,C,c,15,l[62]),C=i(C,I,R,_,g,21,l[63]);o[0]=o[0]+_|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+R|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var a=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),t=this._hash,n=t.words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=c.clone.call(this);return e._hash=this._hash.clone(),e}}),a.MD5=c._createHelper(s),a.HmacMD5=c._createHmacHelper(s)}(Math),function(){var e=o,t=e.lib,n=t.Base,r=t.WordArray,t=e.algo,i=t.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=this.cfg,i=n.hasher.create(),a=r.create(),o=a.words,s=n.keySize,n=n.iterations;o.length>>2]}},n.BlockCipher=c.extend({cfg:c.cfg.extend({mode:l,padding:p}),reset:function(){c.reset.call(this);var e=this.cfg,t=e.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(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var h=n.CipherParams=r.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),l=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return e=e.salt,(e?i.create([1398893684,1701076831]).concat(e).concat(t):t).toString(s)},parse:function(e){e=s.parse(e);var t=e.words;if(1398893684==t[0]&&1701076831==t[1]){var n=i.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return h.create({ciphertext:e,salt:n})}},d=n.SerializableCipher=r.extend({cfg:r.extend({format:l}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,h.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),t=(t.kdf={}).OpenSSL={execute:function(e,t,n,r){return r||(r=i.random(8)),e=u.create({keySize:t+n}).compute(e,r),n=i.create(e.words.slice(t),4*n),e.sigBytes=4*t,h.create({key:e,iv:n,salt:r})}},y=n.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:t}),encrypt:function(e,t,n,r){return r=this.cfg.extend(r),n=r.kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,e=d.encrypt.call(this,e,t,n.key,r),e.mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,d.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=o,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],a=[],s=[],u=[],c=[],l=[],f=[],p=[],h=[],d=[],y=0;256>y;y++)d[y]=128>y?y<<1:y<<1^283;for(var v=0,g=0,y=0;256>y;y++){var m=g^g<<1^g<<2^g<<3^g<<4,m=m>>>8^255&m^99;r[v]=m,i[m]=v;var b=d[v],k=d[b],w=d[k],x=257*d[m]^16843008*m;a[v]=x<<24|x>>>8,s[v]=x<<16|x>>>16,u[v]=x<<8|x>>>24,c[v]=x,x=16843009*w^65537*k^257*b^16843008*v,l[m]=x<<24|x>>>8,f[m]=x<<16|x>>>16,p[m]=x<<8|x>>>24,h[m]=x,v?(v=b^d[d[d[w^b]]],g^=d[d[g]]):v=g=1}var S=[0,1,2,4,8,16,32,64,128,27,54],n=n.AES=t.extend({_doReset:function(){for(var e=this._key,t=e.words,n=e.sigBytes/4,e=4*((this._nRounds=n+6)+1),i=this._keySchedule=[],a=0;a>>24]<<24|r[o>>>16&255]<<16|r[o>>>8&255]<<8|r[255&o]):(o=o<<8|o>>>24,o=r[o>>>24]<<24|r[o>>>16&255]<<16|r[o>>>8&255]<<8|r[255&o],o^=S[a/n|0]<<24),i[a]=i[a-n]^o}for(t=this._invKeySchedule=[],n=0;nn||4>=a?o:l[r[o>>>24]]^f[r[o>>>16&255]]^p[r[o>>>8&255]]^h[r[255&o]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,u,c,r)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,l,f,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,a,o,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],f=e[t+2]^n[2],p=e[t+3]^n[3],h=4,d=1;d>>24]^i[l>>>16&255]^a[f>>>8&255]^o[255&p]^n[h++],v=r[l>>>24]^i[f>>>16&255]^a[p>>>8&255]^o[255&c]^n[h++],g=r[f>>>24]^i[p>>>16&255]^a[c>>>8&255]^o[255&l]^n[h++],p=r[p>>>24]^i[c>>>16&255]^a[l>>>8&255]^o[255&f]^n[h++],c=y,l=v,f=g;y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[f>>>8&255]<<8|s[255&p])^n[h++],v=(s[l>>>24]<<24|s[f>>>16&255]<<16|s[p>>>8&255]<<8|s[255&c])^n[h++],g=(s[f>>>24]<<24|s[p>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[h++],p=(s[p>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&f])^n[h++],e[t]=y,e[t+1]=v,e[t+2]=g,e[t+3]=p},keySize:8});e.AES=t._createHelper(n)}();var o=o||function(e,t){var n={},r=n.lib={},i=function(){},a=r.Base={extend:function(e){i.prototype=this;var t=new i;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=r.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;ul;){var f;e:{f=c;for(var p=e.sqrt(f),h=2;h<=p;h++)if(!(f%h)){f=!1;break e}f=!0}f&&(8>l&&(a[l]=u(e.pow(c,.5))),s[l]=u(e.pow(c,1/3)),l++),c++}var d=[],n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],a=n[2],o=n[3],u=n[4],c=n[5],l=n[6],f=n[7],p=0;64>p;p++){if(16>p)d[p]=0|e[t+p];else{var h=d[p-15],y=d[p-2];d[p]=((h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3)+d[p-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+d[p-16]}h=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[p]+d[p],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&a^i&a),f=l,l=c,c=u,u=o+h|0,o=a,a=i,i=r,r=h+y|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+f|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(n),t.HmacSHA256=i._createHmacHelper(n)}(Math),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var a=this._oKey=n.clone(),o=this._iKey=n.clone(),s=a.words,u=o.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;uc;c++)u[c]=e();r=r.SHA512=n.extend({_doReset:function(){this._hash=new a.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],a=n[2],o=n[3],c=n[4],l=n[5],f=n[6],n=n[7],p=r.high,h=r.low,d=i.high,y=i.low,v=a.high,g=a.low,m=o.high,b=o.low,k=c.high,w=c.low,x=l.high,S=l.low,_=f.high,C=f.low,I=n.high,R=n.low,E=p,F=h,P=d,D=y,O=v,M=g,A=m,T=b,N=k,j=w,B=x,L=S,H=_,U=C,z=I,K=R,W=0;80>W;W++){var V=u[W];if(16>W)var J=V.high=0|e[t+2*W],q=V.low=0|e[t+2*W+1];else{var J=u[W-15],q=J.high,$=J.low,J=(q>>>1|$<<31)^(q>>>8|$<<24)^q>>>7,$=($>>>1|q<<31)^($>>>8|q<<24)^($>>>7|q<<25),G=u[W-2],q=G.high,Q=G.low,G=(q>>>19|Q<<13)^(q<<3|Q>>>29)^q>>>6,Q=(Q>>>19|q<<13)^(Q<<3|q>>>29)^(Q>>>6|q<<26),q=u[W-7],Y=q.high,X=u[W-16],Z=X.high,X=X.low,q=$+q.low,J=J+Y+(q>>>0<$>>>0?1:0),q=q+Q,J=J+G+(q>>>0>>0?1:0),q=q+X,J=J+Z+(q>>>0>>0?1:0);V.high=J,V.low=q}var Y=N&B^~N&H,X=j&L^~j&U,V=E&P^E&O^P&O,ee=F&D^F&M^D&M,$=(E>>>28|F<<4)^(E<<30|F>>>2)^(E<<25|F>>>7),G=(F>>>28|E<<4)^(F<<30|E>>>2)^(F<<25|E>>>7),Q=s[W],te=Q.high,ne=Q.low,Q=K+((j>>>14|N<<18)^(j>>>18|N<<14)^(j<<23|N>>>9)),Z=z+((N>>>14|j<<18)^(N>>>18|j<<14)^(N<<23|j>>>9))+(Q>>>0>>0?1:0),Q=Q+X,Z=Z+Y+(Q>>>0>>0?1:0),Q=Q+ne,Z=Z+te+(Q>>>0>>0?1:0),Q=Q+q,Z=Z+J+(Q>>>0>>0?1:0),q=G+ee,V=$+V+(q>>>0>>0?1:0),z=H,K=U,H=B,U=L,B=N,L=j,j=T+Q|0,N=A+Z+(j>>>0>>0?1:0)|0,A=O,T=M,O=P,M=D,P=E,D=F,F=Q+q|0,E=Z+V+(F>>>0>>0?1:0)|0}h=r.low=h+F,r.high=p+E+(h>>>0>>0?1:0),y=i.low=y+D,i.high=d+P+(y>>>0>>0?1:0),g=a.low=g+M,a.high=v+O+(g>>>0>>0?1:0),b=o.low=b+T,o.high=m+A+(b>>>0>>0?1:0),w=c.low=w+j,c.high=k+N+(w>>>0>>0?1:0),S=l.low=S+L,l.high=x+B+(S>>>0>>0?1:0),C=f.low=C+U,f.high=_+H+(C>>>0>>0?1:0),R=n.low=R+K,n.high=I+z+(R>>>0>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(r+128>>>10<<5)]=Math.floor(n/4294967296),t[31+(r+128>>>10<<5)]=n,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32}),t.SHA512=n._createHelper(r),t.HmacSHA512=n._createHmacHelper(r)}(),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var a=this._oKey=n.clone(),o=this._iKey=n.clone(),s=a.words,u=o.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;uc;c++){if(16>c)i[c]=0|e[t+c];else{var l=i[c-3]^i[c-8]^i[c-14]^i[c-16];i[c]=l<<1|l>>>31}l=(r<<5|r>>>27)+u+i[c],l=20>c?l+(1518500249+(a&o|~a&s)):40>c?l+(1859775393+(a^o^s)):60>c?l+((a&o|a&s|o&s)-1894007588):l+((a^o^s)-899497514),u=s,s=o,o=a<<30|a>>>2,a=r,r=l}n[0]=n[0]+r|0,n[1]=n[1]+a|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});e.SHA1=r._createHelper(t),e.HmacSHA1=r._createHmacHelper(t)}(),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var a=this._oKey=n.clone(),o=this._iKey=n.clone(),s=a.words,u=o.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;uc;c++){if(16>c)i[c]=0|e[t+c];else{var l=i[c-3]^i[c-8]^i[c-14]^i[c-16];i[c]=l<<1|l>>>31}l=(r<<5|r>>>27)+u+i[c],l=20>c?l+(1518500249+(a&o|~a&s)):40>c?l+(1859775393+(a^o^s)):60>c?l+((a&o|a&s|o&s)-1894007588):l+((a^o^s)-899497514),u=s,s=o,o=a<<30|a>>>2,a=r,r=l}n[0]=n[0]+r|0,n[1]=n[1]+a|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});e.SHA1=r._createHelper(t),e.HmacSHA1=r._createHmacHelper(t)}(),Object.defineProperty(r,"__esModule",{value:!0});var s,u=function(){function e(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l=function(){function e(e,t){for(var n=0;n=200&&c.status<=299?s.$timeout(function(){a(e),i(e)}):(console.error("Request error:",e),s.$timeout(function(){o(e,c.status),u(e)}))}},"get"==t&&Object.keys(r).length>0&&(n+=s.formatParams(r)),c.open(t,n,!0),e.next=6,s.setAuthHeadersForRequest(c);case 6:c.setRequestHeader("Content-type","application/json"),"post"==t||"patch"==t?c.send(JSON.stringify(r)):c.send();case 8:case"end":return e.stop()}},e,s)}));return function(t,n){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"formatParams",value:function(e){return"?"+Object.keys(e).map(function(t){return t+"="+encodeURIComponent(e[t])}).join("&")}}]),e}(),y=r.SFMigrationManager=function(){function e(t,n,r,o){var s=this;a(this,e),this.modelManager=t,this.syncManager=n,this.storageManager=r,this.completionHandlers=[],this.loadMigrations();var u=!1,c=o.addEventHandler(function(e){e==p.DidSignInEvent&&(u=!0)});this.syncManager.addEventHandler(function(){var e=i(regeneratorRuntime.mark(function e(t,n){var r,i,a,l,f,p,h,d,y,v;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r="local-data-loaded"==t,i="sync:completed"==t,!r&&!i){e.next=40;break}if(r?s.receivedLocalDataEvent=!0:i&&(s.receivedSyncCompletedEvent=!0),!s.receivedLocalDataEvent||!s.receivedSyncCompletedEvent){e.next=40;break}if(!u){e.next=39;break}return u=!1,o.removeEventHandler(c),e.next=10,s.getCompletedMigrations();case 10:a=e.sent.slice(),l=!0,f=!1,p=void 0,e.prev=14,h=a[Symbol.iterator]();case 16:if(l=(d=h.next()).done){e.next=25;break}return y=d.value,e.next=20,s.migrationForEncodedName(y);case 20:v=e.sent,v.runOnlyOnce||_.pull(s._completed,y);case 22:l=!0,e.next=16;break;case 25:e.next=31;break;case 27:e.prev=27,e.t0=e.catch(14),f=!0,p=e.t0;case 31:e.prev=31,e.prev=32,!l&&h.return&&h.return();case 34:if(e.prev=34,!f){e.next=37;break}throw p;case 37:return e.finish(34);case 38:return e.finish(31);case 39:s.runPendingMigrations();case 40:case"end":return e.stop()}},e,s,[[14,27,31,39],[32,,34,38]])}));return function(t,n){return e.apply(this,arguments)}}())}return l(e,[{key:"addCompletionHandler",value:function(e){this.completionHandlers.push(e)}},{key:"removeCompletionHandler",value:function(e){_.pull(this.completionHandlers,e)}},{key:"migrationForEncodedName",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.decode(t);case 2:return n=e.sent,e.abrupt("return",this.migrations.find(function(e){return e.name==n}));case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"loadMigrations",value:function(){this.migrations=this.registeredMigrations()}},{key:"registeredMigrations",value:function(){}},{key:"runPendingMigrations",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a,o,s,u,c,l,f,p,h,d,y,v,g,m,b,k,w,x,S,_,C,I,R,E,F;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPendingMigrations();case 2:for(t=e.sent,n=!0,r=!1,i=void 0,e.prev=6,a=t[Symbol.iterator]();!(n=(o=a.next()).done);n=!0)s=o.value,s.items=[];e.next=14;break;case 10:e.prev=10,e.t0=e.catch(6),r=!0,i=e.t0;case 14:e.prev=14,e.prev=15,!n&&a.return&&a.return();case 17:if(e.prev=17,!r){e.next=20;break}throw i;case 20:return e.finish(17);case 21:return e.finish(14);case 22:u=!0,c=!1,l=void 0,e.prev=25,f=this.modelManager.allNondummyItems[Symbol.iterator]();case 27:if(u=(p=f.next()).done){e.next=51;break}for(h=p.value,d=!0,y=!1,v=void 0,e.prev=32,g=t[Symbol.iterator]();!(d=(m=g.next()).done);d=!0)s=m.value,h.content_type==s.content_type&&s.items.push(h);e.next=40;break;case 36:e.prev=36,e.t1=e.catch(32),y=!0,v=e.t1;case 40:e.prev=40,e.prev=41,!d&&g.return&&g.return();case 43:if(e.prev=43,!y){e.next=46;break}throw v;case 46:return e.finish(43);case 47:return e.finish(40);case 48:u=!0,e.next=27;break;case 51:e.next=57;break;case 53:e.prev=53,e.t2=e.catch(25),c=!0,l=e.t2;case 57:e.prev=57,e.prev=58,!u&&f.return&&f.return();case 60:if(e.prev=60,!c){e.next=63;break}throw l;case 63:return e.finish(60);case 64:return e.finish(57);case 65:b=!0,k=!1,w=void 0,e.prev=68,x=t[Symbol.iterator]();case 70:if(b=(S=x.next()).done){e.next=81;break}if(s=S.value,!(s.items&&s.items.length>0||s.customHandler)){e.next=77;break}return e.next=75,this.runMigration(s,s.items);case 75:e.next=78;break;case 77:this.markMigrationCompleted(s);case 78:b=!0,e.next=70;break;case 81:e.next=87;break;case 83:e.prev=83,e.t3=e.catch(68),k=!0,w=e.t3;case 87:e.prev=87,e.prev=88,!b&&x.return&&x.return();case 90:if(e.prev=90,!k){e.next=93;break}throw w;case 93:return e.finish(90);case 94:return e.finish(87);case 95:for(_=!0,C=!1,I=void 0,e.prev=98,R=this.completionHandlers[Symbol.iterator]();!(_=(E=R.next()).done);_=!0)(F=E.value)();e.next=106;break;case 102:e.prev=102,e.t4=e.catch(98),C=!0,I=e.t4;case 106:e.prev=106,e.prev=107,!_&&R.return&&R.return();case 109:if(e.prev=109,!C){e.next=112;break}throw I;case 112:return e.finish(109);case 113:return e.finish(106);case 114:case"end":return e.stop()}},e,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]])}));return e}()},{key:"encode",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",window.btoa(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"decode",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",window.atob(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"getCompletedMigrations",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._completed){e.next=5;break}return e.next=3,this.storageManager.getItem("migrations");case 3:t=e.sent,this._completed=t?JSON.parse(t):[];case 5:return e.abrupt("return",this._completed);case 6:case"end":return e.stop()}},e,this)}));return e}()},{key:"getPendingMigrations",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a,o,s,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getCompletedMigrations();case 2:t=e.sent,n=[],r=!0,i=!1,a=void 0,e.prev=7,o=this.migrations[Symbol.iterator]();case 9:if(r=(s=o.next()).done){e.next=22;break}return u=s.value,e.t0=t,e.next=14,this.encode(u.name);case 14:if(e.t1=e.sent,e.t2=e.t0.indexOf.call(e.t0,e.t1),e.t3=-1,e.t2!=e.t3){e.next=19;break}n.push(u);case 19:r=!0,e.next=9;break;case 22:e.next=28;break;case 24:e.prev=24,e.t4=e.catch(7),i=!0,a=e.t4;case 28:e.prev=28,e.prev=29,!r&&o.return&&o.return();case 31:if(e.prev=31,!i){e.next=34;break}throw a;case 34:return e.finish(31);case 35:return e.finish(28);case 36:return e.abrupt("return",n);case 37:case"end":return e.stop()}},e,this,[[7,24,28,36],[29,,31,35]])}));return e}()},{key:"markMigrationCompleted",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getCompletedMigrations();case 2:return n=e.sent,e.t0=n,e.next=6,this.encode(t.name);case 6:e.t1=e.sent,e.t0.push.call(e.t0,e.t1),this.storageManager.setItem("migrations",JSON.stringify(n)),t.running=!1;case 10:case"end":return e.stop()}},e,this)}));return e}()},{key:"runMigration",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.running){e.next=2;break}return e.abrupt("return");case 2:if(console.log("Running migration:",t.name),t.running=!0,!t.customHandler){e.next=8;break}return e.abrupt("return",t.customHandler().then(function(){r.markMigrationCompleted(t)}));case 8:return e.abrupt("return",t.handler(n).then(function(){r.markMigrationCompleted(t)}));case 9:case"end":return e.stop()}},e,this)}));return e}()}]),e}(),v=r.SFModelManager=function(){function e(t){a(this,e),e.MappingSourceRemoteRetrieved="MappingSourceRemoteRetrieved",e.MappingSourceRemoteSaved="MappingSourceRemoteSaved",e.MappingSourceLocalSaved="MappingSourceLocalSaved",e.MappingSourceLocalRetrieved="MappingSourceLocalRetrieved",e.MappingSourceComponentRetrieved="MappingSourceComponentRetrieved",e.MappingSourceDesktopInstalled="MappingSourceDesktopInstalled",e.MappingSourceRemoteActionRetrieved="MappingSourceRemoteActionRetrieved",e.MappingSourceFileImport="MappingSourceFileImport",e.isMappingSourceRetrieved=function(t){return[e.MappingSourceRemoteRetrieved,e.MappingSourceComponentRetrieved,e.MappingSourceRemoteActionRetrieved].includes(t)},this.$timeout=t||setTimeout.bind(window),this.itemSyncObservers=[],this.itemsPendingRemoval=[],this.items=[],this.itemsHash={},this.missedReferences={},this.uuidChangeObservers=[]}return l(e,[{key:"handleSignout",value:function(){this.items.length=0,this.itemsHash={},this.itemsPendingRemoval.length=0,this.missedReferences={}}},{key:"addModelUuidChangeObserver",value:function(e,t){this.uuidChangeObservers.push({id:e,callback:t})}},{key:"notifyObserversOfUuidChange",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.uuidChangeObservers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){a.value.callback(e,t)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"alternateUUIDForItem",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.createItem(n,!0),t.next=3,SFJS.crypto.generateUUID();case 3:for(r.uuid=t.sent,r.informReferencesOfUUIDChange(n.uuid,r.uuid),this.informModelsOfUUIDChangeForItem(r,n.uuid,r.uuid),i=!0,a=!1,o=void 0,t.prev=9,s=n.referencingObjects[Symbol.iterator]();!(i=(u=s.next()).done);i=!0)c=u.value,c.setIsNoLongerBeingReferencedBy(n),n.setIsNoLongerBeingReferencedBy(c),c.addItemAsRelationship(r),c.setDirty(!0);t.next=17;break;case 13:t.prev=13,t.t0=t.catch(9),a=!0,o=t.t0;case 17:t.prev=17,t.prev=18,!i&&s.return&&s.return();case 20:if(t.prev=20,!a){t.next=23;break}throw o;case 23:return t.finish(20);case 24:return t.finish(17);case 25:return this.resolveReferencesForItem(r),console.log(n.uuid,"--\x3e",r.uuid),n.deleted=!0,n.content.references=[],n.setDirty(!1),this.mapResponseItemsToLocalModels([n],e.MappingSourceLocalSaved),this.addItem(r),r.setDirty(!0),this.notifyObserversOfUuidChange(n,r),t.abrupt("return",r);case 35:case"end":return t.stop()}},t,this,[[9,13,17,25],[18,,20,24]])}));return t}()},{key:"informModelsOfUUIDChangeForItem",value:function(e,t,n){var r=!0,i=!1,a=void 0;try{for(var o,s=this.items[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){o.value.potentialItemOfInterestHasChangedItsUUID(e,t,n)}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}}},{key:"didSyncModelsOffline",value:function(t){this.notifySyncObserversOfModels(t,e.MappingSourceLocalSaved)}},{key:"mapResponseItemsToLocalModels",value:function(e,t,n){return this.mapResponseItemsToLocalModelsWithOptions({items:e,source:t,sourceKey:n})}},{key:"mapResponseItemsToLocalModelsOmittingFields",value:function(e,t,n,r){return this.mapResponseItemsToLocalModelsWithOptions({items:e,omitFields:t,source:n,sourceKey:r})}},{key:"mapResponseItemsToLocalModelsWithOptions",value:function(e){var t=e.items,n=e.omitFields,r=e.source,i=e.sourceKey,a=(e.options,[]),o=[],s=[],c=!0,l=!1,f=void 0;try{for(var p,h=t[Symbol.iterator]();!(c=(p=h.next()).done);c=!0){var d=p.value;if(d){var y=!d.content&&!d.errorDecrypting;if(!(!d.content_type||!d.uuid)&&!y||d.deleted){if(Array.isArray(n)){var v=!0,g=!1,m=void 0;try{for(var b,k=n[Symbol.iterator]();!(v=(b=k.next()).done);v=!0){delete d[b.value]}}catch(e){g=!0,m=e}finally{try{!v&&k.return&&k.return()}finally{if(g)throw m}}}var w=this.findItem(d.uuid);if(w&&(w.updateFromJSON(d),w.dummy=!1),this.itemsPendingRemoval.includes(d.uuid))_.pull(this.itemsPendingRemoval,d.uuid);else{var x=d.content_type||w&&w.content_type;if(!(this.acceptableContentTypes&&!this.acceptableContentTypes.includes(x))){var S=!1;if(1==d.deleted){if(!d.dirty){w&&(s.push(w),this.removeItemLocally(w));continue}S=!0}w||(w=this.createItem(d,!0)),this.addItem(w,S),w.errorDecrypting||s.push(w),a.push(w),o.push(d)}}}else console.error("Server response item is corrupt:",d)}}}catch(e){l=!0,f=e}finally{try{!c&&h.return&&h.return()}finally{if(l)throw f}}var C=!0,I=!1,R=void 0;try{for(var E,F=o.entries()[Symbol.iterator]();!(C=(E=F.next()).done);C=!0){var P=E.value,D=u(P,2),O=D[0],M=D[1],A=a[O];M.content&&this.resolveReferencesForItem(A),A.didFinishSyncing()}}catch(e){I=!0,R=e}finally{try{!C&&F.return&&F.return()}finally{if(I)throw R}}var T=this.popMissedReferenceStructsForObjects(o),N=!0,j=!1,B=void 0;try{for(var L,H=T[Symbol.iterator]();!(N=(L=H.next()).done);N=!0){var U=L.value;!function(e){var t=a.find(function(t){return t.uuid==e.reference_uuid});if(t){e.for_item.addItemAsRelationship(t)}}(U)}}catch(e){j=!0,B=e}finally{try{!N&&H.return&&H.return()}finally{if(j)throw B}}return this.notifySyncObserversOfModels(s,r,i),a}},{key:"missedReferenceBuildKey",value:function(e,t){return e+":"+t}},{key:"popMissedReferenceStructsForObjects",value:function(e){if(!e||0==e.length)return[];var t=[],n=[],r=e.map(function(e){return e.uuid}),i=r[0].length,a=Object.keys(this.missedReferences),o=!0,s=!1,u=void 0;try{for(var c,l=a[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var f=c.value;r.includes(f.substring(0,i))&&(t.push(this.missedReferences[f]),n.push(f))}}catch(e){s=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw u}}var p=!0,h=!1,d=void 0;try{for(var y,v=n[Symbol.iterator]();!(p=(y=v.next()).done);p=!0){var g=y.value;delete this.missedReferences[g]}}catch(e){h=!0,d=e}finally{try{!p&&v.return&&v.return()}finally{if(h)throw d}}return t}},{key:"resolveReferencesForItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e.errorDecrypting){var n=e.contentObject;if(e.updateLocalRelationships(),n.references){var r=n.references.slice(),i=r.map(function(e){return e.uuid}),a=this.findItems(i,!0),o=!0,s=!1,c=void 0;try{for(var l,f=a.entries()[Symbol.iterator]();!(o=(l=f.next()).done);o=!0){var p=l.value,h=u(p,2),d=h[0],y=h[1];if(y)e.addItemAsRelationship(y),t&&y.setDirty(!0);else{var v=i[d],g=this.missedReferenceBuildKey(v,e.uuid);if(!this.missedReferences[g]){var m={reference_uuid:v,for_item:e};this.missedReferences[g]=m}}}}catch(e){s=!0,c=e}finally{try{!o&&f.return&&f.return()}finally{if(s)throw c}}}}}},{key:"notifySyncObserversOfModels",value:function(e,t,n){var r=this,i=this.itemSyncObservers.sort(function(e,t){return e.priority0&&r._callSyncObserverCallbackWithTimeout(i,a,o,s,t,n)}(l)}}catch(e){o=!0,s=e}finally{try{!a&&c.return&&c.return()}finally{if(o)throw s}}}},{key:"_callSyncObserverCallbackWithTimeout",value:function(e,t,n,r,i,a){this.$timeout(function(){e.callback(t,n,r,i,a)})}},{key:"createItem",value:function(t,n){var r=e.ContentTypeClassMapping&&e.ContentTypeClassMapping[t.content_type];r||(r=x);var i=new r(t);return n||this.notifySyncObserversOfModels([i],e.MappingSourceLocalSaved),i}},{key:"createConflictedItem",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,SFJS.crypto.generateUUID();case 2:return n=e.sent,t=_.merge(t,{uuid:n}),r=this.createItem(t,!0),e.abrupt("return",r);case 6:case"end":return e.stop()}},e,this)}));return e}()},{key:"addConflictedItem",value:function(e,t){this.addItem(e);var n=!0,r=!1,i=void 0;try{for(var a,o=t.referencingObjects[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;s.addItemAsRelationship(e),s.setDirty(!0)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}this.resolveReferencesForItem(e),e.content.conflict_of=t.uuid,e.setDirty(!0)}},{key:"duplicateItem",value:function(e){var t=new e.constructor({content:e.content});t.created_at=e.created_at,t.content_type=e.content_type,this.addItem(t);var n=!0,r=!1,i=void 0;try{for(var a,o=e.referencingObjects[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;s.addItemAsRelationship(t),s.setDirty(!0)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return this.resolveReferencesForItem(t),t.setDirty(!0),t}},{key:"addItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.addItems([e],t)}},{key:"addItems",value:function(e){var t=this;arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.forEach(function(e){t.itemsHash[e.uuid]||(t.itemsHash[e.uuid]=e,t.items.push(e))})}},{key:"addItemSyncObserver",value:function(e,t,n){this.addItemSyncObserverWithPriority({id:e,types:t,callback:n,priority:1})}},{key:"addItemSyncObserverWithPriority",value:function(e){var t=e.id,n=e.priority,r=e.types,i=e.callback;Array.isArray(r)||(r=[r]),this.itemSyncObservers.push({id:t,types:r,priority:n,callback:i})}},{key:"removeItemSyncObserver",value:function(e){_.remove(this.itemSyncObservers,_.find(this.itemSyncObservers,{id:e}))}},{key:"getDirtyItems",value:function(){return this.items.filter(function(e){return 1==e.dirty&&!e.dummy&&(!e.errorDecrypting||e.deleted)})}},{key:"clearDirtyItems",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){i.value.setDirty(!1)}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}}},{key:"setItemToBeDeleted",value:function(e){e.deleted=!0,e.dummy||e.setDirty(!0),this.removeAndDirtyAllRelationshipsForItem(e)}},{key:"removeAndDirtyAllRelationshipsForItem",value:function(e){if(!e.errorDecrypting){var t=!0,n=!1,r=void 0;try{for(var i,a=e.content.references[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value,s=this.findItem(o.uuid);s&&(e.removeItemAsRelationship(s),s.hasRelationshipWithItem(e)&&(s.removeItemAsRelationship(e),s.setDirty(!0)))}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}}var u=!0,c=!1,l=void 0;try{for(var f,p=e.referencingObjects[Symbol.iterator]();!(u=(f=p.next()).done);u=!0){var h=f.value;h.removeItemAsRelationship(e),h.setDirty(!0)}}catch(e){c=!0,l=e}finally{try{!u&&p.return&&p.return()}finally{if(c)throw l}}e.referencingObjects=[]}},{key:"setAllItemsDirty",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.allItems,n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){a.value.setDirty(!0,e)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"removeItemLocally",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:_.remove(this.items,{uuid:t.uuid}),delete this.itemsHash[t.uuid],t.isBeingRemovedLocally(),this.itemsPendingRemoval.push(t.uuid);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"allItemsMatchingTypes",value:function(e){return this.allItems.filter(function(t){return(_.includes(e,t.content_type)||_.includes(e,"*"))&&!t.dummy})}},{key:"invalidItems",value:function(){return this.allItems.filter(function(e){return e.errorDecrypting})}},{key:"validItemsForContentType",value:function(e){return this.allItems.filter(function(t){return t.content_type==e&&!t.errorDecrypting})}},{key:"findItem",value:function(e){return this.itemsHash[e]}},{key:"findItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value,c=this.itemsHash[u];(c||t)&&n.push(c)}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return n}},{key:"itemsMatchingPredicate",value:function(e){return this.itemsMatchingPredicates([e])}},{key:"itemsMatchingPredicates",value:function(e){return this.filterItemsWithPredicates(this.allItems,e)}},{key:"filterItemsWithPredicates",value:function(e,t){return e.filter(function(e){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(!e.satisfiesPredicate(s))return!1}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return!0})}},{key:"importItems",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c,l,f,p,h,d,y,v,g,m;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:r=[],i=!0,a=!1,o=void 0,t.prev=4,s=n[Symbol.iterator]();case 6:if(i=(u=s.next()).done){t.next=21;break}if(c=u.value,!(l=this.findItem(c.uuid))||l.errorDecrypting){t.next=16;break}return t.next=12,this.createConflictedItem(c);case 12:f=t.sent,c.deleted||l.isItemContentEqualWith(f)||(this.addConflictedItem(f,l),r.push(f)),t.next=18;break;case 16:r.push(c),l&&l.errorDecrypting&&(l.errorDecrypting=!1);case 18:i=!0,t.next=6;break;case 21:t.next=27;break;case 23:t.prev=23,t.t0=t.catch(4),a=!0,o=t.t0;case 27:t.prev=27,t.prev=28,!i&&s.return&&s.return();case 30:if(t.prev=30,!a){t.next=33;break}throw o;case 33:return t.finish(30);case 34:return t.finish(27);case 35:for(p=this.mapResponseItemsToLocalModels(r,e.MappingSourceFileImport),h=!0,d=!1,y=void 0,t.prev=39,v=p[Symbol.iterator]();!(h=(g=v.next()).done);h=!0)m=g.value,m.setDirty(!0,!0),m.deleted=!1;t.next=47;break;case 43:t.prev=43,t.t1=t.catch(39),d=!0,y=t.t1;case 47:t.prev=47,t.prev=48,!h&&v.return&&v.return();case 50:if(t.prev=50,!d){t.next=53;break}throw y;case 53:return t.finish(50);case 54:return t.finish(47);case 55:return t.abrupt("return",p);case 56:case"end":return t.stop()}},t,this,[[4,23,27,35],[28,,30,34],[39,43,47,55],[48,,50,54]])}));return t}()},{key:"getAllItemsJSONData",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.getJSONDataForItems(this.allItems,t,n,r));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"getJSONDataForItems",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.all(t.map(function(e){return new S(e,n,r).paramsForExportFile()})).then(function(e){if(i&&0==e.length)return null;var t={items:e};return n&&(t.auth_params=r),JSON.stringify(t,null,2)}));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"computeDataIntegrityHash",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=this.allNondummyItems.sort(function(e,t){return t.updated_at-e.updated_at}),n=t.map(function(e){return e.updatedAtTimestamp()}),r=n.join(","),e.next=6,SFJS.crypto.sha256(r);case 6:return i=e.sent,e.abrupt("return",i);case 10:return e.prev=10,e.t0=e.catch(0),console.error("Error computing data integrity hash",e.t0),e.abrupt("return",null);case 14:case"end":return e.stop()}},e,this,[[0,10]])}));return e}()},{key:"allItems",get:function(){return this.items.slice()}},{key:"allNondummyItems",get:function(){return this.items.filter(function(e){return!e.dummy})}}]),e}(),g=r.SFPrivilegesManager=function(){function e(t,n,r){a(this,e),this.modelManager=t,this.syncManager=n,this.singletonManager=r,this.loadPrivileges(),e.CredentialAccountPassword="CredentialAccountPassword",e.CredentialLocalPasscode="CredentialLocalPasscode",e.ActionManageExtensions="ActionManageExtensions",e.ActionManageBackups="ActionManageBackups",e.ActionViewProtectedNotes="ActionViewProtectedNotes",e.ActionManagePrivileges="ActionManagePrivileges",e.ActionManagePasscode="ActionManagePasscode",e.ActionDeleteNote="ActionDeleteNote",e.SessionExpiresAtKey="SessionExpiresAtKey",e.SessionLengthKey="SessionLengthKey",e.SessionLengthNone=0,e.SessionLengthFiveMinutes=300,e.SessionLengthOneHour=3600,e.SessionLengthOneWeek=604800,this.availableActions=[e.ActionViewProtectedNotes,e.ActionDeleteNote,e.ActionManagePasscode,e.ActionManageBackups,e.ActionManageExtensions,e.ActionManagePrivileges],this.availableCredentials=[e.CredentialAccountPassword,e.CredentialLocalPasscode],this.sessionLengths=[e.SessionLengthNone,e.SessionLengthFiveMinutes,e.SessionLengthOneHour,e.SessionLengthOneWeek,e.SessionLengthIndefinite]}return l(e,[{key:"setDelegate",value:function(e){this.delegate=e}},{key:"getAvailableActions",value:function(){return this.availableActions}},{key:"getAvailableCredentials",value:function(){return this.availableCredentials}},{key:"netCredentialsForAction",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPrivileges();case 2:t.t0=n,r=t.sent.getCredentialsForAction(t.t0),i=[],a=!0,o=!1,s=void 0,t.prev=8,u=r[Symbol.iterator]();case 10:if(a=(c=u.next()).done){t.next=27;break}if((l=c.value)!=e.CredentialAccountPassword){t.next=19;break}return t.next=15,this.delegate.isOffline();case 15:f=t.sent,f||i.push(l),t.next=24;break;case 19:if(l!=e.CredentialLocalPasscode){t.next=24;break}return t.next=22,this.delegate.hasLocalPasscode();case 22:p=t.sent,p&&i.push(l);case 24:a=!0,t.next=10;break;case 27:t.next=33;break;case 29:t.prev=29,t.t1=t.catch(8),o=!0,s=t.t1;case 33:t.prev=33,t.prev=34,!a&&u.return&&u.return();case 36:if(t.prev=36,!o){t.next=39;break}throw s;case 39:return t.finish(36);case 40:return t.finish(33);case 41:return t.abrupt("return",i);case 42:case"end":return t.stop()}},t,this,[[8,29,33,41],[34,,36,40]])}));return t}()},{key:"loadPrivileges",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.loadPromise){e.next=2;break}return e.abrupt("return",this.loadPromise);case 2:return this.loadPromise=new Promise(function(e,n){var r=I.contentType(),a=new C("content_type","=",r);t.singletonManager.registerSingleton([a],function(n){t.privileges=n,e(n)},function(){var n=i(regeneratorRuntime.mark(function n(i){var a;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(a=new I({content_type:r}),SFJS.crypto.generateUUIDSync){n.next=4;break}return n.next=4,a.initUUID();case 4:t.modelManager.addItem(a),a.setDirty(!0),t.syncManager.sync(),i(a),e(a);case 9:case"end":return n.stop()}},n,t)}));return function(e){return n.apply(this,arguments)}}())}),e.abrupt("return",this.loadPromise);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"getPrivileges",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.privileges){e.next=4;break}return e.abrupt("return",this.privileges);case 4:return e.abrupt("return",this.loadPrivileges());case 5:case"end":return e.stop()}},e,this)}));return e}()},{key:"displayInfoForCredential",value:function(t){var n={};return n[e.CredentialAccountPassword]={label:"Account Password",prompt:"Please enter your account password."},n[e.CredentialLocalPasscode]={label:"Local Passcode",prompt:"Please enter your local passcode."},n[t]}},{key:"displayInfoForAction",value:function(t){var n={};return n[e.ActionManageExtensions]={label:"Manage Extensions"},n[e.ActionManageBackups]={label:"Download/Import Backups"},n[e.ActionViewProtectedNotes]={label:"View Protected Notes"},n[e.ActionManagePrivileges]={label:"Manage Privileges"},n[e.ActionManagePasscode]={label:"Manage Passcode"},n[e.ActionDeleteNote]={label:"Delete Notes"},n[t]}},{key:"getSessionLengthOptions",value:function(){return[{value:e.SessionLengthNone,label:"Don't Remember"},{value:e.SessionLengthFiveMinutes,label:"5 Minutes"},{value:e.SessionLengthOneHour,label:"1 Hour"},{value:e.SessionLengthOneWeek,label:"1 Week"}]}},{key:"setSessionLength",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=function(e){var t=new Date;return t.setSeconds(t.getSeconds()+e),t},i=r(n),t.abrupt("return",Promise.all([this.delegate.saveToStorage(e.SessionExpiresAtKey,JSON.stringify(i)),this.delegate.saveToStorage(e.SessionLengthKey,JSON.stringify(n))]));case 3:case"end":return t.stop()}},t,this)}));return t}()},{key:"clearSession",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.setSessionLength(e.SessionLengthNone));case 1:case"end":return t.stop()}},t,this)}));return t}()},{key:"getSelectedSessionLength",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.delegate.getFromStorage(e.SessionLengthKey);case 2:if(!(n=t.sent)){t.next=7;break}return t.abrupt("return",JSON.parse(n));case 7:return t.abrupt("return",e.SessionLengthNone);case 8:case"end":return t.stop()}},t,this)}));return t}()},{key:"getSessionExpirey",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.delegate.getFromStorage(e.SessionExpiresAtKey);case 2:if(!(n=t.sent)){t.next=7;break}return t.abrupt("return",new Date(JSON.parse(n)));case 7:return t.abrupt("return",new Date);case 8:case"end":return t.stop()}},t,this)}));return t}()},{key:"actionHasPrivilegesConfigured",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.netCredentialsForAction(t);case 2:return e.t0=e.sent.length,e.abrupt("return",e.t0>0);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"actionRequiresPrivilege",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getSessionExpirey();case 2:if(!((n=e.sent)>new Date)){e.next=5;break}return e.abrupt("return",!1);case 5:return e.next=7,this.netCredentialsForAction(t);case 7:return r=e.sent,e.abrupt("return",r.length>0);case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"savePrivileges",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPrivileges();case 2:t=e.sent,t.setDirty(!0),this.syncManager.sync();case 5:case"end":return e.stop()}},e,this)}));return e}()},{key:"authenticateAction",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.netCredentialsForAction(t);case 2:r=e.sent,i=[],a=[],o=!0,s=!1,u=void 0,e.prev=7,c=r[Symbol.iterator]();case 9:if(o=(l=c.next()).done){e.next=18;break}return f=l.value,e.next=13,this._verifyAuthenticationParameters(f,n[f]);case 13:p=e.sent,p?i.push(f):a.push(f);case 15:o=!0,e.next=9;break;case 18:e.next=24;break;case 20:e.prev=20,e.t0=e.catch(7),s=!0,u=e.t0;case 24:e.prev=24,e.prev=25,!o&&c.return&&c.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:return e.abrupt("return",{success:0==a.length,successfulCredentials:i,failedCredentials:a});case 33:case"end":return e.stop()}},e,this,[[7,20,24,32],[25,,27,31]])}));return e}()},{key:"_verifyAuthenticationParameters",value:function(){function t(e,t){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n,r){var a,o,s=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(a=function(){var e=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s.delegate.verifyAccountPassword(t));case 1:case"end":return e.stop()}},e,s)}));return function(t){return e.apply(this,arguments)}}(),o=function(){var e=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s.delegate.verifyLocalPasscode(t));case 1:case"end":return e.stop()}},e,s)}));return function(t){return e.apply(this,arguments)}}(),n!=e.CredentialAccountPassword){t.next=6;break}return t.abrupt("return",a(r));case 6:if(n!=e.CredentialLocalPasscode){t.next=8;break}return t.abrupt("return",o(r));case 8:case"end":return t.stop()}},t,this)}));return t}()}]),e}(),m=r.SFSessionHistoryManager=function(){function e(t,n,r,i,o){var s=this;a(this,e),this.modelManager=t,this.storageManager=n,this.$timeout=o||setTimeout.bind(window),this.keyRequestHandler=r,this.loadFromDisk().then(function(){s.modelManager.addItemSyncObserver("session-history",i,function(e,t,n,r,i){var a=!0,o=!1,u=void 0;try{for(var c,l=e[Symbol.iterator]();!(a=(c=l.next()).done);a=!0){var f=c.value;try{s.addHistoryEntryForItem(f)}catch(e){console.log("Caught exception while trying to add item history entry",e)}}}catch(e){o=!0,u=e}finally{try{!a&&l.return&&l.return()}finally{if(o)throw u}}})})}return l(e,[{key:"encryptionParams",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.keyRequestHandler());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"addHistoryEntryForItem",value:function(e){var t=this,n={uuid:e.uuid,content_type:e.content_type,updated_at:e.updated_at,content:e.content},r=this.historySession.addEntryForItem(n);this.autoOptimize&&this.historySession.optimizeHistoryForItem(e),r&&this.diskEnabled&&(this.diskTimeout&&(this.$timeout.hasOwnProperty("cancel")?this.$timeout.cancel(this.diskTimeout):clearTimeout(this.diskTimeout)),this.diskTimeout=this.$timeout(function(){t.saveToDisk()},2e3))}},{key:"historyForItem",value:function(e){return this.historySession.historyForItem(e)}},{key:"clearHistoryForItem",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.historySession.clearItemHistory(t),e.abrupt("return",this.saveToDisk());case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"clearAllHistory",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.historySession.clearAllHistory(),e.abrupt("return",this.storageManager.removeItem("sessionHistory_revisions"));case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"toggleDiskSaving",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.diskEnabled=!this.diskEnabled,!this.diskEnabled){e.next=6;break}this.storageManager.setItem("sessionHistory_persist",JSON.stringify(!0)),this.saveToDisk(),e.next=8;break;case 6:return this.storageManager.setItem("sessionHistory_persist",JSON.stringify(!1)),e.abrupt("return",this.storageManager.removeItem("sessionHistory_revisions"));case 8:case"end":return e.stop()}},e,this)}));return e}()},{key:"saveToDisk",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.diskEnabled){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.encryptionParams();case 4:t=e.sent,n=new S(this.historySession,t.keys,t.auth_params),n.paramsForSync().then(function(e){r.storageManager.setItem("sessionHistory_revisions",JSON.stringify(e))});case 7:case"end":return e.stop()}},e,this)}));return e}()},{key:"loadFromDisk",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.storageManager.getItem("sessionHistory_persist");case 2:return t=e.sent,t&&(this.diskEnabled=JSON.parse(t)),e.next=6,this.storageManager.getItem("sessionHistory_revisions");case 6:if(!(n=e.sent)){e.next=18;break}return n=JSON.parse(n),e.next=11,this.encryptionParams();case 11:return r=e.sent,e.next=14,SFJS.itemTransformer.decryptItem(n,r.keys);case 14:i=new R(n),this.historySession=i,e.next=19;break;case 18:this.historySession=new R;case 19:return e.next=21,this.storageManager.getItem("sessionHistory_autoOptimize");case 21:a=e.sent,this.autoOptimize=!a||JSON.parse(a);case 23:case"end":return e.stop()}},e,this)}));return e}()},{key:"toggleAutoOptimize",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.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 e.stop()}},e,this)}));return e}()}]),e}(),b=r.SFSingletonManager=function(){function e(t,n){var r=this;a(this,e),this.syncManager=n,this.modelManager=t,this.singletonHandlers=[],t.addItemSyncObserverWithPriority({id:"sf-singleton-manager",types:"*",priority:-1,callback:function(){r.resolveSingletons(t.allNondummyItems,null,!0)}}),n.addEventHandler(function(e,n){if("local-data-loaded"==e)r.resolveSingletons(t.allNondummyItems,null,!0),r.initialDataLoaded=!0;else if("sync:completed"==e){if(!r.initialDataLoaded)return;r.resolveSingletons(n.retrievedItems,n.savedItems)}}),t.addModelUuidChangeObserver("singleton-manager",function(e,t){var n=!0,i=!1,a=void 0;try{for(var o,s=r.singletonHandlers[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;u.singleton&&C.ItemSatisfiesPredicates(t,u.predicates)&&(u.singleton=null,r.resolveSingletons([t]))}}catch(e){i=!0,a=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw a}}})}return l(e,[{key:"registerSingleton",value:function(e,t,n){this.singletonHandlers.push({predicates:e,resolutionCallback:t,createBlock:n})}},{key:"resolveSingletons",value:function(e,t,n){var r=this;e=e||[],t=t||[];var i=!0,a=!1,o=void 0;try{for(var s,u=this.singletonHandlers[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;!function(i){var a=i.predicates.slice(),o=r.modelManager.filterItemsWithPredicates(e,a),s=function(){i.createBlock&&(i.pendingCreateBlockCallback=!0,i.createBlock(function(e){i.singleton=e,i.pendingCreateBlockCallback=!1,i.resolutionCallback&&i.resolutionCallback(e)}))},u=r.modelManager.filterItemsWithPredicates(t,a).length;if(o.length>0||u>0){var c=r.modelManager.itemsMatchingPredicates(a);if(c.length>=2){var l=c.sort(function(e,t){return e.errorDecrypting?1:t.errorDecrypting?-1:e.created_at=this.MaxDiscordanceBeforeOutOfSync&&(this.outOfSync||(this.outOfSync=!0,this.notifyEvent("enter-out-of-sync"))),e.abrupt("return",!1);case 13:return this.outOfSync&&(this.outOfSync=!1,this.notifyEvent("exit-out-of-sync")),this.syncDiscordance=0,e.abrupt("return",!0);case 16:case"end":return e.stop()}},e,this)}));return e}()},{key:"isOutOfSync",value:function(){return this.outOfSync}},{key:"getServerURL",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.storageManager.getItem("server");case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0=window._default_sf_server;case 5:return e.abrupt("return",e.t0);case 6:case"end":return e.stop()}},e,this)}));return e}()},{key:"getSyncURL",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getServerURL();case 2:return e.t0=e.sent,e.abrupt("return",e.t0+"/items/sync");case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"registerSyncStatusObserver",value:function(e){var t={key:new Date,callback:e};return this.syncStatusObservers.push(t),t}},{key:"removeSyncStatusObserver",value:function(e){_.pull(this.syncStatusObservers,e)}},{key:"syncStatusDidChange",value:function(){var e=this;this.syncStatusObservers.forEach(function(t){t.callback(e.syncStatus)})}},{key:"addEventHandler",value:function(e){return this.eventHandlers.push(e),e}},{key:"removeEventHandler",value:function(e){_.pull(this.eventHandlers,e)}},{key:"notifyEvent",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.eventHandlers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){(0,a.value)(e,t||{})}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"setKeyRequestHandler",value:function(e){this.keyRequestHandler=e}},{key:"getActiveKeyInfo",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.keyRequestHandler(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"initialDataLoaded",value:function(){return this._initialDataLoaded}},{key:"loadLocalItems",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.storageManager.getAllModels().then(function(t){t=t.sort(function(e,t){var n=new Date(t.updated_at)-new Date(e.updated_at),i=r.contentTypeLoadPriority,a=0,o=0;return i&&(a=i.indexOf(e.content_type),o=i.indexOf(t.content_type),-1==a&&(a=i.length),-1==o&&(o=i.length)),a==o?n:a5&&(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:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var t=i(regeneratorRuntime.mark(function t(i,a){var o,s,u,c,l,f,p,h,d,y,v,g,m;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.syncLocked){t.next=4;break}return console.log("Sync Locked, Returning;"),i(),t.abrupt("return");case 4:if(r||(r={}),o=n.modelManager.getDirtyItems(),s=o.filter(function(e){return e.dirtyCount>0&&(e.dirtyCount=0,!0)}),!n.syncStatus.syncOpInProgress||r.force){t.next=14;break}return n.repeatOnCompletion=!0,n.queuedCallbacks.push(i),t.next=12,n.writeItemsToLocalStorage(s,!1);case 12:return console.log("Sync op in progress; returning."),t.abrupt("return");case 14:return t.next=16,n.getActiveKeyInfo(e.KeyRequestLoadSaveAccount);case 16:if(u=t.sent,!u.offline){t.next=20;break}return n.syncOffline(o).then(function(e){n.modelManager.clearDirtyItems(o),i(e)}).catch(function(e){n.notifyEvent("sync-exception",e)}),t.abrupt("return");case 20:return c=n.syncStatus.needsMoreSync,n.syncStatus.syncOpInProgress=!0,n.syncStatus.syncStart=new Date,n.beginCheckingIfSyncIsTakingTooLong(),l=n.PerSyncItemUploadLimit,f=o.slice(0,l),f.lengthn.syncStatus.total&&(n.syncStatus.total=n.syncStatus.current),n.syncStatusDidChange(),t.next=32,n.writeItemsToLocalStorage(s,!1);case 32:return r.onPreSyncSave&&r.onPreSyncSave(),n.allRetreivedItems||(n.allRetreivedItems=[]),n.allSavedItems||(n.allSavedItems=[]),p={},p.limit=150,r.performIntegrityCheck&&(p.compute_integrity=!0),t.prev=38,t.next=41,Promise.all(f.map(function(e){var t=new S(e,u.keys,u.auth_params);return t.additionalFields=r.additionalFields,t.paramsForSync()})).then(function(e){p.items=e});case 41:t.next=46;break;case 43:t.prev=43,t.t0=t.catch(38),n.notifyEvent("sync-exception",t.t0);case 46:for(h=!0,d=!1,y=void 0,t.prev=49,v=f[Symbol.iterator]();!(h=(g=v.next()).done);h=!0)m=g.value,m.dirtyCount=0;t.next=57;break;case 53:t.prev=53,t.t1=t.catch(49),d=!0,y=t.t1;case 57:t.prev=57,t.prev=58,!h&&v.return&&v.return();case 60:if(t.prev=60,!d){t.next=63;break}throw y;case 63:return t.finish(60);case 64:return t.finish(57);case 65:return t.next=67,n.getSyncToken();case 67:return p.sync_token=t.sent,t.next=70,n.getCursorToken();case 70:return p.cursor_token=t.sent,t.prev=71,t.t2=n.httpManager,t.next=75,n.getSyncURL();case 75:t.t3=t.sent,t.t4=p,t.t5=function(e){n.handleSyncSuccess(f,e,r).then(function(){i(e)}).catch(function(e){console.log("Caught sync success exception:",e),n.handleSyncError(null,null,o).then(function(e){i(e)})})},t.t6=function(e,t){n.handleSyncError(e,t,o).then(function(e){i(e)})},t.t2.postAbsolute.call(t.t2,t.t3,t.t4,t.t5,t.t6),t.next=85;break;case 82:t.prev=82,t.t7=t.catch(71),console.log("Sync exception caught:",t.t7);case 85:case"end":return t.stop()}},t,n,[[38,43],[49,53,57,65],[58,,60,64],[71,82]])}));return function(e,n){return t.apply(this,arguments)}}()));case 1:case"end":return t.stop()}},t,this)}));return t}()},{key:"handleSyncSuccess",value:function(){function t(e,t,r){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n,r,i){var a,o,s,u,c,l,f,p,h,d,y,g,m,b,k=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(a=[],o=!0,s=!1,u=void 0,t.prev=4,c=n[Symbol.iterator]();!(o=(l=c.next()).done);o=!0)f=l.value,0==f.dirtyCount&&a.push(f);t.next=12;break;case 8:t.prev=8,t.t0=t.catch(4),s=!0,u=t.t0;case 12:t.prev=12,t.prev=13,!o&&c.return&&c.return();case 15:if(t.prev=15,!s){t.next=18;break}throw u;case 18:return t.finish(15);case 19:return t.finish(12);case 20:return this.modelManager.clearDirtyItems(a),this.syncStatus.error=null,p=this.allSavedItems.map(function(e){return e.uuid}),r.retrieved_items=r.retrieved_items.filter(function(e){return!p.includes(e.uuid)}),t.next=26,this.handleItemsResponse(r.retrieved_items,null,v.MappingSourceRemoteRetrieved,e.KeyRequestLoadSaveAccount);case 26:return h=t.sent,this.allRetreivedItems=this.allRetreivedItems.concat(h),this.syncStatus.retrievedCount=this.allRetreivedItems.length,d=["content","auth_hash"],t.next=32,this.handleItemsResponse(r.saved_items,d,v.MappingSourceRemoteSaved,e.KeyRequestLoadSaveAccount);case 32:return y=t.sent,this.allSavedItems=this.allSavedItems.concat(y),g=r.unsaved,t.next=37,this.handleUnsavedItemsResponse(g);case 37:return t.next=39,this.writeItemsToLocalStorage(y,!1);case 39:return t.next=41,this.writeItemsToLocalStorage(h,!1);case 41:if(this.syncStatus.syncOpInProgress=!1,this.syncStatus.current+=n.length,this.syncStatusDidChange(),this.setSyncToken(r.sync_token),this.setCursorToken(r.cursor_token),this.stopCheckingIfSyncIsTakingTooLong(),!r.integrity_hash||r.cursor_token){t.next=52;break}return t.next=50,this.handleServerIntegrityHash(r.integrity_hash);case 50:m=t.sent,m||this.syncDiscordance=this.majorDataChangeThreshold||y.length>=this.majorDataChangeThreshold||g.length>=this.majorDataChangeThreshold)&&this.notifyEvent("major-data-change"),this.callQueuedCallbacks(r),this.notifyEvent("sync:completed",{retrievedItems:this.allRetreivedItems,savedItems:this.allSavedItems,unsavedItems:g}),this.allRetreivedItems=[],this.allSavedItems=[],t.abrupt("return",r);case 72:case"end":return t.stop()}},t,this,[[4,8,12,20],[13,,15,19]])}));return t}()},{key:"handleSyncError",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("Sync error: ",t),401==n&&this.notifyEvent("sync-session-invalid"),t?"string"==typeof t&&(t={error:{message:t}}):t={error:{message:"Could not connect to server."}},this.syncStatus.syncOpInProgress=!1,this.syncStatus.error=t.error,this.syncStatusDidChange(),this.writeItemsToLocalStorage(r,!1),this.modelManager.didSyncModelsOffline(r),this.stopCheckingIfSyncIsTakingTooLong(),this.notifyEvent("sync:error",t.error),this.callQueuedCallbacks({error:"Sync error"}),e.abrupt("return",t);case 12:case"end":return e.stop()}},e,this)}));return e}()},{key:"handleItemsResponse",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a,o,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getActiveKeyInfo(i);case 2:return a=e.sent.keys,e.next=5,SFJS.itemTransformer.decryptMultipleItems(t,a);case 5:return o=this.modelManager.mapResponseItemsToLocalModelsOmittingFields(t,n,r),s=o.filter(function(e){var t=e.errorDecryptingValueChanged;return e.errorDecryptingValueChanged=!1,t}),s.length>0&&this.writeItemsToLocalStorage(s,!1),e.abrupt("return",o);case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"refreshErroredItems",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this.modelManager.allNondummyItems.filter(function(e){return 1==e.errorDecrypting}),!(n.length>0)){t.next=3;break}return t.abrupt("return",this.handleItemsResponse(n,null,v.MappingSourceLocalRetrieved,e.KeyRequestLoadSaveAccount));case 3:case"end":return t.stop()}},t,this)}));return t}()},{key:"handleUnsavedItemsResponse",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(0!=n.length){t.next=2;break}return t.abrupt("return");case 2:console.log("Handle Conflicted Items:",n),r=!0,i=!1,a=void 0,t.prev=6,o=n[Symbol.iterator]();case 8:if(r=(s=o.next()).done){t.next=35;break}return u=s.value,c=u.item,t.t0=SFJS.itemTransformer,t.t1=[c],t.next=15,this.getActiveKeyInfo(e.KeyRequestLoadSaveAccount);case 15:return t.t2=t.sent.keys,t.next=18,t.t0.decryptMultipleItems.call(t.t0,t.t1,t.t2);case 18:if(l=this.modelManager.findItem(c.uuid)){t.next=21;break}return t.abrupt("continue",32);case 21:if(f=u.error,"uuid_conflict"!==f.tag){t.next=27;break}return t.next=25,this.modelManager.alternateUUIDForItem(l);case 25:t.next=32;break;case 27:if("sync_conflict"!==f.tag){t.next=32;break}return t.next=30,this.modelManager.createConflictedItem(c);case 30:p=t.sent,c.deleted||l.isItemContentEqualWith(p)||this.modelManager.addConflictedItem(p,l);case 32:r=!0,t.next=8;break;case 35:t.next=41;break;case 37:t.prev=37,t.t3=t.catch(6),i=!0,a=t.t3;case 41:t.prev=41,t.prev=42,!r&&o.return&&o.return();case 44:if(t.prev=44,!i){t.next=47;break}throw a;case 47:return t.finish(44);case 48:return t.finish(41);case 49:this.sync(null,{additionalFields:["created_at","updated_at"]});case 50:case"end":return t.stop()}},t,this,[[6,37,41,49],[42,,44,48]])}));return t}()},{key:"stateless_downloadAllItems",value:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(){var r=i(regeneratorRuntime.mark(function r(a,o){var s;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return s={limit:n.limit||500,sync_token:n.syncToken,cursor_token:n.cursorToken,content_type:n.contentType,event:n.event},r.prev=1,r.t0=t.httpManager,r.next=5,t.getSyncURL();case 5:r.t1=r.sent,r.t2=s,r.t3=function(){var r=i(regeneratorRuntime.mark(function r(i){var o,s;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return n.retrievedItems||(n.retrievedItems=[]),o=i.retrieved_items,r.next=4,t.getActiveKeyInfo(e.KeyRequestLoadSaveAccount);case 4:return s=r.sent.keys,r.next=7,SFJS.itemTransformer.decryptMultipleItems(o,s);case 7:n.retrievedItems=n.retrievedItems.concat(o.map(function(e){return t.modelManager.createItem(e,!0)})),n.syncToken=i.sync_token,n.cursorToken=i.cursor_token,n.cursorToken?t.stateless_downloadAllItems(n).then(a):a(n.retrievedItems);case 11:case"end":return r.stop()}},r,t)}));return function(e){return r.apply(this,arguments)}}(),r.t4=function(e,t){o(e)},r.t0.postAbsolute.call(r.t0,r.t1,r.t2,r.t3,r.t4),r.next=16;break;case 12:r.prev=12,r.t5=r.catch(1),console.log("Download all items exception caught:",r.t5),o(r.t5);case 16:case"end":return r.stop()}},r,t,[[1,12]])}));return function(e,t){return r.apply(this,arguments)}}())}},{key:"resolveOutOfSync",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stateless_downloadAllItems({event:"resolve-out-of-sync"}).then(function(){var e=i(regeneratorRuntime.mark(function e(n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:r=[],i=!0,a=!1,o=void 0,e.prev=4,s=n[Symbol.iterator]();case 6:if(i=(u=s.next()).done){e.next=20;break}if(c=u.value,!(l=t.modelManager.findItem(c.uuid))){e.next=16;break}if(!(f=!c.isItemContentEqualWith(l))){e.next=16;break}return e.next=14,t.modelManager.createConflictedItem(l,l);case 14:p=e.sent,t.modelManager.addConflictedItem(p,l);case 16:r.push(c);case 17:i=!0,e.next=6;break;case 20:e.next=26;break;case 22:e.prev=22,e.t0=e.catch(4),a=!0,o=e.t0;case 26:e.prev=26,e.prev=27,!i&&s.return&&s.return();case 29:if(e.prev=29,!a){e.next=32;break}throw o;case 32:return e.finish(29);case 33:return e.finish(26);case 34:return t.modelManager.mapResponseItemsToLocalModelsWithOptions({items:r,source:v.MappingSourceRemoteRetrieved}),e.next=37,t.writeItemsToLocalStorage(t.modelManager.allNondummyItems);case 37:return e.abrupt("return",t.sync({performIntegrityCheck:!0}));case 38:case"end":return e.stop()}},e,t,[[4,22,26,34],[27,,29,33]])}));return function(t){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"handleSignout",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this._syncToken=null,this._cursorToken=null,this._queuedCallbacks=[],this.syncStatus={};case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"clearSyncToken",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._syncToken=null,this._cursorToken=null,e.abrupt("return",this.storageManager.removeItem("syncToken"));case 3:case"end":return e.stop()}},e,this)}));return e}()},{key:"queuedCallbacks",get:function(){return this._queuedCallbacks||(this._queuedCallbacks=[]),this._queuedCallbacks}}]),e}(),x=r.SFItem=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.content={},this.referencingObjects=[],this.updateFromJSON(t),this.uuid||"undefined"!=typeof SFJS&&SFJS.crypto.generateUUIDSync&&(this.uuid=SFJS.crypto.generateUUIDSync()),"object"!==c(this.content)||this.content.references||(this.content.references=[])}return l(e,[{key:"initUUID",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.uuid){e.next=4;break}return e.next=3,SFJS.crypto.generateUUID();case 3:this.uuid=e.sent;case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"updateFromJSON",value:function(t){if(t){this.created_at=t.created_at,this.updated_at=t.updated_at,this.deleted=t.deleted,this.uuid=t.uuid,this.enc_item_key=t.enc_item_key,this.auth_hash=t.auth_hash,this.auth_params=t.auth_params;var n=["errorDecrypting","dirty","dirtyCount","dummy"],r=!0,i=!1,a=void 0;try{for(var o,s=n[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;void 0!==t[u]&&(this[u]=t[u])}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}if(this.content_type||(this.content_type=t.content_type),t.errorDecrypting)this.content=t.content;else try{var c="string"==typeof t.content?JSON.parse(t.content):t.content;e.deepMerge(this.contentObject,c)}catch(e){console.log("Error while updating item from json",e)}this.created_at?(this.created_at=new Date(this.created_at),this.updated_at=new Date(this.updated_at)):(this.created_at=new Date,this.updated_at=new Date),this._client_updated_at=null,t.content?this.mapContentToLocalProperties(this.contentObject):1==t.deleted&&this.handleDeletedContent()}}},{key:"mapContentToLocalProperties",value:function(e){}},{key:"createContentJSONFromProperties",value:function(){var t=this.structureParams();return e.deepMerge(this.contentObject,t),t}},{key:"structureParams",value:function(){return this.getContentCopy()}},{key:"handleDeletedContent",value:function(){}},{key:"setDirty",value:function(e,t){this.dirty=e,this.dirtyCount||(this.dirtyCount=0),e?this.dirtyCount++:this.dirtyCount=0,e&&!t?this.client_updated_at=new Date:this.hasRawClientUpdatedAtValue()||(this.client_updated_at=new Date(this.updated_at))}},{key:"updateLocalRelationships",value:function(){}},{key:"addItemAsRelationship",value:function(e){if(e.setIsBeingReferencedBy(this),!this.hasRelationshipWithItem(e)){var t=this.content.references||[];t.push({uuid:e.uuid,content_type:e.content_type}),this.content.references=t}}},{key:"removeItemAsRelationship",value:function(e){e.setIsNoLongerBeingReferencedBy(this),this.removeReferenceWithUuid(e.uuid)}},{key:"setIsBeingReferencedBy",value:function(e){_.find(this.referencingObjects,{uuid:e.uuid})||this.referencingObjects.push(e)}},{key:"setIsNoLongerBeingReferencedBy",value:function(e){_.remove(this.referencingObjects,{uuid:e.uuid}),this.hasRelationshipWithItem(e)&&(this.removeReferenceWithUuid(e.uuid),this.setDirty(!0))}},{key:"removeReferenceWithUuid",value:function(e){var t=this.content.references||[];t=t.filter(function(t){return t.uuid!=e}),this.content.references=t}},{key:"hasRelationshipWithItem",value:function(e){return null!=this.content.references.find(function(t){return t.uuid==e.uuid})}},{key:"isBeingRemovedLocally",value:function(){}},{key:"didFinishSyncing",value:function(){}},{key:"informReferencesOfUUIDChange",value:function(e,t){}},{key:"potentialItemOfInterestHasChangedItsUUID",value:function(e,t,n){var r=!0,i=!1,a=void 0;try{for(var o,s=this.content.references[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;u.uuid==t&&(u.uuid=n,this.setDirty(!0))}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}}},{key:"doNotEncrypt",value:function(){return!1}},{key:"setDomainDataItem",value:function(e,t,n){if(!n)return void console.error("SFItem.AppDomain needs to be set.");if(!this.errorDecrypting){this.content.appData||(this.content.appData={});var r=this.content.appData[n];r||(r={}),r[e]=t,this.content.appData[n]=r}}},{key:"getDomainDataItem",value:function(e,t){if(!t)return void console.error("SFItem.AppDomain needs to be set.");if(!this.errorDecrypting){this.content.appData||(this.content.appData={});var n=this.content.appData[t];return n?n[e]:null}}},{key:"setAppDataItem",value:function(t,n){this.setDomainDataItem(t,n,e.AppDomain)}},{key:"getAppDataItem",value:function(t){return this.getDomainDataItem(t,e.AppDomain)}},{key:"hasRawClientUpdatedAtValue",value:function(){return null!=this.getAppDataItem("client_updated_at")}},{key:"keysToIgnoreWhenCheckingContentEquality",value:function(){return[]}},{key:"appDataKeysToIgnoreWhenCheckingContentEquality",value:function(){return["client_updated_at"]}},{key:"getContentCopy",value:function(){return JSON.parse(JSON.stringify(this.content))}},{key:"isItemContentEqualWith",value:function(t){var n=function(e,t){if(!e)return e;var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){delete e[a.value]}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return e},r=this.getContentCopy();r.appData&&n(r.appData[e.AppDomain],this.appDataKeysToIgnoreWhenCheckingContentEquality()),r=n(r,this.keysToIgnoreWhenCheckingContentEquality());var i=t.getContentCopy();return i.appData&&n(i.appData[e.AppDomain],t.appDataKeysToIgnoreWhenCheckingContentEquality()),i=n(i,t.keysToIgnoreWhenCheckingContentEquality()),JSON.stringify(r)===JSON.stringify(i)}},{key:"satisfiesPredicate",value:function(e){return C.ItemSatisfiesPredicate(this,e)}},{key:"createdAtString",value:function(){return this.dateToLocalizedString(this.created_at)}},{key:"updatedAtString",value:function(){return this.dateToLocalizedString(this.client_updated_at)}},{key:"updatedAtTimestamp",value:function(){return this.updated_at.getTime()}},{key:"dateToLocalizedString",value:function(e){if("undefined"!=typeof Intl&&Intl.DateTimeFormat){if(!s){var t=navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language;s=new Intl.DateTimeFormat(t,{year:"numeric",month:"short",day:"2-digit",weekday:"long",hour:"2-digit",minute:"2-digit"})}return s.format(e)}return e.toDateString()+" "+e.toLocaleTimeString()}},{key:"contentObject",get:function(){if(this.errorDecrypting)return this.content;if(!this.content)return this.content={},this.content;if(null!==this.content&&"object"===c(this.content))return this.content;try{var e=JSON.parse(this.content);return this.content=e,this.content}catch(e){return console.log("Error parsing json",e,this),this.content={},this.content}}},{key:"pinned",get:function(){return this.getAppDataItem("pinned")}},{key:"archived",get:function(){return this.getAppDataItem("archived")}},{key:"locked",get:function(){return this.getAppDataItem("locked")}},{key:"displayName",get:function(){return"Item"}},{key:"client_updated_at",get:function(){if(!this._client_updated_at){var e=this.getAppDataItem("client_updated_at");this._client_updated_at=e?new Date(e):new Date(this.updated_at)}return this._client_updated_at},set:function(e){this._client_updated_at=e,this.setAppDataItem("client_updated_at",e)}}],[{key:"deepMerge",value:function(e,t){function n(e,t){if(_.isArray(e))return t}return _.mergeWith(e,t,n),e}}]),e}(),S=r.SFItemParams=function(){function e(t,n,r){if(a(this,e),this.item=t,this.keys=n,this.auth_params=r,this.keys&&!this.auth_params)throw"SFItemParams.auth_params must be supplied if supplying keys.";if(this.auth_params&&!this.auth_params.version)throw"SFItemParams.auth_params is missing version"}return l(e,[{key:"paramsForExportFile",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.additionalFields=["updated_at"],this.forExportFile=!0,!t){e.next=6;break}return e.abrupt("return",this.__params());case 6:return e.next=8,this.__params();case 8:return n=e.sent,e.abrupt("return",_.omit(n,["deleted"]));case 10:case"end":return e.stop()}},e,this)}));return e}()},{key:"paramsForExtension",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.paramsForExportFile());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"paramsForLocalStorage",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.additionalFields=["updated_at","dirty","errorDecrypting"],this.forExportFile=!0,e.abrupt("return",this.__params());case 3:case"end":return e.stop()}},e,this)}));return e}()},{key:"paramsForSync",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.__params());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"__params",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t={uuid:this.item.uuid,content_type:this.item.content_type,deleted:this.item.deleted,created_at:this.item.created_at},this.item.errorDecrypting){e.next=23;break}if(n=this.item.doNotEncrypt()&&!this.forExportFile,!this.keys||n){e.next=11;break}return e.next=6,SFJS.itemTransformer.encryptItem(this.item,this.keys,this.auth_params);case 6:r=e.sent,_.merge(t,r),"001"!==this.auth_params.version&&(t.auth_hash=null),e.next=21;break;case 11:if(!this.forExportFile){e.next=15;break}e.t0=this.item.createContentJSONFromProperties(),e.next=19;break;case 15:return e.next=17,SFJS.crypto.base64(JSON.stringify(this.item.createContentJSONFromProperties()));case 17:e.t1=e.sent,e.t0="000"+e.t1;case 19:t.content=e.t0,this.forExportFile||(t.enc_item_key=null,t.auth_hash=null);case 21:e.next=26;break;case 23:t.content=this.item.content,t.enc_item_key=this.item.enc_item_key,t.auth_hash=this.item.auth_hash;case 26:return this.additionalFields&&_.merge(t,_.pick(this.item,this.additionalFields)),e.abrupt("return",t);case 28:case"end":return e.stop()}},e,this)}));return e}()}]),e}(),C=r.SFPredicate=function(){function e(t,n,r){a(this,e),this.keypath=t,this.operator=n,this.value=r,e.IsRecursiveOperator(this.operator)&&(this.value=this.value.map(e.fromArray))}return l(e,null,[{key:"fromArray",value:function(t){return new e(t[0],t[1],t[2])}},{key:"ObjectSatisfiesPredicate",value:function(t,n){if(Array.isArray(n)&&(n=this.fromArray(n)),e.IsRecursiveOperator(n.operator)){if("and"===n.operator){var r=!0,i=!1,a=void 0;try{for(var o,s=n.value[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;if(!this.ObjectSatisfiesPredicate(t,u))return!1}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return!0}if("or"===n.operator){var c=!0,l=!1,f=void 0;try{for(var p,h=n.value[Symbol.iterator]();!(c=(p=h.next()).done);c=!0){var u=p.value;if(this.ObjectSatisfiesPredicate(t,u))return!0}}catch(e){l=!0,f=e}finally{try{!c&&h.return&&h.return()}finally{if(l)throw f}}return!1}}var d=n.value;"string"==typeof d&&d.includes(".ago")&&(d=this.DateFromString(d));var y=n.keypath.split(".").reduce(function(e,t){return e&&e[t]},t),v=[!1,"",null,void 0,NaN];if(void 0==y)return"!="==n.operator?!v.includes(n.value):v.includes(n.value);if("="==n.operator)return Array.isArray(y)?JSON.stringify(y)==JSON.stringify(d):y==d;if("!="==n.operator)return Array.isArray(y)?JSON.stringify(y)!=JSON.stringify(d):y!==d;if("<"==n.operator)return y"==n.operator)return y>d;if("<="==n.operator)return y<=d;if(">="==n.operator)return y>=d;if("startsWith"==n.operator)return y.startsWith(d);if("in"==n.operator)return-1!=d.indexOf(y);if("includes"==n.operator)return this.resolveIncludesPredicate(y,d);if("matches"==n.operator){return new RegExp(d).test(y)}return!1}},{key:"resolveIncludesPredicate",value:function(t,n){if("string"==typeof n)return t.includes(n);var r;r=Array.isArray(n)?e.fromArray(n):n;var i=!0,a=!1,o=void 0;try{for(var s,u=t[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;if(this.ObjectSatisfiesPredicate(c,r))return!0}}catch(e){a=!0,o=e}finally{try{!i&&u.return&&u.return()}finally{if(a)throw o}}return!1}},{key:"ItemSatisfiesPredicate",value:function(t,n){return Array.isArray(n)&&(n=e.fromArray(n)),this.ObjectSatisfiesPredicate(t,n)}},{key:"ItemSatisfiesPredicates",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(!this.ItemSatisfiesPredicate(e,s))return!1}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return!0}},{key:"DateFromString",value:function(e){var t=e.split("."),n=t[1],r=new Date,i=parseInt(t[0]);return"days"==n?r.setDate(r.getDate()-i):"hours"==n&&r.setHours(r.getHours()-i),r}},{key:"IsRecursiveOperator",value:function(e){return["and","or"].includes(e)}}]),e}(),I=r.SFPrivileges=function(e){function r(e){a(this,r);var n=t(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return n.content.desktopPrivileges||(n.content.desktopPrivileges={}),n}return n(r,e),l(r,null,[{key:"contentType",value:function(){return"SN|Privileges"}}]),l(r,[{key:"setCredentialsForAction",value:function(e,t){this.content.desktopPrivileges[e]=t}},{key:"getCredentialsForAction",value:function(e){return this.content.desktopPrivileges[e]||[]}},{key:"toggleCredentialForAction",value:function(e,t){this.isCredentialRequiredForAction(e,t)?this.removeCredentialForAction(e,t):this.addCredentialForAction(e,t)}},{key:"removeCredentialForAction",value:function(e,t){_.pull(this.content.desktopPrivileges[e],t)}},{key:"addCredentialForAction",value:function(e,t){var n=this.getCredentialsForAction(e);n.push(t),this.setCredentialsForAction(e,n)}},{key:"isCredentialRequiredForAction",value:function(e,t){return this.getCredentialsForAction(e).includes(t)}}]),r}(x),R=r.SFHistorySession=function(e){function r(e){a(this,r);var n=t(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return n.content.itemUUIDToItemHistoryMapping||(n.content.itemUUIDToItemHistoryMapping={}),Object.keys(n.content.itemUUIDToItemHistoryMapping).forEach(function(e){var t=n.content.itemUUIDToItemHistoryMapping[e];n.content.itemUUIDToItemHistoryMapping[e]=new E(t)}),n}return n(r,e),l(r,[{key:"addEntryForItem",value:function(e){return this.historyForItem(e).addHistoryEntryForItem(e)}},{key:"historyForItem",value:function(e){var t=this.content.itemUUIDToItemHistoryMapping[e.uuid];return t||(t=this.content.itemUUIDToItemHistoryMapping[e.uuid]=new E),t}},{key:"clearItemHistory",value:function(e){this.historyForItem(e).clear()}},{key:"clearAllHistory",value:function(){this.content.itemUUIDToItemHistoryMapping={}}},{key:"optimizeHistoryForItem",value:function(e){var t=this.historyForItem(e);t.entries.length>r.LargeItemEntryAmountThreshold&&t.optimize()}}]),r}(x);R.LargeItemEntryAmountThreshold=60;var E=r.SFItemHistory=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a(this,e),this.entries||(this.entries=[]),t.entries){var n=!0,r=!1,i=void 0;try{for(var o,s=t.entries[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value,c=this.createEntryForItem(u.item);c.setPreviousEntry(this.getLastEntry()),this.entries.push(c)}}catch(e){r=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(r)throw i}}}}return l(e,[{key:"createEntryForItem",value:function(t){var n=e.HistoryEntryClassMapping&&e.HistoryEntryClassMapping[t.content_type];return n||(n=F),new n(t)}},{key:"getLastEntry",value:function(){return this.entries[this.entries.length-1]}},{key:"addHistoryEntryForItem",value:function(e){var t=this.createEntryForItem(e),n=this.getLastEntry();if(t.setPreviousEntry(n),!t.isSameAsEntry(n))return this.entries.push(t),t}},{key:"clear",value:function(){this.entries.length=0}},{key:"optimize",value:function(){var t=this,n=[],r=function(t){return t.deltaSize()>e.LargeEntryDeltaThreshold},i=function(e,i,a){if(a)n.push(e);else{var i=n.indexOf(e);-1!==i&&n.splice(i,1)}if(a&&r(e)&&-1==e.operationVector()){var o=t.entries[i-1];o&&n.push(o)}};this.entries.forEach(function(e,n){if(0==n||n==t.entries.length-1)i(e,n,!0);else{var a=r(e);i(e,n,a)}}),this.entries=this.entries.filter(function(e,t){return-1!==n.indexOf(e)})}}]),e}();E.LargeEntryDeltaThreshold=15;var F=r.SFItemHistoryEntry=function(){function e(t){a(this,e),this.item=x.deepMerge({},t),this.defaultContentKeyToDiffOn="text",this.textCharDiffLength=0,"string"==typeof this.item.updated_at&&(this.item.updated_at=new Date(this.item.updated_at))}return l(e,[{key:"setPreviousEntry",value:function(e){this.hasPreviousEntry=null!=e,this.item.content[this.defaultContentKeyToDiffOn]&&(this.textCharDiffLength=e?this.item.content[this.defaultContentKeyToDiffOn].length-e.item.content[this.defaultContentKeyToDiffOn].length:this.item.content[this.defaultContentKeyToDiffOn].length)}},{key:"operationVector",value:function(){return void 0!=this.textCharDiffLength?this.hasPreviousEntry&&0!=this.textCharDiffLength?this.textCharDiffLength<0?-1:1:0:1}},{key:"deltaSize",value:function(){return void 0!=this.textCharDiffLength?Math.abs(this.textCharDiffLength):1}},{key:"isSameAsEntry",value:function(e){if(!e)return!1;var t=new x(this.item),n=new x(e.item);return t.isItemContentEqualWith(n)}}]),e}(),h="undefined"!=typeof window?window:void 0!==e?e:null,P=r.SFAbstractCrypto=function(){function e(){a(this,e),this.DefaultPBKDF2Length=768}return l(e,[{key:"generateUUIDSync",value:function(){var e=h.crypto||h.msCrypto;if(e){var t=new Uint32Array(4);e.getRandomValues(t);var n=-1;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){n++;var r=t[n>>3]>>n%8*4&15;return("x"==e?r:3&r|8).toString(16)})}var r=(new Date).getTime();return h.performance&&"function"==typeof h.performance.now&&(r+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)})}},{key:"generateUUID",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.generateUUIDSync());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"decryptText",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=a.ciphertextToAuth,u=a.contentCiphertext,c=a.encryptionKey,l=a.iv,f=a.authHash,p=a.authKey,h=arguments[1];return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!h||f){e.next=3;break}return console.error("Auth hash is required."),e.abrupt("return");case 3:if(!f){e.next=10;break}return e.next=6,this.hmac256(s,p);case 6:if(t=e.sent,f===t){e.next=10;break}return console.error("Auth hash does not match, returning null."),e.abrupt("return",null);case 10:return n=o.enc.Hex.parse(c),r=o.enc.Hex.parse(l||""),i=o.AES.decrypt(u,n,{iv:r,mode:o.mode.CBC,padding:o.pad.Pkcs7}),e.abrupt("return",i.toString(o.enc.Utf8));case 14:case"end":return e.stop()}},e,this)}));return e}()},{key:"encryptText",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){var i,a,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=o.enc.Hex.parse(n),a=o.enc.Hex.parse(r||""),s=o.AES.encrypt(t,i,{iv:a,mode:o.mode.CBC,padding:o.pad.Pkcs7}),e.abrupt("return",s.toString());case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateRandomKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",o.lib.WordArray.random(t/8).toString());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateItemEncryptionKey",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=512,n=1,e.next=4,this.generateRandomKey(t);case 4:return r=e.sent,e.next=7,this.generateRandomKey(t);case 7:return i=e.sent,e.abrupt("return",this.pbkdf2(i,r,n,t));case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"firstHalfOfKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.substring(0,t.length/2));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"secondHalfOfKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.substring(t.length/2,t.length));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"base64",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",h.btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)})));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"base64Decode",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",h.atob(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"sha256",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",o.SHA256(t).toString());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"hmac256",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.enc.Hex.parse(n),i=o.enc.Utf8.parse(t),a=o.HmacSHA256(i,r).toString(),e.abrupt("return",a);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateSalt",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sha256([t,"SF",n,r,i].join(":"));case 2:return a=e.sent,e.abrupt("return",a);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateSymmetricKeyPair",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a,o,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},u=s.password,c=s.pw_salt,l=s.pw_cost;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.pbkdf2(u,c,l,this.DefaultPBKDF2Length);case 2:return t=e.sent,n=t.length,r=n/3,i=t.slice(0,r),a=t.slice(r,2*r),o=t.slice(2*r,3*r),e.abrupt("return",[i,a,o]);case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"computeEncryptionKeysForUser",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("003"!=n.version){e.next=9;break}if(n.identifier){e.next=4;break}return console.error("authParams is missing identifier."),e.abrupt("return");case 4:return e.next=6,this.generateSalt(n.identifier,n.version,n.pw_cost,n.pw_nonce);case 6:r=e.sent,e.next=10;break;case 9:r=n.pw_salt;case 10:return e.abrupt("return",this.generateSymmetricKeyPair({password:t,pw_salt:r,pw_cost:n.pw_cost}).then(function(e){return{pw:e[0],mk:e[1],ak:e[2]}}));case 11:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateInitialKeysAndAuthParamsForUser",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r,i,a,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.SFJS.version,i=this.SFJS.defaultPasswordGenerationCost,e.next=4,this.generateRandomKey(256);case 4:return a=e.sent,e.next=7,this.generateSalt(t,r,i,a);case 7:return o=e.sent,e.abrupt("return",this.generateSymmetricKeyPair({password:n,pw_salt:o,pw_cost:i}).then(function(e){var n={pw_nonce:a,pw_cost:i,identifier:t,version:r};return{keys:{pw:e[0],mk:e[1],ak:e[2]},authParams:n}}));case 9:case"end":return e.stop()}},e,this)}));return e}()}]),e}(),D=r.SFCryptoJS=function(e){function r(){return a(this,r),t(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return n(r,e),l(r,[{key:"pbkdf2",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return a={keySize:i/32,hasher:o.algo.SHA512,iterations:r},e.abrupt("return",o.PBKDF2(t,n,a).toString());case 2:case"end":return e.stop()}},e,this)}));return e}()}]),r}(P),h="undefined"!=typeof window?window:void 0!==e?e:null,O=h.crypto?h.crypto.subtle:null,M=r.SFCryptoWeb=function(e){function r(){return a(this,r),t(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return n(r,e),l(r,[{key:"pbkdf2",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.webCryptoImportKey(t,"PBKDF2",["deriveBits"]);case 2:if(a=e.sent){e.next=6;break}return console.log("Key is null, unable to continue"),e.abrupt("return",null);case 6:return e.abrupt("return",this.webCryptoDeriveBits(a,n,r,i));case 7:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateRandomKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=!0,e.abrupt("return",O.generateKey({name:"AES-CBC",length:t},n,["encrypt","decrypt"]).then(function(e){return O.exportKey("raw",e).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.arrayBufferToHexString(new Uint8Array(t));case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,r)}));return function(t){return e.apply(this,arguments)}}()).catch(function(e){console.error("Error exporting key",e)})}).catch(function(e){console.error("Error generating key",e)}));case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateItemEncryptionKey",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=256,e.abrupt("return",Promise.all([this.generateRandomKey(t),this.generateRandomKey(t)]).then(function(e){return e.join("")}));case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"encryptText",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){var a,o,s,u,c,l=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!r){e.next=6;break}return e.next=3,this.hexStringToArrayBuffer(r);case 3:e.t0=e.sent,e.next=7;break;case 6:e.t0=new ArrayBuffer(16);case 7:return a=e.t0,o={name:"AES-CBC",iv:a},e.next=11,this.hexStringToArrayBuffer(n);case 11:return s=e.sent,e.next=14,this.webCryptoImportKey(s,o.name,["encrypt"]);case 14:return u=e.sent,e.next=17,this.stringToArrayBuffer(t);case 17:return c=e.sent,e.abrupt("return",crypto.subtle.encrypt(o,u,c).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l.arrayBufferToBase64(t);case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,l)}));return function(t){return e.apply(this,arguments)}}()));case 19:case"end":return e.stop()}},e,this)}));return e}()},{key:"decryptText",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,a,o,s,u=this,c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=c.ciphertextToAuth,f=c.contentCiphertext,p=c.encryptionKey,h=c.iv,d=c.authHash,y=c.authKey,v=arguments[1];return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!v||d){e.next=3;break}return console.error("Auth hash is required."),e.abrupt("return");case 3:if(!d){e.next=10;break}return e.next=6,this.hmac256(l,y);case 6:if(t=e.sent,d===t){e.next=10;break}return console.error("Auth hash does not match, returning null. "+d+" != "+t),e.abrupt("return",null);case 10:if(!h){e.next=16;break}return e.next=13,this.hexStringToArrayBuffer(h);case 13:e.t0=e.sent,e.next=17;break;case 16:e.t0=new ArrayBuffer(16);case 17:return n=e.t0,r={name:"AES-CBC",iv:n},e.next=21,this.hexStringToArrayBuffer(p);case 21:return a=e.sent,e.next=24,this.webCryptoImportKey(a,r.name,["decrypt"]);case 24:return o=e.sent,e.next=27,this.base64ToArrayBuffer(f);case 27:return s=e.sent,e.abrupt("return",crypto.subtle.decrypt(r,o,s).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.arrayBufferToString(t);case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,u)}));return function(t){return e.apply(this,arguments)}}()).catch(function(e){console.error("Error decrypting:",e)}));case 29:case"end":return e.stop()}},e,this)}));return e}()},{key:"webCryptoImportKey",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=6;break}return e.next=3,this.stringToArrayBuffer(t);case 3:e.t0=e.sent,e.next=7;break;case 6:e.t0=t;case 7:return a=e.t0,e.abrupt("return",O.importKey("raw",a,{name:n,hash:i},!1,r).then(function(e){return e}).catch(function(e){return console.error(e),null}));case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"webCryptoDeriveBits",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,a){var o,s=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.stringToArrayBuffer(n);case 2:return e.t0=e.sent,e.t1=r,e.t2={name:"SHA-512"},o={name:"PBKDF2",salt:e.t0,iterations:e.t1,hash:e.t2},e.abrupt("return",O.deriveBits(o,t,a).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.arrayBufferToHexString(new Uint8Array(t));case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,s)}));return function(t){return e.apply(this,arguments)}}()).catch(function(e){return console.error(e),null}));case 7:case"end":return e.stop()}},e,this)}));return e}()},{key:"stringToArrayBuffer",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){var r=new Blob([t]),i=new FileReader;i.onload=function(t){e(t.target.result)},i.readAsArrayBuffer(r)}));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"arrayBufferToString",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){var r=new Blob([t]),i=new FileReader;i.onload=function(t){e(t.target.result)},i.readAsText(r)}));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"arrayBufferToHexString",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:for(n=new Uint8Array(t),r="",a=0;a5e3)||this.crypto instanceof M}},{key:"supportedVersions",value:function(){return["001","002","003"]}},{key:"isVersionNewerThanLibraryVersion",value:function(e){var t=this.version();return parseInt(e)>parseInt(t)}},{key:"isProtocolVersionOutdated",value:function(e){var t={"001":Date.parse("2018-01-01"),"002":Date.parse("2020-01-01")},n=t[e];return!!n&&new Date>n}},{key:"costMinimumForVersion",value:function(e){return{"001":3e3,"002":3e3,"003":11e4}[e]}},{key:"defaultPasswordGenerationCost",value:function(){return this.costMinimumForVersion(this.version())}}]),e}();if(h)try{h.StandardFile=T,h.SFJS=new T,h.SFCryptoWeb=M,h.SFCryptoJS=D,h.SFItemTransformer=A,h.SFModelManager=v,h.SFItem=x,h.SFItemParams=S,h.SFHttpManager=d,h.SFStorageManager=k,h.SFSyncManager=w,h.SFAuthManager=p,h.SFMigrationManager=y,h.SFAlertManager=f,h.SFPredicate=C,h.SFHistorySession=R,h.SFSessionHistoryManager=m,h.SFItemHistory=E,h.SFItemHistoryEntry=F,h.SFPrivilegesManager=g,h.SFPrivileges=I,h.SFSingletonManager=b}catch(e){console.log("Exception while exporting window variables",e)}}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(t,n(3))},function(e,t){!function(t){"use strict";function n(e,t,n,r){var a=t&&t.prototype instanceof i?t:i,o=Object.create(a.prototype),s=new h(r||[]);return o._invoke=c(e,n,s),o}function r(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function i(){}function a(){}function o(){}function s(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function u(e){function t(n,i,a,o){var s=r(e[n],e,i);if("throw"!==s.type){var u=s.arg,c=u.value;return c&&"object"==typeof c&&m.call(c,"__await")?Promise.resolve(c.__await).then(function(e){t("next",e,a,o)},function(e){t("throw",e,a,o)}):Promise.resolve(c).then(function(e){u.value=e,a(u)},o)}o(s.arg)}function n(e,n){function r(){return new Promise(function(r,i){t(e,n,r,i)})}return i=i?i.then(r,r):r()}var i;this._invoke=n}function c(e,t,n){var i=C;return function(a,o){if(i===R)throw new Error("Generator is already running");if(i===E){if("throw"===a)throw o;return y()}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var u=l(s,n);if(u){if(u===F)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===C)throw i=E,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=R;var c=r(e,t,n);if("normal"===c.type){if(i=n.done?E:I,c.arg===F)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=E,n.method="throw",n.arg=c.arg)}}}function l(e,t){var n=e.iterator[t.method];if(n===v){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=v,l(e,t),"throw"===t.method))return F;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return F}var i=r(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,F;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=v),t.delegate=null,F):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,F)}function f(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function p(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function h(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(f,this),this.reset(!0)}function d(e){if(e){var t=e[k];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n=0;--r){var i=this.tryEntries[r],a=i.completion;if("root"===i.tryLoc)return t("end");if(i.tryLoc<=this.prev){var o=m.call(i,"catchLoc"),s=m.call(i,"finallyLoc");if(o&&s){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&m.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),p(n),F}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;p(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:d(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=v),F}}}(function(){return this}()||Function("return this")())},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n=0?this.items[c]=u:this.items.push(u);case 15:r=!0,t.next=5;break;case 18:t.next=24;break;case 20:t.prev=20,t.t0=t.catch(3),i=!0,a=t.t0;case 24:t.prev=24,t.prev=25,r||null==o.return||o.return();case 27:if(t.prev=27,!i){t.next=30;break}throw a;case 30:return t.finish(27);case 31:return t.finish(24);case 32:this.notifyObserversOfEvent(e.BridgeEventReceivedItems);case 33:case"end":return t.stop()}},t,this,[[3,20,24,32],[25,,27,31]])}));return t}()},{key:"indexOfItem",value:function(e){for(var t in this.items)if(this.items[t].uuid==e.uuid)return t;return-1}},{key:"removeItemFromItems",value:function(e){this.items=this.items.filter(function(t){return t.uuid!==e.uuid})}},{key:"createItem",value:function(e,t){this.createItems([e],t)}},{key:"createItems",value:function(e,t){this.componentManager.createItems(e,function(e){t&&t(e.map(function(e){return new f.SFItem(e)}))})}},{key:"saveItem",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.saveItems([t]));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"saveItems",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t,i){r.componentManager.saveItems(n,function(n){t(n),r.notifyObserversOfEvent(e.BridgeEventSavedItem)})}));case 1:case"end":return t.stop()}},t)}));return t}()},{key:"indexOfItem",value:function(e){for(var t in this.items)if(this.items[t].uuid==e.uuid)return t;return-1}},{key:"deleteItem",value:function(e,t){this.deleteItems([e],t)}},{key:"deleteItems",value:function(e,t){this.componentManager.deleteItems(e,t)}},{key:"removeItemFromItems",value:function(e){this.items=this.items.filter(function(t){return t.uuid!==e.uuid})}}]),e}());u(p,"FileItemContentTypeKey","SN|FileSafe|File"),u(p,"FileSafeCredentialsContentType","SN|FileSafe|Credentials"),u(p,"FileDescriptorContentTypeKey","SN|FileSafe|FileMetadata"),u(p,"FileSafeIntegrationContentTypeKey","SN|FileSafe|Integration"),u(p,"BridgeEventLoadedCredentials","BridgeEventLoadedCredentials"),u(p,"BridgeEventReceivedItems","BridgeEventReceivedItems"),u(p,"BridgeEventSavedItem","BridgeEventSavedItem")},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;nt.length)n=e;else{n=t;var r=0,i=-1,a=-1,o=n.length;for(0>r&&(r=-r>o?0:o+r),i=i>o?o:i,0>i&&(i+=o),o=r>i?0:i-r>>>0,r>>>=0,i=Array(o);++aa?pt:o,a=1),t=Object(t);++is))return!1;if((u=a.get(e))&&a.get(t))return u==t;var u=-1,c=!0,l=2&n?new E:pt;for(a.set(e,t),a.set(t,e);++un&&(n=ln(r+n,0)),y(e,be(t,3),n)):-1}function Te(e){return(null==e?0:e.length)?L(e,1):[]}function Ne(e){var t=null==e?0:e.length;return t?e[t-1]:pt}function je(e,t){var n;if(e&&e.length&&t&&t.length){n=t;var r=v,i=-1,a=n.length;for(e===n&&(n=ue(n));++i=e}function We(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Ve(e){return null!=e&&"object"==typeof e}function Je(e){return!(!Ve(e)||"[object Object]"!=z(e))&&(null===(e=Xt(e))||"function"==typeof(e=Kt.call(e,"constructor")&&e.constructor)&&e instanceof e&&zt.call(e)==Jt)}function qe(e){return"string"==typeof e||!Hn(e)&&Ve(e)&&"[object String]"==z(e)}function $e(e){return"symbol"==typeof e||Ve(e)&&"[object Symbol]"==z(e)}function Ge(e){return e?(e=Ye(e),e===ht||e===-ht?1.7976931348623157e308*(0>e?-1:1):e===e?e:0):0===e?e:0}function Qe(e){e=Ge(e);var t=e%1;return e===e?t?e-t:e:0}function Ye(e){if("number"==typeof e)return e;if($e(e))return dt;if(We(e)&&(e="function"==typeof e.valueOf?e.valueOf():e,e=We(e)?e+"":e),"string"!=typeof e)return 0===e?e:+e;e=e.replace(bt,"");var t=St.test(e);return t||Ct.test(e)?Pt(e.slice(2),t?2:8):xt.test(e)?dt:+e}function Xe(e){return ce(e,rt(e))}function Ze(e){return null==e?"":ne(e)}function et(e,t,n){return e=null==e?pt:H(e,t),e===pt?n:e}function tt(e,t){var n;if(n=null!=e){n=e;var r;r=ie(t,n);for(var i=-1,a=r.length,o=!1;++i(e=M(t,e))||(e==t.length-1?t.pop():tn.call(t,e,1),--this.size,0))},I.prototype.get=function(e){var t=this.__data__;return e=M(t,e),0>e?pt:t[e][1]},I.prototype.has=function(e){return-1r?(++this.size,n.push([e,t])):n[r][1]=t,this},R.prototype.clear=function(){this.size=0,this.__data__={hash:new C,map:new(dn||I),string:new C}},R.prototype.delete=function(e){return e=ke(this,e).delete(e),this.size-=e?1:0,e},R.prototype.get=function(e){return ke(this,e).get(e)},R.prototype.has=function(e){return ke(this,e).has(e)},R.prototype.set=function(e,t){var n=ke(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},E.prototype.add=E.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},E.prototype.has=function(e){return this.__data__.has(e)},F.prototype.clear=function(){this.__data__=new I,this.size=0},F.prototype.delete=function(e){var t=this.__data__;return e=t.delete(e),this.size=t.size,e},F.prototype.get=function(e){return this.__data__.get(e)},F.prototype.has=function(e){return this.__data__.has(e)},F.prototype.set=function(e,t){var n=this.__data__;if(n instanceof I){var r=n.__data__;if(!dn||199>r.length)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new R(r)}return n.set(e,t),this.size=n.size,this};var En=function(e,t){return function(t,n){if(null==t)return t;if(!He(t))return e(t,n);for(var r=t.length,i=-1,a=Object(t);++in&&(n=ln(r+n,0)),qe(e)?n<=r&&-10){var i=!0,a=!1,o=void 0;try{for(var s,u=t.integrations[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;if(c!=e){t.setIntegrationAsDefault(c);break}}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}}})}},{key:"integrations",get:function(){return this.extensionBridge.filterItems(l.a.FileSafeIntegrationContentTypeKey)}}]),e}()},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n0&&(e=n.credentials[0]),e}),u(this,"setCredentialAsDefault",function(e){var t=n.getDefaultCredentials();t&&(t.content.isDefault=!1),e.content.isDefault=!0,n.extensionBridge.saveItems([t,e])}),u(this,"deleteCredential",function(e){n.extensionBridge.deleteItem(e)}),this.extensionBridge=r,this.onCredentialLoad=i,this.credentials=[],this.extensionBridge.addEventHandler(function(e){e==f.a.BridgeEventReceivedItems&&n.reloadCredentials()})}return s(e,[{key:"reloadCredentials",value:function(){this.credentials=[];var e=this.extensionBridge.filterItems(f.a.FileSafeCredentialsContentType);if(0!=e.length){var t=!0,n=!1,r=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;this.credentials.find(function(e){return e.uuid==o.uuid})||this.credentials.push(o)}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}this.onCredentialLoad(),this.credentials.length>0&&this.didLoadCredentials()}}},{key:"createNewCredentials",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=256,e.next=3,SFJS.crypto.generateRandomKey(t);case 3:return n=e.sent,e.next=6,SFJS.crypto.generateRandomKey(t);case 6:return r=e.sent,e.next=9,SFJS.crypto.generateInitialKeysAndAuthParamsForUser(n,r);case 9:return i=e.sent,i.isDefault=0==this.credentials.length,a=new l.SFItem({content_type:f.a.FileSafeCredentialsContentType,content:i}),this.extensionBridge.saveItem(a),this.didLoadCredentials(),e.abrupt("return",a);case 15:case"end":return e.stop()}},e,this)}));return e}()},{key:"didLoadCredentials",value:function(){this.extensionBridge.notifyObserversOfEvent(f.a.BridgeEventLoadedCredentials)}},{key:"credentialForFileDescriptor",value:function(e){return this.credentials.find(function(t){return e.content.references.find(function(e){return e.uuid==t.uuid})})}},{key:"getAllCredentials",value:function(){return this.credentials}},{key:"saveCredential",value:function(e){this.extensionBridge.saveItem(e)}}]),e}()},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n3&&void 0!==arguments[3]&&arguments[3],i=document.createElement("a");i.setAttribute("download",t),i.href=this.tempUrlForData(e,n),i.setAttribute("target","_blank"),r?window.location.href=i.href:(document.body.appendChild(i),i.click(),i.remove())}},{key:"tempUrlForData",value:function(e,t){return window.URL.createObjectURL(new Blob([e],{type:t||"text/json"}))}},{key:"copyTextToClipboard",value:function(e){if(window.clipboardData&&window.clipboardData.setData)return clipboardData.setData("Text",e);if(document.queryCommandSupported&&document.queryCommandSupported("copy")){var t=document.createElement("textarea");t.textContent=e,t.style.position="fixed",document.body.appendChild(t),t.select();try{return document.execCommand("copy")}catch(e){return console.warn("Copy to clipboard failed.",e),!1}finally{document.body.removeChild(t)}}}}]),e}()}])},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function a(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){function o(e){i(u,r,a,o,s,"next",e)}function s(e){i(u,r,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;ni)){r.next=14;break}return alert("The maximum upload size is ".concat(n," megabytes per file.")),o.setState({status:null}),e(),r.abrupt("return");case 14:return r.next=16,SFJS.crypto.arrayBufferToBase64(l);case 16:return p=r.sent,r.next=19,o.encryptFile(p,t.name,t.type);case 19:e();case 20:case"end":return r.stop()}},r)}));return function(e){return r.apply(this,arguments)}}(),o.setState({status:"Reading file..."}),t.name.endsWith(".sf")||t.name.endsWith(".json")?(u=!0,s.readAsText(t)):s.readAsArrayBuffer(t)}));case 4:case"end":return e.stop()}},e)}));return e}()},{key:"decryptDraggedFile",value:function(){function e(e){return t.apply(this,arguments)}var t=a(regeneratorRuntime.mark(function e(t){var n,r,i,o,s,u,c,l,f,p=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.setState({status:"Decrypting..."}),n=k.a.get().filesafe.getAllCredentials(),r=function(){var e=a(regeneratorRuntime.mark(function e(n){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,r){k.a.get().filesafe.decryptFile({fileDescriptor:t,credential:n}).then(function(t){var n=t.decryptedItem;k.a.get().filesafe.downloadBase64Data({base64Data:t.decryptedData,fileName:n.content.fileName,fileType:n.content.fileType}),p.setState({status:null}),e(!0)}).catch(function(e){console.error("Error decrypting:",e),p.flashError("Error decrypting file."),r(!1)})}));case 1:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),i=!0,o=!1,s=void 0,e.prev=6,u=n[Symbol.iterator]();case 8:if(i=(c=u.next()).done){e.next=18;break}return l=c.value,e.next=12,r(l);case 12:if(!(f=e.sent)){e.next=15;break}return e.abrupt("return");case 15:i=!0,e.next=8;break;case 18:e.next=24;break;case 20:e.prev=20,e.t0=e.catch(6),o=!0,s=e.t0;case 24:e.prev=24,e.prev=25,i||null==u.return||u.return();case 27:if(e.prev=27,!o){e.next=30;break}throw s;case 30:return e.finish(27);case 31:return e.finish(24);case 32:case"end":return e.stop()}},e,this,[[6,20,24,32],[25,,27,31]])}));return e}()},{key:"wait",value:function(){function e(e){return t.apply(this,arguments)}var t=a(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){setTimeout(function(){e()},1e3*t)}));case 1:case"end":return e.stop()}},e)}));return e}()},{key:"encryptFile",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=a(regeneratorRuntime.mark(function e(t,n,r){var i,o,s=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.setState({status:"Encrypting..."}),i=k.a.get().filesafe.getDefaultCredentials(),o=k.a.get().filesafe.getDefaultIntegration(),e.abrupt("return",k.a.get().filesafe.encryptFile({data:t,inputFileName:n,fileType:r,credential:i}).then(function(){var e=a(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return s.setState({status:"Uploading to ".concat(k.a.get().filesafe.displayStringForIntegration(o),"...")}),e.next=3,s.wait(.5);case 3:return e.abrupt("return",k.a.get().filesafe.uploadFile({fileItem:t,inputFileName:n,fileType:r,credential:i}).then(function(){s.setState({status:"Upload Success."})}).catch(function(e){console.error("fs-embed | error uploading file:",e),s.flashError("Error uploading file.")}));case 4:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()));case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"flashError",value:function(e){var t=this;this.setState({status:e,statusClass:"danger"}),setTimeout(function(){t.setState({status:null,statusClass:null})},2500)}},{key:"render",value:function(){var e=this,t=this.state.statusClass?this.state.statusClass:"info",n="info"==t;return v.a.createElement("div",{className:"sn-component files-view"},v.a.createElement("div",{className:"sk-panel-row align-top"},v.a.createElement("div",{className:"files"},this.state.messages.length>0&&v.a.createElement("div",{id:"messages-container",className:"sk-panel-section"},v.a.createElement(m.a,{messages:this.state.messages})),this.state.status&&v.a.createElement("div",{id:"file-upload-status",className:"sk-horizontal-group"},n&&v.a.createElement("div",{className:"sk-spinner info small"}),v.a.createElement("div",{className:t},this.state.status)),v.a.createElement("div",{id:"add-file-button-container"},v.a.createElement("div",{className:"file sk-button info"},v.a.createElement("label",{className:"no-style"},v.a.createElement("input",{type:"file",style:{display:"none"},onChange:function(t){e.handleDroppedFiles(t.target.files)}}),v.a.createElement("div",{id:"attach-file-button-label",className:"sk-label"},"Attach File")))),v.a.createElement(b.a,{files:this.state.noteFiles}))))}},{key:"rootElement",get:function(){return document.getElementById("filesafe-embed")}},{key:"dropContainer",get:function(){return document.getElementById("files-view")}},{key:"fileInput",get:function(){return document.getElementById("file-input")}}]),t}(v.a.Component)},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;nCreate New under Keys.",css:"sk-base"}),r=this.integrationManager.integrations,r&&0!=r.length||t.push({message:"Add a new integration by selecting Add New under Integrations",css:"sk-base"}),e.abrupt("return",t);case 8:case"end":return e.stop()}},e,this)}));return e}()}]),e}()},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n1;return d.a.createElement("div",null,d.a.createElement("div",{className:"sk-panel-row"},d.a.createElement("div",{className:"sk-h2 sk-bold"},"Integrations"),!this.state.showInputForm&&d.a.createElement("div",{className:"sk-button info no-border",onClick:this.addNewIntegrationClicked},d.a.createElement("div",{className:"sk-label"},"Add New"))),d.a.createElement("div",{id:"integrations"},this.state.showInputForm&&d.a.createElement("div",{className:"sk-notification info"},d.a.createElement("strong",null,"New Integration"),d.a.createElement("p",{className:"sk-p"},"A new tab has opened. After you complete the authentication flow, enter the code you receive below."),d.a.createElement("div",{className:"sk-panel-row"}),d.a.createElement("input",{className:"title sk-input contrast",type:"text",placeholder:"Enter integration code",value:this.state.integrationCode,onChange:this.handleTextChange,onKeyPress:this.handleKeyPress}),d.a.createElement("div",{className:"sk-button-group",style:{marginTop:10}},d.a.createElement("div",{className:"sk-button neutral",onClick:this.cancelIntegrationForm},d.a.createElement("a",{className:"sk-label"},"Cancel")),d.a.createElement("div",{className:"sk-button sk-base",onClick:this.submitIntegrationCode},d.a.createElement("a",{className:"sk-label"},"Submit"))))),d.a.createElement("div",{className:"list-container"},this.state.integrations.map(function(n){return d.a.createElement("div",{className:"list-item sk-horizontal-group top"},d.a.createElement("div",{className:"sk-circle x-small "+(n.content.isDefaultUploadSource?"info":"sk-secondary-contrast")}),d.a.createElement("div",null,d.a.createElement("div",{className:"sk-panel-row condensed sk-bold"},e.displayStringForIntegration(n)),d.a.createElement("div",{className:"sk-panel-row condensed"},d.a.createElement("div",{className:"sk-horizontal-group"},t&&!n.content.isDefaultUploadSource&&d.a.createElement("a",{className:"info",onClick:function(){e.setIntegrationAsDefaultUploadSource(n)}},"Make Default"),d.a.createElement("a",{className:"danger",onClick:function(){e.deleteIntegration(n)}},"Delete")))))})))}}]),t}(d.a.Component)}])},function(e,t){e.exports=function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,n){(function(t){var n,n;!function(t){e.exports=t()}(function(){return function(){function e(t,r,i){function a(s,u){if(!r[s]){if(!t[s]){var c="function"==typeof n&&n;if(!u&&c)return n(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var f=r[s]={exports:{}};t[s][0].call(f.exports,function(e){return a(t[s][1][e]||e)},f,f.exports,e,t,r,i)}return r[s].exports}for(var o="function"==typeof n&&n,s=0;s>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,o=0;4>o&&i+.75*o>>6*(3-o)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var n=e.length,r=this._map,i=r.charAt(64);i&&-1!=(i=e.indexOf(i))&&(n=i);for(var i=[],a=0,o=0;o>>6-o%4*2;i[a>>>2]|=(s|u)<<24-a%4*8,a++}return t.create(i,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){function t(e,t,n,r,i,a,o){return((e=e+(t&n|~t&r)+i+o)<>>32-a)+t}function n(e,t,n,r,i,a,o){return((e=e+(t&r|n&~r)+i+o)<>>32-a)+t}function r(e,t,n,r,i,a,o){return((e=e+(t^n^r)+i+o)<>>32-a)+t}function i(e,t,n,r,i,a,o){return((e=e+(n^(t|~r))+i+o)<>>32-a)+t}for(var a=o,s=a.lib,u=s.WordArray,c=s.Hasher,s=a.algo,l=[],f=0;64>f;f++)l[f]=4294967296*e.abs(e.sin(f+1))|0;s=s.MD5=c.extend({_doReset:function(){this._hash=new u.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,a){for(var o=0;16>o;o++){var s=a+o,u=e[s];e[s]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}var o=this._hash.words,s=e[a+0],u=e[a+1],c=e[a+2],f=e[a+3],p=e[a+4],h=e[a+5],d=e[a+6],y=e[a+7],v=e[a+8],g=e[a+9],m=e[a+10],b=e[a+11],k=e[a+12],w=e[a+13],x=e[a+14],S=e[a+15],_=o[0],C=o[1],I=o[2],R=o[3],_=t(_,C,I,R,s,7,l[0]),R=t(R,_,C,I,u,12,l[1]),I=t(I,R,_,C,c,17,l[2]),C=t(C,I,R,_,f,22,l[3]),_=t(_,C,I,R,p,7,l[4]),R=t(R,_,C,I,h,12,l[5]),I=t(I,R,_,C,d,17,l[6]),C=t(C,I,R,_,y,22,l[7]),_=t(_,C,I,R,v,7,l[8]),R=t(R,_,C,I,g,12,l[9]),I=t(I,R,_,C,m,17,l[10]),C=t(C,I,R,_,b,22,l[11]),_=t(_,C,I,R,k,7,l[12]),R=t(R,_,C,I,w,12,l[13]),I=t(I,R,_,C,x,17,l[14]),C=t(C,I,R,_,S,22,l[15]),_=n(_,C,I,R,u,5,l[16]),R=n(R,_,C,I,d,9,l[17]),I=n(I,R,_,C,b,14,l[18]),C=n(C,I,R,_,s,20,l[19]),_=n(_,C,I,R,h,5,l[20]),R=n(R,_,C,I,m,9,l[21]),I=n(I,R,_,C,S,14,l[22]),C=n(C,I,R,_,p,20,l[23]),_=n(_,C,I,R,g,5,l[24]),R=n(R,_,C,I,x,9,l[25]),I=n(I,R,_,C,f,14,l[26]),C=n(C,I,R,_,v,20,l[27]),_=n(_,C,I,R,w,5,l[28]),R=n(R,_,C,I,c,9,l[29]),I=n(I,R,_,C,y,14,l[30]),C=n(C,I,R,_,k,20,l[31]),_=r(_,C,I,R,h,4,l[32]),R=r(R,_,C,I,v,11,l[33]),I=r(I,R,_,C,b,16,l[34]),C=r(C,I,R,_,x,23,l[35]),_=r(_,C,I,R,u,4,l[36]),R=r(R,_,C,I,p,11,l[37]),I=r(I,R,_,C,y,16,l[38]),C=r(C,I,R,_,m,23,l[39]),_=r(_,C,I,R,w,4,l[40]),R=r(R,_,C,I,s,11,l[41]),I=r(I,R,_,C,f,16,l[42]),C=r(C,I,R,_,d,23,l[43]),_=r(_,C,I,R,g,4,l[44]),R=r(R,_,C,I,k,11,l[45]),I=r(I,R,_,C,S,16,l[46]),C=r(C,I,R,_,c,23,l[47]),_=i(_,C,I,R,s,6,l[48]),R=i(R,_,C,I,y,10,l[49]),I=i(I,R,_,C,x,15,l[50]),C=i(C,I,R,_,h,21,l[51]),_=i(_,C,I,R,k,6,l[52]),R=i(R,_,C,I,f,10,l[53]),I=i(I,R,_,C,m,15,l[54]),C=i(C,I,R,_,u,21,l[55]),_=i(_,C,I,R,v,6,l[56]),R=i(R,_,C,I,S,10,l[57]),I=i(I,R,_,C,d,15,l[58]),C=i(C,I,R,_,w,21,l[59]),_=i(_,C,I,R,p,6,l[60]),R=i(R,_,C,I,b,10,l[61]),I=i(I,R,_,C,c,15,l[62]),C=i(C,I,R,_,g,21,l[63]);o[0]=o[0]+_|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+R|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var a=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),t=this._hash,n=t.words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=c.clone.call(this);return e._hash=this._hash.clone(),e}}),a.MD5=c._createHelper(s),a.HmacMD5=c._createHmacHelper(s)}(Math),function(){var e=o,t=e.lib,n=t.Base,r=t.WordArray,t=e.algo,i=t.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=this.cfg,i=n.hasher.create(),a=r.create(),o=a.words,s=n.keySize,n=n.iterations;o.length>>2]}},n.BlockCipher=c.extend({cfg:c.cfg.extend({mode:l,padding:p}),reset:function(){c.reset.call(this);var e=this.cfg,t=e.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(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var h=n.CipherParams=r.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),l=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return e=e.salt,(e?i.create([1398893684,1701076831]).concat(e).concat(t):t).toString(s)},parse:function(e){e=s.parse(e);var t=e.words;if(1398893684==t[0]&&1701076831==t[1]){var n=i.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return h.create({ciphertext:e,salt:n})}},d=n.SerializableCipher=r.extend({cfg:r.extend({format:l}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,h.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),t=(t.kdf={}).OpenSSL={execute:function(e,t,n,r){return r||(r=i.random(8)),e=u.create({keySize:t+n}).compute(e,r),n=i.create(e.words.slice(t),4*n),e.sigBytes=4*t,h.create({key:e,iv:n,salt:r})}},y=n.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:t}),encrypt:function(e,t,n,r){return r=this.cfg.extend(r),n=r.kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,e=d.encrypt.call(this,e,t,n.key,r),e.mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,d.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=o,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],a=[],s=[],u=[],c=[],l=[],f=[],p=[],h=[],d=[],y=0;256>y;y++)d[y]=128>y?y<<1:y<<1^283;for(var v=0,g=0,y=0;256>y;y++){var m=g^g<<1^g<<2^g<<3^g<<4,m=m>>>8^255&m^99;r[v]=m,i[m]=v;var b=d[v],k=d[b],w=d[k],x=257*d[m]^16843008*m;a[v]=x<<24|x>>>8,s[v]=x<<16|x>>>16,u[v]=x<<8|x>>>24,c[v]=x,x=16843009*w^65537*k^257*b^16843008*v,l[m]=x<<24|x>>>8,f[m]=x<<16|x>>>16,p[m]=x<<8|x>>>24,h[m]=x,v?(v=b^d[d[d[w^b]]],g^=d[d[g]]):v=g=1}var S=[0,1,2,4,8,16,32,64,128,27,54],n=n.AES=t.extend({_doReset:function(){for(var e=this._key,t=e.words,n=e.sigBytes/4,e=4*((this._nRounds=n+6)+1),i=this._keySchedule=[],a=0;a>>24]<<24|r[o>>>16&255]<<16|r[o>>>8&255]<<8|r[255&o]):(o=o<<8|o>>>24,o=r[o>>>24]<<24|r[o>>>16&255]<<16|r[o>>>8&255]<<8|r[255&o],o^=S[a/n|0]<<24),i[a]=i[a-n]^o}for(t=this._invKeySchedule=[],n=0;nn||4>=a?o:l[r[o>>>24]]^f[r[o>>>16&255]]^p[r[o>>>8&255]]^h[r[255&o]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,u,c,r)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,l,f,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,a,o,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],f=e[t+2]^n[2],p=e[t+3]^n[3],h=4,d=1;d>>24]^i[l>>>16&255]^a[f>>>8&255]^o[255&p]^n[h++],v=r[l>>>24]^i[f>>>16&255]^a[p>>>8&255]^o[255&c]^n[h++],g=r[f>>>24]^i[p>>>16&255]^a[c>>>8&255]^o[255&l]^n[h++],p=r[p>>>24]^i[c>>>16&255]^a[l>>>8&255]^o[255&f]^n[h++],c=y,l=v,f=g;y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[f>>>8&255]<<8|s[255&p])^n[h++],v=(s[l>>>24]<<24|s[f>>>16&255]<<16|s[p>>>8&255]<<8|s[255&c])^n[h++],g=(s[f>>>24]<<24|s[p>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[h++],p=(s[p>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&f])^n[h++],e[t]=y,e[t+1]=v,e[t+2]=g,e[t+3]=p},keySize:8});e.AES=t._createHelper(n)}();var o=o||function(e,t){var n={},r=n.lib={},i=function(){},a=r.Base={extend:function(e){i.prototype=this;var t=new i;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=r.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;ul;){var f;e:{f=c;for(var p=e.sqrt(f),h=2;h<=p;h++)if(!(f%h)){f=!1;break e}f=!0}f&&(8>l&&(a[l]=u(e.pow(c,.5))),s[l]=u(e.pow(c,1/3)),l++),c++}var d=[],n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],a=n[2],o=n[3],u=n[4],c=n[5],l=n[6],f=n[7],p=0;64>p;p++){if(16>p)d[p]=0|e[t+p];else{var h=d[p-15],y=d[p-2];d[p]=((h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3)+d[p-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+d[p-16]}h=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[p]+d[p],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&a^i&a),f=l,l=c,c=u,u=o+h|0,o=a,a=i,i=r,r=h+y|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+f|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(n),t.HmacSHA256=i._createHmacHelper(n)}(Math),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var a=this._oKey=n.clone(),o=this._iKey=n.clone(),s=a.words,u=o.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;uc;c++)u[c]=e();r=r.SHA512=n.extend({_doReset:function(){this._hash=new a.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],a=n[2],o=n[3],c=n[4],l=n[5],f=n[6],n=n[7],p=r.high,h=r.low,d=i.high,y=i.low,v=a.high,g=a.low,m=o.high,b=o.low,k=c.high,w=c.low,x=l.high,S=l.low,_=f.high,C=f.low,I=n.high,R=n.low,E=p,F=h,P=d,D=y,O=v,M=g,A=m,T=b,N=k,j=w,B=x,L=S,H=_,U=C,z=I,K=R,W=0;80>W;W++){var V=u[W];if(16>W)var J=V.high=0|e[t+2*W],q=V.low=0|e[t+2*W+1];else{var J=u[W-15],q=J.high,$=J.low,J=(q>>>1|$<<31)^(q>>>8|$<<24)^q>>>7,$=($>>>1|q<<31)^($>>>8|q<<24)^($>>>7|q<<25),G=u[W-2],q=G.high,Q=G.low,G=(q>>>19|Q<<13)^(q<<3|Q>>>29)^q>>>6,Q=(Q>>>19|q<<13)^(Q<<3|q>>>29)^(Q>>>6|q<<26),q=u[W-7],Y=q.high,X=u[W-16],Z=X.high,X=X.low,q=$+q.low,J=J+Y+(q>>>0<$>>>0?1:0),q=q+Q,J=J+G+(q>>>0>>0?1:0),q=q+X,J=J+Z+(q>>>0>>0?1:0);V.high=J,V.low=q}var Y=N&B^~N&H,X=j&L^~j&U,V=E&P^E&O^P&O,ee=F&D^F&M^D&M,$=(E>>>28|F<<4)^(E<<30|F>>>2)^(E<<25|F>>>7),G=(F>>>28|E<<4)^(F<<30|E>>>2)^(F<<25|E>>>7),Q=s[W],te=Q.high,ne=Q.low,Q=K+((j>>>14|N<<18)^(j>>>18|N<<14)^(j<<23|N>>>9)),Z=z+((N>>>14|j<<18)^(N>>>18|j<<14)^(N<<23|j>>>9))+(Q>>>0>>0?1:0),Q=Q+X,Z=Z+Y+(Q>>>0>>0?1:0),Q=Q+ne,Z=Z+te+(Q>>>0>>0?1:0),Q=Q+q,Z=Z+J+(Q>>>0>>0?1:0),q=G+ee,V=$+V+(q>>>0>>0?1:0),z=H,K=U,H=B,U=L,B=N,L=j,j=T+Q|0,N=A+Z+(j>>>0>>0?1:0)|0,A=O,T=M,O=P,M=D,P=E,D=F,F=Q+q|0,E=Z+V+(F>>>0>>0?1:0)|0}h=r.low=h+F,r.high=p+E+(h>>>0>>0?1:0),y=i.low=y+D,i.high=d+P+(y>>>0>>0?1:0),g=a.low=g+M,a.high=v+O+(g>>>0>>0?1:0),b=o.low=b+T,o.high=m+A+(b>>>0>>0?1:0),w=c.low=w+j,c.high=k+N+(w>>>0>>0?1:0),S=l.low=S+L,l.high=x+B+(S>>>0>>0?1:0),C=f.low=C+U,f.high=_+H+(C>>>0>>0?1:0),R=n.low=R+K,n.high=I+z+(R>>>0>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(r+128>>>10<<5)]=Math.floor(n/4294967296),t[31+(r+128>>>10<<5)]=n,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32}),t.SHA512=n._createHelper(r),t.HmacSHA512=n._createHmacHelper(r)}(),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var a=this._oKey=n.clone(),o=this._iKey=n.clone(),s=a.words,u=o.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;uc;c++){if(16>c)i[c]=0|e[t+c];else{var l=i[c-3]^i[c-8]^i[c-14]^i[c-16];i[c]=l<<1|l>>>31}l=(r<<5|r>>>27)+u+i[c],l=20>c?l+(1518500249+(a&o|~a&s)):40>c?l+(1859775393+(a^o^s)):60>c?l+((a&o|a&s|o&s)-1894007588):l+((a^o^s)-899497514),u=s,s=o,o=a<<30|a>>>2,a=r,r=l}n[0]=n[0]+r|0,n[1]=n[1]+a|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});e.SHA1=r._createHelper(t),e.HmacSHA1=r._createHmacHelper(t)}(),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var a=this._oKey=n.clone(),o=this._iKey=n.clone(),s=a.words,u=o.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;uc;c++){if(16>c)i[c]=0|e[t+c];else{var l=i[c-3]^i[c-8]^i[c-14]^i[c-16];i[c]=l<<1|l>>>31}l=(r<<5|r>>>27)+u+i[c],l=20>c?l+(1518500249+(a&o|~a&s)):40>c?l+(1859775393+(a^o^s)):60>c?l+((a&o|a&s|o&s)-1894007588):l+((a^o^s)-899497514),u=s,s=o,o=a<<30|a>>>2,a=r,r=l}n[0]=n[0]+r|0,n[1]=n[1]+a|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});e.SHA1=r._createHelper(t),e.HmacSHA1=r._createHmacHelper(t)}(),Object.defineProperty(r,"__esModule",{value:!0});var s,u=function(){function e(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l=function(){function e(e,t){for(var n=0;n=200&&c.status<=299?s.$timeout(function(){a(e),i(e)}):(console.error("Request error:",e),s.$timeout(function(){o(e,c.status),u(e)}))}},"get"==t&&Object.keys(r).length>0&&(n+=s.formatParams(r)),c.open(t,n,!0),e.next=6,s.setAuthHeadersForRequest(c);case 6:c.setRequestHeader("Content-type","application/json"),"post"==t||"patch"==t?c.send(JSON.stringify(r)):c.send();case 8:case"end":return e.stop()}},e,s)}));return function(t,n){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"formatParams",value:function(e){return"?"+Object.keys(e).map(function(t){return t+"="+encodeURIComponent(e[t])}).join("&")}}]),e}(),y=r.SFMigrationManager=function(){function e(t,n,r,o){var s=this;a(this,e),this.modelManager=t,this.syncManager=n,this.storageManager=r,this.completionHandlers=[],this.loadMigrations();var u=!1,c=o.addEventHandler(function(e){e==p.DidSignInEvent&&(u=!0)});this.syncManager.addEventHandler(function(){var e=i(regeneratorRuntime.mark(function e(t,n){var r,i,a,l,f,p,h,d,y,v;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r="local-data-loaded"==t,i="sync:completed"==t,!r&&!i){e.next=40;break}if(r?s.receivedLocalDataEvent=!0:i&&(s.receivedSyncCompletedEvent=!0),!s.receivedLocalDataEvent||!s.receivedSyncCompletedEvent){e.next=40;break}if(!u){e.next=39;break}return u=!1,o.removeEventHandler(c),e.next=10,s.getCompletedMigrations();case 10:a=e.sent.slice(),l=!0,f=!1,p=void 0,e.prev=14,h=a[Symbol.iterator]();case 16:if(l=(d=h.next()).done){e.next=25;break}return y=d.value,e.next=20,s.migrationForEncodedName(y);case 20:v=e.sent,v.runOnlyOnce||_.pull(s._completed,y);case 22:l=!0,e.next=16;break;case 25:e.next=31;break;case 27:e.prev=27,e.t0=e.catch(14),f=!0,p=e.t0;case 31:e.prev=31,e.prev=32,!l&&h.return&&h.return();case 34:if(e.prev=34,!f){e.next=37;break}throw p;case 37:return e.finish(34);case 38:return e.finish(31);case 39:s.runPendingMigrations();case 40:case"end":return e.stop()}},e,s,[[14,27,31,39],[32,,34,38]])}));return function(t,n){return e.apply(this,arguments)}}())}return l(e,[{key:"addCompletionHandler",value:function(e){this.completionHandlers.push(e)}},{key:"removeCompletionHandler",value:function(e){_.pull(this.completionHandlers,e)}},{key:"migrationForEncodedName",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.decode(t);case 2:return n=e.sent,e.abrupt("return",this.migrations.find(function(e){return e.name==n}));case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"loadMigrations",value:function(){this.migrations=this.registeredMigrations()}},{key:"registeredMigrations",value:function(){}},{key:"runPendingMigrations",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a,o,s,u,c,l,f,p,h,d,y,v,g,m,b,k,w,x,S,_,C,I,R,E,F;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPendingMigrations();case 2:for(t=e.sent,n=!0,r=!1,i=void 0,e.prev=6,a=t[Symbol.iterator]();!(n=(o=a.next()).done);n=!0)s=o.value,s.items=[];e.next=14;break;case 10:e.prev=10,e.t0=e.catch(6),r=!0,i=e.t0;case 14:e.prev=14,e.prev=15,!n&&a.return&&a.return();case 17:if(e.prev=17,!r){e.next=20;break}throw i;case 20:return e.finish(17);case 21:return e.finish(14);case 22:u=!0,c=!1,l=void 0,e.prev=25,f=this.modelManager.allNondummyItems[Symbol.iterator]();case 27:if(u=(p=f.next()).done){e.next=51;break}for(h=p.value,d=!0,y=!1,v=void 0,e.prev=32,g=t[Symbol.iterator]();!(d=(m=g.next()).done);d=!0)s=m.value,h.content_type==s.content_type&&s.items.push(h);e.next=40;break;case 36:e.prev=36,e.t1=e.catch(32),y=!0,v=e.t1;case 40:e.prev=40,e.prev=41,!d&&g.return&&g.return();case 43:if(e.prev=43,!y){e.next=46;break}throw v;case 46:return e.finish(43);case 47:return e.finish(40);case 48:u=!0,e.next=27;break;case 51:e.next=57;break;case 53:e.prev=53,e.t2=e.catch(25),c=!0,l=e.t2;case 57:e.prev=57,e.prev=58,!u&&f.return&&f.return();case 60:if(e.prev=60,!c){e.next=63;break}throw l;case 63:return e.finish(60);case 64:return e.finish(57);case 65:b=!0,k=!1,w=void 0,e.prev=68,x=t[Symbol.iterator]();case 70:if(b=(S=x.next()).done){e.next=81;break}if(s=S.value,!(s.items&&s.items.length>0||s.customHandler)){e.next=77;break}return e.next=75,this.runMigration(s,s.items);case 75:e.next=78;break;case 77:this.markMigrationCompleted(s);case 78:b=!0,e.next=70;break;case 81:e.next=87;break;case 83:e.prev=83,e.t3=e.catch(68),k=!0,w=e.t3;case 87:e.prev=87,e.prev=88,!b&&x.return&&x.return();case 90:if(e.prev=90,!k){e.next=93;break}throw w;case 93:return e.finish(90);case 94:return e.finish(87);case 95:for(_=!0,C=!1,I=void 0,e.prev=98,R=this.completionHandlers[Symbol.iterator]();!(_=(E=R.next()).done);_=!0)(F=E.value)();e.next=106;break;case 102:e.prev=102,e.t4=e.catch(98),C=!0,I=e.t4;case 106:e.prev=106,e.prev=107,!_&&R.return&&R.return();case 109:if(e.prev=109,!C){e.next=112;break}throw I;case 112:return e.finish(109);case 113:return e.finish(106);case 114:case"end":return e.stop()}},e,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]])}));return e}()},{key:"encode",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",window.btoa(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"decode",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",window.atob(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"getCompletedMigrations",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._completed){e.next=5;break}return e.next=3,this.storageManager.getItem("migrations");case 3:t=e.sent,this._completed=t?JSON.parse(t):[];case 5:return e.abrupt("return",this._completed);case 6:case"end":return e.stop()}},e,this)}));return e}()},{key:"getPendingMigrations",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a,o,s,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getCompletedMigrations();case 2:t=e.sent,n=[],r=!0,i=!1,a=void 0,e.prev=7,o=this.migrations[Symbol.iterator]();case 9:if(r=(s=o.next()).done){e.next=22;break}return u=s.value,e.t0=t,e.next=14,this.encode(u.name);case 14:if(e.t1=e.sent,e.t2=e.t0.indexOf.call(e.t0,e.t1),e.t3=-1,e.t2!=e.t3){e.next=19;break}n.push(u);case 19:r=!0,e.next=9;break;case 22:e.next=28;break;case 24:e.prev=24,e.t4=e.catch(7),i=!0,a=e.t4;case 28:e.prev=28,e.prev=29,!r&&o.return&&o.return();case 31:if(e.prev=31,!i){e.next=34;break}throw a;case 34:return e.finish(31);case 35:return e.finish(28);case 36:return e.abrupt("return",n);case 37:case"end":return e.stop()}},e,this,[[7,24,28,36],[29,,31,35]])}));return e}()},{key:"markMigrationCompleted",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getCompletedMigrations();case 2:return n=e.sent,e.t0=n,e.next=6,this.encode(t.name);case 6:e.t1=e.sent,e.t0.push.call(e.t0,e.t1),this.storageManager.setItem("migrations",JSON.stringify(n)),t.running=!1;case 10:case"end":return e.stop()}},e,this)}));return e}()},{key:"runMigration",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.running){e.next=2;break}return e.abrupt("return");case 2:if(console.log("Running migration:",t.name),t.running=!0,!t.customHandler){e.next=8;break}return e.abrupt("return",t.customHandler().then(function(){r.markMigrationCompleted(t)}));case 8:return e.abrupt("return",t.handler(n).then(function(){r.markMigrationCompleted(t)}));case 9:case"end":return e.stop()}},e,this)}));return e}()}]),e}(),v=r.SFModelManager=function(){function e(t){a(this,e),e.MappingSourceRemoteRetrieved="MappingSourceRemoteRetrieved",e.MappingSourceRemoteSaved="MappingSourceRemoteSaved",e.MappingSourceLocalSaved="MappingSourceLocalSaved",e.MappingSourceLocalRetrieved="MappingSourceLocalRetrieved",e.MappingSourceComponentRetrieved="MappingSourceComponentRetrieved",e.MappingSourceDesktopInstalled="MappingSourceDesktopInstalled",e.MappingSourceRemoteActionRetrieved="MappingSourceRemoteActionRetrieved",e.MappingSourceFileImport="MappingSourceFileImport",e.isMappingSourceRetrieved=function(t){return[e.MappingSourceRemoteRetrieved,e.MappingSourceComponentRetrieved,e.MappingSourceRemoteActionRetrieved].includes(t)},this.$timeout=t||setTimeout.bind(window),this.itemSyncObservers=[],this.itemsPendingRemoval=[],this.items=[],this.itemsHash={},this.missedReferences={},this.uuidChangeObservers=[]}return l(e,[{key:"handleSignout",value:function(){this.items.length=0,this.itemsHash={},this.itemsPendingRemoval.length=0,this.missedReferences={}}},{key:"addModelUuidChangeObserver",value:function(e,t){this.uuidChangeObservers.push({id:e,callback:t})}},{key:"notifyObserversOfUuidChange",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.uuidChangeObservers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){a.value.callback(e,t)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"alternateUUIDForItem",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.createItem(n,!0),t.next=3,SFJS.crypto.generateUUID();case 3:for(r.uuid=t.sent,r.informReferencesOfUUIDChange(n.uuid,r.uuid),this.informModelsOfUUIDChangeForItem(r,n.uuid,r.uuid),i=!0,a=!1,o=void 0,t.prev=9,s=n.referencingObjects[Symbol.iterator]();!(i=(u=s.next()).done);i=!0)c=u.value,c.setIsNoLongerBeingReferencedBy(n),n.setIsNoLongerBeingReferencedBy(c),c.addItemAsRelationship(r),c.setDirty(!0);t.next=17;break;case 13:t.prev=13,t.t0=t.catch(9),a=!0,o=t.t0;case 17:t.prev=17,t.prev=18,!i&&s.return&&s.return();case 20:if(t.prev=20,!a){t.next=23;break}throw o;case 23:return t.finish(20);case 24:return t.finish(17);case 25:return this.resolveReferencesForItem(r),console.log(n.uuid,"--\x3e",r.uuid),n.deleted=!0,n.content.references=[],n.setDirty(!1),this.mapResponseItemsToLocalModels([n],e.MappingSourceLocalSaved),this.addItem(r),r.setDirty(!0),this.notifyObserversOfUuidChange(n,r),t.abrupt("return",r);case 35:case"end":return t.stop()}},t,this,[[9,13,17,25],[18,,20,24]])}));return t}()},{key:"informModelsOfUUIDChangeForItem",value:function(e,t,n){var r=!0,i=!1,a=void 0;try{for(var o,s=this.items[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){o.value.potentialItemOfInterestHasChangedItsUUID(e,t,n)}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}}},{key:"didSyncModelsOffline",value:function(t){this.notifySyncObserversOfModels(t,e.MappingSourceLocalSaved)}},{key:"mapResponseItemsToLocalModels",value:function(e,t,n){return this.mapResponseItemsToLocalModelsWithOptions({items:e,source:t,sourceKey:n})}},{key:"mapResponseItemsToLocalModelsOmittingFields",value:function(e,t,n,r){return this.mapResponseItemsToLocalModelsWithOptions({items:e,omitFields:t,source:n,sourceKey:r})}},{key:"mapResponseItemsToLocalModelsWithOptions",value:function(e){var t=e.items,n=e.omitFields,r=e.source,i=e.sourceKey,a=(e.options,[]),o=[],s=[],c=!0,l=!1,f=void 0;try{for(var p,h=t[Symbol.iterator]();!(c=(p=h.next()).done);c=!0){var d=p.value;if(d){var y=!d.content&&!d.errorDecrypting;if(!(!d.content_type||!d.uuid)&&!y||d.deleted){if(Array.isArray(n)){var v=!0,g=!1,m=void 0;try{for(var b,k=n[Symbol.iterator]();!(v=(b=k.next()).done);v=!0){delete d[b.value]}}catch(e){g=!0,m=e}finally{try{!v&&k.return&&k.return()}finally{if(g)throw m}}}var w=this.findItem(d.uuid);if(w&&(w.updateFromJSON(d),w.dummy=!1),this.itemsPendingRemoval.includes(d.uuid))_.pull(this.itemsPendingRemoval,d.uuid);else{var x=d.content_type||w&&w.content_type;if(!(this.acceptableContentTypes&&!this.acceptableContentTypes.includes(x))){var S=!1;if(1==d.deleted){if(!d.dirty){w&&(s.push(w),this.removeItemLocally(w));continue}S=!0}w||(w=this.createItem(d,!0)),this.addItem(w,S),w.errorDecrypting||s.push(w),a.push(w),o.push(d)}}}else console.error("Server response item is corrupt:",d)}}}catch(e){l=!0,f=e}finally{try{!c&&h.return&&h.return()}finally{if(l)throw f}}var C=!0,I=!1,R=void 0;try{for(var E,F=o.entries()[Symbol.iterator]();!(C=(E=F.next()).done);C=!0){var P=E.value,D=u(P,2),O=D[0],M=D[1],A=a[O];M.content&&this.resolveReferencesForItem(A),A.didFinishSyncing()}}catch(e){I=!0,R=e}finally{try{!C&&F.return&&F.return()}finally{if(I)throw R}}var T=this.popMissedReferenceStructsForObjects(o),N=!0,j=!1,B=void 0;try{for(var L,H=T[Symbol.iterator]();!(N=(L=H.next()).done);N=!0){var U=L.value;!function(e){var t=a.find(function(t){return t.uuid==e.reference_uuid});if(t){e.for_item.addItemAsRelationship(t)}}(U)}}catch(e){j=!0,B=e}finally{try{!N&&H.return&&H.return()}finally{if(j)throw B}}return this.notifySyncObserversOfModels(s,r,i),a}},{key:"missedReferenceBuildKey",value:function(e,t){return e+":"+t}},{key:"popMissedReferenceStructsForObjects",value:function(e){if(!e||0==e.length)return[];var t=[],n=[],r=e.map(function(e){return e.uuid}),i=r[0].length,a=Object.keys(this.missedReferences),o=!0,s=!1,u=void 0;try{for(var c,l=a[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var f=c.value;r.includes(f.substring(0,i))&&(t.push(this.missedReferences[f]),n.push(f))}}catch(e){s=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw u}}var p=!0,h=!1,d=void 0;try{for(var y,v=n[Symbol.iterator]();!(p=(y=v.next()).done);p=!0){var g=y.value;delete this.missedReferences[g]}}catch(e){h=!0,d=e}finally{try{!p&&v.return&&v.return()}finally{if(h)throw d}}return t}},{key:"resolveReferencesForItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e.errorDecrypting){var n=e.contentObject;if(e.updateLocalRelationships(),n.references){var r=n.references.slice(),i=r.map(function(e){return e.uuid}),a=this.findItems(i,!0),o=!0,s=!1,c=void 0;try{for(var l,f=a.entries()[Symbol.iterator]();!(o=(l=f.next()).done);o=!0){var p=l.value,h=u(p,2),d=h[0],y=h[1];if(y)e.addItemAsRelationship(y),t&&y.setDirty(!0);else{var v=i[d],g=this.missedReferenceBuildKey(v,e.uuid);if(!this.missedReferences[g]){var m={reference_uuid:v,for_item:e};this.missedReferences[g]=m}}}}catch(e){s=!0,c=e}finally{try{!o&&f.return&&f.return()}finally{if(s)throw c}}}}}},{key:"notifySyncObserversOfModels",value:function(e,t,n){var r=this,i=this.itemSyncObservers.sort(function(e,t){return e.priority0&&r._callSyncObserverCallbackWithTimeout(i,a,o,s,t,n)}(l)}}catch(e){o=!0,s=e}finally{try{!a&&c.return&&c.return()}finally{if(o)throw s}}}},{key:"_callSyncObserverCallbackWithTimeout",value:function(e,t,n,r,i,a){this.$timeout(function(){e.callback(t,n,r,i,a)})}},{key:"createItem",value:function(t,n){var r=e.ContentTypeClassMapping&&e.ContentTypeClassMapping[t.content_type];r||(r=x);var i=new r(t);return n||this.notifySyncObserversOfModels([i],e.MappingSourceLocalSaved),i}},{key:"createConflictedItem",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,SFJS.crypto.generateUUID();case 2:return n=e.sent,t=_.merge(t,{uuid:n}),r=this.createItem(t,!0),e.abrupt("return",r);case 6:case"end":return e.stop()}},e,this)}));return e}()},{key:"addConflictedItem",value:function(e,t){this.addItem(e);var n=!0,r=!1,i=void 0;try{for(var a,o=t.referencingObjects[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;s.addItemAsRelationship(e),s.setDirty(!0)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}this.resolveReferencesForItem(e),e.content.conflict_of=t.uuid,e.setDirty(!0)}},{key:"duplicateItem",value:function(e){var t=new e.constructor({content:e.content});t.created_at=e.created_at,t.content_type=e.content_type,this.addItem(t);var n=!0,r=!1,i=void 0;try{for(var a,o=e.referencingObjects[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;s.addItemAsRelationship(t),s.setDirty(!0)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return this.resolveReferencesForItem(t),t.setDirty(!0),t}},{key:"addItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.addItems([e],t)}},{key:"addItems",value:function(e){var t=this;arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.forEach(function(e){t.itemsHash[e.uuid]||(t.itemsHash[e.uuid]=e,t.items.push(e))})}},{key:"addItemSyncObserver",value:function(e,t,n){this.addItemSyncObserverWithPriority({id:e,types:t,callback:n,priority:1})}},{key:"addItemSyncObserverWithPriority",value:function(e){var t=e.id,n=e.priority,r=e.types,i=e.callback;Array.isArray(r)||(r=[r]),this.itemSyncObservers.push({id:t,types:r,priority:n,callback:i})}},{key:"removeItemSyncObserver",value:function(e){_.remove(this.itemSyncObservers,_.find(this.itemSyncObservers,{id:e}))}},{key:"getDirtyItems",value:function(){return this.items.filter(function(e){return 1==e.dirty&&!e.dummy&&(!e.errorDecrypting||e.deleted)})}},{key:"clearDirtyItems",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){i.value.setDirty(!1)}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}}},{key:"setItemToBeDeleted",value:function(e){e.deleted=!0,e.dummy||e.setDirty(!0),this.removeAndDirtyAllRelationshipsForItem(e)}},{key:"removeAndDirtyAllRelationshipsForItem",value:function(e){if(!e.errorDecrypting){var t=!0,n=!1,r=void 0;try{for(var i,a=e.content.references[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value,s=this.findItem(o.uuid);s&&(e.removeItemAsRelationship(s),s.hasRelationshipWithItem(e)&&(s.removeItemAsRelationship(e),s.setDirty(!0)))}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}}var u=!0,c=!1,l=void 0;try{for(var f,p=e.referencingObjects[Symbol.iterator]();!(u=(f=p.next()).done);u=!0){var h=f.value;h.removeItemAsRelationship(e),h.setDirty(!0)}}catch(e){c=!0,l=e}finally{try{!u&&p.return&&p.return()}finally{if(c)throw l}}e.referencingObjects=[]}},{key:"setAllItemsDirty",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.allItems,n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){a.value.setDirty(!0,e)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"removeItemLocally",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:_.remove(this.items,{uuid:t.uuid}),delete this.itemsHash[t.uuid],t.isBeingRemovedLocally(),this.itemsPendingRemoval.push(t.uuid);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"allItemsMatchingTypes",value:function(e){return this.allItems.filter(function(t){return(_.includes(e,t.content_type)||_.includes(e,"*"))&&!t.dummy})}},{key:"invalidItems",value:function(){return this.allItems.filter(function(e){return e.errorDecrypting})}},{key:"validItemsForContentType",value:function(e){return this.allItems.filter(function(t){return t.content_type==e&&!t.errorDecrypting})}},{key:"findItem",value:function(e){return this.itemsHash[e]}},{key:"findItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value,c=this.itemsHash[u];(c||t)&&n.push(c)}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return n}},{key:"itemsMatchingPredicate",value:function(e){return this.itemsMatchingPredicates([e])}},{key:"itemsMatchingPredicates",value:function(e){return this.filterItemsWithPredicates(this.allItems,e)}},{key:"filterItemsWithPredicates",value:function(e,t){return e.filter(function(e){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(!e.satisfiesPredicate(s))return!1}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return!0})}},{key:"importItems",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c,l,f,p,h,d,y,v,g,m;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:r=[],i=!0,a=!1,o=void 0,t.prev=4,s=n[Symbol.iterator]();case 6:if(i=(u=s.next()).done){t.next=21;break}if(c=u.value,!(l=this.findItem(c.uuid))||l.errorDecrypting){t.next=16;break}return t.next=12,this.createConflictedItem(c);case 12:f=t.sent,c.deleted||l.isItemContentEqualWith(f)||(this.addConflictedItem(f,l),r.push(f)),t.next=18;break;case 16:r.push(c),l&&l.errorDecrypting&&(l.errorDecrypting=!1);case 18:i=!0,t.next=6;break;case 21:t.next=27;break;case 23:t.prev=23,t.t0=t.catch(4),a=!0,o=t.t0;case 27:t.prev=27,t.prev=28,!i&&s.return&&s.return();case 30:if(t.prev=30,!a){t.next=33;break}throw o;case 33:return t.finish(30);case 34:return t.finish(27);case 35:for(p=this.mapResponseItemsToLocalModels(r,e.MappingSourceFileImport),h=!0,d=!1,y=void 0,t.prev=39,v=p[Symbol.iterator]();!(h=(g=v.next()).done);h=!0)m=g.value,m.setDirty(!0,!0),m.deleted=!1;t.next=47;break;case 43:t.prev=43,t.t1=t.catch(39),d=!0,y=t.t1;case 47:t.prev=47,t.prev=48,!h&&v.return&&v.return();case 50:if(t.prev=50,!d){t.next=53;break}throw y;case 53:return t.finish(50);case 54:return t.finish(47);case 55:return t.abrupt("return",p);case 56:case"end":return t.stop()}},t,this,[[4,23,27,35],[28,,30,34],[39,43,47,55],[48,,50,54]])}));return t}()},{key:"getAllItemsJSONData",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.getJSONDataForItems(this.allItems,t,n,r));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"getJSONDataForItems",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.all(t.map(function(e){return new S(e,n,r).paramsForExportFile()})).then(function(e){if(i&&0==e.length)return null;var t={items:e};return n&&(t.auth_params=r),JSON.stringify(t,null,2)}));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"computeDataIntegrityHash",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=this.allNondummyItems.sort(function(e,t){return t.updated_at-e.updated_at}),n=t.map(function(e){return e.updatedAtTimestamp()}),r=n.join(","),e.next=6,SFJS.crypto.sha256(r);case 6:return i=e.sent,e.abrupt("return",i);case 10:return e.prev=10,e.t0=e.catch(0),console.error("Error computing data integrity hash",e.t0),e.abrupt("return",null);case 14:case"end":return e.stop()}},e,this,[[0,10]])}));return e}()},{key:"allItems",get:function(){return this.items.slice()}},{key:"allNondummyItems",get:function(){return this.items.filter(function(e){return!e.dummy})}}]),e}(),g=r.SFPrivilegesManager=function(){function e(t,n,r){a(this,e),this.modelManager=t,this.syncManager=n,this.singletonManager=r,this.loadPrivileges(),e.CredentialAccountPassword="CredentialAccountPassword",e.CredentialLocalPasscode="CredentialLocalPasscode",e.ActionManageExtensions="ActionManageExtensions",e.ActionManageBackups="ActionManageBackups",e.ActionViewProtectedNotes="ActionViewProtectedNotes",e.ActionManagePrivileges="ActionManagePrivileges",e.ActionManagePasscode="ActionManagePasscode",e.ActionDeleteNote="ActionDeleteNote",e.SessionExpiresAtKey="SessionExpiresAtKey",e.SessionLengthKey="SessionLengthKey",e.SessionLengthNone=0,e.SessionLengthFiveMinutes=300,e.SessionLengthOneHour=3600,e.SessionLengthOneWeek=604800,this.availableActions=[e.ActionViewProtectedNotes,e.ActionDeleteNote,e.ActionManagePasscode,e.ActionManageBackups,e.ActionManageExtensions,e.ActionManagePrivileges],this.availableCredentials=[e.CredentialAccountPassword,e.CredentialLocalPasscode],this.sessionLengths=[e.SessionLengthNone,e.SessionLengthFiveMinutes,e.SessionLengthOneHour,e.SessionLengthOneWeek,e.SessionLengthIndefinite]}return l(e,[{key:"setDelegate",value:function(e){this.delegate=e}},{key:"getAvailableActions",value:function(){return this.availableActions}},{key:"getAvailableCredentials",value:function(){return this.availableCredentials}},{key:"netCredentialsForAction",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPrivileges();case 2:t.t0=n,r=t.sent.getCredentialsForAction(t.t0),i=[],a=!0,o=!1,s=void 0,t.prev=8,u=r[Symbol.iterator]();case 10:if(a=(c=u.next()).done){t.next=27;break}if((l=c.value)!=e.CredentialAccountPassword){t.next=19;break}return t.next=15,this.delegate.isOffline();case 15:f=t.sent,f||i.push(l),t.next=24;break;case 19:if(l!=e.CredentialLocalPasscode){t.next=24;break}return t.next=22,this.delegate.hasLocalPasscode();case 22:p=t.sent,p&&i.push(l);case 24:a=!0,t.next=10;break;case 27:t.next=33;break;case 29:t.prev=29,t.t1=t.catch(8),o=!0,s=t.t1;case 33:t.prev=33,t.prev=34,!a&&u.return&&u.return();case 36:if(t.prev=36,!o){t.next=39;break}throw s;case 39:return t.finish(36);case 40:return t.finish(33);case 41:return t.abrupt("return",i);case 42:case"end":return t.stop()}},t,this,[[8,29,33,41],[34,,36,40]])}));return t}()},{key:"loadPrivileges",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.loadPromise){e.next=2;break}return e.abrupt("return",this.loadPromise);case 2:return this.loadPromise=new Promise(function(e,n){var r=I.contentType(),a=new C("content_type","=",r);t.singletonManager.registerSingleton([a],function(n){t.privileges=n,e(n)},function(){var n=i(regeneratorRuntime.mark(function n(i){var a;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(a=new I({content_type:r}),SFJS.crypto.generateUUIDSync){n.next=4;break}return n.next=4,a.initUUID();case 4:t.modelManager.addItem(a),a.setDirty(!0),t.syncManager.sync(),i(a),e(a);case 9:case"end":return n.stop()}},n,t)}));return function(e){return n.apply(this,arguments)}}())}),e.abrupt("return",this.loadPromise);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"getPrivileges",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.privileges){e.next=4;break}return e.abrupt("return",this.privileges);case 4:return e.abrupt("return",this.loadPrivileges());case 5:case"end":return e.stop()}},e,this)}));return e}()},{key:"displayInfoForCredential",value:function(t){var n={};return n[e.CredentialAccountPassword]={label:"Account Password",prompt:"Please enter your account password."},n[e.CredentialLocalPasscode]={label:"Local Passcode",prompt:"Please enter your local passcode."},n[t]}},{key:"displayInfoForAction",value:function(t){var n={};return n[e.ActionManageExtensions]={label:"Manage Extensions"},n[e.ActionManageBackups]={label:"Download/Import Backups"},n[e.ActionViewProtectedNotes]={label:"View Protected Notes"},n[e.ActionManagePrivileges]={label:"Manage Privileges"},n[e.ActionManagePasscode]={label:"Manage Passcode"},n[e.ActionDeleteNote]={label:"Delete Notes"},n[t]}},{key:"getSessionLengthOptions",value:function(){return[{value:e.SessionLengthNone,label:"Don't Remember"},{value:e.SessionLengthFiveMinutes,label:"5 Minutes"},{value:e.SessionLengthOneHour,label:"1 Hour"},{value:e.SessionLengthOneWeek,label:"1 Week"}]}},{key:"setSessionLength",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=function(e){var t=new Date;return t.setSeconds(t.getSeconds()+e),t},i=r(n),t.abrupt("return",Promise.all([this.delegate.saveToStorage(e.SessionExpiresAtKey,JSON.stringify(i)),this.delegate.saveToStorage(e.SessionLengthKey,JSON.stringify(n))]));case 3:case"end":return t.stop()}},t,this)}));return t}()},{key:"clearSession",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.setSessionLength(e.SessionLengthNone));case 1:case"end":return t.stop()}},t,this)}));return t}()},{key:"getSelectedSessionLength",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.delegate.getFromStorage(e.SessionLengthKey);case 2:if(!(n=t.sent)){t.next=7;break}return t.abrupt("return",JSON.parse(n));case 7:return t.abrupt("return",e.SessionLengthNone);case 8:case"end":return t.stop()}},t,this)}));return t}()},{key:"getSessionExpirey",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.delegate.getFromStorage(e.SessionExpiresAtKey);case 2:if(!(n=t.sent)){t.next=7;break}return t.abrupt("return",new Date(JSON.parse(n)));case 7:return t.abrupt("return",new Date);case 8:case"end":return t.stop()}},t,this)}));return t}()},{key:"actionHasPrivilegesConfigured",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.netCredentialsForAction(t);case 2:return e.t0=e.sent.length,e.abrupt("return",e.t0>0);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"actionRequiresPrivilege",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getSessionExpirey();case 2:if(!((n=e.sent)>new Date)){e.next=5;break}return e.abrupt("return",!1);case 5:return e.next=7,this.netCredentialsForAction(t);case 7:return r=e.sent,e.abrupt("return",r.length>0);case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"savePrivileges",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPrivileges();case 2:t=e.sent,t.setDirty(!0),this.syncManager.sync();case 5:case"end":return e.stop()}},e,this)}));return e}()},{key:"authenticateAction",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.netCredentialsForAction(t);case 2:r=e.sent,i=[],a=[],o=!0,s=!1,u=void 0,e.prev=7,c=r[Symbol.iterator]();case 9:if(o=(l=c.next()).done){e.next=18;break}return f=l.value,e.next=13,this._verifyAuthenticationParameters(f,n[f]);case 13:p=e.sent,p?i.push(f):a.push(f);case 15:o=!0,e.next=9;break;case 18:e.next=24;break;case 20:e.prev=20,e.t0=e.catch(7),s=!0,u=e.t0;case 24:e.prev=24,e.prev=25,!o&&c.return&&c.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:return e.abrupt("return",{success:0==a.length,successfulCredentials:i,failedCredentials:a});case 33:case"end":return e.stop()}},e,this,[[7,20,24,32],[25,,27,31]])}));return e}()},{key:"_verifyAuthenticationParameters",value:function(){function t(e,t){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n,r){var a,o,s=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(a=function(){var e=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s.delegate.verifyAccountPassword(t));case 1:case"end":return e.stop()}},e,s)}));return function(t){return e.apply(this,arguments)}}(),o=function(){var e=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s.delegate.verifyLocalPasscode(t));case 1:case"end":return e.stop()}},e,s)}));return function(t){return e.apply(this,arguments)}}(),n!=e.CredentialAccountPassword){t.next=6;break}return t.abrupt("return",a(r));case 6:if(n!=e.CredentialLocalPasscode){t.next=8;break}return t.abrupt("return",o(r));case 8:case"end":return t.stop()}},t,this)}));return t}()}]),e}(),m=r.SFSessionHistoryManager=function(){function e(t,n,r,i,o){var s=this;a(this,e),this.modelManager=t,this.storageManager=n,this.$timeout=o||setTimeout.bind(window),this.keyRequestHandler=r,this.loadFromDisk().then(function(){s.modelManager.addItemSyncObserver("session-history",i,function(e,t,n,r,i){var a=!0,o=!1,u=void 0;try{for(var c,l=e[Symbol.iterator]();!(a=(c=l.next()).done);a=!0){var f=c.value;try{s.addHistoryEntryForItem(f)}catch(e){console.log("Caught exception while trying to add item history entry",e)}}}catch(e){o=!0,u=e}finally{try{!a&&l.return&&l.return()}finally{if(o)throw u}}})})}return l(e,[{key:"encryptionParams",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.keyRequestHandler());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"addHistoryEntryForItem",value:function(e){var t=this,n={uuid:e.uuid,content_type:e.content_type,updated_at:e.updated_at,content:e.content},r=this.historySession.addEntryForItem(n);this.autoOptimize&&this.historySession.optimizeHistoryForItem(e),r&&this.diskEnabled&&(this.diskTimeout&&(this.$timeout.hasOwnProperty("cancel")?this.$timeout.cancel(this.diskTimeout):clearTimeout(this.diskTimeout)),this.diskTimeout=this.$timeout(function(){t.saveToDisk()},2e3))}},{key:"historyForItem",value:function(e){return this.historySession.historyForItem(e)}},{key:"clearHistoryForItem",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.historySession.clearItemHistory(t),e.abrupt("return",this.saveToDisk());case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"clearAllHistory",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.historySession.clearAllHistory(),e.abrupt("return",this.storageManager.removeItem("sessionHistory_revisions"));case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"toggleDiskSaving",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.diskEnabled=!this.diskEnabled,!this.diskEnabled){e.next=6;break}this.storageManager.setItem("sessionHistory_persist",JSON.stringify(!0)),this.saveToDisk(),e.next=8;break;case 6:return this.storageManager.setItem("sessionHistory_persist",JSON.stringify(!1)),e.abrupt("return",this.storageManager.removeItem("sessionHistory_revisions"));case 8:case"end":return e.stop()}},e,this)}));return e}()},{key:"saveToDisk",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.diskEnabled){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.encryptionParams();case 4:t=e.sent,n=new S(this.historySession,t.keys,t.auth_params),n.paramsForSync().then(function(e){r.storageManager.setItem("sessionHistory_revisions",JSON.stringify(e))});case 7:case"end":return e.stop()}},e,this)}));return e}()},{key:"loadFromDisk",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.storageManager.getItem("sessionHistory_persist");case 2:return t=e.sent,t&&(this.diskEnabled=JSON.parse(t)),e.next=6,this.storageManager.getItem("sessionHistory_revisions");case 6:if(!(n=e.sent)){e.next=18;break}return n=JSON.parse(n),e.next=11,this.encryptionParams();case 11:return r=e.sent,e.next=14,SFJS.itemTransformer.decryptItem(n,r.keys);case 14:i=new R(n),this.historySession=i,e.next=19;break;case 18:this.historySession=new R;case 19:return e.next=21,this.storageManager.getItem("sessionHistory_autoOptimize");case 21:a=e.sent,this.autoOptimize=!a||JSON.parse(a);case 23:case"end":return e.stop()}},e,this)}));return e}()},{key:"toggleAutoOptimize",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.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 e.stop()}},e,this)}));return e}()}]),e}(),b=r.SFSingletonManager=function(){function e(t,n){var r=this;a(this,e),this.syncManager=n,this.modelManager=t,this.singletonHandlers=[],t.addItemSyncObserverWithPriority({id:"sf-singleton-manager",types:"*",priority:-1,callback:function(){r.resolveSingletons(t.allNondummyItems,null,!0)}}),n.addEventHandler(function(e,n){if("local-data-loaded"==e)r.resolveSingletons(t.allNondummyItems,null,!0),r.initialDataLoaded=!0;else if("sync:completed"==e){if(!r.initialDataLoaded)return;r.resolveSingletons(n.retrievedItems,n.savedItems)}}),t.addModelUuidChangeObserver("singleton-manager",function(e,t){var n=!0,i=!1,a=void 0;try{for(var o,s=r.singletonHandlers[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;u.singleton&&C.ItemSatisfiesPredicates(t,u.predicates)&&(u.singleton=null,r.resolveSingletons([t]))}}catch(e){i=!0,a=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw a}}})}return l(e,[{key:"registerSingleton",value:function(e,t,n){this.singletonHandlers.push({predicates:e,resolutionCallback:t,createBlock:n})}},{key:"resolveSingletons",value:function(e,t,n){var r=this;e=e||[],t=t||[];var i=!0,a=!1,o=void 0;try{for(var s,u=this.singletonHandlers[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;!function(i){var a=i.predicates.slice(),o=r.modelManager.filterItemsWithPredicates(e,a),s=function(){i.createBlock&&(i.pendingCreateBlockCallback=!0,i.createBlock(function(e){i.singleton=e,i.pendingCreateBlockCallback=!1,i.resolutionCallback&&i.resolutionCallback(e)}))},u=r.modelManager.filterItemsWithPredicates(t,a).length;if(o.length>0||u>0){var c=r.modelManager.itemsMatchingPredicates(a);if(c.length>=2){var l=c.sort(function(e,t){return e.errorDecrypting?1:t.errorDecrypting?-1:e.created_at=this.MaxDiscordanceBeforeOutOfSync&&(this.outOfSync||(this.outOfSync=!0,this.notifyEvent("enter-out-of-sync"))),e.abrupt("return",!1);case 13:return this.outOfSync&&(this.outOfSync=!1,this.notifyEvent("exit-out-of-sync")),this.syncDiscordance=0,e.abrupt("return",!0);case 16:case"end":return e.stop()}},e,this)}));return e}()},{key:"isOutOfSync",value:function(){return this.outOfSync}},{key:"getServerURL",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.storageManager.getItem("server");case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0=window._default_sf_server;case 5:return e.abrupt("return",e.t0);case 6:case"end":return e.stop()}},e,this)}));return e}()},{key:"getSyncURL",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getServerURL();case 2:return e.t0=e.sent,e.abrupt("return",e.t0+"/items/sync");case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"registerSyncStatusObserver",value:function(e){var t={key:new Date,callback:e};return this.syncStatusObservers.push(t),t}},{key:"removeSyncStatusObserver",value:function(e){_.pull(this.syncStatusObservers,e)}},{key:"syncStatusDidChange",value:function(){var e=this;this.syncStatusObservers.forEach(function(t){t.callback(e.syncStatus)})}},{key:"addEventHandler",value:function(e){return this.eventHandlers.push(e),e}},{key:"removeEventHandler",value:function(e){_.pull(this.eventHandlers,e)}},{key:"notifyEvent",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.eventHandlers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){(0,a.value)(e,t||{})}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"setKeyRequestHandler",value:function(e){this.keyRequestHandler=e}},{key:"getActiveKeyInfo",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.keyRequestHandler(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"initialDataLoaded",value:function(){return this._initialDataLoaded}},{key:"loadLocalItems",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.storageManager.getAllModels().then(function(t){t=t.sort(function(e,t){var n=new Date(t.updated_at)-new Date(e.updated_at),i=r.contentTypeLoadPriority,a=0,o=0;return i&&(a=i.indexOf(e.content_type),o=i.indexOf(t.content_type),-1==a&&(a=i.length),-1==o&&(o=i.length)),a==o?n:a5&&(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:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var t=i(regeneratorRuntime.mark(function t(i,a){var o,s,u,c,l,f,p,h,d,y,v,g,m;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.syncLocked){t.next=4;break}return console.log("Sync Locked, Returning;"),i(),t.abrupt("return");case 4:if(r||(r={}),o=n.modelManager.getDirtyItems(),s=o.filter(function(e){return e.dirtyCount>0&&(e.dirtyCount=0,!0)}),!n.syncStatus.syncOpInProgress||r.force){t.next=14;break}return n.repeatOnCompletion=!0,n.queuedCallbacks.push(i),t.next=12,n.writeItemsToLocalStorage(s,!1);case 12:return console.log("Sync op in progress; returning."),t.abrupt("return");case 14:return t.next=16,n.getActiveKeyInfo(e.KeyRequestLoadSaveAccount);case 16:if(u=t.sent,!u.offline){t.next=20;break}return n.syncOffline(o).then(function(e){n.modelManager.clearDirtyItems(o),i(e)}).catch(function(e){n.notifyEvent("sync-exception",e)}),t.abrupt("return");case 20:return c=n.syncStatus.needsMoreSync,n.syncStatus.syncOpInProgress=!0,n.syncStatus.syncStart=new Date,n.beginCheckingIfSyncIsTakingTooLong(),l=n.PerSyncItemUploadLimit,f=o.slice(0,l),f.lengthn.syncStatus.total&&(n.syncStatus.total=n.syncStatus.current),n.syncStatusDidChange(),t.next=32,n.writeItemsToLocalStorage(s,!1);case 32:return r.onPreSyncSave&&r.onPreSyncSave(),n.allRetreivedItems||(n.allRetreivedItems=[]),n.allSavedItems||(n.allSavedItems=[]),p={},p.limit=150,r.performIntegrityCheck&&(p.compute_integrity=!0),t.prev=38,t.next=41,Promise.all(f.map(function(e){var t=new S(e,u.keys,u.auth_params);return t.additionalFields=r.additionalFields,t.paramsForSync()})).then(function(e){p.items=e});case 41:t.next=46;break;case 43:t.prev=43,t.t0=t.catch(38),n.notifyEvent("sync-exception",t.t0);case 46:for(h=!0,d=!1,y=void 0,t.prev=49,v=f[Symbol.iterator]();!(h=(g=v.next()).done);h=!0)m=g.value,m.dirtyCount=0;t.next=57;break;case 53:t.prev=53,t.t1=t.catch(49),d=!0,y=t.t1;case 57:t.prev=57,t.prev=58,!h&&v.return&&v.return();case 60:if(t.prev=60,!d){t.next=63;break}throw y;case 63:return t.finish(60);case 64:return t.finish(57);case 65:return t.next=67,n.getSyncToken();case 67:return p.sync_token=t.sent,t.next=70,n.getCursorToken();case 70:return p.cursor_token=t.sent,t.prev=71,t.t2=n.httpManager,t.next=75,n.getSyncURL();case 75:t.t3=t.sent,t.t4=p,t.t5=function(e){n.handleSyncSuccess(f,e,r).then(function(){i(e)}).catch(function(e){console.log("Caught sync success exception:",e),n.handleSyncError(null,null,o).then(function(e){i(e)})})},t.t6=function(e,t){n.handleSyncError(e,t,o).then(function(e){i(e)})},t.t2.postAbsolute.call(t.t2,t.t3,t.t4,t.t5,t.t6),t.next=85;break;case 82:t.prev=82,t.t7=t.catch(71),console.log("Sync exception caught:",t.t7);case 85:case"end":return t.stop()}},t,n,[[38,43],[49,53,57,65],[58,,60,64],[71,82]])}));return function(e,n){return t.apply(this,arguments)}}()));case 1:case"end":return t.stop()}},t,this)}));return t}()},{key:"handleSyncSuccess",value:function(){function t(e,t,r){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n,r,i){var a,o,s,u,c,l,f,p,h,d,y,g,m,b,k=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(a=[],o=!0,s=!1,u=void 0,t.prev=4,c=n[Symbol.iterator]();!(o=(l=c.next()).done);o=!0)f=l.value,0==f.dirtyCount&&a.push(f);t.next=12;break;case 8:t.prev=8,t.t0=t.catch(4),s=!0,u=t.t0;case 12:t.prev=12,t.prev=13,!o&&c.return&&c.return();case 15:if(t.prev=15,!s){t.next=18;break}throw u;case 18:return t.finish(15);case 19:return t.finish(12);case 20:return this.modelManager.clearDirtyItems(a),this.syncStatus.error=null,p=this.allSavedItems.map(function(e){return e.uuid}),r.retrieved_items=r.retrieved_items.filter(function(e){return!p.includes(e.uuid)}),t.next=26,this.handleItemsResponse(r.retrieved_items,null,v.MappingSourceRemoteRetrieved,e.KeyRequestLoadSaveAccount);case 26:return h=t.sent,this.allRetreivedItems=this.allRetreivedItems.concat(h),this.syncStatus.retrievedCount=this.allRetreivedItems.length,d=["content","auth_hash"],t.next=32,this.handleItemsResponse(r.saved_items,d,v.MappingSourceRemoteSaved,e.KeyRequestLoadSaveAccount);case 32:return y=t.sent,this.allSavedItems=this.allSavedItems.concat(y),g=r.unsaved,t.next=37,this.handleUnsavedItemsResponse(g);case 37:return t.next=39,this.writeItemsToLocalStorage(y,!1);case 39:return t.next=41,this.writeItemsToLocalStorage(h,!1);case 41:if(this.syncStatus.syncOpInProgress=!1,this.syncStatus.current+=n.length,this.syncStatusDidChange(),this.setSyncToken(r.sync_token),this.setCursorToken(r.cursor_token),this.stopCheckingIfSyncIsTakingTooLong(),!r.integrity_hash||r.cursor_token){t.next=52;break}return t.next=50,this.handleServerIntegrityHash(r.integrity_hash);case 50:m=t.sent,m||this.syncDiscordance=this.majorDataChangeThreshold||y.length>=this.majorDataChangeThreshold||g.length>=this.majorDataChangeThreshold)&&this.notifyEvent("major-data-change"),this.callQueuedCallbacks(r),this.notifyEvent("sync:completed",{retrievedItems:this.allRetreivedItems,savedItems:this.allSavedItems,unsavedItems:g}),this.allRetreivedItems=[],this.allSavedItems=[],t.abrupt("return",r);case 72:case"end":return t.stop()}},t,this,[[4,8,12,20],[13,,15,19]])}));return t}()},{key:"handleSyncError",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("Sync error: ",t),401==n&&this.notifyEvent("sync-session-invalid"),t?"string"==typeof t&&(t={error:{message:t}}):t={error:{message:"Could not connect to server."}},this.syncStatus.syncOpInProgress=!1,this.syncStatus.error=t.error,this.syncStatusDidChange(),this.writeItemsToLocalStorage(r,!1),this.modelManager.didSyncModelsOffline(r),this.stopCheckingIfSyncIsTakingTooLong(),this.notifyEvent("sync:error",t.error),this.callQueuedCallbacks({error:"Sync error"}),e.abrupt("return",t);case 12:case"end":return e.stop()}},e,this)}));return e}()},{key:"handleItemsResponse",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a,o,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getActiveKeyInfo(i);case 2:return a=e.sent.keys,e.next=5,SFJS.itemTransformer.decryptMultipleItems(t,a);case 5:return o=this.modelManager.mapResponseItemsToLocalModelsOmittingFields(t,n,r),s=o.filter(function(e){var t=e.errorDecryptingValueChanged;return e.errorDecryptingValueChanged=!1,t}),s.length>0&&this.writeItemsToLocalStorage(s,!1),e.abrupt("return",o);case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"refreshErroredItems",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this.modelManager.allNondummyItems.filter(function(e){return 1==e.errorDecrypting}),!(n.length>0)){t.next=3;break}return t.abrupt("return",this.handleItemsResponse(n,null,v.MappingSourceLocalRetrieved,e.KeyRequestLoadSaveAccount));case 3:case"end":return t.stop()}},t,this)}));return t}()},{key:"handleUnsavedItemsResponse",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(0!=n.length){t.next=2;break}return t.abrupt("return");case 2:console.log("Handle Conflicted Items:",n),r=!0,i=!1,a=void 0,t.prev=6,o=n[Symbol.iterator]();case 8:if(r=(s=o.next()).done){t.next=35;break}return u=s.value,c=u.item,t.t0=SFJS.itemTransformer,t.t1=[c],t.next=15,this.getActiveKeyInfo(e.KeyRequestLoadSaveAccount);case 15:return t.t2=t.sent.keys,t.next=18,t.t0.decryptMultipleItems.call(t.t0,t.t1,t.t2);case 18:if(l=this.modelManager.findItem(c.uuid)){t.next=21;break}return t.abrupt("continue",32);case 21:if(f=u.error,"uuid_conflict"!==f.tag){t.next=27;break}return t.next=25,this.modelManager.alternateUUIDForItem(l);case 25:t.next=32;break;case 27:if("sync_conflict"!==f.tag){t.next=32;break}return t.next=30,this.modelManager.createConflictedItem(c);case 30:p=t.sent,c.deleted||l.isItemContentEqualWith(p)||this.modelManager.addConflictedItem(p,l);case 32:r=!0,t.next=8;break;case 35:t.next=41;break;case 37:t.prev=37,t.t3=t.catch(6),i=!0,a=t.t3;case 41:t.prev=41,t.prev=42,!r&&o.return&&o.return();case 44:if(t.prev=44,!i){t.next=47;break}throw a;case 47:return t.finish(44);case 48:return t.finish(41);case 49:this.sync(null,{additionalFields:["created_at","updated_at"]});case 50:case"end":return t.stop()}},t,this,[[6,37,41,49],[42,,44,48]])}));return t}()},{key:"stateless_downloadAllItems",value:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(){var r=i(regeneratorRuntime.mark(function r(a,o){var s;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return s={limit:n.limit||500,sync_token:n.syncToken,cursor_token:n.cursorToken,content_type:n.contentType,event:n.event},r.prev=1,r.t0=t.httpManager,r.next=5,t.getSyncURL();case 5:r.t1=r.sent,r.t2=s,r.t3=function(){var r=i(regeneratorRuntime.mark(function r(i){var o,s;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return n.retrievedItems||(n.retrievedItems=[]),o=i.retrieved_items,r.next=4,t.getActiveKeyInfo(e.KeyRequestLoadSaveAccount);case 4:return s=r.sent.keys,r.next=7,SFJS.itemTransformer.decryptMultipleItems(o,s);case 7:n.retrievedItems=n.retrievedItems.concat(o.map(function(e){return t.modelManager.createItem(e,!0)})),n.syncToken=i.sync_token,n.cursorToken=i.cursor_token,n.cursorToken?t.stateless_downloadAllItems(n).then(a):a(n.retrievedItems);case 11:case"end":return r.stop()}},r,t)}));return function(e){return r.apply(this,arguments)}}(),r.t4=function(e,t){o(e)},r.t0.postAbsolute.call(r.t0,r.t1,r.t2,r.t3,r.t4),r.next=16;break;case 12:r.prev=12,r.t5=r.catch(1),console.log("Download all items exception caught:",r.t5),o(r.t5);case 16:case"end":return r.stop()}},r,t,[[1,12]])}));return function(e,t){return r.apply(this,arguments)}}())}},{key:"resolveOutOfSync",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stateless_downloadAllItems({event:"resolve-out-of-sync"}).then(function(){var e=i(regeneratorRuntime.mark(function e(n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:r=[],i=!0,a=!1,o=void 0,e.prev=4,s=n[Symbol.iterator]();case 6:if(i=(u=s.next()).done){e.next=20;break}if(c=u.value,!(l=t.modelManager.findItem(c.uuid))){e.next=16;break}if(!(f=!c.isItemContentEqualWith(l))){e.next=16;break}return e.next=14,t.modelManager.createConflictedItem(l,l);case 14:p=e.sent,t.modelManager.addConflictedItem(p,l);case 16:r.push(c);case 17:i=!0,e.next=6;break;case 20:e.next=26;break;case 22:e.prev=22,e.t0=e.catch(4),a=!0,o=e.t0;case 26:e.prev=26,e.prev=27,!i&&s.return&&s.return();case 29:if(e.prev=29,!a){e.next=32;break}throw o;case 32:return e.finish(29);case 33:return e.finish(26);case 34:return t.modelManager.mapResponseItemsToLocalModelsWithOptions({items:r,source:v.MappingSourceRemoteRetrieved}),e.next=37,t.writeItemsToLocalStorage(t.modelManager.allNondummyItems);case 37:return e.abrupt("return",t.sync({performIntegrityCheck:!0}));case 38:case"end":return e.stop()}},e,t,[[4,22,26,34],[27,,29,33]])}));return function(t){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"handleSignout",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this._syncToken=null,this._cursorToken=null,this._queuedCallbacks=[],this.syncStatus={};case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"clearSyncToken",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._syncToken=null,this._cursorToken=null,e.abrupt("return",this.storageManager.removeItem("syncToken"));case 3:case"end":return e.stop()}},e,this)}));return e}()},{key:"queuedCallbacks",get:function(){return this._queuedCallbacks||(this._queuedCallbacks=[]),this._queuedCallbacks}}]),e}(),x=r.SFItem=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.content={},this.referencingObjects=[],this.updateFromJSON(t),this.uuid||"undefined"!=typeof SFJS&&SFJS.crypto.generateUUIDSync&&(this.uuid=SFJS.crypto.generateUUIDSync()),"object"!==c(this.content)||this.content.references||(this.content.references=[])}return l(e,[{key:"initUUID",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.uuid){e.next=4;break}return e.next=3,SFJS.crypto.generateUUID();case 3:this.uuid=e.sent;case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"updateFromJSON",value:function(t){if(t){this.created_at=t.created_at,this.updated_at=t.updated_at,this.deleted=t.deleted,this.uuid=t.uuid,this.enc_item_key=t.enc_item_key,this.auth_hash=t.auth_hash,this.auth_params=t.auth_params;var n=["errorDecrypting","dirty","dirtyCount","dummy"],r=!0,i=!1,a=void 0;try{for(var o,s=n[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;void 0!==t[u]&&(this[u]=t[u])}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}if(this.content_type||(this.content_type=t.content_type),t.errorDecrypting)this.content=t.content;else try{var c="string"==typeof t.content?JSON.parse(t.content):t.content;e.deepMerge(this.contentObject,c)}catch(e){console.log("Error while updating item from json",e)}this.created_at?(this.created_at=new Date(this.created_at),this.updated_at=new Date(this.updated_at)):(this.created_at=new Date,this.updated_at=new Date),this._client_updated_at=null,t.content?this.mapContentToLocalProperties(this.contentObject):1==t.deleted&&this.handleDeletedContent()}}},{key:"mapContentToLocalProperties",value:function(e){}},{key:"createContentJSONFromProperties",value:function(){var t=this.structureParams();return e.deepMerge(this.contentObject,t),t}},{key:"structureParams",value:function(){return this.getContentCopy()}},{key:"handleDeletedContent",value:function(){}},{key:"setDirty",value:function(e,t){this.dirty=e,this.dirtyCount||(this.dirtyCount=0),e?this.dirtyCount++:this.dirtyCount=0,e&&!t?this.client_updated_at=new Date:this.hasRawClientUpdatedAtValue()||(this.client_updated_at=new Date(this.updated_at))}},{key:"updateLocalRelationships",value:function(){}},{key:"addItemAsRelationship",value:function(e){if(e.setIsBeingReferencedBy(this),!this.hasRelationshipWithItem(e)){var t=this.content.references||[];t.push({uuid:e.uuid,content_type:e.content_type}),this.content.references=t}}},{key:"removeItemAsRelationship",value:function(e){e.setIsNoLongerBeingReferencedBy(this),this.removeReferenceWithUuid(e.uuid)}},{key:"setIsBeingReferencedBy",value:function(e){_.find(this.referencingObjects,{uuid:e.uuid})||this.referencingObjects.push(e)}},{key:"setIsNoLongerBeingReferencedBy",value:function(e){_.remove(this.referencingObjects,{uuid:e.uuid}),this.hasRelationshipWithItem(e)&&(this.removeReferenceWithUuid(e.uuid),this.setDirty(!0))}},{key:"removeReferenceWithUuid",value:function(e){var t=this.content.references||[];t=t.filter(function(t){return t.uuid!=e}),this.content.references=t}},{key:"hasRelationshipWithItem",value:function(e){return null!=this.content.references.find(function(t){return t.uuid==e.uuid})}},{key:"isBeingRemovedLocally",value:function(){}},{key:"didFinishSyncing",value:function(){}},{key:"informReferencesOfUUIDChange",value:function(e,t){}},{key:"potentialItemOfInterestHasChangedItsUUID",value:function(e,t,n){var r=!0,i=!1,a=void 0;try{for(var o,s=this.content.references[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;u.uuid==t&&(u.uuid=n,this.setDirty(!0))}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}}},{key:"doNotEncrypt",value:function(){return!1}},{key:"setDomainDataItem",value:function(e,t,n){if(!n)return void console.error("SFItem.AppDomain needs to be set.");if(!this.errorDecrypting){this.content.appData||(this.content.appData={});var r=this.content.appData[n];r||(r={}),r[e]=t,this.content.appData[n]=r}}},{key:"getDomainDataItem",value:function(e,t){if(!t)return void console.error("SFItem.AppDomain needs to be set.");if(!this.errorDecrypting){this.content.appData||(this.content.appData={});var n=this.content.appData[t];return n?n[e]:null}}},{key:"setAppDataItem",value:function(t,n){this.setDomainDataItem(t,n,e.AppDomain)}},{key:"getAppDataItem",value:function(t){return this.getDomainDataItem(t,e.AppDomain)}},{key:"hasRawClientUpdatedAtValue",value:function(){return null!=this.getAppDataItem("client_updated_at")}},{key:"keysToIgnoreWhenCheckingContentEquality",value:function(){return[]}},{key:"appDataKeysToIgnoreWhenCheckingContentEquality",value:function(){return["client_updated_at"]}},{key:"getContentCopy",value:function(){return JSON.parse(JSON.stringify(this.content))}},{key:"isItemContentEqualWith",value:function(t){var n=function(e,t){if(!e)return e;var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){delete e[a.value]}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return e},r=this.getContentCopy();r.appData&&n(r.appData[e.AppDomain],this.appDataKeysToIgnoreWhenCheckingContentEquality()),r=n(r,this.keysToIgnoreWhenCheckingContentEquality());var i=t.getContentCopy();return i.appData&&n(i.appData[e.AppDomain],t.appDataKeysToIgnoreWhenCheckingContentEquality()),i=n(i,t.keysToIgnoreWhenCheckingContentEquality()),JSON.stringify(r)===JSON.stringify(i)}},{key:"satisfiesPredicate",value:function(e){return C.ItemSatisfiesPredicate(this,e)}},{key:"createdAtString",value:function(){return this.dateToLocalizedString(this.created_at)}},{key:"updatedAtString",value:function(){return this.dateToLocalizedString(this.client_updated_at)}},{key:"updatedAtTimestamp",value:function(){return this.updated_at.getTime()}},{key:"dateToLocalizedString",value:function(e){if("undefined"!=typeof Intl&&Intl.DateTimeFormat){if(!s){var t=navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language;s=new Intl.DateTimeFormat(t,{year:"numeric",month:"short",day:"2-digit",weekday:"long",hour:"2-digit",minute:"2-digit"})}return s.format(e)}return e.toDateString()+" "+e.toLocaleTimeString()}},{key:"contentObject",get:function(){if(this.errorDecrypting)return this.content;if(!this.content)return this.content={},this.content;if(null!==this.content&&"object"===c(this.content))return this.content;try{var e=JSON.parse(this.content);return this.content=e,this.content}catch(e){return console.log("Error parsing json",e,this),this.content={},this.content}}},{key:"pinned",get:function(){return this.getAppDataItem("pinned")}},{key:"archived",get:function(){return this.getAppDataItem("archived")}},{key:"locked",get:function(){return this.getAppDataItem("locked")}},{key:"displayName",get:function(){return"Item"}},{key:"client_updated_at",get:function(){if(!this._client_updated_at){var e=this.getAppDataItem("client_updated_at");this._client_updated_at=e?new Date(e):new Date(this.updated_at)}return this._client_updated_at},set:function(e){this._client_updated_at=e,this.setAppDataItem("client_updated_at",e)}}],[{key:"deepMerge",value:function(e,t){function n(e,t){if(_.isArray(e))return t}return _.mergeWith(e,t,n),e}}]),e}(),S=r.SFItemParams=function(){function e(t,n,r){if(a(this,e),this.item=t,this.keys=n,this.auth_params=r,this.keys&&!this.auth_params)throw"SFItemParams.auth_params must be supplied if supplying keys.";if(this.auth_params&&!this.auth_params.version)throw"SFItemParams.auth_params is missing version"}return l(e,[{key:"paramsForExportFile",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.additionalFields=["updated_at"],this.forExportFile=!0,!t){e.next=6;break}return e.abrupt("return",this.__params());case 6:return e.next=8,this.__params();case 8:return n=e.sent,e.abrupt("return",_.omit(n,["deleted"]));case 10:case"end":return e.stop()}},e,this)}));return e}()},{key:"paramsForExtension",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.paramsForExportFile());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"paramsForLocalStorage",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.additionalFields=["updated_at","dirty","errorDecrypting"],this.forExportFile=!0,e.abrupt("return",this.__params());case 3:case"end":return e.stop()}},e,this)}));return e}()},{key:"paramsForSync",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.__params());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"__params",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t={uuid:this.item.uuid,content_type:this.item.content_type,deleted:this.item.deleted,created_at:this.item.created_at},this.item.errorDecrypting){e.next=23;break}if(n=this.item.doNotEncrypt()&&!this.forExportFile,!this.keys||n){e.next=11;break}return e.next=6,SFJS.itemTransformer.encryptItem(this.item,this.keys,this.auth_params);case 6:r=e.sent,_.merge(t,r),"001"!==this.auth_params.version&&(t.auth_hash=null),e.next=21;break;case 11:if(!this.forExportFile){e.next=15;break}e.t0=this.item.createContentJSONFromProperties(),e.next=19;break;case 15:return e.next=17,SFJS.crypto.base64(JSON.stringify(this.item.createContentJSONFromProperties()));case 17:e.t1=e.sent,e.t0="000"+e.t1;case 19:t.content=e.t0,this.forExportFile||(t.enc_item_key=null,t.auth_hash=null);case 21:e.next=26;break;case 23:t.content=this.item.content,t.enc_item_key=this.item.enc_item_key,t.auth_hash=this.item.auth_hash;case 26:return this.additionalFields&&_.merge(t,_.pick(this.item,this.additionalFields)),e.abrupt("return",t);case 28:case"end":return e.stop()}},e,this)}));return e}()}]),e}(),C=r.SFPredicate=function(){function e(t,n,r){a(this,e),this.keypath=t,this.operator=n,this.value=r,e.IsRecursiveOperator(this.operator)&&(this.value=this.value.map(e.fromArray))}return l(e,null,[{key:"fromArray",value:function(t){return new e(t[0],t[1],t[2])}},{key:"ObjectSatisfiesPredicate",value:function(t,n){if(Array.isArray(n)&&(n=this.fromArray(n)),e.IsRecursiveOperator(n.operator)){if("and"===n.operator){var r=!0,i=!1,a=void 0;try{for(var o,s=n.value[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;if(!this.ObjectSatisfiesPredicate(t,u))return!1}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return!0}if("or"===n.operator){var c=!0,l=!1,f=void 0;try{for(var p,h=n.value[Symbol.iterator]();!(c=(p=h.next()).done);c=!0){var u=p.value;if(this.ObjectSatisfiesPredicate(t,u))return!0}}catch(e){l=!0,f=e}finally{try{!c&&h.return&&h.return()}finally{if(l)throw f}}return!1}}var d=n.value;"string"==typeof d&&d.includes(".ago")&&(d=this.DateFromString(d));var y=n.keypath.split(".").reduce(function(e,t){return e&&e[t]},t),v=[!1,"",null,void 0,NaN];if(void 0==y)return"!="==n.operator?!v.includes(n.value):v.includes(n.value);if("="==n.operator)return Array.isArray(y)?JSON.stringify(y)==JSON.stringify(d):y==d;if("!="==n.operator)return Array.isArray(y)?JSON.stringify(y)!=JSON.stringify(d):y!==d;if("<"==n.operator)return y"==n.operator)return y>d;if("<="==n.operator)return y<=d;if(">="==n.operator)return y>=d;if("startsWith"==n.operator)return y.startsWith(d);if("in"==n.operator)return-1!=d.indexOf(y);if("includes"==n.operator)return this.resolveIncludesPredicate(y,d);if("matches"==n.operator){return new RegExp(d).test(y)}return!1}},{key:"resolveIncludesPredicate",value:function(t,n){if("string"==typeof n)return t.includes(n);var r;r=Array.isArray(n)?e.fromArray(n):n;var i=!0,a=!1,o=void 0;try{for(var s,u=t[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;if(this.ObjectSatisfiesPredicate(c,r))return!0}}catch(e){a=!0,o=e}finally{try{!i&&u.return&&u.return()}finally{if(a)throw o}}return!1}},{key:"ItemSatisfiesPredicate",value:function(t,n){return Array.isArray(n)&&(n=e.fromArray(n)),this.ObjectSatisfiesPredicate(t,n)}},{key:"ItemSatisfiesPredicates",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(!this.ItemSatisfiesPredicate(e,s))return!1}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return!0}},{key:"DateFromString",value:function(e){var t=e.split("."),n=t[1],r=new Date,i=parseInt(t[0]);return"days"==n?r.setDate(r.getDate()-i):"hours"==n&&r.setHours(r.getHours()-i),r}},{key:"IsRecursiveOperator",value:function(e){return["and","or"].includes(e)}}]),e}(),I=r.SFPrivileges=function(e){function r(e){a(this,r);var n=t(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return n.content.desktopPrivileges||(n.content.desktopPrivileges={}),n}return n(r,e),l(r,null,[{key:"contentType",value:function(){return"SN|Privileges"}}]),l(r,[{key:"setCredentialsForAction",value:function(e,t){this.content.desktopPrivileges[e]=t}},{key:"getCredentialsForAction",value:function(e){return this.content.desktopPrivileges[e]||[]}},{key:"toggleCredentialForAction",value:function(e,t){this.isCredentialRequiredForAction(e,t)?this.removeCredentialForAction(e,t):this.addCredentialForAction(e,t)}},{key:"removeCredentialForAction",value:function(e,t){_.pull(this.content.desktopPrivileges[e],t)}},{key:"addCredentialForAction",value:function(e,t){var n=this.getCredentialsForAction(e);n.push(t),this.setCredentialsForAction(e,n)}},{key:"isCredentialRequiredForAction",value:function(e,t){return this.getCredentialsForAction(e).includes(t)}}]),r}(x),R=r.SFHistorySession=function(e){function r(e){a(this,r);var n=t(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return n.content.itemUUIDToItemHistoryMapping||(n.content.itemUUIDToItemHistoryMapping={}),Object.keys(n.content.itemUUIDToItemHistoryMapping).forEach(function(e){var t=n.content.itemUUIDToItemHistoryMapping[e];n.content.itemUUIDToItemHistoryMapping[e]=new E(t)}),n}return n(r,e),l(r,[{key:"addEntryForItem",value:function(e){return this.historyForItem(e).addHistoryEntryForItem(e)}},{key:"historyForItem",value:function(e){var t=this.content.itemUUIDToItemHistoryMapping[e.uuid];return t||(t=this.content.itemUUIDToItemHistoryMapping[e.uuid]=new E),t}},{key:"clearItemHistory",value:function(e){this.historyForItem(e).clear()}},{key:"clearAllHistory",value:function(){this.content.itemUUIDToItemHistoryMapping={}}},{key:"optimizeHistoryForItem",value:function(e){var t=this.historyForItem(e);t.entries.length>r.LargeItemEntryAmountThreshold&&t.optimize()}}]),r}(x);R.LargeItemEntryAmountThreshold=60;var E=r.SFItemHistory=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a(this,e),this.entries||(this.entries=[]),t.entries){var n=!0,r=!1,i=void 0;try{for(var o,s=t.entries[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value,c=this.createEntryForItem(u.item);c.setPreviousEntry(this.getLastEntry()),this.entries.push(c)}}catch(e){r=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(r)throw i}}}}return l(e,[{key:"createEntryForItem",value:function(t){var n=e.HistoryEntryClassMapping&&e.HistoryEntryClassMapping[t.content_type];return n||(n=F),new n(t)}},{key:"getLastEntry",value:function(){return this.entries[this.entries.length-1]}},{key:"addHistoryEntryForItem",value:function(e){var t=this.createEntryForItem(e),n=this.getLastEntry();if(t.setPreviousEntry(n),!t.isSameAsEntry(n))return this.entries.push(t),t}},{key:"clear",value:function(){this.entries.length=0}},{key:"optimize",value:function(){var t=this,n=[],r=function(t){return t.deltaSize()>e.LargeEntryDeltaThreshold},i=function(e,i,a){if(a)n.push(e);else{var i=n.indexOf(e);-1!==i&&n.splice(i,1)}if(a&&r(e)&&-1==e.operationVector()){var o=t.entries[i-1];o&&n.push(o)}};this.entries.forEach(function(e,n){if(0==n||n==t.entries.length-1)i(e,n,!0);else{var a=r(e);i(e,n,a)}}),this.entries=this.entries.filter(function(e,t){return-1!==n.indexOf(e)})}}]),e}();E.LargeEntryDeltaThreshold=15;var F=r.SFItemHistoryEntry=function(){function e(t){a(this,e),this.item=x.deepMerge({},t),this.defaultContentKeyToDiffOn="text",this.textCharDiffLength=0,"string"==typeof this.item.updated_at&&(this.item.updated_at=new Date(this.item.updated_at))}return l(e,[{key:"setPreviousEntry",value:function(e){this.hasPreviousEntry=null!=e,this.item.content[this.defaultContentKeyToDiffOn]&&(this.textCharDiffLength=e?this.item.content[this.defaultContentKeyToDiffOn].length-e.item.content[this.defaultContentKeyToDiffOn].length:this.item.content[this.defaultContentKeyToDiffOn].length)}},{key:"operationVector",value:function(){return void 0!=this.textCharDiffLength?this.hasPreviousEntry&&0!=this.textCharDiffLength?this.textCharDiffLength<0?-1:1:0:1}},{key:"deltaSize",value:function(){return void 0!=this.textCharDiffLength?Math.abs(this.textCharDiffLength):1}},{key:"isSameAsEntry",value:function(e){if(!e)return!1;var t=new x(this.item),n=new x(e.item);return t.isItemContentEqualWith(n)}}]),e}(),h="undefined"!=typeof window?window:void 0!==e?e:null,P=r.SFAbstractCrypto=function(){function e(){a(this,e),this.DefaultPBKDF2Length=768}return l(e,[{key:"generateUUIDSync",value:function(){var e=h.crypto||h.msCrypto;if(e){var t=new Uint32Array(4);e.getRandomValues(t);var n=-1;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){n++;var r=t[n>>3]>>n%8*4&15;return("x"==e?r:3&r|8).toString(16)})}var r=(new Date).getTime();return h.performance&&"function"==typeof h.performance.now&&(r+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)})}},{key:"generateUUID",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.generateUUIDSync());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"decryptText",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=a.ciphertextToAuth,u=a.contentCiphertext,c=a.encryptionKey,l=a.iv,f=a.authHash,p=a.authKey,h=arguments[1];return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!h||f){e.next=3;break}return console.error("Auth hash is required."),e.abrupt("return");case 3:if(!f){e.next=10;break}return e.next=6,this.hmac256(s,p);case 6:if(t=e.sent,f===t){e.next=10;break}return console.error("Auth hash does not match, returning null."),e.abrupt("return",null);case 10:return n=o.enc.Hex.parse(c),r=o.enc.Hex.parse(l||""),i=o.AES.decrypt(u,n,{iv:r,mode:o.mode.CBC,padding:o.pad.Pkcs7}),e.abrupt("return",i.toString(o.enc.Utf8));case 14:case"end":return e.stop()}},e,this)}));return e}()},{key:"encryptText",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){var i,a,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=o.enc.Hex.parse(n),a=o.enc.Hex.parse(r||""),s=o.AES.encrypt(t,i,{iv:a,mode:o.mode.CBC,padding:o.pad.Pkcs7}),e.abrupt("return",s.toString());case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateRandomKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",o.lib.WordArray.random(t/8).toString());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateItemEncryptionKey",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=512,n=1,e.next=4,this.generateRandomKey(t);case 4:return r=e.sent,e.next=7,this.generateRandomKey(t);case 7:return i=e.sent,e.abrupt("return",this.pbkdf2(i,r,n,t));case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"firstHalfOfKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.substring(0,t.length/2));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"secondHalfOfKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.substring(t.length/2,t.length));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"base64",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",h.btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)})));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"base64Decode",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",h.atob(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"sha256",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",o.SHA256(t).toString());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"hmac256",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.enc.Hex.parse(n),i=o.enc.Utf8.parse(t),a=o.HmacSHA256(i,r).toString(),e.abrupt("return",a);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateSalt",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sha256([t,"SF",n,r,i].join(":"));case 2:return a=e.sent,e.abrupt("return",a);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateSymmetricKeyPair",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a,o,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},u=s.password,c=s.pw_salt,l=s.pw_cost;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.pbkdf2(u,c,l,this.DefaultPBKDF2Length);case 2:return t=e.sent,n=t.length,r=n/3,i=t.slice(0,r),a=t.slice(r,2*r),o=t.slice(2*r,3*r),e.abrupt("return",[i,a,o]);case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"computeEncryptionKeysForUser",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("003"!=n.version){e.next=9;break}if(n.identifier){e.next=4;break}return console.error("authParams is missing identifier."),e.abrupt("return");case 4:return e.next=6,this.generateSalt(n.identifier,n.version,n.pw_cost,n.pw_nonce);case 6:r=e.sent,e.next=10;break;case 9:r=n.pw_salt;case 10:return e.abrupt("return",this.generateSymmetricKeyPair({password:t,pw_salt:r,pw_cost:n.pw_cost}).then(function(e){return{pw:e[0],mk:e[1],ak:e[2]}}));case 11:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateInitialKeysAndAuthParamsForUser",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r,i,a,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.SFJS.version,i=this.SFJS.defaultPasswordGenerationCost,e.next=4,this.generateRandomKey(256);case 4:return a=e.sent,e.next=7,this.generateSalt(t,r,i,a);case 7:return o=e.sent,e.abrupt("return",this.generateSymmetricKeyPair({password:n,pw_salt:o,pw_cost:i}).then(function(e){var n={pw_nonce:a,pw_cost:i,identifier:t,version:r};return{keys:{pw:e[0],mk:e[1],ak:e[2]},authParams:n}}));case 9:case"end":return e.stop()}},e,this)}));return e}()}]),e}(),D=r.SFCryptoJS=function(e){function r(){return a(this,r),t(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return n(r,e),l(r,[{key:"pbkdf2",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return a={keySize:i/32,hasher:o.algo.SHA512,iterations:r},e.abrupt("return",o.PBKDF2(t,n,a).toString());case 2:case"end":return e.stop()}},e,this)}));return e}()}]),r}(P),h="undefined"!=typeof window?window:void 0!==e?e:null,O=h.crypto?h.crypto.subtle:null,M=r.SFCryptoWeb=function(e){function r(){return a(this,r),t(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return n(r,e),l(r,[{key:"pbkdf2",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.webCryptoImportKey(t,"PBKDF2",["deriveBits"]);case 2:if(a=e.sent){e.next=6;break}return console.log("Key is null, unable to continue"),e.abrupt("return",null);case 6:return e.abrupt("return",this.webCryptoDeriveBits(a,n,r,i));case 7:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateRandomKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=!0,e.abrupt("return",O.generateKey({name:"AES-CBC",length:t},n,["encrypt","decrypt"]).then(function(e){return O.exportKey("raw",e).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.arrayBufferToHexString(new Uint8Array(t));case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,r)}));return function(t){return e.apply(this,arguments)}}()).catch(function(e){console.error("Error exporting key",e)})}).catch(function(e){console.error("Error generating key",e)}));case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateItemEncryptionKey",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=256,e.abrupt("return",Promise.all([this.generateRandomKey(t),this.generateRandomKey(t)]).then(function(e){return e.join("")}));case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"encryptText",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){var a,o,s,u,c,l=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!r){e.next=6;break}return e.next=3,this.hexStringToArrayBuffer(r);case 3:e.t0=e.sent,e.next=7;break;case 6:e.t0=new ArrayBuffer(16);case 7:return a=e.t0,o={name:"AES-CBC",iv:a},e.next=11,this.hexStringToArrayBuffer(n);case 11:return s=e.sent,e.next=14,this.webCryptoImportKey(s,o.name,["encrypt"]);case 14:return u=e.sent,e.next=17,this.stringToArrayBuffer(t);case 17:return c=e.sent,e.abrupt("return",crypto.subtle.encrypt(o,u,c).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l.arrayBufferToBase64(t);case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,l)}));return function(t){return e.apply(this,arguments)}}()));case 19:case"end":return e.stop()}},e,this)}));return e}()},{key:"decryptText",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,a,o,s,u=this,c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=c.ciphertextToAuth,f=c.contentCiphertext,p=c.encryptionKey,h=c.iv,d=c.authHash,y=c.authKey,v=arguments[1];return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!v||d){e.next=3;break}return console.error("Auth hash is required."),e.abrupt("return");case 3:if(!d){e.next=10;break}return e.next=6,this.hmac256(l,y);case 6:if(t=e.sent,d===t){e.next=10;break}return console.error("Auth hash does not match, returning null. "+d+" != "+t),e.abrupt("return",null);case 10:if(!h){e.next=16;break}return e.next=13,this.hexStringToArrayBuffer(h);case 13:e.t0=e.sent,e.next=17;break;case 16:e.t0=new ArrayBuffer(16);case 17:return n=e.t0,r={name:"AES-CBC",iv:n},e.next=21,this.hexStringToArrayBuffer(p);case 21:return a=e.sent,e.next=24,this.webCryptoImportKey(a,r.name,["decrypt"]);case 24:return o=e.sent,e.next=27,this.base64ToArrayBuffer(f);case 27:return s=e.sent,e.abrupt("return",crypto.subtle.decrypt(r,o,s).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.arrayBufferToString(t);case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,u)}));return function(t){return e.apply(this,arguments)}}()).catch(function(e){console.error("Error decrypting:",e)}));case 29:case"end":return e.stop()}},e,this)}));return e}()},{key:"webCryptoImportKey",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=6;break}return e.next=3,this.stringToArrayBuffer(t);case 3:e.t0=e.sent,e.next=7;break;case 6:e.t0=t;case 7:return a=e.t0,e.abrupt("return",O.importKey("raw",a,{name:n,hash:i},!1,r).then(function(e){return e}).catch(function(e){return console.error(e),null}));case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"webCryptoDeriveBits",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,a){var o,s=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.stringToArrayBuffer(n);case 2:return e.t0=e.sent,e.t1=r,e.t2={name:"SHA-512"},o={name:"PBKDF2",salt:e.t0,iterations:e.t1,hash:e.t2},e.abrupt("return",O.deriveBits(o,t,a).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.arrayBufferToHexString(new Uint8Array(t));case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,s)}));return function(t){return e.apply(this,arguments)}}()).catch(function(e){return console.error(e),null}));case 7:case"end":return e.stop()}},e,this)}));return e}()},{key:"stringToArrayBuffer",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){var r=new Blob([t]),i=new FileReader;i.onload=function(t){e(t.target.result)},i.readAsArrayBuffer(r)}));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"arrayBufferToString",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){var r=new Blob([t]),i=new FileReader;i.onload=function(t){e(t.target.result)},i.readAsText(r)}));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"arrayBufferToHexString",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:for(n=new Uint8Array(t),r="",a=0;a5e3)||this.crypto instanceof M}},{key:"supportedVersions",value:function(){return["001","002","003"]}},{key:"isVersionNewerThanLibraryVersion",value:function(e){var t=this.version();return parseInt(e)>parseInt(t)}},{key:"isProtocolVersionOutdated",value:function(e){var t={"001":Date.parse("2018-01-01"),"002":Date.parse("2020-01-01")},n=t[e];return!!n&&new Date>n}},{key:"costMinimumForVersion",value:function(e){return{"001":3e3,"002":3e3,"003":11e4}[e]}},{key:"defaultPasswordGenerationCost",value:function(){return this.costMinimumForVersion(this.version())}}]),e}();if(h)try{h.StandardFile=T,h.SFJS=new T,h.SFCryptoWeb=M,h.SFCryptoJS=D,h.SFItemTransformer=A,h.SFModelManager=v,h.SFItem=x,h.SFItemParams=S,h.SFHttpManager=d,h.SFStorageManager=k,h.SFSyncManager=w,h.SFAuthManager=p,h.SFMigrationManager=y,h.SFAlertManager=f,h.SFPredicate=C,h.SFHistorySession=R,h.SFSessionHistoryManager=m,h.SFItemHistory=E,h.SFItemHistoryEntry=F,h.SFPrivilegesManager=g,h.SFPrivileges=I,h.SFSingletonManager=b}catch(e){console.log("Exception while exporting window variables",e)}}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(t,n(3))},function(e,t){!function(t){"use strict";function n(e,t,n,r){var a=t&&t.prototype instanceof i?t:i,o=Object.create(a.prototype),s=new h(r||[]);return o._invoke=c(e,n,s),o}function r(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function i(){}function a(){}function o(){}function s(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function u(e){function t(n,i,a,o){var s=r(e[n],e,i);if("throw"!==s.type){var u=s.arg,c=u.value;return c&&"object"==typeof c&&m.call(c,"__await")?Promise.resolve(c.__await).then(function(e){t("next",e,a,o)},function(e){t("throw",e,a,o)}):Promise.resolve(c).then(function(e){u.value=e,a(u)},o)}o(s.arg)}function n(e,n){function r(){return new Promise(function(r,i){t(e,n,r,i)})}return i=i?i.then(r,r):r()}var i;this._invoke=n}function c(e,t,n){var i=C;return function(a,o){if(i===R)throw new Error("Generator is already running");if(i===E){if("throw"===a)throw o;return y()}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var u=l(s,n);if(u){if(u===F)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===C)throw i=E,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=R;var c=r(e,t,n);if("normal"===c.type){if(i=n.done?E:I,c.arg===F)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=E,n.method="throw",n.arg=c.arg)}}}function l(e,t){var n=e.iterator[t.method];if(n===v){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=v,l(e,t),"throw"===t.method))return F;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return F}var i=r(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,F;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=v),t.delegate=null,F):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,F)}function f(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function p(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function h(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(f,this),this.reset(!0)}function d(e){if(e){var t=e[k];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n=0;--r){var i=this.tryEntries[r],a=i.completion;if("root"===i.tryLoc)return t("end");if(i.tryLoc<=this.prev){var o=m.call(i,"catchLoc"),s=m.call(i,"finallyLoc");if(o&&s){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&m.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),p(n),F}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;p(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:d(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=v),F}}}(function(){return this}()||Function("return this")())},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n=0?this.items[c]=u:this.items.push(u);case 15:r=!0,t.next=5;break;case 18:t.next=24;break;case 20:t.prev=20,t.t0=t.catch(3),i=!0,a=t.t0;case 24:t.prev=24,t.prev=25,r||null==o.return||o.return();case 27:if(t.prev=27,!i){t.next=30;break}throw a;case 30:return t.finish(27);case 31:return t.finish(24);case 32:this.notifyObserversOfEvent(e.BridgeEventReceivedItems);case 33:case"end":return t.stop()}},t,this,[[3,20,24,32],[25,,27,31]])}));return t}()},{key:"indexOfItem",value:function(e){for(var t in this.items)if(this.items[t].uuid==e.uuid)return t;return-1}},{key:"removeItemFromItems",value:function(e){this.items=this.items.filter(function(t){return t.uuid!==e.uuid})}},{key:"createItem",value:function(e,t){this.createItems([e],t)}},{key:"createItems",value:function(e,t){this.componentManager.createItems(e,function(e){t&&t(e.map(function(e){return new f.SFItem(e)}))})}},{key:"saveItem",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.saveItems([t]));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"saveItems",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t,i){r.componentManager.saveItems(n,function(n){t(n),r.notifyObserversOfEvent(e.BridgeEventSavedItem)})}));case 1:case"end":return t.stop()}},t)}));return t}()},{key:"indexOfItem",value:function(e){for(var t in this.items)if(this.items[t].uuid==e.uuid)return t;return-1}},{key:"deleteItem",value:function(e,t){this.deleteItems([e],t)}},{key:"deleteItems",value:function(e,t){this.componentManager.deleteItems(e,t)}},{key:"removeItemFromItems",value:function(e){this.items=this.items.filter(function(t){return t.uuid!==e.uuid})}}]),e}());u(p,"FileItemContentTypeKey","SN|FileSafe|File"),u(p,"FileSafeCredentialsContentType","SN|FileSafe|Credentials"),u(p,"FileDescriptorContentTypeKey","SN|FileSafe|FileMetadata"),u(p,"FileSafeIntegrationContentTypeKey","SN|FileSafe|Integration"),u(p,"BridgeEventLoadedCredentials","BridgeEventLoadedCredentials"),u(p,"BridgeEventReceivedItems","BridgeEventReceivedItems"),u(p,"BridgeEventSavedItem","BridgeEventSavedItem")},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;nt.length)n=e;else{n=t;var r=0,i=-1,a=-1,o=n.length;for(0>r&&(r=-r>o?0:o+r),i=i>o?o:i,0>i&&(i+=o),o=r>i?0:i-r>>>0,r>>>=0,i=Array(o);++aa?pt:o,a=1),t=Object(t);++is))return!1;if((u=a.get(e))&&a.get(t))return u==t;var u=-1,c=!0,l=2&n?new E:pt;for(a.set(e,t),a.set(t,e);++un&&(n=ln(r+n,0)),y(e,be(t,3),n)):-1}function Te(e){return(null==e?0:e.length)?L(e,1):[]}function Ne(e){var t=null==e?0:e.length;return t?e[t-1]:pt}function je(e,t){var n;if(e&&e.length&&t&&t.length){n=t;var r=v,i=-1,a=n.length;for(e===n&&(n=ue(n));++i=e}function We(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Ve(e){return null!=e&&"object"==typeof e}function Je(e){return!(!Ve(e)||"[object Object]"!=z(e))&&(null===(e=Xt(e))||"function"==typeof(e=Kt.call(e,"constructor")&&e.constructor)&&e instanceof e&&zt.call(e)==Jt)}function qe(e){return"string"==typeof e||!Hn(e)&&Ve(e)&&"[object String]"==z(e)}function $e(e){return"symbol"==typeof e||Ve(e)&&"[object Symbol]"==z(e)}function Ge(e){return e?(e=Ye(e),e===ht||e===-ht?1.7976931348623157e308*(0>e?-1:1):e===e?e:0):0===e?e:0}function Qe(e){e=Ge(e);var t=e%1;return e===e?t?e-t:e:0}function Ye(e){if("number"==typeof e)return e;if($e(e))return dt;if(We(e)&&(e="function"==typeof e.valueOf?e.valueOf():e,e=We(e)?e+"":e),"string"!=typeof e)return 0===e?e:+e;e=e.replace(bt,"");var t=St.test(e);return t||Ct.test(e)?Pt(e.slice(2),t?2:8):xt.test(e)?dt:+e}function Xe(e){return ce(e,rt(e))}function Ze(e){return null==e?"":ne(e)}function et(e,t,n){return e=null==e?pt:H(e,t),e===pt?n:e}function tt(e,t){var n;if(n=null!=e){n=e;var r;r=ie(t,n);for(var i=-1,a=r.length,o=!1;++i(e=M(t,e))||(e==t.length-1?t.pop():tn.call(t,e,1),--this.size,0))},I.prototype.get=function(e){var t=this.__data__;return e=M(t,e),0>e?pt:t[e][1]},I.prototype.has=function(e){return-1r?(++this.size,n.push([e,t])):n[r][1]=t,this},R.prototype.clear=function(){this.size=0,this.__data__={hash:new C,map:new(dn||I),string:new C}},R.prototype.delete=function(e){return e=ke(this,e).delete(e),this.size-=e?1:0,e},R.prototype.get=function(e){return ke(this,e).get(e)},R.prototype.has=function(e){return ke(this,e).has(e)},R.prototype.set=function(e,t){var n=ke(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},E.prototype.add=E.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},E.prototype.has=function(e){return this.__data__.has(e)},F.prototype.clear=function(){this.__data__=new I,this.size=0},F.prototype.delete=function(e){var t=this.__data__;return e=t.delete(e),this.size=t.size,e},F.prototype.get=function(e){return this.__data__.get(e)},F.prototype.has=function(e){return this.__data__.has(e)},F.prototype.set=function(e,t){var n=this.__data__;if(n instanceof I){var r=n.__data__;if(!dn||199>r.length)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new R(r)}return n.set(e,t),this.size=n.size,this};var En=function(e,t){return function(t,n){if(null==t)return t;if(!He(t))return e(t,n);for(var r=t.length,i=-1,a=Object(t);++in&&(n=ln(r+n,0)),qe(e)?n<=r&&-10){var i=!0,a=!1,o=void 0;try{for(var s,u=t.integrations[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;if(c!=e){t.setIntegrationAsDefault(c);break}}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}}})}},{key:"integrations",get:function(){return this.extensionBridge.filterItems(l.a.FileSafeIntegrationContentTypeKey)}}]),e}()},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n0&&(e=n.credentials[0]),e}),u(this,"setCredentialAsDefault",function(e){var t=n.getDefaultCredentials();t&&(t.content.isDefault=!1),e.content.isDefault=!0,n.extensionBridge.saveItems([t,e])}),u(this,"deleteCredential",function(e){n.extensionBridge.deleteItem(e)}),this.extensionBridge=r,this.onCredentialLoad=i,this.credentials=[],this.extensionBridge.addEventHandler(function(e){e==f.a.BridgeEventReceivedItems&&n.reloadCredentials()})}return s(e,[{key:"reloadCredentials",value:function(){this.credentials=[];var e=this.extensionBridge.filterItems(f.a.FileSafeCredentialsContentType);if(0!=e.length){var t=!0,n=!1,r=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;this.credentials.find(function(e){return e.uuid==o.uuid})||this.credentials.push(o)}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}this.onCredentialLoad(),this.credentials.length>0&&this.didLoadCredentials()}}},{key:"createNewCredentials",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=256,e.next=3,SFJS.crypto.generateRandomKey(t);case 3:return n=e.sent,e.next=6,SFJS.crypto.generateRandomKey(t);case 6:return r=e.sent,e.next=9,SFJS.crypto.generateInitialKeysAndAuthParamsForUser(n,r);case 9:return i=e.sent,i.isDefault=0==this.credentials.length,a=new l.SFItem({content_type:f.a.FileSafeCredentialsContentType,content:i}),this.extensionBridge.saveItem(a),this.didLoadCredentials(),e.abrupt("return",a);case 15:case"end":return e.stop()}},e,this)}));return e}()},{key:"didLoadCredentials",value:function(){this.extensionBridge.notifyObserversOfEvent(f.a.BridgeEventLoadedCredentials)}},{key:"credentialForFileDescriptor",value:function(e){return this.credentials.find(function(t){return e.content.references.find(function(e){return e.uuid==t.uuid})})}},{key:"getAllCredentials",value:function(){return this.credentials}},{key:"saveCredential",value:function(e){this.extensionBridge.saveItem(e)}}]),e}()},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n3&&void 0!==arguments[3]&&arguments[3],i=document.createElement("a");i.setAttribute("download",t),i.href=this.tempUrlForData(e,n),i.setAttribute("target","_blank"),r?window.location.href=i.href:(document.body.appendChild(i),i.click(),i.remove())}},{key:"tempUrlForData",value:function(e,t){return window.URL.createObjectURL(new Blob([e],{type:t||"text/json"}))}},{key:"copyTextToClipboard",value:function(e){if(window.clipboardData&&window.clipboardData.setData)return clipboardData.setData("Text",e);if(document.queryCommandSupported&&document.queryCommandSupported("copy")){var t=document.createElement("textarea");t.textContent=e,t.style.position="fixed",document.body.appendChild(t),t.select();try{return document.execCommand("copy")}catch(e){return console.warn("Copy to clipboard failed.",e),!1}finally{document.body.removeChild(t)}}}}]),e}()}])},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n0&&this.requestPermissions(this.initialPermissions);var t=!0,n=!1,r=void 0;try{for(var i,a=this.messageQueue[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;this.postMessage(o.action,o.data,o.callback)}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}this.messageQueue=[],this.loggingEnabled&&console.log("onReadyData",e),this.activateThemes(e.activeThemeUrls||[]),this.onReadyCallback&&this.onReadyCallback()}},{key:"getSelfComponentUUID",value:function(){return this.uuid}},{key:"isRunningInDesktopApplication",value:function(){return"desktop"===this.environment}},{key:"setComponentDataValueForKey",value:function(e,t){this.componentData[e]=t,this.postMessage("set-component-data",{componentData:this.componentData},function(e){})}},{key:"clearComponentData",value:function(){this.componentData={},this.postMessage("set-component-data",{componentData:this.componentData},function(e){})}},{key:"componentDataValueForKey",value:function(e){return this.componentData[e]}},{key:"postMessage",value:function(e,t,n){if(!this.sessionKey)return void this.messageQueue.push({action:e,data:t,callback:n});var r={action:e,data:t,messageId:this.generateUUID(),sessionKey:this.sessionKey,api:"component"},i=JSON.parse(JSON.stringify(r));i.callback=n,this.sentMessages.push(i),this.isMobile&&(r=JSON.stringify(r)),this.loggingEnabled&&console.log("Posting message:",r),window.parent.postMessage(r,this.origin)}},{key:"setSize",value:function(e,t,n){this.postMessage("set-size",{type:e,width:t,height:n},function(e){})}},{key:"requestPermissions",value:function(e,t){this.postMessage("request-permissions",{permissions:e},function(e){t&&t()}.bind(this))}},{key:"streamItems",value:function(e,t){Array.isArray(e)||(e=[e]),this.postMessage("stream-items",{content_types:e},function(e){t(e.items)}.bind(this))}},{key:"streamContextItem",value:function(e){this.postMessage("stream-context-item",null,function(t){var n=t.item;e(n)})}},{key:"selectItem",value:function(e){this.postMessage("select-item",{item:this.jsonObjectForItem(e)})}},{key:"createItem",value:function(e,t){this.postMessage("create-item",{item:this.jsonObjectForItem(e)},function(e){var n=e.item;!n&&e.items&&e.items.length>0&&(n=e.items[0]),this.associateItem(n),t&&t(n)}.bind(this))}},{key:"createItems",value:function(e,t){var n=this,r=e.map(function(e){return n.jsonObjectForItem(e)});this.postMessage("create-items",{items:r},function(e){t&&t(e.items)}.bind(this))}},{key:"associateItem",value:function(e){this.postMessage("associate-item",{item:this.jsonObjectForItem(e)})}},{key:"deassociateItem",value:function(e){this.postMessage("deassociate-item",{item:this.jsonObjectForItem(e)})}},{key:"clearSelection",value:function(){this.postMessage("clear-selection",{content_type:"Tag"})}},{key:"deleteItem",value:function(e,t){this.deleteItems([e],t)}},{key:"deleteItems",value:function(e,t){var n={items:e.map(function(e){return this.jsonObjectForItem(e)}.bind(this))};this.postMessage("delete-items",n,function(e){t&&t(e)})}},{key:"sendCustomEvent",value:function(e,t,n){this.postMessage(e,t,function(e){n&&n(e)}.bind(this))}},{key:"saveItem",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.saveItems([e],t,n)}},{key:"saveItemWithPresave",value:function(e,t,n){this.saveItemsWithPresave([e],t,n)}},{key:"saveItemsWithPresave",value:function(e,t,n){this.saveItems(e,n,!1,t)}},{key:"saveItems",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments[3],a=function(e){i&&i();var r=[],a=[],o=!0,s=!1,u=void 0;try{for(var c,l=e[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var f=c.value;r.includes(f.uuid)||(r.push(f.uuid),f.updated_at=new Date,a.push(n.jsonObjectForItem(f)))}}catch(e){s=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw u}}n.postMessage("save-items",{items:a},function(e){t&&t()})};this.pendingSaveItems||(this.pendingSaveItems=[]),1!=this.coallesedSaving||r?a(e):(this.pendingSave&&clearTimeout(this.pendingSave),this.pendingSaveItems=this.pendingSaveItems.concat(e),this.pendingSave=setTimeout(function(){a(n.pendingSaveItems),n.pendingSaveItems=[]},this.coallesedSavingDelay))}},{key:"jsonObjectForItem",value:function(e){var t=Object.assign({},e);return t.children=null,t.parent=null,t}},{key:"getItemAppDataValue",value:function(e,t){var n=e.content.appData&&e.content.appData["org.standardnotes.sn"];return n?n[t]:null}},{key:"activateThemes",value:function(e){if(this.loggingEnabled&&console.log("Incoming themes",e),this.activeThemes.sort().toString()!=e.sort().toString()){var t=e||[],n=[],r=!0,i=!1,a=void 0;try{for(var o,s=this.activeThemes[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;e.includes(u)?t=t.filter(function(e){return e!=u}):n.push(u)}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}this.loggingEnabled&&(console.log("Deactivating themes:",n),console.log("Activating themes:",t));var c=!0,l=!1,f=void 0;try{for(var p,h=n[Symbol.iterator]();!(c=(p=h.next()).done);c=!0){var d=p.value;this.deactivateTheme(d)}}catch(e){l=!0,f=e}finally{try{!c&&h.return&&h.return()}finally{if(l)throw f}}this.activeThemes=e;var y=!0,v=!1,g=void 0;try{for(var m,b=t[Symbol.iterator]();!(y=(m=b.next()).done);y=!0){var k=m.value;if(k){var w=document.createElement("link");w.id=btoa(k),w.href=k,w.type="text/css",w.rel="stylesheet",w.media="screen,print",w.className="custom-theme",document.getElementsByTagName("head")[0].appendChild(w)}}}catch(e){v=!0,g=e}finally{try{!y&&b.return&&b.return()}finally{if(v)throw g}}}}},{key:"themeElementForUrl",value:function(e){return Array.from(document.getElementsByClassName("custom-theme")).slice().find(function(t){return t.id==btoa(e)})}},{key:"deactivateTheme",value:function(e){var t=this.themeElementForUrl(e);t&&(t.disabled=!0,t.parentNode.removeChild(t))}},{key:"generateUUID",value:function(){var e=window.crypto||window.msCrypto;if(e){var t=new Uint32Array(4);e.getRandomValues(t);var n=-1;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){n++;var r=t[n>>3]>>n%8*4&15;return("x"==e?r:3&r|8).toString(16)})}var r=(new Date).getTime();return window.performance&&"function"==typeof window.performance.now&&(r+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)})}}]),e}();void 0!==e&&void 0!==e.exports&&(e.exports=a),window&&(window.ComponentManager=a)}]); \ No newline at end of file +var i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,s,u=r(e),c=1;cD.length&&D.push(e)}function p(e,t,n,i){var a=typeof e;if("undefined"!==a&&"boolean"!==a||(e=null),null===e||"string"===a||"number"===a||"object"===a&&e.$$typeof===F)return n(i,e,""===t?"."+h(e,0):t),1;var o=0;if(t=""===t?".":t+":",Array.isArray(e))for(var s=0;s=V(e.last.priorityLevel,t))n=e.last;else for(e=e.first;null!==e&&0>=V(e.priorityLevel,t);)n=e,e=e.next;return n}function G(e,t){var n=e.alternate,r=e.updateQueue;null===r&&(r=e.updateQueue=J()),null!==n?null===(e=n.updateQueue)&&(e=n.updateQueue=J()):e=null,Tr=r,Nr=e!==r?e:null;var i=Tr;n=Nr;var a=$(i,t),o=null!==a?a.next:i.first;return null===n?(q(i,t,a,o),null):(r=$(n,t),e=null!==r?r.next:n.first,q(i,t,a,o),o===e&&null!==o||a===r&&null!==a?(null===r&&(n.first=t),null===e&&(n.last=null),null):(t={priorityLevel:t.priorityLevel,partialState:t.partialState,callback:t.callback,isReplace:t.isReplace,isForced:t.isForced,isTopLevelUnmount:t.isTopLevelUnmount,next:null},q(n,t,r,e),t))}function Q(e,t,n,r){return e=e.partialState,"function"==typeof e?e.call(t,n,r):e}function Y(e,t,n){e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=n}function X(e){return e.tag===zr&&null!=e.type.childContextTypes}function Z(e,t){var n=e.stateNode,i=e.type.childContextTypes;if("function"!=typeof n.getChildContext)return t;n=n.getChildContext();for(var a in n)a in i||r("108",p(e)||"Unknown",a);return gt({},t,n)}function ee(e,t,n){this.tag=e,this.key=t,this.stateNode=this.type=null,this.sibling=this.child=this.return=null,this.index=0,this.memoizedState=this.updateQueue=this.memoizedProps=this.pendingProps=this.ref=null,this.internalContextTag=n,this.effectTag=ci,this.lastEffect=this.firstEffect=this.nextEffect=null,this.pendingWorkPriority=si,this.alternate=null}function te(e,t,n){var i=void 0;return"function"==typeof e?(i=e.prototype&&e.prototype.isReactComponent?new ee(Zr,t,n):new ee(Xr,t,n),i.type=e):"string"==typeof e?(i=new ee(ti,t,n),i.type=e):"object"==typeof e&&null!==e&&"number"==typeof e.tag?i=e:r("130",null==e?e:typeof e,""),i}function ne(e){return null===e||void 0===e?null:(e=Hi&&e[Hi]||e["@@iterator"],"function"==typeof e?e:null)}function re(e,t){var n=t.ref;if(null!==n&&"function"!=typeof n){if(t._owner){t=t._owner;var i=void 0;t&&("number"==typeof t.tag?(t.tag!==Di&&r("110"),i=t.stateNode):i=t.getPublicInstance()),i||r("147",n);var a=""+n;return null!==e&&null!==e.ref&&e.ref._stringRef===a?e.ref:(e=function(e){var t=i.refs===kt?i.refs={}:i.refs;null===e?delete t[a]:t[a]=e},e._stringRef=a,e)}"string"!=typeof n&&r("148"),t._owner||r("149",n)}return n}function ie(e,t){"textarea"!==e.type&&r("31","[object Object]"===Object.prototype.toString.call(t)?"object with keys {"+Object.keys(t).join(", ")+"}":t,"")}function ae(e,t){function n(n,r){if(t){if(!e){if(null===r.alternate)return;r=r.alternate}var i=n.lastEffect;null!==i?(i.nextEffect=r,n.lastEffect=r):n.firstEffect=n.lastEffect=r,r.nextEffect=null,r.effectTag=Li}}function i(e,r){if(!t)return null;for(;null!==r;)n(e,r),r=r.sibling;return null}function a(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function o(t,n){return e?(t=xi(t,n),t.index=0,t.sibling=null,t):(t.pendingWorkPriority=n,t.effectTag=ji,t.index=0,t.sibling=null,t)}function s(e,n,r){return e.index=r,t?null!==(r=e.alternate)?(r=r.index,rp?(h=f,f=null):h=f.sibling;var d=v(e,f,o[p],u);if(null===d){null===f&&(f=h);break}t&&f&&null===d.alternate&&n(e,f),r=s(d,r,p),null===l?c=d:l.sibling=d,l=d,f=h}if(p===o.length)return i(e,f),c;if(null===f){for(;ph?(d=p,p=null):d=p.sibling;var b=v(e,p,m.value,c);if(null===b){p||(p=d);break}t&&p&&null===b.alternate&&n(e,p),o=s(b,o,h),null===f?l=b:f.sibling=b,f=b,p=d}if(m.done)return i(e,p),l;if(null===p){for(;!m.done;h++,m=u.next())null!==(m=y(e,m.value,c))&&(o=s(m,o,h),null===f?l=m:f.sibling=m,f=m);return l}for(p=a(e,p);!m.done;h++,m=u.next())null!==(m=g(p,e,h,m.value,c))&&(t&&null!==m.alternate&&p.delete(null===m.key?h:m.key),o=s(m,o,h),null===f?l=m:f.sibling=m,f=m);return t&&p.forEach(function(t){return n(e,t)}),l}return function(e,t,a,s){var c="object"==typeof a&&null!==a;if(c)switch(a.$$typeof){case Ui:e:{var l=a.key;for(c=t;null!==c;){if(c.key===l){if(c.type===a.type){i(e,c.sibling),t=o(c,s),t.ref=re(c,a),t.pendingProps=a.props,t.return=e,e=t;break e}i(e,c);break}n(e,c),c=c.sibling}s=Si(a,e.internalContextTag,s),s.ref=re(t,a),s.return=e,e=s}return u(e);case bi:e:{for(c=a.key;null!==t;){if(t.key===c){if(t.tag===Ai){i(e,t.sibling),t=o(t,s),t.pendingProps=a,t.return=e,e=t;break e}i(e,t);break}n(e,t),t=t.sibling}a=Ii(a,e.internalContextTag,s),a.return=e,e=a}return u(e);case ki:e:{if(null!==t){if(t.tag===Ti){i(e,t.sibling),t=o(t,s),t.type=a.value,t.return=e,e=t;break e}i(e,t)}t=Ri(a,e.internalContextTag,s),t.type=a.value,t.return=e,e=t}return u(e);case wi:e:{for(c=a.key;null!==t;){if(t.key===c){if(t.tag===Mi&&t.stateNode.containerInfo===a.containerInfo&&t.stateNode.implementation===a.implementation){i(e,t.sibling),t=o(t,s),t.pendingProps=a.children||[],t.return=e,e=t;break e}i(e,t);break}n(e,t),t=t.sibling}a=Ei(a,e.internalContextTag,s),a.return=e,e=a}return u(e)}if("string"==typeof a||"number"==typeof a)return a=""+a,null!==t&&t.tag===Oi?(i(e,t.sibling),t=o(t,s),t.pendingProps=a,t.return=e,e=t):(i(e,t),a=Ci(a,e.internalContextTag,s),a.return=e,e=a),u(e);if(Fi(a))return m(e,t,a,s);if(ne(a))return b(e,t,a,s);if(c&&ie(e,a),void 0===a)switch(e.tag){case Di:case Pi:a=e.type,r("152",a.displayName||a.name||"Component")}return i(e,t)}}function oe(e,t,n,i){function a(e,t){t.updater=o,e.stateNode=t,$t.set(t,e)}var o={isMounted:ra,enqueueSetState:function(n,r,i){n=$t.get(n);var a=t(n,!1);Xi(n,r,void 0===i?null:i,a),e(n,a)},enqueueReplaceState:function(n,r,i){n=$t.get(n);var a=t(n,!1);Zi(n,r,void 0===i?null:i,a),e(n,a)},enqueueForceUpdate:function(n,r){n=$t.get(n);var i=t(n,!1);ea(n,void 0===r?null:r,i),e(n,i)}};return{adoptClassInstance:a,constructClassInstance:function(e,t){var n=e.type,r=Qi(e),i=Yi(e),o=i?Gi(e,r):kt;return t=new n(t,o),a(e,t),i&&$i(e,r,o),t},mountClassInstance:function(e,t){var n=e.alternate,i=e.stateNode,a=i.state||null,s=e.pendingProps;s||r("158");var u=Qi(e);i.props=s,i.state=a,i.refs=kt,i.context=Gi(e,u),Rr.enableAsyncSubtreeAPI&&null!=e.type&&null!=e.type.prototype&&!0===e.type.prototype.unstable_isAsyncReactComponent&&(e.internalContextTag|=qi),"function"==typeof i.componentWillMount&&(u=i.state,i.componentWillMount(),u!==i.state&&o.enqueueReplaceState(i,i.state,null),null!==(u=e.updateQueue)&&(i.state=ta(n,e,u,i,a,s,t))),"function"==typeof i.componentDidMount&&(e.effectTag|=Ji)},updateClassInstance:function(e,t,a){var s=t.stateNode;s.props=t.memoizedProps,s.state=t.memoizedState;var u=t.memoizedProps,c=t.pendingProps;c||null==(c=u)&&r("159");var l=s.context,f=Qi(t);if(f=Gi(t,f),"function"!=typeof s.componentWillReceiveProps||u===c&&l===f||(l=s.state,s.componentWillReceiveProps(c,f),s.state!==l&&o.enqueueReplaceState(s,s.state,null)),l=t.memoizedState,a=null!==t.updateQueue?ta(e,t,t.updateQueue,s,l,c,a):l,!(u!==c||l!==a||na()||null!==t.updateQueue&&t.updateQueue.hasForceUpdate))return"function"!=typeof s.componentDidUpdate||u===e.memoizedProps&&l===e.memoizedState||(t.effectTag|=Ji),!1;var p=c;if(null===u||null!==t.updateQueue&&t.updateQueue.hasForceUpdate)p=!0;else{var h=t.stateNode,d=t.type;p="function"==typeof h.shouldComponentUpdate?h.shouldComponentUpdate(p,a,f):!d.prototype||!d.prototype.isPureReactComponent||(!wt(u,p)||!wt(l,a))}return p?("function"==typeof s.componentWillUpdate&&s.componentWillUpdate(c,a,f),"function"==typeof s.componentDidUpdate&&(t.effectTag|=Ji)):("function"!=typeof s.componentDidUpdate||u===e.memoizedProps&&l===e.memoizedState||(t.effectTag|=Ji),n(t,c),i(t,a)),s.props=c,s.state=a,s.context=f,p}}}function se(e,t,n,i,a){function o(e,t,n){s(e,t,n,t.pendingWorkPriority)}function s(e,t,n,r){t.child=null===e?ia(t,t.child,n,r):e.child===t.child?aa(t,t.child,n,r):oa(t,t.child,n,r)}function u(e,t){var n=t.ref;null===n||e&&e.ref===n||(t.effectTag|=Oa)}function c(e,t,n,r){if(u(e,t),!n)return r&&da(t,!1),f(e,t);n=t.stateNode,Ma.current=t;var i=n.render();return t.effectTag|=Ea,o(e,t,i),t.memoizedState=n.state,t.memoizedProps=n.props,r&&da(t,!0),t.child}function l(e){var t=e.stateNode;t.pendingContext?ha(e,t.pendingContext,t.pendingContext!==t.context):t.context&&ha(e,t.context,!1),g(e,t.containerInfo)}function f(e,t){return sa(e,t),t.child}function p(e,t){switch(t.tag){case ma:l(t);break;case ga:pa(t);break;case wa:g(t,t.stateNode.containerInfo)}return null}var h=e.shouldSetTextContent,d=e.useSyncScheduling,y=e.shouldDeprioritizeSubtree,v=t.pushHostContext,g=t.pushHostContainer,m=n.enterHydrationState,b=n.resetHydrationState,k=n.tryToClaimNextHydratableInstance;e=oe(i,a,function(e,t){e.memoizedProps=t},function(e,t){e.memoizedState=t});var w=e.adoptClassInstance,x=e.constructClassInstance,S=e.mountClassInstance,_=e.updateClassInstance;return{beginWork:function(e,t,n){if(t.pendingWorkPriority===Ia||t.pendingWorkPriority>n)return p(e,t);switch(t.tag){case ya:null!==e&&r("155");var i=t.type,a=t.pendingProps,s=la(t);return s=ca(t,s),i=i(a,s),t.effectTag|=Ea,"object"==typeof i&&null!==i&&"function"==typeof i.render?(t.tag=ga,a=pa(t),w(t,i),S(t,n),t=c(e,t,!0,a)):(t.tag=va,o(e,t,i),t.memoizedProps=a,t=t.child),t;case va:e:{if(a=t.type,n=t.pendingProps,i=t.memoizedProps,fa())null===n&&(n=i);else if(null===n||i===n){t=f(e,t);break e}i=la(t),i=ca(t,i),a=a(n,i),t.effectTag|=Ea,o(e,t,a),t.memoizedProps=n,t=t.child}return t;case ga:return a=pa(t),i=void 0,null===e?t.stateNode?r("153"):(x(t,t.pendingProps),S(t,n),i=!0):i=_(e,t,n),c(e,t,i,a);case ma:return l(t),i=t.updateQueue,null!==i?(a=t.memoizedState,i=ua(e,t,i,null,a,null,n),a===i?(b(),t=f(e,t)):(a=i.element,null!==e&&null!==e.child||!m(t)?(b(),o(e,t,a)):(t.effectTag|=Fa,t.child=ia(t,t.child,a,n)),t.memoizedState=i,t=t.child)):(b(),t=f(e,t)),t;case ba:v(t),null===e&&k(t),a=t.type;var C=t.memoizedProps;return i=t.pendingProps,null===i&&null===(i=C)&&r("154"),s=null!==e?e.memoizedProps:null,fa()||null!==i&&C!==i?(C=i.children,h(a,i)?C=null:s&&h(a,s)&&(t.effectTag|=Pa),u(e,t),n!==Ra&&!d&&y(a,i)?(t.pendingWorkPriority=Ra,t=null):(o(e,t,C),t.memoizedProps=i,t=t.child)):t=f(e,t),t;case ka:return null===e&&k(t),e=t.pendingProps,null===e&&(e=t.memoizedProps),t.memoizedProps=e,null;case Sa:t.tag=xa;case xa:return n=t.pendingProps,fa()?null===n&&null===(n=e&&e.memoizedProps)&&r("154"):null!==n&&t.memoizedProps!==n||(n=t.memoizedProps),a=n.children,i=t.pendingWorkPriority,t.stateNode=null===e?ia(t,t.stateNode,a,i):e.child===t.child?aa(t,t.stateNode,a,i):oa(t,t.stateNode,a,i),t.memoizedProps=n,t.stateNode;case _a:return null;case wa:e:{if(g(t,t.stateNode.containerInfo),n=t.pendingWorkPriority,a=t.pendingProps,fa())null===a&&null==(a=e&&e.memoizedProps)&&r("154");else if(null===a||t.memoizedProps===a){t=f(e,t);break e}null===e?t.child=oa(t,t.child,a,n):o(e,t,a),t.memoizedProps=a,t=t.child}return t;case Ca:e:{if(n=t.pendingProps,fa())null===n&&(n=t.memoizedProps);else if(null===n||t.memoizedProps===n){t=f(e,t);break e}o(e,t,n),t.memoizedProps=n,t=t.child}return t;default:r("156")}},beginFailedWork:function(e,t,n){switch(t.tag){case ga:pa(t);break;case ma:l(t);break;default:r("157")}return t.effectTag|=Da,null===e?t.child=null:t.child!==e.child&&(t.child=e.child),t.pendingWorkPriority===Ia||t.pendingWorkPriority>n?p(e,t):(t.firstEffect=null,t.lastEffect=null,s(e,t,null,n),t.tag===ga&&(e=t.stateNode,t.memoizedProps=e.props,t.memoizedState=e.state),t.child)}}}function ue(e,t,n){var i=e.createInstance,a=e.createTextInstance,o=e.appendInitialChild,s=e.finalizeInitialChildren,u=e.prepareUpdate,c=t.getRootHostContainer,l=t.popHostContext,f=t.getHostContext,p=t.popHostContainer,h=n.prepareToHydrateHostInstance,d=n.prepareToHydrateHostTextInstance,y=n.popHydrationState;return{completeWork:function(e,t,n){var v=t.pendingProps;switch(null===v?v=t.memoizedProps:t.pendingWorkPriority===Ya&&n!==Ya||(t.pendingProps=null),t.tag){case Ba:return null;case La:return Ta(t),null;case Ha:return p(t),Na(t),v=t.stateNode,v.pendingContext&&(v.context=v.pendingContext,v.pendingContext=null),null!==e&&null!==e.child||(y(t),t.effectTag&=~$a),null;case Ua:l(t),n=c();var g=t.type;if(null!==e&&null!=t.stateNode){var m=e.memoizedProps,b=t.stateNode,k=f();v=u(b,g,m,v,n,k),(t.updateQueue=v)&&(t.effectTag|=Qa),e.ref!==t.ref&&(t.effectTag|=Ga)}else{if(!v)return null===t.stateNode&&r("166"),null;if(e=f(),y(t))h(t,n,e)&&(t.effectTag|=Qa);else{e=i(g,v,n,e,t);e:for(m=t.child;null!==m;){if(m.tag===Ua||m.tag===za)o(e,m.stateNode);else if(m.tag!==Ka&&null!==m.child){m=m.child;continue}if(m===t)break e;for(;null===m.sibling;){if(null===m.return||m.return===t)break e;m=m.return}m=m.sibling}s(e,g,v,n)&&(t.effectTag|=Qa),t.stateNode=e}null!==t.ref&&(t.effectTag|=Ga)}return null;case za:if(e&&null!=t.stateNode)e.memoizedProps!==v&&(t.effectTag|=Qa);else{if("string"!=typeof v)return null===t.stateNode&&r("166"),null;e=c(),n=f(),y(t)?d(t)&&(t.effectTag|=Qa):t.stateNode=a(v,e,n,t)}return null;case Wa:(v=t.memoizedProps)||r("165"),t.tag=Va,n=[];e:for((g=t.stateNode)&&(g.return=t);null!==g;){if(g.tag===Ua||g.tag===za||g.tag===Ka)r("164");else if(g.tag===Ja)n.push(g.type);else if(null!==g.child){g.child.return=g,g=g.child;continue}for(;null===g.sibling;){if(null===g.return||g.return===t)break e;g=g.return}g.sibling.return=g.return,g=g.sibling}return g=v.handler,v=g(v.props,n),t.child=Aa(t,null!==e?e.child:null,v,t.pendingWorkPriority),t.child;case Va:return t.tag=Wa,null;case Ja:case qa:return null;case Ka:return t.effectTag|=Qa,p(t),null;case ja:r("167");default:r("156")}}}}function ce(e){return function(t){try{return e(t)}catch(e){}}}function le(e,t){function n(e){var n=e.ref;if(null!==n)try{n(null)}catch(n){t(e,n)}}function i(e){return e.tag===ro||e.tag===no||e.tag===ao}function a(e){for(var t=e;;)if(s(t),null!==t.child&&t.tag!==ao)t.child.return=t,t=t.child;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return;t=t.return}t.sibling.return=t.return,t=t.sibling}}function o(e){for(var t=e,n=!1,i=void 0,o=void 0;;){if(!n){n=t.return;e:for(;;){switch(null===n&&r("160"),n.tag){case ro:i=n.stateNode,o=!1;break e;case no:case ao:i=n.stateNode.containerInfo,o=!0;break e}n=n.return}n=!0}if(t.tag===ro||t.tag===io)a(t),o?g(i,t.stateNode):v(i,t.stateNode);else if(t.tag===ao?i=t.stateNode.containerInfo:s(t),null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return;t=t.return,t.tag===ao&&(n=!1)}t.sibling.return=t.return,t=t.sibling}}function s(e){switch("function"==typeof uo&&uo(e),e.tag){case to:n(e);var r=e.stateNode;if("function"==typeof r.componentWillUnmount)try{r.props=e.memoizedProps,r.state=e.memoizedState,r.componentWillUnmount()}catch(n){t(e,n)}break;case ro:n(e);break;case oo:a(e.stateNode);break;case ao:o(e)}}var u=e.commitMount,c=e.commitUpdate,l=e.resetTextContent,f=e.commitTextUpdate,p=e.appendChild,h=e.appendChildToContainer,d=e.insertBefore,y=e.insertInContainerBefore,v=e.removeChild,g=e.removeChildFromContainer,m=e.getPublicInstance;return{commitPlacement:function(e){e:{for(var t=e.return;null!==t;){if(i(t)){var n=t;break e}t=t.return}r("160"),n=void 0}var a=t=void 0;switch(n.tag){case ro:t=n.stateNode,a=!1;break;case no:case ao:t=n.stateNode.containerInfo,a=!0;break;default:r("161")}n.effectTag&po&&(l(t),n.effectTag&=~po);e:t:for(n=e;;){for(;null===n.sibling;){if(null===n.return||i(n.return)){n=null;break e}n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==ro&&n.tag!==io;){if(n.effectTag&co)continue t;if(null===n.child||n.tag===ao)continue t;n.child.return=n,n=n.child}if(!(n.effectTag&co)){n=n.stateNode;break e}}for(var o=e;;){if(o.tag===ro||o.tag===io)n?a?y(t,o.stateNode,n):d(t,o.stateNode,n):a?h(t,o.stateNode):p(t,o.stateNode);else if(o.tag!==ao&&null!==o.child){o.child.return=o,o=o.child;continue}if(o===e)break;for(;null===o.sibling;){if(null===o.return||o.return===e)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},commitDeletion:function(e){o(e),e.return=null,e.child=null,e.alternate&&(e.alternate.child=null,e.alternate.return=null)},commitWork:function(e,t){switch(t.tag){case to:break;case ro:var n=t.stateNode;if(null!=n){var i=t.memoizedProps;e=null!==e?e.memoizedProps:i;var a=t.type,o=t.updateQueue;t.updateQueue=null,null!==o&&c(n,o,a,e,i,t)}break;case io:null===t.stateNode&&r("162"),n=t.memoizedProps,f(t.stateNode,null!==e?e.memoizedProps:n,n);break;case no:case ao:break;default:r("163")}},commitLifeCycles:function(e,t){switch(t.tag){case to:var n=t.stateNode;if(t.effectTag&lo)if(null===e)n.props=t.memoizedProps,n.state=t.memoizedState,n.componentDidMount();else{var i=e.memoizedProps;e=e.memoizedState,n.props=t.memoizedProps,n.state=t.memoizedState,n.componentDidUpdate(i,e)}t.effectTag&fo&&null!==t.updateQueue&&so(t,t.updateQueue,n);break;case no:e=t.updateQueue,null!==e&&so(t,e,t.child&&t.child.stateNode);break;case ro:n=t.stateNode,null===e&&t.effectTag&lo&&u(n,t.type,t.memoizedProps,t);break;case io:case ao:break;default:r("163")}},commitAttachRef:function(e){var t=e.ref;if(null!==t){var n=e.stateNode;switch(e.tag){case ro:t(m(n));break;default:t(n)}}},commitDetachRef:function(e){null!==(e=e.ref)&&e(null)}}}function fe(e){function t(e){return e===go&&r("174"),e}var n=e.getChildHostContext,i=e.getRootHostContext,a=ho(go),o=ho(go),s=ho(go);return{getHostContext:function(){return t(a.current)},getRootHostContainer:function(){return t(s.current)},popHostContainer:function(e){yo(a,e),yo(o,e),yo(s,e)},popHostContext:function(e){o.current===e&&(yo(a,e),yo(o,e))},pushHostContainer:function(e,t){vo(s,t,e),t=i(t),vo(o,e,e),vo(a,t,e)},pushHostContext:function(e){var r=t(s.current),i=t(a.current);r=n(i,e.type,r),i!==r&&(vo(o,e,e),vo(a,r,e))},resetHostContainer:function(){a.current=go,s.current=go}}}function pe(e){function t(e,t){var n=So();n.stateNode=t,n.return=e,n.effectTag=wo,null!==e.lastEffect?(e.lastEffect.nextEffect=n,e.lastEffect=n):e.firstEffect=e.lastEffect=n}function n(e,t){switch(e.tag){case mo:return o(t,e.type,e.pendingProps);case bo:return s(t,e.pendingProps);default:return!1}}function i(e){for(e=e.return;null!==e&&e.tag!==mo&&e.tag!==ko;)e=e.return;d=e}var a=e.shouldSetTextContent,o=e.canHydrateInstance,s=e.canHydrateTextInstance,u=e.getNextHydratableSibling,c=e.getFirstHydratableChild,l=e.hydrateInstance,f=e.hydrateTextInstance,p=e.didNotHydrateInstance,h=e.didNotFindHydratableInstance;if(e=e.didNotFindHydratableTextInstance,!(o&&s&&u&&c&&l&&f&&p&&h&&e))return{enterHydrationState:function(){return!1},resetHydrationState:function(){},tryToClaimNextHydratableInstance:function(){},prepareToHydrateHostInstance:function(){r("175")},prepareToHydrateHostTextInstance:function(){r("176")},popHydrationState:function(){return!1}};var d=null,y=null,v=!1;return{enterHydrationState:function(e){return y=c(e.stateNode.containerInfo),d=e,v=!0},resetHydrationState:function(){y=d=null,v=!1},tryToClaimNextHydratableInstance:function(e){if(v){var r=y;if(r){if(!n(e,r)){if(!(r=u(r))||!n(e,r))return e.effectTag|=xo,v=!1,void(d=e);t(d,y)}e.stateNode=r,d=e,y=c(r)}else e.effectTag|=xo,v=!1,d=e}},prepareToHydrateHostInstance:function(e,t,n){return t=l(e.stateNode,e.type,e.memoizedProps,t,n,e),e.updateQueue=t,null!==t},prepareToHydrateHostTextInstance:function(e){return f(e.stateNode,e.memoizedProps,e)},popHydrationState:function(e){if(e!==d)return!1;if(!v)return i(e),v=!0,!1;var n=e.type;if(e.tag!==mo||"head"!==n&&"body"!==n&&!a(n,e.memoizedProps))for(n=y;n;)t(e,n),n=u(n);return i(e),y=d?u(e.stateNode):null,!0}}}function he(e){function t(){for(;null!==J&&J.current.pendingWorkPriority===Po;){J.isScheduled=!1;var e=J.nextScheduledRoot;if(J.nextScheduledRoot=null,J===q)return q=J=null,K=Po,null;J=e}e=J;for(var t=null,n=Po;null!==e;)e.current.pendingWorkPriority!==Po&&(n===Po||n>e.current.pendingWorkPriority)&&(n=e.current.pendingWorkPriority,t=e),e=e.nextScheduledRoot;null!==t?(K=n,Co(),Yo(),x(),z=Ro(t.current,n),t!==ie&&(re=0,ie=t)):(K=Po,ie=z=null)}function n(n){ee=!0,V=null;var i=n.stateNode;if(i.current===n&&r("177"),K!==Do&&K!==Oo||re++,Io.current=null,n.effectTag>jo)if(null!==n.lastEffect){n.lastEffect.nextEffect=n;var a=n.firstEffect}else a=n;else a=n.firstEffect;for(T(),W=a;null!==W;){var o=!1,s=void 0;try{for(;null!==W;){var u=W.effectTag;if(u&zo&&e.resetTextContent(W.stateNode),u&Vo){var c=W.alternate;null!==c&&O(c)}switch(u&~(Ko|Wo|zo|Vo|jo)){case Bo:R(W),W.effectTag&=~Bo;break;case Ho:R(W),W.effectTag&=~Bo,F(W.alternate,W);break;case Lo:F(W.alternate,W);break;case Uo:te=!0,E(W),te=!1}W=W.nextEffect}}catch(e){o=!0,s=e}o&&(null===W&&r("178"),f(W,s),null!==W&&(W=W.nextEffect))}for(N(),i.current=n,W=a;null!==W;){i=!1,a=void 0;try{for(;null!==W;){var l=W.effectTag;if(l&(Lo|Ko)&&P(W.alternate,W),l&Vo&&D(W),l&Wo)switch(o=W,s=void 0,null!==G&&(s=G.get(o),G.delete(o),null==s&&null!==o.alternate&&(o=o.alternate,s=G.get(o),G.delete(o))),null==s&&r("184"),o.tag){case Go:o.stateNode.componentDidCatch(s.error,{componentStack:s.componentStack});break;case Jo:null===X&&(X=s.error);break;default:r("157")}var p=W.nextEffect;W.nextEffect=null,W=p}}catch(e){i=!0,a=e}i&&(null===W&&r("178"),f(W,a),null!==W&&(W=W.nextEffect))}ee=!1,"function"==typeof Fo&&Fo(n.stateNode),Y&&(Y.forEach(g),Y=null),t()}function i(e){for(;;){var t=I(e.alternate,e,K),n=e.return,r=e.sibling,i=e;if(!(i.pendingWorkPriority!==Po&&i.pendingWorkPriority>K)){for(var a=Qo(i),o=i.child;null!==o;)a=Eo(a,o.pendingWorkPriority),o=o.sibling;i.pendingWorkPriority=a}if(null!==t)return t;if(null!==n&&(null===n.firstEffect&&(n.firstEffect=e.firstEffect),null!==e.lastEffect&&(null!==n.lastEffect&&(n.lastEffect.nextEffect=e.firstEffect),n.lastEffect=e.lastEffect),e.effectTag>jo&&(null!==n.lastEffect?n.lastEffect.nextEffect=e:n.firstEffect=e,n.lastEffect=e)),null!==r)return r;if(null===n){V=e;break}e=n}return null}function a(e){var t=_(e.alternate,e,K);return null===t&&(t=i(e)),Io.current=null,t}function o(e){var t=C(e.alternate,e,K);return null===t&&(t=i(e)),Io.current=null,t}function s(e){l(To,e)}function u(){if(null!==G&&0e)){j=K;e:for(;;){if(K<=Oo)for(;null!==z&&!(null===(z=a(z))&&(null===V&&r("179"),j=Oo,n(V),j=K,u(),K===Po||K>e||K>Oo)););else if(null!==i)for(;null!==z&&!L;)if(1e||KOo&&!$&&(M(s),$=!0),e=X,Z=L=B=!1,ie=Q=G=X=null,re=0,null!==e)throw e}function f(e,t){var n=Io.current=null,r=!1,i=!1,a=null;if(e.tag===Jo)n=e,h(e)&&(Z=!0);else for(var o=e.return;null!==o&&null===n;){if(o.tag===Go?"function"==typeof o.stateNode.componentDidCatch&&(r=!0,a=p(o),n=o,i=!0):o.tag===Jo&&(n=o),h(o)){if(te||null!==Y&&(Y.has(o)||null!==o.alternate&&Y.has(o.alternate)))return null;n=null,i=!1}o=o.return}if(null!==n){null===Q&&(Q=new Set),Q.add(n);var s="";o=e;do{e:switch(o.tag){case pi:case hi:case di:case yi:var u=o._debugOwner,c=o._debugSource,l=p(o),f=null;u&&(f=p(u)),u=c,l="\n in "+(l||"Unknown")+(u?" (at "+u.fileName.replace(/^.*[\\\/]/,"")+":"+u.lineNumber+")":f?" (created by "+f+")":"");break e;default:l=""}s+=l,o=o.return}while(o);o=s,e=p(e),null===G&&(G=new Map),t={componentName:e,componentStack:o,error:t,errorBoundary:r?n.stateNode:null,errorBoundaryFound:r,errorBoundaryName:a,willRetry:i},G.set(n,t);try{console.error(t.error)}catch(e){console.error(e)}return ee?(null===Y&&(Y=new Set),Y.add(n)):g(n),n}return null===X&&(X=t),null}function h(e){return null!==Q&&(Q.has(e)||null!==e.alternate&&Q.has(e.alternate))}function d(e,t){return y(e,t,!1)}function y(e,t){re>ne&&(Z=!0,r("185")),!B&&t<=K&&(z=null);for(var n=!0;null!==e&&n;){if(n=!1,(e.pendingWorkPriority===Po||e.pendingWorkPriority>t)&&(n=!0,e.pendingWorkPriority=t),null!==e.alternate&&(e.alternate.pendingWorkPriority===Po||e.alternate.pendingWorkPriority>t)&&(n=!0,e.alternate.pendingWorkPriority=t),null===e.return){if(e.tag!==Jo)break;var i=e.stateNode;if(t===Po||i.isScheduled||(i.isScheduled=!0,q?q.nextScheduledRoot=i:J=i,q=i),!B)switch(t){case Do:U?l(Do,null):l(Oo,null);break;case Oo:H||r("186");break;default:$||(M(s),$=!0)}}e=e.return}}function v(e,t){var n=j;return n===Po&&(n=!A||e.internalContextTag&No||t?Ao:Do),n===Do&&(B||H)?Oo:n}function g(e){y(e,Oo,!0)}var m=fe(e),b=pe(e),k=m.popHostContainer,w=m.popHostContext,x=m.resetHostContainer,S=se(e,m,b,d,v),_=S.beginWork,C=S.beginFailedWork,I=ue(e,m,b).completeWork;m=le(e,f);var R=m.commitPlacement,E=m.commitDeletion,F=m.commitWork,P=m.commitLifeCycles,D=m.commitAttachRef,O=m.commitDetachRef,M=e.scheduleDeferredCallback,A=e.useSyncScheduling,T=e.prepareForCommit,N=e.resetAfterCommit,j=Po,B=!1,L=!1,H=!1,U=!1,z=null,K=Po,W=null,V=null,J=null,q=null,$=!1,G=null,Q=null,Y=null,X=null,Z=!1,ee=!1,te=!1,ne=1e3,re=0,ie=null;return{scheduleUpdate:d,getPriorityContext:v,batchedUpdates:function(e,t){var n=H;H=!0;try{return e(t)}finally{H=n,B||H||l(Oo,null)}},unbatchedUpdates:function(e){var t=U,n=H;U=H,H=!1;try{return e()}finally{H=n,U=t}},flushSync:function(e){var t=H,n=j;H=!0,j=Do;try{return e()}finally{H=t,j=n,B&&r("187"),l(Oo,null)}},deferredUpdates:function(e){var t=j;j=Ao;try{return e()}finally{j=t}}}}function de(){r("196")}function ye(e){return e?(e=$t.get(e),"number"==typeof e.tag?de(e):e._processChildContext(e._context)):kt}function ve(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ge(e,t){var n=ve(e);e=0;for(var r;n;){if(n.nodeType===as){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ve(n)}}function me(){return!os&&vt.canUseDOM&&(os="textContent"in document.documentElement?"textContent":"innerText"),os}function be(){r("211")}function ke(){r("212")}function we(e){if(null==e)return null;if(e.nodeType===fs)return e;var t=$t.get(e);if(t)return"number"==typeof t.tag?be(t):ke(t);"function"==typeof e.render?r("188"):r("213",Object.keys(e))}function xe(e){if(void 0!==e._hostParent)return e._hostParent;if("number"==typeof e.tag){do{e=e.return}while(e&&e.tag!==ps);if(e)return e}return null}function Se(e,t){for(var n=0,r=e;r;r=xe(r))n++;r=0;for(var i=t;i;i=xe(i))r++;for(;0this.eventPool.length&&this.eventPool.push(e)}function Oe(e){e.eventPool=[],e.getPooled=Pe,e.release=De}function Me(e,t,n,r){return Fe.call(this,e,t,n,r)}function Ae(e,t,n,r){return Fe.call(this,e,t,n,r)}function Te(e,t){switch(e){case"topKeyUp":return-1!==ws.indexOf(t.keyCode);case"topKeyDown":return 229!==t.keyCode;case"topKeyPress":case"topMouseDown":case"topBlur":return!0;default:return!1}}function Ne(e){return e=e.detail,"object"==typeof e&&"data"in e?e.data:null}function je(e,t){switch(e){case"topCompositionEnd":return Ne(t);case"topKeyPress":return 32!==t.which?null:(Ps=!0,Es);case"topTextInput":return e=t.data,e===Es&&Ps?null:e;default:return null}}function Be(e,t){if(Ds)return"topCompositionEnd"===e||!xs&&Te(e,t)?(e=ms.getData(),ms.reset(),Ds=!1,e):null;switch(e){case"topPaste":return null;case"topKeyPress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=u.hasBooleanValue+u.hasNumericValue+u.hasOverloadedBooleanValue||r("50",o),a.hasOwnProperty(o)&&(u.attributeName=a[o]),i.hasOwnProperty(o)&&(u.attributeNamespace=i[o]),e.hasOwnProperty(o)&&(u.mutationMethod=e[o]),At.properties[o]=u}}},At={ID_ATTRIBUTE_NAME:"data-reactid",ROOT_ATTRIBUTE_NAME:"data-reactroot",ATTRIBUTE_NAME_START_CHAR:":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",ATTRIBUTE_NAME_CHAR:":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",properties:{},shouldSetAttribute:function(e,t){if(At.isReservedProp(e)||!("o"!==e[0]&&"O"!==e[0]||"n"!==e[1]&&"N"!==e[1]))return!1;if(null===t)return!0;switch(typeof t){case"boolean":return At.shouldAttributeAcceptBooleanValue(e);case"undefined":case"number":case"string":case"object":return!0;default:return!1}},getPropertyInfo:function(e){return At.properties.hasOwnProperty(e)?At.properties[e]:null},shouldAttributeAcceptBooleanValue:function(e){if(At.isReservedProp(e))return!0;var t=At.getPropertyInfo(e);return t?t.hasBooleanValue||t.hasStringBooleanValue||t.hasOverloadedBooleanValue:"data-"===(e=e.toLowerCase().slice(0,5))||"aria-"===e},isReservedProp:function(e){return Ot.hasOwnProperty(e)},injection:Mt},Tt=At,Nt={IndeterminateComponent:0,FunctionalComponent:1,ClassComponent:2,HostRoot:3,HostPortal:4,HostComponent:5,HostText:6,CoroutineComponent:7,CoroutineHandlerPhase:8,YieldComponent:9,Fragment:10},jt={ELEMENT_NODE:1,TEXT_NODE:3,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_FRAGMENT_NODE:11},Bt=Nt.HostComponent,Lt=Nt.HostText,Ht=jt.ELEMENT_NODE,Ut=jt.COMMENT_NODE,zt=Tt.ID_ATTRIBUTE_NAME,Kt={hasCachedChildNodes:1},Wt=Math.random().toString(36).slice(2),Vt="__reactInternalInstance$"+Wt,Jt="__reactEventHandlers$"+Wt,qt={getClosestInstanceFromNode:f,getInstanceFromNode:function(e){var t=e[Vt];return t?t.tag===Bt||t.tag===Lt?t:t._hostNode===e?t:null:(t=f(e),null!=t&&t._hostNode===e?t:null)},getNodeFromInstance:function(e){if(e.tag===Bt||e.tag===Lt)return e.stateNode;if(void 0===e._hostNode&&r("33"),e._hostNode)return e._hostNode;for(var t=[];!e._hostNode;)t.push(e),e._hostParent||r("34"),e=e._hostParent;for(;t.length;e=t.pop())l(e,e._hostNode);return e._hostNode},precacheChildNodes:l,precacheNode:c,uncacheNode:function(e){var t=e._hostNode;t&&(delete t[Vt],e._hostNode=null)},precacheFiberNode:function(e,t){t[Vt]=e},getFiberCurrentPropsFromNode:function(e){return e[Jt]||null},updateFiberProps:function(e,t){e[Jt]=t}},$t={remove:function(e){e._reactInternalFiber=void 0},get:function(e){return e._reactInternalFiber},has:function(e){return void 0!==e._reactInternalFiber},set:function(e,t){e._reactInternalFiber=t}},Gt={ReactCurrentOwner:yt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner},Qt={NoEffect:0,PerformedWork:1,Placement:2,Update:4,PlacementAndUpdate:6,Deletion:8,ContentReset:16,Callback:32,Err:64,Ref:128},Yt=Nt.HostComponent,Xt=Nt.HostRoot,Zt=Nt.HostPortal,en=Nt.HostText,tn=Qt.NoEffect,nn=Qt.Placement,rn={isFiberMounted:function(e){return 2===h(e)},isMounted:function(e){return!!(e=$t.get(e))&&2===h(e)},findCurrentFiberUsingSlowPath:y,findCurrentHostFiber:function(e){if(!(e=y(e)))return null;for(var t=e;;){if(t.tag===Yt||t.tag===en)return t;if(t.child)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null},findCurrentHostFiberWithNoPortals:function(e){if(!(e=y(e)))return null;for(var t=e;;){if(t.tag===Yt||t.tag===en)return t;if(t.child&&t.tag!==Zt)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null}},an={_caughtError:null,_hasCaughtError:!1,_rethrowError:null,_hasRethrowError:!1,injection:{injectErrorUtils:function(e){"function"!=typeof e.invokeGuardedCallback&&r("197"),v=e.invokeGuardedCallback}},invokeGuardedCallback:function(e,t,n,r,i,a,o,s,u){v.apply(an,arguments)},invokeGuardedCallbackAndCatchFirstError:function(e,t,n,r,i,a,o,s,u){if(an.invokeGuardedCallback.apply(this,arguments),an.hasCaughtError()){var c=an.clearCaughtError();an._hasRethrowError||(an._hasRethrowError=!0,an._rethrowError=c)}},rethrowCaughtError:function(){return g.apply(an,arguments)},hasCaughtError:function(){return an._hasCaughtError},clearCaughtError:function(){if(an._hasCaughtError){var e=an._caughtError;return an._caughtError=null,an._hasCaughtError=!1,e}r("198")}},on=an,sn={isEndish:function(e){return"topMouseUp"===e||"topTouchEnd"===e||"topTouchCancel"===e},isMoveish:function(e){return"topMouseMove"===e||"topTouchMove"===e},isStartish:function(e){return"topMouseDown"===e||"topTouchStart"===e},executeDirectDispatch:function(e){var t=e._dispatchListeners,n=e._dispatchInstances;return Array.isArray(t)&&r("103"),e.currentTarget=t?sn.getNodeFromInstance(n):null,t=t?t(e):null,e.currentTarget=null,e._dispatchListeners=null,e._dispatchInstances=null,t},executeDispatchesInOrder:function(e,t){var n=e._dispatchListeners,r=e._dispatchInstances;if(Array.isArray(n))for(var i=0;ign.length&&gn.push(e)}}}},bn=mn,kn=null,wn={injection:{injectEventPluginOrder:Dt.injectEventPluginOrder,injectEventPluginsByName:Dt.injectEventPluginsByName},getListener:function(e,t){if("number"==typeof e.tag){var n=e.stateNode;if(!n)return null;var i=un.getFiberCurrentPropsFromNode(n);if(!i)return null;if(n=i[t],P(t,e.type,i))return null}else{if("string"==typeof(i=e._currentElement)||"number"==typeof i||!e._rootNodeID)return null;if(e=i.props,n=e[t],P(t,i.type,e))return null}return n&&"function"!=typeof n&&r("231",t,typeof n),n},extractEvents:function(e,t,n,r){for(var i,a=Dt.plugins,o=0;on||r.hasOverloadedBooleanValue&&!1===n?Un.deleteValueForProperty(e,t):r.mustUseProperty?e[r.propertyName]=n:(t=r.attributeName,(i=r.attributeNamespace)?e.setAttributeNS(i,t,""+n):r.hasBooleanValue||r.hasOverloadedBooleanValue&&!0===n?e.setAttribute(t,""):e.setAttribute(t,""+n))}else Un.setValueForAttribute(e,t,Tt.shouldSetAttribute(t,n)?n:null)},setValueForAttribute:function(e,t,n){T(t)&&(null==n?e.removeAttribute(t):e.setAttribute(t,""+n))},deleteValueForAttribute:function(e,t){e.removeAttribute(t)},deleteValueForProperty:function(e,t){var n=Tt.getPropertyInfo(t);n?(t=n.mutationMethod)?t(e,void 0):n.mustUseProperty?e[n.propertyName]=!n.hasBooleanValue&&"":e.removeAttribute(n.attributeName):e.removeAttribute(t)}},zn=Un,Kn=Gt.ReactDebugCurrentFrame,Wn={current:null,phase:null,resetCurrentFiber:function(){Kn.getCurrentStack=null,Wn.current=null,Wn.phase=null},setCurrentFiber:function(e,t){Kn.getCurrentStack=N,Wn.current=e,Wn.phase=t},getCurrentFiberOwnerName:function(){return null},getCurrentFiberStackAddendum:N},Vn=Wn,Jn={getHostProps:function(e,t){var n=t.value,r=t.checked;return gt({type:void 0,step:void 0,min:void 0,max:void 0},t,{defaultChecked:void 0,defaultValue:void 0,value:null!=n?n:e._wrapperState.initialValue,checked:null!=r?r:e._wrapperState.initialChecked})},initWrapperState:function(e,t){var n=t.defaultValue;e._wrapperState={initialChecked:null!=t.checked?t.checked:t.defaultChecked,initialValue:null!=t.value?t.value:n,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}},updateWrapper:function(e,t){var n=t.checked;null!=n&&zn.setValueForProperty(e,"checked",n||!1),n=t.value,null!=n?0===n&&""===e.value?e.value="0":"number"===t.type?(t=parseFloat(e.value)||0,(n!=t||n==t&&e.value!=n)&&(e.value=""+n)):e.value!==""+n&&(e.value=""+n):(null==t.value&&null!=t.defaultValue&&e.defaultValue!==""+t.defaultValue&&(e.defaultValue=""+t.defaultValue),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked))},postMountWrapper:function(e,t){switch(t.type){case"submit":case"reset":break;case"color":case"date":case"datetime":case"datetime-local":case"month":case"time":case"week":e.value="",e.value=e.defaultValue;break;default:e.value=e.value}t=e.name,""!==t&&(e.name=""),e.defaultChecked=!e.defaultChecked,e.defaultChecked=!e.defaultChecked,""!==t&&(e.name=t)},restoreControlledState:function(e,t){Jn.updateWrapper(e,t);var n=t.name;if("radio"===t.type&&null!=n){for(t=e;t.parentNode;)t=t.parentNode;for(n=t.querySelectorAll("input[name="+JSON.stringify(""+n)+'][type="radio"]'),t=0;t=t.length||r("93"),t=t[0]),n=""+t),null==n&&(n=""),i=n),e._wrapperState={initialValue:""+i}},updateWrapper:function(e,t){var n=t.value;null!=n&&(n=""+n,n!==e.value&&(e.value=n),null==t.defaultValue&&(e.defaultValue=n)),null!=t.defaultValue&&(e.defaultValue=t.defaultValue)},postMountWrapper:function(e){var t=e.textContent;t===e._wrapperState.initialValue&&(e.value=t)},restoreControlledState:function(e,t){Qn.updateWrapper(e,t)}},Yn=Qn,Xn=gt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),Zn={_getTrackerFromNode:function(e){return e._valueTracker},track:function(e){e._valueTracker||(e._valueTracker=U(e))},updateValueIfChanged:function(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=H(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)},stopTracking:function(e){(e=e._valueTracker)&&e.stopTracking()}},er=Rt.Namespaces,tr=function(e){return"undefined"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n)})}:e}(function(e,t){if(e.namespaceURI!==er.svg||"innerHTML"in e)e.innerHTML=t;else for(Nn=Nn||document.createElement("div"),Nn.innerHTML=""+t+"",t=Nn.firstChild;t.firstChild;)e.appendChild(t.firstChild)}),nr=/["'&<>]/,rr=jt.TEXT_NODE;vt.canUseDOM&&("textContent"in document.documentElement||(K=function(e,t){if(e.nodeType===rr)e.nodeValue=t;else{if("boolean"==typeof t||"number"==typeof t)t=""+t;else{t=""+t;var n=nr.exec(t);if(n){var r,i="",a=0;for(r=n.index;r<\/script>",e=e.removeChild(e.firstChild)):e="string"==typeof t.is?n.createElement(e,{is:t.is}):n.createElement(e):e=n.createElementNS(r,e),e},createTextNode:function(e,t){return(t.nodeType===ar?t:t.ownerDocument).createTextNode(e)},setInitialProperties:function(e,t,n,r){var i=z(t,n);switch(t){case"iframe":case"object":Fn.trapBubbledEvent("topLoad","load",e);var a=n;break;case"video":case"audio":for(a in fr)fr.hasOwnProperty(a)&&Fn.trapBubbledEvent(a,fr[a],e);a=n;break;case"source":Fn.trapBubbledEvent("topError","error",e),a=n;break;case"img":case"image":Fn.trapBubbledEvent("topError","error",e),Fn.trapBubbledEvent("topLoad","load",e),a=n;break;case"form":Fn.trapBubbledEvent("topReset","reset",e),Fn.trapBubbledEvent("topSubmit","submit",e),a=n;break;case"details":Fn.trapBubbledEvent("topToggle","toggle",e),a=n;break;case"input":qn.initWrapperState(e,n),a=qn.getHostProps(e,n),Fn.trapBubbledEvent("topInvalid","invalid",e),W(r,"onChange");break;case"option":$n.validateProps(e,n),a=$n.getHostProps(e,n);break;case"select":Gn.initWrapperState(e,n),a=Gn.getHostProps(e,n),Fn.trapBubbledEvent("topInvalid","invalid",e),W(r,"onChange");break;case"textarea":Yn.initWrapperState(e,n),a=Yn.getHostProps(e,n),Fn.trapBubbledEvent("topInvalid","invalid",e),W(r,"onChange");break;default:a=n}L(t,a);var o,s=a;for(o in s)if(s.hasOwnProperty(o)){var u=s[o];"style"===o?jn.setValueForStyles(e,u):"dangerouslySetInnerHTML"===o?null!=(u=u?u.__html:void 0)&&tr(e,u):"children"===o?"string"==typeof u?ir(e,u):"number"==typeof u&&ir(e,""+u):"suppressContentEditableWarning"!==o&&(ur.hasOwnProperty(o)?null!=u&&W(r,o):i?zn.setValueForAttribute(e,o,u):null!=u&&zn.setValueForProperty(e,o,u))}switch(t){case"input":Zn.track(e),qn.postMountWrapper(e,n);break;case"textarea":Zn.track(e),Yn.postMountWrapper(e,n);break;case"option":$n.postMountWrapper(e,n);break;case"select":Gn.postMountWrapper(e,n);break;default:"function"==typeof a.onClick&&(e.onclick=bt)}},diffProperties:function(e,t,n,r,i){var a=null;switch(t){case"input":n=qn.getHostProps(e,n),r=qn.getHostProps(e,r),a=[];break;case"option":n=$n.getHostProps(e,n),r=$n.getHostProps(e,r),a=[];break;case"select":n=Gn.getHostProps(e,n),r=Gn.getHostProps(e,r),a=[];break;case"textarea":n=Yn.getHostProps(e,n),r=Yn.getHostProps(e,r),a=[];break;default:"function"!=typeof n.onClick&&"function"==typeof r.onClick&&(e.onclick=bt)}L(t,r);var o,s;e=null;for(o in n)if(!r.hasOwnProperty(o)&&n.hasOwnProperty(o)&&null!=n[o])if("style"===o)for(s in t=n[o])t.hasOwnProperty(s)&&(e||(e={}),e[s]="");else"dangerouslySetInnerHTML"!==o&&"children"!==o&&"suppressContentEditableWarning"!==o&&(ur.hasOwnProperty(o)?a||(a=[]):(a=a||[]).push(o,null));for(o in r){var u=r[o];if(t=null!=n?n[o]:void 0,r.hasOwnProperty(o)&&u!==t&&(null!=u||null!=t))if("style"===o)if(t){for(s in t)!t.hasOwnProperty(s)||u&&u.hasOwnProperty(s)||(e||(e={}),e[s]="");for(s in u)u.hasOwnProperty(s)&&t[s]!==u[s]&&(e||(e={}),e[s]=u[s])}else e||(a||(a=[]),a.push(o,e)),e=u;else"dangerouslySetInnerHTML"===o?(u=u?u.__html:void 0,t=t?t.__html:void 0,null!=u&&t!==u&&(a=a||[]).push(o,""+u)):"children"===o?t===u||"string"!=typeof u&&"number"!=typeof u||(a=a||[]).push(o,""+u):"suppressContentEditableWarning"!==o&&(ur.hasOwnProperty(o)?(null!=u&&W(i,o),a||t===u||(a=[])):(a=a||[]).push(o,u))}return e&&(a=a||[]).push("style",e),a},updateProperties:function(e,t,n,r,i){z(n,r),r=z(n,i);for(var a=0;at&&(t=8),kr=t=V(c.priorityLevel,o);){n.first=c.next,null===n.first&&(n.last=null);var l;c.isReplace?(i=Q(c,r,i,a),u=!0):(l=Q(c,r,i,a))&&(i=u?gt({},i,l):gt(i,l),u=!1),c.isForced&&(s=!0),null===c.callback||c.isTopLevelUnmount&&null!==c.next||(e=null!==e?e:[],e.push(c.callback),t.effectTag|=Fr),c=c.next}return n.callbackList=e,n.hasForceUpdate=s,null!==n.first||null!==e||s||(t.updateQueue=null),i},commitCallbacks:function(e,t,n){if(null!==(e=t.callbackList))for(t.callbackList=null,t=0;tLr||(e.current=Br[Lr],Br[Lr]=null,Lr--)},push:function(e,t){Lr++,Br[Lr]=e.current,e.current=t},reset:function(){for(;-1e)?e:t}},fi=li.createHostRootFiber,pi=Nt.IndeterminateComponent,hi=Nt.FunctionalComponent,di=Nt.ClassComponent,yi=Nt.HostComponent;"function"==typeof Symbol&&Symbol.for?(_r=Symbol.for("react.coroutine"),Cr=Symbol.for("react.yield")):(_r=60104,Cr=60105);var vi={createCoroutine:function(e,t,n){var r=3t&&(r=t,t=i,i=r),r=ge(e,i),e=ge(e,t),r&&e){var a=document.createRange();a.setStart(r.node,r.offset),n.removeAllRanges(),i>t?(n.addRange(a),n.extend(e.node,e.offset)):(a.setEnd(e.node,e.offset),n.addRange(a))}}}},us=jt.ELEMENT_NODE,cs={hasSelectionCapabilities:function(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&"text"===e.type||"textarea"===t||"true"===e.contentEditable)},getSelectionInformation:function(){var e=_t();return{focusedElem:e,selectionRange:cs.hasSelectionCapabilities(e)?cs.getSelection(e):null}},restoreSelection:function(e){var t=_t(),n=e.focusedElem;if(e=e.selectionRange,t!==n&&xt(document.documentElement,n)){for(cs.hasSelectionCapabilities(n)&&cs.setSelection(n,e),t=[],e=n;e=e.parentNode;)e.nodeType===us&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(St(n),n=0;n=parseInt(Cs.version(),10))}var Is=_s,Rs=vt.canUseDOM&&(!xs||Ss&&8=Ss),Es=String.fromCharCode(32),Fs={beforeInput:{phasedRegistrationNames:{bubbled:"onBeforeInput",captured:"onBeforeInputCapture"},dependencies:["topCompositionEnd","topKeyPress","topTextInput","topPaste"]},compositionEnd:{phasedRegistrationNames:{bubbled:"onCompositionEnd",captured:"onCompositionEndCapture"},dependencies:"topBlur topCompositionEnd topKeyDown topKeyPress topKeyUp topMouseDown".split(" ")},compositionStart:{phasedRegistrationNames:{bubbled:"onCompositionStart",captured:"onCompositionStartCapture"},dependencies:"topBlur topCompositionStart topKeyDown topKeyPress topKeyUp topMouseDown".split(" ")},compositionUpdate:{phasedRegistrationNames:{bubbled:"onCompositionUpdate",captured:"onCompositionUpdateCapture"},dependencies:"topBlur topCompositionUpdate topKeyDown topKeyPress topKeyUp topMouseDown".split(" ")}},Ps=!1,Ds=!1,Os={eventTypes:Fs,extractEvents:function(e,t,n,r){var i;if(xs)e:{switch(e){case"topCompositionStart":var a=Fs.compositionStart;break e;case"topCompositionEnd":a=Fs.compositionEnd;break e;case"topCompositionUpdate":a=Fs.compositionUpdate;break e}a=void 0}else Ds?Te(e,n)&&(a=Fs.compositionEnd):"topKeyDown"===e&&229===n.keyCode&&(a=Fs.compositionStart);return a?(Rs&&(Ds||a!==Fs.compositionStart?a===Fs.compositionEnd&&Ds&&(i=ms.getData()):Ds=ms.initialize(r)),a=Me.getPooled(a,t,n,r),i?a.data=i:null!==(i=Ne(n))&&(a.data=i),ys.accumulateTwoPhaseDispatches(a),i=a):i=null,(e=Is?je(e,n):Be(e,n))?(t=Ae.getPooled(Fs.beforeInput,t,n,r),t.data=e,ys.accumulateTwoPhaseDispatches(t)):t=null,[i,t]}},Ms={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0},As={change:{phasedRegistrationNames:{bubbled:"onChange",captured:"onChangeCapture"},dependencies:"topBlur topChange topClick topFocus topInput topKeyDown topKeyUp topSelectionChange".split(" ")}},Ts=null,Ns=null,js=!1;vt.canUseDOM&&(js=D("input")&&(!document.documentMode||9=document.documentMode,Ws={select:{phasedRegistrationNames:{bubbled:"onSelect",captured:"onSelectCapture"},dependencies:"topBlur topContextMenu topFocus topKeyDown topKeyUp topMouseDown topMouseUp topSelectionChange".split(" ")}},Vs=null,Js=null,qs=null,$s=!1,Gs=Fn.isListeningToAllDependencies,Qs={eventTypes:Ws,extractEvents:function(e,t,n,r){var i=r.window===r?r.document:r.nodeType===zs?r:r.ownerDocument;if(!i||!Gs("onSelect",i))return null;switch(i=t?qt.getNodeFromInstance(t):window,e){case"topFocus":(Le(i)||"true"===i.contentEditable)&&(Vs=i,Js=t,qs=null);break;case"topBlur":qs=Js=Vs=null;break;case"topMouseDown":$s=!0;break;case"topContextMenu":case"topMouseUp":return $s=!1,et(n,r);case"topSelectionChange":if(Ks)break;case"topKeyDown":case"topKeyUp":return et(n,r)}return null}};Fe.augmentClass(tt,{animationName:null,elapsedTime:null,pseudoElement:null}),Fe.augmentClass(nt,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Qe.augmentClass(rt,{relatedTarget:null});var Ys={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Xs={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"};Qe.augmentClass(at,{key:function(e){if(e.key){var t=Ys[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?(e=it(e),13===e?"Enter":String.fromCharCode(e)):"keydown"===e.type||"keyup"===e.type?Xs[e.keyCode]||"Unidentified":""},location:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,repeat:null,locale:null,getModifierState:Xe,charCode:function(e){return"keypress"===e.type?it(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?it(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}}),Ze.augmentClass(ot,{dataTransfer:null}),Qe.augmentClass(st,{touches:null,targetTouches:null,changedTouches:null,altKey:null,metaKey:null,ctrlKey:null,shiftKey:null,getModifierState:Xe}),Fe.augmentClass(ut,{propertyName:null,elapsedTime:null,pseudoElement:null}),Ze.augmentClass(ct,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:null,deltaMode:null});var Zs={},eu={};"abort animationEnd animationIteration animationStart blur cancel canPlay canPlayThrough click close contextMenu copy cut doubleClick drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error focus input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing progress rateChange reset scroll seeked seeking stalled submit suspend timeUpdate toggle touchCancel touchEnd touchMove touchStart transitionEnd volumeChange waiting wheel".split(" ").forEach(function(e){var t=e[0].toUpperCase()+e.slice(1),n="on"+t;t="top"+t,n={phasedRegistrationNames:{bubbled:n,captured:n+"Capture"},dependencies:[t]},Zs[e]=n,eu[t]=n});var tu={eventTypes:Zs,extractEvents:function(e,t,n,i){var a=eu[e];if(!a)return null;switch(e){case"topAbort":case"topCancel":case"topCanPlay":case"topCanPlayThrough":case"topClose":case"topDurationChange":case"topEmptied":case"topEncrypted":case"topEnded":case"topError":case"topInput":case"topInvalid":case"topLoad":case"topLoadedData":case"topLoadedMetadata":case"topLoadStart":case"topPause":case"topPlay":case"topPlaying":case"topProgress":case"topRateChange":case"topReset":case"topSeeked":case"topSeeking":case"topStalled":case"topSubmit":case"topSuspend":case"topTimeUpdate":case"topToggle":case"topVolumeChange":case"topWaiting":var o=Fe;break;case"topKeyPress":if(0===it(n))return null;case"topKeyDown":case"topKeyUp":o=at;break;case"topBlur":case"topFocus":o=rt;break;case"topClick":if(2===n.button)return null;case"topDoubleClick":case"topMouseDown":case"topMouseMove":case"topMouseUp":case"topMouseOut":case"topMouseOver":case"topContextMenu":o=Ze;break;case"topDrag":case"topDragEnd":case"topDragEnter":case"topDragExit":case"topDragLeave":case"topDragOver":case"topDragStart":case"topDrop":o=ot;break;case"topTouchCancel":case"topTouchEnd":case"topTouchMove":case"topTouchStart":o=st;break;case"topAnimationEnd":case"topAnimationIteration":case"topAnimationStart":o=tt;break;case"topTransitionEnd":o=ut;break;case"topScroll":o=Qe;break;case"topWheel":o=ct;break;case"topCopy":case"topCut":case"topPaste":o=nt}return o||r("86",e),e=o.getPooled(a,t,n,i),ys.accumulateTwoPhaseDispatches(e),e}};bn.setHandleTopLevel(Fn.handleTopLevel),wn.injection.injectEventPluginOrder("ResponderEventPlugin SimpleEventPlugin TapEventPlugin EnterLeaveEventPlugin ChangeEventPlugin SelectEventPlugin BeforeInputEventPlugin".split(" ")),un.injection.injectComponentTree(qt),wn.injection.injectEventPluginsByName({SimpleEventPlugin:tu,EnterLeaveEventPlugin:Us,ChangeEventPlugin:Bs,SelectEventPlugin:Qs,BeforeInputEventPlugin:Os});var nu=Tt.injection.MUST_USE_PROPERTY,ru=Tt.injection.HAS_BOOLEAN_VALUE,iu=Tt.injection.HAS_NUMERIC_VALUE,au=Tt.injection.HAS_POSITIVE_NUMERIC_VALUE,ou=Tt.injection.HAS_STRING_BOOLEAN_VALUE,su={Properties:{allowFullScreen:ru,allowTransparency:ou,async:ru,autoPlay:ru,capture:ru,checked:nu|ru,cols:au,contentEditable:ou,controls:ru,default:ru,defer:ru,disabled:ru,download:Tt.injection.HAS_OVERLOADED_BOOLEAN_VALUE,draggable:ou,formNoValidate:ru,hidden:ru,loop:ru,multiple:nu|ru,muted:nu|ru,noValidate:ru,open:ru,playsInline:ru,readOnly:ru,required:ru,reversed:ru,rows:au,rowSpan:iu,scoped:ru,seamless:ru,selected:nu|ru,size:au,start:iu,span:au,spellCheck:ou,style:0,itemScope:ru,acceptCharset:0,className:0,htmlFor:0,httpEquiv:0,value:ou},DOMAttributeNames:{acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv"},DOMMutationMethods:{value:function(e,t){if(null==t)return e.removeAttribute("value");"number"!==e.type||!1===e.hasAttribute("value")?e.setAttribute("value",""+t):e.validity&&!e.validity.badInput&&e.ownerDocument.activeElement!==e&&e.setAttribute("value",""+t)}}},uu=Tt.injection.HAS_STRING_BOOLEAN_VALUE,cu={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},lu={Properties:{autoReverse:uu,externalResourcesRequired:uu,preserveAlpha:uu},DOMAttributeNames:{autoReverse:"autoReverse",externalResourcesRequired:"externalResourcesRequired",preserveAlpha:"preserveAlpha"},DOMAttributeNamespaces:{xlinkActuate:cu.xlink,xlinkArcrole:cu.xlink,xlinkHref:cu.xlink,xlinkRole:cu.xlink,xlinkShow:cu.xlink,xlinkTitle:cu.xlink,xlinkType:cu.xlink,xmlBase:cu.xml,xmlLang:cu.xml,xmlSpace:cu.xml}},fu=/[\-\:]([a-z])/g;"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode x-height xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xmlns:xlink xml:lang xml:space".split(" ").forEach(function(e){var t=e.replace(fu,lt);lu.Properties[t]=0,lu.DOMAttributeNames[t]=e}),Tt.injection.injectDOMPropertyConfig(su),Tt.injection.injectDOMPropertyConfig(lu);var pu=eo.injectInternals,hu=jt.ELEMENT_NODE,du=jt.TEXT_NODE,yu=jt.COMMENT_NODE,vu=jt.DOCUMENT_NODE,gu=jt.DOCUMENT_FRAGMENT_NODE,mu=Tt.ROOT_ATTRIBUTE_NAME,bu=Rt.getChildNamespace,ku=pr.createElement,wu=pr.createTextNode,xu=pr.setInitialProperties,Su=pr.diffProperties,_u=pr.updateProperties,Cu=pr.diffHydratedProperties,Iu=pr.diffHydratedText,Ru=pr.warnForDeletedHydratableElement,Eu=pr.warnForDeletedHydratableText,Fu=pr.warnForInsertedHydratedElement,Pu=pr.warnForInsertedHydratedText,Du=qt.precacheFiberNode,Ou=qt.updateFiberProps;pn.injection.injectFiberControlledHostComponent(pr),we._injectFiber(function(e){return Tu.findHostInstance(e)});var Mu=null,Au=null,Tu=function(e){var t=e.getPublicInstance;e=he(e);var n=e.scheduleUpdate,r=e.getPriorityContext;return{createContainer:function(e){var t=fi();return e={current:t,containerInfo:e,isScheduled:!1,nextScheduledRoot:null,context:null,pendingContext:null},t.stateNode=e},updateContainer:function(e,t,i,a){var o=t.current;i=ye(i),null===t.context?t.context=i:t.pendingContext=i,t=a,a=r(o,Rr.enableAsyncSubtreeAPI&&null!=e&&null!=e.type&&null!=e.type.prototype&&!0===e.type.prototype.unstable_isAsyncReactComponent),e={element:e},Xo(o,e,void 0===t?null:t,a),n(o,a)},batchedUpdates:e.batchedUpdates,unbatchedUpdates:e.unbatchedUpdates,deferredUpdates:e.deferredUpdates,flushSync:e.flushSync,getPublicRootInstance:function(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case ns:return t(e.child.stateNode);default:return e.child.stateNode}},findHostInstance:function(e){return e=rs(e),null===e?null:e.stateNode},findHostInstanceWithNoPortals:function(e){return e=is(e),null===e?null:e.stateNode}}}({getRootHostContext:function(e){if(e.nodeType===vu)e=(e=e.documentElement)?e.namespaceURI:bu(null,"");else{var t=e.nodeType===yu?e.parentNode:e;e=t.namespaceURI||null,t=t.tagName,e=bu(e,t)}return e},getChildHostContext:function(e,t){return bu(e,t)},getPublicInstance:function(e){return e},prepareForCommit:function(){Mu=Fn.isEnabled(),Au=ls.getSelectionInformation(),Fn.setEnabled(!1)},resetAfterCommit:function(){ls.restoreSelection(Au),Au=null,Fn.setEnabled(Mu),Mu=null},createInstance:function(e,t,n,r,i){return e=ku(e,t,n,r),Du(i,e),Ou(e,t),e},appendInitialChild:function(e,t){e.appendChild(t)},finalizeInitialChildren:function(e,t,n,r){xu(e,t,n,r);e:{switch(t){case"button":case"input":case"select":case"textarea":e=!!n.autoFocus;break e}e=!1}return e},prepareUpdate:function(e,t,n,r,i){return Su(e,t,n,r,i)},commitMount:function(e){e.focus()},commitUpdate:function(e,t,n,r,i){Ou(e,i),_u(e,t,n,r,i)},shouldSetTextContent:function(e,t){return"textarea"===e||"string"==typeof t.children||"number"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&"string"==typeof t.dangerouslySetInnerHTML.__html},resetTextContent:function(e){e.textContent=""},shouldDeprioritizeSubtree:function(e,t){return!!t.hidden},createTextInstance:function(e,t,n,r){return e=wu(e,t),Du(r,e),e},commitTextUpdate:function(e,t,n){e.nodeValue=n},appendChild:function(e,t){e.appendChild(t)},appendChildToContainer:function(e,t){e.nodeType===yu?e.parentNode.insertBefore(t,e):e.appendChild(t)},insertBefore:function(e,t,n){e.insertBefore(t,n)},insertInContainerBefore:function(e,t,n){e.nodeType===yu?e.parentNode.insertBefore(t,n):e.insertBefore(t,n)},removeChild:function(e,t){e.removeChild(t)},removeChildFromContainer:function(e,t){e.nodeType===yu?e.parentNode.removeChild(t):e.removeChild(t)},canHydrateInstance:function(e,t){return e.nodeType===hu&&t===e.nodeName.toLowerCase()},canHydrateTextInstance:function(e,t){return""!==t&&e.nodeType===du},getNextHydratableSibling:function(e){for(e=e.nextSibling;e&&e.nodeType!==hu&&e.nodeType!==du;)e=e.nextSibling;return e},getFirstHydratableChild:function(e){for(e=e.firstChild;e&&e.nodeType!==hu&&e.nodeType!==du;)e=e.nextSibling;return e},hydrateInstance:function(e,t,n,r,i,a){return Du(a,e),Ou(e,n),Cu(e,t,n,i,r)},hydrateTextInstance:function(e,t,n){return Du(n,e),Iu(e,t)},didNotHydrateInstance:function(e,t){1===t.nodeType?Ru(e,t):Eu(e,t)},didNotFindHydratableInstance:function(e,t,n){Fu(e,t,n)},didNotFindHydratableTextInstance:function(e,t){Pu(e,t)},scheduleDeferredCallback:Ir.rIC,useSyncScheduling:!0});dn.injection.injectFiberBatchedUpdates(Tu.batchedUpdates);var Nu={createPortal:dt,hydrate:function(e,t,n){return ht(null,e,t,!0,n)},render:function(e,t,n){return ht(null,e,t,!1,n)},unstable_renderSubtreeIntoContainer:function(e,t,n,i){return null!=e&&$t.has(e)||r("38"),ht(e,t,n,!1,i)},unmountComponentAtNode:function(e){return ft(e)||r("40"),!!e._reactRootContainer&&(Tu.unbatchedUpdates(function(){ht(null,null,e,!1,function(){e._reactRootContainer=null})}),!0)},findDOMNode:we,unstable_createPortal:dt,unstable_batchedUpdates:dn.batchedUpdates,unstable_deferredUpdates:Tu.deferredUpdates,flushSync:Tu.flushSync,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{EventPluginHub:wn,EventPluginRegistry:Dt,EventPropagators:ys,ReactControlledComponent:pn,ReactDOMComponentTree:qt,ReactDOMEventListener:bn}};pu({findFiberByHostInstance:qt.getClosestInstanceFromNode,findHostInstanceByFiber:Tu.findHostInstance,bundleType:0,version:"16.0.1",rendererPackageName:"react-dom"}),e.exports=Nu},function(e,t,n){"use strict";var r=!("undefined"==typeof window||!window.document||!window.document.createElement),i={canUseDOM:r,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:r&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:r&&!!window.screen,isInWorker:!r};e.exports=i},function(e,t,n){"use strict";var r=n(1),i={listen:function(e,t,n){return e.addEventListener?(e.addEventListener(t,n,!1),{remove:function(){e.removeEventListener(t,n,!1)}}):e.attachEvent?(e.attachEvent("on"+t,n),{remove:function(){e.detachEvent("on"+t,n)}}):void 0},capture:function(e,t,n){return e.addEventListener?(e.addEventListener(t,n,!0),{remove:function(){e.removeEventListener(t,n,!0)}}):{remove:r}},registerDefault:function(){}};e.exports=i},function(e,t,n){"use strict";function r(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!==e&&t!==t}function i(e,t){if(r(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var o=0;o0&&(r=r.concat(i)),r}},{key:"isMobile",get:function(){return g.a.get().filesafe.isMobile()}}]),t}(v.a.Component)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=n.n(r),a=n(2),o=n.n(a),s=n(5);t.default={FilesafeEmbed:s.a,React:i.a,ReactDOM:o.a}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?o(e):t}function o(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){for(var n=0;n1&&!t.content.isDefault&&d.a.createElement("a",{className:"info",onClick:function(){e.setCredentialAsDefault(t)}},"Make Default"),d.a.createElement("a",{className:"info",onClick:function(){e.exportCredential(t)}},"Export"),d.a.createElement("a",{className:"danger",onClick:function(){e.deleteCredential(t)}},"Delete")))))})))}}]),t}(d.a.Component)},function(e,t){e.exports=function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,n){(function(t){var n,n;!function(t){e.exports=t()}(function(){return function(){function e(t,r,i){function a(s,u){if(!r[s]){if(!t[s]){var c="function"==typeof n&&n;if(!u&&c)return n(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var f=r[s]={exports:{}};t[s][0].call(f.exports,function(e){return a(t[s][1][e]||e)},f,f.exports,e,t,r,i)}return r[s].exports}for(var o="function"==typeof n&&n,s=0;s>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,o=0;4>o&&i+.75*o>>6*(3-o)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var n=e.length,r=this._map,i=r.charAt(64);i&&-1!=(i=e.indexOf(i))&&(n=i);for(var i=[],a=0,o=0;o>>6-o%4*2;i[a>>>2]|=(s|u)<<24-a%4*8,a++}return t.create(i,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){function t(e,t,n,r,i,a,o){return((e=e+(t&n|~t&r)+i+o)<>>32-a)+t}function n(e,t,n,r,i,a,o){return((e=e+(t&r|n&~r)+i+o)<>>32-a)+t}function r(e,t,n,r,i,a,o){return((e=e+(t^n^r)+i+o)<>>32-a)+t}function i(e,t,n,r,i,a,o){return((e=e+(n^(t|~r))+i+o)<>>32-a)+t}for(var a=o,s=a.lib,u=s.WordArray,c=s.Hasher,s=a.algo,l=[],f=0;64>f;f++)l[f]=4294967296*e.abs(e.sin(f+1))|0;s=s.MD5=c.extend({_doReset:function(){this._hash=new u.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,a){for(var o=0;16>o;o++){var s=a+o,u=e[s];e[s]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}var o=this._hash.words,s=e[a+0],u=e[a+1],c=e[a+2],f=e[a+3],p=e[a+4],h=e[a+5],d=e[a+6],y=e[a+7],v=e[a+8],g=e[a+9],m=e[a+10],b=e[a+11],k=e[a+12],w=e[a+13],x=e[a+14],S=e[a+15],_=o[0],C=o[1],I=o[2],R=o[3],_=t(_,C,I,R,s,7,l[0]),R=t(R,_,C,I,u,12,l[1]),I=t(I,R,_,C,c,17,l[2]),C=t(C,I,R,_,f,22,l[3]),_=t(_,C,I,R,p,7,l[4]),R=t(R,_,C,I,h,12,l[5]),I=t(I,R,_,C,d,17,l[6]),C=t(C,I,R,_,y,22,l[7]),_=t(_,C,I,R,v,7,l[8]),R=t(R,_,C,I,g,12,l[9]),I=t(I,R,_,C,m,17,l[10]),C=t(C,I,R,_,b,22,l[11]),_=t(_,C,I,R,k,7,l[12]),R=t(R,_,C,I,w,12,l[13]),I=t(I,R,_,C,x,17,l[14]),C=t(C,I,R,_,S,22,l[15]),_=n(_,C,I,R,u,5,l[16]),R=n(R,_,C,I,d,9,l[17]),I=n(I,R,_,C,b,14,l[18]),C=n(C,I,R,_,s,20,l[19]),_=n(_,C,I,R,h,5,l[20]),R=n(R,_,C,I,m,9,l[21]),I=n(I,R,_,C,S,14,l[22]),C=n(C,I,R,_,p,20,l[23]),_=n(_,C,I,R,g,5,l[24]),R=n(R,_,C,I,x,9,l[25]),I=n(I,R,_,C,f,14,l[26]),C=n(C,I,R,_,v,20,l[27]),_=n(_,C,I,R,w,5,l[28]),R=n(R,_,C,I,c,9,l[29]),I=n(I,R,_,C,y,14,l[30]),C=n(C,I,R,_,k,20,l[31]),_=r(_,C,I,R,h,4,l[32]),R=r(R,_,C,I,v,11,l[33]),I=r(I,R,_,C,b,16,l[34]),C=r(C,I,R,_,x,23,l[35]),_=r(_,C,I,R,u,4,l[36]),R=r(R,_,C,I,p,11,l[37]),I=r(I,R,_,C,y,16,l[38]),C=r(C,I,R,_,m,23,l[39]),_=r(_,C,I,R,w,4,l[40]),R=r(R,_,C,I,s,11,l[41]),I=r(I,R,_,C,f,16,l[42]),C=r(C,I,R,_,d,23,l[43]),_=r(_,C,I,R,g,4,l[44]),R=r(R,_,C,I,k,11,l[45]),I=r(I,R,_,C,S,16,l[46]),C=r(C,I,R,_,c,23,l[47]),_=i(_,C,I,R,s,6,l[48]),R=i(R,_,C,I,y,10,l[49]),I=i(I,R,_,C,x,15,l[50]),C=i(C,I,R,_,h,21,l[51]),_=i(_,C,I,R,k,6,l[52]),R=i(R,_,C,I,f,10,l[53]),I=i(I,R,_,C,m,15,l[54]),C=i(C,I,R,_,u,21,l[55]),_=i(_,C,I,R,v,6,l[56]),R=i(R,_,C,I,S,10,l[57]),I=i(I,R,_,C,d,15,l[58]),C=i(C,I,R,_,w,21,l[59]),_=i(_,C,I,R,p,6,l[60]),R=i(R,_,C,I,b,10,l[61]),I=i(I,R,_,C,c,15,l[62]),C=i(C,I,R,_,g,21,l[63]);o[0]=o[0]+_|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+R|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var a=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),t=this._hash,n=t.words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=c.clone.call(this);return e._hash=this._hash.clone(),e}}),a.MD5=c._createHelper(s),a.HmacMD5=c._createHmacHelper(s)}(Math),function(){var e=o,t=e.lib,n=t.Base,r=t.WordArray,t=e.algo,i=t.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=this.cfg,i=n.hasher.create(),a=r.create(),o=a.words,s=n.keySize,n=n.iterations;o.length>>2]}},n.BlockCipher=c.extend({cfg:c.cfg.extend({mode:l,padding:p}),reset:function(){c.reset.call(this);var e=this.cfg,t=e.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(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var h=n.CipherParams=r.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),l=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return e=e.salt,(e?i.create([1398893684,1701076831]).concat(e).concat(t):t).toString(s)},parse:function(e){e=s.parse(e);var t=e.words;if(1398893684==t[0]&&1701076831==t[1]){var n=i.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return h.create({ciphertext:e,salt:n})}},d=n.SerializableCipher=r.extend({cfg:r.extend({format:l}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,h.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),t=(t.kdf={}).OpenSSL={execute:function(e,t,n,r){return r||(r=i.random(8)),e=u.create({keySize:t+n}).compute(e,r),n=i.create(e.words.slice(t),4*n),e.sigBytes=4*t,h.create({key:e,iv:n,salt:r})}},y=n.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:t}),encrypt:function(e,t,n,r){return r=this.cfg.extend(r),n=r.kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,e=d.encrypt.call(this,e,t,n.key,r),e.mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,d.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=o,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],a=[],s=[],u=[],c=[],l=[],f=[],p=[],h=[],d=[],y=0;256>y;y++)d[y]=128>y?y<<1:y<<1^283;for(var v=0,g=0,y=0;256>y;y++){var m=g^g<<1^g<<2^g<<3^g<<4,m=m>>>8^255&m^99;r[v]=m,i[m]=v;var b=d[v],k=d[b],w=d[k],x=257*d[m]^16843008*m;a[v]=x<<24|x>>>8,s[v]=x<<16|x>>>16,u[v]=x<<8|x>>>24,c[v]=x,x=16843009*w^65537*k^257*b^16843008*v,l[m]=x<<24|x>>>8,f[m]=x<<16|x>>>16,p[m]=x<<8|x>>>24,h[m]=x,v?(v=b^d[d[d[w^b]]],g^=d[d[g]]):v=g=1}var S=[0,1,2,4,8,16,32,64,128,27,54],n=n.AES=t.extend({_doReset:function(){for(var e=this._key,t=e.words,n=e.sigBytes/4,e=4*((this._nRounds=n+6)+1),i=this._keySchedule=[],a=0;a>>24]<<24|r[o>>>16&255]<<16|r[o>>>8&255]<<8|r[255&o]):(o=o<<8|o>>>24,o=r[o>>>24]<<24|r[o>>>16&255]<<16|r[o>>>8&255]<<8|r[255&o],o^=S[a/n|0]<<24),i[a]=i[a-n]^o}for(t=this._invKeySchedule=[],n=0;nn||4>=a?o:l[r[o>>>24]]^f[r[o>>>16&255]]^p[r[o>>>8&255]]^h[r[255&o]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,u,c,r)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,l,f,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,a,o,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],f=e[t+2]^n[2],p=e[t+3]^n[3],h=4,d=1;d>>24]^i[l>>>16&255]^a[f>>>8&255]^o[255&p]^n[h++],v=r[l>>>24]^i[f>>>16&255]^a[p>>>8&255]^o[255&c]^n[h++],g=r[f>>>24]^i[p>>>16&255]^a[c>>>8&255]^o[255&l]^n[h++],p=r[p>>>24]^i[c>>>16&255]^a[l>>>8&255]^o[255&f]^n[h++],c=y,l=v,f=g;y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[f>>>8&255]<<8|s[255&p])^n[h++],v=(s[l>>>24]<<24|s[f>>>16&255]<<16|s[p>>>8&255]<<8|s[255&c])^n[h++],g=(s[f>>>24]<<24|s[p>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[h++],p=(s[p>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&f])^n[h++],e[t]=y,e[t+1]=v,e[t+2]=g,e[t+3]=p},keySize:8});e.AES=t._createHelper(n)}();var o=o||function(e,t){var n={},r=n.lib={},i=function(){},a=r.Base={extend:function(e){i.prototype=this;var t=new i;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=r.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;ul;){var f;e:{f=c;for(var p=e.sqrt(f),h=2;h<=p;h++)if(!(f%h)){f=!1;break e}f=!0}f&&(8>l&&(a[l]=u(e.pow(c,.5))),s[l]=u(e.pow(c,1/3)),l++),c++}var d=[],n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],a=n[2],o=n[3],u=n[4],c=n[5],l=n[6],f=n[7],p=0;64>p;p++){if(16>p)d[p]=0|e[t+p];else{var h=d[p-15],y=d[p-2];d[p]=((h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3)+d[p-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+d[p-16]}h=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[p]+d[p],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&a^i&a),f=l,l=c,c=u,u=o+h|0,o=a,a=i,i=r,r=h+y|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+f|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(n),t.HmacSHA256=i._createHmacHelper(n)}(Math),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var a=this._oKey=n.clone(),o=this._iKey=n.clone(),s=a.words,u=o.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;uc;c++)u[c]=e();r=r.SHA512=n.extend({_doReset:function(){this._hash=new a.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],a=n[2],o=n[3],c=n[4],l=n[5],f=n[6],n=n[7],p=r.high,h=r.low,d=i.high,y=i.low,v=a.high,g=a.low,m=o.high,b=o.low,k=c.high,w=c.low,x=l.high,S=l.low,_=f.high,C=f.low,I=n.high,R=n.low,E=p,F=h,P=d,D=y,O=v,M=g,A=m,T=b,N=k,j=w,B=x,L=S,H=_,U=C,z=I,K=R,W=0;80>W;W++){var V=u[W];if(16>W)var J=V.high=0|e[t+2*W],q=V.low=0|e[t+2*W+1];else{var J=u[W-15],q=J.high,$=J.low,J=(q>>>1|$<<31)^(q>>>8|$<<24)^q>>>7,$=($>>>1|q<<31)^($>>>8|q<<24)^($>>>7|q<<25),G=u[W-2],q=G.high,Q=G.low,G=(q>>>19|Q<<13)^(q<<3|Q>>>29)^q>>>6,Q=(Q>>>19|q<<13)^(Q<<3|q>>>29)^(Q>>>6|q<<26),q=u[W-7],Y=q.high,X=u[W-16],Z=X.high,X=X.low,q=$+q.low,J=J+Y+(q>>>0<$>>>0?1:0),q=q+Q,J=J+G+(q>>>0>>0?1:0),q=q+X,J=J+Z+(q>>>0>>0?1:0);V.high=J,V.low=q}var Y=N&B^~N&H,X=j&L^~j&U,V=E&P^E&O^P&O,ee=F&D^F&M^D&M,$=(E>>>28|F<<4)^(E<<30|F>>>2)^(E<<25|F>>>7),G=(F>>>28|E<<4)^(F<<30|E>>>2)^(F<<25|E>>>7),Q=s[W],te=Q.high,ne=Q.low,Q=K+((j>>>14|N<<18)^(j>>>18|N<<14)^(j<<23|N>>>9)),Z=z+((N>>>14|j<<18)^(N>>>18|j<<14)^(N<<23|j>>>9))+(Q>>>0>>0?1:0),Q=Q+X,Z=Z+Y+(Q>>>0>>0?1:0),Q=Q+ne,Z=Z+te+(Q>>>0>>0?1:0),Q=Q+q,Z=Z+J+(Q>>>0>>0?1:0),q=G+ee,V=$+V+(q>>>0>>0?1:0),z=H,K=U,H=B,U=L,B=N,L=j,j=T+Q|0,N=A+Z+(j>>>0>>0?1:0)|0,A=O,T=M,O=P,M=D,P=E,D=F,F=Q+q|0,E=Z+V+(F>>>0>>0?1:0)|0}h=r.low=h+F,r.high=p+E+(h>>>0>>0?1:0),y=i.low=y+D,i.high=d+P+(y>>>0>>0?1:0),g=a.low=g+M,a.high=v+O+(g>>>0>>0?1:0),b=o.low=b+T,o.high=m+A+(b>>>0>>0?1:0),w=c.low=w+j,c.high=k+N+(w>>>0>>0?1:0),S=l.low=S+L,l.high=x+B+(S>>>0>>0?1:0),C=f.low=C+U,f.high=_+H+(C>>>0>>0?1:0),R=n.low=R+K,n.high=I+z+(R>>>0>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(r+128>>>10<<5)]=Math.floor(n/4294967296),t[31+(r+128>>>10<<5)]=n,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32}),t.SHA512=n._createHelper(r),t.HmacSHA512=n._createHmacHelper(r)}(),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var a=this._oKey=n.clone(),o=this._iKey=n.clone(),s=a.words,u=o.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;uc;c++){if(16>c)i[c]=0|e[t+c];else{var l=i[c-3]^i[c-8]^i[c-14]^i[c-16];i[c]=l<<1|l>>>31}l=(r<<5|r>>>27)+u+i[c],l=20>c?l+(1518500249+(a&o|~a&s)):40>c?l+(1859775393+(a^o^s)):60>c?l+((a&o|a&s|o&s)-1894007588):l+((a^o^s)-899497514),u=s,s=o,o=a<<30|a>>>2,a=r,r=l}n[0]=n[0]+r|0,n[1]=n[1]+a|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});e.SHA1=r._createHelper(t),e.HmacSHA1=r._createHmacHelper(t)}(),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var a=this._oKey=n.clone(),o=this._iKey=n.clone(),s=a.words,u=o.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;uc;c++){if(16>c)i[c]=0|e[t+c];else{var l=i[c-3]^i[c-8]^i[c-14]^i[c-16];i[c]=l<<1|l>>>31}l=(r<<5|r>>>27)+u+i[c],l=20>c?l+(1518500249+(a&o|~a&s)):40>c?l+(1859775393+(a^o^s)):60>c?l+((a&o|a&s|o&s)-1894007588):l+((a^o^s)-899497514),u=s,s=o,o=a<<30|a>>>2,a=r,r=l}n[0]=n[0]+r|0,n[1]=n[1]+a|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});e.SHA1=r._createHelper(t),e.HmacSHA1=r._createHmacHelper(t)}(),Object.defineProperty(r,"__esModule",{value:!0});var s,u=function(){function e(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l=function(){function e(e,t){for(var n=0;n=200&&c.status<=299?s.$timeout(function(){a(e),i(e)}):(console.error("Request error:",e),s.$timeout(function(){o(e,c.status),u(e)}))}},"get"==t&&Object.keys(r).length>0&&(n+=s.formatParams(r)),c.open(t,n,!0),e.next=6,s.setAuthHeadersForRequest(c);case 6:c.setRequestHeader("Content-type","application/json"),"post"==t||"patch"==t?c.send(JSON.stringify(r)):c.send();case 8:case"end":return e.stop()}},e,s)}));return function(t,n){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"formatParams",value:function(e){return"?"+Object.keys(e).map(function(t){return t+"="+encodeURIComponent(e[t])}).join("&")}}]),e}(),y=r.SFMigrationManager=function(){function e(t,n,r,o){var s=this;a(this,e),this.modelManager=t,this.syncManager=n,this.storageManager=r,this.completionHandlers=[],this.loadMigrations();var u=!1,c=o.addEventHandler(function(e){e==p.DidSignInEvent&&(u=!0)});this.syncManager.addEventHandler(function(){var e=i(regeneratorRuntime.mark(function e(t,n){var r,i,a,l,f,p,h,d,y,v;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r="local-data-loaded"==t,i="sync:completed"==t,!r&&!i){e.next=40;break}if(r?s.receivedLocalDataEvent=!0:i&&(s.receivedSyncCompletedEvent=!0),!s.receivedLocalDataEvent||!s.receivedSyncCompletedEvent){e.next=40;break}if(!u){e.next=39;break}return u=!1,o.removeEventHandler(c),e.next=10,s.getCompletedMigrations();case 10:a=e.sent.slice(),l=!0,f=!1,p=void 0,e.prev=14,h=a[Symbol.iterator]();case 16:if(l=(d=h.next()).done){e.next=25;break}return y=d.value,e.next=20,s.migrationForEncodedName(y);case 20:v=e.sent,v.runOnlyOnce||_.pull(s._completed,y);case 22:l=!0,e.next=16;break;case 25:e.next=31;break;case 27:e.prev=27,e.t0=e.catch(14),f=!0,p=e.t0;case 31:e.prev=31,e.prev=32,!l&&h.return&&h.return();case 34:if(e.prev=34,!f){e.next=37;break}throw p;case 37:return e.finish(34);case 38:return e.finish(31);case 39:s.runPendingMigrations();case 40:case"end":return e.stop()}},e,s,[[14,27,31,39],[32,,34,38]])}));return function(t,n){return e.apply(this,arguments)}}())}return l(e,[{key:"addCompletionHandler",value:function(e){this.completionHandlers.push(e)}},{key:"removeCompletionHandler",value:function(e){_.pull(this.completionHandlers,e)}},{key:"migrationForEncodedName",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.decode(t);case 2:return n=e.sent,e.abrupt("return",this.migrations.find(function(e){return e.name==n}));case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"loadMigrations",value:function(){this.migrations=this.registeredMigrations()}},{key:"registeredMigrations",value:function(){}},{key:"runPendingMigrations",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a,o,s,u,c,l,f,p,h,d,y,v,g,m,b,k,w,x,S,_,C,I,R,E,F;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPendingMigrations();case 2:for(t=e.sent,n=!0,r=!1,i=void 0,e.prev=6,a=t[Symbol.iterator]();!(n=(o=a.next()).done);n=!0)s=o.value,s.items=[];e.next=14;break;case 10:e.prev=10,e.t0=e.catch(6),r=!0,i=e.t0;case 14:e.prev=14,e.prev=15,!n&&a.return&&a.return();case 17:if(e.prev=17,!r){e.next=20;break}throw i;case 20:return e.finish(17);case 21:return e.finish(14);case 22:u=!0,c=!1,l=void 0,e.prev=25,f=this.modelManager.allNondummyItems[Symbol.iterator]();case 27:if(u=(p=f.next()).done){e.next=51;break}for(h=p.value,d=!0,y=!1,v=void 0,e.prev=32,g=t[Symbol.iterator]();!(d=(m=g.next()).done);d=!0)s=m.value,h.content_type==s.content_type&&s.items.push(h);e.next=40;break;case 36:e.prev=36,e.t1=e.catch(32),y=!0,v=e.t1;case 40:e.prev=40,e.prev=41,!d&&g.return&&g.return();case 43:if(e.prev=43,!y){e.next=46;break}throw v;case 46:return e.finish(43);case 47:return e.finish(40);case 48:u=!0,e.next=27;break;case 51:e.next=57;break;case 53:e.prev=53,e.t2=e.catch(25),c=!0,l=e.t2;case 57:e.prev=57,e.prev=58,!u&&f.return&&f.return();case 60:if(e.prev=60,!c){e.next=63;break}throw l;case 63:return e.finish(60);case 64:return e.finish(57);case 65:b=!0,k=!1,w=void 0,e.prev=68,x=t[Symbol.iterator]();case 70:if(b=(S=x.next()).done){e.next=81;break}if(s=S.value,!(s.items&&s.items.length>0||s.customHandler)){e.next=77;break}return e.next=75,this.runMigration(s,s.items);case 75:e.next=78;break;case 77:this.markMigrationCompleted(s);case 78:b=!0,e.next=70;break;case 81:e.next=87;break;case 83:e.prev=83,e.t3=e.catch(68),k=!0,w=e.t3;case 87:e.prev=87,e.prev=88,!b&&x.return&&x.return();case 90:if(e.prev=90,!k){e.next=93;break}throw w;case 93:return e.finish(90);case 94:return e.finish(87);case 95:for(_=!0,C=!1,I=void 0,e.prev=98,R=this.completionHandlers[Symbol.iterator]();!(_=(E=R.next()).done);_=!0)(F=E.value)();e.next=106;break;case 102:e.prev=102,e.t4=e.catch(98),C=!0,I=e.t4;case 106:e.prev=106,e.prev=107,!_&&R.return&&R.return();case 109:if(e.prev=109,!C){e.next=112;break}throw I;case 112:return e.finish(109);case 113:return e.finish(106);case 114:case"end":return e.stop()}},e,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]])}));return e}()},{key:"encode",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",window.btoa(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"decode",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",window.atob(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"getCompletedMigrations",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._completed){e.next=5;break}return e.next=3,this.storageManager.getItem("migrations");case 3:t=e.sent,this._completed=t?JSON.parse(t):[];case 5:return e.abrupt("return",this._completed);case 6:case"end":return e.stop()}},e,this)}));return e}()},{key:"getPendingMigrations",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a,o,s,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getCompletedMigrations();case 2:t=e.sent,n=[],r=!0,i=!1,a=void 0,e.prev=7,o=this.migrations[Symbol.iterator]();case 9:if(r=(s=o.next()).done){e.next=22;break}return u=s.value,e.t0=t,e.next=14,this.encode(u.name);case 14:if(e.t1=e.sent,e.t2=e.t0.indexOf.call(e.t0,e.t1),e.t3=-1,e.t2!=e.t3){e.next=19;break}n.push(u);case 19:r=!0,e.next=9;break;case 22:e.next=28;break;case 24:e.prev=24,e.t4=e.catch(7),i=!0,a=e.t4;case 28:e.prev=28,e.prev=29,!r&&o.return&&o.return();case 31:if(e.prev=31,!i){e.next=34;break}throw a;case 34:return e.finish(31);case 35:return e.finish(28);case 36:return e.abrupt("return",n);case 37:case"end":return e.stop()}},e,this,[[7,24,28,36],[29,,31,35]])}));return e}()},{key:"markMigrationCompleted",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getCompletedMigrations();case 2:return n=e.sent,e.t0=n,e.next=6,this.encode(t.name);case 6:e.t1=e.sent,e.t0.push.call(e.t0,e.t1),this.storageManager.setItem("migrations",JSON.stringify(n)),t.running=!1;case 10:case"end":return e.stop()}},e,this)}));return e}()},{key:"runMigration",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.running){e.next=2;break}return e.abrupt("return");case 2:if(console.log("Running migration:",t.name),t.running=!0,!t.customHandler){e.next=8;break}return e.abrupt("return",t.customHandler().then(function(){r.markMigrationCompleted(t)}));case 8:return e.abrupt("return",t.handler(n).then(function(){r.markMigrationCompleted(t)}));case 9:case"end":return e.stop()}},e,this)}));return e}()}]),e}(),v=r.SFModelManager=function(){function e(t){a(this,e),e.MappingSourceRemoteRetrieved="MappingSourceRemoteRetrieved",e.MappingSourceRemoteSaved="MappingSourceRemoteSaved",e.MappingSourceLocalSaved="MappingSourceLocalSaved",e.MappingSourceLocalRetrieved="MappingSourceLocalRetrieved",e.MappingSourceComponentRetrieved="MappingSourceComponentRetrieved",e.MappingSourceDesktopInstalled="MappingSourceDesktopInstalled",e.MappingSourceRemoteActionRetrieved="MappingSourceRemoteActionRetrieved",e.MappingSourceFileImport="MappingSourceFileImport",e.isMappingSourceRetrieved=function(t){return[e.MappingSourceRemoteRetrieved,e.MappingSourceComponentRetrieved,e.MappingSourceRemoteActionRetrieved].includes(t)},this.$timeout=t||setTimeout.bind(window),this.itemSyncObservers=[],this.itemsPendingRemoval=[],this.items=[],this.itemsHash={},this.missedReferences={},this.uuidChangeObservers=[]}return l(e,[{key:"handleSignout",value:function(){this.items.length=0,this.itemsHash={},this.itemsPendingRemoval.length=0,this.missedReferences={}}},{key:"addModelUuidChangeObserver",value:function(e,t){this.uuidChangeObservers.push({id:e,callback:t})}},{key:"notifyObserversOfUuidChange",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.uuidChangeObservers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){a.value.callback(e,t)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"alternateUUIDForItem",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.createItem(n,!0),t.next=3,SFJS.crypto.generateUUID();case 3:for(r.uuid=t.sent,r.informReferencesOfUUIDChange(n.uuid,r.uuid),this.informModelsOfUUIDChangeForItem(r,n.uuid,r.uuid),i=!0,a=!1,o=void 0,t.prev=9,s=n.referencingObjects[Symbol.iterator]();!(i=(u=s.next()).done);i=!0)c=u.value,c.setIsNoLongerBeingReferencedBy(n),n.setIsNoLongerBeingReferencedBy(c),c.addItemAsRelationship(r),c.setDirty(!0);t.next=17;break;case 13:t.prev=13,t.t0=t.catch(9),a=!0,o=t.t0;case 17:t.prev=17,t.prev=18,!i&&s.return&&s.return();case 20:if(t.prev=20,!a){t.next=23;break}throw o;case 23:return t.finish(20);case 24:return t.finish(17);case 25:return this.resolveReferencesForItem(r),console.log(n.uuid,"--\x3e",r.uuid),n.deleted=!0,n.content.references=[],n.setDirty(!1),this.mapResponseItemsToLocalModels([n],e.MappingSourceLocalSaved),this.addItem(r),r.setDirty(!0),this.notifyObserversOfUuidChange(n,r),t.abrupt("return",r);case 35:case"end":return t.stop()}},t,this,[[9,13,17,25],[18,,20,24]])}));return t}()},{key:"informModelsOfUUIDChangeForItem",value:function(e,t,n){var r=!0,i=!1,a=void 0;try{for(var o,s=this.items[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){o.value.potentialItemOfInterestHasChangedItsUUID(e,t,n)}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}}},{key:"didSyncModelsOffline",value:function(t){this.notifySyncObserversOfModels(t,e.MappingSourceLocalSaved)}},{key:"mapResponseItemsToLocalModels",value:function(e,t,n){return this.mapResponseItemsToLocalModelsWithOptions({items:e,source:t,sourceKey:n})}},{key:"mapResponseItemsToLocalModelsOmittingFields",value:function(e,t,n,r){return this.mapResponseItemsToLocalModelsWithOptions({items:e,omitFields:t,source:n,sourceKey:r})}},{key:"mapResponseItemsToLocalModelsWithOptions",value:function(e){var t=e.items,n=e.omitFields,r=e.source,i=e.sourceKey,a=(e.options,[]),o=[],s=[],c=!0,l=!1,f=void 0;try{for(var p,h=t[Symbol.iterator]();!(c=(p=h.next()).done);c=!0){var d=p.value;if(d){var y=!d.content&&!d.errorDecrypting;if(!(!d.content_type||!d.uuid)&&!y||d.deleted){if(Array.isArray(n)){var v=!0,g=!1,m=void 0;try{for(var b,k=n[Symbol.iterator]();!(v=(b=k.next()).done);v=!0){delete d[b.value]}}catch(e){g=!0,m=e}finally{try{!v&&k.return&&k.return()}finally{if(g)throw m}}}var w=this.findItem(d.uuid);if(w&&(w.updateFromJSON(d),w.dummy=!1),this.itemsPendingRemoval.includes(d.uuid))_.pull(this.itemsPendingRemoval,d.uuid);else{var x=d.content_type||w&&w.content_type;if(!(this.acceptableContentTypes&&!this.acceptableContentTypes.includes(x))){var S=!1;if(1==d.deleted){if(!d.dirty){w&&(s.push(w),this.removeItemLocally(w));continue}S=!0}w||(w=this.createItem(d,!0)),this.addItem(w,S),w.errorDecrypting||s.push(w),a.push(w),o.push(d)}}}else console.error("Server response item is corrupt:",d)}}}catch(e){l=!0,f=e}finally{try{!c&&h.return&&h.return()}finally{if(l)throw f}}var C=!0,I=!1,R=void 0;try{for(var E,F=o.entries()[Symbol.iterator]();!(C=(E=F.next()).done);C=!0){var P=E.value,D=u(P,2),O=D[0],M=D[1],A=a[O];M.content&&this.resolveReferencesForItem(A),A.didFinishSyncing()}}catch(e){I=!0,R=e}finally{try{!C&&F.return&&F.return()}finally{if(I)throw R}}var T=this.popMissedReferenceStructsForObjects(o),N=!0,j=!1,B=void 0;try{for(var L,H=T[Symbol.iterator]();!(N=(L=H.next()).done);N=!0){var U=L.value;!function(e){var t=a.find(function(t){return t.uuid==e.reference_uuid});if(t){e.for_item.addItemAsRelationship(t)}}(U)}}catch(e){j=!0,B=e}finally{try{!N&&H.return&&H.return()}finally{if(j)throw B}}return this.notifySyncObserversOfModels(s,r,i),a}},{key:"missedReferenceBuildKey",value:function(e,t){return e+":"+t}},{key:"popMissedReferenceStructsForObjects",value:function(e){if(!e||0==e.length)return[];var t=[],n=[],r=e.map(function(e){return e.uuid}),i=r[0].length,a=Object.keys(this.missedReferences),o=!0,s=!1,u=void 0;try{for(var c,l=a[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var f=c.value;r.includes(f.substring(0,i))&&(t.push(this.missedReferences[f]),n.push(f))}}catch(e){s=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw u}}var p=!0,h=!1,d=void 0;try{for(var y,v=n[Symbol.iterator]();!(p=(y=v.next()).done);p=!0){var g=y.value;delete this.missedReferences[g]}}catch(e){h=!0,d=e}finally{try{!p&&v.return&&v.return()}finally{if(h)throw d}}return t}},{key:"resolveReferencesForItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e.errorDecrypting){var n=e.contentObject;if(e.updateLocalRelationships(),n.references){var r=n.references.slice(),i=r.map(function(e){return e.uuid}),a=this.findItems(i,!0),o=!0,s=!1,c=void 0;try{for(var l,f=a.entries()[Symbol.iterator]();!(o=(l=f.next()).done);o=!0){var p=l.value,h=u(p,2),d=h[0],y=h[1];if(y)e.addItemAsRelationship(y),t&&y.setDirty(!0);else{var v=i[d],g=this.missedReferenceBuildKey(v,e.uuid);if(!this.missedReferences[g]){var m={reference_uuid:v,for_item:e};this.missedReferences[g]=m}}}}catch(e){s=!0,c=e}finally{try{!o&&f.return&&f.return()}finally{if(s)throw c}}}}}},{key:"notifySyncObserversOfModels",value:function(e,t,n){var r=this,i=this.itemSyncObservers.sort(function(e,t){return e.priority0&&r._callSyncObserverCallbackWithTimeout(i,a,o,s,t,n)}(l)}}catch(e){o=!0,s=e}finally{try{!a&&c.return&&c.return()}finally{if(o)throw s}}}},{key:"_callSyncObserverCallbackWithTimeout",value:function(e,t,n,r,i,a){this.$timeout(function(){e.callback(t,n,r,i,a)})}},{key:"createItem",value:function(t,n){var r=e.ContentTypeClassMapping&&e.ContentTypeClassMapping[t.content_type];r||(r=x);var i=new r(t);return n||this.notifySyncObserversOfModels([i],e.MappingSourceLocalSaved),i}},{key:"createConflictedItem",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,SFJS.crypto.generateUUID();case 2:return n=e.sent,t=_.merge(t,{uuid:n}),r=this.createItem(t,!0),e.abrupt("return",r);case 6:case"end":return e.stop()}},e,this)}));return e}()},{key:"addConflictedItem",value:function(e,t){this.addItem(e);var n=!0,r=!1,i=void 0;try{for(var a,o=t.referencingObjects[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;s.addItemAsRelationship(e),s.setDirty(!0)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}this.resolveReferencesForItem(e),e.content.conflict_of=t.uuid,e.setDirty(!0)}},{key:"duplicateItem",value:function(e){var t=new e.constructor({content:e.content});t.created_at=e.created_at,t.content_type=e.content_type,this.addItem(t);var n=!0,r=!1,i=void 0;try{for(var a,o=e.referencingObjects[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;s.addItemAsRelationship(t),s.setDirty(!0)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return this.resolveReferencesForItem(t),t.setDirty(!0),t}},{key:"addItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.addItems([e],t)}},{key:"addItems",value:function(e){var t=this;arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.forEach(function(e){t.itemsHash[e.uuid]||(t.itemsHash[e.uuid]=e,t.items.push(e))})}},{key:"addItemSyncObserver",value:function(e,t,n){this.addItemSyncObserverWithPriority({id:e,types:t,callback:n,priority:1})}},{key:"addItemSyncObserverWithPriority",value:function(e){var t=e.id,n=e.priority,r=e.types,i=e.callback;Array.isArray(r)||(r=[r]),this.itemSyncObservers.push({id:t,types:r,priority:n,callback:i})}},{key:"removeItemSyncObserver",value:function(e){_.remove(this.itemSyncObservers,_.find(this.itemSyncObservers,{id:e}))}},{key:"getDirtyItems",value:function(){return this.items.filter(function(e){return 1==e.dirty&&!e.dummy&&(!e.errorDecrypting||e.deleted)})}},{key:"clearDirtyItems",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){i.value.setDirty(!1)}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}}},{key:"setItemToBeDeleted",value:function(e){e.deleted=!0,e.dummy||e.setDirty(!0),this.removeAndDirtyAllRelationshipsForItem(e)}},{key:"removeAndDirtyAllRelationshipsForItem",value:function(e){if(!e.errorDecrypting){var t=!0,n=!1,r=void 0;try{for(var i,a=e.content.references[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value,s=this.findItem(o.uuid);s&&(e.removeItemAsRelationship(s),s.hasRelationshipWithItem(e)&&(s.removeItemAsRelationship(e),s.setDirty(!0)))}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}}var u=!0,c=!1,l=void 0;try{for(var f,p=e.referencingObjects[Symbol.iterator]();!(u=(f=p.next()).done);u=!0){var h=f.value;h.removeItemAsRelationship(e),h.setDirty(!0)}}catch(e){c=!0,l=e}finally{try{!u&&p.return&&p.return()}finally{if(c)throw l}}e.referencingObjects=[]}},{key:"setAllItemsDirty",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.allItems,n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){a.value.setDirty(!0,e)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"removeItemLocally",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:_.remove(this.items,{uuid:t.uuid}),delete this.itemsHash[t.uuid],t.isBeingRemovedLocally(),this.itemsPendingRemoval.push(t.uuid);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"allItemsMatchingTypes",value:function(e){return this.allItems.filter(function(t){return(_.includes(e,t.content_type)||_.includes(e,"*"))&&!t.dummy})}},{key:"invalidItems",value:function(){return this.allItems.filter(function(e){return e.errorDecrypting})}},{key:"validItemsForContentType",value:function(e){return this.allItems.filter(function(t){return t.content_type==e&&!t.errorDecrypting})}},{key:"findItem",value:function(e){return this.itemsHash[e]}},{key:"findItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value,c=this.itemsHash[u];(c||t)&&n.push(c)}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return n}},{key:"itemsMatchingPredicate",value:function(e){return this.itemsMatchingPredicates([e])}},{key:"itemsMatchingPredicates",value:function(e){return this.filterItemsWithPredicates(this.allItems,e)}},{key:"filterItemsWithPredicates",value:function(e,t){return e.filter(function(e){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(!e.satisfiesPredicate(s))return!1}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return!0})}},{key:"importItems",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c,l,f,p,h,d,y,v,g,m;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:r=[],i=!0,a=!1,o=void 0,t.prev=4,s=n[Symbol.iterator]();case 6:if(i=(u=s.next()).done){t.next=21;break}if(c=u.value,!(l=this.findItem(c.uuid))||l.errorDecrypting){t.next=16;break}return t.next=12,this.createConflictedItem(c);case 12:f=t.sent,c.deleted||l.isItemContentEqualWith(f)||(this.addConflictedItem(f,l),r.push(f)),t.next=18;break;case 16:r.push(c),l&&l.errorDecrypting&&(l.errorDecrypting=!1);case 18:i=!0,t.next=6;break;case 21:t.next=27;break;case 23:t.prev=23,t.t0=t.catch(4),a=!0,o=t.t0;case 27:t.prev=27,t.prev=28,!i&&s.return&&s.return();case 30:if(t.prev=30,!a){t.next=33;break}throw o;case 33:return t.finish(30);case 34:return t.finish(27);case 35:for(p=this.mapResponseItemsToLocalModels(r,e.MappingSourceFileImport),h=!0,d=!1,y=void 0,t.prev=39,v=p[Symbol.iterator]();!(h=(g=v.next()).done);h=!0)m=g.value,m.setDirty(!0,!0),m.deleted=!1;t.next=47;break;case 43:t.prev=43,t.t1=t.catch(39),d=!0,y=t.t1;case 47:t.prev=47,t.prev=48,!h&&v.return&&v.return();case 50:if(t.prev=50,!d){t.next=53;break}throw y;case 53:return t.finish(50);case 54:return t.finish(47);case 55:return t.abrupt("return",p);case 56:case"end":return t.stop()}},t,this,[[4,23,27,35],[28,,30,34],[39,43,47,55],[48,,50,54]])}));return t}()},{key:"getAllItemsJSONData",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.getJSONDataForItems(this.allItems,t,n,r));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"getJSONDataForItems",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.all(t.map(function(e){return new S(e,n,r).paramsForExportFile()})).then(function(e){if(i&&0==e.length)return null;var t={items:e};return n&&(t.auth_params=r),JSON.stringify(t,null,2)}));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"computeDataIntegrityHash",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=this.allNondummyItems.sort(function(e,t){return t.updated_at-e.updated_at}),n=t.map(function(e){return e.updatedAtTimestamp()}),r=n.join(","),e.next=6,SFJS.crypto.sha256(r);case 6:return i=e.sent,e.abrupt("return",i);case 10:return e.prev=10,e.t0=e.catch(0),console.error("Error computing data integrity hash",e.t0),e.abrupt("return",null);case 14:case"end":return e.stop()}},e,this,[[0,10]])}));return e}()},{key:"allItems",get:function(){return this.items.slice()}},{key:"allNondummyItems",get:function(){return this.items.filter(function(e){return!e.dummy})}}]),e}(),g=r.SFPrivilegesManager=function(){function e(t,n,r){a(this,e),this.modelManager=t,this.syncManager=n,this.singletonManager=r,this.loadPrivileges(),e.CredentialAccountPassword="CredentialAccountPassword",e.CredentialLocalPasscode="CredentialLocalPasscode",e.ActionManageExtensions="ActionManageExtensions",e.ActionManageBackups="ActionManageBackups",e.ActionViewProtectedNotes="ActionViewProtectedNotes",e.ActionManagePrivileges="ActionManagePrivileges",e.ActionManagePasscode="ActionManagePasscode",e.ActionDeleteNote="ActionDeleteNote",e.SessionExpiresAtKey="SessionExpiresAtKey",e.SessionLengthKey="SessionLengthKey",e.SessionLengthNone=0,e.SessionLengthFiveMinutes=300,e.SessionLengthOneHour=3600,e.SessionLengthOneWeek=604800,this.availableActions=[e.ActionViewProtectedNotes,e.ActionDeleteNote,e.ActionManagePasscode,e.ActionManageBackups,e.ActionManageExtensions,e.ActionManagePrivileges],this.availableCredentials=[e.CredentialAccountPassword,e.CredentialLocalPasscode],this.sessionLengths=[e.SessionLengthNone,e.SessionLengthFiveMinutes,e.SessionLengthOneHour,e.SessionLengthOneWeek,e.SessionLengthIndefinite]}return l(e,[{key:"setDelegate",value:function(e){this.delegate=e}},{key:"getAvailableActions",value:function(){return this.availableActions}},{key:"getAvailableCredentials",value:function(){return this.availableCredentials}},{key:"netCredentialsForAction",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPrivileges();case 2:t.t0=n,r=t.sent.getCredentialsForAction(t.t0),i=[],a=!0,o=!1,s=void 0,t.prev=8,u=r[Symbol.iterator]();case 10:if(a=(c=u.next()).done){t.next=27;break}if((l=c.value)!=e.CredentialAccountPassword){t.next=19;break}return t.next=15,this.delegate.isOffline();case 15:f=t.sent,f||i.push(l),t.next=24;break;case 19:if(l!=e.CredentialLocalPasscode){t.next=24;break}return t.next=22,this.delegate.hasLocalPasscode();case 22:p=t.sent,p&&i.push(l);case 24:a=!0,t.next=10;break;case 27:t.next=33;break;case 29:t.prev=29,t.t1=t.catch(8),o=!0,s=t.t1;case 33:t.prev=33,t.prev=34,!a&&u.return&&u.return();case 36:if(t.prev=36,!o){t.next=39;break}throw s;case 39:return t.finish(36);case 40:return t.finish(33);case 41:return t.abrupt("return",i);case 42:case"end":return t.stop()}},t,this,[[8,29,33,41],[34,,36,40]])}));return t}()},{key:"loadPrivileges",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.loadPromise){e.next=2;break}return e.abrupt("return",this.loadPromise);case 2:return this.loadPromise=new Promise(function(e,n){var r=I.contentType(),a=new C("content_type","=",r);t.singletonManager.registerSingleton([a],function(n){t.privileges=n,e(n)},function(){var n=i(regeneratorRuntime.mark(function n(i){var a;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(a=new I({content_type:r}),SFJS.crypto.generateUUIDSync){n.next=4;break}return n.next=4,a.initUUID();case 4:t.modelManager.addItem(a),a.setDirty(!0),t.syncManager.sync(),i(a),e(a);case 9:case"end":return n.stop()}},n,t)}));return function(e){return n.apply(this,arguments)}}())}),e.abrupt("return",this.loadPromise);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"getPrivileges",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.privileges){e.next=4;break}return e.abrupt("return",this.privileges);case 4:return e.abrupt("return",this.loadPrivileges());case 5:case"end":return e.stop()}},e,this)}));return e}()},{key:"displayInfoForCredential",value:function(t){var n={};return n[e.CredentialAccountPassword]={label:"Account Password",prompt:"Please enter your account password."},n[e.CredentialLocalPasscode]={label:"Local Passcode",prompt:"Please enter your local passcode."},n[t]}},{key:"displayInfoForAction",value:function(t){var n={};return n[e.ActionManageExtensions]={label:"Manage Extensions"},n[e.ActionManageBackups]={label:"Download/Import Backups"},n[e.ActionViewProtectedNotes]={label:"View Protected Notes"},n[e.ActionManagePrivileges]={label:"Manage Privileges"},n[e.ActionManagePasscode]={label:"Manage Passcode"},n[e.ActionDeleteNote]={label:"Delete Notes"},n[t]}},{key:"getSessionLengthOptions",value:function(){return[{value:e.SessionLengthNone,label:"Don't Remember"},{value:e.SessionLengthFiveMinutes,label:"5 Minutes"},{value:e.SessionLengthOneHour,label:"1 Hour"},{value:e.SessionLengthOneWeek,label:"1 Week"}]}},{key:"setSessionLength",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=function(e){var t=new Date;return t.setSeconds(t.getSeconds()+e),t},i=r(n),t.abrupt("return",Promise.all([this.delegate.saveToStorage(e.SessionExpiresAtKey,JSON.stringify(i)),this.delegate.saveToStorage(e.SessionLengthKey,JSON.stringify(n))]));case 3:case"end":return t.stop()}},t,this)}));return t}()},{key:"clearSession",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.setSessionLength(e.SessionLengthNone));case 1:case"end":return t.stop()}},t,this)}));return t}()},{key:"getSelectedSessionLength",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.delegate.getFromStorage(e.SessionLengthKey);case 2:if(!(n=t.sent)){t.next=7;break}return t.abrupt("return",JSON.parse(n));case 7:return t.abrupt("return",e.SessionLengthNone);case 8:case"end":return t.stop()}},t,this)}));return t}()},{key:"getSessionExpirey",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.delegate.getFromStorage(e.SessionExpiresAtKey);case 2:if(!(n=t.sent)){t.next=7;break}return t.abrupt("return",new Date(JSON.parse(n)));case 7:return t.abrupt("return",new Date);case 8:case"end":return t.stop()}},t,this)}));return t}()},{key:"actionHasPrivilegesConfigured",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.netCredentialsForAction(t);case 2:return e.t0=e.sent.length,e.abrupt("return",e.t0>0);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"actionRequiresPrivilege",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getSessionExpirey();case 2:if(!((n=e.sent)>new Date)){e.next=5;break}return e.abrupt("return",!1);case 5:return e.next=7,this.netCredentialsForAction(t);case 7:return r=e.sent,e.abrupt("return",r.length>0);case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"savePrivileges",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPrivileges();case 2:t=e.sent,t.setDirty(!0),this.syncManager.sync();case 5:case"end":return e.stop()}},e,this)}));return e}()},{key:"authenticateAction",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.netCredentialsForAction(t);case 2:r=e.sent,i=[],a=[],o=!0,s=!1,u=void 0,e.prev=7,c=r[Symbol.iterator]();case 9:if(o=(l=c.next()).done){e.next=18;break}return f=l.value,e.next=13,this._verifyAuthenticationParameters(f,n[f]);case 13:p=e.sent,p?i.push(f):a.push(f);case 15:o=!0,e.next=9;break;case 18:e.next=24;break;case 20:e.prev=20,e.t0=e.catch(7),s=!0,u=e.t0;case 24:e.prev=24,e.prev=25,!o&&c.return&&c.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:return e.abrupt("return",{success:0==a.length,successfulCredentials:i,failedCredentials:a});case 33:case"end":return e.stop()}},e,this,[[7,20,24,32],[25,,27,31]])}));return e}()},{key:"_verifyAuthenticationParameters",value:function(){function t(e,t){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n,r){var a,o,s=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(a=function(){var e=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s.delegate.verifyAccountPassword(t));case 1:case"end":return e.stop()}},e,s)}));return function(t){return e.apply(this,arguments)}}(),o=function(){var e=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s.delegate.verifyLocalPasscode(t));case 1:case"end":return e.stop()}},e,s)}));return function(t){return e.apply(this,arguments)}}(),n!=e.CredentialAccountPassword){t.next=6;break}return t.abrupt("return",a(r));case 6:if(n!=e.CredentialLocalPasscode){t.next=8;break}return t.abrupt("return",o(r));case 8:case"end":return t.stop()}},t,this)}));return t}()}]),e}(),m=r.SFSessionHistoryManager=function(){function e(t,n,r,i,o){var s=this;a(this,e),this.modelManager=t,this.storageManager=n,this.$timeout=o||setTimeout.bind(window),this.keyRequestHandler=r,this.loadFromDisk().then(function(){s.modelManager.addItemSyncObserver("session-history",i,function(e,t,n,r,i){var a=!0,o=!1,u=void 0;try{for(var c,l=e[Symbol.iterator]();!(a=(c=l.next()).done);a=!0){var f=c.value;try{s.addHistoryEntryForItem(f)}catch(e){console.log("Caught exception while trying to add item history entry",e)}}}catch(e){o=!0,u=e}finally{try{!a&&l.return&&l.return()}finally{if(o)throw u}}})})}return l(e,[{key:"encryptionParams",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.keyRequestHandler());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"addHistoryEntryForItem",value:function(e){var t=this,n={uuid:e.uuid,content_type:e.content_type,updated_at:e.updated_at,content:e.content},r=this.historySession.addEntryForItem(n);this.autoOptimize&&this.historySession.optimizeHistoryForItem(e),r&&this.diskEnabled&&(this.diskTimeout&&(this.$timeout.hasOwnProperty("cancel")?this.$timeout.cancel(this.diskTimeout):clearTimeout(this.diskTimeout)),this.diskTimeout=this.$timeout(function(){t.saveToDisk()},2e3))}},{key:"historyForItem",value:function(e){return this.historySession.historyForItem(e)}},{key:"clearHistoryForItem",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.historySession.clearItemHistory(t),e.abrupt("return",this.saveToDisk());case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"clearAllHistory",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.historySession.clearAllHistory(),e.abrupt("return",this.storageManager.removeItem("sessionHistory_revisions"));case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"toggleDiskSaving",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.diskEnabled=!this.diskEnabled,!this.diskEnabled){e.next=6;break}this.storageManager.setItem("sessionHistory_persist",JSON.stringify(!0)),this.saveToDisk(),e.next=8;break;case 6:return this.storageManager.setItem("sessionHistory_persist",JSON.stringify(!1)),e.abrupt("return",this.storageManager.removeItem("sessionHistory_revisions"));case 8:case"end":return e.stop()}},e,this)}));return e}()},{key:"saveToDisk",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.diskEnabled){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.encryptionParams();case 4:t=e.sent,n=new S(this.historySession,t.keys,t.auth_params),n.paramsForSync().then(function(e){r.storageManager.setItem("sessionHistory_revisions",JSON.stringify(e))});case 7:case"end":return e.stop()}},e,this)}));return e}()},{key:"loadFromDisk",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.storageManager.getItem("sessionHistory_persist");case 2:return t=e.sent,t&&(this.diskEnabled=JSON.parse(t)),e.next=6,this.storageManager.getItem("sessionHistory_revisions");case 6:if(!(n=e.sent)){e.next=18;break}return n=JSON.parse(n),e.next=11,this.encryptionParams();case 11:return r=e.sent,e.next=14,SFJS.itemTransformer.decryptItem(n,r.keys);case 14:i=new R(n),this.historySession=i,e.next=19;break;case 18:this.historySession=new R;case 19:return e.next=21,this.storageManager.getItem("sessionHistory_autoOptimize");case 21:a=e.sent,this.autoOptimize=!a||JSON.parse(a);case 23:case"end":return e.stop()}},e,this)}));return e}()},{key:"toggleAutoOptimize",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.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 e.stop()}},e,this)}));return e}()}]),e}(),b=r.SFSingletonManager=function(){function e(t,n){var r=this;a(this,e),this.syncManager=n,this.modelManager=t,this.singletonHandlers=[],t.addItemSyncObserverWithPriority({id:"sf-singleton-manager",types:"*",priority:-1,callback:function(){r.resolveSingletons(t.allNondummyItems,null,!0)}}),n.addEventHandler(function(e,n){if("local-data-loaded"==e)r.resolveSingletons(t.allNondummyItems,null,!0),r.initialDataLoaded=!0;else if("sync:completed"==e){if(!r.initialDataLoaded)return;r.resolveSingletons(n.retrievedItems,n.savedItems)}}),t.addModelUuidChangeObserver("singleton-manager",function(e,t){var n=!0,i=!1,a=void 0;try{for(var o,s=r.singletonHandlers[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;u.singleton&&C.ItemSatisfiesPredicates(t,u.predicates)&&(u.singleton=null,r.resolveSingletons([t]))}}catch(e){i=!0,a=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw a}}})}return l(e,[{key:"registerSingleton",value:function(e,t,n){this.singletonHandlers.push({predicates:e,resolutionCallback:t,createBlock:n})}},{key:"resolveSingletons",value:function(e,t,n){var r=this;e=e||[],t=t||[];var i=!0,a=!1,o=void 0;try{for(var s,u=this.singletonHandlers[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;!function(i){var a=i.predicates.slice(),o=r.modelManager.filterItemsWithPredicates(e,a),s=function(){i.createBlock&&(i.pendingCreateBlockCallback=!0,i.createBlock(function(e){i.singleton=e,i.pendingCreateBlockCallback=!1,i.resolutionCallback&&i.resolutionCallback(e)}))},u=r.modelManager.filterItemsWithPredicates(t,a).length;if(o.length>0||u>0){var c=r.modelManager.itemsMatchingPredicates(a);if(c.length>=2){var l=c.sort(function(e,t){return e.errorDecrypting?1:t.errorDecrypting?-1:e.created_at=this.MaxDiscordanceBeforeOutOfSync&&(this.outOfSync||(this.outOfSync=!0,this.notifyEvent("enter-out-of-sync"))),e.abrupt("return",!1);case 13:return this.outOfSync&&(this.outOfSync=!1,this.notifyEvent("exit-out-of-sync")),this.syncDiscordance=0,e.abrupt("return",!0);case 16:case"end":return e.stop()}},e,this)}));return e}()},{key:"isOutOfSync",value:function(){return this.outOfSync}},{key:"getServerURL",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.storageManager.getItem("server");case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0=window._default_sf_server;case 5:return e.abrupt("return",e.t0);case 6:case"end":return e.stop()}},e,this)}));return e}()},{key:"getSyncURL",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getServerURL();case 2:return e.t0=e.sent,e.abrupt("return",e.t0+"/items/sync");case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"registerSyncStatusObserver",value:function(e){var t={key:new Date,callback:e};return this.syncStatusObservers.push(t),t}},{key:"removeSyncStatusObserver",value:function(e){_.pull(this.syncStatusObservers,e)}},{key:"syncStatusDidChange",value:function(){var e=this;this.syncStatusObservers.forEach(function(t){t.callback(e.syncStatus)})}},{key:"addEventHandler",value:function(e){return this.eventHandlers.push(e),e}},{key:"removeEventHandler",value:function(e){_.pull(this.eventHandlers,e)}},{key:"notifyEvent",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.eventHandlers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){(0,a.value)(e,t||{})}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"setKeyRequestHandler",value:function(e){this.keyRequestHandler=e}},{key:"getActiveKeyInfo",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.keyRequestHandler(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"initialDataLoaded",value:function(){return this._initialDataLoaded}},{key:"loadLocalItems",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.storageManager.getAllModels().then(function(t){t=t.sort(function(e,t){var n=new Date(t.updated_at)-new Date(e.updated_at),i=r.contentTypeLoadPriority,a=0,o=0;return i&&(a=i.indexOf(e.content_type),o=i.indexOf(t.content_type),-1==a&&(a=i.length),-1==o&&(o=i.length)),a==o?n:a5&&(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:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var t=i(regeneratorRuntime.mark(function t(i,a){var o,s,u,c,l,f,p,h,d,y,v,g,m;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.syncLocked){t.next=4;break}return console.log("Sync Locked, Returning;"),i(),t.abrupt("return");case 4:if(r||(r={}),o=n.modelManager.getDirtyItems(),s=o.filter(function(e){return e.dirtyCount>0&&(e.dirtyCount=0,!0)}),!n.syncStatus.syncOpInProgress||r.force){t.next=14;break}return n.repeatOnCompletion=!0,n.queuedCallbacks.push(i),t.next=12,n.writeItemsToLocalStorage(s,!1);case 12:return console.log("Sync op in progress; returning."),t.abrupt("return");case 14:return t.next=16,n.getActiveKeyInfo(e.KeyRequestLoadSaveAccount);case 16:if(u=t.sent,!u.offline){t.next=20;break}return n.syncOffline(o).then(function(e){n.modelManager.clearDirtyItems(o),i(e)}).catch(function(e){n.notifyEvent("sync-exception",e)}),t.abrupt("return");case 20:return c=n.syncStatus.needsMoreSync,n.syncStatus.syncOpInProgress=!0,n.syncStatus.syncStart=new Date,n.beginCheckingIfSyncIsTakingTooLong(),l=n.PerSyncItemUploadLimit,f=o.slice(0,l),f.lengthn.syncStatus.total&&(n.syncStatus.total=n.syncStatus.current),n.syncStatusDidChange(),t.next=32,n.writeItemsToLocalStorage(s,!1);case 32:return r.onPreSyncSave&&r.onPreSyncSave(),n.allRetreivedItems||(n.allRetreivedItems=[]),n.allSavedItems||(n.allSavedItems=[]),p={},p.limit=150,r.performIntegrityCheck&&(p.compute_integrity=!0),t.prev=38,t.next=41,Promise.all(f.map(function(e){var t=new S(e,u.keys,u.auth_params);return t.additionalFields=r.additionalFields,t.paramsForSync()})).then(function(e){p.items=e});case 41:t.next=46;break;case 43:t.prev=43,t.t0=t.catch(38),n.notifyEvent("sync-exception",t.t0);case 46:for(h=!0,d=!1,y=void 0,t.prev=49,v=f[Symbol.iterator]();!(h=(g=v.next()).done);h=!0)m=g.value,m.dirtyCount=0;t.next=57;break;case 53:t.prev=53,t.t1=t.catch(49),d=!0,y=t.t1;case 57:t.prev=57,t.prev=58,!h&&v.return&&v.return();case 60:if(t.prev=60,!d){t.next=63;break}throw y;case 63:return t.finish(60);case 64:return t.finish(57);case 65:return t.next=67,n.getSyncToken();case 67:return p.sync_token=t.sent,t.next=70,n.getCursorToken();case 70:return p.cursor_token=t.sent,t.prev=71,t.t2=n.httpManager,t.next=75,n.getSyncURL();case 75:t.t3=t.sent,t.t4=p,t.t5=function(e){n.handleSyncSuccess(f,e,r).then(function(){i(e)}).catch(function(e){console.log("Caught sync success exception:",e),n.handleSyncError(null,null,o).then(function(e){i(e)})})},t.t6=function(e,t){n.handleSyncError(e,t,o).then(function(e){i(e)})},t.t2.postAbsolute.call(t.t2,t.t3,t.t4,t.t5,t.t6),t.next=85;break;case 82:t.prev=82,t.t7=t.catch(71),console.log("Sync exception caught:",t.t7);case 85:case"end":return t.stop()}},t,n,[[38,43],[49,53,57,65],[58,,60,64],[71,82]])}));return function(e,n){return t.apply(this,arguments)}}()));case 1:case"end":return t.stop()}},t,this)}));return t}()},{key:"handleSyncSuccess",value:function(){function t(e,t,r){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n,r,i){var a,o,s,u,c,l,f,p,h,d,y,g,m,b,k=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(a=[],o=!0,s=!1,u=void 0,t.prev=4,c=n[Symbol.iterator]();!(o=(l=c.next()).done);o=!0)f=l.value,0==f.dirtyCount&&a.push(f);t.next=12;break;case 8:t.prev=8,t.t0=t.catch(4),s=!0,u=t.t0;case 12:t.prev=12,t.prev=13,!o&&c.return&&c.return();case 15:if(t.prev=15,!s){t.next=18;break}throw u;case 18:return t.finish(15);case 19:return t.finish(12);case 20:return this.modelManager.clearDirtyItems(a),this.syncStatus.error=null,p=this.allSavedItems.map(function(e){return e.uuid}),r.retrieved_items=r.retrieved_items.filter(function(e){return!p.includes(e.uuid)}),t.next=26,this.handleItemsResponse(r.retrieved_items,null,v.MappingSourceRemoteRetrieved,e.KeyRequestLoadSaveAccount);case 26:return h=t.sent,this.allRetreivedItems=this.allRetreivedItems.concat(h),this.syncStatus.retrievedCount=this.allRetreivedItems.length,d=["content","auth_hash"],t.next=32,this.handleItemsResponse(r.saved_items,d,v.MappingSourceRemoteSaved,e.KeyRequestLoadSaveAccount);case 32:return y=t.sent,this.allSavedItems=this.allSavedItems.concat(y),g=r.unsaved,t.next=37,this.handleUnsavedItemsResponse(g);case 37:return t.next=39,this.writeItemsToLocalStorage(y,!1);case 39:return t.next=41,this.writeItemsToLocalStorage(h,!1);case 41:if(this.syncStatus.syncOpInProgress=!1,this.syncStatus.current+=n.length,this.syncStatusDidChange(),this.setSyncToken(r.sync_token),this.setCursorToken(r.cursor_token),this.stopCheckingIfSyncIsTakingTooLong(),!r.integrity_hash||r.cursor_token){t.next=52;break}return t.next=50,this.handleServerIntegrityHash(r.integrity_hash);case 50:m=t.sent,m||this.syncDiscordance=this.majorDataChangeThreshold||y.length>=this.majorDataChangeThreshold||g.length>=this.majorDataChangeThreshold)&&this.notifyEvent("major-data-change"),this.callQueuedCallbacks(r),this.notifyEvent("sync:completed",{retrievedItems:this.allRetreivedItems,savedItems:this.allSavedItems,unsavedItems:g}),this.allRetreivedItems=[],this.allSavedItems=[],t.abrupt("return",r);case 72:case"end":return t.stop()}},t,this,[[4,8,12,20],[13,,15,19]])}));return t}()},{key:"handleSyncError",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("Sync error: ",t),401==n&&this.notifyEvent("sync-session-invalid"),t?"string"==typeof t&&(t={error:{message:t}}):t={error:{message:"Could not connect to server."}},this.syncStatus.syncOpInProgress=!1,this.syncStatus.error=t.error,this.syncStatusDidChange(),this.writeItemsToLocalStorage(r,!1),this.modelManager.didSyncModelsOffline(r),this.stopCheckingIfSyncIsTakingTooLong(),this.notifyEvent("sync:error",t.error),this.callQueuedCallbacks({error:"Sync error"}),e.abrupt("return",t);case 12:case"end":return e.stop()}},e,this)}));return e}()},{key:"handleItemsResponse",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a,o,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getActiveKeyInfo(i);case 2:return a=e.sent.keys,e.next=5,SFJS.itemTransformer.decryptMultipleItems(t,a);case 5:return o=this.modelManager.mapResponseItemsToLocalModelsOmittingFields(t,n,r),s=o.filter(function(e){var t=e.errorDecryptingValueChanged;return e.errorDecryptingValueChanged=!1,t}),s.length>0&&this.writeItemsToLocalStorage(s,!1),e.abrupt("return",o);case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"refreshErroredItems",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this.modelManager.allNondummyItems.filter(function(e){return 1==e.errorDecrypting}),!(n.length>0)){t.next=3;break}return t.abrupt("return",this.handleItemsResponse(n,null,v.MappingSourceLocalRetrieved,e.KeyRequestLoadSaveAccount));case 3:case"end":return t.stop()}},t,this)}));return t}()},{key:"handleUnsavedItemsResponse",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(0!=n.length){t.next=2;break}return t.abrupt("return");case 2:console.log("Handle Conflicted Items:",n),r=!0,i=!1,a=void 0,t.prev=6,o=n[Symbol.iterator]();case 8:if(r=(s=o.next()).done){t.next=35;break}return u=s.value,c=u.item,t.t0=SFJS.itemTransformer,t.t1=[c],t.next=15,this.getActiveKeyInfo(e.KeyRequestLoadSaveAccount);case 15:return t.t2=t.sent.keys,t.next=18,t.t0.decryptMultipleItems.call(t.t0,t.t1,t.t2);case 18:if(l=this.modelManager.findItem(c.uuid)){t.next=21;break}return t.abrupt("continue",32);case 21:if(f=u.error,"uuid_conflict"!==f.tag){t.next=27;break}return t.next=25,this.modelManager.alternateUUIDForItem(l);case 25:t.next=32;break;case 27:if("sync_conflict"!==f.tag){t.next=32;break}return t.next=30,this.modelManager.createConflictedItem(c);case 30:p=t.sent,c.deleted||l.isItemContentEqualWith(p)||this.modelManager.addConflictedItem(p,l);case 32:r=!0,t.next=8;break;case 35:t.next=41;break;case 37:t.prev=37,t.t3=t.catch(6),i=!0,a=t.t3;case 41:t.prev=41,t.prev=42,!r&&o.return&&o.return();case 44:if(t.prev=44,!i){t.next=47;break}throw a;case 47:return t.finish(44);case 48:return t.finish(41);case 49:this.sync(null,{additionalFields:["created_at","updated_at"]});case 50:case"end":return t.stop()}},t,this,[[6,37,41,49],[42,,44,48]])}));return t}()},{key:"stateless_downloadAllItems",value:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(){var r=i(regeneratorRuntime.mark(function r(a,o){var s;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return s={limit:n.limit||500,sync_token:n.syncToken,cursor_token:n.cursorToken,content_type:n.contentType,event:n.event},r.prev=1,r.t0=t.httpManager,r.next=5,t.getSyncURL();case 5:r.t1=r.sent,r.t2=s,r.t3=function(){var r=i(regeneratorRuntime.mark(function r(i){var o,s;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return n.retrievedItems||(n.retrievedItems=[]),o=i.retrieved_items,r.next=4,t.getActiveKeyInfo(e.KeyRequestLoadSaveAccount);case 4:return s=r.sent.keys,r.next=7,SFJS.itemTransformer.decryptMultipleItems(o,s);case 7:n.retrievedItems=n.retrievedItems.concat(o.map(function(e){return t.modelManager.createItem(e,!0)})),n.syncToken=i.sync_token,n.cursorToken=i.cursor_token,n.cursorToken?t.stateless_downloadAllItems(n).then(a):a(n.retrievedItems);case 11:case"end":return r.stop()}},r,t)}));return function(e){return r.apply(this,arguments)}}(),r.t4=function(e,t){o(e)},r.t0.postAbsolute.call(r.t0,r.t1,r.t2,r.t3,r.t4),r.next=16;break;case 12:r.prev=12,r.t5=r.catch(1),console.log("Download all items exception caught:",r.t5),o(r.t5);case 16:case"end":return r.stop()}},r,t,[[1,12]])}));return function(e,t){return r.apply(this,arguments)}}())}},{key:"resolveOutOfSync",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stateless_downloadAllItems({event:"resolve-out-of-sync"}).then(function(){var e=i(regeneratorRuntime.mark(function e(n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:r=[],i=!0,a=!1,o=void 0,e.prev=4,s=n[Symbol.iterator]();case 6:if(i=(u=s.next()).done){e.next=20;break}if(c=u.value,!(l=t.modelManager.findItem(c.uuid))){e.next=16;break}if(!(f=!c.isItemContentEqualWith(l))){e.next=16;break}return e.next=14,t.modelManager.createConflictedItem(l,l);case 14:p=e.sent,t.modelManager.addConflictedItem(p,l);case 16:r.push(c);case 17:i=!0,e.next=6;break;case 20:e.next=26;break;case 22:e.prev=22,e.t0=e.catch(4),a=!0,o=e.t0;case 26:e.prev=26,e.prev=27,!i&&s.return&&s.return();case 29:if(e.prev=29,!a){e.next=32;break}throw o;case 32:return e.finish(29);case 33:return e.finish(26);case 34:return t.modelManager.mapResponseItemsToLocalModelsWithOptions({items:r,source:v.MappingSourceRemoteRetrieved}),e.next=37,t.writeItemsToLocalStorage(t.modelManager.allNondummyItems);case 37:return e.abrupt("return",t.sync({performIntegrityCheck:!0}));case 38:case"end":return e.stop()}},e,t,[[4,22,26,34],[27,,29,33]])}));return function(t){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"handleSignout",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this._syncToken=null,this._cursorToken=null,this._queuedCallbacks=[],this.syncStatus={};case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"clearSyncToken",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._syncToken=null,this._cursorToken=null,e.abrupt("return",this.storageManager.removeItem("syncToken"));case 3:case"end":return e.stop()}},e,this)}));return e}()},{key:"queuedCallbacks",get:function(){return this._queuedCallbacks||(this._queuedCallbacks=[]),this._queuedCallbacks}}]),e}(),x=r.SFItem=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.content={},this.referencingObjects=[],this.updateFromJSON(t),this.uuid||"undefined"!=typeof SFJS&&SFJS.crypto.generateUUIDSync&&(this.uuid=SFJS.crypto.generateUUIDSync()),"object"!==c(this.content)||this.content.references||(this.content.references=[])}return l(e,[{key:"initUUID",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.uuid){e.next=4;break}return e.next=3,SFJS.crypto.generateUUID();case 3:this.uuid=e.sent;case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"updateFromJSON",value:function(t){if(t){this.created_at=t.created_at,this.updated_at=t.updated_at,this.deleted=t.deleted,this.uuid=t.uuid,this.enc_item_key=t.enc_item_key,this.auth_hash=t.auth_hash,this.auth_params=t.auth_params;var n=["errorDecrypting","dirty","dirtyCount","dummy"],r=!0,i=!1,a=void 0;try{for(var o,s=n[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;void 0!==t[u]&&(this[u]=t[u])}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}if(this.content_type||(this.content_type=t.content_type),t.errorDecrypting)this.content=t.content;else try{var c="string"==typeof t.content?JSON.parse(t.content):t.content;e.deepMerge(this.contentObject,c)}catch(e){console.log("Error while updating item from json",e)}this.created_at?(this.created_at=new Date(this.created_at),this.updated_at=new Date(this.updated_at)):(this.created_at=new Date,this.updated_at=new Date),this._client_updated_at=null,t.content?this.mapContentToLocalProperties(this.contentObject):1==t.deleted&&this.handleDeletedContent()}}},{key:"mapContentToLocalProperties",value:function(e){}},{key:"createContentJSONFromProperties",value:function(){var t=this.structureParams();return e.deepMerge(this.contentObject,t),t}},{key:"structureParams",value:function(){return this.getContentCopy()}},{key:"handleDeletedContent",value:function(){}},{key:"setDirty",value:function(e,t){this.dirty=e,this.dirtyCount||(this.dirtyCount=0),e?this.dirtyCount++:this.dirtyCount=0,e&&!t?this.client_updated_at=new Date:this.hasRawClientUpdatedAtValue()||(this.client_updated_at=new Date(this.updated_at))}},{key:"updateLocalRelationships",value:function(){}},{key:"addItemAsRelationship",value:function(e){if(e.setIsBeingReferencedBy(this),!this.hasRelationshipWithItem(e)){var t=this.content.references||[];t.push({uuid:e.uuid,content_type:e.content_type}),this.content.references=t}}},{key:"removeItemAsRelationship",value:function(e){e.setIsNoLongerBeingReferencedBy(this),this.removeReferenceWithUuid(e.uuid)}},{key:"setIsBeingReferencedBy",value:function(e){_.find(this.referencingObjects,{uuid:e.uuid})||this.referencingObjects.push(e)}},{key:"setIsNoLongerBeingReferencedBy",value:function(e){_.remove(this.referencingObjects,{uuid:e.uuid}),this.hasRelationshipWithItem(e)&&(this.removeReferenceWithUuid(e.uuid),this.setDirty(!0))}},{key:"removeReferenceWithUuid",value:function(e){var t=this.content.references||[];t=t.filter(function(t){return t.uuid!=e}),this.content.references=t}},{key:"hasRelationshipWithItem",value:function(e){return null!=this.content.references.find(function(t){return t.uuid==e.uuid})}},{key:"isBeingRemovedLocally",value:function(){}},{key:"didFinishSyncing",value:function(){}},{key:"informReferencesOfUUIDChange",value:function(e,t){}},{key:"potentialItemOfInterestHasChangedItsUUID",value:function(e,t,n){var r=!0,i=!1,a=void 0;try{for(var o,s=this.content.references[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;u.uuid==t&&(u.uuid=n,this.setDirty(!0))}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}}},{key:"doNotEncrypt",value:function(){return!1}},{key:"setDomainDataItem",value:function(e,t,n){if(!n)return void console.error("SFItem.AppDomain needs to be set.");if(!this.errorDecrypting){this.content.appData||(this.content.appData={});var r=this.content.appData[n];r||(r={}),r[e]=t,this.content.appData[n]=r}}},{key:"getDomainDataItem",value:function(e,t){if(!t)return void console.error("SFItem.AppDomain needs to be set.");if(!this.errorDecrypting){this.content.appData||(this.content.appData={});var n=this.content.appData[t];return n?n[e]:null}}},{key:"setAppDataItem",value:function(t,n){this.setDomainDataItem(t,n,e.AppDomain)}},{key:"getAppDataItem",value:function(t){return this.getDomainDataItem(t,e.AppDomain)}},{key:"hasRawClientUpdatedAtValue",value:function(){return null!=this.getAppDataItem("client_updated_at")}},{key:"keysToIgnoreWhenCheckingContentEquality",value:function(){return[]}},{key:"appDataKeysToIgnoreWhenCheckingContentEquality",value:function(){return["client_updated_at"]}},{key:"getContentCopy",value:function(){return JSON.parse(JSON.stringify(this.content))}},{key:"isItemContentEqualWith",value:function(t){var n=function(e,t){if(!e)return e;var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){delete e[a.value]}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return e},r=this.getContentCopy();r.appData&&n(r.appData[e.AppDomain],this.appDataKeysToIgnoreWhenCheckingContentEquality()),r=n(r,this.keysToIgnoreWhenCheckingContentEquality());var i=t.getContentCopy();return i.appData&&n(i.appData[e.AppDomain],t.appDataKeysToIgnoreWhenCheckingContentEquality()),i=n(i,t.keysToIgnoreWhenCheckingContentEquality()),JSON.stringify(r)===JSON.stringify(i)}},{key:"satisfiesPredicate",value:function(e){return C.ItemSatisfiesPredicate(this,e)}},{key:"createdAtString",value:function(){return this.dateToLocalizedString(this.created_at)}},{key:"updatedAtString",value:function(){return this.dateToLocalizedString(this.client_updated_at)}},{key:"updatedAtTimestamp",value:function(){return this.updated_at.getTime()}},{key:"dateToLocalizedString",value:function(e){if("undefined"!=typeof Intl&&Intl.DateTimeFormat){if(!s){var t=navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language;s=new Intl.DateTimeFormat(t,{year:"numeric",month:"short",day:"2-digit",weekday:"long",hour:"2-digit",minute:"2-digit"})}return s.format(e)}return e.toDateString()+" "+e.toLocaleTimeString()}},{key:"contentObject",get:function(){if(this.errorDecrypting)return this.content;if(!this.content)return this.content={},this.content;if(null!==this.content&&"object"===c(this.content))return this.content;try{var e=JSON.parse(this.content);return this.content=e,this.content}catch(e){return console.log("Error parsing json",e,this),this.content={},this.content}}},{key:"pinned",get:function(){return this.getAppDataItem("pinned")}},{key:"archived",get:function(){return this.getAppDataItem("archived")}},{key:"locked",get:function(){return this.getAppDataItem("locked")}},{key:"displayName",get:function(){return"Item"}},{key:"client_updated_at",get:function(){if(!this._client_updated_at){var e=this.getAppDataItem("client_updated_at");this._client_updated_at=e?new Date(e):new Date(this.updated_at)}return this._client_updated_at},set:function(e){this._client_updated_at=e,this.setAppDataItem("client_updated_at",e)}}],[{key:"deepMerge",value:function(e,t){function n(e,t){if(_.isArray(e))return t}return _.mergeWith(e,t,n),e}}]),e}(),S=r.SFItemParams=function(){function e(t,n,r){if(a(this,e),this.item=t,this.keys=n,this.auth_params=r,this.keys&&!this.auth_params)throw"SFItemParams.auth_params must be supplied if supplying keys.";if(this.auth_params&&!this.auth_params.version)throw"SFItemParams.auth_params is missing version"}return l(e,[{key:"paramsForExportFile",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.additionalFields=["updated_at"],this.forExportFile=!0,!t){e.next=6;break}return e.abrupt("return",this.__params());case 6:return e.next=8,this.__params();case 8:return n=e.sent,e.abrupt("return",_.omit(n,["deleted"]));case 10:case"end":return e.stop()}},e,this)}));return e}()},{key:"paramsForExtension",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.paramsForExportFile());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"paramsForLocalStorage",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.additionalFields=["updated_at","dirty","errorDecrypting"],this.forExportFile=!0,e.abrupt("return",this.__params());case 3:case"end":return e.stop()}},e,this)}));return e}()},{key:"paramsForSync",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.__params());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"__params",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t={uuid:this.item.uuid,content_type:this.item.content_type,deleted:this.item.deleted,created_at:this.item.created_at},this.item.errorDecrypting){e.next=23;break}if(n=this.item.doNotEncrypt()&&!this.forExportFile,!this.keys||n){e.next=11;break}return e.next=6,SFJS.itemTransformer.encryptItem(this.item,this.keys,this.auth_params);case 6:r=e.sent,_.merge(t,r),"001"!==this.auth_params.version&&(t.auth_hash=null),e.next=21;break;case 11:if(!this.forExportFile){e.next=15;break}e.t0=this.item.createContentJSONFromProperties(),e.next=19;break;case 15:return e.next=17,SFJS.crypto.base64(JSON.stringify(this.item.createContentJSONFromProperties()));case 17:e.t1=e.sent,e.t0="000"+e.t1;case 19:t.content=e.t0,this.forExportFile||(t.enc_item_key=null,t.auth_hash=null);case 21:e.next=26;break;case 23:t.content=this.item.content,t.enc_item_key=this.item.enc_item_key,t.auth_hash=this.item.auth_hash;case 26:return this.additionalFields&&_.merge(t,_.pick(this.item,this.additionalFields)),e.abrupt("return",t);case 28:case"end":return e.stop()}},e,this)}));return e}()}]),e}(),C=r.SFPredicate=function(){function e(t,n,r){a(this,e),this.keypath=t,this.operator=n,this.value=r,e.IsRecursiveOperator(this.operator)&&(this.value=this.value.map(e.fromArray))}return l(e,null,[{key:"fromArray",value:function(t){return new e(t[0],t[1],t[2])}},{key:"ObjectSatisfiesPredicate",value:function(t,n){if(Array.isArray(n)&&(n=this.fromArray(n)),e.IsRecursiveOperator(n.operator)){if("and"===n.operator){var r=!0,i=!1,a=void 0;try{for(var o,s=n.value[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;if(!this.ObjectSatisfiesPredicate(t,u))return!1}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return!0}if("or"===n.operator){var c=!0,l=!1,f=void 0;try{for(var p,h=n.value[Symbol.iterator]();!(c=(p=h.next()).done);c=!0){var u=p.value;if(this.ObjectSatisfiesPredicate(t,u))return!0}}catch(e){l=!0,f=e}finally{try{!c&&h.return&&h.return()}finally{if(l)throw f}}return!1}}var d=n.value;"string"==typeof d&&d.includes(".ago")&&(d=this.DateFromString(d));var y=n.keypath.split(".").reduce(function(e,t){return e&&e[t]},t),v=[!1,"",null,void 0,NaN];if(void 0==y)return"!="==n.operator?!v.includes(n.value):v.includes(n.value);if("="==n.operator)return Array.isArray(y)?JSON.stringify(y)==JSON.stringify(d):y==d;if("!="==n.operator)return Array.isArray(y)?JSON.stringify(y)!=JSON.stringify(d):y!==d;if("<"==n.operator)return y"==n.operator)return y>d;if("<="==n.operator)return y<=d;if(">="==n.operator)return y>=d;if("startsWith"==n.operator)return y.startsWith(d);if("in"==n.operator)return-1!=d.indexOf(y);if("includes"==n.operator)return this.resolveIncludesPredicate(y,d);if("matches"==n.operator){return new RegExp(d).test(y)}return!1}},{key:"resolveIncludesPredicate",value:function(t,n){if("string"==typeof n)return t.includes(n);var r;r=Array.isArray(n)?e.fromArray(n):n;var i=!0,a=!1,o=void 0;try{for(var s,u=t[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;if(this.ObjectSatisfiesPredicate(c,r))return!0}}catch(e){a=!0,o=e}finally{try{!i&&u.return&&u.return()}finally{if(a)throw o}}return!1}},{key:"ItemSatisfiesPredicate",value:function(t,n){return Array.isArray(n)&&(n=e.fromArray(n)),this.ObjectSatisfiesPredicate(t,n)}},{key:"ItemSatisfiesPredicates",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(!this.ItemSatisfiesPredicate(e,s))return!1}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return!0}},{key:"DateFromString",value:function(e){var t=e.split("."),n=t[1],r=new Date,i=parseInt(t[0]);return"days"==n?r.setDate(r.getDate()-i):"hours"==n&&r.setHours(r.getHours()-i),r}},{key:"IsRecursiveOperator",value:function(e){return["and","or"].includes(e)}}]),e}(),I=r.SFPrivileges=function(e){function r(e){a(this,r);var n=t(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return n.content.desktopPrivileges||(n.content.desktopPrivileges={}),n}return n(r,e),l(r,null,[{key:"contentType",value:function(){return"SN|Privileges"}}]),l(r,[{key:"setCredentialsForAction",value:function(e,t){this.content.desktopPrivileges[e]=t}},{key:"getCredentialsForAction",value:function(e){return this.content.desktopPrivileges[e]||[]}},{key:"toggleCredentialForAction",value:function(e,t){this.isCredentialRequiredForAction(e,t)?this.removeCredentialForAction(e,t):this.addCredentialForAction(e,t)}},{key:"removeCredentialForAction",value:function(e,t){_.pull(this.content.desktopPrivileges[e],t)}},{key:"addCredentialForAction",value:function(e,t){var n=this.getCredentialsForAction(e);n.push(t),this.setCredentialsForAction(e,n)}},{key:"isCredentialRequiredForAction",value:function(e,t){return this.getCredentialsForAction(e).includes(t)}}]),r}(x),R=r.SFHistorySession=function(e){function r(e){a(this,r);var n=t(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return n.content.itemUUIDToItemHistoryMapping||(n.content.itemUUIDToItemHistoryMapping={}),Object.keys(n.content.itemUUIDToItemHistoryMapping).forEach(function(e){var t=n.content.itemUUIDToItemHistoryMapping[e];n.content.itemUUIDToItemHistoryMapping[e]=new E(t)}),n}return n(r,e),l(r,[{key:"addEntryForItem",value:function(e){return this.historyForItem(e).addHistoryEntryForItem(e)}},{key:"historyForItem",value:function(e){var t=this.content.itemUUIDToItemHistoryMapping[e.uuid];return t||(t=this.content.itemUUIDToItemHistoryMapping[e.uuid]=new E),t}},{key:"clearItemHistory",value:function(e){this.historyForItem(e).clear()}},{key:"clearAllHistory",value:function(){this.content.itemUUIDToItemHistoryMapping={}}},{key:"optimizeHistoryForItem",value:function(e){var t=this.historyForItem(e);t.entries.length>r.LargeItemEntryAmountThreshold&&t.optimize()}}]),r}(x);R.LargeItemEntryAmountThreshold=60;var E=r.SFItemHistory=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a(this,e),this.entries||(this.entries=[]),t.entries){var n=!0,r=!1,i=void 0;try{for(var o,s=t.entries[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value,c=this.createEntryForItem(u.item);c.setPreviousEntry(this.getLastEntry()),this.entries.push(c)}}catch(e){r=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(r)throw i}}}}return l(e,[{key:"createEntryForItem",value:function(t){var n=e.HistoryEntryClassMapping&&e.HistoryEntryClassMapping[t.content_type];return n||(n=F),new n(t)}},{key:"getLastEntry",value:function(){return this.entries[this.entries.length-1]}},{key:"addHistoryEntryForItem",value:function(e){var t=this.createEntryForItem(e),n=this.getLastEntry();if(t.setPreviousEntry(n),!t.isSameAsEntry(n))return this.entries.push(t),t}},{key:"clear",value:function(){this.entries.length=0}},{key:"optimize",value:function(){var t=this,n=[],r=function(t){return t.deltaSize()>e.LargeEntryDeltaThreshold},i=function(e,i,a){if(a)n.push(e);else{var i=n.indexOf(e);-1!==i&&n.splice(i,1)}if(a&&r(e)&&-1==e.operationVector()){var o=t.entries[i-1];o&&n.push(o)}};this.entries.forEach(function(e,n){if(0==n||n==t.entries.length-1)i(e,n,!0);else{var a=r(e);i(e,n,a)}}),this.entries=this.entries.filter(function(e,t){return-1!==n.indexOf(e)})}}]),e}();E.LargeEntryDeltaThreshold=15;var F=r.SFItemHistoryEntry=function(){function e(t){a(this,e),this.item=x.deepMerge({},t),this.defaultContentKeyToDiffOn="text",this.textCharDiffLength=0,"string"==typeof this.item.updated_at&&(this.item.updated_at=new Date(this.item.updated_at))}return l(e,[{key:"setPreviousEntry",value:function(e){this.hasPreviousEntry=null!=e,this.item.content[this.defaultContentKeyToDiffOn]&&(this.textCharDiffLength=e?this.item.content[this.defaultContentKeyToDiffOn].length-e.item.content[this.defaultContentKeyToDiffOn].length:this.item.content[this.defaultContentKeyToDiffOn].length)}},{key:"operationVector",value:function(){return void 0!=this.textCharDiffLength?this.hasPreviousEntry&&0!=this.textCharDiffLength?this.textCharDiffLength<0?-1:1:0:1}},{key:"deltaSize",value:function(){return void 0!=this.textCharDiffLength?Math.abs(this.textCharDiffLength):1}},{key:"isSameAsEntry",value:function(e){if(!e)return!1;var t=new x(this.item),n=new x(e.item);return t.isItemContentEqualWith(n)}}]),e}(),h="undefined"!=typeof window?window:void 0!==e?e:null,P=r.SFAbstractCrypto=function(){function e(){a(this,e),this.DefaultPBKDF2Length=768}return l(e,[{key:"generateUUIDSync",value:function(){var e=h.crypto||h.msCrypto;if(e){var t=new Uint32Array(4);e.getRandomValues(t);var n=-1;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){n++;var r=t[n>>3]>>n%8*4&15;return("x"==e?r:3&r|8).toString(16)})}var r=(new Date).getTime();return h.performance&&"function"==typeof h.performance.now&&(r+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)})}},{key:"generateUUID",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.generateUUIDSync());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"decryptText",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=a.ciphertextToAuth,u=a.contentCiphertext,c=a.encryptionKey,l=a.iv,f=a.authHash,p=a.authKey,h=arguments[1];return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!h||f){e.next=3;break}return console.error("Auth hash is required."),e.abrupt("return");case 3:if(!f){e.next=10;break}return e.next=6,this.hmac256(s,p);case 6:if(t=e.sent,f===t){e.next=10;break}return console.error("Auth hash does not match, returning null."),e.abrupt("return",null);case 10:return n=o.enc.Hex.parse(c),r=o.enc.Hex.parse(l||""),i=o.AES.decrypt(u,n,{iv:r,mode:o.mode.CBC,padding:o.pad.Pkcs7}),e.abrupt("return",i.toString(o.enc.Utf8));case 14:case"end":return e.stop()}},e,this)}));return e}()},{key:"encryptText",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){var i,a,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=o.enc.Hex.parse(n),a=o.enc.Hex.parse(r||""),s=o.AES.encrypt(t,i,{iv:a,mode:o.mode.CBC,padding:o.pad.Pkcs7}),e.abrupt("return",s.toString());case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateRandomKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",o.lib.WordArray.random(t/8).toString());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateItemEncryptionKey",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=512,n=1,e.next=4,this.generateRandomKey(t);case 4:return r=e.sent,e.next=7,this.generateRandomKey(t);case 7:return i=e.sent,e.abrupt("return",this.pbkdf2(i,r,n,t));case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"firstHalfOfKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.substring(0,t.length/2));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"secondHalfOfKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.substring(t.length/2,t.length));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"base64",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",h.btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)})));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"base64Decode",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",h.atob(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"sha256",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",o.SHA256(t).toString());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"hmac256",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.enc.Hex.parse(n),i=o.enc.Utf8.parse(t),a=o.HmacSHA256(i,r).toString(),e.abrupt("return",a);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateSalt",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sha256([t,"SF",n,r,i].join(":"));case 2:return a=e.sent,e.abrupt("return",a);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateSymmetricKeyPair",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a,o,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},u=s.password,c=s.pw_salt,l=s.pw_cost;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.pbkdf2(u,c,l,this.DefaultPBKDF2Length);case 2:return t=e.sent,n=t.length,r=n/3,i=t.slice(0,r),a=t.slice(r,2*r),o=t.slice(2*r,3*r),e.abrupt("return",[i,a,o]);case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"computeEncryptionKeysForUser",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("003"!=n.version){e.next=9;break}if(n.identifier){e.next=4;break}return console.error("authParams is missing identifier."),e.abrupt("return");case 4:return e.next=6,this.generateSalt(n.identifier,n.version,n.pw_cost,n.pw_nonce);case 6:r=e.sent,e.next=10;break;case 9:r=n.pw_salt;case 10:return e.abrupt("return",this.generateSymmetricKeyPair({password:t,pw_salt:r,pw_cost:n.pw_cost}).then(function(e){return{pw:e[0],mk:e[1],ak:e[2]}}));case 11:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateInitialKeysAndAuthParamsForUser",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r,i,a,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.SFJS.version,i=this.SFJS.defaultPasswordGenerationCost,e.next=4,this.generateRandomKey(256);case 4:return a=e.sent,e.next=7,this.generateSalt(t,r,i,a);case 7:return o=e.sent,e.abrupt("return",this.generateSymmetricKeyPair({password:n,pw_salt:o,pw_cost:i}).then(function(e){var n={pw_nonce:a,pw_cost:i,identifier:t,version:r};return{keys:{pw:e[0],mk:e[1],ak:e[2]},authParams:n}}));case 9:case"end":return e.stop()}},e,this)}));return e}()}]),e}(),D=r.SFCryptoJS=function(e){function r(){return a(this,r),t(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return n(r,e),l(r,[{key:"pbkdf2",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return a={keySize:i/32,hasher:o.algo.SHA512,iterations:r},e.abrupt("return",o.PBKDF2(t,n,a).toString());case 2:case"end":return e.stop()}},e,this)}));return e}()}]),r}(P),h="undefined"!=typeof window?window:void 0!==e?e:null,O=h.crypto?h.crypto.subtle:null,M=r.SFCryptoWeb=function(e){function r(){return a(this,r),t(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return n(r,e),l(r,[{key:"pbkdf2",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.webCryptoImportKey(t,"PBKDF2",["deriveBits"]);case 2:if(a=e.sent){e.next=6;break}return console.log("Key is null, unable to continue"),e.abrupt("return",null);case 6:return e.abrupt("return",this.webCryptoDeriveBits(a,n,r,i));case 7:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateRandomKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=!0,e.abrupt("return",O.generateKey({name:"AES-CBC",length:t},n,["encrypt","decrypt"]).then(function(e){return O.exportKey("raw",e).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.arrayBufferToHexString(new Uint8Array(t));case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,r)}));return function(t){return e.apply(this,arguments)}}()).catch(function(e){console.error("Error exporting key",e)})}).catch(function(e){console.error("Error generating key",e)}));case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateItemEncryptionKey",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=256,e.abrupt("return",Promise.all([this.generateRandomKey(t),this.generateRandomKey(t)]).then(function(e){return e.join("")}));case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"encryptText",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){var a,o,s,u,c,l=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!r){e.next=6;break}return e.next=3,this.hexStringToArrayBuffer(r);case 3:e.t0=e.sent,e.next=7;break;case 6:e.t0=new ArrayBuffer(16);case 7:return a=e.t0,o={name:"AES-CBC",iv:a},e.next=11,this.hexStringToArrayBuffer(n);case 11:return s=e.sent,e.next=14,this.webCryptoImportKey(s,o.name,["encrypt"]);case 14:return u=e.sent,e.next=17,this.stringToArrayBuffer(t);case 17:return c=e.sent,e.abrupt("return",crypto.subtle.encrypt(o,u,c).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l.arrayBufferToBase64(t);case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,l)}));return function(t){return e.apply(this,arguments)}}()));case 19:case"end":return e.stop()}},e,this)}));return e}()},{key:"decryptText",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,a,o,s,u=this,c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=c.ciphertextToAuth,f=c.contentCiphertext,p=c.encryptionKey,h=c.iv,d=c.authHash,y=c.authKey,v=arguments[1];return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!v||d){e.next=3;break}return console.error("Auth hash is required."),e.abrupt("return");case 3:if(!d){e.next=10;break}return e.next=6,this.hmac256(l,y);case 6:if(t=e.sent,d===t){e.next=10;break}return console.error("Auth hash does not match, returning null. "+d+" != "+t),e.abrupt("return",null);case 10:if(!h){e.next=16;break}return e.next=13,this.hexStringToArrayBuffer(h);case 13:e.t0=e.sent,e.next=17;break;case 16:e.t0=new ArrayBuffer(16);case 17:return n=e.t0,r={name:"AES-CBC",iv:n},e.next=21,this.hexStringToArrayBuffer(p);case 21:return a=e.sent,e.next=24,this.webCryptoImportKey(a,r.name,["decrypt"]);case 24:return o=e.sent,e.next=27,this.base64ToArrayBuffer(f);case 27:return s=e.sent,e.abrupt("return",crypto.subtle.decrypt(r,o,s).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.arrayBufferToString(t);case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,u)}));return function(t){return e.apply(this,arguments)}}()).catch(function(e){console.error("Error decrypting:",e)}));case 29:case"end":return e.stop()}},e,this)}));return e}()},{key:"webCryptoImportKey",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=6;break}return e.next=3,this.stringToArrayBuffer(t);case 3:e.t0=e.sent,e.next=7;break;case 6:e.t0=t;case 7:return a=e.t0,e.abrupt("return",O.importKey("raw",a,{name:n,hash:i},!1,r).then(function(e){return e}).catch(function(e){return console.error(e),null}));case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"webCryptoDeriveBits",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,a){var o,s=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.stringToArrayBuffer(n);case 2:return e.t0=e.sent,e.t1=r,e.t2={name:"SHA-512"},o={name:"PBKDF2",salt:e.t0,iterations:e.t1,hash:e.t2},e.abrupt("return",O.deriveBits(o,t,a).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.arrayBufferToHexString(new Uint8Array(t));case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,s)}));return function(t){return e.apply(this,arguments)}}()).catch(function(e){return console.error(e),null}));case 7:case"end":return e.stop()}},e,this)}));return e}()},{key:"stringToArrayBuffer",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){var r=new Blob([t]),i=new FileReader;i.onload=function(t){e(t.target.result)},i.readAsArrayBuffer(r)}));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"arrayBufferToString",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){var r=new Blob([t]),i=new FileReader;i.onload=function(t){e(t.target.result)},i.readAsText(r)}));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"arrayBufferToHexString",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:for(n=new Uint8Array(t),r="",a=0;a5e3)||this.crypto instanceof M}},{key:"supportedVersions",value:function(){return["001","002","003"]}},{key:"isVersionNewerThanLibraryVersion",value:function(e){var t=this.version();return parseInt(e)>parseInt(t)}},{key:"isProtocolVersionOutdated",value:function(e){var t={"001":Date.parse("2018-01-01"),"002":Date.parse("2020-01-01")},n=t[e];return!!n&&new Date>n}},{key:"costMinimumForVersion",value:function(e){return{"001":3e3,"002":3e3,"003":11e4}[e]}},{key:"defaultPasswordGenerationCost",value:function(){return this.costMinimumForVersion(this.version())}}]),e}();if(h)try{h.StandardFile=T,h.SFJS=new T,h.SFCryptoWeb=M,h.SFCryptoJS=D,h.SFItemTransformer=A,h.SFModelManager=v,h.SFItem=x,h.SFItemParams=S,h.SFHttpManager=d,h.SFStorageManager=k,h.SFSyncManager=w,h.SFAuthManager=p,h.SFMigrationManager=y,h.SFAlertManager=f,h.SFPredicate=C,h.SFHistorySession=R,h.SFSessionHistoryManager=m,h.SFItemHistory=E,h.SFItemHistoryEntry=F,h.SFPrivilegesManager=g,h.SFPrivileges=I,h.SFSingletonManager=b}catch(e){console.log("Exception while exporting window variables",e)}}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(t,n(3))},function(e,t){!function(t){"use strict";function n(e,t,n,r){var a=t&&t.prototype instanceof i?t:i,o=Object.create(a.prototype),s=new h(r||[]);return o._invoke=c(e,n,s),o}function r(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function i(){}function a(){}function o(){}function s(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function u(e){function t(n,i,a,o){var s=r(e[n],e,i);if("throw"!==s.type){var u=s.arg,c=u.value;return c&&"object"==typeof c&&m.call(c,"__await")?Promise.resolve(c.__await).then(function(e){t("next",e,a,o)},function(e){t("throw",e,a,o)}):Promise.resolve(c).then(function(e){u.value=e,a(u)},o)}o(s.arg)}function n(e,n){function r(){return new Promise(function(r,i){t(e,n,r,i)})}return i=i?i.then(r,r):r()}var i;this._invoke=n}function c(e,t,n){var i=C;return function(a,o){if(i===R)throw new Error("Generator is already running");if(i===E){if("throw"===a)throw o;return y()}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var u=l(s,n);if(u){if(u===F)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===C)throw i=E,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=R;var c=r(e,t,n);if("normal"===c.type){if(i=n.done?E:I,c.arg===F)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=E,n.method="throw",n.arg=c.arg)}}}function l(e,t){var n=e.iterator[t.method];if(n===v){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=v,l(e,t),"throw"===t.method))return F;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return F}var i=r(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,F;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=v),t.delegate=null,F):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,F)}function f(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function p(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function h(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(f,this),this.reset(!0)}function d(e){if(e){var t=e[k];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n=0;--r){var i=this.tryEntries[r],a=i.completion;if("root"===i.tryLoc)return t("end");if(i.tryLoc<=this.prev){var o=m.call(i,"catchLoc"),s=m.call(i,"finallyLoc");if(o&&s){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&m.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),p(n),F}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;p(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:d(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=v),F}}}(function(){return this}()||Function("return this")())},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n=0?this.items[c]=u:this.items.push(u);case 15:r=!0,t.next=5;break;case 18:t.next=24;break;case 20:t.prev=20,t.t0=t.catch(3),i=!0,a=t.t0;case 24:t.prev=24,t.prev=25,r||null==o.return||o.return();case 27:if(t.prev=27,!i){t.next=30;break}throw a;case 30:return t.finish(27);case 31:return t.finish(24);case 32:this.notifyObserversOfEvent(e.BridgeEventReceivedItems);case 33:case"end":return t.stop()}},t,this,[[3,20,24,32],[25,,27,31]])}));return t}()},{key:"indexOfItem",value:function(e){for(var t in this.items)if(this.items[t].uuid==e.uuid)return t;return-1}},{key:"removeItemFromItems",value:function(e){this.items=this.items.filter(function(t){return t.uuid!==e.uuid})}},{key:"createItem",value:function(e,t){this.createItems([e],t)}},{key:"createItems",value:function(e,t){this.componentManager.createItems(e,function(e){t&&t(e.map(function(e){return new f.SFItem(e)}))})}},{key:"saveItem",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.saveItems([t]));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"saveItems",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t,i){r.componentManager.saveItems(n,function(n){t(n),r.notifyObserversOfEvent(e.BridgeEventSavedItem)})}));case 1:case"end":return t.stop()}},t)}));return t}()},{key:"indexOfItem",value:function(e){for(var t in this.items)if(this.items[t].uuid==e.uuid)return t;return-1}},{key:"deleteItem",value:function(e,t){this.deleteItems([e],t)}},{key:"deleteItems",value:function(e,t){this.componentManager.deleteItems(e,t)}},{key:"removeItemFromItems",value:function(e){this.items=this.items.filter(function(t){return t.uuid!==e.uuid})}}]),e}());u(p,"FileItemContentTypeKey","SN|FileSafe|File"),u(p,"FileSafeCredentialsContentType","SN|FileSafe|Credentials"),u(p,"FileDescriptorContentTypeKey","SN|FileSafe|FileMetadata"),u(p,"FileSafeIntegrationContentTypeKey","SN|FileSafe|Integration"),u(p,"BridgeEventLoadedCredentials","BridgeEventLoadedCredentials"),u(p,"BridgeEventReceivedItems","BridgeEventReceivedItems"),u(p,"BridgeEventSavedItem","BridgeEventSavedItem")},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;nt.length)n=e;else{n=t;var r=0,i=-1,a=-1,o=n.length;for(0>r&&(r=-r>o?0:o+r),i=i>o?o:i,0>i&&(i+=o),o=r>i?0:i-r>>>0,r>>>=0,i=Array(o);++aa?pt:o,a=1),t=Object(t);++is))return!1;if((u=a.get(e))&&a.get(t))return u==t;var u=-1,c=!0,l=2&n?new E:pt;for(a.set(e,t),a.set(t,e);++un&&(n=ln(r+n,0)),y(e,be(t,3),n)):-1}function Te(e){return(null==e?0:e.length)?L(e,1):[]}function Ne(e){var t=null==e?0:e.length;return t?e[t-1]:pt}function je(e,t){var n;if(e&&e.length&&t&&t.length){n=t;var r=v,i=-1,a=n.length;for(e===n&&(n=ue(n));++i=e}function We(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Ve(e){return null!=e&&"object"==typeof e}function Je(e){return!(!Ve(e)||"[object Object]"!=z(e))&&(null===(e=Xt(e))||"function"==typeof(e=Kt.call(e,"constructor")&&e.constructor)&&e instanceof e&&zt.call(e)==Jt)}function qe(e){return"string"==typeof e||!Hn(e)&&Ve(e)&&"[object String]"==z(e)}function $e(e){return"symbol"==typeof e||Ve(e)&&"[object Symbol]"==z(e)}function Ge(e){return e?(e=Ye(e),e===ht||e===-ht?1.7976931348623157e308*(0>e?-1:1):e===e?e:0):0===e?e:0}function Qe(e){e=Ge(e);var t=e%1;return e===e?t?e-t:e:0}function Ye(e){if("number"==typeof e)return e;if($e(e))return dt;if(We(e)&&(e="function"==typeof e.valueOf?e.valueOf():e,e=We(e)?e+"":e),"string"!=typeof e)return 0===e?e:+e;e=e.replace(bt,"");var t=St.test(e);return t||Ct.test(e)?Pt(e.slice(2),t?2:8):xt.test(e)?dt:+e}function Xe(e){return ce(e,rt(e))}function Ze(e){return null==e?"":ne(e)}function et(e,t,n){return e=null==e?pt:H(e,t),e===pt?n:e}function tt(e,t){var n;if(n=null!=e){n=e;var r;r=ie(t,n);for(var i=-1,a=r.length,o=!1;++i(e=M(t,e))||(e==t.length-1?t.pop():tn.call(t,e,1),--this.size,0))},I.prototype.get=function(e){var t=this.__data__;return e=M(t,e),0>e?pt:t[e][1]},I.prototype.has=function(e){return-1r?(++this.size,n.push([e,t])):n[r][1]=t,this},R.prototype.clear=function(){this.size=0,this.__data__={hash:new C,map:new(dn||I),string:new C}},R.prototype.delete=function(e){return e=ke(this,e).delete(e),this.size-=e?1:0,e},R.prototype.get=function(e){return ke(this,e).get(e)},R.prototype.has=function(e){return ke(this,e).has(e)},R.prototype.set=function(e,t){var n=ke(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},E.prototype.add=E.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},E.prototype.has=function(e){return this.__data__.has(e)},F.prototype.clear=function(){this.__data__=new I,this.size=0},F.prototype.delete=function(e){var t=this.__data__;return e=t.delete(e),this.size=t.size,e},F.prototype.get=function(e){return this.__data__.get(e)},F.prototype.has=function(e){return this.__data__.has(e)},F.prototype.set=function(e,t){var n=this.__data__;if(n instanceof I){var r=n.__data__;if(!dn||199>r.length)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new R(r)}return n.set(e,t),this.size=n.size,this};var En=function(e,t){return function(t,n){if(null==t)return t;if(!He(t))return e(t,n);for(var r=t.length,i=-1,a=Object(t);++in&&(n=ln(r+n,0)),qe(e)?n<=r&&-10){var i=!0,a=!1,o=void 0;try{for(var s,u=t.integrations[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;if(c!=e){t.setIntegrationAsDefault(c);break}}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}}})}},{key:"integrations",get:function(){return this.extensionBridge.filterItems(l.a.FileSafeIntegrationContentTypeKey)}}]),e}()},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n0&&(e=n.credentials[0]),e}),u(this,"setCredentialAsDefault",function(e){var t=n.getDefaultCredentials();t&&(t.content.isDefault=!1),e.content.isDefault=!0,n.extensionBridge.saveItems([t,e])}),u(this,"deleteCredential",function(e){n.extensionBridge.deleteItem(e)}),this.extensionBridge=r,this.onCredentialLoad=i,this.credentials=[],this.extensionBridge.addEventHandler(function(e){e==f.a.BridgeEventReceivedItems&&n.reloadCredentials()})}return s(e,[{key:"reloadCredentials",value:function(){this.credentials=[];var e=this.extensionBridge.filterItems(f.a.FileSafeCredentialsContentType);if(0!=e.length){var t=!0,n=!1,r=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;this.credentials.find(function(e){return e.uuid==o.uuid})||this.credentials.push(o)}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}this.onCredentialLoad(),this.credentials.length>0&&this.didLoadCredentials()}}},{key:"createNewCredentials",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=256,e.next=3,SFJS.crypto.generateRandomKey(t);case 3:return n=e.sent,e.next=6,SFJS.crypto.generateRandomKey(t);case 6:return r=e.sent,e.next=9,SFJS.crypto.generateInitialKeysAndAuthParamsForUser(n,r);case 9:return i=e.sent,i.isDefault=0==this.credentials.length,a=new l.SFItem({content_type:f.a.FileSafeCredentialsContentType,content:i}),this.extensionBridge.saveItem(a),this.didLoadCredentials(),e.abrupt("return",a);case 15:case"end":return e.stop()}},e,this)}));return e}()},{key:"didLoadCredentials",value:function(){this.extensionBridge.notifyObserversOfEvent(f.a.BridgeEventLoadedCredentials)}},{key:"credentialForFileDescriptor",value:function(e){return this.credentials.find(function(t){return e.content.references.find(function(e){return e.uuid==t.uuid})})}},{key:"getAllCredentials",value:function(){return this.credentials}},{key:"saveCredential",value:function(e){this.extensionBridge.saveItem(e)}}]),e}()},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n3&&void 0!==arguments[3]&&arguments[3],i=document.createElement("a");i.setAttribute("download",t),i.href=this.tempUrlForData(e,n),i.setAttribute("target","_blank"),r?window.location.href=i.href:(document.body.appendChild(i),i.click(),i.remove())}},{key:"tempUrlForData",value:function(e,t){return window.URL.createObjectURL(new Blob([e],{type:t||"text/json"}))}},{key:"copyTextToClipboard",value:function(e){if(window.clipboardData&&window.clipboardData.setData)return clipboardData.setData("Text",e);if(document.queryCommandSupported&&document.queryCommandSupported("copy")){var t=document.createElement("textarea");t.textContent=e,t.style.position="fixed",document.body.appendChild(t),t.select();try{return document.execCommand("copy")}catch(e){return console.warn("Copy to clipboard failed.",e),!1}finally{document.body.removeChild(t)}}}}]),e}()}])},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function a(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){function o(e){i(u,r,a,o,s,"next",e)}function s(e){i(u,r,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;ni)){r.next=14;break}return alert("The maximum upload size is ".concat(n," megabytes per file.")),o.setState({status:null}),e(),r.abrupt("return");case 14:return r.next=16,SFJS.crypto.arrayBufferToBase64(l);case 16:return p=r.sent,r.next=19,o.encryptFile(p,t.name,t.type);case 19:e();case 20:case"end":return r.stop()}},r)}));return function(e){return r.apply(this,arguments)}}(),o.setState({status:"Reading file..."}),t.name.endsWith(".sf")||t.name.endsWith(".json")?(u=!0,s.readAsText(t)):s.readAsArrayBuffer(t)}));case 4:case"end":return e.stop()}},e)}));return e}()},{key:"decryptDraggedFile",value:function(){function e(e){return t.apply(this,arguments)}var t=a(regeneratorRuntime.mark(function e(t){var n,r,i,o,s,u,c,l,f,p=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.setState({status:"Decrypting..."}),n=k.a.get().filesafe.getAllCredentials(),r=function(){var e=a(regeneratorRuntime.mark(function e(n){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,r){k.a.get().filesafe.decryptFile({fileDescriptor:t,credential:n}).then(function(t){var n=t.decryptedItem;k.a.get().filesafe.downloadBase64Data({base64Data:t.decryptedData,fileName:n.content.fileName,fileType:n.content.fileType}),p.setState({status:null}),e(!0)}).catch(function(e){console.error("Error decrypting:",e),p.flashError("Error decrypting file."),r(!1)})}));case 1:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),i=!0,o=!1,s=void 0,e.prev=6,u=n[Symbol.iterator]();case 8:if(i=(c=u.next()).done){e.next=18;break}return l=c.value,e.next=12,r(l);case 12:if(!(f=e.sent)){e.next=15;break}return e.abrupt("return");case 15:i=!0,e.next=8;break;case 18:e.next=24;break;case 20:e.prev=20,e.t0=e.catch(6),o=!0,s=e.t0;case 24:e.prev=24,e.prev=25,i||null==u.return||u.return();case 27:if(e.prev=27,!o){e.next=30;break}throw s;case 30:return e.finish(27);case 31:return e.finish(24);case 32:case"end":return e.stop()}},e,this,[[6,20,24,32],[25,,27,31]])}));return e}()},{key:"wait",value:function(){function e(e){return t.apply(this,arguments)}var t=a(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){setTimeout(function(){e()},1e3*t)}));case 1:case"end":return e.stop()}},e)}));return e}()},{key:"encryptFile",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=a(regeneratorRuntime.mark(function e(t,n,r){var i,o,s=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.setState({status:"Encrypting..."}),i=k.a.get().filesafe.getDefaultCredentials(),o=k.a.get().filesafe.getDefaultIntegration(),e.abrupt("return",k.a.get().filesafe.encryptFile({data:t,inputFileName:n,fileType:r,credential:i}).then(function(){var e=a(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return s.setState({status:"Uploading to ".concat(k.a.get().filesafe.displayStringForIntegration(o),"...")}),e.next=3,s.wait(.5);case 3:return e.abrupt("return",k.a.get().filesafe.uploadFile({fileItem:t,inputFileName:n,fileType:r,credential:i}).then(function(){s.setState({status:"Upload Success."})}).catch(function(e){console.error("fs-embed | error uploading file:",e),s.flashError("Error uploading file.")}));case 4:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()));case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"flashError",value:function(e){var t=this;this.setState({status:e,statusClass:"danger"}),setTimeout(function(){t.setState({status:null,statusClass:null})},2500)}},{key:"render",value:function(){var e=this,t=this.state.statusClass?this.state.statusClass:"info",n="info"==t;return v.a.createElement("div",{className:"sn-component files-view"},v.a.createElement("div",{className:"sk-panel-row align-top"},v.a.createElement("div",{className:"files"},this.state.messages.length>0&&v.a.createElement("div",{id:"messages-container",className:"sk-panel-section"},v.a.createElement(m.a,{messages:this.state.messages})),this.state.status&&v.a.createElement("div",{id:"file-upload-status",className:"sk-horizontal-group"},n&&v.a.createElement("div",{className:"sk-spinner info small"}),v.a.createElement("div",{className:t},this.state.status)),v.a.createElement("div",{id:"add-file-button-container"},v.a.createElement("div",{className:"file sk-button info"},v.a.createElement("label",{className:"no-style"},v.a.createElement("input",{type:"file",style:{display:"none"},onChange:function(t){e.handleDroppedFiles(t.target.files)}}),v.a.createElement("div",{id:"attach-file-button-label",className:"sk-label"},"Attach File")))),v.a.createElement(b.a,{files:this.state.noteFiles}))))}},{key:"rootElement",get:function(){return document.getElementById("filesafe-embed")}},{key:"dropContainer",get:function(){return document.getElementById("files-view")}},{key:"fileInput",get:function(){return document.getElementById("file-input")}}]),t}(v.a.Component)},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;nCreate New under Keys.",css:"sk-base"}),r=this.integrationManager.integrations,r&&0!=r.length||t.push({message:"Add a new integration by selecting Add New under Integrations",css:"sk-base"}),e.abrupt("return",t);case 8:case"end":return e.stop()}},e,this)}));return e}()}]),e}()},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n1;return d.a.createElement("div",null,d.a.createElement("div",{className:"sk-panel-row"},d.a.createElement("div",{className:"sk-h2 sk-bold"},"Integrations"),!this.state.showInputForm&&d.a.createElement("div",{className:"sk-button info no-border",onClick:this.addNewIntegrationClicked},d.a.createElement("div",{className:"sk-label"},"Add New"))),d.a.createElement("div",{id:"integrations"},this.state.showInputForm&&d.a.createElement("div",{className:"sk-notification info"},d.a.createElement("strong",null,"New Integration"),d.a.createElement("p",{className:"sk-p"},"A new tab has opened. After you complete the authentication flow, enter the code you receive below."),d.a.createElement("div",{className:"sk-panel-row"}),d.a.createElement("input",{className:"title sk-input contrast",type:"text",placeholder:"Enter integration code",value:this.state.integrationCode,onChange:this.handleTextChange,onKeyPress:this.handleKeyPress}),d.a.createElement("div",{className:"sk-button-group",style:{marginTop:10}},d.a.createElement("div",{className:"sk-button neutral",onClick:this.cancelIntegrationForm},d.a.createElement("a",{className:"sk-label"},"Cancel")),d.a.createElement("div",{className:"sk-button sk-base",onClick:this.submitIntegrationCode},d.a.createElement("a",{className:"sk-label"},"Submit"))))),d.a.createElement("div",{className:"list-container"},this.state.integrations.map(function(n){return d.a.createElement("div",{className:"list-item sk-horizontal-group top"},d.a.createElement("div",{className:"sk-circle x-small "+(n.content.isDefaultUploadSource?"info":"sk-secondary-contrast")}),d.a.createElement("div",null,d.a.createElement("div",{className:"sk-panel-row condensed sk-bold"},e.displayStringForIntegration(n)),d.a.createElement("div",{className:"sk-panel-row condensed"},d.a.createElement("div",{className:"sk-horizontal-group"},t&&!n.content.isDefaultUploadSource&&d.a.createElement("a",{className:"info",onClick:function(){e.setIntegrationAsDefaultUploadSource(n)}},"Make Default"),d.a.createElement("a",{className:"danger",onClick:function(){e.deleteIntegration(n)}},"Delete")))))})))}}]),t}(d.a.Component)}])},function(e,t){e.exports=function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,n){(function(t){var n,n;!function(t){e.exports=t()}(function(){return function(){function e(t,r,i){function a(s,u){if(!r[s]){if(!t[s]){var c="function"==typeof n&&n;if(!u&&c)return n(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var f=r[s]={exports:{}};t[s][0].call(f.exports,function(e){return a(t[s][1][e]||e)},f,f.exports,e,t,r,i)}return r[s].exports}for(var o="function"==typeof n&&n,s=0;s>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,o=0;4>o&&i+.75*o>>6*(3-o)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var n=e.length,r=this._map,i=r.charAt(64);i&&-1!=(i=e.indexOf(i))&&(n=i);for(var i=[],a=0,o=0;o>>6-o%4*2;i[a>>>2]|=(s|u)<<24-a%4*8,a++}return t.create(i,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){function t(e,t,n,r,i,a,o){return((e=e+(t&n|~t&r)+i+o)<>>32-a)+t}function n(e,t,n,r,i,a,o){return((e=e+(t&r|n&~r)+i+o)<>>32-a)+t}function r(e,t,n,r,i,a,o){return((e=e+(t^n^r)+i+o)<>>32-a)+t}function i(e,t,n,r,i,a,o){return((e=e+(n^(t|~r))+i+o)<>>32-a)+t}for(var a=o,s=a.lib,u=s.WordArray,c=s.Hasher,s=a.algo,l=[],f=0;64>f;f++)l[f]=4294967296*e.abs(e.sin(f+1))|0;s=s.MD5=c.extend({_doReset:function(){this._hash=new u.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,a){for(var o=0;16>o;o++){var s=a+o,u=e[s];e[s]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}var o=this._hash.words,s=e[a+0],u=e[a+1],c=e[a+2],f=e[a+3],p=e[a+4],h=e[a+5],d=e[a+6],y=e[a+7],v=e[a+8],g=e[a+9],m=e[a+10],b=e[a+11],k=e[a+12],w=e[a+13],x=e[a+14],S=e[a+15],_=o[0],C=o[1],I=o[2],R=o[3],_=t(_,C,I,R,s,7,l[0]),R=t(R,_,C,I,u,12,l[1]),I=t(I,R,_,C,c,17,l[2]),C=t(C,I,R,_,f,22,l[3]),_=t(_,C,I,R,p,7,l[4]),R=t(R,_,C,I,h,12,l[5]),I=t(I,R,_,C,d,17,l[6]),C=t(C,I,R,_,y,22,l[7]),_=t(_,C,I,R,v,7,l[8]),R=t(R,_,C,I,g,12,l[9]),I=t(I,R,_,C,m,17,l[10]),C=t(C,I,R,_,b,22,l[11]),_=t(_,C,I,R,k,7,l[12]),R=t(R,_,C,I,w,12,l[13]),I=t(I,R,_,C,x,17,l[14]),C=t(C,I,R,_,S,22,l[15]),_=n(_,C,I,R,u,5,l[16]),R=n(R,_,C,I,d,9,l[17]),I=n(I,R,_,C,b,14,l[18]),C=n(C,I,R,_,s,20,l[19]),_=n(_,C,I,R,h,5,l[20]),R=n(R,_,C,I,m,9,l[21]),I=n(I,R,_,C,S,14,l[22]),C=n(C,I,R,_,p,20,l[23]),_=n(_,C,I,R,g,5,l[24]),R=n(R,_,C,I,x,9,l[25]),I=n(I,R,_,C,f,14,l[26]),C=n(C,I,R,_,v,20,l[27]),_=n(_,C,I,R,w,5,l[28]),R=n(R,_,C,I,c,9,l[29]),I=n(I,R,_,C,y,14,l[30]),C=n(C,I,R,_,k,20,l[31]),_=r(_,C,I,R,h,4,l[32]),R=r(R,_,C,I,v,11,l[33]),I=r(I,R,_,C,b,16,l[34]),C=r(C,I,R,_,x,23,l[35]),_=r(_,C,I,R,u,4,l[36]),R=r(R,_,C,I,p,11,l[37]),I=r(I,R,_,C,y,16,l[38]),C=r(C,I,R,_,m,23,l[39]),_=r(_,C,I,R,w,4,l[40]),R=r(R,_,C,I,s,11,l[41]),I=r(I,R,_,C,f,16,l[42]),C=r(C,I,R,_,d,23,l[43]),_=r(_,C,I,R,g,4,l[44]),R=r(R,_,C,I,k,11,l[45]),I=r(I,R,_,C,S,16,l[46]),C=r(C,I,R,_,c,23,l[47]),_=i(_,C,I,R,s,6,l[48]),R=i(R,_,C,I,y,10,l[49]),I=i(I,R,_,C,x,15,l[50]),C=i(C,I,R,_,h,21,l[51]),_=i(_,C,I,R,k,6,l[52]),R=i(R,_,C,I,f,10,l[53]),I=i(I,R,_,C,m,15,l[54]),C=i(C,I,R,_,u,21,l[55]),_=i(_,C,I,R,v,6,l[56]),R=i(R,_,C,I,S,10,l[57]),I=i(I,R,_,C,d,15,l[58]),C=i(C,I,R,_,w,21,l[59]),_=i(_,C,I,R,p,6,l[60]),R=i(R,_,C,I,b,10,l[61]),I=i(I,R,_,C,c,15,l[62]),C=i(C,I,R,_,g,21,l[63]);o[0]=o[0]+_|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+R|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var a=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),t=this._hash,n=t.words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=c.clone.call(this);return e._hash=this._hash.clone(),e}}),a.MD5=c._createHelper(s),a.HmacMD5=c._createHmacHelper(s)}(Math),function(){var e=o,t=e.lib,n=t.Base,r=t.WordArray,t=e.algo,i=t.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=this.cfg,i=n.hasher.create(),a=r.create(),o=a.words,s=n.keySize,n=n.iterations;o.length>>2]}},n.BlockCipher=c.extend({cfg:c.cfg.extend({mode:l,padding:p}),reset:function(){c.reset.call(this);var e=this.cfg,t=e.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(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var h=n.CipherParams=r.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),l=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return e=e.salt,(e?i.create([1398893684,1701076831]).concat(e).concat(t):t).toString(s)},parse:function(e){e=s.parse(e);var t=e.words;if(1398893684==t[0]&&1701076831==t[1]){var n=i.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return h.create({ciphertext:e,salt:n})}},d=n.SerializableCipher=r.extend({cfg:r.extend({format:l}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,h.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),t=(t.kdf={}).OpenSSL={execute:function(e,t,n,r){return r||(r=i.random(8)),e=u.create({keySize:t+n}).compute(e,r),n=i.create(e.words.slice(t),4*n),e.sigBytes=4*t,h.create({key:e,iv:n,salt:r})}},y=n.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:t}),encrypt:function(e,t,n,r){return r=this.cfg.extend(r),n=r.kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,e=d.encrypt.call(this,e,t,n.key,r),e.mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,d.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=o,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],a=[],s=[],u=[],c=[],l=[],f=[],p=[],h=[],d=[],y=0;256>y;y++)d[y]=128>y?y<<1:y<<1^283;for(var v=0,g=0,y=0;256>y;y++){var m=g^g<<1^g<<2^g<<3^g<<4,m=m>>>8^255&m^99;r[v]=m,i[m]=v;var b=d[v],k=d[b],w=d[k],x=257*d[m]^16843008*m;a[v]=x<<24|x>>>8,s[v]=x<<16|x>>>16,u[v]=x<<8|x>>>24,c[v]=x,x=16843009*w^65537*k^257*b^16843008*v,l[m]=x<<24|x>>>8,f[m]=x<<16|x>>>16,p[m]=x<<8|x>>>24,h[m]=x,v?(v=b^d[d[d[w^b]]],g^=d[d[g]]):v=g=1}var S=[0,1,2,4,8,16,32,64,128,27,54],n=n.AES=t.extend({_doReset:function(){for(var e=this._key,t=e.words,n=e.sigBytes/4,e=4*((this._nRounds=n+6)+1),i=this._keySchedule=[],a=0;a>>24]<<24|r[o>>>16&255]<<16|r[o>>>8&255]<<8|r[255&o]):(o=o<<8|o>>>24,o=r[o>>>24]<<24|r[o>>>16&255]<<16|r[o>>>8&255]<<8|r[255&o],o^=S[a/n|0]<<24),i[a]=i[a-n]^o}for(t=this._invKeySchedule=[],n=0;nn||4>=a?o:l[r[o>>>24]]^f[r[o>>>16&255]]^p[r[o>>>8&255]]^h[r[255&o]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,u,c,r)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,l,f,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,a,o,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],f=e[t+2]^n[2],p=e[t+3]^n[3],h=4,d=1;d>>24]^i[l>>>16&255]^a[f>>>8&255]^o[255&p]^n[h++],v=r[l>>>24]^i[f>>>16&255]^a[p>>>8&255]^o[255&c]^n[h++],g=r[f>>>24]^i[p>>>16&255]^a[c>>>8&255]^o[255&l]^n[h++],p=r[p>>>24]^i[c>>>16&255]^a[l>>>8&255]^o[255&f]^n[h++],c=y,l=v,f=g;y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[f>>>8&255]<<8|s[255&p])^n[h++],v=(s[l>>>24]<<24|s[f>>>16&255]<<16|s[p>>>8&255]<<8|s[255&c])^n[h++],g=(s[f>>>24]<<24|s[p>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[h++],p=(s[p>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&f])^n[h++],e[t]=y,e[t+1]=v,e[t+2]=g,e[t+3]=p},keySize:8});e.AES=t._createHelper(n)}();var o=o||function(e,t){var n={},r=n.lib={},i=function(){},a=r.Base={extend:function(e){i.prototype=this;var t=new i;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=r.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;ul;){var f;e:{f=c;for(var p=e.sqrt(f),h=2;h<=p;h++)if(!(f%h)){f=!1;break e}f=!0}f&&(8>l&&(a[l]=u(e.pow(c,.5))),s[l]=u(e.pow(c,1/3)),l++),c++}var d=[],n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],a=n[2],o=n[3],u=n[4],c=n[5],l=n[6],f=n[7],p=0;64>p;p++){if(16>p)d[p]=0|e[t+p];else{var h=d[p-15],y=d[p-2];d[p]=((h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3)+d[p-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+d[p-16]}h=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[p]+d[p],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&a^i&a),f=l,l=c,c=u,u=o+h|0,o=a,a=i,i=r,r=h+y|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+f|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(n),t.HmacSHA256=i._createHmacHelper(n)}(Math),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var a=this._oKey=n.clone(),o=this._iKey=n.clone(),s=a.words,u=o.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;uc;c++)u[c]=e();r=r.SHA512=n.extend({_doReset:function(){this._hash=new a.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],a=n[2],o=n[3],c=n[4],l=n[5],f=n[6],n=n[7],p=r.high,h=r.low,d=i.high,y=i.low,v=a.high,g=a.low,m=o.high,b=o.low,k=c.high,w=c.low,x=l.high,S=l.low,_=f.high,C=f.low,I=n.high,R=n.low,E=p,F=h,P=d,D=y,O=v,M=g,A=m,T=b,N=k,j=w,B=x,L=S,H=_,U=C,z=I,K=R,W=0;80>W;W++){var V=u[W];if(16>W)var J=V.high=0|e[t+2*W],q=V.low=0|e[t+2*W+1];else{var J=u[W-15],q=J.high,$=J.low,J=(q>>>1|$<<31)^(q>>>8|$<<24)^q>>>7,$=($>>>1|q<<31)^($>>>8|q<<24)^($>>>7|q<<25),G=u[W-2],q=G.high,Q=G.low,G=(q>>>19|Q<<13)^(q<<3|Q>>>29)^q>>>6,Q=(Q>>>19|q<<13)^(Q<<3|q>>>29)^(Q>>>6|q<<26),q=u[W-7],Y=q.high,X=u[W-16],Z=X.high,X=X.low,q=$+q.low,J=J+Y+(q>>>0<$>>>0?1:0),q=q+Q,J=J+G+(q>>>0>>0?1:0),q=q+X,J=J+Z+(q>>>0>>0?1:0);V.high=J,V.low=q}var Y=N&B^~N&H,X=j&L^~j&U,V=E&P^E&O^P&O,ee=F&D^F&M^D&M,$=(E>>>28|F<<4)^(E<<30|F>>>2)^(E<<25|F>>>7),G=(F>>>28|E<<4)^(F<<30|E>>>2)^(F<<25|E>>>7),Q=s[W],te=Q.high,ne=Q.low,Q=K+((j>>>14|N<<18)^(j>>>18|N<<14)^(j<<23|N>>>9)),Z=z+((N>>>14|j<<18)^(N>>>18|j<<14)^(N<<23|j>>>9))+(Q>>>0>>0?1:0),Q=Q+X,Z=Z+Y+(Q>>>0>>0?1:0),Q=Q+ne,Z=Z+te+(Q>>>0>>0?1:0),Q=Q+q,Z=Z+J+(Q>>>0>>0?1:0),q=G+ee,V=$+V+(q>>>0>>0?1:0),z=H,K=U,H=B,U=L,B=N,L=j,j=T+Q|0,N=A+Z+(j>>>0>>0?1:0)|0,A=O,T=M,O=P,M=D,P=E,D=F,F=Q+q|0,E=Z+V+(F>>>0>>0?1:0)|0}h=r.low=h+F,r.high=p+E+(h>>>0>>0?1:0),y=i.low=y+D,i.high=d+P+(y>>>0>>0?1:0),g=a.low=g+M,a.high=v+O+(g>>>0>>0?1:0),b=o.low=b+T,o.high=m+A+(b>>>0>>0?1:0),w=c.low=w+j,c.high=k+N+(w>>>0>>0?1:0),S=l.low=S+L,l.high=x+B+(S>>>0>>0?1:0),C=f.low=C+U,f.high=_+H+(C>>>0>>0?1:0),R=n.low=R+K,n.high=I+z+(R>>>0>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(r+128>>>10<<5)]=Math.floor(n/4294967296),t[31+(r+128>>>10<<5)]=n,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32}),t.SHA512=n._createHelper(r),t.HmacSHA512=n._createHmacHelper(r)}(),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var a=this._oKey=n.clone(),o=this._iKey=n.clone(),s=a.words,u=o.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;uc;c++){if(16>c)i[c]=0|e[t+c];else{var l=i[c-3]^i[c-8]^i[c-14]^i[c-16];i[c]=l<<1|l>>>31}l=(r<<5|r>>>27)+u+i[c],l=20>c?l+(1518500249+(a&o|~a&s)):40>c?l+(1859775393+(a^o^s)):60>c?l+((a&o|a&s|o&s)-1894007588):l+((a^o^s)-899497514),u=s,s=o,o=a<<30|a>>>2,a=r,r=l}n[0]=n[0]+r|0,n[1]=n[1]+a|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});e.SHA1=r._createHelper(t),e.HmacSHA1=r._createHmacHelper(t)}(),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var a=this._oKey=n.clone(),o=this._iKey=n.clone(),s=a.words,u=o.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){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(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,a=this.blockSize,s=i/(4*a),s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0);if(t=s*a,i=e.min(4*t,i),t){for(var u=0;uc;c++){if(16>c)i[c]=0|e[t+c];else{var l=i[c-3]^i[c-8]^i[c-14]^i[c-16];i[c]=l<<1|l>>>31}l=(r<<5|r>>>27)+u+i[c],l=20>c?l+(1518500249+(a&o|~a&s)):40>c?l+(1859775393+(a^o^s)):60>c?l+((a&o|a&s|o&s)-1894007588):l+((a^o^s)-899497514),u=s,s=o,o=a<<30|a>>>2,a=r,r=l}n[0]=n[0]+r|0,n[1]=n[1]+a|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});e.SHA1=r._createHelper(t),e.HmacSHA1=r._createHmacHelper(t)}(),Object.defineProperty(r,"__esModule",{value:!0});var s,u=function(){function e(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l=function(){function e(e,t){for(var n=0;n=200&&c.status<=299?s.$timeout(function(){a(e),i(e)}):(console.error("Request error:",e),s.$timeout(function(){o(e,c.status),u(e)}))}},"get"==t&&Object.keys(r).length>0&&(n+=s.formatParams(r)),c.open(t,n,!0),e.next=6,s.setAuthHeadersForRequest(c);case 6:c.setRequestHeader("Content-type","application/json"),"post"==t||"patch"==t?c.send(JSON.stringify(r)):c.send();case 8:case"end":return e.stop()}},e,s)}));return function(t,n){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"formatParams",value:function(e){return"?"+Object.keys(e).map(function(t){return t+"="+encodeURIComponent(e[t])}).join("&")}}]),e}(),y=r.SFMigrationManager=function(){function e(t,n,r,o){var s=this;a(this,e),this.modelManager=t,this.syncManager=n,this.storageManager=r,this.completionHandlers=[],this.loadMigrations();var u=!1,c=o.addEventHandler(function(e){e==p.DidSignInEvent&&(u=!0)});this.syncManager.addEventHandler(function(){var e=i(regeneratorRuntime.mark(function e(t,n){var r,i,a,l,f,p,h,d,y,v;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r="local-data-loaded"==t,i="sync:completed"==t,!r&&!i){e.next=40;break}if(r?s.receivedLocalDataEvent=!0:i&&(s.receivedSyncCompletedEvent=!0),!s.receivedLocalDataEvent||!s.receivedSyncCompletedEvent){e.next=40;break}if(!u){e.next=39;break}return u=!1,o.removeEventHandler(c),e.next=10,s.getCompletedMigrations();case 10:a=e.sent.slice(),l=!0,f=!1,p=void 0,e.prev=14,h=a[Symbol.iterator]();case 16:if(l=(d=h.next()).done){e.next=25;break}return y=d.value,e.next=20,s.migrationForEncodedName(y);case 20:v=e.sent,v.runOnlyOnce||_.pull(s._completed,y);case 22:l=!0,e.next=16;break;case 25:e.next=31;break;case 27:e.prev=27,e.t0=e.catch(14),f=!0,p=e.t0;case 31:e.prev=31,e.prev=32,!l&&h.return&&h.return();case 34:if(e.prev=34,!f){e.next=37;break}throw p;case 37:return e.finish(34);case 38:return e.finish(31);case 39:s.runPendingMigrations();case 40:case"end":return e.stop()}},e,s,[[14,27,31,39],[32,,34,38]])}));return function(t,n){return e.apply(this,arguments)}}())}return l(e,[{key:"addCompletionHandler",value:function(e){this.completionHandlers.push(e)}},{key:"removeCompletionHandler",value:function(e){_.pull(this.completionHandlers,e)}},{key:"migrationForEncodedName",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.decode(t);case 2:return n=e.sent,e.abrupt("return",this.migrations.find(function(e){return e.name==n}));case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"loadMigrations",value:function(){this.migrations=this.registeredMigrations()}},{key:"registeredMigrations",value:function(){}},{key:"runPendingMigrations",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a,o,s,u,c,l,f,p,h,d,y,v,g,m,b,k,w,x,S,_,C,I,R,E,F;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPendingMigrations();case 2:for(t=e.sent,n=!0,r=!1,i=void 0,e.prev=6,a=t[Symbol.iterator]();!(n=(o=a.next()).done);n=!0)s=o.value,s.items=[];e.next=14;break;case 10:e.prev=10,e.t0=e.catch(6),r=!0,i=e.t0;case 14:e.prev=14,e.prev=15,!n&&a.return&&a.return();case 17:if(e.prev=17,!r){e.next=20;break}throw i;case 20:return e.finish(17);case 21:return e.finish(14);case 22:u=!0,c=!1,l=void 0,e.prev=25,f=this.modelManager.allNondummyItems[Symbol.iterator]();case 27:if(u=(p=f.next()).done){e.next=51;break}for(h=p.value,d=!0,y=!1,v=void 0,e.prev=32,g=t[Symbol.iterator]();!(d=(m=g.next()).done);d=!0)s=m.value,h.content_type==s.content_type&&s.items.push(h);e.next=40;break;case 36:e.prev=36,e.t1=e.catch(32),y=!0,v=e.t1;case 40:e.prev=40,e.prev=41,!d&&g.return&&g.return();case 43:if(e.prev=43,!y){e.next=46;break}throw v;case 46:return e.finish(43);case 47:return e.finish(40);case 48:u=!0,e.next=27;break;case 51:e.next=57;break;case 53:e.prev=53,e.t2=e.catch(25),c=!0,l=e.t2;case 57:e.prev=57,e.prev=58,!u&&f.return&&f.return();case 60:if(e.prev=60,!c){e.next=63;break}throw l;case 63:return e.finish(60);case 64:return e.finish(57);case 65:b=!0,k=!1,w=void 0,e.prev=68,x=t[Symbol.iterator]();case 70:if(b=(S=x.next()).done){e.next=81;break}if(s=S.value,!(s.items&&s.items.length>0||s.customHandler)){e.next=77;break}return e.next=75,this.runMigration(s,s.items);case 75:e.next=78;break;case 77:this.markMigrationCompleted(s);case 78:b=!0,e.next=70;break;case 81:e.next=87;break;case 83:e.prev=83,e.t3=e.catch(68),k=!0,w=e.t3;case 87:e.prev=87,e.prev=88,!b&&x.return&&x.return();case 90:if(e.prev=90,!k){e.next=93;break}throw w;case 93:return e.finish(90);case 94:return e.finish(87);case 95:for(_=!0,C=!1,I=void 0,e.prev=98,R=this.completionHandlers[Symbol.iterator]();!(_=(E=R.next()).done);_=!0)(F=E.value)();e.next=106;break;case 102:e.prev=102,e.t4=e.catch(98),C=!0,I=e.t4;case 106:e.prev=106,e.prev=107,!_&&R.return&&R.return();case 109:if(e.prev=109,!C){e.next=112;break}throw I;case 112:return e.finish(109);case 113:return e.finish(106);case 114:case"end":return e.stop()}},e,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]])}));return e}()},{key:"encode",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",window.btoa(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"decode",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",window.atob(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"getCompletedMigrations",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._completed){e.next=5;break}return e.next=3,this.storageManager.getItem("migrations");case 3:t=e.sent,this._completed=t?JSON.parse(t):[];case 5:return e.abrupt("return",this._completed);case 6:case"end":return e.stop()}},e,this)}));return e}()},{key:"getPendingMigrations",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a,o,s,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getCompletedMigrations();case 2:t=e.sent,n=[],r=!0,i=!1,a=void 0,e.prev=7,o=this.migrations[Symbol.iterator]();case 9:if(r=(s=o.next()).done){e.next=22;break}return u=s.value,e.t0=t,e.next=14,this.encode(u.name);case 14:if(e.t1=e.sent,e.t2=e.t0.indexOf.call(e.t0,e.t1),e.t3=-1,e.t2!=e.t3){e.next=19;break}n.push(u);case 19:r=!0,e.next=9;break;case 22:e.next=28;break;case 24:e.prev=24,e.t4=e.catch(7),i=!0,a=e.t4;case 28:e.prev=28,e.prev=29,!r&&o.return&&o.return();case 31:if(e.prev=31,!i){e.next=34;break}throw a;case 34:return e.finish(31);case 35:return e.finish(28);case 36:return e.abrupt("return",n);case 37:case"end":return e.stop()}},e,this,[[7,24,28,36],[29,,31,35]])}));return e}()},{key:"markMigrationCompleted",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getCompletedMigrations();case 2:return n=e.sent,e.t0=n,e.next=6,this.encode(t.name);case 6:e.t1=e.sent,e.t0.push.call(e.t0,e.t1),this.storageManager.setItem("migrations",JSON.stringify(n)),t.running=!1;case 10:case"end":return e.stop()}},e,this)}));return e}()},{key:"runMigration",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.running){e.next=2;break}return e.abrupt("return");case 2:if(console.log("Running migration:",t.name),t.running=!0,!t.customHandler){e.next=8;break}return e.abrupt("return",t.customHandler().then(function(){r.markMigrationCompleted(t)}));case 8:return e.abrupt("return",t.handler(n).then(function(){r.markMigrationCompleted(t)}));case 9:case"end":return e.stop()}},e,this)}));return e}()}]),e}(),v=r.SFModelManager=function(){function e(t){a(this,e),e.MappingSourceRemoteRetrieved="MappingSourceRemoteRetrieved",e.MappingSourceRemoteSaved="MappingSourceRemoteSaved",e.MappingSourceLocalSaved="MappingSourceLocalSaved",e.MappingSourceLocalRetrieved="MappingSourceLocalRetrieved",e.MappingSourceComponentRetrieved="MappingSourceComponentRetrieved",e.MappingSourceDesktopInstalled="MappingSourceDesktopInstalled",e.MappingSourceRemoteActionRetrieved="MappingSourceRemoteActionRetrieved",e.MappingSourceFileImport="MappingSourceFileImport",e.isMappingSourceRetrieved=function(t){return[e.MappingSourceRemoteRetrieved,e.MappingSourceComponentRetrieved,e.MappingSourceRemoteActionRetrieved].includes(t)},this.$timeout=t||setTimeout.bind(window),this.itemSyncObservers=[],this.itemsPendingRemoval=[],this.items=[],this.itemsHash={},this.missedReferences={},this.uuidChangeObservers=[]}return l(e,[{key:"handleSignout",value:function(){this.items.length=0,this.itemsHash={},this.itemsPendingRemoval.length=0,this.missedReferences={}}},{key:"addModelUuidChangeObserver",value:function(e,t){this.uuidChangeObservers.push({id:e,callback:t})}},{key:"notifyObserversOfUuidChange",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.uuidChangeObservers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){a.value.callback(e,t)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"alternateUUIDForItem",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.createItem(n,!0),t.next=3,SFJS.crypto.generateUUID();case 3:for(r.uuid=t.sent,r.informReferencesOfUUIDChange(n.uuid,r.uuid),this.informModelsOfUUIDChangeForItem(r,n.uuid,r.uuid),i=!0,a=!1,o=void 0,t.prev=9,s=n.referencingObjects[Symbol.iterator]();!(i=(u=s.next()).done);i=!0)c=u.value,c.setIsNoLongerBeingReferencedBy(n),n.setIsNoLongerBeingReferencedBy(c),c.addItemAsRelationship(r),c.setDirty(!0);t.next=17;break;case 13:t.prev=13,t.t0=t.catch(9),a=!0,o=t.t0;case 17:t.prev=17,t.prev=18,!i&&s.return&&s.return();case 20:if(t.prev=20,!a){t.next=23;break}throw o;case 23:return t.finish(20);case 24:return t.finish(17);case 25:return this.resolveReferencesForItem(r),console.log(n.uuid,"--\x3e",r.uuid),n.deleted=!0,n.content.references=[],n.setDirty(!1),this.mapResponseItemsToLocalModels([n],e.MappingSourceLocalSaved),this.addItem(r),r.setDirty(!0),this.notifyObserversOfUuidChange(n,r),t.abrupt("return",r);case 35:case"end":return t.stop()}},t,this,[[9,13,17,25],[18,,20,24]])}));return t}()},{key:"informModelsOfUUIDChangeForItem",value:function(e,t,n){var r=!0,i=!1,a=void 0;try{for(var o,s=this.items[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){o.value.potentialItemOfInterestHasChangedItsUUID(e,t,n)}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}}},{key:"didSyncModelsOffline",value:function(t){this.notifySyncObserversOfModels(t,e.MappingSourceLocalSaved)}},{key:"mapResponseItemsToLocalModels",value:function(e,t,n){return this.mapResponseItemsToLocalModelsWithOptions({items:e,source:t,sourceKey:n})}},{key:"mapResponseItemsToLocalModelsOmittingFields",value:function(e,t,n,r){return this.mapResponseItemsToLocalModelsWithOptions({items:e,omitFields:t,source:n,sourceKey:r})}},{key:"mapResponseItemsToLocalModelsWithOptions",value:function(e){var t=e.items,n=e.omitFields,r=e.source,i=e.sourceKey,a=(e.options,[]),o=[],s=[],c=!0,l=!1,f=void 0;try{for(var p,h=t[Symbol.iterator]();!(c=(p=h.next()).done);c=!0){var d=p.value;if(d){var y=!d.content&&!d.errorDecrypting;if(!(!d.content_type||!d.uuid)&&!y||d.deleted){if(Array.isArray(n)){var v=!0,g=!1,m=void 0;try{for(var b,k=n[Symbol.iterator]();!(v=(b=k.next()).done);v=!0){delete d[b.value]}}catch(e){g=!0,m=e}finally{try{!v&&k.return&&k.return()}finally{if(g)throw m}}}var w=this.findItem(d.uuid);if(w&&(w.updateFromJSON(d),w.dummy=!1),this.itemsPendingRemoval.includes(d.uuid))_.pull(this.itemsPendingRemoval,d.uuid);else{var x=d.content_type||w&&w.content_type;if(!(this.acceptableContentTypes&&!this.acceptableContentTypes.includes(x))){var S=!1;if(1==d.deleted){if(!d.dirty){w&&(s.push(w),this.removeItemLocally(w));continue}S=!0}w||(w=this.createItem(d,!0)),this.addItem(w,S),w.errorDecrypting||s.push(w),a.push(w),o.push(d)}}}else console.error("Server response item is corrupt:",d)}}}catch(e){l=!0,f=e}finally{try{!c&&h.return&&h.return()}finally{if(l)throw f}}var C=!0,I=!1,R=void 0;try{for(var E,F=o.entries()[Symbol.iterator]();!(C=(E=F.next()).done);C=!0){var P=E.value,D=u(P,2),O=D[0],M=D[1],A=a[O];M.content&&this.resolveReferencesForItem(A),A.didFinishSyncing()}}catch(e){I=!0,R=e}finally{try{!C&&F.return&&F.return()}finally{if(I)throw R}}var T=this.popMissedReferenceStructsForObjects(o),N=!0,j=!1,B=void 0;try{for(var L,H=T[Symbol.iterator]();!(N=(L=H.next()).done);N=!0){var U=L.value;!function(e){var t=a.find(function(t){return t.uuid==e.reference_uuid});if(t){e.for_item.addItemAsRelationship(t)}}(U)}}catch(e){j=!0,B=e}finally{try{!N&&H.return&&H.return()}finally{if(j)throw B}}return this.notifySyncObserversOfModels(s,r,i),a}},{key:"missedReferenceBuildKey",value:function(e,t){return e+":"+t}},{key:"popMissedReferenceStructsForObjects",value:function(e){if(!e||0==e.length)return[];var t=[],n=[],r=e.map(function(e){return e.uuid}),i=r[0].length,a=Object.keys(this.missedReferences),o=!0,s=!1,u=void 0;try{for(var c,l=a[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var f=c.value;r.includes(f.substring(0,i))&&(t.push(this.missedReferences[f]),n.push(f))}}catch(e){s=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw u}}var p=!0,h=!1,d=void 0;try{for(var y,v=n[Symbol.iterator]();!(p=(y=v.next()).done);p=!0){var g=y.value;delete this.missedReferences[g]}}catch(e){h=!0,d=e}finally{try{!p&&v.return&&v.return()}finally{if(h)throw d}}return t}},{key:"resolveReferencesForItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e.errorDecrypting){var n=e.contentObject;if(e.updateLocalRelationships(),n.references){var r=n.references.slice(),i=r.map(function(e){return e.uuid}),a=this.findItems(i,!0),o=!0,s=!1,c=void 0;try{for(var l,f=a.entries()[Symbol.iterator]();!(o=(l=f.next()).done);o=!0){var p=l.value,h=u(p,2),d=h[0],y=h[1];if(y)e.addItemAsRelationship(y),t&&y.setDirty(!0);else{var v=i[d],g=this.missedReferenceBuildKey(v,e.uuid);if(!this.missedReferences[g]){var m={reference_uuid:v,for_item:e};this.missedReferences[g]=m}}}}catch(e){s=!0,c=e}finally{try{!o&&f.return&&f.return()}finally{if(s)throw c}}}}}},{key:"notifySyncObserversOfModels",value:function(e,t,n){var r=this,i=this.itemSyncObservers.sort(function(e,t){return e.priority0&&r._callSyncObserverCallbackWithTimeout(i,a,o,s,t,n)}(l)}}catch(e){o=!0,s=e}finally{try{!a&&c.return&&c.return()}finally{if(o)throw s}}}},{key:"_callSyncObserverCallbackWithTimeout",value:function(e,t,n,r,i,a){this.$timeout(function(){e.callback(t,n,r,i,a)})}},{key:"createItem",value:function(t,n){var r=e.ContentTypeClassMapping&&e.ContentTypeClassMapping[t.content_type];r||(r=x);var i=new r(t);return n||this.notifySyncObserversOfModels([i],e.MappingSourceLocalSaved),i}},{key:"createConflictedItem",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,SFJS.crypto.generateUUID();case 2:return n=e.sent,t=_.merge(t,{uuid:n}),r=this.createItem(t,!0),e.abrupt("return",r);case 6:case"end":return e.stop()}},e,this)}));return e}()},{key:"addConflictedItem",value:function(e,t){this.addItem(e);var n=!0,r=!1,i=void 0;try{for(var a,o=t.referencingObjects[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;s.addItemAsRelationship(e),s.setDirty(!0)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}this.resolveReferencesForItem(e),e.content.conflict_of=t.uuid,e.setDirty(!0)}},{key:"duplicateItem",value:function(e){var t=new e.constructor({content:e.content});t.created_at=e.created_at,t.content_type=e.content_type,this.addItem(t);var n=!0,r=!1,i=void 0;try{for(var a,o=e.referencingObjects[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;s.addItemAsRelationship(t),s.setDirty(!0)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return this.resolveReferencesForItem(t),t.setDirty(!0),t}},{key:"addItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.addItems([e],t)}},{key:"addItems",value:function(e){var t=this;arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.forEach(function(e){t.itemsHash[e.uuid]||(t.itemsHash[e.uuid]=e,t.items.push(e))})}},{key:"addItemSyncObserver",value:function(e,t,n){this.addItemSyncObserverWithPriority({id:e,types:t,callback:n,priority:1})}},{key:"addItemSyncObserverWithPriority",value:function(e){var t=e.id,n=e.priority,r=e.types,i=e.callback;Array.isArray(r)||(r=[r]),this.itemSyncObservers.push({id:t,types:r,priority:n,callback:i})}},{key:"removeItemSyncObserver",value:function(e){_.remove(this.itemSyncObservers,_.find(this.itemSyncObservers,{id:e}))}},{key:"getDirtyItems",value:function(){return this.items.filter(function(e){return 1==e.dirty&&!e.dummy&&(!e.errorDecrypting||e.deleted)})}},{key:"clearDirtyItems",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){i.value.setDirty(!1)}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}}},{key:"setItemToBeDeleted",value:function(e){e.deleted=!0,e.dummy||e.setDirty(!0),this.removeAndDirtyAllRelationshipsForItem(e)}},{key:"removeAndDirtyAllRelationshipsForItem",value:function(e){if(!e.errorDecrypting){var t=!0,n=!1,r=void 0;try{for(var i,a=e.content.references[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value,s=this.findItem(o.uuid);s&&(e.removeItemAsRelationship(s),s.hasRelationshipWithItem(e)&&(s.removeItemAsRelationship(e),s.setDirty(!0)))}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}}var u=!0,c=!1,l=void 0;try{for(var f,p=e.referencingObjects[Symbol.iterator]();!(u=(f=p.next()).done);u=!0){var h=f.value;h.removeItemAsRelationship(e),h.setDirty(!0)}}catch(e){c=!0,l=e}finally{try{!u&&p.return&&p.return()}finally{if(c)throw l}}e.referencingObjects=[]}},{key:"setAllItemsDirty",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.allItems,n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){a.value.setDirty(!0,e)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"removeItemLocally",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:_.remove(this.items,{uuid:t.uuid}),delete this.itemsHash[t.uuid],t.isBeingRemovedLocally(),this.itemsPendingRemoval.push(t.uuid);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"allItemsMatchingTypes",value:function(e){return this.allItems.filter(function(t){return(_.includes(e,t.content_type)||_.includes(e,"*"))&&!t.dummy})}},{key:"invalidItems",value:function(){return this.allItems.filter(function(e){return e.errorDecrypting})}},{key:"validItemsForContentType",value:function(e){return this.allItems.filter(function(t){return t.content_type==e&&!t.errorDecrypting})}},{key:"findItem",value:function(e){return this.itemsHash[e]}},{key:"findItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value,c=this.itemsHash[u];(c||t)&&n.push(c)}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return n}},{key:"itemsMatchingPredicate",value:function(e){return this.itemsMatchingPredicates([e])}},{key:"itemsMatchingPredicates",value:function(e){return this.filterItemsWithPredicates(this.allItems,e)}},{key:"filterItemsWithPredicates",value:function(e,t){return e.filter(function(e){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(!e.satisfiesPredicate(s))return!1}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return!0})}},{key:"importItems",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c,l,f,p,h,d,y,v,g,m;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:r=[],i=!0,a=!1,o=void 0,t.prev=4,s=n[Symbol.iterator]();case 6:if(i=(u=s.next()).done){t.next=21;break}if(c=u.value,!(l=this.findItem(c.uuid))||l.errorDecrypting){t.next=16;break}return t.next=12,this.createConflictedItem(c);case 12:f=t.sent,c.deleted||l.isItemContentEqualWith(f)||(this.addConflictedItem(f,l),r.push(f)),t.next=18;break;case 16:r.push(c),l&&l.errorDecrypting&&(l.errorDecrypting=!1);case 18:i=!0,t.next=6;break;case 21:t.next=27;break;case 23:t.prev=23,t.t0=t.catch(4),a=!0,o=t.t0;case 27:t.prev=27,t.prev=28,!i&&s.return&&s.return();case 30:if(t.prev=30,!a){t.next=33;break}throw o;case 33:return t.finish(30);case 34:return t.finish(27);case 35:for(p=this.mapResponseItemsToLocalModels(r,e.MappingSourceFileImport),h=!0,d=!1,y=void 0,t.prev=39,v=p[Symbol.iterator]();!(h=(g=v.next()).done);h=!0)m=g.value,m.setDirty(!0,!0),m.deleted=!1;t.next=47;break;case 43:t.prev=43,t.t1=t.catch(39),d=!0,y=t.t1;case 47:t.prev=47,t.prev=48,!h&&v.return&&v.return();case 50:if(t.prev=50,!d){t.next=53;break}throw y;case 53:return t.finish(50);case 54:return t.finish(47);case 55:return t.abrupt("return",p);case 56:case"end":return t.stop()}},t,this,[[4,23,27,35],[28,,30,34],[39,43,47,55],[48,,50,54]])}));return t}()},{key:"getAllItemsJSONData",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.getJSONDataForItems(this.allItems,t,n,r));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"getJSONDataForItems",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.all(t.map(function(e){return new S(e,n,r).paramsForExportFile()})).then(function(e){if(i&&0==e.length)return null;var t={items:e};return n&&(t.auth_params=r),JSON.stringify(t,null,2)}));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"computeDataIntegrityHash",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=this.allNondummyItems.sort(function(e,t){return t.updated_at-e.updated_at}),n=t.map(function(e){return e.updatedAtTimestamp()}),r=n.join(","),e.next=6,SFJS.crypto.sha256(r);case 6:return i=e.sent,e.abrupt("return",i);case 10:return e.prev=10,e.t0=e.catch(0),console.error("Error computing data integrity hash",e.t0),e.abrupt("return",null);case 14:case"end":return e.stop()}},e,this,[[0,10]])}));return e}()},{key:"allItems",get:function(){return this.items.slice()}},{key:"allNondummyItems",get:function(){return this.items.filter(function(e){return!e.dummy})}}]),e}(),g=r.SFPrivilegesManager=function(){function e(t,n,r){a(this,e),this.modelManager=t,this.syncManager=n,this.singletonManager=r,this.loadPrivileges(),e.CredentialAccountPassword="CredentialAccountPassword",e.CredentialLocalPasscode="CredentialLocalPasscode",e.ActionManageExtensions="ActionManageExtensions",e.ActionManageBackups="ActionManageBackups",e.ActionViewProtectedNotes="ActionViewProtectedNotes",e.ActionManagePrivileges="ActionManagePrivileges",e.ActionManagePasscode="ActionManagePasscode",e.ActionDeleteNote="ActionDeleteNote",e.SessionExpiresAtKey="SessionExpiresAtKey",e.SessionLengthKey="SessionLengthKey",e.SessionLengthNone=0,e.SessionLengthFiveMinutes=300,e.SessionLengthOneHour=3600,e.SessionLengthOneWeek=604800,this.availableActions=[e.ActionViewProtectedNotes,e.ActionDeleteNote,e.ActionManagePasscode,e.ActionManageBackups,e.ActionManageExtensions,e.ActionManagePrivileges],this.availableCredentials=[e.CredentialAccountPassword,e.CredentialLocalPasscode],this.sessionLengths=[e.SessionLengthNone,e.SessionLengthFiveMinutes,e.SessionLengthOneHour,e.SessionLengthOneWeek,e.SessionLengthIndefinite]}return l(e,[{key:"setDelegate",value:function(e){this.delegate=e}},{key:"getAvailableActions",value:function(){return this.availableActions}},{key:"getAvailableCredentials",value:function(){return this.availableCredentials}},{key:"netCredentialsForAction",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPrivileges();case 2:t.t0=n,r=t.sent.getCredentialsForAction(t.t0),i=[],a=!0,o=!1,s=void 0,t.prev=8,u=r[Symbol.iterator]();case 10:if(a=(c=u.next()).done){t.next=27;break}if((l=c.value)!=e.CredentialAccountPassword){t.next=19;break}return t.next=15,this.delegate.isOffline();case 15:f=t.sent,f||i.push(l),t.next=24;break;case 19:if(l!=e.CredentialLocalPasscode){t.next=24;break}return t.next=22,this.delegate.hasLocalPasscode();case 22:p=t.sent,p&&i.push(l);case 24:a=!0,t.next=10;break;case 27:t.next=33;break;case 29:t.prev=29,t.t1=t.catch(8),o=!0,s=t.t1;case 33:t.prev=33,t.prev=34,!a&&u.return&&u.return();case 36:if(t.prev=36,!o){t.next=39;break}throw s;case 39:return t.finish(36);case 40:return t.finish(33);case 41:return t.abrupt("return",i);case 42:case"end":return t.stop()}},t,this,[[8,29,33,41],[34,,36,40]])}));return t}()},{key:"loadPrivileges",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.loadPromise){e.next=2;break}return e.abrupt("return",this.loadPromise);case 2:return this.loadPromise=new Promise(function(e,n){var r=I.contentType(),a=new C("content_type","=",r);t.singletonManager.registerSingleton([a],function(n){t.privileges=n,e(n)},function(){var n=i(regeneratorRuntime.mark(function n(i){var a;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(a=new I({content_type:r}),SFJS.crypto.generateUUIDSync){n.next=4;break}return n.next=4,a.initUUID();case 4:t.modelManager.addItem(a),a.setDirty(!0),t.syncManager.sync(),i(a),e(a);case 9:case"end":return n.stop()}},n,t)}));return function(e){return n.apply(this,arguments)}}())}),e.abrupt("return",this.loadPromise);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"getPrivileges",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.privileges){e.next=4;break}return e.abrupt("return",this.privileges);case 4:return e.abrupt("return",this.loadPrivileges());case 5:case"end":return e.stop()}},e,this)}));return e}()},{key:"displayInfoForCredential",value:function(t){var n={};return n[e.CredentialAccountPassword]={label:"Account Password",prompt:"Please enter your account password."},n[e.CredentialLocalPasscode]={label:"Local Passcode",prompt:"Please enter your local passcode."},n[t]}},{key:"displayInfoForAction",value:function(t){var n={};return n[e.ActionManageExtensions]={label:"Manage Extensions"},n[e.ActionManageBackups]={label:"Download/Import Backups"},n[e.ActionViewProtectedNotes]={label:"View Protected Notes"},n[e.ActionManagePrivileges]={label:"Manage Privileges"},n[e.ActionManagePasscode]={label:"Manage Passcode"},n[e.ActionDeleteNote]={label:"Delete Notes"},n[t]}},{key:"getSessionLengthOptions",value:function(){return[{value:e.SessionLengthNone,label:"Don't Remember"},{value:e.SessionLengthFiveMinutes,label:"5 Minutes"},{value:e.SessionLengthOneHour,label:"1 Hour"},{value:e.SessionLengthOneWeek,label:"1 Week"}]}},{key:"setSessionLength",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=function(e){var t=new Date;return t.setSeconds(t.getSeconds()+e),t},i=r(n),t.abrupt("return",Promise.all([this.delegate.saveToStorage(e.SessionExpiresAtKey,JSON.stringify(i)),this.delegate.saveToStorage(e.SessionLengthKey,JSON.stringify(n))]));case 3:case"end":return t.stop()}},t,this)}));return t}()},{key:"clearSession",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.setSessionLength(e.SessionLengthNone));case 1:case"end":return t.stop()}},t,this)}));return t}()},{key:"getSelectedSessionLength",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.delegate.getFromStorage(e.SessionLengthKey);case 2:if(!(n=t.sent)){t.next=7;break}return t.abrupt("return",JSON.parse(n));case 7:return t.abrupt("return",e.SessionLengthNone);case 8:case"end":return t.stop()}},t,this)}));return t}()},{key:"getSessionExpirey",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.delegate.getFromStorage(e.SessionExpiresAtKey);case 2:if(!(n=t.sent)){t.next=7;break}return t.abrupt("return",new Date(JSON.parse(n)));case 7:return t.abrupt("return",new Date);case 8:case"end":return t.stop()}},t,this)}));return t}()},{key:"actionHasPrivilegesConfigured",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.netCredentialsForAction(t);case 2:return e.t0=e.sent.length,e.abrupt("return",e.t0>0);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"actionRequiresPrivilege",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getSessionExpirey();case 2:if(!((n=e.sent)>new Date)){e.next=5;break}return e.abrupt("return",!1);case 5:return e.next=7,this.netCredentialsForAction(t);case 7:return r=e.sent,e.abrupt("return",r.length>0);case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"savePrivileges",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPrivileges();case 2:t=e.sent,t.setDirty(!0),this.syncManager.sync();case 5:case"end":return e.stop()}},e,this)}));return e}()},{key:"authenticateAction",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.netCredentialsForAction(t);case 2:r=e.sent,i=[],a=[],o=!0,s=!1,u=void 0,e.prev=7,c=r[Symbol.iterator]();case 9:if(o=(l=c.next()).done){e.next=18;break}return f=l.value,e.next=13,this._verifyAuthenticationParameters(f,n[f]);case 13:p=e.sent,p?i.push(f):a.push(f);case 15:o=!0,e.next=9;break;case 18:e.next=24;break;case 20:e.prev=20,e.t0=e.catch(7),s=!0,u=e.t0;case 24:e.prev=24,e.prev=25,!o&&c.return&&c.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:return e.abrupt("return",{success:0==a.length,successfulCredentials:i,failedCredentials:a});case 33:case"end":return e.stop()}},e,this,[[7,20,24,32],[25,,27,31]])}));return e}()},{key:"_verifyAuthenticationParameters",value:function(){function t(e,t){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n,r){var a,o,s=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(a=function(){var e=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s.delegate.verifyAccountPassword(t));case 1:case"end":return e.stop()}},e,s)}));return function(t){return e.apply(this,arguments)}}(),o=function(){var e=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s.delegate.verifyLocalPasscode(t));case 1:case"end":return e.stop()}},e,s)}));return function(t){return e.apply(this,arguments)}}(),n!=e.CredentialAccountPassword){t.next=6;break}return t.abrupt("return",a(r));case 6:if(n!=e.CredentialLocalPasscode){t.next=8;break}return t.abrupt("return",o(r));case 8:case"end":return t.stop()}},t,this)}));return t}()}]),e}(),m=r.SFSessionHistoryManager=function(){function e(t,n,r,i,o){var s=this;a(this,e),this.modelManager=t,this.storageManager=n,this.$timeout=o||setTimeout.bind(window),this.keyRequestHandler=r,this.loadFromDisk().then(function(){s.modelManager.addItemSyncObserver("session-history",i,function(e,t,n,r,i){var a=!0,o=!1,u=void 0;try{for(var c,l=e[Symbol.iterator]();!(a=(c=l.next()).done);a=!0){var f=c.value;try{s.addHistoryEntryForItem(f)}catch(e){console.log("Caught exception while trying to add item history entry",e)}}}catch(e){o=!0,u=e}finally{try{!a&&l.return&&l.return()}finally{if(o)throw u}}})})}return l(e,[{key:"encryptionParams",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.keyRequestHandler());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"addHistoryEntryForItem",value:function(e){var t=this,n={uuid:e.uuid,content_type:e.content_type,updated_at:e.updated_at,content:e.content},r=this.historySession.addEntryForItem(n);this.autoOptimize&&this.historySession.optimizeHistoryForItem(e),r&&this.diskEnabled&&(this.diskTimeout&&(this.$timeout.hasOwnProperty("cancel")?this.$timeout.cancel(this.diskTimeout):clearTimeout(this.diskTimeout)),this.diskTimeout=this.$timeout(function(){t.saveToDisk()},2e3))}},{key:"historyForItem",value:function(e){return this.historySession.historyForItem(e)}},{key:"clearHistoryForItem",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.historySession.clearItemHistory(t),e.abrupt("return",this.saveToDisk());case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"clearAllHistory",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.historySession.clearAllHistory(),e.abrupt("return",this.storageManager.removeItem("sessionHistory_revisions"));case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"toggleDiskSaving",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.diskEnabled=!this.diskEnabled,!this.diskEnabled){e.next=6;break}this.storageManager.setItem("sessionHistory_persist",JSON.stringify(!0)),this.saveToDisk(),e.next=8;break;case 6:return this.storageManager.setItem("sessionHistory_persist",JSON.stringify(!1)),e.abrupt("return",this.storageManager.removeItem("sessionHistory_revisions"));case 8:case"end":return e.stop()}},e,this)}));return e}()},{key:"saveToDisk",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.diskEnabled){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.encryptionParams();case 4:t=e.sent,n=new S(this.historySession,t.keys,t.auth_params),n.paramsForSync().then(function(e){r.storageManager.setItem("sessionHistory_revisions",JSON.stringify(e))});case 7:case"end":return e.stop()}},e,this)}));return e}()},{key:"loadFromDisk",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.storageManager.getItem("sessionHistory_persist");case 2:return t=e.sent,t&&(this.diskEnabled=JSON.parse(t)),e.next=6,this.storageManager.getItem("sessionHistory_revisions");case 6:if(!(n=e.sent)){e.next=18;break}return n=JSON.parse(n),e.next=11,this.encryptionParams();case 11:return r=e.sent,e.next=14,SFJS.itemTransformer.decryptItem(n,r.keys);case 14:i=new R(n),this.historySession=i,e.next=19;break;case 18:this.historySession=new R;case 19:return e.next=21,this.storageManager.getItem("sessionHistory_autoOptimize");case 21:a=e.sent,this.autoOptimize=!a||JSON.parse(a);case 23:case"end":return e.stop()}},e,this)}));return e}()},{key:"toggleAutoOptimize",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.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 e.stop()}},e,this)}));return e}()}]),e}(),b=r.SFSingletonManager=function(){function e(t,n){var r=this;a(this,e),this.syncManager=n,this.modelManager=t,this.singletonHandlers=[],t.addItemSyncObserverWithPriority({id:"sf-singleton-manager",types:"*",priority:-1,callback:function(){r.resolveSingletons(t.allNondummyItems,null,!0)}}),n.addEventHandler(function(e,n){if("local-data-loaded"==e)r.resolveSingletons(t.allNondummyItems,null,!0),r.initialDataLoaded=!0;else if("sync:completed"==e){if(!r.initialDataLoaded)return;r.resolveSingletons(n.retrievedItems,n.savedItems)}}),t.addModelUuidChangeObserver("singleton-manager",function(e,t){var n=!0,i=!1,a=void 0;try{for(var o,s=r.singletonHandlers[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;u.singleton&&C.ItemSatisfiesPredicates(t,u.predicates)&&(u.singleton=null,r.resolveSingletons([t]))}}catch(e){i=!0,a=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw a}}})}return l(e,[{key:"registerSingleton",value:function(e,t,n){this.singletonHandlers.push({predicates:e,resolutionCallback:t,createBlock:n})}},{key:"resolveSingletons",value:function(e,t,n){var r=this;e=e||[],t=t||[];var i=!0,a=!1,o=void 0;try{for(var s,u=this.singletonHandlers[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;!function(i){var a=i.predicates.slice(),o=r.modelManager.filterItemsWithPredicates(e,a),s=function(){i.createBlock&&(i.pendingCreateBlockCallback=!0,i.createBlock(function(e){i.singleton=e,i.pendingCreateBlockCallback=!1,i.resolutionCallback&&i.resolutionCallback(e)}))},u=r.modelManager.filterItemsWithPredicates(t,a).length;if(o.length>0||u>0){var c=r.modelManager.itemsMatchingPredicates(a);if(c.length>=2){var l=c.sort(function(e,t){return e.errorDecrypting?1:t.errorDecrypting?-1:e.created_at=this.MaxDiscordanceBeforeOutOfSync&&(this.outOfSync||(this.outOfSync=!0,this.notifyEvent("enter-out-of-sync"))),e.abrupt("return",!1);case 13:return this.outOfSync&&(this.outOfSync=!1,this.notifyEvent("exit-out-of-sync")),this.syncDiscordance=0,e.abrupt("return",!0);case 16:case"end":return e.stop()}},e,this)}));return e}()},{key:"isOutOfSync",value:function(){return this.outOfSync}},{key:"getServerURL",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.storageManager.getItem("server");case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0=window._default_sf_server;case 5:return e.abrupt("return",e.t0);case 6:case"end":return e.stop()}},e,this)}));return e}()},{key:"getSyncURL",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getServerURL();case 2:return e.t0=e.sent,e.abrupt("return",e.t0+"/items/sync");case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"registerSyncStatusObserver",value:function(e){var t={key:new Date,callback:e};return this.syncStatusObservers.push(t),t}},{key:"removeSyncStatusObserver",value:function(e){_.pull(this.syncStatusObservers,e)}},{key:"syncStatusDidChange",value:function(){var e=this;this.syncStatusObservers.forEach(function(t){t.callback(e.syncStatus)})}},{key:"addEventHandler",value:function(e){return this.eventHandlers.push(e),e}},{key:"removeEventHandler",value:function(e){_.pull(this.eventHandlers,e)}},{key:"notifyEvent",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.eventHandlers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){(0,a.value)(e,t||{})}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"setKeyRequestHandler",value:function(e){this.keyRequestHandler=e}},{key:"getActiveKeyInfo",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.keyRequestHandler(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"initialDataLoaded",value:function(){return this._initialDataLoaded}},{key:"loadLocalItems",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.storageManager.getAllModels().then(function(t){t=t.sort(function(e,t){var n=new Date(t.updated_at)-new Date(e.updated_at),i=r.contentTypeLoadPriority,a=0,o=0;return i&&(a=i.indexOf(e.content_type),o=i.indexOf(t.content_type),-1==a&&(a=i.length),-1==o&&(o=i.length)),a==o?n:a5&&(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:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var t=i(regeneratorRuntime.mark(function t(i,a){var o,s,u,c,l,f,p,h,d,y,v,g,m;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.syncLocked){t.next=4;break}return console.log("Sync Locked, Returning;"),i(),t.abrupt("return");case 4:if(r||(r={}),o=n.modelManager.getDirtyItems(),s=o.filter(function(e){return e.dirtyCount>0&&(e.dirtyCount=0,!0)}),!n.syncStatus.syncOpInProgress||r.force){t.next=14;break}return n.repeatOnCompletion=!0,n.queuedCallbacks.push(i),t.next=12,n.writeItemsToLocalStorage(s,!1);case 12:return console.log("Sync op in progress; returning."),t.abrupt("return");case 14:return t.next=16,n.getActiveKeyInfo(e.KeyRequestLoadSaveAccount);case 16:if(u=t.sent,!u.offline){t.next=20;break}return n.syncOffline(o).then(function(e){n.modelManager.clearDirtyItems(o),i(e)}).catch(function(e){n.notifyEvent("sync-exception",e)}),t.abrupt("return");case 20:return c=n.syncStatus.needsMoreSync,n.syncStatus.syncOpInProgress=!0,n.syncStatus.syncStart=new Date,n.beginCheckingIfSyncIsTakingTooLong(),l=n.PerSyncItemUploadLimit,f=o.slice(0,l),f.lengthn.syncStatus.total&&(n.syncStatus.total=n.syncStatus.current),n.syncStatusDidChange(),t.next=32,n.writeItemsToLocalStorage(s,!1);case 32:return r.onPreSyncSave&&r.onPreSyncSave(),n.allRetreivedItems||(n.allRetreivedItems=[]),n.allSavedItems||(n.allSavedItems=[]),p={},p.limit=150,r.performIntegrityCheck&&(p.compute_integrity=!0),t.prev=38,t.next=41,Promise.all(f.map(function(e){var t=new S(e,u.keys,u.auth_params);return t.additionalFields=r.additionalFields,t.paramsForSync()})).then(function(e){p.items=e});case 41:t.next=46;break;case 43:t.prev=43,t.t0=t.catch(38),n.notifyEvent("sync-exception",t.t0);case 46:for(h=!0,d=!1,y=void 0,t.prev=49,v=f[Symbol.iterator]();!(h=(g=v.next()).done);h=!0)m=g.value,m.dirtyCount=0;t.next=57;break;case 53:t.prev=53,t.t1=t.catch(49),d=!0,y=t.t1;case 57:t.prev=57,t.prev=58,!h&&v.return&&v.return();case 60:if(t.prev=60,!d){t.next=63;break}throw y;case 63:return t.finish(60);case 64:return t.finish(57);case 65:return t.next=67,n.getSyncToken();case 67:return p.sync_token=t.sent,t.next=70,n.getCursorToken();case 70:return p.cursor_token=t.sent,t.prev=71,t.t2=n.httpManager,t.next=75,n.getSyncURL();case 75:t.t3=t.sent,t.t4=p,t.t5=function(e){n.handleSyncSuccess(f,e,r).then(function(){i(e)}).catch(function(e){console.log("Caught sync success exception:",e),n.handleSyncError(null,null,o).then(function(e){i(e)})})},t.t6=function(e,t){n.handleSyncError(e,t,o).then(function(e){i(e)})},t.t2.postAbsolute.call(t.t2,t.t3,t.t4,t.t5,t.t6),t.next=85;break;case 82:t.prev=82,t.t7=t.catch(71),console.log("Sync exception caught:",t.t7);case 85:case"end":return t.stop()}},t,n,[[38,43],[49,53,57,65],[58,,60,64],[71,82]])}));return function(e,n){return t.apply(this,arguments)}}()));case 1:case"end":return t.stop()}},t,this)}));return t}()},{key:"handleSyncSuccess",value:function(){function t(e,t,r){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n,r,i){var a,o,s,u,c,l,f,p,h,d,y,g,m,b,k=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(a=[],o=!0,s=!1,u=void 0,t.prev=4,c=n[Symbol.iterator]();!(o=(l=c.next()).done);o=!0)f=l.value,0==f.dirtyCount&&a.push(f);t.next=12;break;case 8:t.prev=8,t.t0=t.catch(4),s=!0,u=t.t0;case 12:t.prev=12,t.prev=13,!o&&c.return&&c.return();case 15:if(t.prev=15,!s){t.next=18;break}throw u;case 18:return t.finish(15);case 19:return t.finish(12);case 20:return this.modelManager.clearDirtyItems(a),this.syncStatus.error=null,p=this.allSavedItems.map(function(e){return e.uuid}),r.retrieved_items=r.retrieved_items.filter(function(e){return!p.includes(e.uuid)}),t.next=26,this.handleItemsResponse(r.retrieved_items,null,v.MappingSourceRemoteRetrieved,e.KeyRequestLoadSaveAccount);case 26:return h=t.sent,this.allRetreivedItems=this.allRetreivedItems.concat(h),this.syncStatus.retrievedCount=this.allRetreivedItems.length,d=["content","auth_hash"],t.next=32,this.handleItemsResponse(r.saved_items,d,v.MappingSourceRemoteSaved,e.KeyRequestLoadSaveAccount);case 32:return y=t.sent,this.allSavedItems=this.allSavedItems.concat(y),g=r.unsaved,t.next=37,this.handleUnsavedItemsResponse(g);case 37:return t.next=39,this.writeItemsToLocalStorage(y,!1);case 39:return t.next=41,this.writeItemsToLocalStorage(h,!1);case 41:if(this.syncStatus.syncOpInProgress=!1,this.syncStatus.current+=n.length,this.syncStatusDidChange(),this.setSyncToken(r.sync_token),this.setCursorToken(r.cursor_token),this.stopCheckingIfSyncIsTakingTooLong(),!r.integrity_hash||r.cursor_token){t.next=52;break}return t.next=50,this.handleServerIntegrityHash(r.integrity_hash);case 50:m=t.sent,m||this.syncDiscordance=this.majorDataChangeThreshold||y.length>=this.majorDataChangeThreshold||g.length>=this.majorDataChangeThreshold)&&this.notifyEvent("major-data-change"),this.callQueuedCallbacks(r),this.notifyEvent("sync:completed",{retrievedItems:this.allRetreivedItems,savedItems:this.allSavedItems,unsavedItems:g}),this.allRetreivedItems=[],this.allSavedItems=[],t.abrupt("return",r);case 72:case"end":return t.stop()}},t,this,[[4,8,12,20],[13,,15,19]])}));return t}()},{key:"handleSyncError",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("Sync error: ",t),401==n&&this.notifyEvent("sync-session-invalid"),t?"string"==typeof t&&(t={error:{message:t}}):t={error:{message:"Could not connect to server."}},this.syncStatus.syncOpInProgress=!1,this.syncStatus.error=t.error,this.syncStatusDidChange(),this.writeItemsToLocalStorage(r,!1),this.modelManager.didSyncModelsOffline(r),this.stopCheckingIfSyncIsTakingTooLong(),this.notifyEvent("sync:error",t.error),this.callQueuedCallbacks({error:"Sync error"}),e.abrupt("return",t);case 12:case"end":return e.stop()}},e,this)}));return e}()},{key:"handleItemsResponse",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a,o,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getActiveKeyInfo(i);case 2:return a=e.sent.keys,e.next=5,SFJS.itemTransformer.decryptMultipleItems(t,a);case 5:return o=this.modelManager.mapResponseItemsToLocalModelsOmittingFields(t,n,r),s=o.filter(function(e){var t=e.errorDecryptingValueChanged;return e.errorDecryptingValueChanged=!1,t}),s.length>0&&this.writeItemsToLocalStorage(s,!1),e.abrupt("return",o);case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"refreshErroredItems",value:function(){function t(){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this.modelManager.allNondummyItems.filter(function(e){return 1==e.errorDecrypting}),!(n.length>0)){t.next=3;break}return t.abrupt("return",this.handleItemsResponse(n,null,v.MappingSourceLocalRetrieved,e.KeyRequestLoadSaveAccount));case 3:case"end":return t.stop()}},t,this)}));return t}()},{key:"handleUnsavedItemsResponse",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(0!=n.length){t.next=2;break}return t.abrupt("return");case 2:console.log("Handle Conflicted Items:",n),r=!0,i=!1,a=void 0,t.prev=6,o=n[Symbol.iterator]();case 8:if(r=(s=o.next()).done){t.next=35;break}return u=s.value,c=u.item,t.t0=SFJS.itemTransformer,t.t1=[c],t.next=15,this.getActiveKeyInfo(e.KeyRequestLoadSaveAccount);case 15:return t.t2=t.sent.keys,t.next=18,t.t0.decryptMultipleItems.call(t.t0,t.t1,t.t2);case 18:if(l=this.modelManager.findItem(c.uuid)){t.next=21;break}return t.abrupt("continue",32);case 21:if(f=u.error,"uuid_conflict"!==f.tag){t.next=27;break}return t.next=25,this.modelManager.alternateUUIDForItem(l);case 25:t.next=32;break;case 27:if("sync_conflict"!==f.tag){t.next=32;break}return t.next=30,this.modelManager.createConflictedItem(c);case 30:p=t.sent,c.deleted||l.isItemContentEqualWith(p)||this.modelManager.addConflictedItem(p,l);case 32:r=!0,t.next=8;break;case 35:t.next=41;break;case 37:t.prev=37,t.t3=t.catch(6),i=!0,a=t.t3;case 41:t.prev=41,t.prev=42,!r&&o.return&&o.return();case 44:if(t.prev=44,!i){t.next=47;break}throw a;case 47:return t.finish(44);case 48:return t.finish(41);case 49:this.sync(null,{additionalFields:["created_at","updated_at"]});case 50:case"end":return t.stop()}},t,this,[[6,37,41,49],[42,,44,48]])}));return t}()},{key:"stateless_downloadAllItems",value:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(){var r=i(regeneratorRuntime.mark(function r(a,o){var s;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return s={limit:n.limit||500,sync_token:n.syncToken,cursor_token:n.cursorToken,content_type:n.contentType,event:n.event},r.prev=1,r.t0=t.httpManager,r.next=5,t.getSyncURL();case 5:r.t1=r.sent,r.t2=s,r.t3=function(){var r=i(regeneratorRuntime.mark(function r(i){var o,s;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return n.retrievedItems||(n.retrievedItems=[]),o=i.retrieved_items,r.next=4,t.getActiveKeyInfo(e.KeyRequestLoadSaveAccount);case 4:return s=r.sent.keys,r.next=7,SFJS.itemTransformer.decryptMultipleItems(o,s);case 7:n.retrievedItems=n.retrievedItems.concat(o.map(function(e){return t.modelManager.createItem(e,!0)})),n.syncToken=i.sync_token,n.cursorToken=i.cursor_token,n.cursorToken?t.stateless_downloadAllItems(n).then(a):a(n.retrievedItems);case 11:case"end":return r.stop()}},r,t)}));return function(e){return r.apply(this,arguments)}}(),r.t4=function(e,t){o(e)},r.t0.postAbsolute.call(r.t0,r.t1,r.t2,r.t3,r.t4),r.next=16;break;case 12:r.prev=12,r.t5=r.catch(1),console.log("Download all items exception caught:",r.t5),o(r.t5);case 16:case"end":return r.stop()}},r,t,[[1,12]])}));return function(e,t){return r.apply(this,arguments)}}())}},{key:"resolveOutOfSync",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stateless_downloadAllItems({event:"resolve-out-of-sync"}).then(function(){var e=i(regeneratorRuntime.mark(function e(n){var r,i,a,o,s,u,c,l,f,p;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:r=[],i=!0,a=!1,o=void 0,e.prev=4,s=n[Symbol.iterator]();case 6:if(i=(u=s.next()).done){e.next=20;break}if(c=u.value,!(l=t.modelManager.findItem(c.uuid))){e.next=16;break}if(!(f=!c.isItemContentEqualWith(l))){e.next=16;break}return e.next=14,t.modelManager.createConflictedItem(l,l);case 14:p=e.sent,t.modelManager.addConflictedItem(p,l);case 16:r.push(c);case 17:i=!0,e.next=6;break;case 20:e.next=26;break;case 22:e.prev=22,e.t0=e.catch(4),a=!0,o=e.t0;case 26:e.prev=26,e.prev=27,!i&&s.return&&s.return();case 29:if(e.prev=29,!a){e.next=32;break}throw o;case 32:return e.finish(29);case 33:return e.finish(26);case 34:return t.modelManager.mapResponseItemsToLocalModelsWithOptions({items:r,source:v.MappingSourceRemoteRetrieved}),e.next=37,t.writeItemsToLocalStorage(t.modelManager.allNondummyItems);case 37:return e.abrupt("return",t.sync({performIntegrityCheck:!0}));case 38:case"end":return e.stop()}},e,t,[[4,22,26,34],[27,,29,33]])}));return function(t){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"handleSignout",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this._syncToken=null,this._cursorToken=null,this._queuedCallbacks=[],this.syncStatus={};case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"clearSyncToken",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._syncToken=null,this._cursorToken=null,e.abrupt("return",this.storageManager.removeItem("syncToken"));case 3:case"end":return e.stop()}},e,this)}));return e}()},{key:"queuedCallbacks",get:function(){return this._queuedCallbacks||(this._queuedCallbacks=[]),this._queuedCallbacks}}]),e}(),x=r.SFItem=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.content={},this.referencingObjects=[],this.updateFromJSON(t),this.uuid||"undefined"!=typeof SFJS&&SFJS.crypto.generateUUIDSync&&(this.uuid=SFJS.crypto.generateUUIDSync()),"object"!==c(this.content)||this.content.references||(this.content.references=[])}return l(e,[{key:"initUUID",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.uuid){e.next=4;break}return e.next=3,SFJS.crypto.generateUUID();case 3:this.uuid=e.sent;case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"updateFromJSON",value:function(t){if(t){this.created_at=t.created_at,this.updated_at=t.updated_at,this.deleted=t.deleted,this.uuid=t.uuid,this.enc_item_key=t.enc_item_key,this.auth_hash=t.auth_hash,this.auth_params=t.auth_params;var n=["errorDecrypting","dirty","dirtyCount","dummy"],r=!0,i=!1,a=void 0;try{for(var o,s=n[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;void 0!==t[u]&&(this[u]=t[u])}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}if(this.content_type||(this.content_type=t.content_type),t.errorDecrypting)this.content=t.content;else try{var c="string"==typeof t.content?JSON.parse(t.content):t.content;e.deepMerge(this.contentObject,c)}catch(e){console.log("Error while updating item from json",e)}this.created_at?(this.created_at=new Date(this.created_at),this.updated_at=new Date(this.updated_at)):(this.created_at=new Date,this.updated_at=new Date),this._client_updated_at=null,t.content?this.mapContentToLocalProperties(this.contentObject):1==t.deleted&&this.handleDeletedContent()}}},{key:"mapContentToLocalProperties",value:function(e){}},{key:"createContentJSONFromProperties",value:function(){var t=this.structureParams();return e.deepMerge(this.contentObject,t),t}},{key:"structureParams",value:function(){return this.getContentCopy()}},{key:"handleDeletedContent",value:function(){}},{key:"setDirty",value:function(e,t){this.dirty=e,this.dirtyCount||(this.dirtyCount=0),e?this.dirtyCount++:this.dirtyCount=0,e&&!t?this.client_updated_at=new Date:this.hasRawClientUpdatedAtValue()||(this.client_updated_at=new Date(this.updated_at))}},{key:"updateLocalRelationships",value:function(){}},{key:"addItemAsRelationship",value:function(e){if(e.setIsBeingReferencedBy(this),!this.hasRelationshipWithItem(e)){var t=this.content.references||[];t.push({uuid:e.uuid,content_type:e.content_type}),this.content.references=t}}},{key:"removeItemAsRelationship",value:function(e){e.setIsNoLongerBeingReferencedBy(this),this.removeReferenceWithUuid(e.uuid)}},{key:"setIsBeingReferencedBy",value:function(e){_.find(this.referencingObjects,{uuid:e.uuid})||this.referencingObjects.push(e)}},{key:"setIsNoLongerBeingReferencedBy",value:function(e){_.remove(this.referencingObjects,{uuid:e.uuid}),this.hasRelationshipWithItem(e)&&(this.removeReferenceWithUuid(e.uuid),this.setDirty(!0))}},{key:"removeReferenceWithUuid",value:function(e){var t=this.content.references||[];t=t.filter(function(t){return t.uuid!=e}),this.content.references=t}},{key:"hasRelationshipWithItem",value:function(e){return null!=this.content.references.find(function(t){return t.uuid==e.uuid})}},{key:"isBeingRemovedLocally",value:function(){}},{key:"didFinishSyncing",value:function(){}},{key:"informReferencesOfUUIDChange",value:function(e,t){}},{key:"potentialItemOfInterestHasChangedItsUUID",value:function(e,t,n){var r=!0,i=!1,a=void 0;try{for(var o,s=this.content.references[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;u.uuid==t&&(u.uuid=n,this.setDirty(!0))}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}}},{key:"doNotEncrypt",value:function(){return!1}},{key:"setDomainDataItem",value:function(e,t,n){if(!n)return void console.error("SFItem.AppDomain needs to be set.");if(!this.errorDecrypting){this.content.appData||(this.content.appData={});var r=this.content.appData[n];r||(r={}),r[e]=t,this.content.appData[n]=r}}},{key:"getDomainDataItem",value:function(e,t){if(!t)return void console.error("SFItem.AppDomain needs to be set.");if(!this.errorDecrypting){this.content.appData||(this.content.appData={});var n=this.content.appData[t];return n?n[e]:null}}},{key:"setAppDataItem",value:function(t,n){this.setDomainDataItem(t,n,e.AppDomain)}},{key:"getAppDataItem",value:function(t){return this.getDomainDataItem(t,e.AppDomain)}},{key:"hasRawClientUpdatedAtValue",value:function(){return null!=this.getAppDataItem("client_updated_at")}},{key:"keysToIgnoreWhenCheckingContentEquality",value:function(){return[]}},{key:"appDataKeysToIgnoreWhenCheckingContentEquality",value:function(){return["client_updated_at"]}},{key:"getContentCopy",value:function(){return JSON.parse(JSON.stringify(this.content))}},{key:"isItemContentEqualWith",value:function(t){var n=function(e,t){if(!e)return e;var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){delete e[a.value]}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return e},r=this.getContentCopy();r.appData&&n(r.appData[e.AppDomain],this.appDataKeysToIgnoreWhenCheckingContentEquality()),r=n(r,this.keysToIgnoreWhenCheckingContentEquality());var i=t.getContentCopy();return i.appData&&n(i.appData[e.AppDomain],t.appDataKeysToIgnoreWhenCheckingContentEquality()),i=n(i,t.keysToIgnoreWhenCheckingContentEquality()),JSON.stringify(r)===JSON.stringify(i)}},{key:"satisfiesPredicate",value:function(e){return C.ItemSatisfiesPredicate(this,e)}},{key:"createdAtString",value:function(){return this.dateToLocalizedString(this.created_at)}},{key:"updatedAtString",value:function(){return this.dateToLocalizedString(this.client_updated_at)}},{key:"updatedAtTimestamp",value:function(){return this.updated_at.getTime()}},{key:"dateToLocalizedString",value:function(e){if("undefined"!=typeof Intl&&Intl.DateTimeFormat){if(!s){var t=navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language;s=new Intl.DateTimeFormat(t,{year:"numeric",month:"short",day:"2-digit",weekday:"long",hour:"2-digit",minute:"2-digit"})}return s.format(e)}return e.toDateString()+" "+e.toLocaleTimeString()}},{key:"contentObject",get:function(){if(this.errorDecrypting)return this.content;if(!this.content)return this.content={},this.content;if(null!==this.content&&"object"===c(this.content))return this.content;try{var e=JSON.parse(this.content);return this.content=e,this.content}catch(e){return console.log("Error parsing json",e,this),this.content={},this.content}}},{key:"pinned",get:function(){return this.getAppDataItem("pinned")}},{key:"archived",get:function(){return this.getAppDataItem("archived")}},{key:"locked",get:function(){return this.getAppDataItem("locked")}},{key:"displayName",get:function(){return"Item"}},{key:"client_updated_at",get:function(){if(!this._client_updated_at){var e=this.getAppDataItem("client_updated_at");this._client_updated_at=e?new Date(e):new Date(this.updated_at)}return this._client_updated_at},set:function(e){this._client_updated_at=e,this.setAppDataItem("client_updated_at",e)}}],[{key:"deepMerge",value:function(e,t){function n(e,t){if(_.isArray(e))return t}return _.mergeWith(e,t,n),e}}]),e}(),S=r.SFItemParams=function(){function e(t,n,r){if(a(this,e),this.item=t,this.keys=n,this.auth_params=r,this.keys&&!this.auth_params)throw"SFItemParams.auth_params must be supplied if supplying keys.";if(this.auth_params&&!this.auth_params.version)throw"SFItemParams.auth_params is missing version"}return l(e,[{key:"paramsForExportFile",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.additionalFields=["updated_at"],this.forExportFile=!0,!t){e.next=6;break}return e.abrupt("return",this.__params());case 6:return e.next=8,this.__params();case 8:return n=e.sent,e.abrupt("return",_.omit(n,["deleted"]));case 10:case"end":return e.stop()}},e,this)}));return e}()},{key:"paramsForExtension",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.paramsForExportFile());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"paramsForLocalStorage",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.additionalFields=["updated_at","dirty","errorDecrypting"],this.forExportFile=!0,e.abrupt("return",this.__params());case 3:case"end":return e.stop()}},e,this)}));return e}()},{key:"paramsForSync",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.__params());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"__params",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t={uuid:this.item.uuid,content_type:this.item.content_type,deleted:this.item.deleted,created_at:this.item.created_at},this.item.errorDecrypting){e.next=23;break}if(n=this.item.doNotEncrypt()&&!this.forExportFile,!this.keys||n){e.next=11;break}return e.next=6,SFJS.itemTransformer.encryptItem(this.item,this.keys,this.auth_params);case 6:r=e.sent,_.merge(t,r),"001"!==this.auth_params.version&&(t.auth_hash=null),e.next=21;break;case 11:if(!this.forExportFile){e.next=15;break}e.t0=this.item.createContentJSONFromProperties(),e.next=19;break;case 15:return e.next=17,SFJS.crypto.base64(JSON.stringify(this.item.createContentJSONFromProperties()));case 17:e.t1=e.sent,e.t0="000"+e.t1;case 19:t.content=e.t0,this.forExportFile||(t.enc_item_key=null,t.auth_hash=null);case 21:e.next=26;break;case 23:t.content=this.item.content,t.enc_item_key=this.item.enc_item_key,t.auth_hash=this.item.auth_hash;case 26:return this.additionalFields&&_.merge(t,_.pick(this.item,this.additionalFields)),e.abrupt("return",t);case 28:case"end":return e.stop()}},e,this)}));return e}()}]),e}(),C=r.SFPredicate=function(){function e(t,n,r){a(this,e),this.keypath=t,this.operator=n,this.value=r,e.IsRecursiveOperator(this.operator)&&(this.value=this.value.map(e.fromArray))}return l(e,null,[{key:"fromArray",value:function(t){return new e(t[0],t[1],t[2])}},{key:"ObjectSatisfiesPredicate",value:function(t,n){if(Array.isArray(n)&&(n=this.fromArray(n)),e.IsRecursiveOperator(n.operator)){if("and"===n.operator){var r=!0,i=!1,a=void 0;try{for(var o,s=n.value[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;if(!this.ObjectSatisfiesPredicate(t,u))return!1}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return!0}if("or"===n.operator){var c=!0,l=!1,f=void 0;try{for(var p,h=n.value[Symbol.iterator]();!(c=(p=h.next()).done);c=!0){var u=p.value;if(this.ObjectSatisfiesPredicate(t,u))return!0}}catch(e){l=!0,f=e}finally{try{!c&&h.return&&h.return()}finally{if(l)throw f}}return!1}}var d=n.value;"string"==typeof d&&d.includes(".ago")&&(d=this.DateFromString(d));var y=n.keypath.split(".").reduce(function(e,t){return e&&e[t]},t),v=[!1,"",null,void 0,NaN];if(void 0==y)return"!="==n.operator?!v.includes(n.value):v.includes(n.value);if("="==n.operator)return Array.isArray(y)?JSON.stringify(y)==JSON.stringify(d):y==d;if("!="==n.operator)return Array.isArray(y)?JSON.stringify(y)!=JSON.stringify(d):y!==d;if("<"==n.operator)return y"==n.operator)return y>d;if("<="==n.operator)return y<=d;if(">="==n.operator)return y>=d;if("startsWith"==n.operator)return y.startsWith(d);if("in"==n.operator)return-1!=d.indexOf(y);if("includes"==n.operator)return this.resolveIncludesPredicate(y,d);if("matches"==n.operator){return new RegExp(d).test(y)}return!1}},{key:"resolveIncludesPredicate",value:function(t,n){if("string"==typeof n)return t.includes(n);var r;r=Array.isArray(n)?e.fromArray(n):n;var i=!0,a=!1,o=void 0;try{for(var s,u=t[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;if(this.ObjectSatisfiesPredicate(c,r))return!0}}catch(e){a=!0,o=e}finally{try{!i&&u.return&&u.return()}finally{if(a)throw o}}return!1}},{key:"ItemSatisfiesPredicate",value:function(t,n){return Array.isArray(n)&&(n=e.fromArray(n)),this.ObjectSatisfiesPredicate(t,n)}},{key:"ItemSatisfiesPredicates",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(!this.ItemSatisfiesPredicate(e,s))return!1}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return!0}},{key:"DateFromString",value:function(e){var t=e.split("."),n=t[1],r=new Date,i=parseInt(t[0]);return"days"==n?r.setDate(r.getDate()-i):"hours"==n&&r.setHours(r.getHours()-i),r}},{key:"IsRecursiveOperator",value:function(e){return["and","or"].includes(e)}}]),e}(),I=r.SFPrivileges=function(e){function r(e){a(this,r);var n=t(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return n.content.desktopPrivileges||(n.content.desktopPrivileges={}),n}return n(r,e),l(r,null,[{key:"contentType",value:function(){return"SN|Privileges"}}]),l(r,[{key:"setCredentialsForAction",value:function(e,t){this.content.desktopPrivileges[e]=t}},{key:"getCredentialsForAction",value:function(e){return this.content.desktopPrivileges[e]||[]}},{key:"toggleCredentialForAction",value:function(e,t){this.isCredentialRequiredForAction(e,t)?this.removeCredentialForAction(e,t):this.addCredentialForAction(e,t)}},{key:"removeCredentialForAction",value:function(e,t){_.pull(this.content.desktopPrivileges[e],t)}},{key:"addCredentialForAction",value:function(e,t){var n=this.getCredentialsForAction(e);n.push(t),this.setCredentialsForAction(e,n)}},{key:"isCredentialRequiredForAction",value:function(e,t){return this.getCredentialsForAction(e).includes(t)}}]),r}(x),R=r.SFHistorySession=function(e){function r(e){a(this,r);var n=t(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return n.content.itemUUIDToItemHistoryMapping||(n.content.itemUUIDToItemHistoryMapping={}),Object.keys(n.content.itemUUIDToItemHistoryMapping).forEach(function(e){var t=n.content.itemUUIDToItemHistoryMapping[e];n.content.itemUUIDToItemHistoryMapping[e]=new E(t)}),n}return n(r,e),l(r,[{key:"addEntryForItem",value:function(e){return this.historyForItem(e).addHistoryEntryForItem(e)}},{key:"historyForItem",value:function(e){var t=this.content.itemUUIDToItemHistoryMapping[e.uuid];return t||(t=this.content.itemUUIDToItemHistoryMapping[e.uuid]=new E),t}},{key:"clearItemHistory",value:function(e){this.historyForItem(e).clear()}},{key:"clearAllHistory",value:function(){this.content.itemUUIDToItemHistoryMapping={}}},{key:"optimizeHistoryForItem",value:function(e){var t=this.historyForItem(e);t.entries.length>r.LargeItemEntryAmountThreshold&&t.optimize()}}]),r}(x);R.LargeItemEntryAmountThreshold=60;var E=r.SFItemHistory=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a(this,e),this.entries||(this.entries=[]),t.entries){var n=!0,r=!1,i=void 0;try{for(var o,s=t.entries[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value,c=this.createEntryForItem(u.item);c.setPreviousEntry(this.getLastEntry()),this.entries.push(c)}}catch(e){r=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(r)throw i}}}}return l(e,[{key:"createEntryForItem",value:function(t){var n=e.HistoryEntryClassMapping&&e.HistoryEntryClassMapping[t.content_type];return n||(n=F),new n(t)}},{key:"getLastEntry",value:function(){return this.entries[this.entries.length-1]}},{key:"addHistoryEntryForItem",value:function(e){var t=this.createEntryForItem(e),n=this.getLastEntry();if(t.setPreviousEntry(n),!t.isSameAsEntry(n))return this.entries.push(t),t}},{key:"clear",value:function(){this.entries.length=0}},{key:"optimize",value:function(){var t=this,n=[],r=function(t){return t.deltaSize()>e.LargeEntryDeltaThreshold},i=function(e,i,a){if(a)n.push(e);else{var i=n.indexOf(e);-1!==i&&n.splice(i,1)}if(a&&r(e)&&-1==e.operationVector()){var o=t.entries[i-1];o&&n.push(o)}};this.entries.forEach(function(e,n){if(0==n||n==t.entries.length-1)i(e,n,!0);else{var a=r(e);i(e,n,a)}}),this.entries=this.entries.filter(function(e,t){return-1!==n.indexOf(e)})}}]),e}();E.LargeEntryDeltaThreshold=15;var F=r.SFItemHistoryEntry=function(){function e(t){a(this,e),this.item=x.deepMerge({},t),this.defaultContentKeyToDiffOn="text",this.textCharDiffLength=0,"string"==typeof this.item.updated_at&&(this.item.updated_at=new Date(this.item.updated_at))}return l(e,[{key:"setPreviousEntry",value:function(e){this.hasPreviousEntry=null!=e,this.item.content[this.defaultContentKeyToDiffOn]&&(this.textCharDiffLength=e?this.item.content[this.defaultContentKeyToDiffOn].length-e.item.content[this.defaultContentKeyToDiffOn].length:this.item.content[this.defaultContentKeyToDiffOn].length)}},{key:"operationVector",value:function(){return void 0!=this.textCharDiffLength?this.hasPreviousEntry&&0!=this.textCharDiffLength?this.textCharDiffLength<0?-1:1:0:1}},{key:"deltaSize",value:function(){return void 0!=this.textCharDiffLength?Math.abs(this.textCharDiffLength):1}},{key:"isSameAsEntry",value:function(e){if(!e)return!1;var t=new x(this.item),n=new x(e.item);return t.isItemContentEqualWith(n)}}]),e}(),h="undefined"!=typeof window?window:void 0!==e?e:null,P=r.SFAbstractCrypto=function(){function e(){a(this,e),this.DefaultPBKDF2Length=768}return l(e,[{key:"generateUUIDSync",value:function(){var e=h.crypto||h.msCrypto;if(e){var t=new Uint32Array(4);e.getRandomValues(t);var n=-1;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){n++;var r=t[n>>3]>>n%8*4&15;return("x"==e?r:3&r|8).toString(16)})}var r=(new Date).getTime();return h.performance&&"function"==typeof h.performance.now&&(r+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)})}},{key:"generateUUID",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.generateUUIDSync());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"decryptText",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=a.ciphertextToAuth,u=a.contentCiphertext,c=a.encryptionKey,l=a.iv,f=a.authHash,p=a.authKey,h=arguments[1];return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!h||f){e.next=3;break}return console.error("Auth hash is required."),e.abrupt("return");case 3:if(!f){e.next=10;break}return e.next=6,this.hmac256(s,p);case 6:if(t=e.sent,f===t){e.next=10;break}return console.error("Auth hash does not match, returning null."),e.abrupt("return",null);case 10:return n=o.enc.Hex.parse(c),r=o.enc.Hex.parse(l||""),i=o.AES.decrypt(u,n,{iv:r,mode:o.mode.CBC,padding:o.pad.Pkcs7}),e.abrupt("return",i.toString(o.enc.Utf8));case 14:case"end":return e.stop()}},e,this)}));return e}()},{key:"encryptText",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){var i,a,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=o.enc.Hex.parse(n),a=o.enc.Hex.parse(r||""),s=o.AES.encrypt(t,i,{iv:a,mode:o.mode.CBC,padding:o.pad.Pkcs7}),e.abrupt("return",s.toString());case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateRandomKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",o.lib.WordArray.random(t/8).toString());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateItemEncryptionKey",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=512,n=1,e.next=4,this.generateRandomKey(t);case 4:return r=e.sent,e.next=7,this.generateRandomKey(t);case 7:return i=e.sent,e.abrupt("return",this.pbkdf2(i,r,n,t));case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"firstHalfOfKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.substring(0,t.length/2));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"secondHalfOfKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.substring(t.length/2,t.length));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"base64",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",h.btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)})));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"base64Decode",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",h.atob(t));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"sha256",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",o.SHA256(t).toString());case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"hmac256",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.enc.Hex.parse(n),i=o.enc.Utf8.parse(t),a=o.HmacSHA256(i,r).toString(),e.abrupt("return",a);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateSalt",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sha256([t,"SF",n,r,i].join(":"));case 2:return a=e.sent,e.abrupt("return",a);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateSymmetricKeyPair",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a,o,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},u=s.password,c=s.pw_salt,l=s.pw_cost;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.pbkdf2(u,c,l,this.DefaultPBKDF2Length);case 2:return t=e.sent,n=t.length,r=n/3,i=t.slice(0,r),a=t.slice(r,2*r),o=t.slice(2*r,3*r),e.abrupt("return",[i,a,o]);case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"computeEncryptionKeysForUser",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("003"!=n.version){e.next=9;break}if(n.identifier){e.next=4;break}return console.error("authParams is missing identifier."),e.abrupt("return");case 4:return e.next=6,this.generateSalt(n.identifier,n.version,n.pw_cost,n.pw_nonce);case 6:r=e.sent,e.next=10;break;case 9:r=n.pw_salt;case 10:return e.abrupt("return",this.generateSymmetricKeyPair({password:t,pw_salt:r,pw_cost:n.pw_cost}).then(function(e){return{pw:e[0],mk:e[1],ak:e[2]}}));case 11:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateInitialKeysAndAuthParamsForUser",value:function(){function e(e,n){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n){var r,i,a,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.SFJS.version,i=this.SFJS.defaultPasswordGenerationCost,e.next=4,this.generateRandomKey(256);case 4:return a=e.sent,e.next=7,this.generateSalt(t,r,i,a);case 7:return o=e.sent,e.abrupt("return",this.generateSymmetricKeyPair({password:n,pw_salt:o,pw_cost:i}).then(function(e){var n={pw_nonce:a,pw_cost:i,identifier:t,version:r};return{keys:{pw:e[0],mk:e[1],ak:e[2]},authParams:n}}));case 9:case"end":return e.stop()}},e,this)}));return e}()}]),e}(),D=r.SFCryptoJS=function(e){function r(){return a(this,r),t(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return n(r,e),l(r,[{key:"pbkdf2",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return a={keySize:i/32,hasher:o.algo.SHA512,iterations:r},e.abrupt("return",o.PBKDF2(t,n,a).toString());case 2:case"end":return e.stop()}},e,this)}));return e}()}]),r}(P),h="undefined"!=typeof window?window:void 0!==e?e:null,O=h.crypto?h.crypto.subtle:null,M=r.SFCryptoWeb=function(e){function r(){return a(this,r),t(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return n(r,e),l(r,[{key:"pbkdf2",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.webCryptoImportKey(t,"PBKDF2",["deriveBits"]);case 2:if(a=e.sent){e.next=6;break}return console.log("Key is null, unable to continue"),e.abrupt("return",null);case 6:return e.abrupt("return",this.webCryptoDeriveBits(a,n,r,i));case 7:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateRandomKey",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=!0,e.abrupt("return",O.generateKey({name:"AES-CBC",length:t},n,["encrypt","decrypt"]).then(function(e){return O.exportKey("raw",e).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.arrayBufferToHexString(new Uint8Array(t));case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,r)}));return function(t){return e.apply(this,arguments)}}()).catch(function(e){console.error("Error exporting key",e)})}).catch(function(e){console.error("Error generating key",e)}));case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"generateItemEncryptionKey",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=256,e.abrupt("return",Promise.all([this.generateRandomKey(t),this.generateRandomKey(t)]).then(function(e){return e.join("")}));case 2:case"end":return e.stop()}},e,this)}));return e}()},{key:"encryptText",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r){var a,o,s,u,c,l=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!r){e.next=6;break}return e.next=3,this.hexStringToArrayBuffer(r);case 3:e.t0=e.sent,e.next=7;break;case 6:e.t0=new ArrayBuffer(16);case 7:return a=e.t0,o={name:"AES-CBC",iv:a},e.next=11,this.hexStringToArrayBuffer(n);case 11:return s=e.sent,e.next=14,this.webCryptoImportKey(s,o.name,["encrypt"]);case 14:return u=e.sent,e.next=17,this.stringToArrayBuffer(t);case 17:return c=e.sent,e.abrupt("return",crypto.subtle.encrypt(o,u,c).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l.arrayBufferToBase64(t);case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,l)}));return function(t){return e.apply(this,arguments)}}()));case 19:case"end":return e.stop()}},e,this)}));return e}()},{key:"decryptText",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,a,o,s,u=this,c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=c.ciphertextToAuth,f=c.contentCiphertext,p=c.encryptionKey,h=c.iv,d=c.authHash,y=c.authKey,v=arguments[1];return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!v||d){e.next=3;break}return console.error("Auth hash is required."),e.abrupt("return");case 3:if(!d){e.next=10;break}return e.next=6,this.hmac256(l,y);case 6:if(t=e.sent,d===t){e.next=10;break}return console.error("Auth hash does not match, returning null. "+d+" != "+t),e.abrupt("return",null);case 10:if(!h){e.next=16;break}return e.next=13,this.hexStringToArrayBuffer(h);case 13:e.t0=e.sent,e.next=17;break;case 16:e.t0=new ArrayBuffer(16);case 17:return n=e.t0,r={name:"AES-CBC",iv:n},e.next=21,this.hexStringToArrayBuffer(p);case 21:return a=e.sent,e.next=24,this.webCryptoImportKey(a,r.name,["decrypt"]);case 24:return o=e.sent,e.next=27,this.base64ToArrayBuffer(f);case 27:return s=e.sent,e.abrupt("return",crypto.subtle.decrypt(r,o,s).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.arrayBufferToString(t);case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,u)}));return function(t){return e.apply(this,arguments)}}()).catch(function(e){console.error("Error decrypting:",e)}));case 29:case"end":return e.stop()}},e,this)}));return e}()},{key:"webCryptoImportKey",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,i){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=6;break}return e.next=3,this.stringToArrayBuffer(t);case 3:e.t0=e.sent,e.next=7;break;case 6:e.t0=t;case 7:return a=e.t0,e.abrupt("return",O.importKey("raw",a,{name:n,hash:i},!1,r).then(function(e){return e}).catch(function(e){return console.error(e),null}));case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"webCryptoDeriveBits",value:function(){function e(e,n,r,i){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t,n,r,a){var o,s=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.stringToArrayBuffer(n);case 2:return e.t0=e.sent,e.t1=r,e.t2={name:"SHA-512"},o={name:"PBKDF2",salt:e.t0,iterations:e.t1,hash:e.t2},e.abrupt("return",O.deriveBits(o,t,a).then(function(){var e=i(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.arrayBufferToHexString(new Uint8Array(t));case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}},e,s)}));return function(t){return e.apply(this,arguments)}}()).catch(function(e){return console.error(e),null}));case 7:case"end":return e.stop()}},e,this)}));return e}()},{key:"stringToArrayBuffer",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){var r=new Blob([t]),i=new FileReader;i.onload=function(t){e(t.target.result)},i.readAsArrayBuffer(r)}));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"arrayBufferToString",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){var r=new Blob([t]),i=new FileReader;i.onload=function(t){e(t.target.result)},i.readAsText(r)}));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"arrayBufferToHexString",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){var n,r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:for(n=new Uint8Array(t),r="",a=0;a5e3)||this.crypto instanceof M}},{key:"supportedVersions",value:function(){return["001","002","003"]}},{key:"isVersionNewerThanLibraryVersion",value:function(e){var t=this.version();return parseInt(e)>parseInt(t)}},{key:"isProtocolVersionOutdated",value:function(e){var t={"001":Date.parse("2018-01-01"),"002":Date.parse("2020-01-01")},n=t[e];return!!n&&new Date>n}},{key:"costMinimumForVersion",value:function(e){return{"001":3e3,"002":3e3,"003":11e4}[e]}},{key:"defaultPasswordGenerationCost",value:function(){return this.costMinimumForVersion(this.version())}}]),e}();if(h)try{h.StandardFile=T,h.SFJS=new T,h.SFCryptoWeb=M,h.SFCryptoJS=D,h.SFItemTransformer=A,h.SFModelManager=v,h.SFItem=x,h.SFItemParams=S,h.SFHttpManager=d,h.SFStorageManager=k,h.SFSyncManager=w,h.SFAuthManager=p,h.SFMigrationManager=y,h.SFAlertManager=f,h.SFPredicate=C,h.SFHistorySession=R,h.SFSessionHistoryManager=m,h.SFItemHistory=E,h.SFItemHistoryEntry=F,h.SFPrivilegesManager=g,h.SFPrivileges=I,h.SFSingletonManager=b}catch(e){console.log("Exception while exporting window variables",e)}}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}).call(t,n(3))},function(e,t){!function(t){"use strict";function n(e,t,n,r){var a=t&&t.prototype instanceof i?t:i,o=Object.create(a.prototype),s=new h(r||[]);return o._invoke=c(e,n,s),o}function r(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function i(){}function a(){}function o(){}function s(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function u(e){function t(n,i,a,o){var s=r(e[n],e,i);if("throw"!==s.type){var u=s.arg,c=u.value;return c&&"object"==typeof c&&m.call(c,"__await")?Promise.resolve(c.__await).then(function(e){t("next",e,a,o)},function(e){t("throw",e,a,o)}):Promise.resolve(c).then(function(e){u.value=e,a(u)},o)}o(s.arg)}function n(e,n){function r(){return new Promise(function(r,i){t(e,n,r,i)})}return i=i?i.then(r,r):r()}var i;this._invoke=n}function c(e,t,n){var i=C;return function(a,o){if(i===R)throw new Error("Generator is already running");if(i===E){if("throw"===a)throw o;return y()}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var u=l(s,n);if(u){if(u===F)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===C)throw i=E,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=R;var c=r(e,t,n);if("normal"===c.type){if(i=n.done?E:I,c.arg===F)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=E,n.method="throw",n.arg=c.arg)}}}function l(e,t){var n=e.iterator[t.method];if(n===v){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=v,l(e,t),"throw"===t.method))return F;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return F}var i=r(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,F;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=v),t.delegate=null,F):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,F)}function f(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function p(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function h(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(f,this),this.reset(!0)}function d(e){if(e){var t=e[k];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n=0;--r){var i=this.tryEntries[r],a=i.completion;if("root"===i.tryLoc)return t("end");if(i.tryLoc<=this.prev){var o=m.call(i,"catchLoc"),s=m.call(i,"finallyLoc");if(o&&s){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&m.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),p(n),F}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;p(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:d(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=v),F}}}(function(){return this}()||Function("return this")())},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n=0?this.items[c]=u:this.items.push(u);case 15:r=!0,t.next=5;break;case 18:t.next=24;break;case 20:t.prev=20,t.t0=t.catch(3),i=!0,a=t.t0;case 24:t.prev=24,t.prev=25,r||null==o.return||o.return();case 27:if(t.prev=27,!i){t.next=30;break}throw a;case 30:return t.finish(27);case 31:return t.finish(24);case 32:this.notifyObserversOfEvent(e.BridgeEventReceivedItems);case 33:case"end":return t.stop()}},t,this,[[3,20,24,32],[25,,27,31]])}));return t}()},{key:"indexOfItem",value:function(e){for(var t in this.items)if(this.items[t].uuid==e.uuid)return t;return-1}},{key:"removeItemFromItems",value:function(e){this.items=this.items.filter(function(t){return t.uuid!==e.uuid})}},{key:"createItem",value:function(e,t){this.createItems([e],t)}},{key:"createItems",value:function(e,t){this.componentManager.createItems(e,function(e){t&&t(e.map(function(e){return new f.SFItem(e)}))})}},{key:"saveItem",value:function(){function e(e){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.saveItems([t]));case 1:case"end":return e.stop()}},e,this)}));return e}()},{key:"saveItems",value:function(){function t(e){return n.apply(this,arguments)}var n=i(regeneratorRuntime.mark(function t(n){var r=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t,i){r.componentManager.saveItems(n,function(n){t(n),r.notifyObserversOfEvent(e.BridgeEventSavedItem)})}));case 1:case"end":return t.stop()}},t)}));return t}()},{key:"indexOfItem",value:function(e){for(var t in this.items)if(this.items[t].uuid==e.uuid)return t;return-1}},{key:"deleteItem",value:function(e,t){this.deleteItems([e],t)}},{key:"deleteItems",value:function(e,t){this.componentManager.deleteItems(e,t)}},{key:"removeItemFromItems",value:function(e){this.items=this.items.filter(function(t){return t.uuid!==e.uuid})}}]),e}());u(p,"FileItemContentTypeKey","SN|FileSafe|File"),u(p,"FileSafeCredentialsContentType","SN|FileSafe|Credentials"),u(p,"FileDescriptorContentTypeKey","SN|FileSafe|FileMetadata"),u(p,"FileSafeIntegrationContentTypeKey","SN|FileSafe|Integration"),u(p,"BridgeEventLoadedCredentials","BridgeEventLoadedCredentials"),u(p,"BridgeEventReceivedItems","BridgeEventReceivedItems"),u(p,"BridgeEventSavedItem","BridgeEventSavedItem")},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;nt.length)n=e;else{n=t;var r=0,i=-1,a=-1,o=n.length;for(0>r&&(r=-r>o?0:o+r),i=i>o?o:i,0>i&&(i+=o),o=r>i?0:i-r>>>0,r>>>=0,i=Array(o);++aa?pt:o,a=1),t=Object(t);++is))return!1;if((u=a.get(e))&&a.get(t))return u==t;var u=-1,c=!0,l=2&n?new E:pt;for(a.set(e,t),a.set(t,e);++un&&(n=ln(r+n,0)),y(e,be(t,3),n)):-1}function Te(e){return(null==e?0:e.length)?L(e,1):[]}function Ne(e){var t=null==e?0:e.length;return t?e[t-1]:pt}function je(e,t){var n;if(e&&e.length&&t&&t.length){n=t;var r=v,i=-1,a=n.length;for(e===n&&(n=ue(n));++i=e}function We(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Ve(e){return null!=e&&"object"==typeof e}function Je(e){return!(!Ve(e)||"[object Object]"!=z(e))&&(null===(e=Xt(e))||"function"==typeof(e=Kt.call(e,"constructor")&&e.constructor)&&e instanceof e&&zt.call(e)==Jt)}function qe(e){return"string"==typeof e||!Hn(e)&&Ve(e)&&"[object String]"==z(e)}function $e(e){return"symbol"==typeof e||Ve(e)&&"[object Symbol]"==z(e)}function Ge(e){return e?(e=Ye(e),e===ht||e===-ht?1.7976931348623157e308*(0>e?-1:1):e===e?e:0):0===e?e:0}function Qe(e){e=Ge(e);var t=e%1;return e===e?t?e-t:e:0}function Ye(e){if("number"==typeof e)return e;if($e(e))return dt;if(We(e)&&(e="function"==typeof e.valueOf?e.valueOf():e,e=We(e)?e+"":e),"string"!=typeof e)return 0===e?e:+e;e=e.replace(bt,"");var t=St.test(e);return t||Ct.test(e)?Pt(e.slice(2),t?2:8):xt.test(e)?dt:+e}function Xe(e){return ce(e,rt(e))}function Ze(e){return null==e?"":ne(e)}function et(e,t,n){return e=null==e?pt:H(e,t),e===pt?n:e}function tt(e,t){var n;if(n=null!=e){n=e;var r;r=ie(t,n);for(var i=-1,a=r.length,o=!1;++i(e=M(t,e))||(e==t.length-1?t.pop():tn.call(t,e,1),--this.size,0))},I.prototype.get=function(e){var t=this.__data__;return e=M(t,e),0>e?pt:t[e][1]},I.prototype.has=function(e){return-1r?(++this.size,n.push([e,t])):n[r][1]=t,this},R.prototype.clear=function(){this.size=0,this.__data__={hash:new C,map:new(dn||I),string:new C}},R.prototype.delete=function(e){return e=ke(this,e).delete(e),this.size-=e?1:0,e},R.prototype.get=function(e){return ke(this,e).get(e)},R.prototype.has=function(e){return ke(this,e).has(e)},R.prototype.set=function(e,t){var n=ke(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},E.prototype.add=E.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},E.prototype.has=function(e){return this.__data__.has(e)},F.prototype.clear=function(){this.__data__=new I,this.size=0},F.prototype.delete=function(e){var t=this.__data__;return e=t.delete(e),this.size=t.size,e},F.prototype.get=function(e){return this.__data__.get(e)},F.prototype.has=function(e){return this.__data__.has(e)},F.prototype.set=function(e,t){var n=this.__data__;if(n instanceof I){var r=n.__data__;if(!dn||199>r.length)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new R(r)}return n.set(e,t),this.size=n.size,this};var En=function(e,t){return function(t,n){if(null==t)return t;if(!He(t))return e(t,n);for(var r=t.length,i=-1,a=Object(t);++in&&(n=ln(r+n,0)),qe(e)?n<=r&&-10){var i=!0,a=!1,o=void 0;try{for(var s,u=t.integrations[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;if(c!=e){t.setIntegrationAsDefault(c);break}}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}}})}},{key:"integrations",get:function(){return this.extensionBridge.filterItems(l.a.FileSafeIntegrationContentTypeKey)}}]),e}()},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n0&&(e=n.credentials[0]),e}),u(this,"setCredentialAsDefault",function(e){var t=n.getDefaultCredentials();t&&(t.content.isDefault=!1),e.content.isDefault=!0,n.extensionBridge.saveItems([t,e])}),u(this,"deleteCredential",function(e){n.extensionBridge.deleteItem(e)}),this.extensionBridge=r,this.onCredentialLoad=i,this.credentials=[],this.extensionBridge.addEventHandler(function(e){e==f.a.BridgeEventReceivedItems&&n.reloadCredentials()})}return s(e,[{key:"reloadCredentials",value:function(){this.credentials=[];var e=this.extensionBridge.filterItems(f.a.FileSafeCredentialsContentType);if(0!=e.length){var t=!0,n=!1,r=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;this.credentials.find(function(e){return e.uuid==o.uuid})||this.credentials.push(o)}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}this.onCredentialLoad(),this.credentials.length>0&&this.didLoadCredentials()}}},{key:"createNewCredentials",value:function(){function e(){return t.apply(this,arguments)}var t=i(regeneratorRuntime.mark(function e(){var t,n,r,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=256,e.next=3,SFJS.crypto.generateRandomKey(t);case 3:return n=e.sent,e.next=6,SFJS.crypto.generateRandomKey(t);case 6:return r=e.sent,e.next=9,SFJS.crypto.generateInitialKeysAndAuthParamsForUser(n,r);case 9:return i=e.sent,i.isDefault=0==this.credentials.length,a=new l.SFItem({content_type:f.a.FileSafeCredentialsContentType,content:i}),this.extensionBridge.saveItem(a),this.didLoadCredentials(),e.abrupt("return",a);case 15:case"end":return e.stop()}},e,this)}));return e}()},{key:"didLoadCredentials",value:function(){this.extensionBridge.notifyObserversOfEvent(f.a.BridgeEventLoadedCredentials)}},{key:"credentialForFileDescriptor",value:function(e){return this.credentials.find(function(t){return e.content.references.find(function(e){return e.uuid==t.uuid})})}},{key:"getAllCredentials",value:function(){return this.credentials}},{key:"saveCredential",value:function(e){this.extensionBridge.saveItem(e)}}]),e}()},function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){function o(e){r(u,i,a,o,s,"next",e)}function s(e){r(u,i,a,o,s,"throw",e)}var u=e.apply(t,n);o(void 0)})}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n3&&void 0!==arguments[3]&&arguments[3],i=document.createElement("a");i.setAttribute("download",t),i.href=this.tempUrlForData(e,n),i.setAttribute("target","_blank"),r?window.location.href=i.href:(document.body.appendChild(i),i.click(),i.remove())}},{key:"tempUrlForData",value:function(e,t){return window.URL.createObjectURL(new Blob([e],{type:t||"text/json"}))}},{key:"copyTextToClipboard",value:function(e){if(window.clipboardData&&window.clipboardData.setData)return clipboardData.setData("Text",e);if(document.queryCommandSupported&&document.queryCommandSupported("copy")){var t=document.createElement("textarea");t.textContent=e,t.style.position="fixed",document.body.appendChild(t),t.select();try{return document.execCommand("copy")}catch(e){return console.warn("Copy to clipboard failed.",e),!1}finally{document.body.removeChild(t)}}}}]),e}()}])},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n0&&this.requestPermissions(this.initialPermissions);var t=!0,n=!1,r=void 0;try{for(var i,a=this.messageQueue[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;this.postMessage(o.action,o.data,o.callback)}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}this.messageQueue=[],this.loggingEnabled&&console.log("onReadyData",e),this.activateThemes(e.activeThemeUrls||[]),this.onReadyCallback&&this.onReadyCallback()}},{key:"getSelfComponentUUID",value:function(){return this.uuid}},{key:"isRunningInDesktopApplication",value:function(){return"desktop"===this.environment}},{key:"setComponentDataValueForKey",value:function(e,t){this.componentData[e]=t,this.postMessage("set-component-data",{componentData:this.componentData},function(e){})}},{key:"clearComponentData",value:function(){this.componentData={},this.postMessage("set-component-data",{componentData:this.componentData},function(e){})}},{key:"componentDataValueForKey",value:function(e){return this.componentData[e]}},{key:"postMessage",value:function(e,t,n){if(!this.sessionKey)return void this.messageQueue.push({action:e,data:t,callback:n});var r={action:e,data:t,messageId:this.generateUUID(),sessionKey:this.sessionKey,api:"component"},i=JSON.parse(JSON.stringify(r));i.callback=n,this.sentMessages.push(i),this.isMobile&&(r=JSON.stringify(r)),this.loggingEnabled&&console.log("Posting message:",r),window.parent.postMessage(r,this.origin)}},{key:"setSize",value:function(e,t,n){this.postMessage("set-size",{type:e,width:t,height:n},function(e){})}},{key:"requestPermissions",value:function(e,t){this.postMessage("request-permissions",{permissions:e},function(e){t&&t()}.bind(this))}},{key:"streamItems",value:function(e,t){Array.isArray(e)||(e=[e]),this.postMessage("stream-items",{content_types:e},function(e){t(e.items)}.bind(this))}},{key:"streamContextItem",value:function(e){this.postMessage("stream-context-item",null,function(t){var n=t.item;e(n)})}},{key:"selectItem",value:function(e){this.postMessage("select-item",{item:this.jsonObjectForItem(e)})}},{key:"createItem",value:function(e,t){this.postMessage("create-item",{item:this.jsonObjectForItem(e)},function(e){var n=e.item;!n&&e.items&&e.items.length>0&&(n=e.items[0]),this.associateItem(n),t&&t(n)}.bind(this))}},{key:"createItems",value:function(e,t){var n=this,r=e.map(function(e){return n.jsonObjectForItem(e)});this.postMessage("create-items",{items:r},function(e){t&&t(e.items)}.bind(this))}},{key:"associateItem",value:function(e){this.postMessage("associate-item",{item:this.jsonObjectForItem(e)})}},{key:"deassociateItem",value:function(e){this.postMessage("deassociate-item",{item:this.jsonObjectForItem(e)})}},{key:"clearSelection",value:function(){this.postMessage("clear-selection",{content_type:"Tag"})}},{key:"deleteItem",value:function(e,t){this.deleteItems([e],t)}},{key:"deleteItems",value:function(e,t){var n={items:e.map(function(e){return this.jsonObjectForItem(e)}.bind(this))};this.postMessage("delete-items",n,function(e){t&&t(e)})}},{key:"sendCustomEvent",value:function(e,t,n){this.postMessage(e,t,function(e){n&&n(e)}.bind(this))}},{key:"saveItem",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.saveItems([e],t,n)}},{key:"saveItemWithPresave",value:function(e,t,n){this.saveItemsWithPresave([e],t,n)}},{key:"saveItemsWithPresave",value:function(e,t,n){this.saveItems(e,n,!1,t)}},{key:"saveItems",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments[3],a=function(e){i&&i();var r=[],a=[],o=!0,s=!1,u=void 0;try{for(var c,l=e[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var f=c.value;r.includes(f.uuid)||(r.push(f.uuid),f.updated_at=new Date,a.push(n.jsonObjectForItem(f)))}}catch(e){s=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw u}}n.postMessage("save-items",{items:a},function(e){t&&t()})};this.pendingSaveItems||(this.pendingSaveItems=[]),1!=this.coallesedSaving||r?a(e):(this.pendingSave&&clearTimeout(this.pendingSave),this.pendingSaveItems=this.pendingSaveItems.concat(e),this.pendingSave=setTimeout(function(){a(n.pendingSaveItems),n.pendingSaveItems=[]},this.coallesedSavingDelay))}},{key:"jsonObjectForItem",value:function(e){var t=Object.assign({},e);return t.children=null,t.parent=null,t}},{key:"getItemAppDataValue",value:function(e,t){var n=e.content.appData&&e.content.appData["org.standardnotes.sn"];return n?n[t]:null}},{key:"activateThemes",value:function(e){if(this.loggingEnabled&&console.log("Incoming themes",e),this.activeThemes.sort().toString()!=e.sort().toString()){var t=e||[],n=[],r=!0,i=!1,a=void 0;try{for(var o,s=this.activeThemes[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;e.includes(u)?t=t.filter(function(e){return e!=u}):n.push(u)}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}this.loggingEnabled&&(console.log("Deactivating themes:",n),console.log("Activating themes:",t));var c=!0,l=!1,f=void 0;try{for(var p,h=n[Symbol.iterator]();!(c=(p=h.next()).done);c=!0){var d=p.value;this.deactivateTheme(d)}}catch(e){l=!0,f=e}finally{try{!c&&h.return&&h.return()}finally{if(l)throw f}}this.activeThemes=e;var y=!0,v=!1,g=void 0;try{for(var m,b=t[Symbol.iterator]();!(y=(m=b.next()).done);y=!0){var k=m.value;if(k){var w=document.createElement("link");w.id=btoa(k),w.href=k,w.type="text/css",w.rel="stylesheet",w.media="screen,print",w.className="custom-theme",document.getElementsByTagName("head")[0].appendChild(w)}}}catch(e){v=!0,g=e}finally{try{!y&&b.return&&b.return()}finally{if(v)throw g}}}}},{key:"themeElementForUrl",value:function(e){return Array.from(document.getElementsByClassName("custom-theme")).slice().find(function(t){return t.id==btoa(e)})}},{key:"deactivateTheme",value:function(e){var t=this.themeElementForUrl(e);t&&(t.disabled=!0,t.parentNode.removeChild(t))}},{key:"generateUUID",value:function(){var e=window.crypto||window.msCrypto;if(e){var t=new Uint32Array(4);e.getRandomValues(t);var n=-1;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){n++;var r=t[n>>3]>>n%8*4&15;return("x"==e?r:3&r|8).toString(16)})}var r=(new Date).getTime();return window.performance&&"function"==typeof window.performance.now&&(r+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)})}}]),e}();void 0!==e&&void 0!==e.exports&&(e.exports=a),window&&(window.ComponentManager=a)}]); \ No newline at end of file diff --git a/package.json b/package.json index 586504e..91ce915 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sn-filesafe", - "version": "2.0.0", + "version": "2.0.1", "main": "dist/dist.js", "scripts": { "lint": "eslint --cache --ignore-path .gitignore --ext .jsx,.js --format=node_modules/eslint-formatter-pretty .",