@lifeready/core 8.0.6 → 8.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("apollo-angular"),require("@dagrejs/graphlib"),require("lodash"),require("node-jose"),require("@aws-amplify/auth/lib-esm/Auth"),require("graphql-tag"),require("moment"),require("@apollo/client/core"),require("@apollo/client/link/context"),require("@apollo/client/link/retry"),require("ngx-cookie-service"),require("graphql/language/printer"),require("@angular/common/http"),require("@aws-amplify/core"),require("@ng-idle/core"),require("@ng-idle/keepalive"),require("slip39"),require("@aws-amplify/auth")):"function"==typeof define&&define.amd?define("@lifeready/core",["exports","@angular/core","apollo-angular","@dagrejs/graphlib","lodash","node-jose","@aws-amplify/auth/lib-esm/Auth","graphql-tag","moment","@apollo/client/core","@apollo/client/link/context","@apollo/client/link/retry","ngx-cookie-service","graphql/language/printer","@angular/common/http","@aws-amplify/core","@ng-idle/core","@ng-idle/keepalive","slip39","@aws-amplify/auth"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).lifeready=e.lifeready||{},e.lifeready.core={}),e.ng.core,e["apollo-angular"],e["@dagrejs/graphlib"],e.lodash,e["node-jose"],e["@aws-amplify/auth/lib-esm/Auth"],e["graphql-tag"],e.moment,e["@apollo/client/core"],e["@apollo/client/link/context"],e["@apollo/client/link/retry"],e["ngx-cookie-service"],e["graphql/language/printer"],e.ng.common.http,e["@aws-amplify/core"],e["@ng-idle/core"],e["@ng-idle/keepalive"],e.slip39,e["@aws-amplify/auth"])}(this,(function(e,t,n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g,S){"use strict";function C(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function b(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var I=C(r),w=C(i),K=C(o),P=b(c),k=C(S),R=function(e,t){return(R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function E(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}R(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function D(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function A(e,t,n,r){var i,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}function M(e,t,n,r){return new(n||(n=Promise))((function(i,a){function s(e){try{c(r.next(e))}catch(e){a(e)}}function o(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}c((r=r.apply(e,t||[])).next())}))}function T(e,t){var n,r,i,a,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}Object.create;function O(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function j(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return s}function N(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(j(arguments[t]));return e}function _(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var F,$,L;Object.create;function U(e){if(e&&e.length){var t=e.map((function(e){return new q({code:e.extensions&&e.extensions.code,source:e.extensions&&e.extensions.source,message:e.message,debug:{locations:e.locations,path:e.path}})}));throw new(J.bind.apply(J,N([void 0],t)))}}!function(e){e.Key="key",e.PassKey="passKey"}(F||(F={})),function(e){e.KeyLink="keyLink",e.PassKeyLink="passKeyLink"}($||($={})),function(e){e.JSON="JSON",e.UINT_8_ARRAY="UINT_8_ARRAY"}(L||(L={}));var x,q=function(e){this._type="KcError",this.code=e.code,this.source=e.source,this.message=e.message,this.debug=e.debug},J=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._type="KcException",this.errors=e}return e.prototype.toString=function(){return this.errors.map((function(e){return JSON.stringify(e,null,2)}))},e}();(x=e.KcErrorCode||(e.KcErrorCode={})).ARCHIVED_RESOURCE="ARCHIVED_RESOURCE",x.BAD_ARGUMENT="BAD_ARGUMENT",x.BAD_SIGNATURE="BAD_SIGNATURE",x.BAD_STATE="BAD_STATE",x.CHANGED_PERMISSIONS="CHANGED_PERMISSIONS",x.CONCURRENT_ACCESS="CONCURRENT_ACCESS",x.CONFIG_ERROR="CONFIG_ERROR",x.CYCLE_DETECTED="CYCLE_DETECTED",x.EXPIRED="EXPIRED",x.INVALID_TOKEN="INVALID_TOKEN",x.INTERNAL_ERROR="INTERNAL_ERROR",x.JSON_DECODE_ERROR="JSON_DECODE_ERROR",x.KEY_MISMATCH="KEY_MISMATCH",x.LIMIT_REACHED="LIMIT_REACHED",x.LOCKED="LOCKED",x.LOGIC_ERROR="LOGIC_ERROR",x.LR_DEBUG_ONLY="LR_DEBUG_ONLY",x.MIN_DELAY="MIN_DELAY",x.MISSING_FIELD="MISSING_FIELD",x.MISSING_FIELD_VALUE="MISSING_FIELD_VALUE",x.MISSING_QUERY_PARAM="MISSING_QUERY_PARAM",x.NOT_IMPLEMENTED="NOT_IMPLEMENTED",x.OBJECT_DOES_NOT_EXIST="OBJECT_DOES_NOT_EXIST",x.OBJECT_EXISTS="OBJECT_EXISTS",x.RANGE_ERROR="RANGE_ERROR",x.TRUSTED_PARTY_NOT_FOUND="TRUSTED_PARTY_NOT_FOUND",x.UNAUTHENTICATED_USER="UNAUTHENTICATED_USER",x.USER_NOT_FOUND="USER_NOT_FOUND",x.VERSION_MISMATCH="VERSION_MISMATCH",x.WRONG_PERMISSIONS="WRONG_PERMISSIONS",x.AUTH="AUTH",x.BAD_LOGIC="BAD_LOGIC",x.BAD_REQUEST="BAD_REQUEST",x.BAD_TIME_SYNC="BAD_TIME_SYNC",x.CODE_MISMATCH="CODE_MISMATCH",x.ENCRYPTION="ENCRYPTION",x.NOT_FOUND="NOT_FOUND",x.SUSPICIOUS_OPERATION="SUSPICIOUS_OPERATION",x.UNSUPPORTED="UNSUPPORTED";var G=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.AUTH,message:n}))||this}return E(n,t),n}(J),Q=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.BAD_ARGUMENT,message:n}))||this}return E(n,t),n}(J),W=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.BAD_LOGIC,message:n}))||this}return E(n,t),n}(J),V=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.BAD_REQUEST,message:n}))||this}return E(n,t),n}(J),B=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.BAD_SIGNATURE,message:n}))||this}return E(n,t),n}(J),Z=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.BAD_STATE,message:n}))||this}return E(n,t),n}(J),H=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.BAD_TIME_SYNC,message:n}))||this}return E(n,t),n}(J),Y=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.CODE_MISMATCH,message:n}))||this}return E(n,t),n}(J),X=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.CONCURRENT_ACCESS,message:n}))||this}return E(n,t),n}(J),z=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.ENCRYPTION,message:n}))||this}return E(n,t),n}(J),ee=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.INTERNAL_ERROR,message:n}))||this}return E(n,t),n}(J),te=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.LOCKED,message:n}))||this}return E(n,t),n}(J),ne=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.NOT_FOUND,message:n}))||this}return E(n,t),n}(J),re=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.SUSPICIOUS_OPERATION,message:n}))||this}return E(n,t),n}(J),ie=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.UNSUPPORTED,message:n}))||this}return E(n,t),n}(J);function ae(e){if(!Array.isArray(e))throw new Error("not array");return e.some((function(e){return null==e?void 0:e.then}))?Promise.all(e):e}function se(e,t){var n,r,i={};try{for(var a=O(Object.keys(e).entries()),s=a.next();!s.done;s=a.next()){var o=j(s.value,2),c=o[0];i[o[1]]=t[c]}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i}function oe(e,t){var n=ae(Object.entries(e).map((function(n){var r=j(n,2),i=r[0],a=r[1];return t(a,i,e)})));return n.then?n.then((function(t){return se(e,t)})):se(e,n)}function ce(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e.currentSession()];case 1:return[2,t.sent().getAccessToken().getJwtToken()];case 2:return t.sent(),[2,""];case 3:return[2]}}))}))}var ue,pe,de=P,le=K.default(ue||(ue=_(["\n query {\n serverTime {\n timestamp\n }\n }\n"],["\n query {\n serverTime {\n timestamp\n }\n }\n"]))),he=function(){function e(e,t){this.auth=e,this.apollo=t,this.VERIFY_ENABLED=!0,this.MAX_DIFF_MSEC=de.duration({seconds:30}).asMilliseconds(),this.offsetMs=null,this.verified=!1}return e.prototype.verifyCognito=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i;return T(this,(function(a){switch(a.label){case 0:return[4,ce(this.auth)];case 1:return(e=a.sent())?[4,fetch("https://cognito-idp.ap-southeast-2.amazonaws.com/",{method:"POST",mode:"cors",cache:"no-cache",headers:{"x-amz-target":"AWSCognitoIdentityProviderService.GetUser","x-amz-user-agent":"aws-amplify/0.1.x js","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify({AccessToken:e})})]:[2];case 2:if(t=a.sent(),n=Date.now(),r=de(t.headers.get("Date")).valueOf(),i=n+this.offsetMs,Math.abs(i-r)>this.MAX_DIFF_MSEC)throw new H("Server time does not match independent source. ServerTime: "+i+", Cognito time: "+r);return this.verified=!0,[2]}}))}))},e.prototype.refresh=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i;return T(this,(function(a){switch(a.label){case 0:return e=Date.now(),[4,this.apollo.query({query:le}).toPromise()];case 1:return t=a.sent(),n=Date.now(),U(t.errors),r=parseInt(t.data.serverTime.timestamp,10),i=n-e,this.offsetMs=Math.round(r-(e+i/2)),this.VERIFY_ENABLED?[4,this.verifyCognito()]:[3,3];case 2:a.sent(),a.label=3;case 3:return[2]}}))}))},e.prototype.serverNow=function(){return M(this,void 0,void 0,(function(){var e,t;return T(this,(function(n){switch(n.label){case 0:return e=!1,null===this.offsetMs&&(e=!0),this.VERIFY_ENABLED?(t=!this.verified)?[4,ce(this.auth)]:[3,2]:[3,3];case 1:t=n.sent(),n.label=2;case 2:t&&(e=!0),n.label=3;case 3:return e?[4,this.refresh()]:[3,5];case 4:n.sent(),n.label=5;case 5:return[2,Date.now()+this.offsetMs]}}))}))},e.prototype.now=function(){return null===this.offsetMs?(console.error("Server time offset not known. You must await serverNow() first. Returning local clock instead."),Date.now()):Date.now()+this.offsetMs},e.prototype.date=function(){return new Date(this.now())},e}();he.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new he(t.ɵɵinject(s.AuthClass),t.ɵɵinject(n.Apollo))},token:he,providedIn:"root"}),he.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],he.ctorParameters=function(){return[{type:s.AuthClass},{type:n.Apollo}]},function(e){e.JSON="JSON",e.COMPACT="COMPACT"}(pe||(pe={}));var ye={payloadType:L.JSON,returnOnlyPayload:!0},fe={payloadType:L.JSON,returnOnlyPayload:!0,serializations:[pe.JSON]};var ve=function(){function e(e){this.timeService=e}return e.prototype.decrypt=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i;return T(this,(function(s){switch(s.label){case 0:if(r={algorithms:["dir","A*GCM","RSA-OAEP-*"]},n=Object.assign(Object.assign({},fe),n),e.jwk&&(e=e.jwk),"string"==typeof t&&n.serializations.includes(pe.JSON))try{t=JSON.parse(t)}catch(e){if(!n.serializations.includes(pe.COMPACT))throw e;console.log("Not a JSON-formatted JWE, it maybe compact serialisation format.")}return[4,a.JWE.createDecrypt(e,r).decrypt(t)];case 1:return(i=s.sent()).payload=this.decodePayload(n.payloadType,i.payload),n.returnOnlyPayload?[2,i.payload]:[2,i]}}))}))},e.prototype.encryptToString=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return T(this,(function(i){switch(i.label){case 0:return r=(n=JSON).stringify,[4,this.encrypt(e,t)];case 1:return[2,r.apply(n,[i.sent()])]}}))}))},e.prototype.encrypt=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,s;return T(this,(function(o){switch(o.label){case 0:if(null==t)throw new Error("Encrypting null/undefined content.");return t instanceof ArrayBuffer||(t=(new TextEncoder).encode(JSON.stringify(t))),r=(n=a.JWE).createEncrypt,i={contentAlg:"A256GCM"},s={},[4,this.timeService.serverNow()];case 1:return[2,r.apply(n,[(i.fields=(s.timestamp=o.sent(),s),i),e]).update(t).final()]}}))}))},e.prototype.sign=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,s,o;return T(this,(function(c){switch(c.label){case 0:return i=(r=a.JWS).createSign,s={},o={},[4,this.timeService.serverNow()];case 1:return n=i.apply(r,[(s.fields=(o.timestamp=c.sent(),o),s),e]),t instanceof Buffer?n.update(t):n.update(JSON.stringify(t),"utf8"),[2,n.final()]}}))}))},e.prototype.signToString=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return T(this,(function(i){switch(i.label){case 0:return r=(n=JSON).stringify,[4,this.sign(e,t)];case 1:return[2,r.apply(n,[i.sent()])]}}))}))},e.prototype.verify=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,s;return T(this,(function(o){switch(o.label){case 0:r={algorithms:["RS*"]},n=Object.assign(Object.assign({},ye),n),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,a.JWS.createVerify(e,r).verify(t)];case 2:return(i=o.sent()).payload=this.decodePayload(n.payloadType,i.payload),n.returnOnlyPayload?[2,i.payload]:[2,i];case 3:throw s=o.sent(),new B("Bad signature: "+s);case 4:return[2]}}))}))},e.prototype.encryptThenSign=function(e,t){var n=e.key,r=e.sigPrk;return M(this,void 0,void 0,(function(){var e,i,a,s;return T(this,(function(o){switch(o.label){case 0:return a=(i=JSON).stringify,[4,this.encrypt(n,t)];case 1:return e=a.apply(i,[o.sent()]),[4,this.sign(r,e)];case 2:return delete(s=o.sent()).payload,[2,{cipher:e,sig:JSON.stringify(s)}]}}))}))},e.prototype.decodePayload=function(e,t){switch(e){case L.JSON:return JSON.parse((new TextDecoder).decode(t));case L.UINT_8_ARRAY:return t;default:throw new Q("Unknown payloadType: "+e)}},e}();ve.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ve(t.ɵɵinject(he))},token:ve,providedIn:"root"}),ve.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ve.ctorParameters=function(){return[{type:he}]};var me=function(){function e(){this.kcCrypto=window.crypto}return e.prototype.toHex=function(e){return Array.from(new Uint8Array(e)).map((function(e){return e.toString(16).padStart(2,"0")})).join("")},e.prototype.stringDigest=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return T(this,(function(a){switch(a.label){case 0:return n=new TextEncoder,r=n.encode(t),[4,this.kcCrypto.subtle.digest(e,r)];case 1:return i=a.sent(),[2,this.toHex(i)]}}))}))},e}();me.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new me},token:me,providedIn:"root"}),me.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}];var ge=function(){function e(e){this.webCryptoService=e,this.MIN_PASS_IDP_PBKDF_ITER=1e5,this.MIN_PASS_KEY_PBKDF_ITER=1e5,this.MIN_LBOP_KEY_PBKDF_ITER=1e5,this.DEFAULT_PASS_IDP_PBKDF_ITER=this.MIN_PASS_IDP_PBKDF_ITER,this.DEFAULT_PASS_KEY_PBKDF_ITER=this.MIN_PASS_KEY_PBKDF_ITER,this.DEFAULT_LBOP_KEY_PBKDF_ITER=this.MIN_LBOP_KEY_PBKDF_ITER,this.kcCrypto=this.webCryptoService.kcCrypto}return e.asKey=function(e,t,n){return a.JWK.asKey(e,t,n)},e.prototype.randomString=function(e){if(e<=0)throw new Q("digits <= 0");var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint32Array(e);return this.kcCrypto.getRandomValues(n),n=n.map((function(e){return t.charCodeAt(e%t.length)})),String.fromCharCode.apply(null,n)},e.prototype.randomDigitsNoZeros=function(e){return this.randomChoices([1,2,3,4,5,6,7,8,9],e).join("")},e.prototype.randomChoices=function(e,t){if(e.length<=1)throw new Q("array.length <= 0");if(t<=0)throw new Q("chooseN <= 0");var n=new Uint32Array(t);this.kcCrypto.getRandomValues(n);var r=[];return n.forEach((function(t){return r.push(e[t%e.length])})),r},e.prototype.createSalt=function(){return this.randomString(16)},e.prototype.createKey=function(){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t)];case 2:return delete(n=r.sent()).ext,delete n.key_ops,[2,e.asKey(n)]}}))}))},e.prototype.createSignKey=function(){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"HMAC",hash:{name:"SHA-512"}},!0,["sign","verify"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.createPkcKey=function(){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["encrypt","decrypt"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t.privateKey)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.createPkcSignKey=function(){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t.privateKey)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.importPassword=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){return t=new TextEncoder,[2,this.kcCrypto.subtle.importKey("raw",t.encode(e),"PBKDF2",!1,["deriveKey"])]}))}))},e.prototype.deriveKey=function(t){var n=t.password,r=t.salt,i=t.iterations,a=t.kid;return M(this,void 0,void 0,(function(){var t,s;return T(this,(function(o){switch(o.label){case 0:return[4,this.kcCrypto.subtle.deriveKey({name:"PBKDF2",salt:(new TextEncoder).encode(r),iterations:i,hash:"SHA-256"},n,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 1:return t=o.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t)];case 2:return s=o.sent(),a&&(s.kid=a),[4,e.asKey(s)];case 3:return[2,{jwk:o.sent()}]}}))}))},e.prototype.derivePassIdp=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){if(e.iterations<this.MIN_PASS_IDP_PBKDF_ITER)throw new re("The number of PassIdp key derivation iterations sent from the server ("+e.iterations+") is lower than the minimum ("+this.MIN_PASS_IDP_PBKDF_ITER+")");return[2,this.deriveKey(e)]}))}))},e.prototype.derivePassKey=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){if(e.iterations<this.MIN_PASS_KEY_PBKDF_ITER)throw new re("The number of PassKey key derivation iterations sent from the server("+e.iterations+") is lower than the minimum("+this.MIN_PASS_KEY_PBKDF_ITER+")");return[2,this.deriveKey(e)]}))}))},e.prototype.deriveLbopKey=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){if(e.iterations<this.MIN_LBOP_KEY_PBKDF_ITER)throw new re("The number of LbopKey key derivation iterations sent from the server("+e.iterations+") is lower than the minimum("+this.MIN_LBOP_KEY_PBKDF_ITER+")");return[2,this.deriveKey(e)]}))}))},e.prototype.createKid=function(){return M(this,void 0,void 0,(function(){return T(this,(function(e){switch(e.label){case 0:return[4,this.createKey()];case 1:return[2,e.sent().kid]}}))}))},e.prototype.createPassIdpParams=function(){return M(this,void 0,void 0,(function(){return T(this,(function(e){return[2,{salt:this.createSalt(),iterations:this.DEFAULT_PASS_IDP_PBKDF_ITER}]}))}))},e.prototype.createPassKeyParams=function(){return M(this,void 0,void 0,(function(){var e;return T(this,(function(t){switch(t.label){case 0:return e={salt:this.createSalt()},[4,this.createKid()];case 1:return[2,(e.kid=t.sent(),e.iterations=this.DEFAULT_PASS_KEY_PBKDF_ITER,e)]}}))}))},e.prototype.createLbopKeyParams=function(){return M(this,void 0,void 0,(function(){var e;return T(this,(function(t){switch(t.label){case 0:return e={salt:this.createSalt()},[4,this.createKid()];case 1:return[2,(e.kid=t.sent(),e.iterations=this.DEFAULT_PASS_KEY_PBKDF_ITER,e)]}}))}))},e}();ge.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ge(t.ɵɵinject(me))},token:ge,providedIn:"root"}),ge.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ge.ctorParameters=function(){return[{type:me}]};var Se=new t.InjectionToken("KC_CONFIG"),Ce=[e.KcErrorCode.CONCURRENT_ACCESS];function be(e,t){var n;return M(this,void 0,void 0,(function(){var r,i;return T(this,(function(a){switch(a.label){case 0:return[4,ce(e)];case 1:return r=a.sent(),i=null===(n=t.debug)||void 0===n?void 0:n.username,[2,{withCredentials:!0,headers:Object.assign(Object.assign({},r&&{authorization:"Bearer "+r}),i&&{"x-kc-dev-user":i})}]}}))}))}var Ie=function(e,t){var n=p.setContext((function(n,r){var i=r.headers;return M(void 0,void 0,void 0,(function(){var n;return T(this,(function(r){switch(r.label){case 0:return[4,be(t,e)];case 1:return n=r.sent(),[2,Object.assign(Object.assign({},n),{headers:Object.assign(Object.assign({},i),n.headers)})]}}))}))})),r=new d.RetryLink({delay:{initial:300,max:1/0,jitter:!0},attempts:{max:3,retryIf:function(e,t){return!!(e instanceof i&&e.errors.some((function(e){var t;return Ce.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})))}}}),i=function(e){function t(t){var n=e.call(this,t.map((function(e){return e.message})).join(", "))||this;return n.errors=t,n}return E(t,e),t}(Error),a=new u.ApolloLink((function(e,t){return t(e).map((function(e){if(e&&e.errors&&e.errors.filter((function(e){var t;return Ce.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})).length>0)throw new i(e.errors);return e}))})),s=u.createHttpLink({uri:e.apolloUrl,credentials:"include"});return Object.assign({link:u.from([r,a,n,s]),cache:new u.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"all"},query:{fetchPolicy:"no-cache",errorPolicy:"all"},mutate:{fetchPolicy:"no-cache",errorPolicy:"all"}}},e.apolloConfig)},we=function(){function e(e,n,r,i){this.keyFactory=e,this.cookieService=n,this.encryptionService=r,this.injector=i,this.KEY_PREFIX="lrSession-",this.cookieSecure=!0,this.serverSessionEncryptionKey=null,t.isDevMode()&&this.setCookieSecure(!1)}return e.prototype.setServerSessionEncryptionKey=function(e){this.serverSessionEncryptionKey=e},e.prototype.clearServerSessionEncryptionKey=function(){this.serverSessionEncryptionKey=null},e.prototype.getCookieParams=function(){return{path:"/",domain:null,secure:this.cookieSecure,sameSite:"Lax"}},e.prototype.clear=function(){var e=this;Object.keys(this.cookieService.getAll()).forEach((function(t){t.startsWith(e.KEY_PREFIX)&&e.deletePrefixedName(t)})),Object.keys(localStorage).forEach((function(t){t.startsWith(e.KEY_PREFIX)&&e.deletePrefixedName(t)}))},e.prototype.setCookieSecure=function(e){if(this.cookieSecure=e,!e){if(!t.isDevMode())throw new Q("Can not set PersistService cookie secure flag to false in production mode.");console.warn("The cookie secure flag in persistService has been set to false, set it to true in production mode")}},e.prototype.prefixName=function(e){return this.KEY_PREFIX+e},e.prototype.delete=function(e){this.deletePrefixedName(this.prefixName(e))},e.prototype.deletePrefixedName=function(e){var t=this.getCookieParams();this.cookieService.delete(e,t.path,t.domain,t.secure,t.sameSite),localStorage.removeItem(e)},e.prototype.set=function(e){var t=e.name,n=e.value,r=e.serverSession,i=e.expiry;return M(this,void 0,void 0,(function(){var e,a,s,o,c,u,p;return T(this,(function(d){switch(d.label){case 0:return e=this.prefixName(t),r?(s={serverSession:!0},[4,this.encryptionService.encryptToString(this.serverSessionEncryptionKey,n)]):[3,2];case 1:return s.data=d.sent(),a=s,[3,3];case 2:a={data:n},d.label=3;case 3:return i?[4,this.keyFactory.createKey()]:[3,6];case 4:return o=d.sent(),a.expiry=i.toISOString(),c=a,[4,this.encryptionService.encryptToString(o,a.data)];case 5:c.data=d.sent(),u={key:o.toJSON(!0)},p=this.getCookieParams(),this.cookieService.set(e,JSON.stringify(u),i,p.path,p.domain,p.secure,p.sameSite),d.label=6;case 6:return localStorage.setItem(e,JSON.stringify(a)),[2]}}))}))},e.prototype.get=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return T(this,(function(i){switch(i.label){case 0:t=this.prefixName(e),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.getImpl(t)];case 2:return null==(n=i.sent())&&this.deletePrefixedName(t),[2,n];case 3:throw r=i.sent(),this.deletePrefixedName(t),r;case 4:return[2]}}))}))},e.prototype.getImpl=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s;return T(this,(function(o){switch(o.label){case 0:return(t=localStorage.getItem(e))?(n=JSON.parse(t)).expiry?(i=this.cookieService.get(e))?(a=JSON.parse(i),[4,ge.asKey(a.key)]):(console.log("No cookie."),[2,null]):[3,3]:[2,null];case 1:return s=o.sent(),[4,this.encryptionService.decrypt(s,n.data)];case 2:return r=o.sent(),[3,4];case 3:r=n.data,o.label=4;case 4:return n.serverSession?[4,this.encryptionService.decrypt(this.serverSessionEncryptionKey,r)]:[3,6];case 5:r=o.sent(),o.label=6;case 6:return[2,r]}}))}))},e}();we.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new we(t.ɵɵinject(ge),t.ɵɵinject(l.CookieService),t.ɵɵinject(ve),t.ɵɵinject(t.INJECTOR))},token:we,providedIn:"root"}),we.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],we.ctorParameters=function(){return[{type:ge},{type:l.CookieService},{type:ve},{type:t.Injector}]};var Ke=function(){function e(e,t){this.config=e,this.persistService=t,this.STORE_MASTER_KEY="masterKey",this.MIN_PASS_IDP_PBKDF_ITER=1e5,this.MIN_PASS_KEY_PBKDF_ITER=1e5,this.MIN_LBOP_KEY_PBKDF_ITER=1e5,this.DEFAULT_PASS_IDP_PBKDF_ITER=this.MIN_PASS_IDP_PBKDF_ITER,this.DEFAULT_PASS_KEY_PBKDF_ITER=this.MIN_PASS_KEY_PBKDF_ITER,this.DEFAULT_LBOP_KEY_PBKDF_ITER=this.MIN_LBOP_KEY_PBKDF_ITER,this.resetKeys()}return e.prototype.resetKeys=function(){this.keys=null,this.masterKey=null},e.prototype.purgeKeys=function(){this.resetKeys(),this.persistService.clear()},e.prototype.setKeys=function(e){this.keys=e},Object.defineProperty(e.prototype,"currentPassKey",{get:function(){return this.keys.passKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentMasterKey",{get:function(){return this.keys.masterKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentRootKey",{get:function(){return this.keys.rootKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentPxk",{get:function(){return this.keys.pxk},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentSigPxk",{get:function(){return this.keys.sigPxk},enumerable:!1,configurable:!0}),e.prototype.expiresAfter=function(e){return new Date(Date.now()+1e3*e)},e.prototype.persistMasterKey=function(e,t){return M(this,void 0,void 0,(function(){var n;return T(this,(function(r){switch(r.label){case 0:return n={id:e.id,jwk:e.jwk.toJSON(!0)},this.masterKey=e,[4,this.persistService.set({name:this.STORE_MASTER_KEY,value:n,expiry:this.expiresAfter(t),serverSession:!this.config.disableSessionEncryptionKey})];case 1:return r.sent(),[2]}}))}))},e.prototype.setMasterKeyExpiresAfterSeconds=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.persistService.get(this.STORE_MASTER_KEY)];case 1:if(null==(t=n.sent()))throw new ne("Can not find masterKey in persisted storage using name: "+this.STORE_MASTER_KEY);return[4,this.persistService.set({name:this.STORE_MASTER_KEY,value:t,expiry:this.expiresAfter(e),serverSession:!this.config.disableSessionEncryptionKey})];case 2:return n.sent(),[2]}}))}))},e.prototype.loadMasterKey=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return this.masterKey?[3,3]:[4,this.persistService.get(this.STORE_MASTER_KEY)];case 1:if(!(t=r.sent()))throw new ne("Could not find masterKey in persisted storage");if(t.id!==e)throw new ne("masterKeyId "+t.id+" in persisted storage does not match the one requested "+e);return n=t,[4,ge.asKey(t.jwk)];case 2:n.jwk=r.sent(),this.masterKey=t,r.label=3;case 3:return[2,this.masterKey]}}))}))},e}();Ke.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ke(t.ɵɵinject(Se),t.ɵɵinject(we))},token:Ke,providedIn:"root"}),Ke.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ke.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:we}]};var Pe=function(){function e(e,t,n){this.encryptionService=e,this.keyService=t,this.keyFactory=n,this.purgeKeys()}return e.prototype.purgeKeys=function(){this.graph=new r.Graph},e.prototype.populateKeys=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return T(this,(function(i){switch(i.label){case 0:return n=(t=this.keyService).setKeys,r={passKey:e.passKey},[4,this.keyService.loadMasterKey(e.masterKey.id)];case 1:return r.masterKey=i.sent(),[4,this.unwrapKey(e.masterKey.id,e.rootKey.id)];case 2:return r.rootKey=i.sent(),[4,this.unwrapKey(e.masterKey.id,e.pxk.id)];case 3:return r.pxk=i.sent(),[4,this.unwrapKey(e.masterKey.id,e.sigPxk.id)];case 4:return n.apply(t,[(r.sigPxk=i.sent(),r)]),[2]}}))}))},e.prototype.hasKey=function(e){return!!this.graph.node(e)},e.prototype.getNode=function(e,t){var n=this.graph.node(e);if(!n)throw new ne("Key graphs does not contain key id: "+e);if(n.type!==t)throw new Z("Key with id "+e+" is not of type "+t);return n.data},e.prototype.key=function(e){return this.getNode(e,F.Key)},e.prototype.passKey=function(e){return this.getNode(e,F.PassKey)},e.prototype.addKeys=function(e){var t,n,r,i,a,s;if(e.keys)try{for(var o=O(e.keys),c=o.next();!c.done;c=o.next()){var u=c.value;if(!this.graph.hasNode(u.id)){var p={type:F.Key,data:w.default.cloneDeep(u)};this.graph.setNode(u.id,p)}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}if(e.keyLinks)try{for(var d=O(e.keyLinks),l=d.next();!l.done;l=d.next()){var h=l.value;if(!this.graph.hasEdge(h.wrappingKeyId,h.keyId)){var y={type:$.KeyLink,data:w.default.cloneDeep(h)};this.graph.setEdge(h.wrappingKeyId,h.keyId,y)}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}if(e.passKeyLinks)try{for(var f=O(e.passKeyLinks),v=f.next();!v.done;v=f.next()){var m=v.value;if(!this.graph.hasEdge(m.passKeyId,m.keyId)){y={type:$.PassKeyLink,data:w.default.cloneDeep(m)};this.graph.setEdge(m.passKeyId,m.keyId,y)}}}catch(e){a={error:e}}finally{try{v&&!v.done&&(s=f.return)&&s.call(f)}finally{if(a)throw a.error}}},e.prototype.tracePath=function(e,t){var n=[],r=t;if(!e[r].predecessor)return null;for(;e[r].predecessor;){var i=e[r].predecessor;n.push(this.graph.edge(i,r)),r=i}return n.reverse(),n},e.prototype.getPath=function(e,t){if(!e||"string"!=typeof e)throw new z("Param knownKeyId wrong format: "+e);if(!t||"string"!=typeof t)throw new z("Param keyId wrong format: "+t);var n=I.default.alg.dijkstra(this.graph,e);return this.tracePath(n,t)},e.prototype.getJwkKey=function(e,t){return M(this,void 0,void 0,(function(){return T(this,(function(n){switch(n.label){case 0:return[4,this.getKey(e,t)];case 1:return[2,n.sent().jwk]}}))}))},e.prototype.getKey=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return T(this,(function(a){switch(a.label){case 0:return n="string"==typeof e?e:null==e?void 0:e.id,this.hasKey(n)||!t?[3,2]:[4,t()];case 1:if(r=a.sent(),null!=n&&n!=r)throw new W("Requested keyId is not in the key cache, so an API request was made to populate the key cache.But the key returned by the API does NOT match the requested keyId.This is a programming logic error.");n=r,a.label=2;case 2:return(i=this.key(n)).jwk?[2,i]:[2,this.unwrapKey(this.keyService.currentMasterKey.id,n)]}}))}))},e.prototype._unwrapLink=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h;return T(this,(function(y){switch(y.label){case 0:return(r=JSON.parse(t.data.wrappedKey)).signatures?[4,this.encryptionService.verify(e,r)]:[3,2];case 1:return i=y.sent(),[3,4];case 2:return[4,this.encryptionService.decrypt(e,r)];case 3:i=y.sent(),y.label=4;case 4:if(t.type!=$.KeyLink)return[3,13];if(!(a=t.data).nestedWrappingKeyIds)return[3,13];y.label=5;case 5:y.trys.push([5,11,12,13]),s=O(a.nestedWrappingKeyIds),o=s.next(),y.label=6;case 6:return o.done?[3,10]:(c=o.value,[4,this.getKey(c)]);case 7:return u=y.sent(),[4,this.encryptionService.decrypt(u.jwk,i)];case 8:i=y.sent(),y.label=9;case 9:return o=s.next(),[3,6];case 10:return[3,13];case 11:return p=y.sent(),l={error:p},[3,13];case 12:try{o&&!o.done&&(h=s.return)&&h.call(s)}finally{if(l)throw l.error}return[7];case 13:return d=n,[4,ge.asKey(i)];case 14:return d.jwk=y.sent(),n.task=null,[2]}}))}))},e.prototype._unwrap=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c;return T(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),n=O(t),r=n.next(),u.label=1;case 1:return r.done?[3,4]:(i=r.value,(a=this.key(i.data.keyId)).jwk?(e=a.jwk,[3,3]):(a.task||(a.task=this._unwrapLink(e,i,a)),[4,a.task]));case 2:u.sent(),e=a.jwk,u.label=3;case 3:return r=n.next(),[3,1];case 4:return[3,7];case 5:return s=u.sent(),o={error:s},[3,7];case 6:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(o)throw o.error}return[7];case 7:return[2,e]}}))}))},e.prototype.unwrapWithPassKey=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i;return T(this,(function(a){switch(a.label){case 0:return r=this.getPath(e,n),i={id:n},[4,this._unwrap(t,r)];case 1:return[2,(i.jwk=a.sent(),i)]}}))}))},e.prototype.unwrapKey=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return T(this,(function(a){switch(a.label){case 0:return[4,this.keyService.loadMasterKey(e)];case 1:return n=a.sent(),e===t?[2,n]:(r=this.getPath(n.id,t),i={id:t},[4,this._unwrap(n.jwk,r)]);case 2:return[2,(i.jwk=a.sent(),i)]}}))}))},e.prototype.decryptFromString=function(e,t,n){return M(this,void 0,void 0,(function(){var r;return T(this,(function(i){switch(i.label){case 0:return t?[4,this.getJwkKey(e)]:[3,3];case 1:return r=i.sent(),[4,this.encryptionService.decrypt(r,JSON.parse(t),n)];case 2:return[2,i.sent()];case 3:return[2,null]}}))}))},e.prototype.decryptFile=function(e,t){return M(this,void 0,void 0,(function(){var n;return T(this,(function(r){switch(r.label){case 0:return[4,this.getJwkKey(e)];case 1:return n=r.sent(),[4,this.encryptionService.decrypt(n,t,{payloadType:L.UINT_8_ARRAY})];case 2:return[2,r.sent()]}}))}))},e.prototype.encryptToString=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return T(this,(function(i){switch(i.label){case 0:return null==t?[2,null]:(r=function(e){return e.id&&e.jwk?e.jwk:e.keystore&&e.length&&e.kty&&e.kid&&e.alg?e:null}(e))?[3,2]:[4,this.getJwkKey(e)];case 1:r=i.sent(),i.label=2;case 2:return n=r,[2,this.encryptionService.encryptToString(n,t)]}}))}))},e.prototype.wrapKey=function(e,t){return M(this,void 0,void 0,(function(){return T(this,(function(n){if(!function(e){return"oct"===e.kty}(t))throw new Q("Only allowing wrapping of symmetric keys.");return[2,this.encryptToString(e,t.toJSON(!0))]}))}))},e.prototype.encryptWithNewKey=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return T(this,(function(a){switch(a.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=a.sent(),[4,this.encryptToString(e,n.toJSON(!0))];case 2:return r=a.sent(),[4,this.encryptToString(n,t)];case 3:return i=a.sent(),[2,{key:n,wrappingKeyId:e,wrappedKey:r,cipher:i}]}}))}))},e}();Pe.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Pe(t.ɵɵinject(ve),t.ɵɵinject(Ke),t.ɵɵinject(ge))},token:Pe,providedIn:"root"}),Pe.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Pe.ctorParameters=function(){return[{type:ve},{type:Ke},{type:ge}]};var ke=function(){function e(e,t){this.apollo=e,this.keyGraph=t}return e.prototype.addKeys=function(e){e.data.keyGraph&&this.keyGraph.addKeys(e.data.keyGraph)},e.prototype.query=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query(e).toPromise()];case 1:return U((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e.prototype.mutate=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.apollo.mutate(e).toPromise()];case 1:return U((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e}();function Re(e,t){var n=e.definitions.filter((function(e){return"OperationDefinition"===e.kind}));if(n.length>1)throw new W("There can be only one '"+t+"' operation, instead there are "+n.length);return n[0]}function Ee(e){return Re(e,"query")}function De(e){return Re(e,"mutation")}function Ae(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function Me(e){return{kind:"Name",value:e}}function Te(e){var t;return(null===(t=e.alias)||void 0===t?void 0:t.value)||e.name.value}function Oe(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return K.default.apply(void 0,N([e],t))}ke.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ke(t.ɵɵinject(n.Apollo),t.ɵɵinject(Pe))},token:ke,providedIn:"root"}),ke.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ke.ctorParameters=function(){return[{type:n.Apollo},{type:Pe}]};var je,Ne,_e="\n{\n keys {\n id\n }\n keyLinks {\n keyId\n wrappingKeyId\n nestedWrappingKeyIds\n wrappedKey\n }\n passKeys {\n id\n }\n passKeyLinks {\n keyId\n passKeyId\n wrappedKey\n }\n __typename\n}\n",Fe=K.default(je||(je=_(["\nfragment KeyGraphFragment on KeyGraphType ","\n"],["\nfragment KeyGraphFragment on KeyGraphType ","\n"])),_e),$e="keyGraph "+_e,Le="keyGraph: fetchKeyGraph "+_e,Ue=K.default(Ne||(Ne=_(["\n query Directory($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n directory(id: $id) {\n id\n keyId\n plainMeta\n cipherMeta\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query Directory($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n directory(id: $id) {\n id\n keyId\n plainMeta\n cipherMeta\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),Fe),xe=["constructor","ngOnChanges","ngOnInit","ngDoCheck","ngAfterContentInit","ngAfterContentChecked","ngAfterViewInit","ngAfterViewChecked","ngOnDestroy"];function qe(e){var t=e.ngZoneName,n=e.exceptLastPromise,r=void 0===n||n,i=e.excludeMethods,a=void 0===i?[]:i,s=e.patchSetters,o=void 0===s||s;return function(e){function n(n,i){var a=this;if(!this[t])throw new W("RunOutsideAngular decorator requires that "+e.name+" inject NgZone as "+t);var s=this[t].runOutsideAngular((function(){return n.apply(a,i)}));return r&&(null==s?void 0:s.then)?Promise.resolve(s):s}return a=N(a,xe),Object.getOwnPropertyNames(e.prototype).filter((function(e){return!a.includes(e)})).forEach((function(t){if(o&&Object.getOwnPropertyDescriptor(e.prototype,t).set){var r=Object.getOwnPropertyDescriptor(e.prototype,t).set;Object.defineProperty(e.prototype,t,{set:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.apply(this,[r,e])}})}if("function"==typeof e.prototype[t]){var i=e.prototype[t];e.prototype[t]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.apply(this,[i,e])}}})),e}}var Je={hasKeys:!0};function Ge(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s=this;return T(this,(function(o){switch(o.label){case 0:return r=(n=Object).assign,i=[Object.assign({},e)],a={},[4,Promise.all(e.edges.map((function(e){return M(s,void 0,void 0,(function(){var n,r,i,a;return T(this,(function(s){switch(s.label){case 0:return r=(n=Object).assign,i=[Object.assign({},e)],a={},[4,t(e.node)];case 1:return[2,r.apply(n,i.concat([(a.node=s.sent(),a)]))]}}))}))})))];case 1:return[2,r.apply(n,i.concat([(a.edges=o.sent(),a)]))]}}))}))}e.CommonProcessorsService=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.series=function(e){var t=this;return function(n){var r=n.field,i=n.context,a=n.options;return M(t,void 0,void 0,(function(){var t,n,s,o,c;return T(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),t=O(e),n=t.next(),u.label=1;case 1:return n.done?[3,4]:[4,(0,n.value)({field:r,context:i,options:a})];case 2:r=u.sent(),u.label=3;case 3:return n=t.next(),[3,1];case 4:return[3,7];case 5:return s=u.sent(),o={error:s},[3,7];case 6:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}return[7];case 7:return[2,r]}}))}))}},e.prototype.makeJsonParseProcessor=function(e){var t=void 0===e?{}:e,n=t.plainFieldName,r=t.jsonFieldSuffix,i=n+(void 0===r?"Json":r);return function(e){var t,r=e.field;if(null==r[n]||i in r)return r;try{return Object.assign(Object.assign({},r),((t={})[i]=JSON.parse(r[n]),t))}catch(e){return r}}},e.prototype.makeDecryptionProcessor=function(e){var t=this,n=void 0===e?{}:e,r=n.cipherFieldName,i=n.clearFieldSuffix,a=void 0===i?"ClearJson":i,s=n.getKeyId,o=void 0===s?null:s,c=r+a;return function(e){return M(t,void 0,void 0,(function(){var t,n,i,a,s,u;return T(this,(function(p){switch(p.label){case 0:return n=e.field,i=e.context,e.options.hasKeys?!(a=n[r])||c in n?[2,n]:o?[4,o(e)]:[3,2]:[2,n];case 1:return u=p.sent(),[3,3];case 2:u=n.keyId||(null===(t=n.key)||void 0===t?void 0:t.id),p.label=3;case 3:if(!(s=u))throw new W("Query response does not contain "+(o?"key-id":"keyId or key.id")+" field: "+i.path.join("."));return[2,this.keyGraph.decryptFromString(s,a).then((function(e){var t;return Object.assign(Object.assign({},n),((t={})[c]=e,t))}))]}}))}))}},e}(),e.CommonProcessorsService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.CommonProcessorsService(t.ɵɵinject(t.NgZone),t.ɵɵinject(Pe))},token:e.CommonProcessorsService,providedIn:"root"}),e.CommonProcessorsService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.CommonProcessorsService.ctorParameters=function(){return[{type:t.NgZone},{type:Pe}]},e.CommonProcessorsService=A([qe({ngZoneName:"ngZone"})],e.CommonProcessorsService);var Qe=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.processTpPasswordResetUser=function(e){var t;return M(this,void 0,void 0,(function(){var n,r,i,a,s=this;return T(this,(function(o){switch(o.label){case 0:return(r=null===(t=e.pxk)||void 0===t?void 0:t.id)?[4,this.keyGraph.getKey(e.pxk.id)]:[3,2];case 1:r=o.sent(),o.label=2;case 2:return n=r,i=Object.assign({},e),n&&e.approvals?(a=i,[4,Promise.all(e.approvals.map((function(e){return s.processTpPasswordResetUserApprovalNode(e,n)})))]):[3,4];case 3:a.approvals=o.sent(),o.label=4;case 4:return[2,i]}}))}))},e.prototype.processTpPasswordResetUserApprovalNode=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return T(this,(function(i){switch(i.label){case 0:return n=Object.assign({},e),e.receiverCipher&&(n.receiverCipherClearJson=this.keyGraph.decryptFromString(t,e.receiverCipher)),e.receiverCipherPartialAssemblyKey?(r=n,[4,this.keyGraph.decryptFromString(t,e.receiverCipherPartialAssemblyKey)]):[3,2];case 1:r.receiverCipherPartialAssemblyKeyClearJson=i.sent(),i.label=2;case 2:return[2,n]}}))}))},e.prototype.makeTpPasswordResetNodeProcessor=function(){var e=this;return function(t){var n=t.field;return M(e,void 0,void 0,(function(){var e,t;return T(this,(function(r){switch(r.label){case 0:if(e=Object.assign({},n),!n.assembly)return[3,2];if(null==n.applied)throw new V('If you request for field "assembly" in the TpPasswordResetNode, then you must also request the "applied" field');return t=e,[4,this.processTpAssemblyNode(n.assembly,n.applied)];case 1:t.assembly=r.sent(),r.label=2;case 2:return[2,e]}}))}))}},e.prototype.processTpAssemblyNode=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l=this;return T(this,(function(h){switch(h.label){case 0:return n=e.subjectKey,r=e.assemblyKey,i=e.assemblyCipherData,a=e.subAssemblies,c=(o=Object).assign,u=[Object.assign({},e)],p={},[4,Ge(a,(function(e){return l.processTpSubAssemblyNode(e,n.id,t)}))];case 1:return s=c.apply(o,u.concat([(p.subAssemblies=h.sent(),p)])),t?[3,3]:i?(d=s,[4,this.keyGraph.decryptFromString(r.id,i)]):[3,3];case 2:d.assemblyCipherDataClearJson=h.sent(),h.label=3;case 3:return[2,s]}}))}))},e.prototype.processTpSubAssemblyNode=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d=this;return T(this,(function(l){switch(l.label){case 0:return r=e.subjectCipherData,i=e.approvers,o=(s=Object).assign,c=[Object.assign({},e)],u={},[4,Ge(i,(function(e){return d.processTpAssemblyApproverNode(e,n)}))];case 1:return a=o.apply(s,c.concat([(u.approvers=l.sent(),u)])),n?[3,3]:r?(p=a,[4,this.keyGraph.decryptFromString(t,r)]):[3,3];case 2:p.subjectCipherDataClearJson=l.sent(),l.label=3;case 3:return[2,a]}}))}))},e.prototype.processTpAssemblyApproverNode=function(e,t){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,e]}))}))},e}();function We(e,t){return Object.assign(Object.assign({},e),{path:N(e.path,[t])})}Qe.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Qe(t.ɵɵinject(t.NgZone),t.ɵɵinject(Pe))},token:Qe,providedIn:"root"}),Qe.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Qe.ctorParameters=function(){return[{type:t.NgZone},{type:Pe}]},Qe=A([qe({ngZoneName:"ngZone"})],Qe),e.QueryProcessorService=function(){function e(e,t,n,r){this.ngZone=e,this.keyService=t,this.common=n,this.tpprProcessor=r,this.TYPENAME="__typename",this.processors={},this.registerProcessor("DirectoryNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeDecryptionProcessor({cipherFieldName:"cipherMeta"})])),this.registerProcessor("FileStateNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeDecryptionProcessor({cipherFieldName:"cipherMeta"})])),this.registerProcessor("ContactCardNode",n.makeDecryptionProcessor({cipherFieldName:"cipherData"})),this.registerProcessor("SharedContactCardNode",n.series([n.makeJsonParseProcessor({plainFieldName:"ownerPlainData"}),n.makeDecryptionProcessor({cipherFieldName:"ownerCipherData",getKeyId:function(e){return e.field.ownerKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"receiverCipherData",getKeyId:function(e){return e.field.receiverKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpPasswordResetNode",this.tpprProcessor.makeTpPasswordResetNodeProcessor()),this.registerProcessor("SharedTpClaimApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherApprovalData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherPartialAssemblyKey",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpAssemblyAsApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("ScenarioReceiverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioReceiverDirectoryNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioApproverAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"assemblyCipherData",getKeyId:function(e){return e.field.assemblyKey.id}})])),this.registerProcessor("ScenarioApproverSubAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("ScenarioApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherApprovalData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherPartialAssemblyKey",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioClaimantNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("TpSubAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("NotificationNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeJsonParseProcessor({plainFieldName:"plainData"})])),this.registerProcessor("UserNode",n.series([n.makeJsonParseProcessor({plainFieldName:"config"})])),this.registerProcessor("ReminderNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plain"})]))}return e.prototype.processQuery=function(e,t){return M(this,void 0,void 0,(function(){var n=this;return T(this,(function(r){return t=Object.assign(Object.assign({},Je),t),[2,oe(e,(function(e,r){return n.processField({field:e,context:{path:[r],processChildren:!0},options:t})}))]}))}))},e.prototype.processField=function(e){var t=e.field,n=e.context,r=e.options;return M(this,void 0,void 0,(function(){var e,i,a,s=this;return T(this,(function(o){if(null==t?void 0:t.then)throw new W("processField() should not receive thenable.");return null==t?[2,null]:(e={field:t,context:Object.assign(Object.assign({},n),{processChildren:!0}),options:r},t[this.TYPENAME]?((i=this.processors[t[this.TYPENAME]])&&(t=i(e)),a=function(e){return n.processChildren&&null!==e&&"object"==typeof e?oe(e,(function(e,t){return s.processField({field:e,context:We(n,t),options:r})})):e},t=t.then?t.then((function(e){return a(e)})):a(t)):n.processChildren&&Array.isArray(t)&&(t=ae(t.map((function(e,t){return s.processField({field:e,context:We(n,t.toString()),options:r})})))),[2,t])}))}))},e.prototype.registerProcessor=function(e,t){if(this.processors[e])throw new W("Processor for field "+e+" already exists.");this.processors[e]=t},e}(),e.QueryProcessorService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.QueryProcessorService(t.ɵɵinject(t.NgZone),t.ɵɵinject(Ke),t.ɵɵinject(e.CommonProcessorsService),t.ɵɵinject(Qe))},token:e.QueryProcessorService,providedIn:"root"}),e.QueryProcessorService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.QueryProcessorService.ctorParameters=function(){return[{type:t.NgZone},{type:Ke},{type:e.CommonProcessorsService},{type:Qe}]},e.QueryProcessorService=A([qe({ngZoneName:"ngZone"})],e.QueryProcessorService);var Ve,Be,Ze,He=function(){function e(){var e=this;this._fulfilled=!1,this.promise=new Promise((function(t,n){e._resolve=t,e._reject=n})).finally((function(){e._fulfilled=!0}))}return Object.defineProperty(e.prototype,"resolve",{get:function(){return this._resolve},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reject",{get:function(){return this._reject},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fulfilled",{get:function(){return this._fulfilled},enumerable:!1,configurable:!0}),e}(),Ye=Ee(K.default(Ve||(Ve=_(["\n query {\n ...FragmentName\n }\n"],["\n query {\n ...FragmentName\n }\n"])))).selectionSet.selections[0],Xe=function(){function e(){this._executed=!1,this.deferredPromise=new He}return Object.defineProperty(e.prototype,"promise",{get:function(){return this.deferredPromise.promise},enumerable:!1,configurable:!0}),e.prototype.resolve=function(e){this.deferredPromise.resolve(e)},e.prototype.reject=function(e){this.deferredPromise.reject(e)},Object.defineProperty(e.prototype,"lrMutationData",{get:function(){return{mutation:this.mutation,variables:this.variables}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"executed",{get:function(){return this._executed},enumerable:!1,configurable:!0}),e.prototype.setExecuted=function(){if(this._executed)throw new Z("Already executed");this._executed=!0},e}(),ze=function(e){function t(t){var n=e.call(this)||this;return n.mutation=t.mutation,n.variables=t.variables,n}return E(t,e),t.prototype.select=function(e){var n=i.cloneDeep(this.mutation),r=De(n),a={};Ae(e).forEach((function(e){a[e.name.value.split("_")[0]]=e}));return r.selectionSet.selections.forEach((function(e){"Field"===e.kind&&function(e){var t=e,n=Te(t),r=a[n];r&&(t.selectionSet.selections=[Object.assign(Object.assign({},Ye),{name:Me(r.name.value)})])}(e)})),new t({mutation:Object.assign(Object.assign({},n),{definitions:N(n.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})),e.definitions)}),variables:this.variables})},t}(Xe),et={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"lrMergedMutation"},variableDefinitions:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[]}}]},tt=function(e){function t(t){var n=e.call(this)||this;n.lrMutations=t;var r=n.merge(),i=r.mutation,a=r.variables,s=r.prefixes;return n.mutation=i,n.variables=a,n.prefixes=s,n.descendants=n.getDescendants(),n}return E(t,e),t.create=function(e){return new t(e)},t.prototype.getDescendants=function(){var e=new Set,n=function(t){if(e.has(t))throw new W("Classes that are derived from LrMutationBase can not be used more than once in a merged mutation.");e.add(t)};return this.lrMutations.forEach((function(e){if(e instanceof ze)n(e);else{if(!(e instanceof t))throw new ie("LrMergeMutation can not handle class: "+e.constructor.name);e.descendants.forEach((function(e){return n(e)}))}})),e},t.prototype.resolve=function(t){for(var n=this,r=0;r<this.lrMutations.length;++r){var i=this.prefixes[r],a={};for(var s in t){if(s.startsWith(i))a[s.slice(i.length)]=t[s]}this.lrMutations[r].resolve(a)}Promise.all(this.lrMutations.map((function(e){return e.promise}))).then((function(t){e.prototype.resolve.call(n,t)}))},t.prototype.reject=function(t){e.prototype.reject.call(this,t),this.lrMutations.forEach((function(e){return e.reject(t)}))},t.prototype.setExecuted=function(){e.prototype.setExecuted.call(this),this.lrMutations.forEach((function(e){return e.setExecuted()}))},t.prototype.renameVariableDefinition=function(e,t){return Object.assign(Object.assign({},e),{variable:Object.assign(Object.assign({},e.variable),{name:Me(t+e.variable.name.value)})})},t.prototype.renameVariableDefinitions=function(e,t){var n=this;return e.map((function(e){return n.renameVariableDefinition(e,t)}))},t.prototype.renameArgument=function(e,t){return"Variable"!==e.value.kind?e:Object.assign(Object.assign({},e),{value:Object.assign(Object.assign({},e.value),{name:Me(t+e.value.name.value)})})},t.prototype.renameField=function(e,t){var n=this;if("Field"!==e.kind)return e;var r=t+Te(e),i=e.arguments.map((function(e){return n.renameArgument(e,t)}));return Object.assign(Object.assign({},e),{alias:{kind:"Name",value:r},arguments:i})},t.prototype.renameFragmentSpread=function(e,t){return Object.assign(Object.assign({},e),{name:Me(t+e.name.value)})},t.prototype.processSelection=function(e,t){switch(e.kind){case"FragmentSpread":return this.renameFragmentSpread(e,t);case"Field":return e.selectionSet?Object.assign(Object.assign({},e),{selectionSet:this.processSelectionSet(e.selectionSet,t)}):e;default:return e}},t.prototype.processSelectionSet=function(e,t){var n=this;return Object.assign(Object.assign({},e),{selections:e.selections.map((function(e){return n.processSelection(e,t)}))})},t.prototype.renameSelections=function(e,t){var n=this;return e.map((function(e){switch(e.kind){case"Field":return n.processSelection(n.renameField(e,t),t);default:return e}}))},t.prototype.renameFragmentDefinition=function(e,t){var n=Object.assign(Object.assign({},e),{name:Me(t+e.name.value)});return e.selectionSet&&(n.selectionSet=this.processSelectionSet(e.selectionSet,t)),n},t.prototype.renameFragmentDefinitions=function(e,t){var n=this;return e.map((function(e){return n.renameFragmentDefinition(e,t)}))},t.prototype.merge=function(){var e=this,t=[],n=[],r={},a=[],s=[];this.lrMutations.forEach((function(i,o){var c,u;if(!(i instanceof Xe))throw new W("An mutation in the array is not of type LrMutationBase.");var p=i.lrMutationData,d=p.mutation,l=p.variables,h=De(d),y="item"+o+"_";h.name&&(y+=h.name.value+"_"),s.push(y),t=N(t,e.renameVariableDefinitions(h.variableDefinitions,y)),n=N(n,e.renameSelections(h.selectionSet.selections,y));try{for(var f=O(Object.keys(l)),v=f.next();!v.done;v=f.next()){var m=v.value;r[y+m]=l[m]}}catch(e){c={error:e}}finally{try{v&&!v.done&&(u=f.return)&&u.call(f)}finally{if(c)throw c.error}}var g=Ae(d);a=N(a,e.renameFragmentDefinitions(g,y))}));var o=i.cloneDeep(et),c=De(o);return c.selectionSet.selections=n,c.variableDefinitions=t,o.definitions=N(o.definitions,a),{mutation:o,variables:r,prefixes:s}},t}(Xe),nt=Ee(K.default(Be||(Be=_(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),$e)).selectionSet.selections[0],rt=Ee(K.default(Ze||(Ze=_(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Le)).selectionSet.selections[0];e.ɵg=function(){function e(e,t,n,r){this.ngZone=e,this.apollo=t,this.keyGraph=n,this.queryProcessor=r,this.stats={queryCount:0,mutationCount:0}}return e.prototype.query=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return e=i.cloneDeep(e),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=Ee(e.query)).selectionSet.selections=N(t.selectionSet.selections,[nt])),e.name&&((t=Ee(e.query)).name={kind:"Name",value:e.name}),[4,this.apollo.query(e).toPromise()];case 1:return n=r.sent(),this.stats.queryCount++,U(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.lrMutateImpl=function(e,t){return M(this,void 0,void 0,(function(){return T(this,(function(n){if(null==t?void 0:t.variables)throw new ie('Unsupported field: "options.variables"');if(e.executed)throw new Z("LrMutation has already executed. LrMutation can only be used once in a lrMutate() call. Create new instances of LrMutation.");return e.setExecuted(),[2,this.apolloMutate(Object.assign(Object.assign({},t),e.lrMutationData)).then((function(t){return e.resolve(t),t})).catch((function(t){throw e.reject(t),t}))]}))}))},e.prototype.apolloMutate=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return e=Object.assign(Object.assign({},e),{mutation:i.cloneDeep(e.mutation)}),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=De(e.mutation)).selectionSet.selections=N(t.selectionSet.selections,[rt])),e.name&&((t=De(e.mutation)).name={kind:"Name",value:e.name}),e.mutation=K.default(h.print(e.mutation)),[4,this.apollo.mutate(e).toPromise()];case 1:return n=r.sent(),this.stats.mutationCount++,U(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.statsSnapshot=function(){return i.cloneDeep(this.stats)},e.prototype.addKeys=function(e){e.data.keyGraph&&(this.keyGraph.addKeys(e.data.keyGraph),delete e.data.keyGraph)},e.prototype.isIncludeKeyGraph=function(e){return null==e},e.prototype.lrMutate=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a;return T(this,(function(s){switch(s.label){case 0:return e instanceof Array?(i=(r=tt).create,[4,Promise.all(e)]):[3,3];case 1:return n=i.apply(r,[s.sent()]),[4,this.lrMutateImpl(n,t)];case 2:return s.sent(),[2,n.promise];case 3:return[4,e];case 4:return a=s.sent(),[4,this.lrMutateImpl(a,t)];case 5:return s.sent(),[2,a.promise]}}))}))},e}(),e.ɵg.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵg(t.ɵɵinject(t.NgZone),t.ɵɵinject(n.Apollo),t.ɵɵinject(Pe),t.ɵɵinject(e.QueryProcessorService))},token:e.ɵg,providedIn:"root"}),e.ɵg.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵg.ctorParameters=function(){return[{type:t.NgZone},{type:n.Apollo},{type:Pe},{type:e.QueryProcessorService}]},e.ɵg=A([qe({ngZoneName:"ngZone"})],e.ɵg);var it,at,st,ot,ct,ut,pt,dt,lt,ht,yt,ft,vt,mt,gt,St,Ct,bt,It,wt,Kt=function(){function t(t){this.lrGraphQL=t.get(e.ɵg)}return t.prototype.mutate=function(e,t){return M(this,void 0,void 0,(function(){return T(this,(function(n){return[2,this.lrGraphQL.lrMutate(e,t)]}))}))},t.prototype.query=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.lrGraphQL.query(e)]}))}))},t}();function Pt(e){return e.edges.map((function(e){return e.node}))}(e.UserDeleteState||(e.UserDeleteState={})).REQUESTED="REQUESTED",(it=e.PlanState||(e.PlanState={})).ENABLED="ENABLED",it.DISABLED="DISABLED",(at=e.ShareTypeChoice||(e.ShareTypeChoice={})).TP="TP",at.DETACHED="DETACHED",(st=e.DetachedShareStateChoice||(e.DetachedShareStateChoice={})).IN_PROGRESS="IN_PROGRESS",st.COMPLETED="COMPLETED",(ot=e.AccessRoleChoice||(e.AccessRoleChoice={})).READER="READER",ot.WRITER="WRITER",ot.ADMIN="ADMIN",ot.CUSTODIAN="CUSTODIAN",ot.DENY="DENY",ot.OWNER="OWNER",(ct=e.AccessRoleChoiceOrder||(e.AccessRoleChoiceOrder={}))[ct.READER=0]="READER",ct[ct.WRITER=1]="WRITER",ct[ct.ADMIN=2]="ADMIN",ct[ct.CUSTODIAN=3]="CUSTODIAN",ct[ct.DENY=4]="DENY",ct[ct.CONFIDENTIAL=5]="CONFIDENTIAL",ct[ct.OWNER=6]="OWNER",(ut=e.AccessRoleMethodChoice||(e.AccessRoleMethodChoice={})).INHERITED="INHERITED",ut.DIRECT="DIRECT",(pt=e.PermissionChoice||(e.PermissionChoice={})).CREATE="CREATE",pt.READ="READ",pt.UPDATE="UPDATE",pt.DELETE="DELETE",pt.SHARE="SHARE",pt.ARCHIVE="ARCHIVE",pt.ACCESS_ARCHIVED="ACCESS_ARCHIVED",pt.UNARCHIVE="UNARCHIVE",pt.SET_CONFIDENTIAL="SET_CONFIDENTIAL",(dt=e.FileOperationField||(e.FileOperationField={})).CREATE="CREATE",dt.READ="READ",dt.UPDATE="UPDATE",dt.REVERT="REVERT",dt.DELETE="DELETE",(lt=e.KeyExchangeOtkState||(e.KeyExchangeOtkState={})).OTK_INITIATED="OTK_INITIATED",lt.OTK_ACCEPTED="OTK_ACCEPTED",lt.OTK_COMPLETED="OTK_COMPLETED",(ht=e.KeyExchangeState||(e.KeyExchangeState={})).IN_PROGRESS="IN_PROGRESS",ht.COMPLETED="COMPLETED",ht.DECLINED="DECLINED",ht.CANCELLED="CANCELLED",ht.DELETED="DELETED",(e.KeyExchangeMode||(e.KeyExchangeMode={})).OTK="OTK",(yt=e.TpAssemblyState||(e.TpAssemblyState={})).DISABLED="DISABLED",yt.ENABLED="ENABLED",yt.CLAIMED="CLAIMED",yt.APPROVED="APPROVED",yt.REJECTED="REJECTED",yt.EXPIRED="EXPIRED",yt.CANCELLED="CANCELLED",yt.RESET="RESET",(ft=e.TpClaimState||(e.TpClaimState={})).CLAIMED="CLAIMED",ft.APPROVED="APPROVED",ft.REJECTED="REJECTED",ft.EXPIRED="EXPIRED",ft.CANCELLED="CANCELLED",ft.RESET="RESET",(vt=e.TpClaimApproverState||(e.TpClaimApproverState={})).CLAIMED="CLAIMED",vt.APPROVED="APPROVED",vt.REJECTED="REJECTED",(mt=e.LockState||(e.LockState={})).UNLOCKED="UNLOCKED",mt.MUTEX_LOCKED="MUTEX_LOCKED",(gt=e.ScenarioState||(e.ScenarioState={})).DISABLED="DISABLED",gt.ENABLED="ENABLED",gt.CLAIMED="CLAIMED",gt.APPROVED="APPROVED",(St=e.ClaimState||(e.ClaimState={})).CLAIMED="CLAIMED",St.EXPIRED="EXPIRED",St.APPROVED="APPROVED",St.REJECTED="REJECTED",St.CANCELLED="CANCELLED",St.RESET="RESET",(Ct=e.ClaimApproverState||(e.ClaimApproverState={})).CLAIMED="CLAIMED",Ct.APPROVED="APPROVED",Ct.REJECTED="REJECTED",(bt=e.ScenarioLastClaimState||(e.ScenarioLastClaimState={})).CLAIMED="CLAIMED",bt.APPROVED="APPROVED",bt.REJECTED="REJECTED",bt.EXPIRED="EXPIRED",bt.CANCELLED="CANCELLED",bt.RESET="RESET",(It=e.LinkTypeField||(e.LinkTypeField={})).HARD="HARD",It.SOFT="SOFT",It.REFERENCE="REFERENCE",(wt=e.PlanStateField||(e.PlanStateField={})).TRIALLING="TRIALLING",wt.ACTIVE="ACTIVE",wt.CANCELLED="CANCELLED",wt.EXPIRED="EXPIRED";var kt,Rt=function(e){var t=window.fetch;return function(n,r){var i=function(){return t(n,r)};if(!r||!r.headers||!r.headers["X-Amz-Target"])return i();var a=r.headers["X-Amz-Target"].split(".");if(a.length<2||"AWSCognitoIdentityProviderService"!==a[0])return i();var s=JSON.parse(r.body);if(s&&s.ClientMetadata&&"true"===s.ClientMetadata.noProxy)return i();var o=!1;if("RespondToAuthChallenge"===a[1]){if(s&&"NEW_PASSWORD_REQUIRED"===s.ChallengeName)return i();o=!0}else"InitiateAuth"===a[1]&&"REFRESH_TOKEN_AUTH"===s.AuthFlow&&(o=!0);return o?t(e+"auth/proxy/",Object.assign(Object.assign({},r),{credentials:"include"})):i()}},Et=function(e,t){var n=e.authUrl,r=e.userPoolId,i=e.userPoolWebClientId;return function(){var e=r.split("_");if(e.length<2)throw new Error("userPoolId should have this format: {aws-region}_xxxxx");window.fetch=Rt(n),t.configure({region:e[0],userPoolId:r,userPoolWebClientId:i,mandatorySignIn:!1})}};(kt=e.Config||(e.Config={}))[kt.TIMEOUT=.01]="TIMEOUT",kt[kt.IDLE=1200]="IDLE",kt[kt.KEEP_ALIVE_INTERVAL=60]="KEEP_ALIVE_INTERVAL";var Dt=function(){function t(e,t,n,r,i,a){this.config=e,this.http=t,this.idle=n,this.keepalive=r,this.keyService=i,this.auth=a,this.IDLE_EXPIRY_KEY="ng2Idle.main.expiry",this.IDLING_KEY="ng2Idle.main.idling",this.initCalled=!1}return t.prototype.assertInit=function(){if(!this.initCalled)throw new Z("Call IdleService.init() first.")},t.prototype.init=function(t){return M(this,void 0,void 0,(function(){var n,r=this;return T(this,(function(i){switch(i.label){case 0:if(this.initCalled)throw new Z("IdleService.init() can only be called once. IdleService.start() calls init() with default values if init() has not been called yet.");if(this.initCalled=!0,(t=Object.assign({onTimeout:null,onKeepalive:null,idleSec:e.Config.IDLE,timeoutSec:e.Config.TIMEOUT,keepAliveIntervalSec:e.Config.KEEP_ALIVE_INTERVAL},t)).timeoutSec<.01)throw new Q("Minimum value for IdleService.init({ timeoutSec }) is 0.01");return this.onTimeout=t.onTimeout,this.onKeepalive=t.onKeepalive,this.idle.setIdle(t.idleSec),this.idle.setTimeout(t.timeoutSec),this.idle.setInterrupts(v.DEFAULT_INTERRUPTSOURCES),this.idle.onIdleEnd.subscribe((function(){return console.log("Idle stopped")})),this.idle.onIdleStart.subscribe((function(){return console.log("Idle started")})),this.idle.onTimeout.subscribe((function(){return M(r,void 0,void 0,(function(){return T(this,(function(e){switch(e.label){case 0:return console.log("Idle timed out"),this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout({onInit:!1}))];case 1:return e.sent(),[2]}}))}))})),this.idle.onTimeoutWarning.subscribe((function(e){return console.log("Will timeout in "+e+" seconds!")})),this.keepalive.interval(t.keepAliveIntervalSec),console.log("Keep alive interval set at: "+e.Config.KEEP_ALIVE_INTERVAL+" seconds"),this.keepalive.onPing.subscribe((function(){return r.onPing()})),(n=localStorage.getItem(this.IDLE_EXPIRY_KEY))&&parseInt(n,10)+1e3*this.idle.getTimeout()<Date.now()?(this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout({onInit:!0}))]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.keepalivePost=function(){return M(this,void 0,void 0,(function(){var e,t,n;return T(this,(function(r){switch(r.label){case 0:return t=(e=this.http).post,n=[this.config.authUrl+"auth/keepalive/",null],[4,be(this.auth,this.config)];case 1:return[4,t.apply(e,n.concat([r.sent()])).toPromise()];case 2:return[2,{keepaliveResult:r.sent(),expiresAfterSeconds:this.idle.getIdle()+this.idle.getTimeout()+this.keepalive.interval()}]}}))}))},t.prototype.persistMasterKey=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.keepalivePost()];case 1:return t=n.sent().expiresAfterSeconds,[4,this.keyService.persistMasterKey(e,t)];case 2:return n.sent(),[2]}}))}))},t.prototype.onPing=function(){return M(this,void 0,void 0,(function(){var e;return T(this,(function(t){switch(t.label){case 0:return console.log("Keep alive triggered at time: "+Date.now()+". Interval set at: "+this.keepalive.interval()+" seconds"),[4,this.keepalivePost()];case 1:return e=t.sent().expiresAfterSeconds,[4,this.keyService.setMasterKeyExpiresAfterSeconds(e)];case 2:return t.sent(),[4,Promise.resolve(this.onKeepalive&&this.onKeepalive())];case 3:return t.sent(),[2]}}))}))},t.prototype.start=function(){return M(this,void 0,void 0,(function(){return T(this,(function(e){switch(e.label){case 0:return this.initCalled?[3,2]:[4,this.init()];case 1:e.sent(),e.label=2;case 2:return this.idle.isRunning()?[2]:[4,this.onPing()];case 3:return e.sent(),this.idle.watch(),[2]}}))}))},t.prototype.stop=function(){this.idle.stop(),this.reset()},t.prototype.reset=function(){localStorage.removeItem(this.IDLE_EXPIRY_KEY),localStorage.removeItem(this.IDLING_KEY)},t}();Dt.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Dt(t.ɵɵinject(Se),t.ɵɵinject(y.HttpClient),t.ɵɵinject(v.Idle),t.ɵɵinject(m.Keepalive),t.ɵɵinject(Ke),t.ɵɵinject(s.AuthClass))},token:Dt,providedIn:"root"}),Dt.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Dt.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:y.HttpClient},{type:v.Idle},{type:m.Keepalive},{type:Ke},{type:s.AuthClass}]};var At,Mt,Tt,Ot,jt,Nt,_t,Ft="\nid\npublicData\npublicSearchable\ncipherData\nkey {\n id\n}\n",$t=(K.default(At||(At=_(["\nquery ContactCardQuery(\n$id: LrRelayIdInput!\n) {\ncontactCard (\n id: $id\n) {\n ","\n}\n","\n}"],["\nquery ContactCardQuery(\n$id: LrRelayIdInput!\n) {\ncontactCard (\n id: $id\n) {\n ","\n}\n","\n}"])),Ft,$e),K.default(Mt||(Mt=_(['\nquery SearchContactCardQuery(\n $publicSearchable: LrJSONFilter!\n) {\n searchContactCards(\n publicSearchable: $publicSearchable\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"],['\nquery SearchContactCardQuery(\n $publicSearchable: LrJSONFilter!\n) {\n searchContactCards(\n publicSearchable: $publicSearchable\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"])),Ft,$e),K.default(Tt||(Tt=_(['\nquery ContactCardListQuery {\n contactCards(\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"],['\nquery ContactCardListQuery {\n contactCards(\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"])),Ft,$e)),Lt=(K.default(Ot||(Ot=_(["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"],["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"])),Ft),K.default(jt||(jt=_(["\nmutation UpdateContactCardMutation(\n $input: UpdateContactCardInput!\n) {\n updateContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"],["\nmutation UpdateContactCardMutation(\n $input: UpdateContactCardInput!\n) {\n updateContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"])),Ft),K.default(Nt||(Nt=_(["\n mutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n }\n"])))),Ut=Oe(_t||(_t=_(["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"],["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"]))),xt=function(){function e(e,t,n,r,i){this.encryptionService=e,this.keyGraph=t,this.lrApollo=n,this.keyService=r,this.keyFactory=i}return e.prototype.decryptMeta=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return e.cipherMeta?[4,this.keyGraph.getJwkKey(e.keyId)]:[3,3];case 1:return t=n.sent(),[4,this.encryptionService.decrypt(t,JSON.parse(e.cipherMeta))];case 2:return[2,n.sent()];case 3:return[2,null]}}))}))},e.prototype.doubleWrapContent=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d;return T(this,(function(l){switch(l.label){case 0:return[4,this.keyFactory.createKey()];case 1:return r=l.sent(),[4,this.wrapContent(r.toJSON(!0),t)];case 2:return i=l.sent(),a={rootKey:i.rootKey,wrappedKeys:i.wrappedKeys,doubleWrappedKey:i.cipherMeta},e?(c=(o=JSON).stringify,[4,this.encryptionService.encrypt(r,e)]):[3,4];case 3:return s=c.apply(o,[l.sent()]),[3,5];case 4:s=null,l.label=5;case 5:return a.cipherMeta=s,n?(d=(p=JSON).stringify,[4,this.encryptionService.encrypt(r,n)]):[3,7];case 6:return u=d.apply(p,[l.sent()]),[3,8];case 7:u=null,l.label=8;case 8:return[2,(a.cipherFileContent=u,a)]}}))}))},e.prototype.reWrapContent=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return T(this,(function(p){switch(p.label){case 0:return[4,this.keyGraph.getJwkKey(e)];case 1:return n=p.sent(),[4,this.keyFactory.createKey()];case 2:return r=p.sent(),i={},s=(a=JSON).stringify,[4,this.encryptionService.encrypt(n,r.toJSON(!0))];case 3:return i.doubleWrappedKey=s.apply(a,[p.sent()]),t?(u=(c=JSON).stringify,[4,this.encryptionService.encrypt(r,t)]):[3,5];case 4:return o=u.apply(c,[p.sent()]),[3,6];case 5:o=null,p.label=6;case 6:return[2,(i.cipherMeta=o,i)]}}))}))},e.prototype.wrapContent=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h=this;return T(this,(function(y){switch(y.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=y.sent(),t&&t.length?[4,Promise.all(t.map((function(e){return M(h,void 0,void 0,(function(){var t,r,i,a;return T(this,(function(s){switch(s.label){case 0:return[4,this.getDirectoryKeyId(e)];case 1:return t=s.sent(),a=(i=JSON).stringify,[4,this.encryptionService.encrypt(t.key,n.toJSON(!0))];case 2:return r=a.apply(i,[s.sent()]),[2,{directoryId:e,wrappingKeyId:t.keyId,wrappedKey:r}]}}))}))})))]:[3,3];case 2:return r=y.sent(),[3,5];case 3:return a=this.keyService.currentRootKey,c=(o=JSON).stringify,[4,this.encryptionService.encrypt(a.jwk,n.toJSON(!0))];case 4:s=c.apply(o,[y.sent()]),i={wrappingKeyId:a.id,wrappedKey:s},y.label=5;case 5:return u={key:n,rootKey:i,wrappedKeys:r},e?(l=(d=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,7];case 6:return p=l.apply(d,[y.sent()]),[3,8];case 7:p=null,y.label=8;case 8:return[2,(u.cipherMeta=p,u)]}}))}))},e.prototype.wrapContentWithKey=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o;return T(this,(function(c){switch(c.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=c.sent(),[4,this.keyGraph.encryptToString(t,n.toJSON(!0))];case 2:return r=c.sent(),i={key:n,rootKey:{wrappingKeyId:t,wrappedKey:r}},e?(o=(s=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,4];case 3:return a=o.apply(s,[c.sent()]),[3,5];case 4:a=null,c.label=5;case 5:return[2,(i.cipherMeta=a,i)]}}))}))},e.prototype.getDirectoryKeyId=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Ut,variables:{id:e}})];case 1:return t=r.sent().directory,n={keyId:t.keyId},[4,this.keyGraph.getJwkKey(t.keyId)];case 2:return[2,(n.key=r.sent(),n)]}}))}))},e}();xt.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new xt(t.ɵɵinject(ve),t.ɵɵinject(Pe),t.ɵɵinject(ke),t.ɵɵinject(Ke),t.ɵɵinject(ge))},token:xt,providedIn:"root"}),xt.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],xt.ctorParameters=function(){return[{type:ve},{type:Pe},{type:ke},{type:Ke},{type:ge}]};var qt,Jt,Gt,Qt,Wt,Vt,Bt,Zt,Ht,Yt="\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n config\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n",Xt="\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n pbk\n }\n mkReshareRequestCipher\n mkReshareResponseCipher\n mkReshareRequestSent\n mkReshareResponseSent\n",zt=Oe(qt||(qt=_(["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ","\n }\n }\n }\n}\n"],["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ","\n }\n }\n }\n}\n"])),Yt),en=Oe(Jt||(Jt=_(["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ","\n }\n}\n"],["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ","\n }\n}\n"])),Yt),tn=Oe(Gt||(Gt=_(["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ","\n }\n}\n"],["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ","\n }\n}\n"])),Yt),nn=Oe(Qt||(Qt=_(["\nmutation CancelKeyExchangeMutation($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"],["\nmutation CancelKeyExchangeMutation($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"]))),rn=Oe(Wt||(Wt=_(["\nmutation DeclineKeyExchangeMutation($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"],["\nmutation DeclineKeyExchangeMutation($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"]))),an=Oe(Vt||(Vt=_(["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n }\n}\n"],["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n }\n}\n"])),Yt),sn=Oe(Bt||(Bt=_(["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"],["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"])),Yt,Xt),on=Oe(Zt||(Zt=_(["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"],["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"])),Yt,Xt),cn=Oe(Ht||(Ht=_(["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n}\n"],["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n}\n"])),Xt);(e.FeatureAction||(e.FeatureAction={})).ACCESS="access";var un,pn=function(){},dn=function(){},ln=function(){},hn=function(){},yn=function(e){this.name=e.name,this.title=e.title,this.firstName=e.firstName,this.lastName=e.lastName},fn=function(){},vn=function(){},mn=function(){},gn=function(){},Sn=function(){},Cn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return E(t,e),t}(Sn),bn=function(){},In=function(){};(un=e.TrustedPartyType||(e.TrustedPartyType={})).User="user",un.Organisation="organisation";var wn,Kn=function(){},Pn="\n id\n owner {\n id\n username\n }\n ownerKey {\n id\n }\n ownerCipherData\n receiver {\n id\n username\n }\n receiverKey {\n id\n }\n receiverCipherData\n sharedKey {\n id\n }\n sharedCipherData\n sharedCipherDataSig\n sharedCipherDataSigPxk {\n id\n }\n",kn=K.default(wn||(wn=_(["\nmutation UpdateOwnedContactCard(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(\n input: $input\n ) {\n ownedContactCard {\n ","\n }\n }\n}"],["\nmutation UpdateOwnedContactCard(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(\n input: $input\n ) {\n ownedContactCard {\n ","\n }\n }\n}"])),Pn),Rn=function(){function e(e,t,n,r){this.keyService=e,this.lrApollo=t,this.keyGraph=n,this.encryptionService=r}return e.prototype.decryptSharedTrustedPartyDetails=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.decryptTrustedPartyDetails(e)];case 1:return t=n.sent(),[2,Object.assign({id:e.id,ownedKeyId:e.ownerKey.id,sharedKeyId:e.sharedKey.id},t)]}}))}))},e.prototype.decryptTrustedPartyDetails=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return T(this,(function(i){switch(i.label){case 0:if(!(e&&e.sharedKey&&e.sharedCipherData))return[3,5];i.label=1;case 1:return i.trys.push([1,4,,5]),n=(t=this.encryptionService).decrypt,[4,this.keyGraph.getJwkKey(e.sharedKey.id)];case 2:return[4,n.apply(t,[i.sent(),e.sharedCipherData])];case 3:return[2,i.sent()];case 4:return r=i.sent(),console.error("Cannot decrypt trusted party details",r),[3,5];case 5:return[2,null]}}))}))},e.prototype.updateMySharedContactCard=function(e,t,n,r){return M(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,h,y;return T(this,(function(f){switch(f.label){case 0:return[4,this.keyGraph.getKey(t)];case 1:return i=f.sent(),[4,this.keyGraph.getKey(n)];case 2:return a=f.sent(),s=this.keyService.currentSigPxk,[4,this.encryptionService.encrypt(a.jwk,r)];case 3:return o=f.sent(),p=(u=JSON).stringify,[4,this.encryptionService.sign(s.jwk,o)];case 4:return c=p.apply(u,[f.sent()]),d={name:new yn(r.name)},y=(h=JSON).stringify,[4,this.encryptionService.sign(s.jwk,d)];case 5:return l=y.apply(h,[f.sent()]),[4,this.lrApollo.mutate({mutation:kn,variables:{input:{id:e,ownerCipherData:"",ownerKeyId:i.id,sharedCipherDataSig:c,sharedKeyId:a.id,sigPxkId:s.id,ownerPlainDataSig:l}}})];case 6:return f.sent(),[2]}}))}))},e}();Rn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Rn(t.ɵɵinject(Ke),t.ɵɵinject(ke),t.ɵɵinject(Pe),t.ɵɵinject(ve))},token:Rn,providedIn:"root"}),Rn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Rn.ctorParameters=function(){return[{type:Ke},{type:ke},{type:Pe},{type:ve}]};var En,Dn,An,Mn,Tn,On="\n id\n user {\n id\n username\n }\n other{\n id\n username,\n features {\n shareVault\n }\n }\n sharedContactCard {\n "+Pn+"\n }\n myContactCard {\n "+Pn+"\n }\n sharedScenarios {\n edges {\n node {\n id\n }\n }\n }\n theirItems {\n directories {\n edges {\n node {\n id\n }\n }\n }\n }\n currentUserSharedKey {\n userSharedKey {\n keyExchange {\n "+Yt+"\n }\n "+Xt+"\n }\n }",jn=K.default(En||(En=_(['\n query {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n userDelete {\n id\n created\n state\n }\n features {\n myVault\n tpVault\n shareVault\n }\n sessionEncryptionKey\n dateJoined\n }\n userPlans {\n id\n stripe {\n subscriptionId\n }\n plan {\n name\n data\n state\n }\n periodEnd\n }\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n key {\n id\n }\n cipherData\n plainData\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ',"\n"],['\n query {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n userDelete {\n id\n created\n state\n }\n features {\n myVault\n tpVault\n shareVault\n }\n sessionEncryptionKey\n dateJoined\n }\n userPlans {\n id\n stripe {\n subscriptionId\n }\n plan {\n name\n data\n state\n }\n periodEnd\n }\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n key {\n id\n }\n cipherData\n plainData\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ',"\n"])),Fe),Nn=K.default(Dn||(Dn=_(["\n mutation CreateContactCardMutation($input: CreateContactCardInput!) {\n createContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"],["\n mutation CreateContactCardMutation($input: CreateContactCardInput!) {\n createContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"]))),_n=K.default(An||(An=_(["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"],["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"]))),Fn=Oe(Mn||(Mn=_(["\nquery TrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n}"],["\nquery TrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n}"])),On),$n=Oe(Tn||(Tn=_(['\nquery ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n cipherData\n key {\n id\n }\n }\n }\n }\n}\n'],['\nquery ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n cipherData\n key {\n id\n }\n }\n }\n }\n}\n']))),Ln=function(){function e(e,t,n,r,i,a,s){this.config=e,this.http=t,this.lrApollo=n,this.keyService=r,this.keyMetaService=i,this.keyGraph=a,this.encryptionService=s}return e.prototype.getCurrentUser=function(){return M(this,void 0,void 0,(function(){var e,t,n,r;return T(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:jn})];case 1:return e=i.sent(),t=e.currentUser,n=e.contactCards,r=n.edges.map((function(e){return e.node}))[0],[2,{currentUser:t,contactCard:r}]}}))}))},e.prototype.decryptContactCard=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return e?[4,this.keyGraph.decryptFromString(e.key.id,e.cipherData)]:[2,null];case 1:return t=n.sent(),[2,Object.assign({id:e.id,keyId:e.key.id},t)]}}))}))},e.prototype.updateDetails=function(e,t,n){return M(this,void 0,void 0,(function(){var r;return T(this,(function(i){switch(i.label){case 0:return[4,e?this.updateContactCard(e,t,n):this.createContactCard(n)];case 1:return r=i.sent(),[2,{fields:n,id:r.id,keyId:r.key.id}]}}))}))},e.prototype.prepareContactCardInput=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return T(this,(function(l){switch(l.label){case 0:return t=this.keyService.currentSigPxk,i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 1:return n=i.apply(r,[l.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 2:return a=o.apply(s,[l.sent()]),c={name:new yn(e.name.value)},d=(p=JSON).stringify,[4,this.encryptionService.sign(t.jwk,c)];case 3:return u=d.apply(p,[l.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:u}]}}))}))},e.prototype.createContactCard=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i;return T(this,(function(a){switch(a.label){case 0:return[4,this.prepareContactCardInput(e)];case 1:return t=a.sent(),[4,this.keyMetaService.wrapContent(e)];case 2:return n=a.sent(),r=n.rootKey,i=n.cipherMeta,[4,this.lrApollo.mutate({mutation:Nn,variables:{input:Object.assign(Object.assign({},t),{cipherData:i,wrappingKeyId:r.wrappingKeyId,wrappedKey:r.wrappedKey,default:!0})}})];case 3:return[2,a.sent().createContactCard.contactCard]}}))}))},e.prototype.updateContactCard=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i;return T(this,(function(a){switch(a.label){case 0:return[4,this.prepareContactCardInput(n)];case 1:return r=a.sent(),[4,this.keyGraph.encryptToString(t,n)];case 2:return i=a.sent(),[4,this.lrApollo.mutate({mutation:_n,variables:{input:Object.assign(Object.assign({},r),{id:e,cipherData:i})}})];case 3:return[2,a.sent().updateContactCard.contactCard]}}))}))},e.prototype.decryptContactCardEdges=function(e){return M(this,void 0,void 0,(function(){var t=this;return T(this,(function(n){return[2,Promise.all(e.map((function(e){return M(t,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return t=e.node,[4,this.decryptContactCard(t)];case 1:return[2,n.sent()]}}))}))})))]}))}))},e.prototype.getContactCards=function(){return M(this,void 0,void 0,(function(){var e;return T(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:$t})];case 1:return e=t.sent(),[4,this.decryptContactCardEdges(e.contactCards.edges)];case 2:return[2,t.sent()]}}))}))},e.prototype.deleteContactCard=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Lt,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteContactCard.id]}}))}))},e.prototype.signOut=function(){return M(this,void 0,void 0,(function(){return T(this,(function(e){switch(e.label){case 0:return[4,this.http.post(this.config.authUrl+"auth/sign-out/",null,{withCredentials:!0,responseType:"text"}).toPromise()];case 1:return e.sent(),[2]}}))}))},e}();Ln.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ln(t.ɵɵinject(Se),t.ɵɵinject(y.HttpClient),t.ɵɵinject(ke),t.ɵɵinject(Ke),t.ɵɵinject(xt),t.ɵɵinject(Pe),t.ɵɵinject(ve))},token:Ln,providedIn:"root"}),Ln.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ln.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:y.HttpClient},{type:ke},{type:Ke},{type:xt},{type:Pe},{type:ve}]};var Un,xn,qn,Jn=K.default(Un||(Un=_(["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"],["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"]))),Gn=K.default(xn||(xn=_(["\n mutation PasswordChange($input: PasswordChangeInput!) {\n passwordChange(input: $input) {\n token\n newPassKey {\n id\n }\n }\n }\n"],["\n mutation PasswordChange($input: PasswordChangeInput!) {\n passwordChange(input: $input) {\n token\n newPassKey {\n id\n }\n }\n }\n"]))),Qn=K.default(qn||(qn=_(["\n query PasswordChangeConfigQuery {\n passwordChangeConfig {\n maxAuthAgeSeconds\n authTime\n serverTime\n }\n }\n"],["\n query PasswordChangeConfigQuery {\n passwordChangeConfig {\n maxAuthAgeSeconds\n authTime\n serverTime\n }\n }\n"]))),Wn=P,Vn=function(){},Bn=function(){function e(e,t,n,r,i,a,s,o,c){this.config=e,this.http=t,this.apollo=n,this.auth=r,this.profileService=i,this.keyFactory=a,this.encryptionService=s,this.keyGraph=o,this.webCryptoService=c,this.CLIENT_NONCE_LENGTH=32}return e.prototype.checkPassword=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return t=this.passwordStrength(e).years,n={length:e.length,timeToCrack:Wn.duration({years:t})},[4,this.getExposureCount(e)];case 1:return[2,(n.passwordExposed=r.sent(),n)]}}))}))},e.prototype.getExposureCount=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i;return T(this,(function(a){switch(a.label){case 0:return[4,this.webCryptoService.stringDigest("SHA-1",e)];case 1:return t=a.sent(),n=t.substring(0,5),[4,this.http.get("https://api.pwnedpasswords.com/range/"+n,{responseType:"text"}).toPromise()];case 2:return r=a.sent(),(i=new RegExp("^(?:"+t.substring(5)+":)(?<count>\\d+)$","im").exec(r))?[2,+i.groups.count]:[2,0]}}))}))},e.prototype.getPassIdpString=function(e){return e.toJSON(!0).k},e.prototype.createPassKeyBundle=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s;return T(this,(function(o){switch(o.label){case 0:return[4,this.keyFactory.createPassIdpParams()];case 1:return t=o.sent(),[4,this.keyFactory.derivePassIdp(Object.assign({password:e},t))];case 2:return n=o.sent().jwk,[4,this.keyFactory.createPassKeyParams()];case 3:return r=o.sent(),[4,this.keyFactory.derivePassKey(Object.assign({password:e},r))];case 4:return i=o.sent().jwk,[4,this.keyFactory.createPkcSignKey()];case 5:return a=o.sent(),[4,this.encryptionService.encrypt(i,a.toJSON(!0))];case 6:return s=o.sent(),[2,{passKeyParams:r,passKey:i,passIdpParams:t,passIdp:n,passIdpVerifier:a,wrappedPassIdpVerifierPrk:s}]}}))}))},e.prototype.isLoginRequired=function(){return M(this,void 0,void 0,(function(){var e,t,n,r;return T(this,(function(i){switch(i.label){case 0:return[4,this.getChangePasswordConfig()];case 1:return e=i.sent(),t=Wn(e.authTime),n=Wn(e.serverTime),r=Wn.duration(n.diff(t)),r.asSeconds()>e.maxAuthAgeSeconds?[2,!0]:[2,!1]}}))}))},e.prototype.changePassword=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p;return T(this,(function(d){switch(d.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return n=d.sent(),[4,this.profileService.getCurrentUser()];case 2:return r=d.sent().currentUser,[4,this.verifyPassword(e,r)];case 3:return i=d.sent(),a=i.passIdp,s=i.signedChallenge,[4,this.createPassKeyBundle(t)];case 4:return o=d.sent(),[4,this.keyGraph.getKey(r.currentUserKey.masterKey.id)];case 5:return c=d.sent(),[4,this.encryptionService.encrypt(o.passKey,c.jwk.toJSON(!0))];case 6:return u=d.sent(),[4,this.changePasswordMutation(s,r.currentUserKey.masterKey.id,u,o)];case 7:return p=d.sent().token,[4,this.auth.changePassword(n,this.getPassIdpString(a),this.getPassIdpString(o.passIdp))];case 8:return d.sent(),[4,this.changePasswordComplete({useNewPassword:!0,token:p})];case 9:return d.sent(),[2]}}))}))},e.prototype.changePasswordComplete=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a;return T(this,(function(s){switch(s.label){case 0:return t=e.useNewPassword,n=e.token,i=(r=this.http).post,a=[this.config.authUrl+"users/password-change-complete/",Object.assign({use_new_password:t},n&&{token:n})],[4,be(this.auth,this.config)];case 1:return[2,i.apply(r,a.concat([s.sent()])).toPromise()]}}))}))},e.prototype.getVerifierPrK=function(e,t){return M(this,void 0,void 0,(function(){var n;return T(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.encryptionService.decrypt(e,t)];case 1:return n=r.sent(),[2,ge.asKey(n)];case 2:throw r.sent(),new G("Wrong current password");case 3:return[2]}}))}))},e.prototype.verifyPassword=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s;return T(this,(function(o){switch(o.label){case 0:return[4,this.apollo.mutate({mutation:Jn,variables:{}})];case 1:return n=o.sent(),[4,this.keyFactory.derivePassKey(Object.assign({password:e},t.currentUserKey.passKey.passKeyParams))];case 2:return r=o.sent(),[4,this.getVerifierPrK(r.jwk,t.currentUserKey.passKey.wrappedPassIdpVerifierPrk)];case 3:return i=o.sent(),a=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.encryptionService.sign(i,{serverNonce:n.passwordChangeRequest.challenge.serverNonce,clientNonce:a})];case 4:return s=o.sent(),[4,this.keyFactory.derivePassIdp(Object.assign({password:e},t.currentUserKey.passKey.passIdpParams))];case 5:return[2,{passIdp:o.sent().jwk,signedChallenge:s}]}}))}))},e.prototype.changePasswordMutation=function(e,t,n,r){return M(this,void 0,void 0,(function(){var i;return T(this,(function(a){switch(a.label){case 0:return[4,this.apollo.mutate({mutation:Gn,variables:{input:{signedChallenge:JSON.stringify(e),masterKeyId:t,newWrappedMasterKey:JSON.stringify(n),newPassKey:{passIdpParams:JSON.stringify(r.passIdpParams),passIdpVerifierPbk:JSON.stringify(r.passIdpVerifier.toJSON()),wrappedPassIdpVerifierPrk:JSON.stringify(r.wrappedPassIdpVerifierPrk),passKeyParams:JSON.stringify(r.passKeyParams)}}}})];case 1:return[2,{token:(i=a.sent()).passwordChange.token,newPassKeyId:i.passwordChange.newPassKey.id}]}}))}))},e.prototype.getChangePasswordConfig=function(){return M(this,void 0,void 0,(function(){var e,t;return T(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query({query:Qn})];case 1:return e=n.sent(),(t=e.passwordChangeConfig).authTime=new Date(t.authTime),t.serverTime=new Date(t.serverTime),[2,t]}}))}))},e.prototype.passwordStrength=function(e){function t(e,t){return((e||"").match(t)||[]).length}var n=t(e,/[A-Z]/g),r=t(e,/[a-z]/g),i=t(e,/[0-9]/g),a=0;if(n&&(a+=26),r&&(a+=26),i&&(a+=10),e.length-n-r-i&&(a+=30),0===e.length)return{years:0,bits:0};var s=Math.pow(a,e.length);return{years:54e3*s/Math.pow(62,12),bits:Math.round(Math.log2(s))}},e}();Bn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Bn(t.ɵɵinject(Se),t.ɵɵinject(y.HttpClient),t.ɵɵinject(ke),t.ɵɵinject(s.AuthClass),t.ɵɵinject(Ln),t.ɵɵinject(ge),t.ɵɵinject(ve),t.ɵɵinject(Pe),t.ɵɵinject(me))},token:Bn,providedIn:"root"}),Bn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Bn.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:y.HttpClient},{type:ke},{type:s.AuthClass},{type:Ln},{type:ge},{type:ve},{type:Pe},{type:me}]};var Zn="lifeready",Hn=function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=""),this.assembly=e,this.subAssembly=t,this.mnemonics=n},Yn=function(){function e(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0),this.index=e,this.threshold=t,this.size=n,this.clearShares()}return e.prototype.clearShares=function(){this.shares=[]},e.prototype.addShare=function(e){this.shares.push(e)},e}(),Xn=function(){function e(e){void 0===e&&(e=0),this.threshold=e,this.clearSubAssemblies()}return e.prototype.size=function(){return this.subAssemblies.length},e.prototype.clearSubAssemblies=function(){this.subAssemblies=[]},e.prototype.addSubAssembly=function(e){this.subAssemblies.push(e)},e}(),zn=(function(){function e(e){this.subAssemblyIndex=e,this.clearShares()}e.prototype.clearShares=function(){this.shares=[]},e.prototype.addShare=function(e){this.shares.push(e)}}(),function(){function e(){this.clearSubQuora()}e.prototype.clearSubQuora=function(){this.subQuora=[]},e.prototype.addSubQuorum=function(e){this.subQuora.push(e)},e.prototype.serialiseShares=function(){var e=[];return this.subQuora.forEach((function(t){e=e.concat(t.shares)})),e}}(),function(){function e(){}return e.prototype.generateShares=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p;return T(this,(function(d){switch(d.label){case 0:r=btoa(e),r=g.Slip39Helper.slip39EncodeHex(r),i=[];try{for(a=O(n.subAssemblies),s=a.next();!s.done;s=a.next())o=s.value,i.push([o.threshold,o.size])}catch(e){u={error:e}}finally{try{s&&!s.done&&(p=a.return)&&p.call(a)}finally{if(u)throw u.error}}return[4,g.Slip39.fromArray(r,{passphrase:t,threshold:n.threshold,groups:i,title:""})];case 1:return c=d.sent(),n.subAssemblies.forEach((function(e,t){e.clearShares();for(var n=0;n<e.size;n++){var r="r/"+t.toString().padStart(2,"0")+"/"+n.toString().padStart(2,"0"),i=c.fromPath(r).mnemonics[0],a=new Hn(t,n,i);e.addShare(a)}})),[2]}}))}))},e.prototype.minimalSet=function(e){var t,n,r,i,a=null,s=new Map;try{for(var o=O(e),c=o.next();!c.done;c=o.next()){var u=c.value,p=g.Slip39Helper.decodeMnemonic(u);if(a&&a!==p.groupThreshold)throw new Error("groupThreshold is different in mnemonics");a=p.groupThreshold,null==(f=s.get(p.groupIndex))&&(f={memberThreshold:p.memberThreshold,members:[]},s.set(p.groupIndex,f)),f.members.push({mnemonic:u,decoded:p})}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}var d=[],l=0;try{for(var h=O(s.values()),y=h.next();!y.done;y=h.next()){var f;if(!((f=y.value).members.length<f.memberThreshold)&&(f.members.slice(0,f.memberThreshold).forEach((function(e){d.push(e.mnemonic)})),++l>=a))break}}catch(e){r={error:e}}finally{try{y&&!y.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}return d},e.prototype.recoverSecret=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return T(this,(function(i){switch(i.label){case 0:return e=this.minimalSet(e),[4,g.Slip39.recoverSecret(e,t)];case 1:return n=i.sent(),r=g.Slip39Helper.slip39DecodeHex(n),[2,atob(r)]}}))}))},e}());zn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new zn},token:zn,providedIn:"root"}),zn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}];var er,tr=Oe(er||(er=_(["\nquery TpsKeysQuery($ids: [ID]) {\n tps(id_In: $ids) {\n edges {\n node {\n id\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n }\n }\n }\n }\n }\n}"],["\nquery TpsKeysQuery($ids: [ID]) {\n tps(id_In: $ids) {\n edges {\n node {\n id\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n }\n }\n }\n }\n }\n}"]))),nr=function(){function t(t){this.keyFactory=t.get(ge),this.keyService=t.get(Ke),this.encryptionService=t.get(ve),this.keyGraph=t.get(Pe),this.slip39Service=t.get(zn),this.lrGraphQl=t.get(e.ɵg)}return t.prototype.recoverAssemblyKey=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return T(this,(function(i){switch(i.label){case 0:return n=e.map((function(e){if(t){if(JSON.stringify(t)!==JSON.stringify(e.assemblyKeyParams))throw new Z("The assembly key parameters are different between the approvals.")}else t=e.assemblyKeyParams;return e.slip39.share.mnemonics})),[4,this.slip39Service.recoverSecret(n,this.slip39Passphrase)];case 1:return r=i.sent(),[4,ge.asKey(Object.assign(Object.assign({},t),{k:r}))];case 2:return[2,i.sent()]}}))}))},t.prototype.prepareTpWrappingKey=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.keyGraph.getKey(e.wrappingKeyId)]}))}))},t.prototype.prepareAssembly=function(e){var t=e.subjectKey,n=e.rootKey;return M(this,void 0,void 0,(function(){var e,r,i,a,s,o,c,u,p;return T(this,(function(d){switch(d.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=d.sent(),r=e.toJSON(!0),i=r.k,a=D(r,["k"]),[4,this.keyFactory.createPkcSignKey()];case 2:return s=d.sent(),[4,this.encryptionService.encryptToString(e,s.toJSON(!0))];case 3:return o=d.sent(),c=JSON.stringify(s.toJSON()),[4,this.encryptionService.encryptToString(t,e.toJSON(!0))];case 4:return u=d.sent(),[4,this.encryptionService.encryptToString(e,{rootKey:n.toJSON(!0)})];case 5:return p=d.sent(),[2,{assemblyKey:e,rawAssemblyKey:i,assemblyKeyParams:a,subjectKeyWrappedAssemblyKey:u,assemblyCipherData:p,assemblyKeyVerifierPbk:c,wrappedAssemblyKeyVerifierPrk:o}]}}))}))},t.prototype.prepareCreateSubAssemblies=function(e){var t=e.input,n=e.subjectKey,r=e.slipSubAssemblies,i=e.assemblyKeyParams;return M(this,void 0,void 0,(function(){var e=this;return T(this,(function(a){return[2,Promise.all(t.map((function(t,a){return M(e,void 0,void 0,(function(){var e,s,o=this;return T(this,(function(c){switch(c.label){case 0:return[4,this.encryptionService.encryptToString(n,t.subjectCipherDataClearJson||"")];case 1:return e=c.sent(),[4,Promise.all(t.approverTps.map((function(e,t){return M(o,void 0,void 0,(function(){return T(this,(function(s){return[2,this.prepareApprover({tp:e,approverIndex:t,slipSubAssembly:r[a],assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 2:return s=c.sent(),[2,{singleReject:t.singleReject,quorum:t.quorum,subjectCipherData:e,createApprovers:s}]}}))}))})))]}))}))},t.prototype.prepareUpdateSubAssemblies=function(e){var t=e.input,n=e.subjectKey,r=e.slipSubAssemblies,i=e.assemblyKeyParams,a=e.subAssemblies;return M(this,void 0,void 0,(function(){var e=this;return T(this,(function(s){if(r.length!==t.length)throw new Q("The slipSubAssemblies must be the same length as the input");return[2,Promise.all(t.map((function(t,s){return M(e,void 0,void 0,(function(){var e,o,c,u,p,d,l=this;return T(this,(function(h){switch(h.label){case 0:return[4,this.encryptionService.encryptToString(n,t.subjectCipherDataClearJson||"")];case 1:return e=h.sent(),o=a.edges.find((function(e){return e.node.id===t.id})).node,c=[],u=[],t.approverTps.forEach((function(e){var t,n=null===(t=o.approvers.edges.find((function(t){return t.node.tp.id===e.tpId})))||void 0===t?void 0:t.node;n?u.push({tp:e,approverId:n.id}):c.push({tp:e})})),p=r[s],d={subAssemblyId:t.id,singleReject:t.singleReject,quorum:t.quorum,subjectCipherData:e},[4,Promise.all(c.map((function(e,t){var r=e.tp;return M(l,void 0,void 0,(function(){return T(this,(function(e){return[2,this.prepareApprover({tp:r,approverIndex:t,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 2:return d.createApprovers=h.sent(),[4,Promise.all(u.map((function(e,t){var r=e.tp,a=e.approverId;return M(l,void 0,void 0,(function(){return T(this,(function(e){return[2,this.prepareApprover({approverId:a,tp:r,approverIndex:t+c.length,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 3:return[2,(d.updateApprovers=h.sent(),d)]}}))}))})))]}))}))},t.prototype.fillWrappingKeyId=function(e,t){var n=this;e.forEach((function(e){e.approverTps.forEach((function(e){if(!e.wrappingKeyId){var r=t.find((function(t){return t.id===e.tpId}));e.wrappingKeyId=n.getTpWrappingKeyId(r)}}))}))},t.prototype.getInputApprovers=function(e){var t=[];return e.forEach((function(e){e.approverTps.forEach((function(e){t.push(e.tpId)}))})),t},t.prototype.prepareCreate=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,h,y;return T(this,(function(f){switch(f.label){case 0:return t=this.keyService.currentRootKey,[4,this.keyFactory.createKey()];case 1:return n=f.sent(),[4,this.keyGraph.wrapKey(t,n)];case 2:return r=f.sent(),[4,this.prepareAssembly({rootKey:t.jwk,subjectKey:n})];case 3:return i=f.sent(),a=i.assemblyKey,s=i.rawAssemblyKey,o=i.assemblyKeyParams,c=D(i,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),[4,this.prepareSlip39(e.createSubAssemblies,e.quorum,s)];case 4:return u=f.sent(),p=this.getInputApprovers(e.createSubAssemblies),l=Pt,[4,this.lrGraphQl.query({query:tr,variables:{ids:p}})];case 5:return d=l.apply(void 0,[f.sent().tps]),this.fillWrappingKeyId(e.createSubAssemblies,d),[4,this.prepareCreateSubAssemblies({input:e.createSubAssemblies,assemblyKeyParams:o,slipSubAssemblies:u.subAssemblies,subjectKey:n})];case 6:return h=f.sent(),[4,this.encryptionService.encryptToString(n,e.subjectCipherDataClearJson||"")];case 7:return y=f.sent(),[2,{assemblyKey:a,mutationInput:Object.assign(Object.assign({},c),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:y,createSubAssemblies:h,rootKeyId:t.id,rootKeyWrappedSubjectKey:r})}]}}))}))},t.prototype.getAssemblyApprovers=function(e){var t=[];return Pt(e.subAssemblies).map((function(e){Pt(e.approvers).forEach((function(e){return t.push(e.tp.id)}))})),t},t.prototype.prepareUpdate=function(e,t){var n;return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b;return T(this,(function(I){switch(I.label){case 0:if(e=Object.assign({createSubAssemblies:[]},e),r=e.createSubAssemblies||[],i=e.updateSubAssemblies||[],a=e.deleteSubAssemblies||[],0===r.length&&0===i.length&&0===a.length)throw new Q("Must specify at least one of: [createSubAssemblies, updateSubAssemblies, deleteSubAssemblies]");return s=this.keyService.currentRootKey,[4,this.keyGraph.getKey(t.subjectKey.id)];case 1:return o=I.sent(),[4,this.prepareAssembly({rootKey:s.jwk,subjectKey:o.jwk})];case 2:return c=I.sent(),u=c.assemblyKey,p=c.rawAssemblyKey,d=c.assemblyKeyParams,l=D(c,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),h=this.getAssemblyApprovers(t).concat(this.getInputApprovers(r),this.getInputApprovers(i)),f=Pt,[4,this.lrGraphQl.query({query:tr,variables:{ids:h}})];case 3:y=f.apply(void 0,[I.sent().tps]),Pt(t.subAssemblies).forEach((function(e){if(!a.includes(e.id)&&!i.some((function(t){return t.id===e.id}))){var t=Pt(e.approvers).map((function(e){return{tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,sharedCipherApprovalDataClearJson:e.sharedCipherApprovalDataClearJson}}));i.push({id:e.id,quorum:e.quorum,singleReject:e.singleReject,approverTps:t,subjectCipherDataClearJson:e.subjectCipherDataClearJson})}})),this.fillWrappingKeyId(r,y),this.fillWrappingKeyId(i,y),I.label=4;case 4:return I.trys.push([4,6,,7]),[4,this.prepareSlip39((r||[]).concat(i||[]),e.quorum,p)];case 5:return v=I.sent(),[3,7];case 6:return m=I.sent(),console.log("Error while creating slip assembly",m),[3,7];case 7:return g={assemblyKeyParams:d,subjectKey:o.jwk},[4,this.prepareCreateSubAssemblies(Object.assign(Object.assign({},g),{input:r,slipSubAssemblies:v.subAssemblies.slice(0,r.length)}))];case 8:return S=I.sent(),[4,this.prepareUpdateSubAssemblies(Object.assign(Object.assign({},g),{input:i,slipSubAssemblies:v.subAssemblies.slice(r.length),subAssemblies:t.subAssemblies}))];case 9:return C=I.sent(),[4,this.encryptionService.encryptToString(o.jwk,null!==(n=e.subjectCipherDataClearJson)&&void 0!==n?n:t.subjectCipherDataClearJson)];case 10:return b=I.sent(),[2,{assemblyKey:u,mutationInput:Object.assign(Object.assign({},l),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:b,subjectKeyId:o.id,createSubAssemblies:S,updateSubAssemblies:C})}]}}))}))},t.prototype.prepareApprover=function(e){var t=e.approverId,n=e.tp,r=e.approverIndex,i=e.slipSubAssembly,a=e.assemblyKeyParams,s=e.subjectKey;return M(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,h,y;return T(this,(function(f){switch(f.label){case 0:return[4,this.prepareTpWrappingKey(n)];case 1:return e=f.sent(),[4,this.keyFactory.createKey()];case 2:return o=f.sent(),[4,this.encryptionService.encryptToString(e.jwk,o.toJSON(!0))];case 3:return c=f.sent(),[4,this.encryptionService.encryptToString(s,o.toJSON(!0))];case 4:return u=f.sent(),p=1===i.threshold?i.shares[0]:i.shares[r],d={slip39:{share:p,subAssembly:{quorum:i.threshold,size:i.size}},assemblyKeyParams:a},[4,this.encryptionService.encryptToString(o,n.sharedCipherDataClearJson||"")];case 5:return l=f.sent(),[4,this.encryptionService.encryptToString(o,n.sharedCipherApprovalDataClearJson||"")];case 6:return h=f.sent(),[4,this.encryptionService.encryptToString(o,d)];case 7:return y=f.sent(),[2,{tpWrappingKeyId:e.id,tpWrappedSharedKey:c,subjectKeyWrappedSharedKey:u,sharedCipherData:l,sharedCipherApprovalData:h,sharedCipherPartialAssemblyKey:y,approverId:t||void 0,tpId:t?void 0:n.tpId}]}}))}))},t.prototype.validateApprovers=function(e){var t,n;try{for(var r=O(e),i=r.next();!i.done;i=r.next()){var a=i.value;if(!a.currentUserSharedKey.userSharedKey.mkSharedKey){var s="tp "+a.other.username+" does not have mkSharedKey";throw console.log(s),new Q(s)}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},t.prototype.prepareSlip39=function(e,t,n){return M(this,void 0,void 0,(function(){var r;return T(this,(function(i){switch(i.label){case 0:if(e.length<t)throw new Q("Not enough sub assemblies to meet quorum");return r=new Xn(t),e.forEach((function(e,t){var n=e.approverTps.length;1===e.quorum&&(n=1),r.addSubAssembly(new Yn(t,e.quorum,n))})),[4,this.slip39Service.generateShares(n,this.slip39Passphrase,r)];case 1:return i.sent(),[2,r]}}))}))},t}();e.ɵi=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r.slip39Passphrase=Zn,r}return E(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.mkSharedKey.id},t}(nr),e.ɵi.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵi(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵi,providedIn:"root"}),e.ɵi.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵi.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵi=A([qe({ngZoneName:"ngZone"})],e.ɵi);var rr,ir,ar,sr,or,cr,ur,pr,dr,lr,hr,yr,fr,vr,mr,gr,Sr=Oe(rr||(rr=_(["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"],["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"]))),Cr=Oe(ir||(ir=_(["\nmutation CreateTpAssemblyKeyChallengeMutation(\n $input: CreateTpAssemblyKeyChallengeInput!\n) {\n createTpAssemblyKeyChallenge(input: $input) {\n challenge\n }\n}"],["\nmutation CreateTpAssemblyKeyChallengeMutation(\n $input: CreateTpAssemblyKeyChallengeInput!\n) {\n createTpAssemblyKeyChallenge(input: $input) {\n challenge\n }\n}"]))),br=Oe(ar||(ar=_(["\nmutation PreCompleteTpPasswordResetRequestMutation(\n $input: PreCompleteTpPasswordResetRequestInput!\n) {\n preCompleteTpPasswordResetRequest(input: $input) {\n idpPassword\n }\n}"],["\nmutation PreCompleteTpPasswordResetRequestMutation(\n $input: PreCompleteTpPasswordResetRequestInput!\n) {\n preCompleteTpPasswordResetRequest(input: $input) {\n idpPassword\n }\n}"]))),Ir=Oe(sr||(sr=_(["\nmutation CompleteTpPasswordResetRequestMutation(\n $input: CompleteTpPasswordResetRequestInput!\n) {\n completeTpPasswordResetRequest(input: $input) {\n id\n }\n}"],["\nmutation CompleteTpPasswordResetRequestMutation(\n $input: CompleteTpPasswordResetRequestInput!\n) {\n completeTpPasswordResetRequest(input: $input) {\n id\n }\n}"]))),wr=Oe(or||(or=_(["\nmutation ApproveTpPasswordResetRequestMutation(\n $input: ApproveTpPasswordResetRequestInput!\n) {\n approveTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"],["\nmutation ApproveTpPasswordResetRequestMutation(\n $input: ApproveTpPasswordResetRequestInput!\n) {\n approveTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"]))),Kr=Oe(cr||(cr=_(["\nmutation RejectTpPasswordResetRequestMutation(\n $input: RejectTpPasswordResetRequestInput!\n) {\n rejectTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"],["\nmutation RejectTpPasswordResetRequestMutation(\n $input: RejectTpPasswordResetRequestInput!\n) {\n rejectTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"]))),Pr=Oe(ur||(ur=_(["\nmutation CreateTpPasswordResetMutation($input: CreateTpPasswordResetInput!) {\n createTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"],["\nmutation CreateTpPasswordResetMutation($input: CreateTpPasswordResetInput!) {\n createTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"]))),kr=Oe(pr||(pr=_(["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"],["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"]))),Rr=Oe(dr||(dr=_(["\nmutation UpdateTpPasswordResetMutation($input: UpdateTpPasswordResetInput!) {\n updateTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"],["\nmutation UpdateTpPasswordResetMutation($input: UpdateTpPasswordResetInput!) {\n updateTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"]))),Er=function(){function e(e,t){var n=this;this._key=e,this.timer=setTimeout((function(){n._key=null}),t)}return Object.defineProperty(e.prototype,"key",{get:function(){return this._key},enumerable:!1,configurable:!0}),e.prototype.pop=function(){var e=this._key;return this._key=null,this.timer&&(clearTimeout(this.timer),this.timer=null),e},e}(),Dr=Oe(lr||(lr=_(["\nquery {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n sessionEncryptionKey\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n sessionEncryptionKey\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"])),Fe),Ar=Oe(hr||(hr=_(["\nquery ResetUserQuery {\n tpPasswordResetUser {\n username\n sessionEncryptionKey\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n }\n}"],["\nquery ResetUserQuery {\n tpPasswordResetUser {\n username\n sessionEncryptionKey\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n }\n}"]))),Mr=Oe(yr||(yr=_(["\nmutation SetSessionEncryptionKeyMutation($input: SetSessionEncryptionKeyInput!) {\n setSessionEncryptionKey(input: $input) {\n sessionEncryptionKey\n }\n}\n"],["\nmutation SetSessionEncryptionKeyMutation($input: SetSessionEncryptionKeyInput!) {\n setSessionEncryptionKey(input: $input) {\n sessionEncryptionKey\n }\n}\n"])));(fr=e.RecoveryStatus||(e.RecoveryStatus={})).NONE="NONE",fr.NEW_PASSWORD="NEW_PASSWORD",fr.OLD_PASSWORD="OLD_PASSWORD",(vr=e.PasswordChangeStatus||(e.PasswordChangeStatus={})).IN_PROGRESS="IN_PROGRESS",vr.RECOVERY="RECOVERY",(mr=e.CognitoChallengeName||(e.CognitoChallengeName={})).NEW_PASSWORD_REQUIRED="NEW_PASSWORD_REQUIRED",mr.SMS_MFA="SMS_MFA",mr.SOFTWARE_TOKEN_MFA="SOFTWARE_TOKEN_MFA",mr.MFA_SETUP="MFA_SETUP",e.AuthService=gr=function(n){function r(e,r,i,a,s,o,c,u,p,d,l,h,y,f){var v=n.call(this,r)||this;if(v.ngZone=e,v.injector=r,v.http=i,v.cognito=a,v.api=s,v.keyService=o,v.keyGraphService=c,v.keyFactoryService=u,v.passwordService=p,v.idleService=d,v.persistService=l,v.encryptionService=h,v.assemblyController=y,v.kcConfig=f,v.logoutListeners=new Set,v.password=null,!t.isDevMode()&&null!=v.kcConfig.debug)throw new V('In production mode, "KcConfig.debug" must be set to null');return v}return E(r,n),r.prototype.importPassword=function(e){return this.keyFactoryService.importPassword(e)},r.prototype.logout=function(){var e;return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,Promise.all(N(this.logoutListeners).map((function(e){return e()})))];case 1:return t.sent(),this.user=null,this.keyService.purgeKeys(),this.keyGraphService.purgeKeys(),[4,Promise.all([this.cognito.signOut(),this.kcLogout()])];case 2:return t.sent(),(null===(e=this.kcConfig.debug)||void 0===e?void 0:e.username)&&(this.kcConfig.debug.username=null),[2]}}))}))},r.prototype.addLogoutListener=function(e){this.logoutListeners.add(e)},r.prototype.removeLogoutListener=function(e){this.logoutListeners.delete(e)},r.prototype.login=function(t,n,r){var i,a=(void 0===r?{}:r).tpPasswordResetAutoComplete,s=void 0===a||a;return M(this,void 0,void 0,(function(){var r;return T(this,(function(a){switch(a.label){case 0:return[4,this.loginImpl(t,n)];case 1:return(r=a.sent()).challenge?(this.password=new Er(n,gr.CHALLENGE_TIMEOUT),[2,r]):s&&(null===(i=r.user.resetUser)||void 0===i?void 0:i.state)===e.TpClaimState.APPROVED?[4,this.completeResetRequest(n)]:[3,4];case 2:return a.sent(),[4,this.loginImpl(t,n)];case 3:r=a.sent(),a.label=4;case 4:return[2,r]}}))}))},r.prototype.verifyLogin=function(t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o;return T(this,(function(c){switch(c.label){case 0:if(n=t.challenge,r=t.code,i=t.rememberMe,!(a=[e.CognitoChallengeName.SMS_MFA,e.CognitoChallengeName.SOFTWARE_TOKEN_MFA]).includes(n.cognitoUser.challengeName))throw new V("challengeName must be one of "+a);return[4,this.cognito.confirmSignIn(n.cognitoUser,r,n.cognitoUser.challengeName)];case 1:return s=c.sent(),[4,this.handlePostAuth(n.recoveryStatus)];case 2:return c.sent(),[4,this.loadUser(s,this.password.pop())];case 3:return o=c.sent(),this.password=null,i&&s.setDeviceStatusRemembered({onSuccess:function(){},onFailure:function(e){return console.error(e)}}),[2,{user:o}]}}))}))},r.prototype.getUser=function(){return M(this,void 0,void 0,(function(){var e;return T(this,(function(t){switch(t.label){case 0:return this.user?[2,this.user]:[4,this.cognito.currentAuthenticatedUser()];case 1:return e=t.sent(),[2,this.loadUser(e)]}}))}))},r.prototype.refreshAccessToken=function(){return M(this,void 0,void 0,(function(){var e,t;return T(this,(function(n){switch(n.label){case 0:return[4,this.cognito.currentAuthenticatedUser()];case 1:return e=n.sent(),t=e.getSignInUserSession().getRefreshToken(),console.log("Token refresh..."),[2,new Promise((function(n,r){e.refreshSession(t,(function(e){e?(console.error("Error refreshing token: ",e),r(e)):(console.log("Token refresh complete"),n(0))}))}))]}}))}))},r.prototype.fetchCurrentUser=function(){return M(this,void 0,void 0,(function(){return T(this,(function(e){switch(e.label){case 0:return[4,this.api.query({query:Dr,processorOptions:{hasKeys:!1}})];case 1:return[2,e.sent().currentUser]}}))}))},r.prototype.fetchResetUser=function(){return M(this,void 0,void 0,(function(){return T(this,(function(e){switch(e.label){case 0:return[4,this.api.query({query:Ar,processorOptions:{hasKeys:!1}})];case 1:return[2,e.sent().tpPasswordResetUser]}}))}))},r.prototype.kcLogout=function(){return M(this,void 0,void 0,(function(){return T(this,(function(e){switch(e.label){case 0:return[4,this.http.post(this.kcConfig.authUrl+"auth/sign-out/",null,{withCredentials:!0,responseType:"text"}).toPromise()];case 1:return e.sent(),[2]}}))}))},r.prototype.fetchPassIdpParams=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.http.get(this.kcConfig.authUrl+"users/pass-idp-params/?login_name="+encodeURIComponent(e)).toPromise()];case 1:return[2,t.sent()]}}))}))},r.prototype.loginImpl=function(t,n){return M(this,void 0,void 0,(function(){var r;return T(this,(function(i){switch(i.label){case 0:return[4,this.logout()];case 1:return i.sent(),[4,this.loginIdp(t,n)];case 2:return r=i.sent(),[e.CognitoChallengeName.SMS_MFA,e.CognitoChallengeName.SOFTWARE_TOKEN_MFA].includes(r.cognitoUser.challengeName)?[2,{challenge:{cognitoUser:r.cognitoUser,recoveryStatus:r.recoveryStatus}}]:[4,this.handlePostAuth(r.recoveryStatus)];case 3:return i.sent(),[4,this.loadUser(r.cognitoUser,n)];case 4:return[2,{user:i.sent()}]}}))}))},r.prototype.loginIdp=function(t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l;return T(this,(function(h){switch(h.label){case 0:return[4,this.fetchPassIdpParams(t)];case 1:if((r=h.sent()).passwordChangeStatus===e.PasswordChangeStatus.IN_PROGRESS)throw new X("A password change is in progress");if(r.passwordChangeStatus!==e.PasswordChangeStatus.RECOVERY)return[3,8];console.log("In recovery mode."),h.label=2;case 2:return h.trys.push([2,4,,5]),a={},[4,this.loginIdpImpl(t,n,r.newPassIdpParams)];case 3:return a.cognitoUser=h.sent(),a.recoveryStatus=e.RecoveryStatus.NEW_PASSWORD,i=a,console.log("New password works!"),[2,i];case 4:if("NotAuthorizedException"!==(s=h.sent()).code)throw s;return[3,5];case 5:return h.trys.push([5,7,,8]),c={},[4,this.loginIdpImpl(t,n,r.currentPassIdpParams)];case 6:return c.cognitoUser=h.sent(),c.recoveryStatus=e.RecoveryStatus.OLD_PASSWORD,o=c,console.log("Old password works!"),[2,o];case 7:throw"NotAuthorizedException"===(u=h.sent()).code?new V("The password change request was interrupted, please try to login with both your new and old password"):u;case 8:if(!r.tpPasswordReset)return[3,12];h.label=9;case 9:return h.trys.push([9,11,,12]),p=r.tpPasswordReset,d={},[4,this.loginIdpImpl(p.resetUsername,n,p.passIdpParams)];case 10:return d.cognitoUser=h.sent(),d.recoveryStatus=e.RecoveryStatus.NONE,[2,d];case 11:return h.sent(),[3,12];case 12:return l={},[4,this.loginIdpImpl(t,n,r.currentPassIdpParams)];case 13:return l.cognitoUser=h.sent(),l.recoveryStatus=e.RecoveryStatus.NONE,[2,l]}}))}))},r.prototype.loginIdpImpl=function(e,t,n){return M(this,void 0,void 0,(function(){var r;return T(this,(function(i){switch(i.label){case 0:return[4,this.keyFactoryService.derivePassIdp(Object.assign({password:t},n))];case 1:return r=i.sent(),[2,this.cognito.signIn(e,this.passwordService.getPassIdpString(r.jwk))]}}))}))},r.prototype.handlePostAuth=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.handlePasswordRecovery(e)];case 1:return t.sent(),[4,this.handleSessionEncryptionKey()];case 2:return t.sent(),[2]}}))}))},r.prototype.handlePasswordRecovery=function(t){return M(this,void 0,void 0,(function(){return T(this,(function(n){switch(n.label){case 0:return t===e.RecoveryStatus.NONE?[3,2]:[4,this.passwordService.changePasswordComplete({useNewPassword:t===e.RecoveryStatus.NEW_PASSWORD})];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},r.prototype.handleSessionEncryptionKey=function(){return M(this,void 0,void 0,(function(){var e,n;return T(this,(function(r){switch(r.label){case 0:if(!this.kcConfig.disableSessionEncryptionKey)return[3,1];if(!t.isDevMode())throw e="You should not set disableSessionEncryptionKey=True in mode prod. It defaults to false.",console.error(e),new ee(e);return console.warn("You have set disableSessionEncryptionKey=True. Make sure not to do this in prod mode."),[3,4];case 1:return[4,this.keyFactoryService.createKey()];case 2:return n=r.sent(),[4,this.lrGraphQL.lrMutate(new ze({mutation:Mr,variables:{input:{sessionEncryptionKey:JSON.stringify(n.toJSON(!0))}}}),{includeKeyGraph:!1})];case 3:r.sent(),this.persistService.setServerSessionEncryptionKey(n),r.label=4;case 4:return[2]}}))}))},r.prototype.getCognitoUserAttribute=function(e,t){var n=t.find((function(t){return t.getName()===e}));return n?n.getValue():null},r.prototype.loadUserKeys=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u;return T(this,(function(p){switch(p.label){case 0:return t=e.userKeys,n=e.password,(r=e.sessionEncryptionKey)?(s=(i=this.persistService).setServerSessionEncryptionKey,[4,a.JWK.asKey(r)]):[3,2];case 1:s.apply(i,[p.sent()]),p.label=2;case 2:return n?[4,this.keyFactoryService.derivePassKey(Object.assign({password:n},t.passKey.passKeyParams))]:[3,6];case 3:return o=p.sent().jwk,u=(c=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(t.passKey.id,o,t.masterKey.id)];case 4:return[4,u.apply(c,[p.sent()])];case 5:p.sent(),p.label=6;case 6:return[2]}}))}))},r.prototype.loadUser=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return T(this,(function(i){switch(i.label){case 0:return e.getUsername().endsWith(".tp_password_reset")?(n=this,[4,this.loadResetUser(e,t)]):[3,2];case 1:return n.user=i.sent(),[3,4];case 2:return r=this,[4,this.loadRegularUser(e,t)];case 3:r.user=i.sent(),i.label=4;case 4:return[4,this.idleService.start()];case 5:return i.sent(),[2,this.user]}}))}))},r.prototype.loadRegularUser=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a;return T(this,(function(s){switch(s.label){case 0:return[4,this.fetchCurrentUser()];case 1:return n=s.sent(),[4,this.loadUserKeys({userKeys:n.currentUserKey,password:t,sessionEncryptionKey:n.sessionEncryptionKey})];case 2:return s.sent(),[4,this.keyGraphService.populateKeys(n.currentUserKey)];case 3:return s.sent(),r=n.id,i=n.username,[4,this.cognito.userAttributes(e)];case 4:return a=s.sent(),[2,{id:r,username:i,sub:this.getCognitoUserAttribute("sub",a),loginEmail:this.getCognitoUserAttribute("email",a),resetUser:null}]}}))}))},r.prototype.loadResetUser=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a;return T(this,(function(s){switch(s.label){case 0:return[4,this.fetchResetUser()];case 1:return n=s.sent(),r={passKey:{id:n.passKey.id,passKeyParams:n.passKey.passKeyParams},masterKey:{id:n.masterKey.id}},[4,this.loadUserKeys({userKeys:r,password:t,sessionEncryptionKey:n.sessionEncryptionKey})];case 2:return s.sent(),[4,this.keyService.setKeys(r)];case 3:return s.sent(),i=n.username,[4,this.cognito.userAttributes(e)];case 4:return a=s.sent(),[2,{username:i,sub:this.getCognitoUserAttribute("sub",a),loginEmail:this.getCognitoUserAttribute("email",a),resetUser:{state:n.state}}]}}))}))},r.prototype.recoverAssemblyKey=function(e){return M(this,void 0,void 0,(function(){var t,n,r=this;return T(this,(function(i){switch(i.label){case 0:return[4,this.keyGraphService.getKey(e.pxk.id)];case 1:return t=i.sent(),[4,Promise.all(e.approvals.filter((function(e){return!!e.receiverCipherPartialAssemblyKey})).map((function(e){return r.encryptionService.decrypt(t,e.receiverCipherPartialAssemblyKey)})))];case 2:return n=i.sent(),[2,this.assemblyController.recoverAssemblyKey(n)]}}))}))},r.prototype.completeResetRequest=function(t){return M(this,void 0,void 0,(function(){var n,r,i,s,o,c,u,p,d,l,h,y,v,m,g=this;return T(this,(function(S){switch(S.label){case 0:return[4,this.fetchResetUser()];case 1:if((n=S.sent()).state!==e.TpClaimState.APPROVED)throw new Z("Password reset request has not been approved.");return[4,this.recoverAssemblyKey(n)];case 2:return r=S.sent(),[4,this.encryptionService.decrypt(r,n.assemblyCipherData)];case 3:return i=S.sent().rootKey,[4,a.JWK.asKey(i)];case 4:return s=S.sent(),[4,this.keyGraphService.getKey(n.masterKey.id)];case 5:return o=S.sent(),[4,this.encryptionService.encryptToString(o.jwk,s.toJSON(!0))];case 6:return c=S.sent(),[4,this.keyFactoryService.derivePassIdp(Object.assign({password:t},n.passKey.passIdpParams))];case 7:return u=S.sent(),p=this.passwordService.getPassIdpString(u.jwk),[4,this.lrGraphQL.lrMutate(new ze({mutation:Cr,variables:{input:{}}}),{includeKeyGraph:!1})];case 8:return(d=S.sent().createTpAssemblyKeyChallenge.challenge).clientNonce=this.keyFactoryService.randomString(32),[4,this.encryptionService.decrypt(r,n.wrappedAssemblyKeyVerifierPrk)];case 9:return l=S.sent(),[4,this.encryptionService.sign(l,d)];case 10:return h=S.sent(),[4,this.lrGraphQL.lrMutate(new ze({mutation:br,variables:{input:{signedChallenge:JSON.stringify(h)}}}),{includeKeyGraph:!1})];case 11:return y=S.sent().preCompleteTpPasswordResetRequest.idpPassword,v=new Promise((function(e){var t=function(r){return M(g,void 0,void 0,(function(){return T(this,(function(i){switch(i.label){case 0:return"signIn"!==r.payload.event?[2]:(f.Hub.remove("auth",t),[4,this.cognito.signIn(n.username,p)]);case 1:return i.sent(),[4,this.lrGraphQL.lrMutate(new ze({mutation:Ir,variables:{input:{masterKeyWrappedRootKey:c,masterKeyId:o.id}}}))];case 2:return i.sent(),e(),[2]}}))}))};f.Hub.listen("auth",t)})),[4,this.cognito.signIn(n.username,y,{noProxy:"true"})];case 12:if("NEW_PASSWORD_REQUIRED"!==(m=S.sent()).challengeName)throw new ee("Expecting Cognito to have done a password reset after call to PreCompleteTpPasswordResetRequestMutation.");return[4,this.cognito.completeNewPassword(m,p,{})];case 13:return m=S.sent(),[2,v]}}))}))},r.prototype.debugLogin=function(e,t){return this.kcConfig.debug.username=e,this.debugLoadUser(t)},r.prototype.debugLoadUser=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s;return T(this,(function(o){switch(o.label){case 0:return[4,this.fetchCurrentUser()];case 1:return t=o.sent(),n=t.id,r=t.username,i=t.currentUserKey,[4,this.keyFactoryService.derivePassKey(Object.assign({password:e},i.passKey.passKeyParams))];case 2:return a=o.sent().jwk,[4,this.keyGraphService.unwrapWithPassKey(i.passKey.id,a,i.masterKey.id)];case 3:return s=o.sent(),[4,this.idleService.persistMasterKey(s)];case 4:return o.sent(),[4,this.keyGraphService.populateKeys(i)];case 5:return o.sent(),this.user={id:n,username:r,resetUser:null,sub:"DEBUG_MODE",loginEmail:"DEBUG_MODE"},[2,this.user]}}))}))},r.prototype.debugClearUser=function(){this.user=null},r.prototype.getCurrentUserAttributes=function(){return M(this,void 0,void 0,(function(){var e;return T(this,(function(t){switch(t.label){case 0:return[4,this.cognito.currentAuthenticatedUser()];case 1:return e=t.sent(),[4,this.cognito.userAttributes(e)];case 2:return[2,t.sent()]}}))}))},r}(Kt),e.AuthService.CHALLENGE_TIMEOUT=3e5,e.AuthService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.AuthService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(y.HttpClient),t.ɵɵinject(s.AuthClass),t.ɵɵinject(e.ɵg),t.ɵɵinject(Ke),t.ɵɵinject(Pe),t.ɵɵinject(ge),t.ɵɵinject(Bn),t.ɵɵinject(Dt),t.ɵɵinject(we),t.ɵɵinject(ve),t.ɵɵinject(e.ɵi),t.ɵɵinject(Se))},token:e.AuthService,providedIn:"root"}),e.AuthService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.AuthService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:y.HttpClient},{type:s.AuthClass},{type:e.ɵg},{type:Ke},{type:Pe},{type:ge},{type:Bn},{type:Dt},{type:we},{type:ve},{type:e.ɵi},{type:void 0,decorators:[{type:t.Inject,args:[Se]}]}]},e.AuthService=gr=A([qe({ngZoneName:"ngZone"})],e.AuthService);var Tr,Or,jr,Nr=Oe(Tr||(Tr=_(["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"],["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"]))),_r=Oe(Or||(Or=_(["\nmutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"],["\nmutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"]))),Fr=Oe(jr||(jr=_(["\nmutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n}\n"]))),$r=function(){};e.ContactCard2Service=function(){function e(e,t,n,r,i,a){this.keyFactory=e,this.keyService=t,this.encryptionService=n,this.keyGraph=r,this.keyMetaService=i,this.ngZone=a}return e.prototype.createContactCard=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a;return T(this,(function(s){switch(s.label){case 0:return t=this.keyService.currentRootKey,[4,this.keyFactory.createKey()];case 1:return n=s.sent(),[4,this.keyGraph.encryptToString(t.jwk,n.toJSON(!0))];case 2:return r=s.sent(),[4,this.keyGraph.encryptToString(n,e.plainCipherDataJson)];case 3:return i=s.sent(),[4,this.prepareContactCardInput(e)];case 4:return a=s.sent(),[2,new ze({mutation:Nr,variables:{input:Object.assign(Object.assign({},a),{wrappingKeyId:t.id,wrappedKey:r,cipherData:i})}})]}}))}))},e.prototype.updateContactCard=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return[4,this.keyGraph.encryptToString(e.keyId,e.plainCipherDataJson)];case 1:return t=r.sent(),[4,this.prepareContactCardInput(e)];case 2:return n=r.sent(),[2,new ze({mutation:_r,variables:{input:Object.assign(Object.assign({},n),{id:e.id,cipherData:t})}})]}}))}))},e.prototype.deleteContactCard=function(e){return new ze({mutation:Fr,variables:{input:{id:e}}})},e.prototype.prepareContactCardInput=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return T(this,(function(d){switch(d.label){case 0:return t=this.keyService.currentSigPxk,i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicDataJson)];case 1:return n=i.apply(r,[d.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicSearchableJson)];case 2:return a=o.apply(s,[d.sent()]),p=(u=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.plainDataJson)];case 3:return c=p.apply(u,[d.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:c}]}}))}))},e}(),e.ContactCard2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ContactCard2Service(t.ɵɵinject(ge),t.ɵɵinject(Ke),t.ɵɵinject(ve),t.ɵɵinject(Pe),t.ɵɵinject(xt),t.ɵɵinject(t.NgZone))},token:e.ContactCard2Service,providedIn:"root"}),e.ContactCard2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ContactCard2Service.ctorParameters=function(){return[{type:ge},{type:Ke},{type:ve},{type:Pe},{type:xt},{type:t.NgZone}]},e.ContactCard2Service=A([qe({ngZoneName:"ngZone"})],e.ContactCard2Service);var Lr=function(){function e(e,t,n){this.config=e,this.http=t,this.auth=n}return e.prototype.downloadEncryptedFileJson=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return n=(t=JSON).parse,[4,this.downloadEncryptedFile(e)];case 1:return[2,n.apply(t,[r.sent()])]}}))}))},e.prototype.downloadEncryptedFile=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return T(this,(function(p){switch(p.label){case 0:return t=this.config.apiUrl+"files/download/?file_state_node_id="+e,r=(n=this.http).get,i=[t],s=(a=Object).assign,c=(o=Object).assign,u=[{}],[4,be(this.auth,this.config)];case 1:return[4,r.apply(n,i.concat([s.apply(a,[c.apply(o,u.concat([p.sent()])),{responseType:"text"}])])).toPromise()];case 2:return[2,p.sent()]}}))}))},e.prototype.loadFile=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return e instanceof ArrayBuffer?[2,e]:[2,new Promise((function(t){var n=new FileReader;n.onload=function(){t(n.result)},n.readAsArrayBuffer(e)}))]}))}))},e.prototype.uploadEncryptedFile=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s;return T(this,(function(o){switch(o.label){case 0:return t=e.encryptedContent,n=e.fileName,(r=new FormData).append("content",new Blob([t]),n),a=(i=this.http).post,s=[this.config.apiUrl+"files/upload/",r],[4,be(this.auth,this.config)];case 1:return[4,a.apply(i,s.concat([o.sent()])).toPromise()];case 2:return[2,o.sent().content_resource]}}))}))},e}();Lr.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Lr(t.ɵɵinject(Se),t.ɵɵinject(y.HttpClient),t.ɵɵinject(s.AuthClass))},token:Lr,providedIn:"root"}),Lr.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Lr.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:y.HttpClient},{type:s.AuthClass}]};var Ur,xr,qr,Jr,Gr,Qr,Wr,Vr,Br,Zr,Hr,Yr,Xr,zr,ei,ti,ni,ri,ii,ai,si,oi=Oe(Ur||(Ur=_(["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"],["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"]))),ci=Oe(xr||(xr=_(["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"],["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"]))),ui=Oe(qr||(qr=_(["\nmutation DeleteDirectoryMutation($input: DeleteDirectoryInput!) {\n deleteDirectory(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteDirectoryMutation($input: DeleteDirectoryInput!) {\n deleteDirectory(input: $input) {\n id\n }\n}\n"]))),pi=Oe(Jr||(Jr=_(["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"],["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"]))),di=Oe(Gr||(Gr=_(["\nmutation UpdateFileMutation($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation UpdateFileMutation($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),li=Oe(Qr||(Qr=_(["\nmutation RevertFileMutation($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation RevertFileMutation($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),hi=Oe(Wr||(Wr=_(["\nmutation DeleteFileMutation($input: DeleteFileInput!) {\n deleteFile(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteFileMutation($input: DeleteFileInput!) {\n deleteFile(input: $input) {\n id\n }\n}\n"]))),yi=Oe(Vr||(Vr=_(["\nmutation ArchiveDirectoryMutation($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation ArchiveDirectoryMutation($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),fi=Oe(Br||(Br=_(["\nmutation ArchiveFileMutation($input: ArchiveFileInput!) {\n archiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation ArchiveFileMutation($input: ArchiveFileInput!) {\n archiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),vi=Oe(Zr||(Zr=_(["\nmutation UnarchiveDirectoryMutation($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation UnarchiveDirectoryMutation($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),mi=Oe(Hr||(Hr=_(["\nmutation UnarchiveFileMutation($input: UnarchiveFileInput!) {\n unarchiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation UnarchiveFileMutation($input: UnarchiveFileInput!) {\n unarchiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),gi=Oe(Yr||(Yr=_(["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),Si=Oe(Xr||(Xr=_(["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"]))),Ci=Oe(zr||(zr=_(["\nmutation BeginDeleteChildItemLinksWindowMutation($input: BeginDeleteChildItemLinksWindowInput!) {\n beginDeleteChildItemLinksWindow(input: $input) {\n begin\n end\n scheduled\n windowMs\n directory {\n id\n }\n }\n}\n"],["\nmutation BeginDeleteChildItemLinksWindowMutation($input: BeginDeleteChildItemLinksWindowInput!) {\n beginDeleteChildItemLinksWindow(input: $input) {\n begin\n end\n scheduled\n windowMs\n directory {\n id\n }\n }\n}\n"]))),bi=Oe(ei||(ei=_(['\nquery TempDirectoryQuery($plainMeta: LrJSONFilter!) {\n rootDirectories(plainMeta: $plainMeta, first: 2, orderBy: "created") {\n edges {\n node {\n id\n keyId\n }\n }\n }\n lock {\n version\n }\n}\n'],['\nquery TempDirectoryQuery($plainMeta: LrJSONFilter!) {\n rootDirectories(plainMeta: $plainMeta, first: 2, orderBy: "created") {\n edges {\n node {\n id\n keyId\n }\n }\n }\n lock {\n version\n }\n}\n']))),Ii=Oe(ti||(ti=_(["\nmutation SetFileConfidentialMutation($input: SetFileConfidentialInput!) {\n setFileConfidential(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation SetFileConfidentialMutation($input: SetFileConfidentialInput!) {\n setFileConfidential(input: $input) {\n file {\n id\n }\n }\n}\n"]))),wi=Oe(ni||(ni=_(["\nmutation SetDirectoryConfidentialMutation($input: SetDirectoryConfidentialInput!) {\n setDirectoryConfidential(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation SetDirectoryConfidentialMutation($input: SetDirectoryConfidentialInput!) {\n setDirectoryConfidential(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),Ki=Oe(ri||(ri=_(["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"],["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"]))),Pi=Oe(ii||(ii=_(["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"],["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"])),Ki),ki=Oe(ai||(ai=_(["\nmutation AcquireLockMutation($input: AcquireLockInput!) {\n acquireLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"],["\nmutation AcquireLockMutation($input: AcquireLockInput!) {\n acquireLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"])),Ki),Ri=Oe(si||(si=_(["\nmutation ReleaseLockMutation($input: ReleaseLockInput!) {\n releaseLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"],["\nmutation ReleaseLockMutation($input: ReleaseLockInput!) {\n releaseLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"])),Ki);e.LockService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return E(t,e),t.prototype.updateLockMutation=function(e){return new ze({mutation:Pi,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t.prototype.acquireLockMutation=function(e){return new ze({mutation:ki,variables:{input:{resourceId:e.resourceId,timeoutMs:e.timeoutMs}}})},t.prototype.releaseLockMutation=function(e){return new ze({mutation:Ri,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t}(Kt),e.LockService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.LockService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.LockService,providedIn:"root"}),e.LockService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.LockService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.LockService=A([qe({ngZoneName:"ngZone"})],e.LockService);var Ei,Di,Ai,Mi,Ti,Oi,ji=Oe(Ei||(Ei=_(["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"],["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"]))),Ni=Oe(Di||(Di=_(["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"],["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"]))),_i=Oe(Ai||(Ai=_(["\nquery DirectoryKeyFromDirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"],["\nquery DirectoryKeyFromDirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"]))),Fi=Oe(Mi||(Mi=_(["\nquery FileKeyFromFileShareQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"],["\nquery FileKeyFromFileShareQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"]))),$i=Oe(Ti||(Ti=_(["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"],["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"])));e.ItemService=Oi=function(t){function n(e,n,r,i,a,s,o,c){var u=t.call(this,n)||this;return u.ngZone=e,u.injector=n,u.fileUploadService=r,u.keyService=i,u.keyFactory=a,u.keyGraph=s,u.lockService=o,u.authService=c,u.tempDirectory=null,u.authService.addLogoutListener((function(){return u.onLogout()})),u}return E(n,t),n.prototype.downloadFileContent=function(e){return M(this,void 0,void 0,(function(){var t,n,r=this;return T(this,(function(i){switch(i.label){case 0:return[4,this.fileUploadService.downloadEncryptedFile(e.fileStateNodeId)];case 1:return t=i.sent(),[4,this.keyGraph.getKey(e.fileStateKeyId,(function(){return r.getFileStateKeyId(e.fileStateNodeId)}))];case 2:return n=i.sent(),[2,this.keyGraph.decryptFromString(n,t,{payloadType:L.UINT_8_ARRAY})]}}))}))},n.prototype.getDirectoryKeyId=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.query({query:ji,variables:{id:e}})];case 1:return[2,t.sent().directory.keyId]}}))}))},n.prototype.getFileKeyId=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.query({query:Ni,variables:{id:e}})];case 1:return[2,t.sent().file.keyId]}}))}))},n.prototype.getDirectoryKeyIdFromDirectoryShare=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.query({query:_i,variables:{id:e}})];case 1:return[2,t.sent().directoryShare.item.keyId]}}))}))},n.prototype.getFileKeyIdFromFileShare=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.query({query:Fi,variables:{id:e}})];case 1:return[2,t.sent().fileShare.item.keyId]}}))}))},n.prototype.getDirectoryKey=function(e,t){return M(this,void 0,void 0,(function(){var n=this;return T(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getDirectoryKeyId(e)}))]}))}))},n.prototype.getFileKey=function(e,t){return M(this,void 0,void 0,(function(){var n=this;return T(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getFileKeyId(e)}))]}))}))},n.prototype.createDirectory=function(e){return this.mutate(this.createDirectoryMutation(e))},n.prototype.createDirectoryMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return T(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:oi},r={},[4,this.prepareCreateDirectory(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.updateDirectory=function(e){return this.mutate(this.updateDirectoryMutation(e))},n.prototype.updateDirectoryMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return T(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:ci},r={},[4,this.prepareUpdateDirectory(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.deleteDirectory=function(e){return this.mutate(this.deleteDirectoryMutation(e))},n.prototype.deleteDirectoryMutation=function(e){return new ze({mutation:ui,variables:{input:{directoryId:e}}})},n.prototype.createFile=function(e){return this.mutate(this.createFileMutation(e))},n.prototype.createFileMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return T(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:pi},r={},[4,this.prepareCreateFile(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.updateFile=function(e){return this.mutate(this.updateFileMutation(e))},n.prototype.updateFileMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return T(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:di},r={},[4,this.prepareUpdateFile(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.revertFile=function(e){return this.mutate(this.revertFileMutation(e))},n.prototype.revertFileMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:li,variables:{input:e}})]}))}))},n.prototype.deleteFile=function(e){return this.mutate(this.deleteFileMutation(e))},n.prototype.deleteFileMutation=function(e){return new ze({mutation:hi,variables:{input:{fileId:e}}})},n.prototype.archiveDirectory=function(e,t){return this.mutate(this.archiveDirectoryMutation(e,t))},n.prototype.archiveDirectoryMutation=function(e,t){return new ze({mutation:yi,variables:{input:{directoryId:e,recursive:t.recursive}}})},n.prototype.archiveFile=function(e){return this.mutate(this.archiveFileMutation(e))},n.prototype.archiveFileMutation=function(e){return new ze({mutation:fi,variables:{input:{fileId:e}}})},n.prototype.unarchiveDirectory=function(e,t){return this.mutate(this.unarchiveDirectoryMutation(e,t))},n.prototype.unarchiveDirectoryMutation=function(e,t){return new ze({mutation:vi,variables:{input:{directoryId:e,recursive:t.recursive}}})},n.prototype.unarchiveFile=function(e){return this.mutate(this.unarchiveFileMutation(e))},n.prototype.unarchiveFileMutation=function(e){return new ze({mutation:mi,variables:{input:{fileId:e}}})},n.prototype.changeDirectoryParents=function(e){return this.mutate(this.changeDirectoryParentsMutation(e))},n.prototype.changeDirectoryParentsMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return T(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:gi},r={},[4,this.prepareChangeDirectoryParents(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.changeFileParents=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.changeFileParentsMutation(e))]}))}))},n.prototype.changeFileParentsMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return T(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:Si},r={},[4,this.prepareChangeFileParents(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.beginDeleteChildItemLinksWindow=function(e){return this.mutate(this.beginDeleteChildItemLinksWindowMutation(e))},n.prototype.beginDeleteChildItemLinksWindowMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:Ci,variables:{input:e}})]}))}))},n.prototype.ensureTempDirectory=function(){var e;return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return T(this,(function(p){switch(p.label){case 0:return this.tempDirectory?[2,this.tempDirectory]:[4,this.query({query:bi,variables:{plainMeta:Oi.TEMP_DIRECTORY_PLAIN_META_FILTER}})];case 1:return(t=p.sent()).rootDirectories.edges.length>1&&console.error("There is more than 1 temp directory (plainMeta filter: "+Oi.TEMP_DIRECTORY_PLAIN_META_FILTER+")"),0!==t.rootDirectories.edges.length?[3,4]:[4,this.createDirectoryMutation({asRootDirectory:!0,plainMetaJson:Oi.TEMP_DIRECTORY_PLAIN_META})];case 2:return n=p.sent(),r=this.lockService.updateLockMutation({version:null===(e=t.lock)||void 0===e?void 0:e.version}),[4,this.lrGraphQL.lrMutate([n,r])];case 3:return i=j.apply(void 0,[p.sent(),1]),a=i[0],s=a.createDirectory.directory,c=s.id,u=s.keyId,this.tempDirectory={id:c,keyId:u},[3,5];case 4:o=t.rootDirectories.edges[0].node,c=o.id,u=o.keyId,this.tempDirectory={id:c,keyId:u},p.label=5;case 5:return[2,this.tempDirectory]}}))}))},n.prototype.createDirectoryTree=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.createDirectoryTreeMutation(e))]}))}))},n.prototype.createDirectoryTreeMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return[4,this.ensureTempDirectory()];case 1:return t=r.sent(),[4,this.beginDeleteChildItemLinksWindow({directoryId:t.id,requestWindowMs:e.requestWindowMs})];case 2:return r.sent(),[4,this.createDirectory({cipherMetaClearJson:e.cipherMetaClearJson,parentDirectories:[{directoryId:t.id,wrappingKeyId:t.keyId}],plainMetaJson:e.plainMetaJson})];case 3:return n=r.sent().createDirectory.directory,[4,e.createContent({id:n.id,keyId:n.keyId})];case 4:return r.sent(),[2,this.changeDirectoryParentsMutation({directoryId:n.id,directoryKeyId:n.keyId,parentsToRemove:[t.id],parentsToAdd:e.parentDirectories})]}}))}))},n.prototype.setFileConfidential=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.setFileConfidentialMutation(e))]}))}))},n.prototype.setFileConfidentialMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:Ii,variables:{input:{fileId:e.fileId,confidential:e.confidential}}})]}))}))},n.prototype.setDirectoryConfidential=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.setDirectoryConfidentialMutation(e))]}))}))},n.prototype.setDirectoryConfidentialMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:wi,variables:{input:{directoryId:e.directoryId,confidential:e.confidential}}})]}))}))},n.prototype.prepareParentDirectory=function(t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o;return T(this,(function(c){switch(c.label){case 0:if(r=t.directoryId,i=t.linkType,a=t.wrappingKeyId,i!=e.LinkTypeField.REFERENCE)return[3,1];if(a)throw new Q("Do not specify wrappingKeyId when link type is REFERENCE.");return[2,{directoryId:r,linkType:i}];case 1:return[4,this.getDirectoryKey(r,a)];case 2:return s=c.sent(),o={directoryId:r,wrappingKeyId:s.id},[4,this.keyGraph.wrapKey(s,n)];case 3:return[2,(o.wrappedKey=c.sent(),o.linkType=i,o)]}}))}))},n.prototype.getFileStateKeyId=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.query({query:$i,variables:{id:e}})];case 1:return[2,t.sent().fileState.keyId]}}))}))},n.prototype.prepareCreateFileState=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h;return T(this,(function(y){switch(y.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=y.sent(),(i=t.file)?[4,this.fileUploadService.loadFile(t.file)]:[3,3];case 2:i=y.sent(),y.label=3;case 3:return(r=i)?[4,this.keyGraph.encryptToString(n,r)]:[3,8];case 4:return s=y.sent(),t.upload?[4,t.upload(s)]:[3,6];case 5:return a=y.sent(),[3,8];case 6:return[4,this.fileUploadService.uploadEncryptedFile({encryptedContent:s})];case 7:a=y.sent(),y.label=8;case 8:return c=(o=Object).assign,p=(u=Object).assign,d=[{}],[4,this.prepareItem(n,t)];case 9:return l=[p.apply(u,d.concat([y.sent()]))],h={},[4,this.keyGraph.wrapKey(e,n)];case 10:return[2,c.apply(o,l.concat([(h.wrappedStateKey=y.sent(),h.contentResource=a,h)]))]}}))}))},n.prototype.prepareChangeItemParents=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i=this;return T(this,(function(a){switch(a.label){case 0:return e.parentsToAdd?[4,Promise.all(e.parentsToAdd.map((function(e){return i.prepareParentDirectory(e,t)})))]:[3,2];case 1:return r=a.sent(),[3,3];case 2:r=[],a.label=3;case 3:return n=r,[2,{directoriesToRemove:e.parentsToRemove||[],directoriesToAdd:n}]}}))}))},n.prototype.prepareItem=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a;return T(this,(function(s){switch(s.label){case 0:return n=t.plainMetaJson,r=t.cipherMetaClearJson,i={plainMeta:n&&JSON.stringify(n)},(a=r)?[4,this.keyGraph.encryptToString(e,r)]:[3,2];case 1:a=s.sent(),s.label=2;case 2:return[2,(i.cipherMeta=a,i)]}}))}))},n.prototype.prepareCreateDirectory=function(e){var t,n,r;return M(this,void 0,void 0,(function(){var i,a,s,o,c,u,p=this;return T(this,(function(d){switch(d.label){case 0:return[4,this.keyFactory.createKey()];case 1:if(i=d.sent(),e.parentDirectories=e.parentDirectories||[],!e.asRootDirectory&&!(null===(t=e.parentDirectories)||void 0===t?void 0:t.length))throw new Q("A new directory must be either a root directory or a sub-directory. So you must provide either parentDirectories or asRootDirectory parameter.");if(e.asRootDirectory&&(null===(n=e.parentDirectories)||void 0===n?void 0:n.length))throw new Q("A new directory must be either a root directory or a sub-directory. So you can only provide either parentDirectories or asRootDirectory parameter.");return[4,Promise.all(null===(r=e.parentDirectories)||void 0===r?void 0:r.map((function(e){return p.prepareParentDirectory(e,i)})))];case 2:return a=d.sent(),e.asRootDirectory?(o=this.keyService.currentRootKey,c={wrappingKeyId:o.id},[4,this.keyGraph.wrapKey(o,i)]):[3,4];case 3:c.wrappedKey=d.sent(),s=c,d.label=4;case 4:return[4,this.prepareItem(i,e)];case 5:return u=d.sent(),[2,Object.assign(Object.assign({},u),{parentDirectories:a,parentRootDirectory:s})]}}))}))},n.prototype.prepareUpdateDirectory=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=r.sent(),[4,this.prepareItem(t.jwk,e)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{directoryId:e.directoryId})]}}))}))},n.prototype.prepareCreateFile=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i=this;return T(this,(function(a){switch(a.label){case 0:return[4,this.keyFactory.createKey()];case 1:return t=a.sent(),[4,Promise.all(e.parentDirectories.map((function(e){return i.prepareParentDirectory(e,t)})))];case 2:return n=a.sent(),[4,this.prepareCreateFileState(t,e)];case 3:return r=a.sent(),[2,Object.assign(Object.assign({},r),{parentDirectories:n})]}}))}))},n.prototype.prepareUpdateFile=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=r.sent(),[4,this.prepareCreateFileState(t.jwk,e)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{fileId:e.fileId})]}}))}))},n.prototype.prepareChangeDirectoryParents=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=r.sent(),[4,this.prepareChangeItemParents(e,t.jwk)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{directoryId:e.directoryId})]}}))}))},n.prototype.prepareChangeFileParents=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=r.sent(),[4,this.prepareChangeItemParents(e,t.jwk)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{fileId:e.fileId})]}}))}))},n.prototype.onLogout=function(){this.tempDirectory=null},n}(Kt),e.ItemService.TEMP_DIRECTORY_PLAIN_META={kcType:"temp"},e.ItemService.TEMP_DIRECTORY_PLAIN_META_FILTER=JSON.stringify({filter:[{contains:Oi.TEMP_DIRECTORY_PLAIN_META}]}),e.ItemService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ItemService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(Lr),t.ɵɵinject(Ke),t.ɵɵinject(ge),t.ɵɵinject(Pe),t.ɵɵinject(e.LockService),t.ɵɵinject(e.AuthService))},token:e.ItemService,providedIn:"root"}),e.ItemService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ItemService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:Lr},{type:Ke},{type:ge},{type:Pe},{type:e.LockService},{type:e.AuthService}]},e.ItemService=Oi=A([qe({ngZoneName:"ngZone"})],e.ItemService),e.KeyExchangeService=function(e){function t(t,n,r,i,a,s){var o=e.call(this,n)||this;return o.ngZone=t,o.injector=n,o.keyFactory=r,o.keyService=i,o.encryptionService=a,o.keyGraph=s,o.CLIENT_NONCE_LENGTH=32,o}return E(t,e),t.prototype.getOtKey=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return T(this,(function(i){switch(i.label){case 0:return t?[4,ge.asKey(Object.assign(Object.assign({},JSON.parse(e.otk.otKeyParams)),{k:t}))]:[3,2];case 1:return[2,i.sent()];case 2:return"OTK_INITIATED"!==e.otk.state||e.isInitiator||!e.otk.responderPbkCipher?[3,5]:(n=this.keyService.currentPxk,[4,this.encryptionService.decrypt(n.jwk,JSON.parse(e.otk.responderPbkCipher),{serializations:[pe.COMPACT]})]);case 3:return(r=i.sent()).otKey?[4,ge.asKey(r.otKey)]:[3,5];case 4:return[2,i.sent()];case 5:return[2,null]}}))}))},t.prototype.decryptOtk=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o;return T(this,(function(c){switch(c.label){case 0:return[4,this.getOtKey(e,t)];case 1:return n=c.sent(),r=e.otk,n&&r.otKeyCipher?(a=(i=Object).assign,s=[Object.assign({},r)],o={otKey:n},[4,this.encryptionService.decrypt(n,e.otk.otKeyCipher)]):[3,3];case 2:r=a.apply(i,s.concat([(o.otKeyCipherClearJson=c.sent(),o)])),c.label=3;case 3:return[2,Object.assign(Object.assign({},e),{otk:r})]}}))}))},t.prototype.decryptResponseCipher=function(e,t,n){return M(this,void 0,void 0,(function(){var r;return T(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.encryptionService.decrypt(e,n)];case 1:return n=i.sent(),[3,3];case 2:if("no key found"!==(r=i.sent()).message)throw r;return[3,3];case 3:return[4,this.encryptionService.decrypt(t,n)];case 4:return[2,i.sent()]}}))}))},t.prototype.decryptKeyExchangeAsInitiator=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return T(this,(function(l){switch(l.label){case 0:return t=this.keyService.currentRootKey,[4,this.encryptionService.decrypt(t.jwk,e.initiatorRootKeyCipher)];case 1:return n=l.sent(),[4,ge.asKey(n.otKey)];case 2:return r=l.sent(),e=Object.assign(Object.assign({},e),{initiatorRootKeyCipherClearJson:n}),(i=e.otk).initiatorOneTimePbkCipher?(s=(a=Object).assign,o=[Object.assign({},i)],c={},u=this.decryptResponseCipher,p=[r],[4,ge.asKey(n.oneTimePrk)]):[3,5];case 3:return[4,u.apply(this,p.concat([l.sent(),i.initiatorOneTimePbkCipher]))];case 4:i=s.apply(a,o.concat([(c.initiatorOneTimePbkCipherClearJson=l.sent(),c)])),l.label=5;case 5:return i.otKeyCipher?(d=i,[4,this.encryptionService.decrypt(r,i.otKeyCipher)]):[3,7];case 6:d.otKeyCipherClearJson=l.sent(),l.label=7;case 7:return[2,Object.assign(Object.assign({},e),{otk:i})]}}))}))},t.prototype.decryptKeyExchangeAsResponder=function(e,t){return M(this,void 0,void 0,(function(){return T(this,(function(n){return[2,this.decryptOtk(e,t)]}))}))},t.prototype.decryptKeyExchange=function(e,t){return M(this,void 0,void 0,(function(){return T(this,(function(n){return e.isInitiator?[2,this.decryptKeyExchangeAsInitiator(e)]:[2,this.decryptKeyExchangeAsResponder(e,t)]}))}))},t.prototype.getKeyExchanges=function(e){var t=(void 0===e?{}:e).state;return M(this,void 0,void 0,(function(){var e,n=this;return T(this,(function(r){switch(r.label){case 0:return[4,this.query({query:zt,variables:{state:t}})];case 1:return e=r.sent().keyExchanges,[2,Promise.all(e.edges.map((function(e){return n.decryptKeyExchange(e.node)})))]}}))}))},t.prototype.getKeyExchange=function(e,t){var n=void 0===t?{}:t,r=n.otKeyK,i=n.token;return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.query({query:i?tn:en,variables:{id:e,token:i},includeKeyGraph:!i})];case 1:return t=n.sent(),[2,this.decryptKeyExchange(t.keyExchange,r)]}}))}))},t.prototype.getCurrentUserSharedKey=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.query({query:cn,variables:{username:e.username,userId:e.userId}})]}))}))},t.prototype.cancelKeyExchange=function(e){return this.mutate(this.cancelKeyExchangeMutation(e))},t.prototype.cancelKeyExchangeMutation=function(e){return new ze({mutation:nn,variables:{input:{id:e}}})},t.prototype.declineKeyExchange=function(e,t){return this.mutate(this.declineKeyExchangeMutation(e,t))},t.prototype.declineKeyExchangeMutation=function(e,t){return new ze({mutation:rn,variables:{input:{id:e,token:t}}})},t.prototype.initiateOtk=function(e){return void 0===e&&(e={}),M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return t=this.mutate,[4,this.initiateOtkMutation(e)];case 1:return[2,t.apply(this,[n.sent().lrMutation])]}}))}))},t.prototype.initiateOtkMutation=function(e){var t=void 0===e?{}:e,n=t.message,r=t.email,i=t.contactCard,a=t.upgrade;return M(this,void 0,void 0,(function(){var e,t,s,o,c,u,p,d,l,h,y,f,v;return T(this,(function(m){switch(m.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=m.sent(),t=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.keyFactory.createPkcKey()];case 2:return s=m.sent(),o=this.keyService.currentPxk,c=this.keyService.currentSigPxk,u=null,i&&i.ownerPlainDataJson?[4,this.encryptionService.signToString(c.jwk,i.ownerPlainDataJson)]:[3,4];case 3:u=m.sent(),m.label=4;case 4:return p={message:n,contactCard:i&&{sharedCipherDataClearJson:i.sharedCipherDataClearJson}},d={nonce:t,initiator:Object.assign(Object.assign({},p),{oneTimePbk:s.toJSON(),pbk:o.jwk.toJSON(),sigPbk:c.jwk.toJSON()})},[4,this.keyGraph.encryptToString(e,d)];case 5:return l=m.sent(),h={nonce:t,oneTimePrk:s.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:i,initiator:p},y=this.keyService.currentRootKey,[4,this.keyGraph.encryptToString(y.jwk,h)];case 6:return f=m.sent(),v=e.toJSON(!0).k,[2,{lrMutation:new ze({mutation:an,variables:{input:{initiatorRootKeyCipher:f,initiatorPxkId:o.id,initiatorSigPxkId:c.id,otKeyParams:JSON.stringify(e.toJSON()),otKeyCipher:l,sendEmail:r&&{email:r,rawOtKey:v},createTp:!0,initiatorPlainDataSig:u,upgrade:a}}}),otKeyK:v}]}}))}))},t.prototype.respondOtk=function(e){return this.mutate(this.respondOtkMutation(e))},t.prototype.respondOtkMutation=function(e){var t=e.keyExchangeId,n=e.token,r=e.decryptedOtk,i=e.message,a=e.initiatorContactCard,s=e.responderContactCard;return M(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I,w,K,P,k,R,E,D,A,M,O,j,N,_,F,$,L,U,x,q,J,G,Q,W,V,B,Z,H,Y,X,z,ee;return T(this,(function(T){switch(T.label){case 0:return e=this.keyService.currentRootKey,o=this.keyService.currentMasterKey,[4,this.keyFactory.createKey()];case 1:return c=T.sent(),[4,this.keyFactory.createKey()];case 2:return u=T.sent(),[4,this.encryptionService.encrypt(e.jwk,c.toJSON(!0))];case 3:return p=T.sent(),[4,this.encryptionService.encrypt(o.jwk,u.toJSON(!0))];case 4:return d=T.sent(),[4,ge.asKey(r.otKeyCipherClearJson.initiator.oneTimePbk)];case 5:return l=T.sent(),[4,ge.asKey(r.otKeyCipherClearJson.initiator.pbk)];case 6:return h=T.sent(),[4,ge.asKey(r.otKeyCipherClearJson.initiator.sigPbk)];case 7:return y=T.sent(),f=this.keyService.currentPxk,v=this.keyService.currentSigPxk,[4,this.encryptionService.sign(v.jwk,h.toJSON())];case 8:return m=T.sent(),[4,this.encryptionService.sign(v.jwk,y.toJSON())];case 9:return g=T.sent(),S={nonce:r.otKeyCipherClearJson.nonce,sharedKey:c.toJSON(!0),mkSharedKey:u.toJSON(!0),responder:{pbk:f.jwk.toJSON(),sigPbk:v.jwk.toJSON(),message:i}},r.otKeyCipherClearJson.initiator.contactCard?(b=r.otKeyCipherClearJson.initiator.contactCard.sharedCipherDataClearJson,[4,this.keyFactory.createKey()]):[3,19];case 10:return I=T.sent(),[4,this.keyFactory.createKey()];case 11:return F=T.sent(),$=this.keyService.currentSigPxk,w={},P=(K=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,I.toJSON(!0))];case 12:return w.receiverWrappedKey=P.apply(K,[T.sent()]),w.receiverWrappingKeyId=e.id,a?(E=(R=JSON).stringify,[4,this.encryptionService.encrypt(I,a.receiverCipherDataClearJson)]):[3,14];case 13:return k=E.apply(R,[T.sent()]),[3,15];case 14:k="",T.label=15;case 15:return w.receiverCipherData=k,A=(D=JSON).stringify,[4,this.encryptionService.encrypt(c,F.toJSON(!0))];case 16:return w.sharedWrappedKey=A.apply(D,[T.sent()]),C=w,[4,this.encryptionService.encrypt(F,b)];case 17:return V=T.sent(),M=C,j=(O=JSON).stringify,[4,this.encryptionService.sign($.jwk,V)];case 18:M.sharedCipherDataSig=j.apply(O,[T.sent()]),C.sigPxkId=$.id,S.responder.contactCard=Object.assign(Object.assign({},S.responder.contactCard),{sharedCipherKey:F.toJSON(!0)}),T.label=19;case 19:return s?[4,this.keyFactory.createKey()]:[3,31];case 20:return _=T.sent(),[4,this.keyFactory.createKey()];case 21:return F=T.sent(),$=this.keyService.currentSigPxk,L={},x=(U=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,_.toJSON(!0))];case 22:return L.ownerWrappedKey=x.apply(U,[T.sent()]),L.ownerWrappingKeyId=e.id,s.ownerCipherDataClearJson?(G=(J=JSON).stringify,[4,this.encryptionService.encrypt(_,s.ownerCipherDataClearJson)]):[3,24];case 23:return q=G.apply(J,[T.sent()]),[3,25];case 24:q="",T.label=25;case 25:return L.ownerCipherData=q,W=(Q=JSON).stringify,[4,this.encryptionService.encrypt(c,F.toJSON(!0))];case 26:return L.sharedWrappedKey=W.apply(Q,[T.sent()]),N=L,[4,this.encryptionService.encrypt(F,s.sharedCipherDataClearJson)];case 27:return V=T.sent(),B=N,H=(Z=JSON).stringify,[4,this.encryptionService.sign($.jwk,V)];case 28:return B.sharedCipherDataSig=H.apply(Z,[T.sent()]),N.sigPxkId=$.id,s.ownerPlainDataJson?(Y=N,z=(X=JSON).stringify,[4,this.encryptionService.sign(v.jwk,s.ownerPlainDataJson)]):[3,30];case 29:Y.ownerPlainDataSig=z.apply(X,[T.sent()]),T.label=30;case 30:S.responder.contactCard=Object.assign(Object.assign({},S.responder.contactCard),{sharedCipherDataClearJson:s.sharedCipherDataClearJson}),T.label=31;case 31:return[4,this.encryptionService.encrypt(l,S)];case 32:return ee=T.sent(),[4,this.encryptionService.encrypt(r.otKey,ee)];case 33:return ee=T.sent(),[2,new ze({mutation:sn,variables:{input:{keyExchangeId:t,keyExchangeToken:n,rootKeyId:e.id,masterKeyId:o.id,responderPxkId:f.id,responderSigPxkId:v.id,signedInitiatorPbk:JSON.stringify(m),signedInitiatorSigPbk:JSON.stringify(g),rkWrappedSharedKey:JSON.stringify(p),mkWrappedMkSharedKey:JSON.stringify(d),initiatorOneTimePbkCipher:JSON.stringify(ee),initiatorContactCard:C,responderContactCard:N}}})]}}))}))},t.prototype.completeOtk=function(e){return this.mutate(this.completeOtkMutation(e))},t.prototype.completeOtkMutation=function(e){var t=e.keyExchangeId,n=e.initiatorRootKeyCipher,r=e.initiatorOneTimePbkCipher,i=e.responderContactCard,a=e.initiatorContactCard;return M(this,void 0,void 0,(function(){var e,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I,w,K,P,k,R,E,D,A,M,O,j,N,_,F,$,L,U,x,q;return T(this,(function(T){switch(T.label){case 0:return e=this.keyService.currentRootKey,s=this.keyService.currentMasterKey,[4,this.encryptionService.decrypt(e.jwk,n)];case 1:return o=T.sent(),u=this.decryptResponseCipher,[4,ge.asKey(o.otKey)];case 2:return p=[T.sent()],[4,ge.asKey(o.oneTimePrk)];case 3:return[4,u.apply(this,p.concat([T.sent(),r]))];case 4:if(c=T.sent(),o.nonce!==c.nonce)throw new Y("The nonce returned by responder does not match with the one created by the initiator.");return d=this.keyService.currentSigPxk,[4,ge.asKey(c.responder.sigPbk)];case 5:return l=T.sent(),[4,ge.asKey(c.responder.pbk)];case 6:return h=T.sent(),[4,this.encryptionService.sign(d.jwk,h.toJSON())];case 7:return y=T.sent(),[4,this.encryptionService.sign(d.jwk,l.toJSON())];case 8:return f=T.sent(),[4,ge.asKey(c.sharedKey)];case 9:return v=T.sent(),[4,this.encryptionService.encrypt(e.jwk,v.toJSON(!0))];case 10:return m=T.sent(),[4,ge.asKey(c.mkSharedKey)];case 11:return g=T.sent(),[4,this.encryptionService.encrypt(s.jwk,g.toJSON(!0))];case 12:return S=T.sent(),i?[4,this.keyFactory.createKey()]:[3,16];case 13:return b=T.sent(),I={},K=(w=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,b.toJSON(!0))];case 14:return I.receiverWrappedKey=K.apply(w,[T.sent()]),I.receiverWrappingKeyId=e.id,k=(P=JSON).stringify,[4,this.encryptionService.encrypt(b,i.receiverCipherDataClearJson)];case 15:I.receiverCipherData=k.apply(P,[T.sent()]),C=I,T.label=16;case 16:return o.initiatorContactCard?(D=o.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,25];case 17:return A=T.sent(),[4,ge.asKey(c.responder.contactCard.sharedCipherKey)];case 18:return M=T.sent(),N=(j=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,A.toJSON(!0))];case 19:return O=N.apply(j,[T.sent()]),(_=(null==a?void 0:a.ownerCipherDataClearJson)||D.ownerCipherDataClearJson)?[4,this.keyGraph.encryptToString(A,_)]:[3,21];case 20:return $=T.sent(),[3,22];case 21:$="",T.label=22;case 22:return F=$,R={ownerWrappedKey:O,ownerWrappingKeyId:e.id,ownerCipherData:F},E={sigPxkId:d.id},[4,this.encryptionService.encrypt(M,D.sharedCipherDataClearJson)];case 23:return L=T.sent(),U=E,q=(x=JSON).stringify,[4,this.encryptionService.sign(d.jwk,L)];case 24:U.sharedCipherDataSig=q.apply(x,[T.sent()]),T.label=25;case 25:return[2,new ze({mutation:on,variables:{input:{keyExchangeId:t,rootKeyId:e.id,masterKeyId:s.id,initiatorSigPxkId:d.id,signedResponderPbk:JSON.stringify(y),signedResponderSigPbk:JSON.stringify(f),rkWrappedSharedKey:JSON.stringify(m),mkWrappedMkSharedKey:JSON.stringify(S),responderContactCardCipher:C,initiatorContactCardCipher:R,initiatorContactCardSharedCipher:E}}})]}}))}))},t}(Kt),e.KeyExchangeService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.KeyExchangeService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ge),t.ɵɵinject(Ke),t.ɵɵinject(ve),t.ɵɵinject(Pe))},token:e.KeyExchangeService,providedIn:"root"}),e.KeyExchangeService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.KeyExchangeService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ge},{type:Ke},{type:ve},{type:Pe}]},e.KeyExchangeService=A([qe({ngZoneName:"ngZone"})],e.KeyExchangeService);var Li="LBOP";(e.KcLbopErrorCode||(e.KcLbopErrorCode={})).INVALID_PASSPHRASE="INVALID_PASSPHRASE";var Ui,xi,qi,Ji,Gi,Qi=K.default(Ui||(Ui=_(["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"],["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"]))),Wi=K.default(xi||(xi=_(["\n mutation DeleteLbop($input: DeleteLbopInput!) {\n deleteLbop(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteLbop($input: DeleteLbopInput!) {\n deleteLbop(input: $input) {\n id\n }\n }\n"]))),Vi=K.default(qi||(qi=_(["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"],["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"]))),Bi=K.default(Ji||(Ji=_(["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"],["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"]))),Zi=K.default(Gi||(Gi=_(["\n query Lbops {\n lbops {\n edges {\n node {\n id\n cipherMeta\n }\n }\n }\n }\n"],["\n query Lbops {\n lbops {\n edges {\n node {\n id\n cipherMeta\n }\n }\n }\n }\n"]))),Hi=function(){function t(e,t,n,r,i,a,s,o){this.config=e,this.http=t,this.lrApollo=n,this.auth=r,this.keyFactory=i,this.keyService=a,this.encryptionService=s,this.passwordService=o,this.CLIENT_NONCE_LENGTH=32,this.LBOP_WORDS=25}return t.prototype.getPartial=function(e){return e.split(" ")[0]},t.prototype.remove=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Wi,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteLbop.id]}}))}))},t.prototype.update=function(e){var t=e.id,n=e.name;return M(this,void 0,void 0,(function(){var e,r,i;return T(this,(function(a){switch(a.label){case 0:return[4,this.get(t)];case 1:return(e=a.sent()).name=n,r=this.keyService.currentMasterKey,[4,this.encryptionService.encrypt(r.jwk,e)];case 2:return i=a.sent(),[4,this.lrApollo.mutate({mutation:Vi,variables:{input:{id:t,cipherMeta:JSON.stringify(i)}}})];case 3:return[2,a.sent().updateLbop]}}))}))},t.prototype.get=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return T(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:Bi,variables:{id:e}})];case 1:return t=i.sent(),n=this.keyService.currentMasterKey,[4,this.encryptionService.decrypt(n.jwk,JSON.parse(t.lbop.cipherMeta))];case 2:return r=i.sent(),[2,Object.assign({id:t.id},r)]}}))}))},t.prototype.list=function(){return M(this,void 0,void 0,(function(){var e,t,n=this;return T(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Zi})];case 1:return e=r.sent(),[4,this.keyService.currentMasterKey];case 2:return t=r.sent(),[2,Promise.all(e.lbops.edges.map((function(e){return M(n,void 0,void 0,(function(){var n;return T(this,(function(r){switch(r.label){case 0:return[4,this.encryptionService.decrypt(t.jwk,JSON.parse(e.node.cipherMeta))];case 1:return n=r.sent(),[2,Object.assign({id:e.node.id},n)]}}))}))})))]}}))}))},t.prototype.create=function(e){var t=e.name;return M(this,void 0,void 0,(function(){var e,n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,S;return T(this,(function(C){switch(C.label){case 0:if(1024!==g.Slip39Helper.WORD_LIST.length)throw new W("Slip39Helper.WORD_LIST.length != 1024");return[4,this.list()];case 1:for(e=C.sent(),r=function(){n=i.keyFactory.randomChoices(g.Slip39Helper.WORD_LIST,i.LBOP_WORDS).join(" ");var t=i.getPartial(n);if(!e.some((function(e){return e.partial===t})))return"break"},i=this;"break"!==r(););return[4,this.keyFactory.createLbopKeyParams()];case 2:return a=C.sent(),c=(o=this.keyFactory).deriveLbopKey,p=(u=Object).assign,d={},[4,this.keyFactory.importPassword(n)];case 3:return[4,c.apply(o,[p.apply(u,[(d.password=C.sent(),d),a])])];case 4:return s=C.sent().jwk,[4,this.keyFactory.createSignKey()];case 5:return l=C.sent(),[4,this.encryptionService.encrypt(s,l.toJSON(!0))];case 6:return h=C.sent(),y=this.keyService.currentMasterKey,[4,this.encryptionService.encrypt(s,y.jwk.toJSON(!0))];case 7:return f=C.sent(),v=Object.assign(Object.assign({},t&&{name:t}),{partial:this.getPartial(n)}),[4,this.encryptionService.encrypt(y.jwk,v)];case 8:return m=C.sent(),[4,this.lrApollo.mutate({mutation:Qi,variables:{input:{cipherMeta:JSON.stringify(m),lbopKeyParams:JSON.stringify(a),lbopKeyVerifier:JSON.stringify(l.toJSON(!0)),wrappedLbopKeyVerifier:JSON.stringify(h),masterKeyId:y.id,wrappedMasterKey:JSON.stringify(f)}}})];case 9:return S=C.sent(),[2,Object.assign(Object.assign({},S.createLbop.lbop),{lbopString:n})]}}))}))},t.prototype.verifyLbops=function(t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g;return T(this,(function(S){switch(S.label){case 0:r=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),S.label=1;case 1:S.trys.push([1,11,12,13]),i=O(t.lbops),a=i.next(),S.label=2;case 2:return a.done?[3,10]:(s=a.value,u=(c=this.keyFactory).deriveLbopKey,d=(p=Object).assign,l={},[4,this.keyFactory.importPassword(n)]);case 3:return[4,u.apply(c,[d.apply(p,[(l.password=S.sent(),l),s.lbopKeyParams])])];case 4:o=S.sent().jwk,S.label=5;case 5:return S.trys.push([5,8,,9]),[4,this.encryptionService.decrypt(o,s.wrappedLbopKeyVerifier)];case 6:return h=S.sent(),y=t.challenge.serverNonce,[4,this.encryptionService.sign(h,{serverNonce:y,clientNonce:r})];case 7:return f=S.sent(),[2,{lbop:s,signedChallenge:f,lbopKey:o}];case 8:return S.sent(),[3,9];case 9:return a=i.next(),[3,2];case 10:return[3,13];case 11:return v=S.sent(),m={error:v},[3,13];case 12:try{a&&!a.done&&(g=i.return)&&g.call(i)}finally{if(m)throw m.error}return[7];case 13:throw new J(new q({source:Li,code:e.KcLbopErrorCode.INVALID_PASSPHRASE,message:"Invalid passphrase."}))}}))}))},t.prototype.verifyContact=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.http.post(this.config.authUrl+"users/lbop-reset/verify-contact/",e).toPromise()]}))}))},t.prototype.confirmContact=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e.claimId,v_code:e.vCode}).toPromise()]}))}))},t.prototype.verify=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return T(this,(function(p){switch(p.label){case 0:return[4,this.http.post(this.config.authUrl+"users/lbop-reset/get-challenge/",{claimId:e.claimId,claimToken:e.claimToken}).toPromise()];case 1:return t=p.sent(),[4,this.verifyLbops(t,e.lbop)];case 2:return n=p.sent(),r=n.signedChallenge,i=n.lbop,a=n.lbopKey,[4,this.http.post(this.config.authUrl+"users/lbop-reset/verify-challenge/",{lbopId:i.lbopId,signedChallenge:r}).toPromise()];case 3:return s=p.sent(),o={lbopId:i.lbopId,verifiedToken:s.verifiedToken,masterKeyId:s.masterKeyId},u=(c=ge).asKey,[4,this.encryptionService.decrypt(a,s.wrappedMasterKey)];case 4:return[4,u.apply(c,[p.sent()])];case 5:return[2,(o.masterKey=p.sent(),o)]}}))}))},t.prototype.setPassword=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i;return T(this,(function(a){switch(a.label){case 0:return[4,this.passwordService.createPassKeyBundle(e.newPassword)];case 1:return t=a.sent(),[4,this.encryptionService.encrypt(t.passKey,e.masterKey.toJSON(!0))];case 2:return n=a.sent(),[4,this.http.post(this.config.authUrl+"users/lbop-reset/set-password/",{lbopId:e.lbopId,verifiedToken:e.verifiedToken,masterKeyId:e.masterKeyId,newWrappedMasterKey:n,newPassKey:{passKeyParams:t.passKeyParams,passIdpParams:t.passIdpParams,passIdpVerifierPbk:t.passIdpVerifier.toJSON(),wrappedPassIdpVerifierPrk:t.wrappedPassIdpVerifierPrk}}).toPromise()];case 3:return r=a.sent(),[4,this.auth.signIn(r.username,r.idpPassword,{noProxy:"true"})];case 4:if("NEW_PASSWORD_REQUIRED"!==(i=a.sent()).challengeName)throw new ee("Expecting Cognito to have done a password reset.");return[4,this.auth.completeNewPassword(i,this.passwordService.getPassIdpString(t.passIdp),{})];case 5:return i=a.sent(),[4,this.auth.signOut()];case 6:return a.sent(),[4,this.http.post(this.config.authUrl+"users/lbop-reset/complete/",{lbopId:e.lbopId,setPasswordToken:r.setPasswordToken}).toPromise()];case 7:return[2,a.sent()]}}))}))},t}();Hi.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Hi(t.ɵɵinject(Se),t.ɵɵinject(y.HttpClient),t.ɵɵinject(ke),t.ɵɵinject(s.AuthClass),t.ɵɵinject(ge),t.ɵɵinject(Ke),t.ɵɵinject(ve),t.ɵɵinject(Bn))},token:Hi,providedIn:"root"}),Hi.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Hi.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:y.HttpClient},{type:ke},{type:s.AuthClass},{type:ge},{type:Ke},{type:ve},{type:Bn}]};var Yi=function(){function e(){}return e.forRoot=function(r){return{ngModule:e,providers:[{provide:Se,useValue:r},{provide:s.AuthClass,useValue:k.default},{provide:t.APP_INITIALIZER,useFactory:Et,deps:[Se,s.AuthClass],multi:!0},{provide:n.APOLLO_OPTIONS,useFactory:Ie,deps:[Se,s.AuthClass]}]}},e}();Yi.decorators=[{type:t.NgModule,args:[{imports:[y.HttpClientModule,m.NgIdleKeepaliveModule.forRoot()]}]}];var Xi,zi,ea,ta,na,ra=Oe(Xi||(Xi=_(["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"],["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"]))),ia=Oe(zi||(zi=_(["\nmutation UpdateAllNotificationsReadStateMutation($input: UpdateAllNotificationsReadStateInput!) {\n updateAllNotificationsReadState(input: $input) {\n count\n }\n}\n"],["\nmutation UpdateAllNotificationsReadStateMutation($input: UpdateAllNotificationsReadStateInput!) {\n updateAllNotificationsReadState(input: $input) {\n count\n }\n}\n"]))),aa=Oe(ea||(ea=_(["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"],["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"]))),sa=Oe(ta||(ta=_(["\nmutation DebugDeleteAllNotificationsMutation($input: DebugDeleteAllNotificationsInput!) {\n debugDeleteAllNotifications(input: $input) {\n count\n }\n}\n"],["\nmutation DebugDeleteAllNotificationsMutation($input: DebugDeleteAllNotificationsInput!) {\n debugDeleteAllNotifications(input: $input) {\n count\n }\n}\n"]))),oa=Oe(na||(na=_(["\nmutation UpdateNotificationFeatureStateMutation($input: UpdateNotificationFeatureStateInput!) {\n updateNotificationFeatureState(input: $input) {\n featureState {\n notificationsLastViewed\n\t\t}\n }\n}\n"],["\nmutation UpdateNotificationFeatureStateMutation($input: UpdateNotificationFeatureStateInput!) {\n updateNotificationFeatureState(input: $input) {\n featureState {\n notificationsLastViewed\n\t\t}\n }\n}\n"])));e.NotificationService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return E(t,e),t.prototype.updateNotification=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.updateNotificationMutation(e))]}))}))},t.prototype.updateNotificationMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:ra,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.updateAllNotificationsReadState=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.updateAllNotificationsReadStateMutation(e))]}))}))},t.prototype.updateAllNotificationsReadStateMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:ia,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.debugCreateNotification=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.debugCreateNotificationMutation(e))]}))}))},t.prototype.debugCreateNotificationMutation=function(e){var t;return M(this,void 0,void 0,(function(){return T(this,(function(n){return[2,new ze({mutation:aa,variables:{input:{receiverId:e.receiverId,hasBeenRead:e.hasBeenRead,timeRead:null===(t=e.timeRead)||void 0===t?void 0:t.toISOString(),plainData:JSON.stringify(e.plainData),plainMeta:JSON.stringify(e.plainMeta)}}})]}))}))},t.prototype.debugDeleteAllNotifications=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.debugDeleteAllNotificationsMutation(e))]}))}))},t.prototype.debugDeleteAllNotificationsMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:sa,variables:{input:{receiverId:e.receiverId}}})]}))}))},t.prototype.updateNotificationFeatureState=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.updateNotificationFeatureStateMutation(e))]}))}))},t.prototype.updateNotificationFeatureStateMutation=function(e){var t;return M(this,void 0,void 0,(function(){return T(this,(function(n){return[2,new ze({mutation:oa,variables:{input:{lastViewed:null===(t=e.lastViewed)||void 0===t?void 0:t.toISOString(),clearLastViewed:null==e.lastViewed||void 0}}})]}))}))},t}(Kt),e.NotificationService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.NotificationService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.NotificationService,providedIn:"root"}),e.NotificationService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.NotificationService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.NotificationService=A([qe({ngZoneName:"ngZone"})],e.NotificationService);var ca,ua,pa,da,la,ha,ya,fa,va,ma,ga=Oe(ca||(ca=_(["\nmutation InitiateStripePaymentMethodCaptureMutation {\n initiateStripePaymentMethodCapture(input: {}) {\n paymentCapture {\n stripeIntentId\n stripeClientSecret\n }\n }\n}\n"],["\nmutation InitiateStripePaymentMethodCaptureMutation {\n initiateStripePaymentMethodCapture(input: {}) {\n paymentCapture {\n stripeIntentId\n stripeClientSecret\n }\n }\n}\n"]))),Sa=Oe(ua||(ua=_(["\nmutation CompleteStripePaymentMethodCaptureMutation($input: CompleteStripePaymentMethodCaptureInput!) {\n completeStripePaymentMethodCapture(input: $input) {\n paymentMethod {\n id\n created\n modified\n card {\n brand\n lastFourDigits\n expiryYear\n expiryMonth\n }\n isDefault \n }\n }\n}\n"],["\nmutation CompleteStripePaymentMethodCaptureMutation($input: CompleteStripePaymentMethodCaptureInput!) {\n completeStripePaymentMethodCapture(input: $input) {\n paymentMethod {\n id\n created\n modified\n card {\n brand\n lastFourDigits\n expiryYear\n expiryMonth\n }\n isDefault \n }\n }\n}\n"]))),Ca=Oe(pa||(pa=_(["\nmutation RemovePaymentMethodMutation($input: RemovePaymentMethodInput!) {\n removePaymentMethod(input: $input) {\n id\n }\n}\n"],["\nmutation RemovePaymentMethodMutation($input: RemovePaymentMethodInput!) {\n removePaymentMethod(input: $input) {\n id\n }\n}\n"]))),ba=Oe(da||(da=_(["\nmutation SetDefaultPaymentMethodMutation($input: SetDefaultPaymentMethodInput!) {\n setDefaultPaymentMethod(input: $input) {\n paymentMethod {\n id\n } \n }\n}\n"],["\nmutation SetDefaultPaymentMethodMutation($input: SetDefaultPaymentMethodInput!) {\n setDefaultPaymentMethod(input: $input) {\n paymentMethod {\n id\n } \n }\n}\n"]))),Ia=Oe(la||(la=_(["\nmutation RemoveDefaultPaymentMethodMutation {\n removeDefaultPaymentMethod(input: {}) {\n paymentMethod {\n id\n } \n }\n}\n"],["\nmutation RemoveDefaultPaymentMethodMutation {\n removeDefaultPaymentMethod(input: {}) {\n paymentMethod {\n id\n } \n }\n}\n"]))),wa=Oe(ha||(ha=_(["\nmutation IssuePlanMutation($input: IssuePlanInput!) {\n issuePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"],["\nmutation IssuePlanMutation($input: IssuePlanInput!) {\n issuePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"]))),Ka=Oe(ya||(ya=_(["\nmutation CancelPlanMutation($input: CancelPlanInput!) {\n cancelPlan(input: $input) {\n plan {\n id\n } \n }\n}\n"],["\nmutation CancelPlanMutation($input: CancelPlanInput!) {\n cancelPlan(input: $input) {\n plan {\n id\n } \n }\n}\n"]))),Pa=Oe(fa||(fa=_(["\nmutation ChangePriceOptionMutation($input: ChangePriceOptionInput!) {\n changePriceOption(input: $input) {\n plan {\n id\n }\n }\n}\n"],["\nmutation ChangePriceOptionMutation($input: ChangePriceOptionInput!) {\n changePriceOption(input: $input) {\n plan {\n id\n }\n }\n}\n"]))),ka=Oe(va||(va=_(["\nmutation ReactivatePlanMutation($input: ReactivatePlanInput!) {\n reactivatePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"],["\nmutation ReactivatePlanMutation($input: ReactivatePlanInput!) {\n reactivatePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"])));e.PlanService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return E(t,e),t.prototype.initiateStripePaymentMethodCapture=function(){return this.mutate(this.initiateStripePaymentMethodCaptureMutation())},t.prototype.initiateStripePaymentMethodCaptureMutation=function(){return new ze({mutation:ga,variables:{input:{}}})},t.prototype.completeStripePaymentMethodCapture=function(e){return this.mutate(this.completeStripePaymentMethodCaptureMutation(e))},t.prototype.completeStripePaymentMethodCaptureMutation=function(e){return new ze({mutation:Sa,variables:{input:{stripeIntentId:e}}})},t.prototype.setDefaultPaymentMethod=function(e){return this.mutate(this.setDefaultPaymentMethodMutation(e))},t.prototype.setDefaultPaymentMethodMutation=function(e){return new ze({mutation:ba,variables:{input:{paymentMethodId:e}}})},t.prototype.removeDefaultPaymentMethod=function(){return this.mutate(this.removeDefaultPaymentMethodMutation())},t.prototype.removeDefaultPaymentMethodMutation=function(){return new ze({mutation:Ia,variables:{input:{}}})},t.prototype.issuePlan=function(e){return this.mutate(this.issuePlanMutation(e))},t.prototype.issuePlanMutation=function(e){return new ze({mutation:wa,variables:{input:e}})},t.prototype.removePaymentMethod=function(e){return this.mutate(this.removePaymentMethodMutation(e))},t.prototype.removePaymentMethodMutation=function(e){return new ze({mutation:Ca,variables:{input:{paymentMethodId:e}}})},t.prototype.cancelPlan=function(e){return this.mutate(this.cancelPlanMutation(e))},t.prototype.cancelPlanMutation=function(e){return new ze({mutation:Ka,variables:{input:e}})},t.prototype.changePriceOption=function(e){return this.mutate(this.changePriceOptionMutation(e))},t.prototype.changePriceOptionMutation=function(e){return new ze({mutation:Pa,variables:{input:e}})},t.prototype.reactivatePlan=function(e){return this.mutate(this.reactivatePlanMutation(e))},t.prototype.reactivatePlanMutation=function(e){return new ze({mutation:ka,variables:{input:{planId:e}}})},t}(Kt),e.PlanService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.PlanService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.PlanService,providedIn:"root"}),e.PlanService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.PlanService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.PlanService=A([qe({ngZoneName:"ngZone"})],e.PlanService),function(e){e.Name="name",e.Email="email",e.Image="image",e.Phone="phone",e.Address="address"}(ma||(ma={}));var Ra=[ma.Name,ma.Email,ma.Image,ma.Phone,ma.Address],Ea=function(){function t(e,t,n){this.sharedContactCardService=e,this.profileService=t,this.api=n}return t.prototype.updateDetails=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return console.log("updateDetails()"),[4,this.fetchMainContactCard()];case 1:return t=r.sent(),[4,this.profileService.updateDetails(null==t?void 0:t.id,null==t?void 0:t.keyId,e)];case 2:return n=r.sent(),[4,this.synchronizeContactCards(e,null==t?void 0:t.fields)];case 3:return r.sent(),[2,n]}}))}))},t.prototype.updateTrustedPartyDetails=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i;return T(this,(function(a){switch(a.label){case 0:return t=e.id,n=e.ownedKeyId,r=e.sharedKeyId,i=D(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(t,n,r,i)];case 1:return a.sent(),[4,this.synchronizeSharedDetails(e)];case 2:return a.sent(),[2]}}))}))},t.prototype.synchronizeSharedDetails=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,h;return T(this,(function(y){switch(y.label){case 0:return t=!1,[4,this.fetchMainContactCard()];case 1:if(n=y.sent(),e.name&&(u=this.checkField(e.name,n.fields.name))&&(n.fields.name=u,t=!0),e.email&&(u=this.checkField(e.email,n.fields.email))&&(n.fields.email=u,t=!0),e.image&&(u=this.checkField(e.image,n.fields.image))&&(n.fields.image=u,t=!0),e.phones&&e.phones.length)try{for(r=O(e.phones),i=r.next();!i.done;i=r.next())a=i.value,(u=this.checkField(a.value,n.fields.phone,a.label))&&(n.fields.phone=u,t=!0)}catch(e){p={error:e}}finally{try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(p)throw p.error}}if(e.addresses&&e.addresses.length)try{for(s=O(e.addresses),o=s.next();!o.done;o=s.next())c=o.value,(u=this.checkField(c.value,n.fields.address,c.label))&&(n.fields.address=u,t=!0)}catch(e){l={error:e}}finally{try{o&&!o.done&&(h=s.return)&&h.call(s)}finally{if(l)throw l.error}}return t?[4,this.profileService.updateDetails(n.id,n.keyId,n.fields)]:[3,3];case 2:y.sent(),y.label=3;case 3:return[2]}}))}))},t.prototype.fetchMainContactCard=function(){var e;return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.api.query({query:$n})];case 1:return[2,(t=null===(e=n.sent().contactCards.edges[0])||void 0===e?void 0:e.node)?{id:t.id,keyId:t.key.id,fields:t.cipherDataClearJson}:null]}}))}))},t.prototype.getTrustedParties=function(){return M(this,void 0,void 0,(function(){var e=this;return T(this,(function(t){switch(t.label){case 0:return[4,this.api.query({query:Fn})];case 1:return[2,Pt(t.sent().tps).map((function(t){return e.mapTrustedParty(t)}))]}}))}))},t.prototype.mapTrustedParty=function(t){var n,r,i=t.sharedContactCard.sharedCipherDataClearJson,a=Object.assign(Object.assign({},t.myContactCard.sharedCipherDataClearJson),{id:t.myContactCard.id,ownedKeyId:t.myContactCard.ownerKey.id,sharedKeyId:t.myContactCard.sharedKey.id});return{id:t.id,type:e.TrustedPartyType.User,hasScenarios:!!t.sharedScenarios.edges.length,hasSharedVault:!!t.theirItems.directories.edges.length,name:null===(n=null==i?void 0:i.name)||void 0===n?void 0:n.name,details:i,mySharedDetails:a,userSharedKey:t.currentUserSharedKey.userSharedKey,username:t.other.username,features:{sharedVault:{hasAccess:"access"===((null===(r=t.other.features)||void 0===r?void 0:r.shareVault)||["noaccess"])[0]}}}},t.prototype.synchronizeContactCards=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return T(this,(function(p){switch(p.label){case 0:return t?0===(n=this.getChanges(e,t)).length?[2]:[4,this.getTrustedParties()]:[2];case 1:if(0===(r=p.sent()).length)return[2];p.label=2;case 2:p.trys.push([2,7,8,9]),i=O(r.map((function(e){return e.mySharedDetails}))),a=i.next(),p.label=3;case 3:return a.done?[3,6]:(s=a.value,[4,this.synchronizeSharedContactCard(s,n)]);case 4:p.sent(),p.label=5;case 5:return a=i.next(),[3,3];case 6:return[3,9];case 7:return o=p.sent(),c={error:o},[3,9];case 8:try{a&&!a.done&&(u=i.return)&&u.call(i)}finally{if(c)throw c.error}return[7];case 9:return[2]}}))}))},t.prototype.getChanges=function(e,t){var n,r,i,a,s,o=[];try{for(var c=O(Ra),u=c.next();!u.done;u=c.next()){var p=u.value,d=t[p];if(d&&d.values){var l=function(t){var n=null===(s=e[p].values)||void 0===s?void 0:s.find((function(e){return e.id===t.id}));n?w.default.isEqual(n.value,t.value)||o.push({field:p,id:t.id,label:t.label,oldValue:t.value,newValue:n.value}):o.push({field:p,id:t.id,label:t.label,oldValue:t.value})};try{for(var h=(i=void 0,O(d.values)),y=h.next();!y.done;y=h.next()){l(y.value)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return o},t.prototype.synchronizeSharedContactCard=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l;return T(this,(function(h){switch(h.label){case 0:n=!1,r=function(t){switch(t.field){case ma.Phone:(r=e.phones&&e.phones.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;case ma.Address:(r=e.addresses&&e.addresses.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;default:var r=e[t.field];w.default.isEqual(r,t.oldValue)&&(n=!0,e[t.field]=t.newValue)}};try{for(i=O(t),a=i.next();!a.done;a=i.next())s=a.value,r(s)}catch(e){d={error:e}}finally{try{a&&!a.done&&(l=i.return)&&l.call(i)}finally{if(d)throw d.error}}return n?(o=e.id,c=e.ownedKeyId,u=e.sharedKeyId,p=D(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(o,c,u,p)]):[3,2];case 1:h.sent(),h.label=2;case 2:return[2]}}))}))},t.prototype.checkField=function(e,t,n){return void 0===n&&(n=null),(t=t||{value:e,hasMultiple:!1}).values=t.values||[],0===t.values.length||t.values.every((function(t){return!w.default.isEqual(e,t.value)}))?(t.values.push({id:n+"-"+(new Date).getTime(),label:n,value:e}),t.hasMultiple=t.values.length>1,t.value=t.value||e,t):null},t}();Ea.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ea(t.ɵɵinject(Rn),t.ɵɵinject(Ln),t.ɵɵinject(e.ɵg))},token:Ea,providedIn:"root"}),Ea.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ea.ctorParameters=function(){return[{type:Rn},{type:Ln},{type:e.ɵg}]};var Da=function(){function e(e,t,n,r,i,a){this.config=e,this.auth=t,this.http=n,this.keyFactory=r,this.encryptionService=i,this.passwordService=a}return e.prototype.verifyEmail=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/claim/email/",{address:e,context:"signup"}).toPromise()];case 1:return[2,t.sent().claim_id]}}))}))},e.prototype.verifyPhone=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/claim/sms/",{address:e,context:"signup"}).toPromise()];case 1:return[2,t.sent().claim_id]}}))}))},e.prototype.confirmVerificationCode=function(e,t){return M(this,void 0,void 0,(function(){return T(this,(function(n){switch(n.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e,v_code:t}).toPromise()];case 1:return[2,n.sent().token]}}))}))},e.prototype.register=function(e,t,n,r,i){return void 0===i&&(i="email"),M(this,void 0,void 0,(function(){var a,s,o,c,u,p,d,l,h,y,f,v,m;return T(this,(function(g){switch(g.label){case 0:return[4,this.passwordService.createPassKeyBundle(t)];case 1:return a=g.sent(),[4,this.keyFactory.createKey()];case 2:return s=g.sent(),[4,this.encryptionService.encrypt(a.passKey,s.toJSON(!0))];case 3:return o=g.sent(),[4,this.keyFactory.createKey()];case 4:return c=g.sent(),[4,this.encryptionService.encrypt(s,c.toJSON(!0))];case 5:return u=g.sent(),[4,this.keyFactory.createPkcKey()];case 6:return p=g.sent(),[4,this.encryptionService.encrypt(c,p.toJSON(!0))];case 7:return d=g.sent(),[4,this.keyFactory.createPkcSignKey()];case 8:return l=g.sent(),[4,this.encryptionService.encrypt(c,l.toJSON(!0))];case 9:return h=g.sent(),[4,this.http.post(this.config.authUrl+"users/",{claims:[{type:i,token:r,claim_id:n}],pass_idp_params:a.passIdpParams,pass_idp_verifier_pbk:a.passIdpVerifier.toJSON(),wrapped_pass_idp_verifier_prk:a.wrappedPassIdpVerifierPrk,pass_key_params:a.passKeyParams,wrapped_master_key:o,wrapped_root_key:u,pbk:p.toJSON(),wrapped_prk:d,sig_pbk:l.toJSON(),wrapped_sig_prk:h}).toPromise()];case 10:return y=g.sent(),f={},y.claims.forEach((function(e){f[e.type]=e.value})),v=this.keyFactory.randomDigitsNoZeros(4),[4,this.auth.signUp({username:e.split("@")[0]+"."+v,password:this.passwordService.getPassIdpString(a.passIdp),attributes:f,clientMetadata:{user_id:String(y.id),user_pre_sign_up_token:String(y.pre_sign_up_token)}})];case 11:return[2,{username:(m=g.sent()).user.getUsername(),userId:y.id,preSignUpToken:y.pre_sign_up_token,userSub:m.userSub}]}}))}))},e.prototype.hibpBreachedAccounts=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.http.get(this.config.authUrl+"users/hibp/breachedaccount/"+e+"/?truncateResponse=false").toPromise()];case 1:return[2,n.sent()];case 2:if(404===(t=n.sent()).status)return[2,null];throw t;case 3:return[2]}}))}))},e}();Da.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Da(t.ɵɵinject(Se),t.ɵɵinject(s.AuthClass),t.ɵɵinject(y.HttpClient),t.ɵɵinject(ge),t.ɵɵinject(ve),t.ɵɵinject(Bn))},token:Da,providedIn:"root"}),Da.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Da.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:s.AuthClass},{type:y.HttpClient},{type:ge},{type:ve},{type:Bn}]};var Aa,Ma,Ta,Oa=function(){},ja=Oe(Aa||(Aa=_(["\nmutation CreateReminderMutation($input: CreateReminderInput!) {\n createReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"],["\nmutation CreateReminderMutation($input: CreateReminderInput!) {\n createReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"]))),Na=Oe(Ma||(Ma=_(["\nmutation UpdateReminderMutation($input: UpdateReminderInput!) {\n updateReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"],["\nmutation UpdateReminderMutation($input: UpdateReminderInput!) {\n updateReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"]))),_a=Oe(Ta||(Ta=_(["\nmutation DeleteReminderMutation($input: DeleteReminderInput!) {\n deleteReminder(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteReminderMutation($input: DeleteReminderInput!) {\n deleteReminder(input: $input) {\n id\n }\n}\n"])));e.ReminderService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return E(t,e),t.prototype.createReminder=function(e){return this.mutate(this.createReminderMutation(e))},t.prototype.createReminderMutation=function(e){var t;return M(this,void 0,void 0,(function(){return T(this,(function(n){return[2,new ze({mutation:ja,variables:{input:{directoryId:e.directoryId,firstEvent:e.firstEvent.toISOString(),plain:JSON.stringify(e.plainJson),notifyAheadSeconds:null!==(t=e.notifyAheadSeconds)&&void 0!==t?t:0}}})]}))}))},t.prototype.updateReminder=function(e){return this.mutate(this.updateReminderMutation(e))},t.prototype.updateReminderMutation=function(e){var t,n;return M(this,void 0,void 0,(function(){return T(this,(function(r){return[2,new ze({mutation:Na,variables:{input:{id:e.id,firstEvent:null===(t=e.firstEvent)||void 0===t?void 0:t.toISOString(),plain:JSON.stringify(null!==(n=e.plainJson)&&void 0!==n?n:void 0),notifyAheadSeconds:e.notifyAheadSeconds}}})]}))}))},t.prototype.deleteReminder=function(e){return this.mutate(this.deleteReminderMutation(e))},t.prototype.deleteReminderMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:_a,variables:{input:{id:e}}})]}))}))},t}(Kt),e.ReminderService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ReminderService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ReminderService,providedIn:"root"}),e.ReminderService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ReminderService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ReminderService=A([qe({ngZoneName:"ngZone"})],e.ReminderService);var Fa,$a,La,Ua,xa,qa,Ja,Ga,Qa,Wa,Va=Oe(Fa||(Fa=_(["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"],["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"]))),Ba=Oe($a||($a=_(["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"],["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"]))),Za=Oe(La||(La=_(["\nmutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n}\n"]))),Ha=Oe(Ua||(Ua=_(["\nmutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),Ya=Oe(xa||(xa=_(["\nmutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),Xa=Oe(qa||(qa=_(["\nmutation RejectScenarioClaimMutation($input: RejectScenarioClaimInput!) {\n rejectScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"],["\nmutation RejectScenarioClaimMutation($input: RejectScenarioClaimInput!) {\n rejectScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"]))),za=Oe(Ja||(Ja=_(["\nmutation ApproveScenarioClaimMutation($input: ApproveScenarioClaimInput!) {\n approveScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"],["\nmutation ApproveScenarioClaimMutation($input: ApproveScenarioClaimInput!) {\n approveScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"]))),es=Oe(Ga||(Ga=_(["\nmutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),ts=Oe(Qa||(Qa=_(["\nmutation DebugExpireScenarioClaimMutation($input: DebugExpireScenarioClaimInput!) {\n debugExpireScenarioClaim(input: $input) {\n scenarioClaim {\n id\n }\n }\n}\n"],["\nmutation DebugExpireScenarioClaimMutation($input: DebugExpireScenarioClaimInput!) {\n debugExpireScenarioClaim(input: $input) {\n scenarioClaim {\n id\n }\n }\n}\n"]))),ns=Oe(Wa||(Wa=_(["\nmutation DebugExpireTpPasswordResetRequestMutation($input: DebugExpireTpPasswordResetRequestInput!) {\n debugExpireTpPasswordResetRequest(input: $input) {\n passwordResetRequest {\n id\n }\n }\n}\n"],["\nmutation DebugExpireTpPasswordResetRequestMutation($input: DebugExpireTpPasswordResetRequestInput!) {\n debugExpireTpPasswordResetRequest(input: $input) {\n passwordResetRequest {\n id\n }\n }\n}\n"])));e.ɵm=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r.slip39Passphrase="lifeready",r}return E(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.sharedKey.id},t}(nr),e.ɵm.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵm(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵm,providedIn:"root"}),e.ɵm.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵm.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵm=A([qe({ngZoneName:"ngZone"})],e.ɵm);var rs,is,as=Oe(rs||(rs=_(["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),ss=Oe(is||(is=_(["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n assemblyKeyId\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"],["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n assemblyKeyId\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));function os(){throw new Q("claimId does not match with the current claimId of the scenario")}function cs(){throw new Z("Scenario claim has not been approved")}e.ScenarioService=function(t){function n(e,n,r,i,a,s){var o=t.call(this,n)||this;return o.ngZone=e,o.injector=n,o.keyGraph=r,o.itemService=i,o.assemblyController=a,o.encryptionService=s,o.prepareAddReceiverDirectory=o.prepareReceiverDirectory,o.prepareUpdateReceiverDirectory=o.prepareReceiverDirectory,o}return E(n,t),n.prototype.createScenario=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.createScenarioMutation(e))]}))}))},n.prototype.createScenarioMutation=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.prepareCreateScenarioMutation(e)];case 1:return t=n.sent(),[2,new ze({mutation:Va,variables:{input:t}})]}}))}))},n.prototype.updateScenario=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.updateScenarioMutation(e))]}))}))},n.prototype.updateScenarioMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return[4,this.getScenario(e.scenarioId)];case 1:return t=r.sent().scenario,[4,this.prepareUpdateScenario(e,t)];case 2:return n=r.sent(),[2,new ze({mutation:Ba,variables:{input:n}})]}}))}))},n.prototype.resetScenario=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.resetScenarioMutation(e))]}))}))},n.prototype.resetScenarioMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i;return T(this,(function(a){switch(a.label){case 0:return[4,this.getScenario(e.scenarioId)];case 1:return t=a.sent().scenario,n=t.assembly,r=Pt(n.subAssemblies).map((function(e){var t=Pt(e.approvers).map((function(e){return{tpId:e.tp.id}}));return{id:e.id,quorum:e.quorum,singleReject:e.singleReject,subjectCipherDataClearJson:e.subjectCipherDataClearJson,approverTps:t}})),[4,this.prepareUpdateScenario({scenarioId:e.scenarioId,enabled:e.enabled,updateAssembly:{quorum:n.quorum,singleReject:n.singleReject,updateSubAssemblies:r}},t)];case 2:return i=a.sent(),[2,new ze({mutation:Ba,variables:{input:i}})]}}))}))},n.prototype.deleteScenario=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.lrGraphQL.lrMutate(this.deleteScenarioMutation(e))]}))}))},n.prototype.deleteScenarioMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:Za,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.createClaim=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.createClaimMutation(e))]}))}))},n.prototype.createClaimMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:Ha,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.cancelClaim=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.cancelClaimMutation(e))]}))}))},n.prototype.cancelClaimMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:Ya,variables:{input:{claimId:e}}})]}))}))},n.prototype.rejectClaim=function(e,t){return M(this,void 0,void 0,(function(){return T(this,(function(n){return[2,this.mutate(this.rejectClaimMutation(e,t))]}))}))},n.prototype.rejectClaimMutation=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return T(this,(function(a){switch(a.label){case 0:return[4,this.prepareRejectClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=tt).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.approveClaim=function(e,t){return M(this,void 0,void 0,(function(){return T(this,(function(n){return[2,this.mutate(this.approveClaimMutation(e,t))]}))}))},n.prototype.approveClaimMutation=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return T(this,(function(a){switch(a.label){case 0:return[4,this.prepareApproveClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=tt).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.receiveClaim=function(e,t){return M(this,void 0,void 0,(function(){return T(this,(function(n){return[2,this.mutate(this.receiveClaim2Mutation(e,t))]}))}))},n.prototype.receiveClaim2Mutation=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return T(this,(function(a){switch(a.label){case 0:return n=ze.bind,r={mutation:es},i={},[4,this.prepareReceiveClaim2(e,t)];case 1:return[2,new(n.apply(ze,[void 0,(r.variables=(i.input=a.sent(),i),r)]))]}}))}))},n.prototype.debugExpireClaim=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.debugExpireClaimMutation(e))]}))}))},n.prototype.debugExpireClaimMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:ts,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.getScenario=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.query({query:as,variables:{scenarioId:e}})]}))}))},n.prototype.getSharedScenario=function(e,t){return M(this,void 0,void 0,(function(){var n;return T(this,(function(r){switch(r.label){case 0:return[4,this.query({query:ss,variables:{scenarioId:e}})];case 1:return n=r.sent(),t&&n.sharedScenario.sharedClaim.id!==t&&os(),[2,n]}}))}))},n.prototype.getParticipantTpsKeys=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return t=e.map((function(e){return e.tpId})),n=Pt,[4,this.lrGraphQL.query({query:tr,variables:{ids:t}})];case 1:return[2,n.apply(void 0,[r.sent().tps])]}}))}))},n.prototype.fillTpSharedKeyId=function(e,t){e.forEach((function(e){if(!e.tpSharedKeyId){var n=t.find((function(t){return t.id===e.tpId}));e.tpSharedKeyId=n.currentUserSharedKey.userSharedKey.sharedKey.id}}))},n.prototype.prepareCreateScenarioMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p=this;return T(this,(function(d){switch(d.label){case 0:return[4,this.assemblyController.prepareCreate(e.createAssembly)];case 1:return t=d.sent(),n=t.assemblyKey,r=t.mutationInput,i=e.createReceivers||[],a=e.createClaimants||[],s=i.concat(a),[4,this.getParticipantTpsKeys(s)];case 2:return o=d.sent(),this.fillTpSharedKeyId(s,o),[4,Promise.all(i.map((function(e){return p.prepareCreateReceiver(e,n)})))];case 3:return c=d.sent(),[4,Promise.all(a.map((function(e){return p.prepareCreateClaimant(e)})))];case 4:return u=d.sent(),[2,{enabled:e.enabled,createAssembly:r,createReceivers:c,createClaimants:u}]}}))}))},n.prototype.prepareUpdateScenario=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I=this;return T(this,(function(w){switch(w.label){case 0:return[4,this.keyGraph.getJwkKey(t.assembly.assemblyKey.id)];case 1:return n=w.sent(),e.updateAssembly?[4,M(I,void 0,void 0,(function(){var r;return T(this,(function(i){switch(i.label){case 0:return[4,this.assemblyController.prepareUpdate(e.updateAssembly,t.assembly)];case 1:return r=i.sent(),n=r.assemblyKey,[2,r.mutationInput]}}))}))]:[3,3];case 2:return i=w.sent(),[3,4];case 3:i=void 0,w.label=4;case 4:return r=i,a=e.createReceivers||[],s=e.createClaimants||[],o=a.concat(s),[4,this.getParticipantTpsKeys(o)];case 5:return c=w.sent(),this.fillTpSharedKeyId(o,c),(p=e.createReceivers)?[4,Promise.all(e.createReceivers.map((function(e){return I.prepareCreateReceiver(e,n)})))]:[3,7];case 6:p=w.sent(),w.label=7;case 7:return u=p,d=Pt(t.receivers),e.updateReceivers?[4,Promise.all(e.updateReceivers.map((function(e){var t=d.find((function(t){return t.tp.id===e.tpId}));return I.prepareUpdateReceiver(e,n,t)})))]:[3,9];case 8:return h=w.sent(),[3,10];case 9:h=[],w.label=10;case 10:return l=h,e.updateAssembly?(y=d.filter((function(t){return!(e.deleteReceivers||[]).includes(t.tp.id)&&!l.some((function(e){return e.tpId===t.tp.id}))})),v=(f=l).concat,[4,this.prepareExistingReceivers(y,n)]):[3,12];case 11:l=v.apply(f,[w.sent()]),w.label=12;case 12:return(g=e.createClaimants)?[4,Promise.all(e.createClaimants.map((function(e){return I.prepareCreateClaimant(e)})))]:[3,14];case 13:g=w.sent(),w.label=14;case 14:return m=g,S=Pt(t.claimants),(b=e.updateClaimants)?[4,Promise.all(e.updateClaimants.map((function(e){var t=S.find((function(t){return t.tp.id===e.tpId}));return I.prepareUpdateClaimant(e,t.sharedKey.id)})))]:[3,16];case 15:b=w.sent(),w.label=16;case 16:return C=b,[2,{scenarioId:e.scenarioId,enabled:e.enabled,updateAssembly:r,createReceivers:u,updateReceivers:l,deleteReceivers:e.deleteReceivers,createClaimants:m,updateClaimants:C,deleteClaimants:e.deleteClaimants}]}}))}))},n.prototype.prepareReceiverDirectory=function(t,n,r){return M(this,void 0,void 0,(function(){var i,a,s;return T(this,(function(o){switch(o.label){case 0:return t.accessRole!=e.AccessRoleChoice.DENY?[3,1]:[2,{directoryId:t.directoryId,accessRole:t.accessRole,wrappedItemKey:null,sharedCipherData:null}];case 1:return[4,this.itemService.getDirectoryKey(t.directoryId,t.directoryKeyId)];case 2:return i=o.sent(),[4,this.keyGraph.encryptToString(n,t.sharedCipherDataClearJson||"")];case 3:return a=o.sent(),[4,this.keyGraph.encryptToString(n,i.jwk.toJSON(!0))];case 4:return s=o.sent(),[4,this.keyGraph.encryptToString(r,s)];case 5:return s=o.sent(),[2,{directoryId:t.directoryId,accessRole:t.accessRole,wrappedItemKey:s,sharedCipherData:a}]}}))}))},n.prototype.prepareCreateReceiver=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o=this;return T(this,(function(c){switch(c.label){case 0:return[4,this.prepareCreateParticipant(e)];case 1:return n=c.sent(),r=n.sharedKey,i=n.mutationInput,(s=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return o.prepareAddReceiverDirectory(e,r.key,t)})))]:[3,3];case 2:s=c.sent(),c.label=3;case 3:return a=s,[2,Object.assign(Object.assign({},i),{addDirectories:a})]}}))}))},n.prototype.prepareUpdateReceiver=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l=this;return T(this,(function(h){switch(h.label){case 0:return r=n.sharedKey.id,i=e.deleteDirectories||[],a=e.updateDirectories||[],Pt(n.receiverItems.receiverDirectories).forEach((function(e){i.includes(e.directory.id)||a.find((function(t){return t.directoryId===e.directory.id}))||a.push({accessRole:e.accessRole,directoryId:e.directory.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson})})),[4,this.prepareUpdateParticipant(e,r)];case 1:return s=h.sent(),o=s.sharedKey,c=s.mutationInput,(p=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return l.prepareAddReceiverDirectory(e,o,t)})))]:[3,3];case 2:p=h.sent(),h.label=3;case 3:return u=p,[4,Promise.all(a.map((function(e){return l.prepareUpdateReceiverDirectory(e,o,t)})))];case 4:return d=h.sent(),[2,Object.assign(Object.assign({},c),{addDirectories:u,updateDirectories:d,deleteDirectories:e.deleteDirectories})]}}))}))},n.prototype.prepareExistingReceiver=function(e,t){return M(this,void 0,void 0,(function(){var n;return T(this,(function(r){return n=Pt(e.receiverItems.receiverDirectories).map((function(e){return{directoryId:e.directory.id,directoryKeyId:e.directory.keyId,accessRole:e.accessRole,sharedCipherDataClearJson:e.sharedCipherDataClearJson}})),[2,this.prepareUpdateReceiver({tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,updateDirectories:n},t,e)]}))}))},n.prototype.prepareExistingReceivers=function(e,t){return M(this,void 0,void 0,(function(){var n=this;return T(this,(function(r){return[2,Promise.all(e.map((function(e){return n.prepareExistingReceiver(e,t)})))]}))}))},n.prototype.prepareCreateParticipant=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.keyGraph.encryptWithNewKey(e.tpSharedKeyId,e.sharedCipherDataClearJson||"")];case 1:return[2,{sharedKey:t=n.sent(),mutationInput:{tpId:e.tpId,tpSharedKeyId:e.tpSharedKeyId,tpSharedKeyWrappedSharedKey:t.wrappedKey,sharedCipherData:t.cipher}}]}}))}))},n.prototype.prepareUpdateParticipant=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return T(this,(function(i){switch(i.label){case 0:return[4,this.keyGraph.getJwkKey(t)];case 1:return n=i.sent(),[4,this.keyGraph.encryptToString(n,e.sharedCipherDataClearJson||"")];case 2:return r=i.sent(),[2,{sharedKey:n,mutationInput:{tpId:e.tpId,sharedKeyId:t,sharedCipherData:r}}]}}))}))},n.prototype.prepareCreateClaimant=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.prepareCreateParticipant(e)];case 1:return[2,t.sent().mutationInput]}}))}))},n.prototype.prepareUpdateClaimant=function(e,t){return M(this,void 0,void 0,(function(){return T(this,(function(n){switch(n.label){case 0:return[4,this.prepareUpdateParticipant(e,t)];case 1:return[2,n.sent().mutationInput]}}))}))},n.prototype.prepareReceiveClaim2=function(t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o;return T(this,(function(c){switch(c.label){case 0:return[4,this.getSharedScenario(t,n)];case 1:return(r=c.sent().sharedScenario).state!==e.ScenarioState.APPROVED&&cs(),i=Pt(r.sharedClaim.asClaimReceiver.approvals),[4,this.recoverAssemblyKey(i)];case 2:return a=c.sent(),[4,this.keyGraph.getKey(r.asReceiver.sharedKey.id)];case 3:return s=c.sent(),[4,this.keyGraph.encryptToString(s,a.toJSON(!0))];case 4:return o=c.sent(),[2,{scenarioClaimId:n,sharedKeyWrappedAssemblyKey:o,sharedKeyId:s.id,assemblyKeyId:r.sharedClaim.asClaimReceiver.assemblyKeyId}]}}))}))},n.prototype.prepareReceiveClaim=function(t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o=this;return T(this,(function(c){switch(c.label){case 0:return[4,this.getSharedScenario(t,n)];case 1:return(r=c.sent().sharedScenario).state!==e.ScenarioState.APPROVED&&cs(),i=Pt(r.sharedClaim.asClaimReceiver.approvals),[4,this.recoverAssemblyKey(i)];case 2:return a=c.sent(),[4,Promise.all(r.asReceiver.receiverItems.receiverDirectories.edges.map((function(e){return e.node})).map((function(e){return M(o,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.encryptionService.decrypt(a,e.wrappedItemKey)];case 1:return t=n.sent(),[2,{receiverDirectoryId:e.id,receiverSharedKeyWrappedItemKey:t}]}}))}))})))];case 3:return s=c.sent(),[2,{scenarioClaimId:n,receiverDirectories:s}]}}))}))},n.prototype.recoverAssemblyKey=function(e){return M(this,void 0,void 0,(function(){var t,n=this;return T(this,(function(r){switch(r.label){case 0:return[4,Promise.all(e.map((function(e){return n.keyGraph.decryptFromString(e.pxk.id,e.receiverCipherPartialAssemblyKey)})))];case 1:return t=r.sent(),[2,this.assemblyController.recoverAssemblyKey(t)]}}))}))},n.prototype.asClaimApprovers=function(e,t,n){return M(this,void 0,void 0,(function(){return T(this,(function(r){switch(r.label){case 0:return[4,this.getSharedScenario(e,t)];case 1:return[2,Pt(r.sent().sharedScenario.sharedClaim.claim.asClaimApprovers).filter((function(e){return e.state===n}))]}}))}))},n.prototype.prepareApproveClaimMutations=function(t,n){return M(this,void 0,void 0,(function(){var r=this;return T(this,(function(i){switch(i.label){case 0:return[4,this.asClaimApprovers(t,n,e.TpClaimApproverState.CLAIMED)];case 1:return[2,i.sent().map((function(e){return M(r,void 0,void 0,(function(){var t,n,r;return T(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:za},r={},[4,this.prepareApproveClaim(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))}))]}}))}))},n.prototype.prepareApproveClaim=function(e){return M(this,void 0,void 0,(function(){var t,n=this;return T(this,(function(r){switch(r.label){case 0:return[4,Promise.all(Pt(e.receiverApprovals).map((function(t){return n.prepareReceiverApproval({receiverApprovalId:t.id,receiverApprovalPxkId:t.pxk.id,sharedCipherPartialAssemblyKeyClearJson:e.sharedCipherPartialAssemblyKeyClearJson})})))];case 1:return t=r.sent(),[2,{claimApproverId:e.id,receiverApprovals:t}]}}))}))},n.prototype.prepareReceiverApproval=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return t={receiverApprovalId:e.receiverApprovalId,receiverCipher:""},[4,this.keyGraph.encryptToString(e.receiverApprovalPxkId,e.sharedCipherPartialAssemblyKeyClearJson)];case 1:return[2,(t.receiverCipherPartialAssemblyKey=n.sent(),t)]}}))}))},n.prototype.prepareRejectClaimMutations=function(t,n){return M(this,void 0,void 0,(function(){var r=this;return T(this,(function(i){switch(i.label){case 0:return[4,this.asClaimApprovers(t,n,e.TpClaimApproverState.CLAIMED)];case 1:return[2,i.sent().map((function(e){return M(r,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:Xa,variables:{input:{claimApproverId:e.id}}})]}))}))}))]}}))}))},n}(Kt),e.ScenarioService.SLIP39_PASSPHRASE="lifeready",e.ScenarioService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ScenarioService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(Pe),t.ɵɵinject(e.ItemService),t.ɵɵinject(e.ɵm),t.ɵɵinject(ve))},token:e.ScenarioService,providedIn:"root"}),e.ScenarioService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ScenarioService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:Pe},{type:e.ItemService},{type:e.ɵm},{type:ve}]},e.ScenarioService=A([qe({ngZoneName:"ngZone"})],e.ScenarioService);var us,ps=Oe(us||(us=_(["\nquery ServerConfigQuery {\n serverConfig {\n relayConnectionMaxLimit\n }\n}\n"],["\nquery ServerConfigQuery {\n serverConfig {\n relayConnectionMaxLimit\n }\n}\n"])));e.ServerConfigService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return E(t,e),t.prototype.getConfig=function(){return M(this,void 0,void 0,(function(){var e;return T(this,(function(t){switch(t.label){case 0:return null!=this.serverConfig?[3,2]:(e=this,[4,this.query({query:ps,includeKeyGraph:!1})]);case 1:e.serverConfig=t.sent().serverConfig,t.label=2;case 2:return[2,this.serverConfig]}}))}))},t}(Kt),e.ServerConfigService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ServerConfigService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ServerConfigService,providedIn:"root"}),e.ServerConfigService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ServerConfigService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ServerConfigService=A([qe({ngZoneName:"ngZone"})],e.ServerConfigService);var ds,ls,hs,ys,fs=Oe(ds||(ds=_(["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"],["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"]))),vs=Oe(ls||(ls=_(["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"],["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"]))),ms=Oe(hs||(hs=_(["\nquery GetOwnedContactCardKeyIdsQuery($id: LrRelayIdInput!) {\n ownedContactCard(id: $id) {\n sharedKey {\n id\n }\n ownerKey {\n id\n }\n }\n}"],["\nquery GetOwnedContactCardKeyIdsQuery($id: LrRelayIdInput!) {\n ownedContactCard(id: $id) {\n sharedKey {\n id\n }\n ownerKey {\n id\n }\n }\n}"]))),gs=Oe(ys||(ys=_(["\nquery GetReceivedContactCardKeyIdQuery($id: LrRelayIdInput!) {\n receivedContactCard(id: $id) {\n receiverKey {\n id\n }\n }\n}"],["\nquery GetReceivedContactCardKeyIdQuery($id: LrRelayIdInput!) {\n receivedContactCard(id: $id) {\n receiverKey {\n id\n }\n }\n}"])));e.SharedContactCard2Service=function(){function e(e,t,n,r,i){this.ngZone=e,this.keyService=t,this.keyGraph=n,this.encryptionService=r,this.lrGraphQL=i}return e.prototype.getOwnedContactCardKeyIds=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:ms,variables:{id:e}})];case 1:return[2,{sharedKeyId:(t=n.sent().ownedContactCard).sharedKey.id,ownerKeyId:t.ownerKey.id}]}}))}))},e.prototype.getReceivedContactCardKeyId=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:gs,variables:{id:e}})];case 1:return[2,t.sent().receivedContactCard.receiverKey.id]}}))}))},e.prototype.updateOwnedContactCard=function(e){var t=e.id,n=e.ownerKeyId,r=e.sharedKeyId,i=e.ownerPlainDataJson,a=e.ownerCipherDataClearJson,s=e.sharedCipherDataClearJson;return M(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,h,y,f,v,m;return T(this,(function(g){switch(g.label){case 0:return g.trys.push([0,3,,7]),[4,this.keyGraph.getKey(n)];case 1:return e=g.sent(),[4,this.keyGraph.getKey(r)];case 2:return o=g.sent(),[3,7];case 3:return g.sent(),[4,this.getOwnedContactCardKeyIds(t)];case 4:return c=g.sent(),[4,this.keyGraph.getKey(c.ownerKeyId)];case 5:return e=g.sent(),[4,this.keyGraph.getKey(c.sharedKeyId)];case 6:return o=g.sent(),[3,7];case 7:return u=this.keyService.currentSigPxk,[4,this.encryptionService.encrypt(o.jwk,s)];case 8:return p=g.sent(),h=(l=JSON).stringify,[4,this.encryptionService.sign(u.jwk,p)];case 9:return d=h.apply(l,[g.sent()]),v=(f=JSON).stringify,[4,this.encryptionService.sign(u.jwk,i)];case 10:return y=v.apply(f,[g.sent()]),[4,this.encryptionService.encryptToString(e.jwk,a)];case 11:return m=g.sent(),[2,new ze({mutation:fs,variables:{input:{id:t,ownerCipherData:m,ownerKeyId:e.id,sharedCipherDataSig:d,sharedKeyId:o.id,sigPxkId:u.id,ownerPlainDataSig:y}}})]}}))}))},e.prototype.updateReceivedContactCard=function(e){var t=e.id,n=e.receiverKeyId,r=e.receiverCipherDataClearJson;return M(this,void 0,void 0,(function(){var e,i,a=this;return T(this,(function(s){switch(s.label){case 0:return[4,this.keyGraph.getKey(n,(function(){return a.getReceivedContactCardKeyId(t)}))];case 1:return e=s.sent(),[4,this.encryptionService.encryptToString(e.jwk,r)];case 2:return i=s.sent(),[2,new ze({mutation:vs,variables:{input:{id:t,receiverCipherData:i,receiverKeyId:e.id}}})]}}))}))},e}(),e.SharedContactCard2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.SharedContactCard2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(Ke),t.ɵɵinject(Pe),t.ɵɵinject(ve),t.ɵɵinject(e.ɵg))},token:e.SharedContactCard2Service,providedIn:"root"}),e.SharedContactCard2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.SharedContactCard2Service.ctorParameters=function(){return[{type:t.NgZone},{type:Ke},{type:Pe},{type:ve},{type:e.ɵg}]},e.SharedContactCard2Service=A([qe({ngZoneName:"ngZone"})],e.SharedContactCard2Service);var Ss,Cs,bs,Is,ws,Ks=Oe(Ss||(Ss=_(["\nfragment SharedTpPasswordResetFragment on SharedTpPasswordResetNode {\n id\n tp {\n id\n other {\n username\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedRequest {\n id\n pxk {\n id\n pbk\n }\n claim {\n id\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nfragment SharedTpPasswordResetFragment on SharedTpPasswordResetNode {\n id\n tp {\n id\n other {\n username\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedRequest {\n id\n pxk {\n id\n pbk\n }\n claim {\n id\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),Ps=Oe(Cs||(Cs=_(["\nquery SharedTpPasswordResetsQuery {\n sharedTpPasswordResets {\n edges {\n node {\n ...SharedTpPasswordResetFragment\n }\n }\n }\n}\n","\n"],["\nquery SharedTpPasswordResetsQuery {\n sharedTpPasswordResets {\n edges {\n node {\n ...SharedTpPasswordResetFragment\n }\n }\n }\n}\n","\n"])),Ks),ks=Oe(bs||(bs=_(["\nquery SharedTpPasswordResetQuery($id: LrRelayIdInput!) {\n sharedTpPasswordReset(id: $id) {\n ...SharedTpPasswordResetFragment\n }\n}\n","\n"],["\nquery SharedTpPasswordResetQuery($id: LrRelayIdInput!) {\n sharedTpPasswordReset(id: $id) {\n ...SharedTpPasswordResetFragment\n }\n}\n","\n"])),Ks),Rs=(Oe(Is||(Is=_(["\nquery TpPasswordResetUserQuery {\n tpPasswordResetUser {\n username\n resetUsername\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n sessionEncryptionKey\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n requestAgainAfter\n }\n}"],["\nquery TpPasswordResetUserQuery {\n tpPasswordResetUser {\n username\n resetUsername\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n sessionEncryptionKey\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n requestAgainAfter\n }\n}"]))),Oe(ws||(ws=_(["\nquery TpPasswordResetQuery {\n tpPasswordReset {\n id\n applied\n assembly {\n singleReject\n quorum\n canMeetQuorum\n subjectCipherData\n subjectKey {\n id\n }\n assemblyKey {\n id\n }\n assemblyCipherData\n subAssemblies {\n edges {\n node {\n id\n singleReject\n quorum\n subjectCipherData\n subjectKey {\n id\n }\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nquery TpPasswordResetQuery {\n tpPasswordReset {\n id\n applied\n assembly {\n singleReject\n quorum\n canMeetQuorum\n subjectCipherData\n subjectKey {\n id\n }\n assemblyKey {\n id\n }\n assemblyCipherData\n subAssemblies {\n edges {\n node {\n id\n singleReject\n quorum\n subjectCipherData\n subjectKey {\n id\n }\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))));e.ɵn=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return E(t,e),t.prototype.getReset=function(){return M(this,void 0,void 0,(function(){return T(this,(function(e){switch(e.label){case 0:return[4,this.query({query:Rs})];case 1:return[2,e.sent().tpPasswordReset]}}))}))},t.prototype.getSharedResets=function(){return M(this,void 0,void 0,(function(){return T(this,(function(e){switch(e.label){case 0:return[4,this.query({query:Ps})];case 1:return[2,e.sent().sharedTpPasswordResets]}}))}))},t.prototype.getSharedReset=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.query({query:ks,variables:{id:e}})];case 1:return[2,t.sent().sharedTpPasswordReset]}}))}))},t}(Kt),e.ɵn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵn(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵn,providedIn:"root"}),e.ɵn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵn.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵn=A([qe({ngZoneName:"ngZone"})],e.ɵn),e.TpPasswordResetRequestService=function(t){function n(e,n,r,i){var a=t.call(this,n)||this;return a.ngZone=e,a.injector=n,a.encryptionService=r,a.privateService=i,a}return E(n,t),n.prototype.activeRequestOrRaise=function(t){var n=t.sharedRequest.claim.state;if(n!==e.TpAssemblyState.CLAIMED)throw new Z("Claim is already in "+n+" state.")},n.prototype.rejectRequest=function(e){return this.mutate(this.rejectRequestMutation(e))},n.prototype.rejectRequestMutation=function(t){return M(this,void 0,void 0,(function(){var n;return T(this,(function(r){switch(r.label){case 0:return[4,this.privateService.getSharedReset(t)];case 1:return n=r.sent(),this.activeRequestOrRaise(n),[2,tt.create(n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})).map((function(e){return new ze({mutation:Kr,variables:{input:{claimApproverId:e.node.id}}})})))]}}))}))},n.prototype.approveRequest=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return T(this,(function(i){switch(i.label){case 0:return r=(n=this.lrGraphQL).lrMutate,[4,this.approveRequestMutation(e,t)];case 1:return[2,r.apply(n,[i.sent()])]}}))}))},n.prototype.approveRequestMutation=function(t,n){return M(this,void 0,void 0,(function(){var n,r,i,s,o,c=this;return T(this,(function(u){switch(u.label){case 0:return[4,this.privateService.getSharedReset(t)];case 1:return n=u.sent(),this.activeRequestOrRaise(n),[4,a.JWK.asKey(JSON.parse(n.sharedRequest.pxk.pbk))];case 2:return r=u.sent(),i=n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})),o=(s=tt).create,[4,Promise.all(i.map((function(e){return M(c,void 0,void 0,(function(){var t,n,i=this;return T(this,(function(a){switch(a.label){case 0:return t=e.node,n={claimApproverId:t.id},[4,Promise.all(t.receiverApprovals.edges.map((function(e){return M(i,void 0,void 0,(function(){var n,i;return T(this,(function(a){switch(a.label){case 0:return n=e.node,i={receiverApprovalId:n.id,receiverCipher:""},[4,this.encryptionService.encryptToString(r,t.sharedCipherPartialAssemblyKeyClearJson)];case 1:return[2,(i.receiverCipherPartialAssemblyKey=a.sent(),i)]}}))}))})))];case 1:return n.receiverApprovals=a.sent(),[2,new ze({mutation:wr,variables:{input:n}})]}}))}))})))];case 3:return[2,o.apply(s,[u.sent()])]}}))}))},n}(Kt),e.TpPasswordResetRequestService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetRequestService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ve),t.ɵɵinject(e.ɵn))},token:e.TpPasswordResetRequestService,providedIn:"root"}),e.TpPasswordResetRequestService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetRequestService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ve},{type:e.ɵn}]},e.TpPasswordResetRequestService=A([qe({ngZoneName:"ngZone"})],e.TpPasswordResetRequestService);function Es(){!function(e){if(!e)throw new Q("You must specify a non empty prefix.");Object.keys(localStorage).forEach((function(t){t.startsWith(e)&&localStorage.removeItem(t)}))}("CognitoIdentityServiceProvider")}e.TpPasswordResetUserService=function(e){function t(t,n,r,i,a,s,o,c){var u=e.call(this,n)||this;return u.ngZone=t,u.injector=n,u.config=r,u.keyFactory=i,u.encryptionService=a,u.passwordService=s,u.http=o,u.auth=c,u}return E(t,e),t.prototype.verifyEmailContact=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){return t={email:e},[2,this.http.post(this.config.authUrl+"tp/password-reset/verify-contact/",t).toPromise()]}))}))},t.prototype.verifyContactRespond=function(e,t){return M(this,void 0,void 0,(function(){return T(this,(function(n){switch(n.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e,v_code:t}).toPromise()];case 1:return[2,n.sent().token]}}))}))},t.prototype.requestReset=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u;return T(this,(function(p){switch(p.label){case 0:return Es(),[4,this.passwordService.createPassKeyBundle(e)];case 1:return r=p.sent(),[4,this.keyFactory.createKey()];case 2:return i=p.sent(),[4,this.encryptionService.encrypt(r.passKey,i.toJSON(!0))];case 3:return a=p.sent(),[4,this.keyFactory.createPkcKey()];case 4:return s=p.sent(),[4,this.encryptionService.encrypt(i,s.toJSON(!0))];case 5:return o=p.sent(),[4,this.http.post(this.config.authUrl+"tp/password-reset/request/",{claimId:t,claimToken:n,pass_key_params:r.passKeyParams,pass_idp_params:r.passIdpParams,pass_idp_verifier_pbk:r.passIdpVerifier.toJSON(),wrapped_pass_idp_verifier_prk:r.wrappedPassIdpVerifierPrk,wrapped_master_key:a,pbk:s.toJSON(),master_key_wrapped_prk:o}).toPromise()];case 6:return c=p.sent(),console.log("Using new password"),[4,this.auth.signUp({username:c.reset_username,password:this.passwordService.getPassIdpString(r.passIdp),clientMetadata:{tp_password_reset_request:JSON.stringify({id:c.id,associate_reset_user_token:c.associate_reset_user_token})}})];case 7:return u=p.sent(),console.log("requestRest done"),[2,{requestResetResult:c,signUpResult:u}]}}))}))},t}(Kt),e.TpPasswordResetUserService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetUserService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(Se),t.ɵɵinject(ge),t.ɵɵinject(ve),t.ɵɵinject(Bn),t.ɵɵinject(y.HttpClient),t.ɵɵinject(s.AuthClass))},token:e.TpPasswordResetUserService,providedIn:"root"}),e.TpPasswordResetUserService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetUserService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:ge},{type:ve},{type:Bn},{type:y.HttpClient},{type:s.AuthClass}]},e.TpPasswordResetUserService=A([qe({ngZoneName:"ngZone"})],e.TpPasswordResetUserService),e.TpPasswordResetService=function(e){function t(t,n,r,i){var a=e.call(this,n)||this;return a.ngZone=t,a.injector=n,a.privateService=r,a.assemblyController=i,a.slip39Passphrase=Zn,a}return E(t,e),t.prototype.cancelResetRequest=function(){return this.mutate(this.cancelResetRequestMutation())},t.prototype.cancelResetRequestMutation=function(){return new ze({mutation:Sr})},t.prototype.deleteReset=function(){return this.mutate(this.deleteResetMutation())},t.prototype.deleteResetMutation=function(){return new ze({mutation:kr})},t.prototype.validateApprovers=function(e){return this.assemblyController.validateApprovers(e)},t.prototype.createReset=function(e){return this.mutate(this.createResetMutation(e))},t.prototype.createResetMutation=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.assemblyController.prepareCreate(e)];case 1:return t=n.sent().mutationInput,[2,new ze({mutation:Pr,variables:{input:{assembly:Object.assign({},t)}}})]}}))}))},t.prototype.updateReset=function(e){return this.mutate(this.updateResetMutation(e))},t.prototype.updateResetMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return[4,this.privateService.getReset()];case 1:return t=r.sent(),[4,this.assemblyController.prepareUpdate(e,t.assembly)];case 2:return n=r.sent().mutationInput,[2,new ze({mutation:Rr,variables:{input:{assembly:Object.assign({},n)}}})]}}))}))},t.prototype.debugExpireResetRequest=function(e){return this.mutate(this.debugExpireResetRequestMutation(e),{includeKeyGraph:!1})},t.prototype.debugExpireResetRequestMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:ns,variables:{input:{username:e}}})]}))}))},t}(Kt),e.TpPasswordResetService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(e.ɵn),t.ɵɵinject(e.ɵi))},token:e.TpPasswordResetService,providedIn:"root"}),e.TpPasswordResetService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:e.ɵn},{type:e.ɵi}]},e.TpPasswordResetService=A([qe({ngZoneName:"ngZone"})],e.TpPasswordResetService);var Ds,As,Ms,Ts,Os,js,Ns,_s,Fs,$s,Ls,Us,xs,qs=Oe(Ds||(Ds=_(["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"]))),Js=Oe(As||(As=_(["\nmutation CreateDirectoryShareMutation($input: CreateDirectoryShareInput!) {\n createDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"],["\nmutation CreateDirectoryShareMutation($input: CreateDirectoryShareInput!) {\n createDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"]))),Gs=Oe(Ms||(Ms=_(["\nmutation CreateFileShareMutation($input: CreateFileShareInput!) {\n createFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"],["\nmutation CreateFileShareMutation($input: CreateFileShareInput!) {\n createFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"]))),Qs=Oe(Ts||(Ts=_(["\nmutation UpdateDirectoryShareMutation($input: UpdateDirectoryShareInput!) {\n updateDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"],["\nmutation UpdateDirectoryShareMutation($input: UpdateDirectoryShareInput!) {\n updateDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"]))),Ws=Oe(Os||(Os=_(["\nmutation UpdateFileShareMutation($input: UpdateFileShareInput!) {\n updateFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"],["\nmutation UpdateFileShareMutation($input: UpdateFileShareInput!) {\n updateFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"]))),Vs=Oe(js||(js=_(["\nmutation DeleteDirectoryShareMutation($input: DeleteDirectoryShareInput!) {\n deleteDirectoryShare(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteDirectoryShareMutation($input: DeleteDirectoryShareInput!) {\n deleteDirectoryShare(input: $input) {\n id\n }\n}\n"]))),Bs=Oe(Ns||(Ns=_(["\nmutation DeleteFileShareMutation($input: DeleteFileShareInput!) {\n deleteFileShare(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteFileShareMutation($input: DeleteFileShareInput!) {\n deleteFileShare(input: $input) {\n id\n }\n}\n"]))),Zs=Oe(_s||(_s=_(["\nmutation CompleteDetachedDirectoryShareMutation($input: CompleteDetachedDirectoryShareInput!) {\n completeDetachedDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"],["\nmutation CompleteDetachedDirectoryShareMutation($input: CompleteDetachedDirectoryShareInput!) {\n completeDetachedDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"]))),Hs=Oe(Fs||(Fs=_(["\nmutation CompleteDetachedFileShareMutation($input: CompleteDetachedFileShareInput!) {\n completeDetachedFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"],["\nmutation CompleteDetachedFileShareMutation($input: CompleteDetachedFileShareInput!) {\n completeDetachedFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"]))),Ys=Oe($s||($s=_(["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"]))),Xs=Oe(Ls||(Ls=_(["\n mutation RespondTpMkReshareMutation($input: RespondTpMkReshareInput!) {\n respondTpMkReshare(input: $input) {\n id\n }\n }\n"],["\n mutation RespondTpMkReshareMutation($input: RespondTpMkReshareInput!) {\n respondTpMkReshare(input: $input) {\n id\n }\n }\n"]))),zs=Oe(Us||(Us=_(["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"]))),eo=Oe(xs||(xs=_(["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"],["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"])));e.TrustedPartyService=function(e){function t(t,n,r,i,a,s,o){var c=e.call(this,n)||this;return c.ngZone=t,c.injector=n,c.keyGraph=r,c.itemService=i,c.keyService=a,c.keyFactory=s,c.encryptionService=o,c}return E(t,e),t.prototype.deleteTp=function(e){return this.mutate(this.deleteTpMutation(e))},t.prototype.deleteTpMutation=function(e){return new ze({mutation:qs,variables:{input:{id:e}}})},t.prototype.createDirectoryShare=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.createDirectoryShareMutation(e))]}))}))},t.prototype.createDirectoryShareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return t=ze.bind,n={mutation:Js},[4,this.prepareCreateItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=r.sent(),n)]))]}}))}))},t.prototype.createFileShare=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.createFileShareMutation(e))]}))}))},t.prototype.createFileShareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return t=ze.bind,n={mutation:Gs},[4,this.prepareCreateItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=r.sent(),n)]))]}}))}))},t.prototype.prepareCreateItemShareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d=this;return T(this,(function(l){switch(l.label){case 0:return t=e.itemId,n=e.itemKeyId,r=e.tpId,i=e.tpSharedKeyId,a=e.accessRole,s=e.isDirectory,o=e.shareType,[4,this.keyGraph.getKey(n,(function(){return s?d.itemService.getDirectoryKeyId(t):d.itemService.getFileKeyId(t)}))];case 1:return c=l.sent(),[4,this.keyGraph.getKey(i,(function(){return d.getTpCurrentUserSharedKey(r).then((function(e){return e.sharedKey.id}))}))];case 2:return u=l.sent(),[4,this.keyGraph.wrapKey(u,c.jwk)];case 3:return p=l.sent(),[2,{input:{id:t,tpId:r,accessRole:a,keyId:c.id,wrappingKeyId:u.id,wrappedKey:p,shareType:o}}]}}))}))},t.prototype.updateDirectoryShare=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.updateDirectoryShareMutation(e))]}))}))},t.prototype.updateDirectoryShareMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:Qs,variables:this.prepareUpdateItemShareMutation(e)})]}))}))},t.prototype.updateFileShare=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.updateFileShareMutation(e))]}))}))},t.prototype.updateFileShareMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:Ws,variables:this.prepareUpdateItemShareMutation(e)})]}))}))},t.prototype.prepareUpdateItemShareMutation=function(e){return{input:{id:e.itemShareId,accessRole:e.accessRole}}},t.prototype.deleteDirectoryShare=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.deleteDirectoryShareMutation(e))]}))}))},t.prototype.deleteDirectoryShareMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:Vs,variables:{input:{id:e}}})]}))}))},t.prototype.deleteFileShare=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.deleteFileShareMutation(e))]}))}))},t.prototype.deleteFileShareMutation=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,new ze({mutation:Bs,variables:{input:{id:e}}})]}))}))},t.prototype.completeDetachedDirectoryShare=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.completeDetachedDirectoryShareMutation(e))]}))}))},t.prototype.completeDetachedDirectoryShareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return t=ze.bind,n={mutation:Zs},[4,this.prepareCompleteDetachedItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=r.sent(),n)]))]}}))}))},t.prototype.completeDetachedFileShare=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){return[2,this.mutate(this.completeDetachedFileShareMutation(e))]}))}))},t.prototype.completeDetachedFileShareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return T(this,(function(r){switch(r.label){case 0:return t=ze.bind,n={mutation:Hs},[4,this.prepareCompleteDetachedItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=r.sent(),n)]))]}}))}))},t.prototype.prepareCompleteDetachedItemShareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o=this;return T(this,(function(c){switch(c.label){case 0:return t=e.itemShareId,n=e.itemKeyId,r=e.isDirectory,[4,this.keyGraph.getKey(n,(function(){return r?o.itemService.getDirectoryKeyIdFromDirectoryShare(t):o.itemService.getFileKeyIdFromFileShare(t)}))];case 1:return i=c.sent(),a=this.keyService.currentRootKey,[4,this.keyGraph.wrapKey(a,i.jwk)];case 2:return s=c.sent(),[2,{input:{id:t,keyId:i.id,wrappingKeyId:a.id,wrappedKey:s}}]}}))}))},t.prototype.requestMkReshareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s;return T(this,(function(o){switch(o.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if((t=o.sent()).mkSharedKey)throw new Z("TP already has mkSharedKey");return n=this.keyService.currentMasterKey,[4,this.keyFactory.createPkcKey()];case 2:return r=o.sent(),[4,this.encryptionService.encryptToString(n.jwk,r.toJSON(!0))];case 3:return i=o.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 4:return a=o.sent(),[4,this.encryptionService.encryptToString(a.jwk,{pbk:r.toJSON()})];case 5:return s=o.sent(),[4,new ze({mutation:Ys,variables:{input:{tpId:e,masterKeyId:n.id,mkPbk:JSON.stringify(r.toJSON()),mkWrappedMkPrk:i,sharedKeyId:a.id,mkReshareRequestCipher:s}}})];case 6:return[2,o.sent()]}}))}))},t.prototype.respondMkReshare=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u,p,d;return T(this,(function(l){switch(l.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if(!(t=l.sent()).mkSharedKey)throw new Z("No access to the mkSharedKey so cannot reshare it with TP");return[4,this.keyGraph.getKey(t.sharedKey.id)];case 2:return n=l.sent(),[4,this.encryptionService.decrypt(n,t.mkReshareRequestCipher)];case 3:return r=l.sent(),[4,a.JWK.asKey(r.pbk)];case 4:return i=l.sent(),[4,this.keyGraph.getKey(t.mkSharedKey.id)];case 5:return s=l.sent(),o={mkSharedKey:{id:s.id,jwk:s.jwk.toJSON(!0)}},p=(u=this.encryptionService).encryptToString,d=[i],[4,this.encryptionService.encryptToString(n.jwk,o)];case 6:return[4,p.apply(u,d.concat([l.sent()]))];case 7:return c=l.sent(),[2,new ze({mutation:Xs,variables:{input:{tpId:e,mkSharedKeyId:s.id,mkReshareResponseCipher:c}}})]}}))}))},t.prototype.completeMkReshare=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u,p,d,l;return T(this,(function(h){switch(h.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:return t=h.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 2:return n=h.sent(),[4,this.keyGraph.getKey(t.mkPxk.id)];case 3:return r=h.sent(),o=(s=this.encryptionService).decrypt,c=[n],[4,this.encryptionService.decrypt(r,t.mkReshareResponseCipher)];case 4:return[4,o.apply(s,c.concat([h.sent()]))];case 5:return i=h.sent(),p={id:i.mkSharedKey.id},[4,a.JWK.asKey(i.mkSharedKey.jwk)];case 6:return p.jwk=h.sent(),u=p,d=this.keyService.currentMasterKey,[4,this.encryptionService.encryptToString(d.jwk,u.jwk.toJSON(!0))];case 7:return l=h.sent(),[2,new ze({mutation:zs,variables:{input:{tpId:e,masterKeyId:d.id,mkSharedKeyId:u.id,mkWrappedMkSharedKey:l}}})]}}))}))},t.prototype.getTpCurrentUserSharedKey=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:eo,variables:{id:e}})];case 1:return[2,t.sent().tp.currentUserSharedKey.userSharedKey]}}))}))},t}(Kt),e.TrustedPartyService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TrustedPartyService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(Pe),t.ɵɵinject(e.ItemService),t.ɵɵinject(Ke),t.ɵɵinject(ge),t.ɵɵinject(ve))},token:e.TrustedPartyService,providedIn:"root"}),e.TrustedPartyService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TrustedPartyService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:Pe},{type:e.ItemService},{type:Ke},{type:ge},{type:ve}]},e.TrustedPartyService=A([qe({ngZoneName:"ngZone"})],e.TrustedPartyService);var to=function(){function e(e){this.auth=e}return e.prototype.getPreferredMFA=function(){return M(this,void 0,void 0,(function(){var e;return T(this,(function(t){switch(t.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return e=t.sent(),[4,this.auth.getPreferredMFA(e)];case 2:return[2,t.sent()]}}))}))},e.prototype.setPreferredMFA=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t=n.sent(),[4,this.auth.setPreferredMFA(t,e)];case 2:return n.sent(),[2]}}))}))},e.prototype.setPhoneNumber=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t=n.sent(),[4,this.auth.updateUserAttributes(t,{phone_number:e})];case 2:return n.sent(),[2]}}))}))},e.prototype.getSMSCode=function(){return M(this,void 0,void 0,(function(){return T(this,(function(e){switch(e.label){case 0:return[4,this.auth.verifyCurrentUserAttribute("phone_number")];case 1:return e.sent(),[2]}}))}))},e.prototype.verifySMSCode=function(e){return M(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this.auth.verifyCurrentUserAttributeSubmit("phone_number",e)];case 1:return t.sent(),[2]}}))}))},e.prototype.getSoftwareToken=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i;return T(this,(function(a){switch(a.label){case 0:return[4,Promise.all([this.auth.currentAuthenticatedUser(),this.auth.currentUserInfo()])];case 1:return e=j.apply(void 0,[a.sent(),2]),t=e[0],n=e[1],[4,this.auth.setupTOTP(t)];case 2:if(r=a.sent(),!(i=n.attributes.email))throw new Q("No email associated with user.");return[2,{code:r,codeUri:"otpauth://totp/"+i+"?secret="+r+"&issuer=LifeReady"}]}}))}))},e.prototype.verifySoftwareToken=function(e){return M(this,void 0,void 0,(function(){var t;return T(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t=n.sent(),[4,this.auth.verifyTotpToken(t,e)];case 2:return n.sent(),[2]}}))}))},e}();to.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new to(t.ɵɵinject(s.AuthClass))},token:to,providedIn:"root"}),to.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],to.ctorParameters=function(){return[{type:s.AuthClass}]};var no,ro,io,ao=K.default(no||(no=_(["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"],["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"]))),so=K.default(ro||(ro=_(["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"],["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"]))),oo=K.default(io||(io=_(["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"],["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"]))),co=function(){function e(e){this.lrApollo=e}return e.prototype.requestUserDelete=function(){return M(this,void 0,void 0,(function(){return T(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:ao,variables:{input:{}}})];case 1:return[2,e.sent().requestUserDelete.userDelete]}}))}))},e.prototype.cancelUserDelete=function(){return M(this,void 0,void 0,(function(){return T(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:so,variables:{input:{}}})];case 1:return[2,e.sent().cancelUserDelete.id]}}))}))},e.prototype.loginHistory=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=null),M(this,void 0,void 0,(function(){return T(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:oo,variables:{first:e,after:t}})];case 1:return[2,n.sent().loginHistory]}}))}))},e}();co.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new co(t.ɵɵinject(ke))},token:co,providedIn:"root"}),co.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],co.ctorParameters=function(){return[{type:ke}]},e.ApiContactCard=hn,e.ApiCurrentUser=ln,e.ApproveScenarioClaimMutation=za,e.ApproveTpPasswordResetRequestMutation=wr,e.ArchiveDirectoryMutation=yi,e.ArchiveFileMutation=fi,e.BeginDeleteChildItemLinksWindowMutation=Ci,e.CancelKeyExchangeMutation=nn,e.CancelScenarioClaimMutation=Ya,e.CancelTpPasswordResetRequestMutation=Sr,e.CancelUserDeleteMutation=so,e.ChangeDirectoryParentsMutation=gi,e.ChangeFileParentsMutation=Si,e.CompleteKeyExchangeOtkMutation=on,e.CompleteTpPasswordResetRequestMutation=Ir,e.ContactCardAddress=fn,e.ContactCardName=yn,e.ContactCardsQuery=$n,e.CreateContactCardMutation=Nn,e.CreateDirectoryMutation=oi,e.CreateFileMutation=pi,e.CreateLbopQuery=Qi,e.CreateScenarioClaimMutation=Ha,e.CreateScenarioMutation=Va,e.CreateTpAssemblyKeyChallengeMutation=Cr,e.CreateTpPasswordResetMutation=Pr,e.CurrentUserKey=dn,e.CurrentUserQuery=jn,e.CurrentUserSharedKeyQuery2=cn,e.DebugExpireScenarioClaimMutation=ts,e.DebugExpireTpPasswordResetRequestMutation=ns,e.DeclineKeyExchangeMutation=rn,e.DefaultProcessorOptions=Je,e.DeleteDirectoryMutation=ui,e.DeleteFileMutation=hi,e.DeleteLbopQuery=Wi,e.DeleteScenarioMutation=Za,e.DeleteTpPasswordResetMutation=kr,e.DirectoryQuery=Ue,e.ERROR_SOURCE=Li,e.Features=pn,e.FetchKeyGraphField=Le,e.FileUploadService=Lr,e.GetOwnedContactCardKeyIdsQuery=ms,e.GetReceivedContactCardKeyIdQuery=gs,e.IdleService=Dt,e.InitiateKeyExchangeOtkMutation=an,e.KC_CONFIG=Se,e.KcAuthException=G,e.KcBadArgumentException=Q,e.KcBadLogicException=W,e.KcBadRequestException=V,e.KcBadSignatureException=B,e.KcBadStateException=Z,e.KcBadTimeSyncException=H,e.KcCodeMismatchException=Y,e.KcConcurrentAccessException=X,e.KcEncryptionException=z,e.KcError=q,e.KcException=J,e.KcInternalErrorException=ee,e.KcLockedException=te,e.KcNotFoundException=ne,e.KcSuspiciousOperationException=re,e.KcUnsupportedException=ie,e.KeyExchangeFields=Yt,e.KeyExchangeQuery2=en,e.KeyExchangeTokenQuery2=tn,e.KeyExchangesQuery2=zt,e.KeyGraphField=$e,e.KeyGraphFragment=Fe,e.LbopQuery=Bi,e.LbopService=Hi,e.LbopsQuery=Zi,e.LifeReadyModule=Yi,e.LoginHistoryQuery=oo,e.LrApolloService=ke,e.LrGraphQLService=e.ɵg,e.LrMergedMutation=tt,e.LrMutation=ze,e.LrMutationBase=Xe,e.LrService=Kt,e.MainContactCardFields=mn,e.MainContactCardPlainFields=gn,e.MainContactCardProperty=vn,e.OwnerPlainDataJson=$r,e.PasswordCheck=Vn,e.PasswordService=Bn,e.PersistService=we,e.PreCompleteTpPasswordResetRequestMutation=br,e.ProfileDetailsService=Ea,e.ProfileService=Ln,e.ReceiveScenarioClaimMutation=es,e.RegisterResult=Oa,e.RegisterService=Da,e.RejectScenarioClaimMutation=Xa,e.RejectTpPasswordResetRequestMutation=Kr,e.RequestUserDeleteMutation=ao,e.RespondKeyExchangeOtkMutation=sn,e.RevertFileMutation=li,e.ServerTimeQuery=le,e.SetDirectoryConfidentialMutation=wi,e.SetFileConfidentialMutation=Ii,e.SharedTrustedPartyDetails=Cn,e.SharedVaultFeature=In,e.TPFeatures=bn,e.TempDirectoryQuery=bi,e.TimeService=he,e.TrustedPartiesQuery=Fn,e.TrustedParty=Kn,e.TrustedPartyDetails=Sn,e.TrustedPartyProperties=On,e.TwoFactorService=to,e.UnarchiveDirectoryMutation=vi,e.UnarchiveFileMutation=mi,e.UpdateContactCardMutation=_n,e.UpdateDirectoryMutation=ci,e.UpdateFileMutation=di,e.UpdateLbopQuery=Vi,e.UpdateOwnedContactCardMutation=fs,e.UpdateReceivedContactCardMutation=vs,e.UpdateScenarioMutation=Ba,e.UpdateTpPasswordResetMutation=Rr,e.UserService=co,e.UserSharedKeyFields=Xt,e.WebCryptoService=me,e.awsFetch=Rt,e.configureAmplifyAuth=Et,e.configureApollo=Ie,e.fragmentSpreadAstSelection=Ye,e.gqlTyped=Oe,e.handleApolloError=U,e.handleCognitoCallback=function(e){return new Promise((function(t,n){return e((function(e,r){return e?n(e):t(r)}))}))},e.httpOptions=be,e.mapEdges=Pt,e.processConnection=Ge,e.throwClaimIdMismatch=os,e.throwClaimNotApproved=cs,e.ɵa=Pe,e.ɵb=ve,e.ɵc=Ke,e.ɵd=ge,e.ɵe=Kt,e.ɵf=qe,e.ɵh=xt,e.ɵj=nr,e.ɵk=Pn,e.ɵl=Rn,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("apollo-angular"),require("@dagrejs/graphlib"),require("lodash"),require("node-jose"),require("@aws-amplify/auth/lib-esm/Auth"),require("graphql-tag"),require("moment"),require("@apollo/client/core"),require("@apollo/client/link/context"),require("@apollo/client/link/retry"),require("ngx-cookie-service"),require("graphql/language/printer"),require("@angular/common/http"),require("@aws-amplify/core"),require("@ng-idle/core"),require("@ng-idle/keepalive"),require("slip39"),require("@aws-amplify/auth")):"function"==typeof define&&define.amd?define("@lifeready/core",["exports","@angular/core","apollo-angular","@dagrejs/graphlib","lodash","node-jose","@aws-amplify/auth/lib-esm/Auth","graphql-tag","moment","@apollo/client/core","@apollo/client/link/context","@apollo/client/link/retry","ngx-cookie-service","graphql/language/printer","@angular/common/http","@aws-amplify/core","@ng-idle/core","@ng-idle/keepalive","slip39","@aws-amplify/auth"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).lifeready=e.lifeready||{},e.lifeready.core={}),e.ng.core,e["apollo-angular"],e["@dagrejs/graphlib"],e.lodash,e["node-jose"],e["@aws-amplify/auth/lib-esm/Auth"],e["graphql-tag"],e.moment,e["@apollo/client/core"],e["@apollo/client/link/context"],e["@apollo/client/link/retry"],e["ngx-cookie-service"],e["graphql/language/printer"],e.ng.common.http,e["@aws-amplify/core"],e["@ng-idle/core"],e["@ng-idle/keepalive"],e.slip39,e["@aws-amplify/auth"])}(this,(function(e,t,n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g,S){"use strict";function C(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function b(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var I=C(r),w=C(i),K=C(o),P=b(c),k=C(S),R=function(e,t){return(R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function E(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}R(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function D(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function A(e,t,n,r){var i,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}function M(e,t,n,r){return new(n||(n=Promise))((function(i,a){function s(e){try{c(r.next(e))}catch(e){a(e)}}function o(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}c((r=r.apply(e,t||[])).next())}))}function O(e,t){var n,r,i,a,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}Object.create;function T(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function j(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return s}function N(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(j(arguments[t]));return e}function F(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var _,$,L;Object.create;function U(e){if(e&&e.length){var t=e.map((function(e){return new q({code:e.extensions&&e.extensions.code,source:e.extensions&&e.extensions.source,message:e.message,debug:{locations:e.locations,path:e.path}})}));throw new(J.bind.apply(J,N([void 0],t)))}}!function(e){e.Key="key",e.PassKey="passKey"}(_||(_={})),function(e){e.KeyLink="keyLink",e.PassKeyLink="passKeyLink"}($||($={})),function(e){e.JSON="JSON",e.UINT_8_ARRAY="UINT_8_ARRAY"}(L||(L={}));var x,q=function(e){this._type="KcError",this.code=e.code,this.source=e.source,this.message=e.message,this.debug=e.debug},J=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._type="KcException",this.errors=e}return e.prototype.toString=function(){return this.errors.map((function(e){return JSON.stringify(e,null,2)}))},e}();(x=e.KcErrorCode||(e.KcErrorCode={})).ARCHIVED_RESOURCE="ARCHIVED_RESOURCE",x.BAD_ARGUMENT="BAD_ARGUMENT",x.BAD_SIGNATURE="BAD_SIGNATURE",x.BAD_STATE="BAD_STATE",x.CHANGED_PERMISSIONS="CHANGED_PERMISSIONS",x.CONCURRENT_ACCESS="CONCURRENT_ACCESS",x.CONFIG_ERROR="CONFIG_ERROR",x.CYCLE_DETECTED="CYCLE_DETECTED",x.EXPIRED="EXPIRED",x.INVALID_TOKEN="INVALID_TOKEN",x.INTERNAL_ERROR="INTERNAL_ERROR",x.JSON_DECODE_ERROR="JSON_DECODE_ERROR",x.KEY_MISMATCH="KEY_MISMATCH",x.LIMIT_REACHED="LIMIT_REACHED",x.LOCKED="LOCKED",x.LOGIC_ERROR="LOGIC_ERROR",x.LR_DEBUG_ONLY="LR_DEBUG_ONLY",x.MIN_DELAY="MIN_DELAY",x.MISSING_FIELD="MISSING_FIELD",x.MISSING_FIELD_VALUE="MISSING_FIELD_VALUE",x.MISSING_QUERY_PARAM="MISSING_QUERY_PARAM",x.NOT_IMPLEMENTED="NOT_IMPLEMENTED",x.OBJECT_DOES_NOT_EXIST="OBJECT_DOES_NOT_EXIST",x.OBJECT_EXISTS="OBJECT_EXISTS",x.RANGE_ERROR="RANGE_ERROR",x.TRUSTED_PARTY_NOT_FOUND="TRUSTED_PARTY_NOT_FOUND",x.UNAUTHENTICATED_USER="UNAUTHENTICATED_USER",x.USER_NOT_FOUND="USER_NOT_FOUND",x.VERSION_MISMATCH="VERSION_MISMATCH",x.WRONG_PERMISSIONS="WRONG_PERMISSIONS",x.AUTH="AUTH",x.BAD_LOGIC="BAD_LOGIC",x.BAD_REQUEST="BAD_REQUEST",x.BAD_TIME_SYNC="BAD_TIME_SYNC",x.CODE_MISMATCH="CODE_MISMATCH",x.ENCRYPTION="ENCRYPTION",x.NOT_FOUND="NOT_FOUND",x.SUSPICIOUS_OPERATION="SUSPICIOUS_OPERATION",x.UNSUPPORTED="UNSUPPORTED";var G=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.AUTH,message:n}))||this}return E(n,t),n}(J),Q=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.BAD_ARGUMENT,message:n}))||this}return E(n,t),n}(J),W=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.BAD_LOGIC,message:n}))||this}return E(n,t),n}(J),V=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.BAD_REQUEST,message:n}))||this}return E(n,t),n}(J),B=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.BAD_SIGNATURE,message:n}))||this}return E(n,t),n}(J),Z=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.BAD_STATE,message:n}))||this}return E(n,t),n}(J),H=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.BAD_TIME_SYNC,message:n}))||this}return E(n,t),n}(J),Y=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.CODE_MISMATCH,message:n}))||this}return E(n,t),n}(J),X=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.CONCURRENT_ACCESS,message:n}))||this}return E(n,t),n}(J),z=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.ENCRYPTION,message:n}))||this}return E(n,t),n}(J),ee=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.INTERNAL_ERROR,message:n}))||this}return E(n,t),n}(J),te=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.LOCKED,message:n}))||this}return E(n,t),n}(J),ne=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.NOT_FOUND,message:n}))||this}return E(n,t),n}(J),re=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.SUSPICIOUS_OPERATION,message:n}))||this}return E(n,t),n}(J),ie=function(t){function n(n){return t.call(this,new q({code:e.KcErrorCode.UNSUPPORTED,message:n}))||this}return E(n,t),n}(J);function ae(e){if(!Array.isArray(e))throw new Error("not array");return e.some((function(e){return null==e?void 0:e.then}))?Promise.all(e):e}function se(e,t){var n,r,i={};try{for(var a=T(Object.keys(e).entries()),s=a.next();!s.done;s=a.next()){var o=j(s.value,2),c=o[0];i[o[1]]=t[c]}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i}function oe(e,t){var n=ae(Object.entries(e).map((function(n){var r=j(n,2),i=r[0],a=r[1];return t(a,i,e)})));return n.then?n.then((function(t){return se(e,t)})):se(e,n)}function ce(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e.currentSession()];case 1:return[2,t.sent().getAccessToken().getJwtToken()];case 2:return t.sent(),[2,""];case 3:return[2]}}))}))}var ue,pe,de=P,le=K.default(ue||(ue=F(["\n query {\n serverTime {\n timestamp\n }\n }\n"],["\n query {\n serverTime {\n timestamp\n }\n }\n"]))),he=function(){function e(e,t){this.auth=e,this.apollo=t,this.VERIFY_ENABLED=!0,this.MAX_DIFF_MSEC=de.duration({seconds:30}).asMilliseconds(),this.offsetMs=null,this.verified=!1}return e.prototype.verifyCognito=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i;return O(this,(function(a){switch(a.label){case 0:return[4,ce(this.auth)];case 1:return(e=a.sent())?[4,fetch("https://cognito-idp.ap-southeast-2.amazonaws.com/",{method:"POST",mode:"cors",cache:"no-cache",headers:{"x-amz-target":"AWSCognitoIdentityProviderService.GetUser","x-amz-user-agent":"aws-amplify/0.1.x js","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify({AccessToken:e})})]:[2];case 2:if(t=a.sent(),n=Date.now(),r=de(t.headers.get("Date")).valueOf(),i=n+this.offsetMs,Math.abs(i-r)>this.MAX_DIFF_MSEC)throw new H("Server time does not match independent source. ServerTime: "+i+", Cognito time: "+r);return this.verified=!0,[2]}}))}))},e.prototype.refresh=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i;return O(this,(function(a){switch(a.label){case 0:return e=Date.now(),[4,this.apollo.query({query:le}).toPromise()];case 1:return t=a.sent(),n=Date.now(),U(t.errors),r=parseInt(t.data.serverTime.timestamp,10),i=n-e,this.offsetMs=Math.round(r-(e+i/2)),this.VERIFY_ENABLED?[4,this.verifyCognito()]:[3,3];case 2:a.sent(),a.label=3;case 3:return[2]}}))}))},e.prototype.serverNow=function(){return M(this,void 0,void 0,(function(){var e,t;return O(this,(function(n){switch(n.label){case 0:return e=!1,null===this.offsetMs&&(e=!0),this.VERIFY_ENABLED?(t=!this.verified)?[4,ce(this.auth)]:[3,2]:[3,3];case 1:t=n.sent(),n.label=2;case 2:t&&(e=!0),n.label=3;case 3:return e?[4,this.refresh()]:[3,5];case 4:n.sent(),n.label=5;case 5:return[2,Date.now()+this.offsetMs]}}))}))},e.prototype.now=function(){return null===this.offsetMs?(console.error("Server time offset not known. You must await serverNow() first. Returning local clock instead."),Date.now()):Date.now()+this.offsetMs},e.prototype.date=function(){return new Date(this.now())},e}();he.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new he(t.ɵɵinject(s.AuthClass),t.ɵɵinject(n.Apollo))},token:he,providedIn:"root"}),he.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],he.ctorParameters=function(){return[{type:s.AuthClass},{type:n.Apollo}]},function(e){e.JSON="JSON",e.COMPACT="COMPACT"}(pe||(pe={}));var ye={payloadType:L.JSON,returnOnlyPayload:!0},fe={payloadType:L.JSON,returnOnlyPayload:!0,serializations:[pe.JSON]};var ve=function(){function e(e){this.timeService=e}return e.prototype.decrypt=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i;return O(this,(function(s){switch(s.label){case 0:if(r={algorithms:["dir","A*GCM","RSA-OAEP-*"]},n=Object.assign(Object.assign({},fe),n),e.jwk&&(e=e.jwk),"string"==typeof t&&n.serializations.includes(pe.JSON))try{t=JSON.parse(t)}catch(e){if(!n.serializations.includes(pe.COMPACT))throw e;console.log("Not a JSON-formatted JWE, it maybe compact serialisation format.")}return[4,a.JWE.createDecrypt(e,r).decrypt(t)];case 1:return(i=s.sent()).payload=this.decodePayload(n.payloadType,i.payload),n.returnOnlyPayload?[2,i.payload]:[2,i]}}))}))},e.prototype.encryptToString=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return O(this,(function(i){switch(i.label){case 0:return r=(n=JSON).stringify,[4,this.encrypt(e,t)];case 1:return[2,r.apply(n,[i.sent()])]}}))}))},e.prototype.encrypt=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,s;return O(this,(function(o){switch(o.label){case 0:if(null==t)throw new Error("Encrypting null/undefined content.");return t instanceof ArrayBuffer||(t=(new TextEncoder).encode(JSON.stringify(t))),r=(n=a.JWE).createEncrypt,i={contentAlg:"A256GCM"},s={},[4,this.timeService.serverNow()];case 1:return[2,r.apply(n,[(i.fields=(s.timestamp=o.sent(),s),i),e]).update(t).final()]}}))}))},e.prototype.sign=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,s,o;return O(this,(function(c){switch(c.label){case 0:return i=(r=a.JWS).createSign,s={},o={},[4,this.timeService.serverNow()];case 1:return n=i.apply(r,[(s.fields=(o.timestamp=c.sent(),o),s),e]),t instanceof Buffer?n.update(t):n.update(JSON.stringify(t),"utf8"),[2,n.final()]}}))}))},e.prototype.signToString=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return O(this,(function(i){switch(i.label){case 0:return r=(n=JSON).stringify,[4,this.sign(e,t)];case 1:return[2,r.apply(n,[i.sent()])]}}))}))},e.prototype.verify=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,s;return O(this,(function(o){switch(o.label){case 0:r={algorithms:["RS*"]},n=Object.assign(Object.assign({},ye),n),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,a.JWS.createVerify(e,r).verify(t)];case 2:return(i=o.sent()).payload=this.decodePayload(n.payloadType,i.payload),n.returnOnlyPayload?[2,i.payload]:[2,i];case 3:throw s=o.sent(),new B("Bad signature: "+s);case 4:return[2]}}))}))},e.prototype.encryptThenSign=function(e,t){var n=e.key,r=e.sigPrk;return M(this,void 0,void 0,(function(){var e,i,a,s;return O(this,(function(o){switch(o.label){case 0:return a=(i=JSON).stringify,[4,this.encrypt(n,t)];case 1:return e=a.apply(i,[o.sent()]),[4,this.sign(r,e)];case 2:return delete(s=o.sent()).payload,[2,{cipher:e,sig:JSON.stringify(s)}]}}))}))},e.prototype.decodePayload=function(e,t){switch(e){case L.JSON:return JSON.parse((new TextDecoder).decode(t));case L.UINT_8_ARRAY:return t;default:throw new Q("Unknown payloadType: "+e)}},e}();ve.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ve(t.ɵɵinject(he))},token:ve,providedIn:"root"}),ve.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ve.ctorParameters=function(){return[{type:he}]};var me=function(){function e(){this.kcCrypto=window.crypto}return e.prototype.toHex=function(e){return Array.from(new Uint8Array(e)).map((function(e){return e.toString(16).padStart(2,"0")})).join("")},e.prototype.stringDigest=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return O(this,(function(a){switch(a.label){case 0:return n=new TextEncoder,r=n.encode(t),[4,this.kcCrypto.subtle.digest(e,r)];case 1:return i=a.sent(),[2,this.toHex(i)]}}))}))},e}();me.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new me},token:me,providedIn:"root"}),me.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}];var ge=function(){function e(e){this.webCryptoService=e,this.MIN_PASS_IDP_PBKDF_ITER=1e5,this.MIN_PASS_KEY_PBKDF_ITER=1e5,this.MIN_LBOP_KEY_PBKDF_ITER=1e5,this.DEFAULT_PASS_IDP_PBKDF_ITER=this.MIN_PASS_IDP_PBKDF_ITER,this.DEFAULT_PASS_KEY_PBKDF_ITER=this.MIN_PASS_KEY_PBKDF_ITER,this.DEFAULT_LBOP_KEY_PBKDF_ITER=this.MIN_LBOP_KEY_PBKDF_ITER,this.kcCrypto=this.webCryptoService.kcCrypto}return e.asKey=function(e,t,n){return a.JWK.asKey(e,t,n)},e.prototype.randomString=function(e){if(e<=0)throw new Q("digits <= 0");var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint32Array(e);return this.kcCrypto.getRandomValues(n),n=n.map((function(e){return t.charCodeAt(e%t.length)})),String.fromCharCode.apply(null,n)},e.prototype.randomDigitsNoZeros=function(e){return this.randomChoices([1,2,3,4,5,6,7,8,9],e).join("")},e.prototype.randomChoices=function(e,t){if(e.length<=1)throw new Q("array.length <= 0");if(t<=0)throw new Q("chooseN <= 0");var n=new Uint32Array(t);this.kcCrypto.getRandomValues(n);var r=[];return n.forEach((function(t){return r.push(e[t%e.length])})),r},e.prototype.createSalt=function(){return this.randomString(16)},e.prototype.createKey=function(){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t)];case 2:return delete(n=r.sent()).ext,delete n.key_ops,[2,e.asKey(n)]}}))}))},e.prototype.createSignKey=function(){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"HMAC",hash:{name:"SHA-512"}},!0,["sign","verify"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.createPkcKey=function(){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["encrypt","decrypt"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t.privateKey)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.createPkcSignKey=function(){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t.privateKey)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.importPassword=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){return t=new TextEncoder,[2,this.kcCrypto.subtle.importKey("raw",t.encode(e),"PBKDF2",!1,["deriveKey"])]}))}))},e.prototype.deriveKey=function(t){var n=t.password,r=t.salt,i=t.iterations,a=t.kid;return M(this,void 0,void 0,(function(){var t,s;return O(this,(function(o){switch(o.label){case 0:return[4,this.kcCrypto.subtle.deriveKey({name:"PBKDF2",salt:(new TextEncoder).encode(r),iterations:i,hash:"SHA-256"},n,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 1:return t=o.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t)];case 2:return s=o.sent(),a&&(s.kid=a),[4,e.asKey(s)];case 3:return[2,{jwk:o.sent()}]}}))}))},e.prototype.derivePassIdp=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){if(e.iterations<this.MIN_PASS_IDP_PBKDF_ITER)throw new re("The number of PassIdp key derivation iterations sent from the server ("+e.iterations+") is lower than the minimum ("+this.MIN_PASS_IDP_PBKDF_ITER+")");return[2,this.deriveKey(e)]}))}))},e.prototype.derivePassKey=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){if(e.iterations<this.MIN_PASS_KEY_PBKDF_ITER)throw new re("The number of PassKey key derivation iterations sent from the server("+e.iterations+") is lower than the minimum("+this.MIN_PASS_KEY_PBKDF_ITER+")");return[2,this.deriveKey(e)]}))}))},e.prototype.deriveLbopKey=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){if(e.iterations<this.MIN_LBOP_KEY_PBKDF_ITER)throw new re("The number of LbopKey key derivation iterations sent from the server("+e.iterations+") is lower than the minimum("+this.MIN_LBOP_KEY_PBKDF_ITER+")");return[2,this.deriveKey(e)]}))}))},e.prototype.createKid=function(){return M(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.createKey()];case 1:return[2,e.sent().kid]}}))}))},e.prototype.createPassIdpParams=function(){return M(this,void 0,void 0,(function(){return O(this,(function(e){return[2,{salt:this.createSalt(),iterations:this.DEFAULT_PASS_IDP_PBKDF_ITER}]}))}))},e.prototype.createPassKeyParams=function(){return M(this,void 0,void 0,(function(){var e;return O(this,(function(t){switch(t.label){case 0:return e={salt:this.createSalt()},[4,this.createKid()];case 1:return[2,(e.kid=t.sent(),e.iterations=this.DEFAULT_PASS_KEY_PBKDF_ITER,e)]}}))}))},e.prototype.createLbopKeyParams=function(){return M(this,void 0,void 0,(function(){var e;return O(this,(function(t){switch(t.label){case 0:return e={salt:this.createSalt()},[4,this.createKid()];case 1:return[2,(e.kid=t.sent(),e.iterations=this.DEFAULT_PASS_KEY_PBKDF_ITER,e)]}}))}))},e}();ge.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ge(t.ɵɵinject(me))},token:ge,providedIn:"root"}),ge.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ge.ctorParameters=function(){return[{type:me}]};var Se=new t.InjectionToken("KC_CONFIG"),Ce=[e.KcErrorCode.CONCURRENT_ACCESS];function be(e,t){var n;return M(this,void 0,void 0,(function(){var r,i;return O(this,(function(a){switch(a.label){case 0:return[4,ce(e)];case 1:return r=a.sent(),i=null===(n=t.debug)||void 0===n?void 0:n.username,[2,{withCredentials:!0,headers:Object.assign(Object.assign({},r&&{authorization:"Bearer "+r}),i&&{"x-kc-dev-user":i})}]}}))}))}var Ie=function(e,t){var n=p.setContext((function(n,r){var i=r.headers;return M(void 0,void 0,void 0,(function(){var n;return O(this,(function(r){switch(r.label){case 0:return[4,be(t,e)];case 1:return n=r.sent(),[2,Object.assign(Object.assign({},n),{headers:Object.assign(Object.assign({},i),n.headers)})]}}))}))})),r=new d.RetryLink({delay:{initial:300,max:1/0,jitter:!0},attempts:{max:3,retryIf:function(e,t){return!!(e instanceof i&&e.errors.some((function(e){var t;return Ce.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})))}}}),i=function(e){function t(t){var n=e.call(this,t.map((function(e){return e.message})).join(", "))||this;return n.errors=t,n}return E(t,e),t}(Error),a=new u.ApolloLink((function(e,t){return t(e).map((function(e){if(e&&e.errors&&e.errors.filter((function(e){var t;return Ce.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})).length>0)throw new i(e.errors);return e}))})),s=u.createHttpLink({uri:e.apolloUrl,credentials:"include"});return Object.assign({link:u.from([r,a,n,s]),cache:new u.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"all"},query:{fetchPolicy:"no-cache",errorPolicy:"all"},mutate:{fetchPolicy:"no-cache",errorPolicy:"all"}}},e.apolloConfig)},we=function(){function e(e,n,r,i){this.keyFactory=e,this.cookieService=n,this.encryptionService=r,this.injector=i,this.KEY_PREFIX="lrSession-",this.cookieSecure=!0,this.serverSessionEncryptionKey=null,t.isDevMode()&&this.setCookieSecure(!1)}return e.prototype.setServerSessionEncryptionKey=function(e){this.serverSessionEncryptionKey=e},e.prototype.clearServerSessionEncryptionKey=function(){this.serverSessionEncryptionKey=null},e.prototype.getCookieParams=function(){return{path:"/",domain:null,secure:this.cookieSecure,sameSite:"Lax"}},e.prototype.clear=function(){var e=this;Object.keys(this.cookieService.getAll()).forEach((function(t){t.startsWith(e.KEY_PREFIX)&&e.deletePrefixedName(t)})),Object.keys(localStorage).forEach((function(t){t.startsWith(e.KEY_PREFIX)&&e.deletePrefixedName(t)}))},e.prototype.setCookieSecure=function(e){if(this.cookieSecure=e,!e){if(!t.isDevMode())throw new Q("Can not set PersistService cookie secure flag to false in production mode.");console.warn("The cookie secure flag in persistService has been set to false, set it to true in production mode")}},e.prototype.prefixName=function(e){return this.KEY_PREFIX+e},e.prototype.delete=function(e){this.deletePrefixedName(this.prefixName(e))},e.prototype.deletePrefixedName=function(e){var t=this.getCookieParams();this.cookieService.delete(e,t.path,t.domain,t.secure,t.sameSite),localStorage.removeItem(e)},e.prototype.set=function(e){var t=e.name,n=e.value,r=e.serverSession,i=e.expiry;return M(this,void 0,void 0,(function(){var e,a,s,o,c,u,p;return O(this,(function(d){switch(d.label){case 0:return e=this.prefixName(t),r?(s={serverSession:!0},[4,this.encryptionService.encryptToString(this.serverSessionEncryptionKey,n)]):[3,2];case 1:return s.data=d.sent(),a=s,[3,3];case 2:a={data:n},d.label=3;case 3:return i?[4,this.keyFactory.createKey()]:[3,6];case 4:return o=d.sent(),a.expiry=i.toISOString(),c=a,[4,this.encryptionService.encryptToString(o,a.data)];case 5:c.data=d.sent(),u={key:o.toJSON(!0)},p=this.getCookieParams(),this.cookieService.set(e,JSON.stringify(u),i,p.path,p.domain,p.secure,p.sameSite),d.label=6;case 6:return localStorage.setItem(e,JSON.stringify(a)),[2]}}))}))},e.prototype.get=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return O(this,(function(i){switch(i.label){case 0:t=this.prefixName(e),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.getImpl(t)];case 2:return null==(n=i.sent())&&this.deletePrefixedName(t),[2,n];case 3:throw r=i.sent(),this.deletePrefixedName(t),r;case 4:return[2]}}))}))},e.prototype.getImpl=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s;return O(this,(function(o){switch(o.label){case 0:return(t=localStorage.getItem(e))?(n=JSON.parse(t)).expiry?(i=this.cookieService.get(e))?(a=JSON.parse(i),[4,ge.asKey(a.key)]):(console.log("No cookie."),[2,null]):[3,3]:[2,null];case 1:return s=o.sent(),[4,this.encryptionService.decrypt(s,n.data)];case 2:return r=o.sent(),[3,4];case 3:r=n.data,o.label=4;case 4:return n.serverSession?[4,this.encryptionService.decrypt(this.serverSessionEncryptionKey,r)]:[3,6];case 5:r=o.sent(),o.label=6;case 6:return[2,r]}}))}))},e}();we.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new we(t.ɵɵinject(ge),t.ɵɵinject(l.CookieService),t.ɵɵinject(ve),t.ɵɵinject(t.INJECTOR))},token:we,providedIn:"root"}),we.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],we.ctorParameters=function(){return[{type:ge},{type:l.CookieService},{type:ve},{type:t.Injector}]};var Ke=function(){function e(e,t){this.config=e,this.persistService=t,this.STORE_MASTER_KEY="masterKey",this.MIN_PASS_IDP_PBKDF_ITER=1e5,this.MIN_PASS_KEY_PBKDF_ITER=1e5,this.MIN_LBOP_KEY_PBKDF_ITER=1e5,this.DEFAULT_PASS_IDP_PBKDF_ITER=this.MIN_PASS_IDP_PBKDF_ITER,this.DEFAULT_PASS_KEY_PBKDF_ITER=this.MIN_PASS_KEY_PBKDF_ITER,this.DEFAULT_LBOP_KEY_PBKDF_ITER=this.MIN_LBOP_KEY_PBKDF_ITER,this.resetKeys()}return e.prototype.resetKeys=function(){this.keys=null,this.masterKey=null},e.prototype.purgeKeys=function(){this.resetKeys(),this.persistService.clear()},e.prototype.setKeys=function(e){this.keys=e},Object.defineProperty(e.prototype,"currentPassKey",{get:function(){return this.keys.passKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentMasterKey",{get:function(){return this.keys.masterKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentRootKey",{get:function(){return this.keys.rootKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentPxk",{get:function(){return this.keys.pxk},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentSigPxk",{get:function(){return this.keys.sigPxk},enumerable:!1,configurable:!0}),e.prototype.expiresAfter=function(e){return new Date(Date.now()+1e3*e)},e.prototype.persistMasterKey=function(e,t){return M(this,void 0,void 0,(function(){var n;return O(this,(function(r){switch(r.label){case 0:return n={id:e.id,jwk:e.jwk.toJSON(!0)},this.masterKey=e,[4,this.persistService.set({name:this.STORE_MASTER_KEY,value:n,expiry:this.expiresAfter(t),serverSession:!this.config.disableSessionEncryptionKey})];case 1:return r.sent(),[2]}}))}))},e.prototype.setMasterKeyExpiresAfterSeconds=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.persistService.get(this.STORE_MASTER_KEY)];case 1:if(null==(t=n.sent()))throw new ne("Can not find masterKey in persisted storage using name: "+this.STORE_MASTER_KEY);return[4,this.persistService.set({name:this.STORE_MASTER_KEY,value:t,expiry:this.expiresAfter(e),serverSession:!this.config.disableSessionEncryptionKey})];case 2:return n.sent(),[2]}}))}))},e.prototype.loadMasterKey=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return this.masterKey?[3,3]:[4,this.persistService.get(this.STORE_MASTER_KEY)];case 1:if(!(t=r.sent()))throw new ne("Could not find masterKey in persisted storage");if(t.id!==e)throw new ne("masterKeyId "+t.id+" in persisted storage does not match the one requested "+e);return n=t,[4,ge.asKey(t.jwk)];case 2:n.jwk=r.sent(),this.masterKey=t,r.label=3;case 3:return[2,this.masterKey]}}))}))},e}();Ke.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ke(t.ɵɵinject(Se),t.ɵɵinject(we))},token:Ke,providedIn:"root"}),Ke.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ke.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:we}]};var Pe=function(){function e(e,t,n){this.encryptionService=e,this.keyService=t,this.keyFactory=n,this.purgeKeys()}return e.prototype.purgeKeys=function(){this.graph=new r.Graph},e.prototype.populateKeys=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return O(this,(function(i){switch(i.label){case 0:return n=(t=this.keyService).setKeys,r={passKey:e.passKey},[4,this.keyService.loadMasterKey(e.masterKey.id)];case 1:return r.masterKey=i.sent(),[4,this.unwrapKey(e.masterKey.id,e.rootKey.id)];case 2:return r.rootKey=i.sent(),[4,this.unwrapKey(e.masterKey.id,e.pxk.id)];case 3:return r.pxk=i.sent(),[4,this.unwrapKey(e.masterKey.id,e.sigPxk.id)];case 4:return n.apply(t,[(r.sigPxk=i.sent(),r)]),[2]}}))}))},e.prototype.hasKey=function(e){return!!this.graph.node(e)},e.prototype.getNode=function(e,t){var n=this.graph.node(e);if(!n)throw new ne("Key graphs does not contain key id: "+e);if(n.type!==t)throw new Z("Key with id "+e+" is not of type "+t);return n.data},e.prototype.key=function(e){return this.getNode(e,_.Key)},e.prototype.passKey=function(e){return this.getNode(e,_.PassKey)},e.prototype.addKeys=function(e){var t,n,r,i,a,s;if(e.keys)try{for(var o=T(e.keys),c=o.next();!c.done;c=o.next()){var u=c.value;if(!this.graph.hasNode(u.id)){var p={type:_.Key,data:w.default.cloneDeep(u)};this.graph.setNode(u.id,p)}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}if(e.keyLinks)try{for(var d=T(e.keyLinks),l=d.next();!l.done;l=d.next()){var h=l.value;if(!this.graph.hasEdge(h.wrappingKeyId,h.keyId)){var y={type:$.KeyLink,data:w.default.cloneDeep(h)};this.graph.setEdge(h.wrappingKeyId,h.keyId,y)}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}if(e.passKeyLinks)try{for(var f=T(e.passKeyLinks),v=f.next();!v.done;v=f.next()){var m=v.value;if(!this.graph.hasEdge(m.passKeyId,m.keyId)){y={type:$.PassKeyLink,data:w.default.cloneDeep(m)};this.graph.setEdge(m.passKeyId,m.keyId,y)}}}catch(e){a={error:e}}finally{try{v&&!v.done&&(s=f.return)&&s.call(f)}finally{if(a)throw a.error}}},e.prototype.tracePath=function(e,t){var n=[],r=t;if(!e[r].predecessor)return null;for(;e[r].predecessor;){var i=e[r].predecessor;n.push(this.graph.edge(i,r)),r=i}return n.reverse(),n},e.prototype.getPath=function(e,t){if(!e||"string"!=typeof e)throw new z("Param knownKeyId wrong format: "+e);if(!t||"string"!=typeof t)throw new z("Param keyId wrong format: "+t);var n=I.default.alg.dijkstra(this.graph,e);return this.tracePath(n,t)},e.prototype.getJwkKey=function(e,t){return M(this,void 0,void 0,(function(){return O(this,(function(n){switch(n.label){case 0:return[4,this.getKey(e,t)];case 1:return[2,n.sent().jwk]}}))}))},e.prototype.getKey=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return O(this,(function(a){switch(a.label){case 0:return n="string"==typeof e?e:null==e?void 0:e.id,this.hasKey(n)||!t?[3,2]:[4,t()];case 1:if(r=a.sent(),null!=n&&n!=r)throw new W("Requested keyId is not in the key cache, so an API request was made to populate the key cache.But the key returned by the API does NOT match the requested keyId.This is a programming logic error.");n=r,a.label=2;case 2:return(i=this.key(n)).jwk?[2,i]:[2,this.unwrapKey(this.keyService.currentMasterKey.id,n)]}}))}))},e.prototype._unwrapLink=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h;return O(this,(function(y){switch(y.label){case 0:return(r=JSON.parse(t.data.wrappedKey)).signatures?[4,this.encryptionService.verify(e,r)]:[3,2];case 1:return i=y.sent(),[3,4];case 2:return[4,this.encryptionService.decrypt(e,r)];case 3:i=y.sent(),y.label=4;case 4:if(t.type!=$.KeyLink)return[3,13];if(!(a=t.data).nestedWrappingKeyIds)return[3,13];y.label=5;case 5:y.trys.push([5,11,12,13]),s=T(a.nestedWrappingKeyIds),o=s.next(),y.label=6;case 6:return o.done?[3,10]:(c=o.value,[4,this.getKey(c)]);case 7:return u=y.sent(),[4,this.encryptionService.decrypt(u.jwk,i)];case 8:i=y.sent(),y.label=9;case 9:return o=s.next(),[3,6];case 10:return[3,13];case 11:return p=y.sent(),l={error:p},[3,13];case 12:try{o&&!o.done&&(h=s.return)&&h.call(s)}finally{if(l)throw l.error}return[7];case 13:return d=n,[4,ge.asKey(i)];case 14:return d.jwk=y.sent(),n.task=null,[2]}}))}))},e.prototype._unwrap=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c;return O(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),n=T(t),r=n.next(),u.label=1;case 1:return r.done?[3,4]:(i=r.value,(a=this.key(i.data.keyId)).jwk?(e=a.jwk,[3,3]):(a.task||(a.task=this._unwrapLink(e,i,a)),[4,a.task]));case 2:u.sent(),e=a.jwk,u.label=3;case 3:return r=n.next(),[3,1];case 4:return[3,7];case 5:return s=u.sent(),o={error:s},[3,7];case 6:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(o)throw o.error}return[7];case 7:return[2,e]}}))}))},e.prototype.unwrapWithPassKey=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i;return O(this,(function(a){switch(a.label){case 0:return r=this.getPath(e,n),i={id:n},[4,this._unwrap(t,r)];case 1:return[2,(i.jwk=a.sent(),i)]}}))}))},e.prototype.unwrapKey=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return O(this,(function(a){switch(a.label){case 0:return[4,this.keyService.loadMasterKey(e)];case 1:return n=a.sent(),e===t?[2,n]:(r=this.getPath(n.id,t),i={id:t},[4,this._unwrap(n.jwk,r)]);case 2:return[2,(i.jwk=a.sent(),i)]}}))}))},e.prototype.decryptFromString=function(e,t,n){return M(this,void 0,void 0,(function(){var r;return O(this,(function(i){switch(i.label){case 0:return t?[4,this.getJwkKey(e)]:[3,3];case 1:return r=i.sent(),[4,this.encryptionService.decrypt(r,JSON.parse(t),n)];case 2:return[2,i.sent()];case 3:return[2,null]}}))}))},e.prototype.decryptFile=function(e,t){return M(this,void 0,void 0,(function(){var n;return O(this,(function(r){switch(r.label){case 0:return[4,this.getJwkKey(e)];case 1:return n=r.sent(),[4,this.encryptionService.decrypt(n,t,{payloadType:L.UINT_8_ARRAY})];case 2:return[2,r.sent()]}}))}))},e.prototype.encryptToString=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return O(this,(function(i){switch(i.label){case 0:return null==t?[2,null]:(r=function(e){return e.id&&e.jwk?e.jwk:e.keystore&&e.length&&e.kty&&e.kid&&e.alg?e:null}(e))?[3,2]:[4,this.getJwkKey(e)];case 1:r=i.sent(),i.label=2;case 2:return n=r,[2,this.encryptionService.encryptToString(n,t)]}}))}))},e.prototype.wrapKey=function(e,t){return M(this,void 0,void 0,(function(){return O(this,(function(n){if(!function(e){return"oct"===e.kty}(t))throw new Q("Only allowing wrapping of symmetric keys.");return[2,this.encryptToString(e,t.toJSON(!0))]}))}))},e.prototype.encryptWithNewKey=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return O(this,(function(a){switch(a.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=a.sent(),[4,this.encryptToString(e,n.toJSON(!0))];case 2:return r=a.sent(),[4,this.encryptToString(n,t)];case 3:return i=a.sent(),[2,{key:n,wrappingKeyId:e,wrappedKey:r,cipher:i}]}}))}))},e}();Pe.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Pe(t.ɵɵinject(ve),t.ɵɵinject(Ke),t.ɵɵinject(ge))},token:Pe,providedIn:"root"}),Pe.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Pe.ctorParameters=function(){return[{type:ve},{type:Ke},{type:ge}]};var ke=function(){function e(e,t){this.apollo=e,this.keyGraph=t}return e.prototype.addKeys=function(e){e.data.keyGraph&&this.keyGraph.addKeys(e.data.keyGraph)},e.prototype.query=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query(e).toPromise()];case 1:return U((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e.prototype.mutate=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.apollo.mutate(e).toPromise()];case 1:return U((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e}();function Re(e,t){var n=e.definitions.filter((function(e){return"OperationDefinition"===e.kind}));if(n.length>1)throw new W("There can be only one '"+t+"' operation, instead there are "+n.length);return n[0]}function Ee(e){return Re(e,"query")}function De(e){return Re(e,"mutation")}function Ae(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function Me(e){return{kind:"Name",value:e}}function Oe(e){var t;return(null===(t=e.alias)||void 0===t?void 0:t.value)||e.name.value}function Te(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return K.default.apply(void 0,N([e],t))}ke.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ke(t.ɵɵinject(n.Apollo),t.ɵɵinject(Pe))},token:ke,providedIn:"root"}),ke.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ke.ctorParameters=function(){return[{type:n.Apollo},{type:Pe}]};var je,Ne,Fe="\n{\n keys {\n id\n }\n keyLinks {\n keyId\n wrappingKeyId\n nestedWrappingKeyIds\n wrappedKey\n }\n passKeys {\n id\n }\n passKeyLinks {\n keyId\n passKeyId\n wrappedKey\n }\n __typename\n}\n",_e=K.default(je||(je=F(["\nfragment KeyGraphFragment on KeyGraphType ","\n"],["\nfragment KeyGraphFragment on KeyGraphType ","\n"])),Fe),$e="keyGraph "+Fe,Le="keyGraph: fetchKeyGraph "+Fe,Ue=K.default(Ne||(Ne=F(["\n query Directory($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n directory(id: $id) {\n id\n keyId\n plainMeta\n cipherMeta\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query Directory($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n directory(id: $id) {\n id\n keyId\n plainMeta\n cipherMeta\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),_e),xe=["constructor","ngOnChanges","ngOnInit","ngDoCheck","ngAfterContentInit","ngAfterContentChecked","ngAfterViewInit","ngAfterViewChecked","ngOnDestroy"];function qe(e){var t=e.ngZoneName,n=e.exceptLastPromise,r=void 0===n||n,i=e.excludeMethods,a=void 0===i?[]:i,s=e.patchSetters,o=void 0===s||s;return function(e){function n(n,i){var a=this;if(!this[t])throw new W("RunOutsideAngular decorator requires that "+e.name+" inject NgZone as "+t);var s=this[t].runOutsideAngular((function(){return n.apply(a,i)}));return r&&(null==s?void 0:s.then)?Promise.resolve(s):s}return a=N(a,xe),Object.getOwnPropertyNames(e.prototype).filter((function(e){return!a.includes(e)})).forEach((function(t){if(o&&Object.getOwnPropertyDescriptor(e.prototype,t).set){var r=Object.getOwnPropertyDescriptor(e.prototype,t).set;Object.defineProperty(e.prototype,t,{set:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.apply(this,[r,e])}})}if("function"==typeof e.prototype[t]){var i=e.prototype[t];e.prototype[t]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.apply(this,[i,e])}}})),e}}var Je={hasKeys:!0};function Ge(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s=this;return O(this,(function(o){switch(o.label){case 0:return r=(n=Object).assign,i=[Object.assign({},e)],a={},[4,Promise.all(e.edges.map((function(e){return M(s,void 0,void 0,(function(){var n,r,i,a;return O(this,(function(s){switch(s.label){case 0:return r=(n=Object).assign,i=[Object.assign({},e)],a={},[4,t(e.node)];case 1:return[2,r.apply(n,i.concat([(a.node=s.sent(),a)]))]}}))}))})))];case 1:return[2,r.apply(n,i.concat([(a.edges=o.sent(),a)]))]}}))}))}e.CommonProcessorsService=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.series=function(e){var t=this;return function(n){var r=n.field,i=n.context,a=n.options;return M(t,void 0,void 0,(function(){var t,n,s,o,c;return O(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),t=T(e),n=t.next(),u.label=1;case 1:return n.done?[3,4]:[4,(0,n.value)({field:r,context:i,options:a})];case 2:r=u.sent(),u.label=3;case 3:return n=t.next(),[3,1];case 4:return[3,7];case 5:return s=u.sent(),o={error:s},[3,7];case 6:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}return[7];case 7:return[2,r]}}))}))}},e.prototype.makeJsonParseProcessor=function(e){var t=void 0===e?{}:e,n=t.plainFieldName,r=t.jsonFieldSuffix,i=n+(void 0===r?"Json":r);return function(e){var t,r=e.field;if(null==r[n]||i in r)return r;try{return Object.assign(Object.assign({},r),((t={})[i]=JSON.parse(r[n]),t))}catch(e){return r}}},e.prototype.makeDecryptionProcessor=function(e){var t=this,n=void 0===e?{}:e,r=n.cipherFieldName,i=n.clearFieldSuffix,a=void 0===i?"ClearJson":i,s=n.getKeyId,o=void 0===s?null:s,c=r+a;return function(e){return M(t,void 0,void 0,(function(){var t,n,i,a,s,u;return O(this,(function(p){switch(p.label){case 0:return n=e.field,i=e.context,e.options.hasKeys?!(a=n[r])||c in n?[2,n]:o?[4,o(e)]:[3,2]:[2,n];case 1:return u=p.sent(),[3,3];case 2:u=n.keyId||(null===(t=n.key)||void 0===t?void 0:t.id),p.label=3;case 3:if(!(s=u))throw new W("Query response does not contain "+(o?"key-id":"keyId or key.id")+" field: "+i.path.join("."));return[2,this.keyGraph.decryptFromString(s,a).then((function(e){var t;return Object.assign(Object.assign({},n),((t={})[c]=e,t))}))]}}))}))}},e}(),e.CommonProcessorsService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.CommonProcessorsService(t.ɵɵinject(t.NgZone),t.ɵɵinject(Pe))},token:e.CommonProcessorsService,providedIn:"root"}),e.CommonProcessorsService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.CommonProcessorsService.ctorParameters=function(){return[{type:t.NgZone},{type:Pe}]},e.CommonProcessorsService=A([qe({ngZoneName:"ngZone"})],e.CommonProcessorsService);var Qe=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.processTpPasswordResetUser=function(e){var t;return M(this,void 0,void 0,(function(){var n,r,i,a,s=this;return O(this,(function(o){switch(o.label){case 0:return(r=null===(t=e.pxk)||void 0===t?void 0:t.id)?[4,this.keyGraph.getKey(e.pxk.id)]:[3,2];case 1:r=o.sent(),o.label=2;case 2:return n=r,i=Object.assign({},e),n&&e.approvals?(a=i,[4,Promise.all(e.approvals.map((function(e){return s.processTpPasswordResetUserApprovalNode(e,n)})))]):[3,4];case 3:a.approvals=o.sent(),o.label=4;case 4:return[2,i]}}))}))},e.prototype.processTpPasswordResetUserApprovalNode=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return O(this,(function(i){switch(i.label){case 0:return n=Object.assign({},e),e.receiverCipher&&(n.receiverCipherClearJson=this.keyGraph.decryptFromString(t,e.receiverCipher)),e.receiverCipherPartialAssemblyKey?(r=n,[4,this.keyGraph.decryptFromString(t,e.receiverCipherPartialAssemblyKey)]):[3,2];case 1:r.receiverCipherPartialAssemblyKeyClearJson=i.sent(),i.label=2;case 2:return[2,n]}}))}))},e.prototype.makeTpPasswordResetNodeProcessor=function(){var e=this;return function(t){var n=t.field;return M(e,void 0,void 0,(function(){var e,t;return O(this,(function(r){switch(r.label){case 0:if(e=Object.assign({},n),!n.assembly)return[3,2];if(null==n.applied)throw new V('If you request for field "assembly" in the TpPasswordResetNode, then you must also request the "applied" field');return t=e,[4,this.processTpAssemblyNode(n.assembly,n.applied)];case 1:t.assembly=r.sent(),r.label=2;case 2:return[2,e]}}))}))}},e.prototype.processTpAssemblyNode=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l=this;return O(this,(function(h){switch(h.label){case 0:return n=e.subjectKey,r=e.assemblyKey,i=e.assemblyCipherData,a=e.subAssemblies,c=(o=Object).assign,u=[Object.assign({},e)],p={},[4,Ge(a,(function(e){return l.processTpSubAssemblyNode(e,n.id,t)}))];case 1:return s=c.apply(o,u.concat([(p.subAssemblies=h.sent(),p)])),t?[3,3]:i?(d=s,[4,this.keyGraph.decryptFromString(r.id,i)]):[3,3];case 2:d.assemblyCipherDataClearJson=h.sent(),h.label=3;case 3:return[2,s]}}))}))},e.prototype.processTpSubAssemblyNode=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d=this;return O(this,(function(l){switch(l.label){case 0:return r=e.subjectCipherData,i=e.approvers,o=(s=Object).assign,c=[Object.assign({},e)],u={},[4,Ge(i,(function(e){return d.processTpAssemblyApproverNode(e,n)}))];case 1:return a=o.apply(s,c.concat([(u.approvers=l.sent(),u)])),n?[3,3]:r?(p=a,[4,this.keyGraph.decryptFromString(t,r)]):[3,3];case 2:p.subjectCipherDataClearJson=l.sent(),l.label=3;case 3:return[2,a]}}))}))},e.prototype.processTpAssemblyApproverNode=function(e,t){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,e]}))}))},e}();function We(e,t){return Object.assign(Object.assign({},e),{path:N(e.path,[t])})}Qe.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Qe(t.ɵɵinject(t.NgZone),t.ɵɵinject(Pe))},token:Qe,providedIn:"root"}),Qe.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Qe.ctorParameters=function(){return[{type:t.NgZone},{type:Pe}]},Qe=A([qe({ngZoneName:"ngZone"})],Qe),e.QueryProcessorService=function(){function e(e,t,n,r){this.ngZone=e,this.keyService=t,this.common=n,this.tpprProcessor=r,this.TYPENAME="__typename",this.processors={},this.registerProcessor("DirectoryNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeDecryptionProcessor({cipherFieldName:"cipherMeta"})])),this.registerProcessor("FileStateNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeDecryptionProcessor({cipherFieldName:"cipherMeta"})])),this.registerProcessor("ContactCardNode",n.makeDecryptionProcessor({cipherFieldName:"cipherData"})),this.registerProcessor("SharedContactCardNode",n.series([n.makeJsonParseProcessor({plainFieldName:"ownerPlainData"}),n.makeDecryptionProcessor({cipherFieldName:"ownerCipherData",getKeyId:function(e){return e.field.ownerKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"receiverCipherData",getKeyId:function(e){return e.field.receiverKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpPasswordResetNode",this.tpprProcessor.makeTpPasswordResetNodeProcessor()),this.registerProcessor("SharedTpClaimApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherApprovalData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherPartialAssemblyKey",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpAssemblyAsApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("ScenarioReceiverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioReceiverDirectoryNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioReceiverFileNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("SharedScenarioReceiverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioApproverAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"assemblyCipherData",getKeyId:function(e){return e.field.assemblyKey.id}})])),this.registerProcessor("ScenarioApproverSubAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("ScenarioApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherApprovalData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherPartialAssemblyKey",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioClaimantNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("TpSubAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("NotificationNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeJsonParseProcessor({plainFieldName:"plainData"})])),this.registerProcessor("UserNode",n.series([n.makeJsonParseProcessor({plainFieldName:"config"})])),this.registerProcessor("ReminderNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plain"})]))}return e.prototype.processQuery=function(e,t){return M(this,void 0,void 0,(function(){var n=this;return O(this,(function(r){return t=Object.assign(Object.assign({},Je),t),[2,oe(e,(function(e,r){return n.processField({field:e,context:{path:[r],processChildren:!0},options:t})}))]}))}))},e.prototype.processField=function(e){var t=e.field,n=e.context,r=e.options;return M(this,void 0,void 0,(function(){var e,i,a,s=this;return O(this,(function(o){if(null==t?void 0:t.then)throw new W("processField() should not receive thenable.");return null==t?[2,null]:(e={field:t,context:Object.assign(Object.assign({},n),{processChildren:!0}),options:r},t[this.TYPENAME]?((i=this.processors[t[this.TYPENAME]])&&(t=i(e)),a=function(e){return n.processChildren&&null!==e&&"object"==typeof e?oe(e,(function(e,t){return s.processField({field:e,context:We(n,t),options:r})})):e},t=t.then?t.then((function(e){return a(e)})):a(t)):n.processChildren&&Array.isArray(t)&&(t=ae(t.map((function(e,t){return s.processField({field:e,context:We(n,t.toString()),options:r})})))),[2,t])}))}))},e.prototype.registerProcessor=function(e,t){if(this.processors[e])throw new W("Processor for field "+e+" already exists.");this.processors[e]=t},e}(),e.QueryProcessorService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.QueryProcessorService(t.ɵɵinject(t.NgZone),t.ɵɵinject(Ke),t.ɵɵinject(e.CommonProcessorsService),t.ɵɵinject(Qe))},token:e.QueryProcessorService,providedIn:"root"}),e.QueryProcessorService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.QueryProcessorService.ctorParameters=function(){return[{type:t.NgZone},{type:Ke},{type:e.CommonProcessorsService},{type:Qe}]},e.QueryProcessorService=A([qe({ngZoneName:"ngZone"})],e.QueryProcessorService);var Ve,Be,Ze,He=function(){function e(){var e=this;this._fulfilled=!1,this.promise=new Promise((function(t,n){e._resolve=t,e._reject=n})).finally((function(){e._fulfilled=!0}))}return Object.defineProperty(e.prototype,"resolve",{get:function(){return this._resolve},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reject",{get:function(){return this._reject},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fulfilled",{get:function(){return this._fulfilled},enumerable:!1,configurable:!0}),e}(),Ye=Ee(K.default(Ve||(Ve=F(["\n query {\n ...FragmentName\n }\n"],["\n query {\n ...FragmentName\n }\n"])))).selectionSet.selections[0],Xe=function(){function e(){this._executed=!1,this.deferredPromise=new He}return Object.defineProperty(e.prototype,"promise",{get:function(){return this.deferredPromise.promise},enumerable:!1,configurable:!0}),e.prototype.resolve=function(e){this.deferredPromise.resolve(e)},e.prototype.reject=function(e){this.deferredPromise.reject(e)},Object.defineProperty(e.prototype,"lrMutationData",{get:function(){return{mutation:this.mutation,variables:this.variables}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"executed",{get:function(){return this._executed},enumerable:!1,configurable:!0}),e.prototype.setExecuted=function(){if(this._executed)throw new Z("Already executed");this._executed=!0},e}(),ze=function(e){function t(t){var n=e.call(this)||this;return n.mutation=t.mutation,n.variables=t.variables,n}return E(t,e),t.prototype.select=function(e){var n=i.cloneDeep(this.mutation),r=De(n),a={};Ae(e).forEach((function(e){a[e.name.value.split("_")[0]]=e}));return r.selectionSet.selections.forEach((function(e){"Field"===e.kind&&function(e){var t=e,n=Oe(t),r=a[n];r&&(t.selectionSet.selections=[Object.assign(Object.assign({},Ye),{name:Me(r.name.value)})])}(e)})),new t({mutation:Object.assign(Object.assign({},n),{definitions:N(n.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})),e.definitions)}),variables:this.variables})},t}(Xe),et={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"lrMergedMutation"},variableDefinitions:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[]}}]},tt=function(e){function t(t){var n=e.call(this)||this;n.lrMutations=t;var r=n.merge(),i=r.mutation,a=r.variables,s=r.prefixes;return n.mutation=i,n.variables=a,n.prefixes=s,n.descendants=n.getDescendants(),n}return E(t,e),t.create=function(e){return new t(e)},t.prototype.getDescendants=function(){var e=new Set,n=function(t){if(e.has(t))throw new W("Classes that are derived from LrMutationBase can not be used more than once in a merged mutation.");e.add(t)};return this.lrMutations.forEach((function(e){if(e instanceof ze)n(e);else{if(!(e instanceof t))throw new ie("LrMergeMutation can not handle class: "+e.constructor.name);e.descendants.forEach((function(e){return n(e)}))}})),e},t.prototype.resolve=function(t){for(var n=this,r=0;r<this.lrMutations.length;++r){var i=this.prefixes[r],a={};for(var s in t){if(s.startsWith(i))a[s.slice(i.length)]=t[s]}this.lrMutations[r].resolve(a)}Promise.all(this.lrMutations.map((function(e){return e.promise}))).then((function(t){e.prototype.resolve.call(n,t)}))},t.prototype.reject=function(t){e.prototype.reject.call(this,t),this.lrMutations.forEach((function(e){return e.reject(t)}))},t.prototype.setExecuted=function(){e.prototype.setExecuted.call(this),this.lrMutations.forEach((function(e){return e.setExecuted()}))},t.prototype.renameVariableDefinition=function(e,t){return Object.assign(Object.assign({},e),{variable:Object.assign(Object.assign({},e.variable),{name:Me(t+e.variable.name.value)})})},t.prototype.renameVariableDefinitions=function(e,t){var n=this;return e.map((function(e){return n.renameVariableDefinition(e,t)}))},t.prototype.renameArgument=function(e,t){return"Variable"!==e.value.kind?e:Object.assign(Object.assign({},e),{value:Object.assign(Object.assign({},e.value),{name:Me(t+e.value.name.value)})})},t.prototype.renameField=function(e,t){var n=this;if("Field"!==e.kind)return e;var r=t+Oe(e),i=e.arguments.map((function(e){return n.renameArgument(e,t)}));return Object.assign(Object.assign({},e),{alias:{kind:"Name",value:r},arguments:i})},t.prototype.renameFragmentSpread=function(e,t){return Object.assign(Object.assign({},e),{name:Me(t+e.name.value)})},t.prototype.processSelection=function(e,t){switch(e.kind){case"FragmentSpread":return this.renameFragmentSpread(e,t);case"Field":return e.selectionSet?Object.assign(Object.assign({},e),{selectionSet:this.processSelectionSet(e.selectionSet,t)}):e;default:return e}},t.prototype.processSelectionSet=function(e,t){var n=this;return Object.assign(Object.assign({},e),{selections:e.selections.map((function(e){return n.processSelection(e,t)}))})},t.prototype.renameSelections=function(e,t){var n=this;return e.map((function(e){switch(e.kind){case"Field":return n.processSelection(n.renameField(e,t),t);default:return e}}))},t.prototype.renameFragmentDefinition=function(e,t){var n=Object.assign(Object.assign({},e),{name:Me(t+e.name.value)});return e.selectionSet&&(n.selectionSet=this.processSelectionSet(e.selectionSet,t)),n},t.prototype.renameFragmentDefinitions=function(e,t){var n=this;return e.map((function(e){return n.renameFragmentDefinition(e,t)}))},t.prototype.merge=function(){var e=this,t=[],n=[],r={},a=[],s=[];this.lrMutations.forEach((function(i,o){var c,u;if(!(i instanceof Xe))throw new W("An mutation in the array is not of type LrMutationBase.");var p=i.lrMutationData,d=p.mutation,l=p.variables,h=De(d),y="item"+o+"_";h.name&&(y+=h.name.value+"_"),s.push(y),t=N(t,e.renameVariableDefinitions(h.variableDefinitions,y)),n=N(n,e.renameSelections(h.selectionSet.selections,y));try{for(var f=T(Object.keys(l)),v=f.next();!v.done;v=f.next()){var m=v.value;r[y+m]=l[m]}}catch(e){c={error:e}}finally{try{v&&!v.done&&(u=f.return)&&u.call(f)}finally{if(c)throw c.error}}var g=Ae(d);a=N(a,e.renameFragmentDefinitions(g,y))}));var o=i.cloneDeep(et),c=De(o);return c.selectionSet.selections=n,c.variableDefinitions=t,o.definitions=N(o.definitions,a),{mutation:o,variables:r,prefixes:s}},t}(Xe),nt=Ee(K.default(Be||(Be=F(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),$e)).selectionSet.selections[0],rt=Ee(K.default(Ze||(Ze=F(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Le)).selectionSet.selections[0];e.ɵg=function(){function e(e,t,n,r){this.ngZone=e,this.apollo=t,this.keyGraph=n,this.queryProcessor=r,this.stats={queryCount:0,mutationCount:0}}return e.prototype.query=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return e=i.cloneDeep(e),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=Ee(e.query)).selectionSet.selections=N(t.selectionSet.selections,[nt])),e.name&&((t=Ee(e.query)).name={kind:"Name",value:e.name}),[4,this.apollo.query(e).toPromise()];case 1:return n=r.sent(),this.stats.queryCount++,U(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.lrMutateImpl=function(e,t){return M(this,void 0,void 0,(function(){return O(this,(function(n){if(null==t?void 0:t.variables)throw new ie('Unsupported field: "options.variables"');if(e.executed)throw new Z("LrMutation has already executed. LrMutation can only be used once in a lrMutate() call. Create new instances of LrMutation.");return e.setExecuted(),[2,this.apolloMutate(Object.assign(Object.assign({},t),e.lrMutationData)).then((function(t){return e.resolve(t),t})).catch((function(t){throw e.reject(t),t}))]}))}))},e.prototype.apolloMutate=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return e=Object.assign(Object.assign({},e),{mutation:i.cloneDeep(e.mutation)}),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=De(e.mutation)).selectionSet.selections=N(t.selectionSet.selections,[rt])),e.name&&((t=De(e.mutation)).name={kind:"Name",value:e.name}),e.mutation=K.default(h.print(e.mutation)),[4,this.apollo.mutate(e).toPromise()];case 1:return n=r.sent(),this.stats.mutationCount++,U(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.statsSnapshot=function(){return i.cloneDeep(this.stats)},e.prototype.addKeys=function(e){e.data.keyGraph&&(this.keyGraph.addKeys(e.data.keyGraph),delete e.data.keyGraph)},e.prototype.isIncludeKeyGraph=function(e){return null==e},e.prototype.lrMutate=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a;return O(this,(function(s){switch(s.label){case 0:return e instanceof Array?(i=(r=tt).create,[4,Promise.all(e)]):[3,3];case 1:return n=i.apply(r,[s.sent()]),[4,this.lrMutateImpl(n,t)];case 2:return s.sent(),[2,n.promise];case 3:return[4,e];case 4:return a=s.sent(),[4,this.lrMutateImpl(a,t)];case 5:return s.sent(),[2,a.promise]}}))}))},e}(),e.ɵg.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵg(t.ɵɵinject(t.NgZone),t.ɵɵinject(n.Apollo),t.ɵɵinject(Pe),t.ɵɵinject(e.QueryProcessorService))},token:e.ɵg,providedIn:"root"}),e.ɵg.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵg.ctorParameters=function(){return[{type:t.NgZone},{type:n.Apollo},{type:Pe},{type:e.QueryProcessorService}]},e.ɵg=A([qe({ngZoneName:"ngZone"})],e.ɵg);var it,at,st,ot,ct,ut,pt,dt,lt,ht,yt,ft,vt,mt,gt,St,Ct,bt,It,wt,Kt=function(){function t(t){this.lrGraphQL=t.get(e.ɵg)}return t.prototype.mutate=function(e,t){return M(this,void 0,void 0,(function(){return O(this,(function(n){return[2,this.lrGraphQL.lrMutate(e,t)]}))}))},t.prototype.query=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.lrGraphQL.query(e)]}))}))},t}();function Pt(e){return e.edges.map((function(e){return e.node}))}(e.UserDeleteState||(e.UserDeleteState={})).REQUESTED="REQUESTED",(it=e.PlanState||(e.PlanState={})).ENABLED="ENABLED",it.DISABLED="DISABLED",(at=e.ShareTypeChoice||(e.ShareTypeChoice={})).TP="TP",at.DETACHED="DETACHED",(st=e.DetachedShareStateChoice||(e.DetachedShareStateChoice={})).IN_PROGRESS="IN_PROGRESS",st.COMPLETED="COMPLETED",(ot=e.AccessRoleChoice||(e.AccessRoleChoice={})).READER="READER",ot.WRITER="WRITER",ot.ADMIN="ADMIN",ot.CUSTODIAN="CUSTODIAN",ot.DENY="DENY",ot.OWNER="OWNER",(ct=e.AccessRoleChoiceOrder||(e.AccessRoleChoiceOrder={}))[ct.READER=0]="READER",ct[ct.WRITER=1]="WRITER",ct[ct.ADMIN=2]="ADMIN",ct[ct.CUSTODIAN=3]="CUSTODIAN",ct[ct.DENY=4]="DENY",ct[ct.CONFIDENTIAL=5]="CONFIDENTIAL",ct[ct.OWNER=6]="OWNER",(ut=e.AccessRoleMethodChoice||(e.AccessRoleMethodChoice={})).INHERITED="INHERITED",ut.DIRECT="DIRECT",(pt=e.PermissionChoice||(e.PermissionChoice={})).CREATE="CREATE",pt.READ="READ",pt.UPDATE="UPDATE",pt.DELETE="DELETE",pt.SHARE="SHARE",pt.ARCHIVE="ARCHIVE",pt.ACCESS_ARCHIVED="ACCESS_ARCHIVED",pt.UNARCHIVE="UNARCHIVE",pt.SET_CONFIDENTIAL="SET_CONFIDENTIAL",(dt=e.FileOperationField||(e.FileOperationField={})).CREATE="CREATE",dt.READ="READ",dt.UPDATE="UPDATE",dt.REVERT="REVERT",dt.DELETE="DELETE",(lt=e.KeyExchangeOtkState||(e.KeyExchangeOtkState={})).OTK_INITIATED="OTK_INITIATED",lt.OTK_ACCEPTED="OTK_ACCEPTED",lt.OTK_COMPLETED="OTK_COMPLETED",(ht=e.KeyExchangeState||(e.KeyExchangeState={})).IN_PROGRESS="IN_PROGRESS",ht.COMPLETED="COMPLETED",ht.DECLINED="DECLINED",ht.CANCELLED="CANCELLED",ht.DELETED="DELETED",(e.KeyExchangeMode||(e.KeyExchangeMode={})).OTK="OTK",(yt=e.TpAssemblyState||(e.TpAssemblyState={})).DISABLED="DISABLED",yt.ENABLED="ENABLED",yt.CLAIMED="CLAIMED",yt.APPROVED="APPROVED",yt.REJECTED="REJECTED",yt.EXPIRED="EXPIRED",yt.CANCELLED="CANCELLED",yt.RESET="RESET",(ft=e.TpClaimState||(e.TpClaimState={})).CLAIMED="CLAIMED",ft.APPROVED="APPROVED",ft.REJECTED="REJECTED",ft.EXPIRED="EXPIRED",ft.CANCELLED="CANCELLED",ft.RESET="RESET",(vt=e.TpClaimApproverState||(e.TpClaimApproverState={})).CLAIMED="CLAIMED",vt.APPROVED="APPROVED",vt.REJECTED="REJECTED",(mt=e.LockState||(e.LockState={})).UNLOCKED="UNLOCKED",mt.MUTEX_LOCKED="MUTEX_LOCKED",(gt=e.ScenarioState||(e.ScenarioState={})).DISABLED="DISABLED",gt.ENABLED="ENABLED",gt.CLAIMED="CLAIMED",gt.APPROVED="APPROVED",(St=e.ClaimState||(e.ClaimState={})).CLAIMED="CLAIMED",St.EXPIRED="EXPIRED",St.APPROVED="APPROVED",St.REJECTED="REJECTED",St.CANCELLED="CANCELLED",St.RESET="RESET",(Ct=e.ClaimApproverState||(e.ClaimApproverState={})).CLAIMED="CLAIMED",Ct.APPROVED="APPROVED",Ct.REJECTED="REJECTED",(bt=e.ScenarioLastClaimState||(e.ScenarioLastClaimState={})).CLAIMED="CLAIMED",bt.APPROVED="APPROVED",bt.REJECTED="REJECTED",bt.EXPIRED="EXPIRED",bt.CANCELLED="CANCELLED",bt.RESET="RESET",(It=e.LinkTypeField||(e.LinkTypeField={})).HARD="HARD",It.SOFT="SOFT",It.REFERENCE="REFERENCE",(wt=e.PlanStateField||(e.PlanStateField={})).TRIALLING="TRIALLING",wt.ACTIVE="ACTIVE",wt.CANCELLED="CANCELLED",wt.EXPIRED="EXPIRED";var kt,Rt=function(e){var t=window.fetch;return function(n,r){var i=function(){return t(n,r)};if(!r||!r.headers||!r.headers["X-Amz-Target"])return i();var a=r.headers["X-Amz-Target"].split(".");if(a.length<2||"AWSCognitoIdentityProviderService"!==a[0])return i();var s=JSON.parse(r.body);if(s&&s.ClientMetadata&&"true"===s.ClientMetadata.noProxy)return i();var o=!1;if("RespondToAuthChallenge"===a[1]){if(s&&"NEW_PASSWORD_REQUIRED"===s.ChallengeName)return i();o=!0}else"InitiateAuth"===a[1]&&"REFRESH_TOKEN_AUTH"===s.AuthFlow&&(o=!0);return o?t(e+"auth/proxy/",Object.assign(Object.assign({},r),{credentials:"include"})):i()}},Et=function(e,t){var n=e.authUrl,r=e.userPoolId,i=e.userPoolWebClientId;return function(){var e=r.split("_");if(e.length<2)throw new Error("userPoolId should have this format: {aws-region}_xxxxx");window.fetch=Rt(n),t.configure({region:e[0],userPoolId:r,userPoolWebClientId:i,mandatorySignIn:!1})}};(kt=e.Config||(e.Config={}))[kt.TIMEOUT=.01]="TIMEOUT",kt[kt.IDLE=1200]="IDLE",kt[kt.KEEP_ALIVE_INTERVAL=60]="KEEP_ALIVE_INTERVAL";var Dt=function(){function t(e,t,n,r,i,a){this.config=e,this.http=t,this.idle=n,this.keepalive=r,this.keyService=i,this.auth=a,this.IDLE_EXPIRY_KEY="ng2Idle.main.expiry",this.IDLING_KEY="ng2Idle.main.idling",this.initCalled=!1}return t.prototype.assertInit=function(){if(!this.initCalled)throw new Z("Call IdleService.init() first.")},t.prototype.init=function(t){return M(this,void 0,void 0,(function(){var n,r=this;return O(this,(function(i){switch(i.label){case 0:if(this.initCalled)throw new Z("IdleService.init() can only be called once. IdleService.start() calls init() with default values if init() has not been called yet.");if(this.initCalled=!0,(t=Object.assign({onTimeout:null,onKeepalive:null,idleSec:e.Config.IDLE,timeoutSec:e.Config.TIMEOUT,keepAliveIntervalSec:e.Config.KEEP_ALIVE_INTERVAL},t)).timeoutSec<.01)throw new Q("Minimum value for IdleService.init({ timeoutSec }) is 0.01");return this.onTimeout=t.onTimeout,this.onKeepalive=t.onKeepalive,this.idle.setIdle(t.idleSec),this.idle.setTimeout(t.timeoutSec),this.idle.setInterrupts(v.DEFAULT_INTERRUPTSOURCES),this.idle.onIdleEnd.subscribe((function(){return console.log("Idle stopped")})),this.idle.onIdleStart.subscribe((function(){return console.log("Idle started")})),this.idle.onTimeout.subscribe((function(){return M(r,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return console.log("Idle timed out"),this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout({onInit:!1}))];case 1:return e.sent(),[2]}}))}))})),this.idle.onTimeoutWarning.subscribe((function(e){return console.log("Will timeout in "+e+" seconds!")})),this.keepalive.interval(t.keepAliveIntervalSec),console.log("Keep alive interval set at: "+e.Config.KEEP_ALIVE_INTERVAL+" seconds"),this.keepalive.onPing.subscribe((function(){return r.onPing()})),(n=localStorage.getItem(this.IDLE_EXPIRY_KEY))&&parseInt(n,10)+1e3*this.idle.getTimeout()<Date.now()?(this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout({onInit:!0}))]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.keepalivePost=function(){return M(this,void 0,void 0,(function(){var e,t,n;return O(this,(function(r){switch(r.label){case 0:return t=(e=this.http).post,n=[this.config.authUrl+"auth/keepalive/",null],[4,be(this.auth,this.config)];case 1:return[4,t.apply(e,n.concat([r.sent()])).toPromise()];case 2:return[2,{keepaliveResult:r.sent(),expiresAfterSeconds:this.idle.getIdle()+this.idle.getTimeout()+this.keepalive.interval()}]}}))}))},t.prototype.persistMasterKey=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.keepalivePost()];case 1:return t=n.sent().expiresAfterSeconds,[4,this.keyService.persistMasterKey(e,t)];case 2:return n.sent(),[2]}}))}))},t.prototype.onPing=function(){return M(this,void 0,void 0,(function(){var e;return O(this,(function(t){switch(t.label){case 0:return console.log("Keep alive triggered at time: "+Date.now()+". Interval set at: "+this.keepalive.interval()+" seconds"),[4,this.keepalivePost()];case 1:return e=t.sent().expiresAfterSeconds,[4,this.keyService.setMasterKeyExpiresAfterSeconds(e)];case 2:return t.sent(),[4,Promise.resolve(this.onKeepalive&&this.onKeepalive())];case 3:return t.sent(),[2]}}))}))},t.prototype.start=function(){return M(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return this.initCalled?[3,2]:[4,this.init()];case 1:e.sent(),e.label=2;case 2:return this.idle.isRunning()?[2]:[4,this.onPing()];case 3:return e.sent(),this.idle.watch(),[2]}}))}))},t.prototype.stop=function(){this.idle.stop(),this.reset()},t.prototype.reset=function(){localStorage.removeItem(this.IDLE_EXPIRY_KEY),localStorage.removeItem(this.IDLING_KEY)},t}();Dt.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Dt(t.ɵɵinject(Se),t.ɵɵinject(y.HttpClient),t.ɵɵinject(v.Idle),t.ɵɵinject(m.Keepalive),t.ɵɵinject(Ke),t.ɵɵinject(s.AuthClass))},token:Dt,providedIn:"root"}),Dt.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Dt.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:y.HttpClient},{type:v.Idle},{type:m.Keepalive},{type:Ke},{type:s.AuthClass}]};var At,Mt,Ot,Tt,jt,Nt,Ft,_t="\nid\npublicData\npublicSearchable\ncipherData\nkey {\n id\n}\n",$t=(K.default(At||(At=F(["\nquery ContactCardQuery(\n$id: LrRelayIdInput!\n) {\ncontactCard (\n id: $id\n) {\n ","\n}\n","\n}"],["\nquery ContactCardQuery(\n$id: LrRelayIdInput!\n) {\ncontactCard (\n id: $id\n) {\n ","\n}\n","\n}"])),_t,$e),K.default(Mt||(Mt=F(['\nquery SearchContactCardQuery(\n $publicSearchable: LrJSONFilter!\n) {\n searchContactCards(\n publicSearchable: $publicSearchable\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"],['\nquery SearchContactCardQuery(\n $publicSearchable: LrJSONFilter!\n) {\n searchContactCards(\n publicSearchable: $publicSearchable\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"])),_t,$e),K.default(Ot||(Ot=F(['\nquery ContactCardListQuery {\n contactCards(\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"],['\nquery ContactCardListQuery {\n contactCards(\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"])),_t,$e)),Lt=(K.default(Tt||(Tt=F(["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"],["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"])),_t),K.default(jt||(jt=F(["\nmutation UpdateContactCardMutation(\n $input: UpdateContactCardInput!\n) {\n updateContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"],["\nmutation UpdateContactCardMutation(\n $input: UpdateContactCardInput!\n) {\n updateContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"])),_t),K.default(Nt||(Nt=F(["\n mutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n }\n"])))),Ut=Te(Ft||(Ft=F(["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"],["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"]))),xt=function(){function e(e,t,n,r,i){this.encryptionService=e,this.keyGraph=t,this.lrApollo=n,this.keyService=r,this.keyFactory=i}return e.prototype.decryptMeta=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return e.cipherMeta?[4,this.keyGraph.getJwkKey(e.keyId)]:[3,3];case 1:return t=n.sent(),[4,this.encryptionService.decrypt(t,JSON.parse(e.cipherMeta))];case 2:return[2,n.sent()];case 3:return[2,null]}}))}))},e.prototype.doubleWrapContent=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d;return O(this,(function(l){switch(l.label){case 0:return[4,this.keyFactory.createKey()];case 1:return r=l.sent(),[4,this.wrapContent(r.toJSON(!0),t)];case 2:return i=l.sent(),a={rootKey:i.rootKey,wrappedKeys:i.wrappedKeys,doubleWrappedKey:i.cipherMeta},e?(c=(o=JSON).stringify,[4,this.encryptionService.encrypt(r,e)]):[3,4];case 3:return s=c.apply(o,[l.sent()]),[3,5];case 4:s=null,l.label=5;case 5:return a.cipherMeta=s,n?(d=(p=JSON).stringify,[4,this.encryptionService.encrypt(r,n)]):[3,7];case 6:return u=d.apply(p,[l.sent()]),[3,8];case 7:u=null,l.label=8;case 8:return[2,(a.cipherFileContent=u,a)]}}))}))},e.prototype.reWrapContent=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return O(this,(function(p){switch(p.label){case 0:return[4,this.keyGraph.getJwkKey(e)];case 1:return n=p.sent(),[4,this.keyFactory.createKey()];case 2:return r=p.sent(),i={},s=(a=JSON).stringify,[4,this.encryptionService.encrypt(n,r.toJSON(!0))];case 3:return i.doubleWrappedKey=s.apply(a,[p.sent()]),t?(u=(c=JSON).stringify,[4,this.encryptionService.encrypt(r,t)]):[3,5];case 4:return o=u.apply(c,[p.sent()]),[3,6];case 5:o=null,p.label=6;case 6:return[2,(i.cipherMeta=o,i)]}}))}))},e.prototype.wrapContent=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h=this;return O(this,(function(y){switch(y.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=y.sent(),t&&t.length?[4,Promise.all(t.map((function(e){return M(h,void 0,void 0,(function(){var t,r,i,a;return O(this,(function(s){switch(s.label){case 0:return[4,this.getDirectoryKeyId(e)];case 1:return t=s.sent(),a=(i=JSON).stringify,[4,this.encryptionService.encrypt(t.key,n.toJSON(!0))];case 2:return r=a.apply(i,[s.sent()]),[2,{directoryId:e,wrappingKeyId:t.keyId,wrappedKey:r}]}}))}))})))]:[3,3];case 2:return r=y.sent(),[3,5];case 3:return a=this.keyService.currentRootKey,c=(o=JSON).stringify,[4,this.encryptionService.encrypt(a.jwk,n.toJSON(!0))];case 4:s=c.apply(o,[y.sent()]),i={wrappingKeyId:a.id,wrappedKey:s},y.label=5;case 5:return u={key:n,rootKey:i,wrappedKeys:r},e?(l=(d=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,7];case 6:return p=l.apply(d,[y.sent()]),[3,8];case 7:p=null,y.label=8;case 8:return[2,(u.cipherMeta=p,u)]}}))}))},e.prototype.wrapContentWithKey=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o;return O(this,(function(c){switch(c.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=c.sent(),[4,this.keyGraph.encryptToString(t,n.toJSON(!0))];case 2:return r=c.sent(),i={key:n,rootKey:{wrappingKeyId:t,wrappedKey:r}},e?(o=(s=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,4];case 3:return a=o.apply(s,[c.sent()]),[3,5];case 4:a=null,c.label=5;case 5:return[2,(i.cipherMeta=a,i)]}}))}))},e.prototype.getDirectoryKeyId=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Ut,variables:{id:e}})];case 1:return t=r.sent().directory,n={keyId:t.keyId},[4,this.keyGraph.getJwkKey(t.keyId)];case 2:return[2,(n.key=r.sent(),n)]}}))}))},e}();xt.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new xt(t.ɵɵinject(ve),t.ɵɵinject(Pe),t.ɵɵinject(ke),t.ɵɵinject(Ke),t.ɵɵinject(ge))},token:xt,providedIn:"root"}),xt.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],xt.ctorParameters=function(){return[{type:ve},{type:Pe},{type:ke},{type:Ke},{type:ge}]};var qt,Jt,Gt,Qt,Wt,Vt,Bt,Zt,Ht,Yt="\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n config\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n",Xt="\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n pbk\n }\n mkReshareRequestCipher\n mkReshareResponseCipher\n mkReshareRequestSent\n mkReshareResponseSent\n",zt=Te(qt||(qt=F(["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ","\n }\n }\n }\n}\n"],["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ","\n }\n }\n }\n}\n"])),Yt),en=Te(Jt||(Jt=F(["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ","\n }\n}\n"],["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ","\n }\n}\n"])),Yt),tn=Te(Gt||(Gt=F(["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ","\n }\n}\n"],["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ","\n }\n}\n"])),Yt),nn=Te(Qt||(Qt=F(["\nmutation CancelKeyExchangeMutation($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"],["\nmutation CancelKeyExchangeMutation($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"]))),rn=Te(Wt||(Wt=F(["\nmutation DeclineKeyExchangeMutation($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"],["\nmutation DeclineKeyExchangeMutation($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"]))),an=Te(Vt||(Vt=F(["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n }\n}\n"],["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n }\n}\n"])),Yt),sn=Te(Bt||(Bt=F(["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"],["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"])),Yt,Xt),on=Te(Zt||(Zt=F(["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"],["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"])),Yt,Xt),cn=Te(Ht||(Ht=F(["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n}\n"],["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n}\n"])),Xt);(e.FeatureAction||(e.FeatureAction={})).ACCESS="access";var un,pn=function(){},dn=function(){},ln=function(){},hn=function(){},yn=function(e){this.name=e.name,this.title=e.title,this.firstName=e.firstName,this.lastName=e.lastName},fn=function(){},vn=function(){},mn=function(){},gn=function(){},Sn=function(){},Cn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return E(t,e),t}(Sn),bn=function(){},In=function(){};(un=e.TrustedPartyType||(e.TrustedPartyType={})).User="user",un.Organisation="organisation";var wn,Kn=function(){},Pn="\n id\n owner {\n id\n username\n }\n ownerKey {\n id\n }\n ownerCipherData\n receiver {\n id\n username\n }\n receiverKey {\n id\n }\n receiverCipherData\n sharedKey {\n id\n }\n sharedCipherData\n sharedCipherDataSig\n sharedCipherDataSigPxk {\n id\n }\n",kn=K.default(wn||(wn=F(["\nmutation UpdateOwnedContactCard(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(\n input: $input\n ) {\n ownedContactCard {\n ","\n }\n }\n}"],["\nmutation UpdateOwnedContactCard(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(\n input: $input\n ) {\n ownedContactCard {\n ","\n }\n }\n}"])),Pn),Rn=function(){function e(e,t,n,r){this.keyService=e,this.lrApollo=t,this.keyGraph=n,this.encryptionService=r}return e.prototype.decryptSharedTrustedPartyDetails=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.decryptTrustedPartyDetails(e)];case 1:return t=n.sent(),[2,Object.assign({id:e.id,ownedKeyId:e.ownerKey.id,sharedKeyId:e.sharedKey.id},t)]}}))}))},e.prototype.decryptTrustedPartyDetails=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return O(this,(function(i){switch(i.label){case 0:if(!(e&&e.sharedKey&&e.sharedCipherData))return[3,5];i.label=1;case 1:return i.trys.push([1,4,,5]),n=(t=this.encryptionService).decrypt,[4,this.keyGraph.getJwkKey(e.sharedKey.id)];case 2:return[4,n.apply(t,[i.sent(),e.sharedCipherData])];case 3:return[2,i.sent()];case 4:return r=i.sent(),console.error("Cannot decrypt trusted party details",r),[3,5];case 5:return[2,null]}}))}))},e.prototype.updateMySharedContactCard=function(e,t,n,r){return M(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,h,y;return O(this,(function(f){switch(f.label){case 0:return[4,this.keyGraph.getKey(t)];case 1:return i=f.sent(),[4,this.keyGraph.getKey(n)];case 2:return a=f.sent(),s=this.keyService.currentSigPxk,[4,this.encryptionService.encrypt(a.jwk,r)];case 3:return o=f.sent(),p=(u=JSON).stringify,[4,this.encryptionService.sign(s.jwk,o)];case 4:return c=p.apply(u,[f.sent()]),d={name:new yn(r.name)},y=(h=JSON).stringify,[4,this.encryptionService.sign(s.jwk,d)];case 5:return l=y.apply(h,[f.sent()]),[4,this.lrApollo.mutate({mutation:kn,variables:{input:{id:e,ownerCipherData:"",ownerKeyId:i.id,sharedCipherDataSig:c,sharedKeyId:a.id,sigPxkId:s.id,ownerPlainDataSig:l}}})];case 6:return f.sent(),[2]}}))}))},e}();Rn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Rn(t.ɵɵinject(Ke),t.ɵɵinject(ke),t.ɵɵinject(Pe),t.ɵɵinject(ve))},token:Rn,providedIn:"root"}),Rn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Rn.ctorParameters=function(){return[{type:Ke},{type:ke},{type:Pe},{type:ve}]};var En,Dn,An,Mn,On,Tn="\n id\n user {\n id\n username\n }\n other{\n id\n username,\n features {\n shareVault\n }\n }\n sharedContactCard {\n "+Pn+"\n }\n myContactCard {\n "+Pn+"\n }\n sharedScenarios {\n edges {\n node {\n id\n }\n }\n }\n theirItems {\n directories {\n edges {\n node {\n id\n }\n }\n }\n }\n currentUserSharedKey {\n userSharedKey {\n keyExchange {\n "+Yt+"\n }\n "+Xt+"\n }\n }",jn=K.default(En||(En=F(['\n query {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n userDelete {\n id\n created\n state\n }\n features {\n myVault\n tpVault\n shareVault\n }\n sessionEncryptionKey\n dateJoined\n }\n userPlans {\n id\n stripe {\n subscriptionId\n }\n plan {\n name\n data\n state\n }\n periodEnd\n }\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n key {\n id\n }\n cipherData\n plainData\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ',"\n"],['\n query {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n userDelete {\n id\n created\n state\n }\n features {\n myVault\n tpVault\n shareVault\n }\n sessionEncryptionKey\n dateJoined\n }\n userPlans {\n id\n stripe {\n subscriptionId\n }\n plan {\n name\n data\n state\n }\n periodEnd\n }\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n key {\n id\n }\n cipherData\n plainData\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ',"\n"])),_e),Nn=K.default(Dn||(Dn=F(["\n mutation CreateContactCardMutation($input: CreateContactCardInput!) {\n createContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"],["\n mutation CreateContactCardMutation($input: CreateContactCardInput!) {\n createContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"]))),Fn=K.default(An||(An=F(["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"],["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"]))),_n=Te(Mn||(Mn=F(["\nquery TrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n}"],["\nquery TrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n}"])),Tn),$n=Te(On||(On=F(['\nquery ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n cipherData\n key {\n id\n }\n }\n }\n }\n}\n'],['\nquery ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n cipherData\n key {\n id\n }\n }\n }\n }\n}\n']))),Ln=function(){function e(e,t,n,r,i,a,s){this.config=e,this.http=t,this.lrApollo=n,this.keyService=r,this.keyMetaService=i,this.keyGraph=a,this.encryptionService=s}return e.prototype.getCurrentUser=function(){return M(this,void 0,void 0,(function(){var e,t,n,r;return O(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:jn})];case 1:return e=i.sent(),t=e.currentUser,n=e.contactCards,r=n.edges.map((function(e){return e.node}))[0],[2,{currentUser:t,contactCard:r}]}}))}))},e.prototype.decryptContactCard=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return e?[4,this.keyGraph.decryptFromString(e.key.id,e.cipherData)]:[2,null];case 1:return t=n.sent(),[2,Object.assign({id:e.id,keyId:e.key.id},t)]}}))}))},e.prototype.updateDetails=function(e,t,n){return M(this,void 0,void 0,(function(){var r;return O(this,(function(i){switch(i.label){case 0:return[4,e?this.updateContactCard(e,t,n):this.createContactCard(n)];case 1:return r=i.sent(),[2,{fields:n,id:r.id,keyId:r.key.id}]}}))}))},e.prototype.prepareContactCardInput=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return O(this,(function(l){switch(l.label){case 0:return t=this.keyService.currentSigPxk,i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 1:return n=i.apply(r,[l.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 2:return a=o.apply(s,[l.sent()]),c={name:new yn(e.name.value)},d=(p=JSON).stringify,[4,this.encryptionService.sign(t.jwk,c)];case 3:return u=d.apply(p,[l.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:u}]}}))}))},e.prototype.createContactCard=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i;return O(this,(function(a){switch(a.label){case 0:return[4,this.prepareContactCardInput(e)];case 1:return t=a.sent(),[4,this.keyMetaService.wrapContent(e)];case 2:return n=a.sent(),r=n.rootKey,i=n.cipherMeta,[4,this.lrApollo.mutate({mutation:Nn,variables:{input:Object.assign(Object.assign({},t),{cipherData:i,wrappingKeyId:r.wrappingKeyId,wrappedKey:r.wrappedKey,default:!0})}})];case 3:return[2,a.sent().createContactCard.contactCard]}}))}))},e.prototype.updateContactCard=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i;return O(this,(function(a){switch(a.label){case 0:return[4,this.prepareContactCardInput(n)];case 1:return r=a.sent(),[4,this.keyGraph.encryptToString(t,n)];case 2:return i=a.sent(),[4,this.lrApollo.mutate({mutation:Fn,variables:{input:Object.assign(Object.assign({},r),{id:e,cipherData:i})}})];case 3:return[2,a.sent().updateContactCard.contactCard]}}))}))},e.prototype.decryptContactCardEdges=function(e){return M(this,void 0,void 0,(function(){var t=this;return O(this,(function(n){return[2,Promise.all(e.map((function(e){return M(t,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return t=e.node,[4,this.decryptContactCard(t)];case 1:return[2,n.sent()]}}))}))})))]}))}))},e.prototype.getContactCards=function(){return M(this,void 0,void 0,(function(){var e;return O(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:$t})];case 1:return e=t.sent(),[4,this.decryptContactCardEdges(e.contactCards.edges)];case 2:return[2,t.sent()]}}))}))},e.prototype.deleteContactCard=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Lt,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteContactCard.id]}}))}))},e.prototype.signOut=function(){return M(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.http.post(this.config.authUrl+"auth/sign-out/",null,{withCredentials:!0,responseType:"text"}).toPromise()];case 1:return e.sent(),[2]}}))}))},e}();Ln.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ln(t.ɵɵinject(Se),t.ɵɵinject(y.HttpClient),t.ɵɵinject(ke),t.ɵɵinject(Ke),t.ɵɵinject(xt),t.ɵɵinject(Pe),t.ɵɵinject(ve))},token:Ln,providedIn:"root"}),Ln.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ln.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:y.HttpClient},{type:ke},{type:Ke},{type:xt},{type:Pe},{type:ve}]};var Un,xn,qn,Jn=K.default(Un||(Un=F(["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"],["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"]))),Gn=K.default(xn||(xn=F(["\n mutation PasswordChange($input: PasswordChangeInput!) {\n passwordChange(input: $input) {\n token\n newPassKey {\n id\n }\n }\n }\n"],["\n mutation PasswordChange($input: PasswordChangeInput!) {\n passwordChange(input: $input) {\n token\n newPassKey {\n id\n }\n }\n }\n"]))),Qn=K.default(qn||(qn=F(["\n query PasswordChangeConfigQuery {\n passwordChangeConfig {\n maxAuthAgeSeconds\n authTime\n serverTime\n }\n }\n"],["\n query PasswordChangeConfigQuery {\n passwordChangeConfig {\n maxAuthAgeSeconds\n authTime\n serverTime\n }\n }\n"]))),Wn=P,Vn=function(){},Bn=function(){function e(e,t,n,r,i,a,s,o,c){this.config=e,this.http=t,this.apollo=n,this.auth=r,this.profileService=i,this.keyFactory=a,this.encryptionService=s,this.keyGraph=o,this.webCryptoService=c,this.CLIENT_NONCE_LENGTH=32}return e.prototype.checkPassword=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return t=this.passwordStrength(e).years,n={length:e.length,timeToCrack:Wn.duration({years:t})},[4,this.getExposureCount(e)];case 1:return[2,(n.passwordExposed=r.sent(),n)]}}))}))},e.prototype.getExposureCount=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i;return O(this,(function(a){switch(a.label){case 0:return[4,this.webCryptoService.stringDigest("SHA-1",e)];case 1:return t=a.sent(),n=t.substring(0,5),[4,this.http.get("https://api.pwnedpasswords.com/range/"+n,{responseType:"text"}).toPromise()];case 2:return r=a.sent(),(i=new RegExp("^(?:"+t.substring(5)+":)(?<count>\\d+)$","im").exec(r))?[2,+i.groups.count]:[2,0]}}))}))},e.prototype.getPassIdpString=function(e){return e.toJSON(!0).k},e.prototype.createPassKeyBundle=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s;return O(this,(function(o){switch(o.label){case 0:return[4,this.keyFactory.createPassIdpParams()];case 1:return t=o.sent(),[4,this.keyFactory.derivePassIdp(Object.assign({password:e},t))];case 2:return n=o.sent().jwk,[4,this.keyFactory.createPassKeyParams()];case 3:return r=o.sent(),[4,this.keyFactory.derivePassKey(Object.assign({password:e},r))];case 4:return i=o.sent().jwk,[4,this.keyFactory.createPkcSignKey()];case 5:return a=o.sent(),[4,this.encryptionService.encrypt(i,a.toJSON(!0))];case 6:return s=o.sent(),[2,{passKeyParams:r,passKey:i,passIdpParams:t,passIdp:n,passIdpVerifier:a,wrappedPassIdpVerifierPrk:s}]}}))}))},e.prototype.isLoginRequired=function(){return M(this,void 0,void 0,(function(){var e,t,n,r;return O(this,(function(i){switch(i.label){case 0:return[4,this.getChangePasswordConfig()];case 1:return e=i.sent(),t=Wn(e.authTime),n=Wn(e.serverTime),r=Wn.duration(n.diff(t)),r.asSeconds()>e.maxAuthAgeSeconds?[2,!0]:[2,!1]}}))}))},e.prototype.changePassword=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p;return O(this,(function(d){switch(d.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return n=d.sent(),[4,this.profileService.getCurrentUser()];case 2:return r=d.sent().currentUser,[4,this.verifyPassword(e,r)];case 3:return i=d.sent(),a=i.passIdp,s=i.signedChallenge,[4,this.createPassKeyBundle(t)];case 4:return o=d.sent(),[4,this.keyGraph.getKey(r.currentUserKey.masterKey.id)];case 5:return c=d.sent(),[4,this.encryptionService.encrypt(o.passKey,c.jwk.toJSON(!0))];case 6:return u=d.sent(),[4,this.changePasswordMutation(s,r.currentUserKey.masterKey.id,u,o)];case 7:return p=d.sent().token,[4,this.auth.changePassword(n,this.getPassIdpString(a),this.getPassIdpString(o.passIdp))];case 8:return d.sent(),[4,this.changePasswordComplete({useNewPassword:!0,token:p})];case 9:return d.sent(),[2]}}))}))},e.prototype.changePasswordComplete=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a;return O(this,(function(s){switch(s.label){case 0:return t=e.useNewPassword,n=e.token,i=(r=this.http).post,a=[this.config.authUrl+"users/password-change-complete/",Object.assign({use_new_password:t},n&&{token:n})],[4,be(this.auth,this.config)];case 1:return[2,i.apply(r,a.concat([s.sent()])).toPromise()]}}))}))},e.prototype.getVerifierPrK=function(e,t){return M(this,void 0,void 0,(function(){var n;return O(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.encryptionService.decrypt(e,t)];case 1:return n=r.sent(),[2,ge.asKey(n)];case 2:throw r.sent(),new G("Wrong current password");case 3:return[2]}}))}))},e.prototype.verifyPassword=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s;return O(this,(function(o){switch(o.label){case 0:return[4,this.apollo.mutate({mutation:Jn,variables:{}})];case 1:return n=o.sent(),[4,this.keyFactory.derivePassKey(Object.assign({password:e},t.currentUserKey.passKey.passKeyParams))];case 2:return r=o.sent(),[4,this.getVerifierPrK(r.jwk,t.currentUserKey.passKey.wrappedPassIdpVerifierPrk)];case 3:return i=o.sent(),a=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.encryptionService.sign(i,{serverNonce:n.passwordChangeRequest.challenge.serverNonce,clientNonce:a})];case 4:return s=o.sent(),[4,this.keyFactory.derivePassIdp(Object.assign({password:e},t.currentUserKey.passKey.passIdpParams))];case 5:return[2,{passIdp:o.sent().jwk,signedChallenge:s}]}}))}))},e.prototype.changePasswordMutation=function(e,t,n,r){return M(this,void 0,void 0,(function(){var i;return O(this,(function(a){switch(a.label){case 0:return[4,this.apollo.mutate({mutation:Gn,variables:{input:{signedChallenge:JSON.stringify(e),masterKeyId:t,newWrappedMasterKey:JSON.stringify(n),newPassKey:{passIdpParams:JSON.stringify(r.passIdpParams),passIdpVerifierPbk:JSON.stringify(r.passIdpVerifier.toJSON()),wrappedPassIdpVerifierPrk:JSON.stringify(r.wrappedPassIdpVerifierPrk),passKeyParams:JSON.stringify(r.passKeyParams)}}}})];case 1:return[2,{token:(i=a.sent()).passwordChange.token,newPassKeyId:i.passwordChange.newPassKey.id}]}}))}))},e.prototype.getChangePasswordConfig=function(){return M(this,void 0,void 0,(function(){var e,t;return O(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query({query:Qn})];case 1:return e=n.sent(),(t=e.passwordChangeConfig).authTime=new Date(t.authTime),t.serverTime=new Date(t.serverTime),[2,t]}}))}))},e.prototype.passwordStrength=function(e){function t(e,t){return((e||"").match(t)||[]).length}var n=t(e,/[A-Z]/g),r=t(e,/[a-z]/g),i=t(e,/[0-9]/g),a=0;if(n&&(a+=26),r&&(a+=26),i&&(a+=10),e.length-n-r-i&&(a+=30),0===e.length)return{years:0,bits:0};var s=Math.pow(a,e.length);return{years:54e3*s/Math.pow(62,12),bits:Math.round(Math.log2(s))}},e}();Bn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Bn(t.ɵɵinject(Se),t.ɵɵinject(y.HttpClient),t.ɵɵinject(ke),t.ɵɵinject(s.AuthClass),t.ɵɵinject(Ln),t.ɵɵinject(ge),t.ɵɵinject(ve),t.ɵɵinject(Pe),t.ɵɵinject(me))},token:Bn,providedIn:"root"}),Bn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Bn.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:y.HttpClient},{type:ke},{type:s.AuthClass},{type:Ln},{type:ge},{type:ve},{type:Pe},{type:me}]};var Zn="lifeready",Hn=function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=""),this.assembly=e,this.subAssembly=t,this.mnemonics=n},Yn=function(){function e(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0),this.index=e,this.threshold=t,this.size=n,this.clearShares()}return e.prototype.clearShares=function(){this.shares=[]},e.prototype.addShare=function(e){this.shares.push(e)},e}(),Xn=function(){function e(e){void 0===e&&(e=0),this.threshold=e,this.clearSubAssemblies()}return e.prototype.size=function(){return this.subAssemblies.length},e.prototype.clearSubAssemblies=function(){this.subAssemblies=[]},e.prototype.addSubAssembly=function(e){this.subAssemblies.push(e)},e}(),zn=(function(){function e(e){this.subAssemblyIndex=e,this.clearShares()}e.prototype.clearShares=function(){this.shares=[]},e.prototype.addShare=function(e){this.shares.push(e)}}(),function(){function e(){this.clearSubQuora()}e.prototype.clearSubQuora=function(){this.subQuora=[]},e.prototype.addSubQuorum=function(e){this.subQuora.push(e)},e.prototype.serialiseShares=function(){var e=[];return this.subQuora.forEach((function(t){e=e.concat(t.shares)})),e}}(),function(){function e(){}return e.prototype.generateShares=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p;return O(this,(function(d){switch(d.label){case 0:r=btoa(e),r=g.Slip39Helper.slip39EncodeHex(r),i=[];try{for(a=T(n.subAssemblies),s=a.next();!s.done;s=a.next())o=s.value,i.push([o.threshold,o.size])}catch(e){u={error:e}}finally{try{s&&!s.done&&(p=a.return)&&p.call(a)}finally{if(u)throw u.error}}return[4,g.Slip39.fromArray(r,{passphrase:t,threshold:n.threshold,groups:i,title:""})];case 1:return c=d.sent(),n.subAssemblies.forEach((function(e,t){e.clearShares();for(var n=0;n<e.size;n++){var r="r/"+t.toString().padStart(2,"0")+"/"+n.toString().padStart(2,"0"),i=c.fromPath(r).mnemonics[0],a=new Hn(t,n,i);e.addShare(a)}})),[2]}}))}))},e.prototype.minimalSet=function(e){var t,n,r,i,a=null,s=new Map;try{for(var o=T(e),c=o.next();!c.done;c=o.next()){var u=c.value,p=g.Slip39Helper.decodeMnemonic(u);if(a&&a!==p.groupThreshold)throw new Error("groupThreshold is different in mnemonics");a=p.groupThreshold,null==(f=s.get(p.groupIndex))&&(f={memberThreshold:p.memberThreshold,members:[]},s.set(p.groupIndex,f)),f.members.push({mnemonic:u,decoded:p})}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}var d=[],l=0;try{for(var h=T(s.values()),y=h.next();!y.done;y=h.next()){var f;if(!((f=y.value).members.length<f.memberThreshold)&&(f.members.slice(0,f.memberThreshold).forEach((function(e){d.push(e.mnemonic)})),++l>=a))break}}catch(e){r={error:e}}finally{try{y&&!y.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}return d},e.prototype.recoverSecret=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return O(this,(function(i){switch(i.label){case 0:return e=this.minimalSet(e),[4,g.Slip39.recoverSecret(e,t)];case 1:return n=i.sent(),r=g.Slip39Helper.slip39DecodeHex(n),[2,atob(r)]}}))}))},e}());zn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new zn},token:zn,providedIn:"root"}),zn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}];var er,tr=Te(er||(er=F(["\nquery TpsKeysQuery($ids: [ID]) {\n tps(id_In: $ids) {\n edges {\n node {\n id\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n }\n }\n }\n }\n }\n}"],["\nquery TpsKeysQuery($ids: [ID]) {\n tps(id_In: $ids) {\n edges {\n node {\n id\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n }\n }\n }\n }\n }\n}"]))),nr=function(){function t(t){this.keyFactory=t.get(ge),this.keyService=t.get(Ke),this.encryptionService=t.get(ve),this.keyGraph=t.get(Pe),this.slip39Service=t.get(zn),this.lrGraphQl=t.get(e.ɵg)}return t.prototype.recoverAssemblyKey=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return O(this,(function(i){switch(i.label){case 0:return n=e.map((function(e){if(t){if(JSON.stringify(t)!==JSON.stringify(e.assemblyKeyParams))throw new Z("The assembly key parameters are different between the approvals.")}else t=e.assemblyKeyParams;return e.slip39.share.mnemonics})),[4,this.slip39Service.recoverSecret(n,this.slip39Passphrase)];case 1:return r=i.sent(),[4,ge.asKey(Object.assign(Object.assign({},t),{k:r}))];case 2:return[2,i.sent()]}}))}))},t.prototype.prepareTpWrappingKey=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.keyGraph.getKey(e.wrappingKeyId)]}))}))},t.prototype.prepareAssembly=function(e){var t=e.subjectKey,n=e.rootKey;return M(this,void 0,void 0,(function(){var e,r,i,a,s,o,c,u,p;return O(this,(function(d){switch(d.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=d.sent(),r=e.toJSON(!0),i=r.k,a=D(r,["k"]),[4,this.keyFactory.createPkcSignKey()];case 2:return s=d.sent(),[4,this.encryptionService.encryptToString(e,s.toJSON(!0))];case 3:return o=d.sent(),c=JSON.stringify(s.toJSON()),[4,this.encryptionService.encryptToString(t,e.toJSON(!0))];case 4:return u=d.sent(),[4,this.encryptionService.encryptToString(e,{rootKey:n.toJSON(!0)})];case 5:return p=d.sent(),[2,{assemblyKey:e,rawAssemblyKey:i,assemblyKeyParams:a,subjectKeyWrappedAssemblyKey:u,assemblyCipherData:p,assemblyKeyVerifierPbk:c,wrappedAssemblyKeyVerifierPrk:o}]}}))}))},t.prototype.prepareCreateSubAssemblies=function(e){var t=e.input,n=e.subjectKey,r=e.slipSubAssemblies,i=e.assemblyKeyParams;return M(this,void 0,void 0,(function(){var e=this;return O(this,(function(a){return[2,Promise.all(t.map((function(t,a){return M(e,void 0,void 0,(function(){var e,s,o=this;return O(this,(function(c){switch(c.label){case 0:return[4,this.encryptionService.encryptToString(n,t.subjectCipherDataClearJson||"")];case 1:return e=c.sent(),[4,Promise.all(t.approverTps.map((function(e,t){return M(o,void 0,void 0,(function(){return O(this,(function(s){return[2,this.prepareApprover({tp:e,approverIndex:t,slipSubAssembly:r[a],assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 2:return s=c.sent(),[2,{singleReject:t.singleReject,quorum:t.quorum,subjectCipherData:e,createApprovers:s}]}}))}))})))]}))}))},t.prototype.prepareUpdateSubAssemblies=function(e){var t=e.input,n=e.subjectKey,r=e.slipSubAssemblies,i=e.assemblyKeyParams,a=e.subAssemblies;return M(this,void 0,void 0,(function(){var e=this;return O(this,(function(s){if(r.length!==t.length)throw new Q("The slipSubAssemblies must be the same length as the input");return[2,Promise.all(t.map((function(t,s){return M(e,void 0,void 0,(function(){var e,o,c,u,p,d,l=this;return O(this,(function(h){switch(h.label){case 0:return[4,this.encryptionService.encryptToString(n,t.subjectCipherDataClearJson||"")];case 1:return e=h.sent(),o=a.edges.find((function(e){return e.node.id===t.id})).node,c=[],u=[],t.approverTps.forEach((function(e){var t,n=null===(t=o.approvers.edges.find((function(t){return t.node.tp.id===e.tpId})))||void 0===t?void 0:t.node;n?u.push({tp:e,approverId:n.id}):c.push({tp:e})})),p=r[s],d={subAssemblyId:t.id,singleReject:t.singleReject,quorum:t.quorum,subjectCipherData:e},[4,Promise.all(c.map((function(e,t){var r=e.tp;return M(l,void 0,void 0,(function(){return O(this,(function(e){return[2,this.prepareApprover({tp:r,approverIndex:t,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 2:return d.createApprovers=h.sent(),[4,Promise.all(u.map((function(e,t){var r=e.tp,a=e.approverId;return M(l,void 0,void 0,(function(){return O(this,(function(e){return[2,this.prepareApprover({approverId:a,tp:r,approverIndex:t+c.length,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 3:return[2,(d.updateApprovers=h.sent(),d)]}}))}))})))]}))}))},t.prototype.fillWrappingKeyId=function(e,t){var n=this;e.forEach((function(e){e.approverTps.forEach((function(e){if(!e.wrappingKeyId){var r=t.find((function(t){return t.id===e.tpId}));e.wrappingKeyId=n.getTpWrappingKeyId(r)}}))}))},t.prototype.getInputApprovers=function(e){var t=[];return e.forEach((function(e){e.approverTps.forEach((function(e){t.push(e.tpId)}))})),t},t.prototype.prepareCreate=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,h,y;return O(this,(function(f){switch(f.label){case 0:return t=this.keyService.currentRootKey,[4,this.keyFactory.createKey()];case 1:return n=f.sent(),[4,this.keyGraph.wrapKey(t,n)];case 2:return r=f.sent(),[4,this.prepareAssembly({rootKey:t.jwk,subjectKey:n})];case 3:return i=f.sent(),a=i.assemblyKey,s=i.rawAssemblyKey,o=i.assemblyKeyParams,c=D(i,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),[4,this.prepareSlip39(e.createSubAssemblies,e.quorum,s)];case 4:return u=f.sent(),p=this.getInputApprovers(e.createSubAssemblies),l=Pt,[4,this.lrGraphQl.query({query:tr,variables:{ids:p}})];case 5:return d=l.apply(void 0,[f.sent().tps]),this.fillWrappingKeyId(e.createSubAssemblies,d),[4,this.prepareCreateSubAssemblies({input:e.createSubAssemblies,assemblyKeyParams:o,slipSubAssemblies:u.subAssemblies,subjectKey:n})];case 6:return h=f.sent(),[4,this.encryptionService.encryptToString(n,e.subjectCipherDataClearJson||"")];case 7:return y=f.sent(),[2,{assemblyKey:a,mutationInput:Object.assign(Object.assign({},c),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:y,createSubAssemblies:h,rootKeyId:t.id,rootKeyWrappedSubjectKey:r})}]}}))}))},t.prototype.getAssemblyApprovers=function(e){var t=[];return Pt(e.subAssemblies).map((function(e){Pt(e.approvers).forEach((function(e){return t.push(e.tp.id)}))})),t},t.prototype.prepareUpdate=function(e,t){var n;return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b;return O(this,(function(I){switch(I.label){case 0:if(e=Object.assign({createSubAssemblies:[]},e),r=e.createSubAssemblies||[],i=e.updateSubAssemblies||[],a=e.deleteSubAssemblies||[],0===r.length&&0===i.length&&0===a.length)throw new Q("Must specify at least one of: [createSubAssemblies, updateSubAssemblies, deleteSubAssemblies]");return s=this.keyService.currentRootKey,[4,this.keyGraph.getKey(t.subjectKey.id)];case 1:return o=I.sent(),[4,this.prepareAssembly({rootKey:s.jwk,subjectKey:o.jwk})];case 2:return c=I.sent(),u=c.assemblyKey,p=c.rawAssemblyKey,d=c.assemblyKeyParams,l=D(c,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),h=this.getAssemblyApprovers(t).concat(this.getInputApprovers(r),this.getInputApprovers(i)),f=Pt,[4,this.lrGraphQl.query({query:tr,variables:{ids:h}})];case 3:y=f.apply(void 0,[I.sent().tps]),Pt(t.subAssemblies).forEach((function(e){if(!a.includes(e.id)&&!i.some((function(t){return t.id===e.id}))){var t=Pt(e.approvers).map((function(e){return{tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,sharedCipherApprovalDataClearJson:e.sharedCipherApprovalDataClearJson}}));i.push({id:e.id,quorum:e.quorum,singleReject:e.singleReject,approverTps:t,subjectCipherDataClearJson:e.subjectCipherDataClearJson})}})),this.fillWrappingKeyId(r,y),this.fillWrappingKeyId(i,y),I.label=4;case 4:return I.trys.push([4,6,,7]),[4,this.prepareSlip39((r||[]).concat(i||[]),e.quorum,p)];case 5:return v=I.sent(),[3,7];case 6:return m=I.sent(),console.log("Error while creating slip assembly",m),[3,7];case 7:return g={assemblyKeyParams:d,subjectKey:o.jwk},[4,this.prepareCreateSubAssemblies(Object.assign(Object.assign({},g),{input:r,slipSubAssemblies:v.subAssemblies.slice(0,r.length)}))];case 8:return S=I.sent(),[4,this.prepareUpdateSubAssemblies(Object.assign(Object.assign({},g),{input:i,slipSubAssemblies:v.subAssemblies.slice(r.length),subAssemblies:t.subAssemblies}))];case 9:return C=I.sent(),[4,this.encryptionService.encryptToString(o.jwk,null!==(n=e.subjectCipherDataClearJson)&&void 0!==n?n:t.subjectCipherDataClearJson)];case 10:return b=I.sent(),[2,{assemblyKey:u,mutationInput:Object.assign(Object.assign({},l),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:b,subjectKeyId:o.id,createSubAssemblies:S,updateSubAssemblies:C})}]}}))}))},t.prototype.prepareApprover=function(e){var t=e.approverId,n=e.tp,r=e.approverIndex,i=e.slipSubAssembly,a=e.assemblyKeyParams,s=e.subjectKey;return M(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,h,y;return O(this,(function(f){switch(f.label){case 0:return[4,this.prepareTpWrappingKey(n)];case 1:return e=f.sent(),[4,this.keyFactory.createKey()];case 2:return o=f.sent(),[4,this.encryptionService.encryptToString(e.jwk,o.toJSON(!0))];case 3:return c=f.sent(),[4,this.encryptionService.encryptToString(s,o.toJSON(!0))];case 4:return u=f.sent(),p=1===i.threshold?i.shares[0]:i.shares[r],d={slip39:{share:p,subAssembly:{quorum:i.threshold,size:i.size}},assemblyKeyParams:a},[4,this.encryptionService.encryptToString(o,n.sharedCipherDataClearJson||"")];case 5:return l=f.sent(),[4,this.encryptionService.encryptToString(o,n.sharedCipherApprovalDataClearJson||"")];case 6:return h=f.sent(),[4,this.encryptionService.encryptToString(o,d)];case 7:return y=f.sent(),[2,{tpWrappingKeyId:e.id,tpWrappedSharedKey:c,subjectKeyWrappedSharedKey:u,sharedCipherData:l,sharedCipherApprovalData:h,sharedCipherPartialAssemblyKey:y,approverId:t||void 0,tpId:t?void 0:n.tpId}]}}))}))},t.prototype.validateApprovers=function(e){var t,n;try{for(var r=T(e),i=r.next();!i.done;i=r.next()){var a=i.value;if(!a.currentUserSharedKey.userSharedKey.mkSharedKey){var s="tp "+a.other.username+" does not have mkSharedKey";throw console.log(s),new Q(s)}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},t.prototype.prepareSlip39=function(e,t,n){return M(this,void 0,void 0,(function(){var r;return O(this,(function(i){switch(i.label){case 0:if(e.length<t)throw new Q("Not enough sub assemblies to meet quorum");return r=new Xn(t),e.forEach((function(e,t){var n=e.approverTps.length;1===e.quorum&&(n=1),r.addSubAssembly(new Yn(t,e.quorum,n))})),[4,this.slip39Service.generateShares(n,this.slip39Passphrase,r)];case 1:return i.sent(),[2,r]}}))}))},t}();e.ɵi=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r.slip39Passphrase=Zn,r}return E(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.mkSharedKey.id},t}(nr),e.ɵi.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵi(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵi,providedIn:"root"}),e.ɵi.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵi.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵi=A([qe({ngZoneName:"ngZone"})],e.ɵi);var rr,ir,ar,sr,or,cr,ur,pr,dr,lr,hr,yr,fr,vr,mr,gr,Sr=Te(rr||(rr=F(["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"],["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"]))),Cr=Te(ir||(ir=F(["\nmutation CreateTpAssemblyKeyChallengeMutation(\n $input: CreateTpAssemblyKeyChallengeInput!\n) {\n createTpAssemblyKeyChallenge(input: $input) {\n challenge\n }\n}"],["\nmutation CreateTpAssemblyKeyChallengeMutation(\n $input: CreateTpAssemblyKeyChallengeInput!\n) {\n createTpAssemblyKeyChallenge(input: $input) {\n challenge\n }\n}"]))),br=Te(ar||(ar=F(["\nmutation PreCompleteTpPasswordResetRequestMutation(\n $input: PreCompleteTpPasswordResetRequestInput!\n) {\n preCompleteTpPasswordResetRequest(input: $input) {\n idpPassword\n }\n}"],["\nmutation PreCompleteTpPasswordResetRequestMutation(\n $input: PreCompleteTpPasswordResetRequestInput!\n) {\n preCompleteTpPasswordResetRequest(input: $input) {\n idpPassword\n }\n}"]))),Ir=Te(sr||(sr=F(["\nmutation CompleteTpPasswordResetRequestMutation(\n $input: CompleteTpPasswordResetRequestInput!\n) {\n completeTpPasswordResetRequest(input: $input) {\n id\n }\n}"],["\nmutation CompleteTpPasswordResetRequestMutation(\n $input: CompleteTpPasswordResetRequestInput!\n) {\n completeTpPasswordResetRequest(input: $input) {\n id\n }\n}"]))),wr=Te(or||(or=F(["\nmutation ApproveTpPasswordResetRequestMutation(\n $input: ApproveTpPasswordResetRequestInput!\n) {\n approveTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"],["\nmutation ApproveTpPasswordResetRequestMutation(\n $input: ApproveTpPasswordResetRequestInput!\n) {\n approveTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"]))),Kr=Te(cr||(cr=F(["\nmutation RejectTpPasswordResetRequestMutation(\n $input: RejectTpPasswordResetRequestInput!\n) {\n rejectTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"],["\nmutation RejectTpPasswordResetRequestMutation(\n $input: RejectTpPasswordResetRequestInput!\n) {\n rejectTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"]))),Pr=Te(ur||(ur=F(["\nmutation CreateTpPasswordResetMutation($input: CreateTpPasswordResetInput!) {\n createTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"],["\nmutation CreateTpPasswordResetMutation($input: CreateTpPasswordResetInput!) {\n createTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"]))),kr=Te(pr||(pr=F(["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"],["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"]))),Rr=Te(dr||(dr=F(["\nmutation UpdateTpPasswordResetMutation($input: UpdateTpPasswordResetInput!) {\n updateTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"],["\nmutation UpdateTpPasswordResetMutation($input: UpdateTpPasswordResetInput!) {\n updateTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"]))),Er=function(){function e(e,t){var n=this;this._key=e,this.timer=setTimeout((function(){n._key=null}),t)}return Object.defineProperty(e.prototype,"key",{get:function(){return this._key},enumerable:!1,configurable:!0}),e.prototype.pop=function(){var e=this._key;return this._key=null,this.timer&&(clearTimeout(this.timer),this.timer=null),e},e}(),Dr=Te(lr||(lr=F(["\nquery {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n sessionEncryptionKey\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n sessionEncryptionKey\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"])),_e),Ar=Te(hr||(hr=F(["\nquery ResetUserQuery {\n tpPasswordResetUser {\n username\n sessionEncryptionKey\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n }\n}"],["\nquery ResetUserQuery {\n tpPasswordResetUser {\n username\n sessionEncryptionKey\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n }\n}"]))),Mr=Te(yr||(yr=F(["\nmutation SetSessionEncryptionKeyMutation($input: SetSessionEncryptionKeyInput!) {\n setSessionEncryptionKey(input: $input) {\n sessionEncryptionKey\n }\n}\n"],["\nmutation SetSessionEncryptionKeyMutation($input: SetSessionEncryptionKeyInput!) {\n setSessionEncryptionKey(input: $input) {\n sessionEncryptionKey\n }\n}\n"])));(fr=e.RecoveryStatus||(e.RecoveryStatus={})).NONE="NONE",fr.NEW_PASSWORD="NEW_PASSWORD",fr.OLD_PASSWORD="OLD_PASSWORD",(vr=e.PasswordChangeStatus||(e.PasswordChangeStatus={})).IN_PROGRESS="IN_PROGRESS",vr.RECOVERY="RECOVERY",(mr=e.CognitoChallengeName||(e.CognitoChallengeName={})).NEW_PASSWORD_REQUIRED="NEW_PASSWORD_REQUIRED",mr.SMS_MFA="SMS_MFA",mr.SOFTWARE_TOKEN_MFA="SOFTWARE_TOKEN_MFA",mr.MFA_SETUP="MFA_SETUP",e.AuthService=gr=function(n){function r(e,r,i,a,s,o,c,u,p,d,l,h,y,f){var v=n.call(this,r)||this;if(v.ngZone=e,v.injector=r,v.http=i,v.cognito=a,v.api=s,v.keyService=o,v.keyGraphService=c,v.keyFactoryService=u,v.passwordService=p,v.idleService=d,v.persistService=l,v.encryptionService=h,v.assemblyController=y,v.kcConfig=f,v.logoutListeners=new Set,v.password=null,!t.isDevMode()&&null!=v.kcConfig.debug)throw new V('In production mode, "KcConfig.debug" must be set to null');return v}return E(r,n),r.prototype.importPassword=function(e){return this.keyFactoryService.importPassword(e)},r.prototype.logout=function(){var e;return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,Promise.all(N(this.logoutListeners).map((function(e){return e()})))];case 1:return t.sent(),this.user=null,this.keyService.purgeKeys(),this.keyGraphService.purgeKeys(),[4,Promise.all([this.cognito.signOut(),this.kcLogout()])];case 2:return t.sent(),(null===(e=this.kcConfig.debug)||void 0===e?void 0:e.username)&&(this.kcConfig.debug.username=null),[2]}}))}))},r.prototype.addLogoutListener=function(e){this.logoutListeners.add(e)},r.prototype.removeLogoutListener=function(e){this.logoutListeners.delete(e)},r.prototype.login=function(t,n,r){var i,a=(void 0===r?{}:r).tpPasswordResetAutoComplete,s=void 0===a||a;return M(this,void 0,void 0,(function(){var r;return O(this,(function(a){switch(a.label){case 0:return[4,this.loginImpl(t,n)];case 1:return(r=a.sent()).challenge?(this.password=new Er(n,gr.CHALLENGE_TIMEOUT),[2,r]):s&&(null===(i=r.user.resetUser)||void 0===i?void 0:i.state)===e.TpClaimState.APPROVED?[4,this.completeResetRequest(n)]:[3,4];case 2:return a.sent(),[4,this.loginImpl(t,n)];case 3:r=a.sent(),a.label=4;case 4:return[2,r]}}))}))},r.prototype.verifyLogin=function(t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o;return O(this,(function(c){switch(c.label){case 0:if(n=t.challenge,r=t.code,i=t.rememberMe,!(a=[e.CognitoChallengeName.SMS_MFA,e.CognitoChallengeName.SOFTWARE_TOKEN_MFA]).includes(n.cognitoUser.challengeName))throw new V("challengeName must be one of "+a);return[4,this.cognito.confirmSignIn(n.cognitoUser,r,n.cognitoUser.challengeName)];case 1:return s=c.sent(),[4,this.handlePostAuth(n.recoveryStatus)];case 2:return c.sent(),[4,this.loadUser(s,this.password.pop())];case 3:return o=c.sent(),this.password=null,i&&s.setDeviceStatusRemembered({onSuccess:function(){},onFailure:function(e){return console.error(e)}}),[2,{user:o}]}}))}))},r.prototype.getUser=function(){return M(this,void 0,void 0,(function(){var e;return O(this,(function(t){switch(t.label){case 0:return this.user?[2,this.user]:[4,this.cognito.currentAuthenticatedUser()];case 1:return e=t.sent(),[2,this.loadUser(e)]}}))}))},r.prototype.refreshAccessToken=function(){return M(this,void 0,void 0,(function(){var e,t;return O(this,(function(n){switch(n.label){case 0:return[4,this.cognito.currentAuthenticatedUser()];case 1:return e=n.sent(),t=e.getSignInUserSession().getRefreshToken(),console.log("Token refresh..."),[2,new Promise((function(n,r){e.refreshSession(t,(function(e){e?(console.error("Error refreshing token: ",e),r(e)):(console.log("Token refresh complete"),n(0))}))}))]}}))}))},r.prototype.fetchCurrentUser=function(){return M(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.api.query({query:Dr,processorOptions:{hasKeys:!1}})];case 1:return[2,e.sent().currentUser]}}))}))},r.prototype.fetchResetUser=function(){return M(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.api.query({query:Ar,processorOptions:{hasKeys:!1}})];case 1:return[2,e.sent().tpPasswordResetUser]}}))}))},r.prototype.kcLogout=function(){return M(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.http.post(this.kcConfig.authUrl+"auth/sign-out/",null,{withCredentials:!0,responseType:"text"}).toPromise()];case 1:return e.sent(),[2]}}))}))},r.prototype.fetchPassIdpParams=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.http.get(this.kcConfig.authUrl+"users/pass-idp-params/?login_name="+encodeURIComponent(e)).toPromise()];case 1:return[2,t.sent()]}}))}))},r.prototype.loginImpl=function(t,n){return M(this,void 0,void 0,(function(){var r;return O(this,(function(i){switch(i.label){case 0:return[4,this.logout()];case 1:return i.sent(),[4,this.loginIdp(t,n)];case 2:return r=i.sent(),[e.CognitoChallengeName.SMS_MFA,e.CognitoChallengeName.SOFTWARE_TOKEN_MFA].includes(r.cognitoUser.challengeName)?[2,{challenge:{cognitoUser:r.cognitoUser,recoveryStatus:r.recoveryStatus}}]:[4,this.handlePostAuth(r.recoveryStatus)];case 3:return i.sent(),[4,this.loadUser(r.cognitoUser,n)];case 4:return[2,{user:i.sent()}]}}))}))},r.prototype.loginIdp=function(t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l;return O(this,(function(h){switch(h.label){case 0:return[4,this.fetchPassIdpParams(t)];case 1:if((r=h.sent()).passwordChangeStatus===e.PasswordChangeStatus.IN_PROGRESS)throw new X("A password change is in progress");if(r.passwordChangeStatus!==e.PasswordChangeStatus.RECOVERY)return[3,8];console.log("In recovery mode."),h.label=2;case 2:return h.trys.push([2,4,,5]),a={},[4,this.loginIdpImpl(t,n,r.newPassIdpParams)];case 3:return a.cognitoUser=h.sent(),a.recoveryStatus=e.RecoveryStatus.NEW_PASSWORD,i=a,console.log("New password works!"),[2,i];case 4:if("NotAuthorizedException"!==(s=h.sent()).code)throw s;return[3,5];case 5:return h.trys.push([5,7,,8]),c={},[4,this.loginIdpImpl(t,n,r.currentPassIdpParams)];case 6:return c.cognitoUser=h.sent(),c.recoveryStatus=e.RecoveryStatus.OLD_PASSWORD,o=c,console.log("Old password works!"),[2,o];case 7:throw"NotAuthorizedException"===(u=h.sent()).code?new V("The password change request was interrupted, please try to login with both your new and old password"):u;case 8:if(!r.tpPasswordReset)return[3,12];h.label=9;case 9:return h.trys.push([9,11,,12]),p=r.tpPasswordReset,d={},[4,this.loginIdpImpl(p.resetUsername,n,p.passIdpParams)];case 10:return d.cognitoUser=h.sent(),d.recoveryStatus=e.RecoveryStatus.NONE,[2,d];case 11:return h.sent(),[3,12];case 12:return l={},[4,this.loginIdpImpl(t,n,r.currentPassIdpParams)];case 13:return l.cognitoUser=h.sent(),l.recoveryStatus=e.RecoveryStatus.NONE,[2,l]}}))}))},r.prototype.loginIdpImpl=function(e,t,n){return M(this,void 0,void 0,(function(){var r;return O(this,(function(i){switch(i.label){case 0:return[4,this.keyFactoryService.derivePassIdp(Object.assign({password:t},n))];case 1:return r=i.sent(),[2,this.cognito.signIn(e,this.passwordService.getPassIdpString(r.jwk))]}}))}))},r.prototype.handlePostAuth=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.handlePasswordRecovery(e)];case 1:return t.sent(),[4,this.handleSessionEncryptionKey()];case 2:return t.sent(),[2]}}))}))},r.prototype.handlePasswordRecovery=function(t){return M(this,void 0,void 0,(function(){return O(this,(function(n){switch(n.label){case 0:return t===e.RecoveryStatus.NONE?[3,2]:[4,this.passwordService.changePasswordComplete({useNewPassword:t===e.RecoveryStatus.NEW_PASSWORD})];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},r.prototype.handleSessionEncryptionKey=function(){return M(this,void 0,void 0,(function(){var e,n;return O(this,(function(r){switch(r.label){case 0:if(!this.kcConfig.disableSessionEncryptionKey)return[3,1];if(!t.isDevMode())throw e="You should not set disableSessionEncryptionKey=True in mode prod. It defaults to false.",console.error(e),new ee(e);return console.warn("You have set disableSessionEncryptionKey=True. Make sure not to do this in prod mode."),[3,4];case 1:return[4,this.keyFactoryService.createKey()];case 2:return n=r.sent(),[4,this.lrGraphQL.lrMutate(new ze({mutation:Mr,variables:{input:{sessionEncryptionKey:JSON.stringify(n.toJSON(!0))}}}),{includeKeyGraph:!1})];case 3:r.sent(),this.persistService.setServerSessionEncryptionKey(n),r.label=4;case 4:return[2]}}))}))},r.prototype.getCognitoUserAttribute=function(e,t){var n=t.find((function(t){return t.getName()===e}));return n?n.getValue():null},r.prototype.loadUserKeys=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u;return O(this,(function(p){switch(p.label){case 0:return t=e.userKeys,n=e.password,(r=e.sessionEncryptionKey)?(s=(i=this.persistService).setServerSessionEncryptionKey,[4,a.JWK.asKey(r)]):[3,2];case 1:s.apply(i,[p.sent()]),p.label=2;case 2:return n?[4,this.keyFactoryService.derivePassKey(Object.assign({password:n},t.passKey.passKeyParams))]:[3,6];case 3:return o=p.sent().jwk,u=(c=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(t.passKey.id,o,t.masterKey.id)];case 4:return[4,u.apply(c,[p.sent()])];case 5:p.sent(),p.label=6;case 6:return[2]}}))}))},r.prototype.loadUser=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return O(this,(function(i){switch(i.label){case 0:return e.getUsername().endsWith(".tp_password_reset")?(n=this,[4,this.loadResetUser(e,t)]):[3,2];case 1:return n.user=i.sent(),[3,4];case 2:return r=this,[4,this.loadRegularUser(e,t)];case 3:r.user=i.sent(),i.label=4;case 4:return[4,this.idleService.start()];case 5:return i.sent(),[2,this.user]}}))}))},r.prototype.loadRegularUser=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a;return O(this,(function(s){switch(s.label){case 0:return[4,this.fetchCurrentUser()];case 1:return n=s.sent(),[4,this.loadUserKeys({userKeys:n.currentUserKey,password:t,sessionEncryptionKey:n.sessionEncryptionKey})];case 2:return s.sent(),[4,this.keyGraphService.populateKeys(n.currentUserKey)];case 3:return s.sent(),r=n.id,i=n.username,[4,this.cognito.userAttributes(e)];case 4:return a=s.sent(),[2,{id:r,username:i,sub:this.getCognitoUserAttribute("sub",a),loginEmail:this.getCognitoUserAttribute("email",a),resetUser:null}]}}))}))},r.prototype.loadResetUser=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a;return O(this,(function(s){switch(s.label){case 0:return[4,this.fetchResetUser()];case 1:return n=s.sent(),r={passKey:{id:n.passKey.id,passKeyParams:n.passKey.passKeyParams},masterKey:{id:n.masterKey.id}},[4,this.loadUserKeys({userKeys:r,password:t,sessionEncryptionKey:n.sessionEncryptionKey})];case 2:return s.sent(),[4,this.keyService.setKeys(r)];case 3:return s.sent(),i=n.username,[4,this.cognito.userAttributes(e)];case 4:return a=s.sent(),[2,{username:i,sub:this.getCognitoUserAttribute("sub",a),loginEmail:this.getCognitoUserAttribute("email",a),resetUser:{state:n.state}}]}}))}))},r.prototype.recoverAssemblyKey=function(e){return M(this,void 0,void 0,(function(){var t,n,r=this;return O(this,(function(i){switch(i.label){case 0:return[4,this.keyGraphService.getKey(e.pxk.id)];case 1:return t=i.sent(),[4,Promise.all(e.approvals.filter((function(e){return!!e.receiverCipherPartialAssemblyKey})).map((function(e){return r.encryptionService.decrypt(t,e.receiverCipherPartialAssemblyKey)})))];case 2:return n=i.sent(),[2,this.assemblyController.recoverAssemblyKey(n)]}}))}))},r.prototype.completeResetRequest=function(t){return M(this,void 0,void 0,(function(){var n,r,i,s,o,c,u,p,d,l,h,y,v,m,g=this;return O(this,(function(S){switch(S.label){case 0:return[4,this.fetchResetUser()];case 1:if((n=S.sent()).state!==e.TpClaimState.APPROVED)throw new Z("Password reset request has not been approved.");return[4,this.recoverAssemblyKey(n)];case 2:return r=S.sent(),[4,this.encryptionService.decrypt(r,n.assemblyCipherData)];case 3:return i=S.sent().rootKey,[4,a.JWK.asKey(i)];case 4:return s=S.sent(),[4,this.keyGraphService.getKey(n.masterKey.id)];case 5:return o=S.sent(),[4,this.encryptionService.encryptToString(o.jwk,s.toJSON(!0))];case 6:return c=S.sent(),[4,this.keyFactoryService.derivePassIdp(Object.assign({password:t},n.passKey.passIdpParams))];case 7:return u=S.sent(),p=this.passwordService.getPassIdpString(u.jwk),[4,this.lrGraphQL.lrMutate(new ze({mutation:Cr,variables:{input:{}}}),{includeKeyGraph:!1})];case 8:return(d=S.sent().createTpAssemblyKeyChallenge.challenge).clientNonce=this.keyFactoryService.randomString(32),[4,this.encryptionService.decrypt(r,n.wrappedAssemblyKeyVerifierPrk)];case 9:return l=S.sent(),[4,this.encryptionService.sign(l,d)];case 10:return h=S.sent(),[4,this.lrGraphQL.lrMutate(new ze({mutation:br,variables:{input:{signedChallenge:JSON.stringify(h)}}}),{includeKeyGraph:!1})];case 11:return y=S.sent().preCompleteTpPasswordResetRequest.idpPassword,v=new Promise((function(e){var t=function(r){return M(g,void 0,void 0,(function(){return O(this,(function(i){switch(i.label){case 0:return"signIn"!==r.payload.event?[2]:(f.Hub.remove("auth",t),[4,this.cognito.signIn(n.username,p)]);case 1:return i.sent(),[4,this.lrGraphQL.lrMutate(new ze({mutation:Ir,variables:{input:{masterKeyWrappedRootKey:c,masterKeyId:o.id}}}))];case 2:return i.sent(),e(),[2]}}))}))};f.Hub.listen("auth",t)})),[4,this.cognito.signIn(n.username,y,{noProxy:"true"})];case 12:if("NEW_PASSWORD_REQUIRED"!==(m=S.sent()).challengeName)throw new ee("Expecting Cognito to have done a password reset after call to PreCompleteTpPasswordResetRequestMutation.");return[4,this.cognito.completeNewPassword(m,p,{})];case 13:return m=S.sent(),[2,v]}}))}))},r.prototype.debugLogin=function(e,t){return this.kcConfig.debug.username=e,this.debugLoadUser(t)},r.prototype.debugLoadUser=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s;return O(this,(function(o){switch(o.label){case 0:return[4,this.fetchCurrentUser()];case 1:return t=o.sent(),n=t.id,r=t.username,i=t.currentUserKey,[4,this.keyFactoryService.derivePassKey(Object.assign({password:e},i.passKey.passKeyParams))];case 2:return a=o.sent().jwk,[4,this.keyGraphService.unwrapWithPassKey(i.passKey.id,a,i.masterKey.id)];case 3:return s=o.sent(),[4,this.idleService.persistMasterKey(s)];case 4:return o.sent(),[4,this.keyGraphService.populateKeys(i)];case 5:return o.sent(),this.user={id:n,username:r,resetUser:null,sub:"DEBUG_MODE",loginEmail:"DEBUG_MODE"},[2,this.user]}}))}))},r.prototype.debugClearUser=function(){this.user=null},r.prototype.getCurrentUserAttributes=function(){return M(this,void 0,void 0,(function(){var e;return O(this,(function(t){switch(t.label){case 0:return[4,this.cognito.currentAuthenticatedUser()];case 1:return e=t.sent(),[4,this.cognito.userAttributes(e)];case 2:return[2,t.sent()]}}))}))},r}(Kt),e.AuthService.CHALLENGE_TIMEOUT=3e5,e.AuthService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.AuthService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(y.HttpClient),t.ɵɵinject(s.AuthClass),t.ɵɵinject(e.ɵg),t.ɵɵinject(Ke),t.ɵɵinject(Pe),t.ɵɵinject(ge),t.ɵɵinject(Bn),t.ɵɵinject(Dt),t.ɵɵinject(we),t.ɵɵinject(ve),t.ɵɵinject(e.ɵi),t.ɵɵinject(Se))},token:e.AuthService,providedIn:"root"}),e.AuthService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.AuthService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:y.HttpClient},{type:s.AuthClass},{type:e.ɵg},{type:Ke},{type:Pe},{type:ge},{type:Bn},{type:Dt},{type:we},{type:ve},{type:e.ɵi},{type:void 0,decorators:[{type:t.Inject,args:[Se]}]}]},e.AuthService=gr=A([qe({ngZoneName:"ngZone"})],e.AuthService);var Or,Tr,jr,Nr=Te(Or||(Or=F(["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"],["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"]))),Fr=Te(Tr||(Tr=F(["\nmutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"],["\nmutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"]))),_r=Te(jr||(jr=F(["\nmutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n}\n"]))),$r=function(){};e.ContactCard2Service=function(){function e(e,t,n,r,i,a){this.keyFactory=e,this.keyService=t,this.encryptionService=n,this.keyGraph=r,this.keyMetaService=i,this.ngZone=a}return e.prototype.createContactCard=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a;return O(this,(function(s){switch(s.label){case 0:return t=this.keyService.currentRootKey,[4,this.keyFactory.createKey()];case 1:return n=s.sent(),[4,this.keyGraph.encryptToString(t.jwk,n.toJSON(!0))];case 2:return r=s.sent(),[4,this.keyGraph.encryptToString(n,e.plainCipherDataJson)];case 3:return i=s.sent(),[4,this.prepareContactCardInput(e)];case 4:return a=s.sent(),[2,new ze({mutation:Nr,variables:{input:Object.assign(Object.assign({},a),{wrappingKeyId:t.id,wrappedKey:r,cipherData:i})}})]}}))}))},e.prototype.updateContactCard=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return[4,this.keyGraph.encryptToString(e.keyId,e.plainCipherDataJson)];case 1:return t=r.sent(),[4,this.prepareContactCardInput(e)];case 2:return n=r.sent(),[2,new ze({mutation:Fr,variables:{input:Object.assign(Object.assign({},n),{id:e.id,cipherData:t})}})]}}))}))},e.prototype.deleteContactCard=function(e){return new ze({mutation:_r,variables:{input:{id:e}}})},e.prototype.prepareContactCardInput=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return O(this,(function(d){switch(d.label){case 0:return t=this.keyService.currentSigPxk,i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicDataJson)];case 1:return n=i.apply(r,[d.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicSearchableJson)];case 2:return a=o.apply(s,[d.sent()]),p=(u=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.plainDataJson)];case 3:return c=p.apply(u,[d.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:c}]}}))}))},e}(),e.ContactCard2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ContactCard2Service(t.ɵɵinject(ge),t.ɵɵinject(Ke),t.ɵɵinject(ve),t.ɵɵinject(Pe),t.ɵɵinject(xt),t.ɵɵinject(t.NgZone))},token:e.ContactCard2Service,providedIn:"root"}),e.ContactCard2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ContactCard2Service.ctorParameters=function(){return[{type:ge},{type:Ke},{type:ve},{type:Pe},{type:xt},{type:t.NgZone}]},e.ContactCard2Service=A([qe({ngZoneName:"ngZone"})],e.ContactCard2Service);var Lr=function(){function e(e,t,n){this.config=e,this.http=t,this.auth=n}return e.prototype.downloadEncryptedFileJson=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return n=(t=JSON).parse,[4,this.downloadEncryptedFile(e)];case 1:return[2,n.apply(t,[r.sent()])]}}))}))},e.prototype.downloadEncryptedFile=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return O(this,(function(p){switch(p.label){case 0:return t=this.config.apiUrl+"files/download/?file_state_node_id="+e,r=(n=this.http).get,i=[t],s=(a=Object).assign,c=(o=Object).assign,u=[{}],[4,be(this.auth,this.config)];case 1:return[4,r.apply(n,i.concat([s.apply(a,[c.apply(o,u.concat([p.sent()])),{responseType:"text"}])])).toPromise()];case 2:return[2,p.sent()]}}))}))},e.prototype.loadFile=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return e instanceof ArrayBuffer?[2,e]:[2,new Promise((function(t){var n=new FileReader;n.onload=function(){t(n.result)},n.readAsArrayBuffer(e)}))]}))}))},e.prototype.uploadEncryptedFile=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s;return O(this,(function(o){switch(o.label){case 0:return t=e.encryptedContent,n=e.fileName,(r=new FormData).append("content",new Blob([t]),n),a=(i=this.http).post,s=[this.config.apiUrl+"files/upload/",r],[4,be(this.auth,this.config)];case 1:return[4,a.apply(i,s.concat([o.sent()])).toPromise()];case 2:return[2,o.sent().content_resource]}}))}))},e}();Lr.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Lr(t.ɵɵinject(Se),t.ɵɵinject(y.HttpClient),t.ɵɵinject(s.AuthClass))},token:Lr,providedIn:"root"}),Lr.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Lr.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:y.HttpClient},{type:s.AuthClass}]};var Ur,xr,qr,Jr,Gr,Qr,Wr,Vr,Br,Zr,Hr,Yr,Xr,zr,ei,ti,ni,ri,ii,ai,si,oi=Te(Ur||(Ur=F(["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"],["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"]))),ci=Te(xr||(xr=F(["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"],["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"]))),ui=Te(qr||(qr=F(["\nmutation DeleteDirectoryMutation($input: DeleteDirectoryInput!) {\n deleteDirectory(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteDirectoryMutation($input: DeleteDirectoryInput!) {\n deleteDirectory(input: $input) {\n id\n }\n}\n"]))),pi=Te(Jr||(Jr=F(["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"],["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"]))),di=Te(Gr||(Gr=F(["\nmutation UpdateFileMutation($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation UpdateFileMutation($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),li=Te(Qr||(Qr=F(["\nmutation RevertFileMutation($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation RevertFileMutation($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),hi=Te(Wr||(Wr=F(["\nmutation DeleteFileMutation($input: DeleteFileInput!) {\n deleteFile(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteFileMutation($input: DeleteFileInput!) {\n deleteFile(input: $input) {\n id\n }\n}\n"]))),yi=Te(Vr||(Vr=F(["\nmutation ArchiveDirectoryMutation($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation ArchiveDirectoryMutation($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),fi=Te(Br||(Br=F(["\nmutation ArchiveFileMutation($input: ArchiveFileInput!) {\n archiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation ArchiveFileMutation($input: ArchiveFileInput!) {\n archiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),vi=Te(Zr||(Zr=F(["\nmutation UnarchiveDirectoryMutation($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation UnarchiveDirectoryMutation($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),mi=Te(Hr||(Hr=F(["\nmutation UnarchiveFileMutation($input: UnarchiveFileInput!) {\n unarchiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation UnarchiveFileMutation($input: UnarchiveFileInput!) {\n unarchiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),gi=Te(Yr||(Yr=F(["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),Si=Te(Xr||(Xr=F(["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"]))),Ci=Te(zr||(zr=F(["\nmutation BeginDeleteChildItemLinksWindowMutation($input: BeginDeleteChildItemLinksWindowInput!) {\n beginDeleteChildItemLinksWindow(input: $input) {\n begin\n end\n scheduled\n windowMs\n directory {\n id\n }\n }\n}\n"],["\nmutation BeginDeleteChildItemLinksWindowMutation($input: BeginDeleteChildItemLinksWindowInput!) {\n beginDeleteChildItemLinksWindow(input: $input) {\n begin\n end\n scheduled\n windowMs\n directory {\n id\n }\n }\n}\n"]))),bi=Te(ei||(ei=F(['\nquery TempDirectoryQuery($plainMeta: LrJSONFilter!) {\n rootDirectories(plainMeta: $plainMeta, first: 2, orderBy: "created") {\n edges {\n node {\n id\n keyId\n }\n }\n }\n lock {\n version\n }\n}\n'],['\nquery TempDirectoryQuery($plainMeta: LrJSONFilter!) {\n rootDirectories(plainMeta: $plainMeta, first: 2, orderBy: "created") {\n edges {\n node {\n id\n keyId\n }\n }\n }\n lock {\n version\n }\n}\n']))),Ii=Te(ti||(ti=F(["\nmutation SetFileConfidentialMutation($input: SetFileConfidentialInput!) {\n setFileConfidential(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation SetFileConfidentialMutation($input: SetFileConfidentialInput!) {\n setFileConfidential(input: $input) {\n file {\n id\n }\n }\n}\n"]))),wi=Te(ni||(ni=F(["\nmutation SetDirectoryConfidentialMutation($input: SetDirectoryConfidentialInput!) {\n setDirectoryConfidential(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation SetDirectoryConfidentialMutation($input: SetDirectoryConfidentialInput!) {\n setDirectoryConfidential(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),Ki=Te(ri||(ri=F(["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"],["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"]))),Pi=Te(ii||(ii=F(["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"],["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"])),Ki),ki=Te(ai||(ai=F(["\nmutation AcquireLockMutation($input: AcquireLockInput!) {\n acquireLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"],["\nmutation AcquireLockMutation($input: AcquireLockInput!) {\n acquireLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"])),Ki),Ri=Te(si||(si=F(["\nmutation ReleaseLockMutation($input: ReleaseLockInput!) {\n releaseLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"],["\nmutation ReleaseLockMutation($input: ReleaseLockInput!) {\n releaseLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"])),Ki);e.LockService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return E(t,e),t.prototype.updateLockMutation=function(e){return new ze({mutation:Pi,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t.prototype.acquireLockMutation=function(e){return new ze({mutation:ki,variables:{input:{resourceId:e.resourceId,timeoutMs:e.timeoutMs}}})},t.prototype.releaseLockMutation=function(e){return new ze({mutation:Ri,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t}(Kt),e.LockService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.LockService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.LockService,providedIn:"root"}),e.LockService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.LockService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.LockService=A([qe({ngZoneName:"ngZone"})],e.LockService);var Ei,Di,Ai,Mi,Oi,Ti,ji=Te(Ei||(Ei=F(["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"],["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"]))),Ni=Te(Di||(Di=F(["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"],["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"]))),Fi=Te(Ai||(Ai=F(["\nquery DirectoryKeyFromDirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"],["\nquery DirectoryKeyFromDirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"]))),_i=Te(Mi||(Mi=F(["\nquery FileKeyFromFileShareQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"],["\nquery FileKeyFromFileShareQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"]))),$i=Te(Oi||(Oi=F(["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"],["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"])));e.ItemService=Ti=function(t){function n(e,n,r,i,a,s,o,c){var u=t.call(this,n)||this;return u.ngZone=e,u.injector=n,u.fileUploadService=r,u.keyService=i,u.keyFactory=a,u.keyGraph=s,u.lockService=o,u.authService=c,u.tempDirectory=null,u.authService.addLogoutListener((function(){return u.onLogout()})),u}return E(n,t),n.prototype.downloadFileContent=function(e){return M(this,void 0,void 0,(function(){var t,n,r=this;return O(this,(function(i){switch(i.label){case 0:return[4,this.fileUploadService.downloadEncryptedFile(e.fileStateNodeId)];case 1:return t=i.sent(),[4,this.keyGraph.getKey(e.fileStateKeyId,(function(){return r.getFileStateKeyId(e.fileStateNodeId)}))];case 2:return n=i.sent(),[2,this.keyGraph.decryptFromString(n,t,{payloadType:L.UINT_8_ARRAY})]}}))}))},n.prototype.getDirectoryKeyId=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.query({query:ji,variables:{id:e}})];case 1:return[2,t.sent().directory.keyId]}}))}))},n.prototype.getFileKeyId=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.query({query:Ni,variables:{id:e}})];case 1:return[2,t.sent().file.keyId]}}))}))},n.prototype.getDirectoryKeyIdFromDirectoryShare=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.query({query:Fi,variables:{id:e}})];case 1:return[2,t.sent().directoryShare.item.keyId]}}))}))},n.prototype.getFileKeyIdFromFileShare=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.query({query:_i,variables:{id:e}})];case 1:return[2,t.sent().fileShare.item.keyId]}}))}))},n.prototype.getDirectoryKey=function(e,t){return M(this,void 0,void 0,(function(){var n=this;return O(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getDirectoryKeyId(e)}))]}))}))},n.prototype.getFileKey=function(e,t){return M(this,void 0,void 0,(function(){var n=this;return O(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getFileKeyId(e)}))]}))}))},n.prototype.createDirectory=function(e){return this.mutate(this.createDirectoryMutation(e))},n.prototype.createDirectoryMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return O(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:oi},r={},[4,this.prepareCreateDirectory(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.updateDirectory=function(e){return this.mutate(this.updateDirectoryMutation(e))},n.prototype.updateDirectoryMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return O(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:ci},r={},[4,this.prepareUpdateDirectory(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.deleteDirectory=function(e){return this.mutate(this.deleteDirectoryMutation(e))},n.prototype.deleteDirectoryMutation=function(e){return new ze({mutation:ui,variables:{input:{directoryId:e}}})},n.prototype.createFile=function(e){return this.mutate(this.createFileMutation(e))},n.prototype.createFileMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return O(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:pi},r={},[4,this.prepareCreateFile(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.updateFile=function(e){return this.mutate(this.updateFileMutation(e))},n.prototype.updateFileMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return O(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:di},r={},[4,this.prepareUpdateFile(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.revertFile=function(e){return this.mutate(this.revertFileMutation(e))},n.prototype.revertFileMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:li,variables:{input:e}})]}))}))},n.prototype.deleteFile=function(e){return this.mutate(this.deleteFileMutation(e))},n.prototype.deleteFileMutation=function(e){return new ze({mutation:hi,variables:{input:{fileId:e}}})},n.prototype.archiveDirectory=function(e,t){return this.mutate(this.archiveDirectoryMutation(e,t))},n.prototype.archiveDirectoryMutation=function(e,t){return new ze({mutation:yi,variables:{input:{directoryId:e,recursive:t.recursive}}})},n.prototype.archiveFile=function(e){return this.mutate(this.archiveFileMutation(e))},n.prototype.archiveFileMutation=function(e){return new ze({mutation:fi,variables:{input:{fileId:e}}})},n.prototype.unarchiveDirectory=function(e,t){return this.mutate(this.unarchiveDirectoryMutation(e,t))},n.prototype.unarchiveDirectoryMutation=function(e,t){return new ze({mutation:vi,variables:{input:{directoryId:e,recursive:t.recursive}}})},n.prototype.unarchiveFile=function(e){return this.mutate(this.unarchiveFileMutation(e))},n.prototype.unarchiveFileMutation=function(e){return new ze({mutation:mi,variables:{input:{fileId:e}}})},n.prototype.changeDirectoryParents=function(e){return this.mutate(this.changeDirectoryParentsMutation(e))},n.prototype.changeDirectoryParentsMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return O(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:gi},r={},[4,this.prepareChangeDirectoryParents(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.changeFileParents=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.changeFileParentsMutation(e))]}))}))},n.prototype.changeFileParentsMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return O(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:Si},r={},[4,this.prepareChangeFileParents(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.beginDeleteChildItemLinksWindow=function(e){return this.mutate(this.beginDeleteChildItemLinksWindowMutation(e))},n.prototype.beginDeleteChildItemLinksWindowMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:Ci,variables:{input:e}})]}))}))},n.prototype.ensureTempDirectory=function(){var e;return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return O(this,(function(p){switch(p.label){case 0:return this.tempDirectory?[2,this.tempDirectory]:[4,this.query({query:bi,variables:{plainMeta:Ti.TEMP_DIRECTORY_PLAIN_META_FILTER}})];case 1:return(t=p.sent()).rootDirectories.edges.length>1&&console.error("There is more than 1 temp directory (plainMeta filter: "+Ti.TEMP_DIRECTORY_PLAIN_META_FILTER+")"),0!==t.rootDirectories.edges.length?[3,4]:[4,this.createDirectoryMutation({asRootDirectory:!0,plainMetaJson:Ti.TEMP_DIRECTORY_PLAIN_META})];case 2:return n=p.sent(),r=this.lockService.updateLockMutation({version:null===(e=t.lock)||void 0===e?void 0:e.version}),[4,this.lrGraphQL.lrMutate([n,r])];case 3:return i=j.apply(void 0,[p.sent(),1]),a=i[0],s=a.createDirectory.directory,c=s.id,u=s.keyId,this.tempDirectory={id:c,keyId:u},[3,5];case 4:o=t.rootDirectories.edges[0].node,c=o.id,u=o.keyId,this.tempDirectory={id:c,keyId:u},p.label=5;case 5:return[2,this.tempDirectory]}}))}))},n.prototype.createDirectoryTree=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.createDirectoryTreeMutation(e))]}))}))},n.prototype.createDirectoryTreeMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return[4,this.ensureTempDirectory()];case 1:return t=r.sent(),[4,this.beginDeleteChildItemLinksWindow({directoryId:t.id,requestWindowMs:e.requestWindowMs})];case 2:return r.sent(),[4,this.createDirectory({cipherMetaClearJson:e.cipherMetaClearJson,parentDirectories:[{directoryId:t.id,wrappingKeyId:t.keyId}],plainMetaJson:e.plainMetaJson})];case 3:return n=r.sent().createDirectory.directory,[4,e.createContent({id:n.id,keyId:n.keyId})];case 4:return r.sent(),[2,this.changeDirectoryParentsMutation({directoryId:n.id,directoryKeyId:n.keyId,parentsToRemove:[t.id],parentsToAdd:e.parentDirectories})]}}))}))},n.prototype.setFileConfidential=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.setFileConfidentialMutation(e))]}))}))},n.prototype.setFileConfidentialMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:Ii,variables:{input:{fileId:e.fileId,confidential:e.confidential}}})]}))}))},n.prototype.setDirectoryConfidential=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.setDirectoryConfidentialMutation(e))]}))}))},n.prototype.setDirectoryConfidentialMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:wi,variables:{input:{directoryId:e.directoryId,confidential:e.confidential}}})]}))}))},n.prototype.prepareParentDirectory=function(t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o;return O(this,(function(c){switch(c.label){case 0:if(r=t.directoryId,i=t.linkType,a=t.wrappingKeyId,i!=e.LinkTypeField.REFERENCE)return[3,1];if(a)throw new Q("Do not specify wrappingKeyId when link type is REFERENCE.");return[2,{directoryId:r,linkType:i}];case 1:return[4,this.getDirectoryKey(r,a)];case 2:return s=c.sent(),o={directoryId:r,wrappingKeyId:s.id},[4,this.keyGraph.wrapKey(s,n)];case 3:return[2,(o.wrappedKey=c.sent(),o.linkType=i,o)]}}))}))},n.prototype.getFileStateKeyId=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.query({query:$i,variables:{id:e}})];case 1:return[2,t.sent().fileState.keyId]}}))}))},n.prototype.prepareCreateFileState=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h;return O(this,(function(y){switch(y.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=y.sent(),(i=t.file)?[4,this.fileUploadService.loadFile(t.file)]:[3,3];case 2:i=y.sent(),y.label=3;case 3:return(r=i)?[4,this.keyGraph.encryptToString(n,r)]:[3,8];case 4:return s=y.sent(),t.upload?[4,t.upload(s)]:[3,6];case 5:return a=y.sent(),[3,8];case 6:return[4,this.fileUploadService.uploadEncryptedFile({encryptedContent:s})];case 7:a=y.sent(),y.label=8;case 8:return c=(o=Object).assign,p=(u=Object).assign,d=[{}],[4,this.prepareItem(n,t)];case 9:return l=[p.apply(u,d.concat([y.sent()]))],h={},[4,this.keyGraph.wrapKey(e,n)];case 10:return[2,c.apply(o,l.concat([(h.wrappedStateKey=y.sent(),h.contentResource=a,h)]))]}}))}))},n.prototype.prepareChangeItemParents=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i=this;return O(this,(function(a){switch(a.label){case 0:return e.parentsToAdd?[4,Promise.all(e.parentsToAdd.map((function(e){return i.prepareParentDirectory(e,t)})))]:[3,2];case 1:return r=a.sent(),[3,3];case 2:r=[],a.label=3;case 3:return n=r,[2,{directoriesToRemove:e.parentsToRemove||[],directoriesToAdd:n}]}}))}))},n.prototype.prepareItem=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a;return O(this,(function(s){switch(s.label){case 0:return n=t.plainMetaJson,r=t.cipherMetaClearJson,i={plainMeta:n&&JSON.stringify(n)},(a=r)?[4,this.keyGraph.encryptToString(e,r)]:[3,2];case 1:a=s.sent(),s.label=2;case 2:return[2,(i.cipherMeta=a,i)]}}))}))},n.prototype.prepareCreateDirectory=function(e){var t,n,r;return M(this,void 0,void 0,(function(){var i,a,s,o,c,u,p=this;return O(this,(function(d){switch(d.label){case 0:return[4,this.keyFactory.createKey()];case 1:if(i=d.sent(),e.parentDirectories=e.parentDirectories||[],!e.asRootDirectory&&!(null===(t=e.parentDirectories)||void 0===t?void 0:t.length))throw new Q("A new directory must be either a root directory or a sub-directory. So you must provide either parentDirectories or asRootDirectory parameter.");if(e.asRootDirectory&&(null===(n=e.parentDirectories)||void 0===n?void 0:n.length))throw new Q("A new directory must be either a root directory or a sub-directory. So you can only provide either parentDirectories or asRootDirectory parameter.");return[4,Promise.all(null===(r=e.parentDirectories)||void 0===r?void 0:r.map((function(e){return p.prepareParentDirectory(e,i)})))];case 2:return a=d.sent(),e.asRootDirectory?(o=this.keyService.currentRootKey,c={wrappingKeyId:o.id},[4,this.keyGraph.wrapKey(o,i)]):[3,4];case 3:c.wrappedKey=d.sent(),s=c,d.label=4;case 4:return[4,this.prepareItem(i,e)];case 5:return u=d.sent(),[2,Object.assign(Object.assign({},u),{parentDirectories:a,parentRootDirectory:s})]}}))}))},n.prototype.prepareUpdateDirectory=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=r.sent(),[4,this.prepareItem(t.jwk,e)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{directoryId:e.directoryId})]}}))}))},n.prototype.prepareCreateFile=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i=this;return O(this,(function(a){switch(a.label){case 0:return[4,this.keyFactory.createKey()];case 1:return t=a.sent(),[4,Promise.all(e.parentDirectories.map((function(e){return i.prepareParentDirectory(e,t)})))];case 2:return n=a.sent(),[4,this.prepareCreateFileState(t,e)];case 3:return r=a.sent(),[2,Object.assign(Object.assign({},r),{parentDirectories:n})]}}))}))},n.prototype.prepareUpdateFile=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=r.sent(),[4,this.prepareCreateFileState(t.jwk,e)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{fileId:e.fileId})]}}))}))},n.prototype.prepareChangeDirectoryParents=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=r.sent(),[4,this.prepareChangeItemParents(e,t.jwk)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{directoryId:e.directoryId})]}}))}))},n.prototype.prepareChangeFileParents=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=r.sent(),[4,this.prepareChangeItemParents(e,t.jwk)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{fileId:e.fileId})]}}))}))},n.prototype.onLogout=function(){this.tempDirectory=null},n}(Kt),e.ItemService.TEMP_DIRECTORY_PLAIN_META={kcType:"temp"},e.ItemService.TEMP_DIRECTORY_PLAIN_META_FILTER=JSON.stringify({filter:[{contains:Ti.TEMP_DIRECTORY_PLAIN_META}]}),e.ItemService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ItemService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(Lr),t.ɵɵinject(Ke),t.ɵɵinject(ge),t.ɵɵinject(Pe),t.ɵɵinject(e.LockService),t.ɵɵinject(e.AuthService))},token:e.ItemService,providedIn:"root"}),e.ItemService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ItemService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:Lr},{type:Ke},{type:ge},{type:Pe},{type:e.LockService},{type:e.AuthService}]},e.ItemService=Ti=A([qe({ngZoneName:"ngZone"})],e.ItemService),e.KeyExchangeService=function(e){function t(t,n,r,i,a,s){var o=e.call(this,n)||this;return o.ngZone=t,o.injector=n,o.keyFactory=r,o.keyService=i,o.encryptionService=a,o.keyGraph=s,o.CLIENT_NONCE_LENGTH=32,o}return E(t,e),t.prototype.getOtKey=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return O(this,(function(i){switch(i.label){case 0:return t?[4,ge.asKey(Object.assign(Object.assign({},JSON.parse(e.otk.otKeyParams)),{k:t}))]:[3,2];case 1:return[2,i.sent()];case 2:return"OTK_INITIATED"!==e.otk.state||e.isInitiator||!e.otk.responderPbkCipher?[3,5]:(n=this.keyService.currentPxk,[4,this.encryptionService.decrypt(n.jwk,JSON.parse(e.otk.responderPbkCipher),{serializations:[pe.COMPACT]})]);case 3:return(r=i.sent()).otKey?[4,ge.asKey(r.otKey)]:[3,5];case 4:return[2,i.sent()];case 5:return[2,null]}}))}))},t.prototype.decryptOtk=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o;return O(this,(function(c){switch(c.label){case 0:return[4,this.getOtKey(e,t)];case 1:return n=c.sent(),r=e.otk,n&&r.otKeyCipher?(a=(i=Object).assign,s=[Object.assign({},r)],o={otKey:n},[4,this.encryptionService.decrypt(n,e.otk.otKeyCipher)]):[3,3];case 2:r=a.apply(i,s.concat([(o.otKeyCipherClearJson=c.sent(),o)])),c.label=3;case 3:return[2,Object.assign(Object.assign({},e),{otk:r})]}}))}))},t.prototype.decryptResponseCipher=function(e,t,n){return M(this,void 0,void 0,(function(){var r;return O(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.encryptionService.decrypt(e,n)];case 1:return n=i.sent(),[3,3];case 2:if("no key found"!==(r=i.sent()).message)throw r;return[3,3];case 3:return[4,this.encryptionService.decrypt(t,n)];case 4:return[2,i.sent()]}}))}))},t.prototype.decryptKeyExchangeAsInitiator=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return O(this,(function(l){switch(l.label){case 0:return t=this.keyService.currentRootKey,[4,this.encryptionService.decrypt(t.jwk,e.initiatorRootKeyCipher)];case 1:return n=l.sent(),[4,ge.asKey(n.otKey)];case 2:return r=l.sent(),e=Object.assign(Object.assign({},e),{initiatorRootKeyCipherClearJson:n}),(i=e.otk).initiatorOneTimePbkCipher?(s=(a=Object).assign,o=[Object.assign({},i)],c={},u=this.decryptResponseCipher,p=[r],[4,ge.asKey(n.oneTimePrk)]):[3,5];case 3:return[4,u.apply(this,p.concat([l.sent(),i.initiatorOneTimePbkCipher]))];case 4:i=s.apply(a,o.concat([(c.initiatorOneTimePbkCipherClearJson=l.sent(),c)])),l.label=5;case 5:return i.otKeyCipher?(d=i,[4,this.encryptionService.decrypt(r,i.otKeyCipher)]):[3,7];case 6:d.otKeyCipherClearJson=l.sent(),l.label=7;case 7:return[2,Object.assign(Object.assign({},e),{otk:i})]}}))}))},t.prototype.decryptKeyExchangeAsResponder=function(e,t){return M(this,void 0,void 0,(function(){return O(this,(function(n){return[2,this.decryptOtk(e,t)]}))}))},t.prototype.decryptKeyExchange=function(e,t){return M(this,void 0,void 0,(function(){return O(this,(function(n){return e.isInitiator?[2,this.decryptKeyExchangeAsInitiator(e)]:[2,this.decryptKeyExchangeAsResponder(e,t)]}))}))},t.prototype.getKeyExchanges=function(e){var t=(void 0===e?{}:e).state;return M(this,void 0,void 0,(function(){var e,n=this;return O(this,(function(r){switch(r.label){case 0:return[4,this.query({query:zt,variables:{state:t}})];case 1:return e=r.sent().keyExchanges,[2,Promise.all(e.edges.map((function(e){return n.decryptKeyExchange(e.node)})))]}}))}))},t.prototype.getKeyExchange=function(e,t){var n=void 0===t?{}:t,r=n.otKeyK,i=n.token;return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.query({query:i?tn:en,variables:{id:e,token:i},includeKeyGraph:!i})];case 1:return t=n.sent(),[2,this.decryptKeyExchange(t.keyExchange,r)]}}))}))},t.prototype.getCurrentUserSharedKey=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.query({query:cn,variables:{username:e.username,userId:e.userId}})]}))}))},t.prototype.cancelKeyExchange=function(e){return this.mutate(this.cancelKeyExchangeMutation(e))},t.prototype.cancelKeyExchangeMutation=function(e){return new ze({mutation:nn,variables:{input:{id:e}}})},t.prototype.declineKeyExchange=function(e,t){return this.mutate(this.declineKeyExchangeMutation(e,t))},t.prototype.declineKeyExchangeMutation=function(e,t){return new ze({mutation:rn,variables:{input:{id:e,token:t}}})},t.prototype.initiateOtk=function(e){return void 0===e&&(e={}),M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return t=this.mutate,[4,this.initiateOtkMutation(e)];case 1:return[2,t.apply(this,[n.sent().lrMutation])]}}))}))},t.prototype.initiateOtkMutation=function(e){var t=void 0===e?{}:e,n=t.message,r=t.email,i=t.contactCard,a=t.upgrade;return M(this,void 0,void 0,(function(){var e,t,s,o,c,u,p,d,l,h,y,f,v;return O(this,(function(m){switch(m.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=m.sent(),t=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.keyFactory.createPkcKey()];case 2:return s=m.sent(),o=this.keyService.currentPxk,c=this.keyService.currentSigPxk,u=null,i&&i.ownerPlainDataJson?[4,this.encryptionService.signToString(c.jwk,i.ownerPlainDataJson)]:[3,4];case 3:u=m.sent(),m.label=4;case 4:return p={message:n,contactCard:i&&{sharedCipherDataClearJson:i.sharedCipherDataClearJson}},d={nonce:t,initiator:Object.assign(Object.assign({},p),{oneTimePbk:s.toJSON(),pbk:o.jwk.toJSON(),sigPbk:c.jwk.toJSON()})},[4,this.keyGraph.encryptToString(e,d)];case 5:return l=m.sent(),h={nonce:t,oneTimePrk:s.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:i,initiator:p},y=this.keyService.currentRootKey,[4,this.keyGraph.encryptToString(y.jwk,h)];case 6:return f=m.sent(),v=e.toJSON(!0).k,[2,{lrMutation:new ze({mutation:an,variables:{input:{initiatorRootKeyCipher:f,initiatorPxkId:o.id,initiatorSigPxkId:c.id,otKeyParams:JSON.stringify(e.toJSON()),otKeyCipher:l,sendEmail:r&&{email:r,rawOtKey:v},createTp:!0,initiatorPlainDataSig:u,upgrade:a}}}),otKeyK:v}]}}))}))},t.prototype.respondOtk=function(e){return this.mutate(this.respondOtkMutation(e))},t.prototype.respondOtkMutation=function(e){var t=e.keyExchangeId,n=e.token,r=e.decryptedOtk,i=e.message,a=e.initiatorContactCard,s=e.responderContactCard;return M(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I,w,K,P,k,R,E,D,A,M,T,j,N,F,_,$,L,U,x,q,J,G,Q,W,V,B,Z,H,Y,X,z,ee;return O(this,(function(O){switch(O.label){case 0:return e=this.keyService.currentRootKey,o=this.keyService.currentMasterKey,[4,this.keyFactory.createKey()];case 1:return c=O.sent(),[4,this.keyFactory.createKey()];case 2:return u=O.sent(),[4,this.encryptionService.encrypt(e.jwk,c.toJSON(!0))];case 3:return p=O.sent(),[4,this.encryptionService.encrypt(o.jwk,u.toJSON(!0))];case 4:return d=O.sent(),[4,ge.asKey(r.otKeyCipherClearJson.initiator.oneTimePbk)];case 5:return l=O.sent(),[4,ge.asKey(r.otKeyCipherClearJson.initiator.pbk)];case 6:return h=O.sent(),[4,ge.asKey(r.otKeyCipherClearJson.initiator.sigPbk)];case 7:return y=O.sent(),f=this.keyService.currentPxk,v=this.keyService.currentSigPxk,[4,this.encryptionService.sign(v.jwk,h.toJSON())];case 8:return m=O.sent(),[4,this.encryptionService.sign(v.jwk,y.toJSON())];case 9:return g=O.sent(),S={nonce:r.otKeyCipherClearJson.nonce,sharedKey:c.toJSON(!0),mkSharedKey:u.toJSON(!0),responder:{pbk:f.jwk.toJSON(),sigPbk:v.jwk.toJSON(),message:i}},r.otKeyCipherClearJson.initiator.contactCard?(b=r.otKeyCipherClearJson.initiator.contactCard.sharedCipherDataClearJson,[4,this.keyFactory.createKey()]):[3,19];case 10:return I=O.sent(),[4,this.keyFactory.createKey()];case 11:return _=O.sent(),$=this.keyService.currentSigPxk,w={},P=(K=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,I.toJSON(!0))];case 12:return w.receiverWrappedKey=P.apply(K,[O.sent()]),w.receiverWrappingKeyId=e.id,a?(E=(R=JSON).stringify,[4,this.encryptionService.encrypt(I,a.receiverCipherDataClearJson)]):[3,14];case 13:return k=E.apply(R,[O.sent()]),[3,15];case 14:k="",O.label=15;case 15:return w.receiverCipherData=k,A=(D=JSON).stringify,[4,this.encryptionService.encrypt(c,_.toJSON(!0))];case 16:return w.sharedWrappedKey=A.apply(D,[O.sent()]),C=w,[4,this.encryptionService.encrypt(_,b)];case 17:return V=O.sent(),M=C,j=(T=JSON).stringify,[4,this.encryptionService.sign($.jwk,V)];case 18:M.sharedCipherDataSig=j.apply(T,[O.sent()]),C.sigPxkId=$.id,S.responder.contactCard=Object.assign(Object.assign({},S.responder.contactCard),{sharedCipherKey:_.toJSON(!0)}),O.label=19;case 19:return s?[4,this.keyFactory.createKey()]:[3,31];case 20:return F=O.sent(),[4,this.keyFactory.createKey()];case 21:return _=O.sent(),$=this.keyService.currentSigPxk,L={},x=(U=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,F.toJSON(!0))];case 22:return L.ownerWrappedKey=x.apply(U,[O.sent()]),L.ownerWrappingKeyId=e.id,s.ownerCipherDataClearJson?(G=(J=JSON).stringify,[4,this.encryptionService.encrypt(F,s.ownerCipherDataClearJson)]):[3,24];case 23:return q=G.apply(J,[O.sent()]),[3,25];case 24:q="",O.label=25;case 25:return L.ownerCipherData=q,W=(Q=JSON).stringify,[4,this.encryptionService.encrypt(c,_.toJSON(!0))];case 26:return L.sharedWrappedKey=W.apply(Q,[O.sent()]),N=L,[4,this.encryptionService.encrypt(_,s.sharedCipherDataClearJson)];case 27:return V=O.sent(),B=N,H=(Z=JSON).stringify,[4,this.encryptionService.sign($.jwk,V)];case 28:return B.sharedCipherDataSig=H.apply(Z,[O.sent()]),N.sigPxkId=$.id,s.ownerPlainDataJson?(Y=N,z=(X=JSON).stringify,[4,this.encryptionService.sign(v.jwk,s.ownerPlainDataJson)]):[3,30];case 29:Y.ownerPlainDataSig=z.apply(X,[O.sent()]),O.label=30;case 30:S.responder.contactCard=Object.assign(Object.assign({},S.responder.contactCard),{sharedCipherDataClearJson:s.sharedCipherDataClearJson}),O.label=31;case 31:return[4,this.encryptionService.encrypt(l,S)];case 32:return ee=O.sent(),[4,this.encryptionService.encrypt(r.otKey,ee)];case 33:return ee=O.sent(),[2,new ze({mutation:sn,variables:{input:{keyExchangeId:t,keyExchangeToken:n,rootKeyId:e.id,masterKeyId:o.id,responderPxkId:f.id,responderSigPxkId:v.id,signedInitiatorPbk:JSON.stringify(m),signedInitiatorSigPbk:JSON.stringify(g),rkWrappedSharedKey:JSON.stringify(p),mkWrappedMkSharedKey:JSON.stringify(d),initiatorOneTimePbkCipher:JSON.stringify(ee),initiatorContactCard:C,responderContactCard:N}}})]}}))}))},t.prototype.completeOtk=function(e){return this.mutate(this.completeOtkMutation(e))},t.prototype.completeOtkMutation=function(e){var t=e.keyExchangeId,n=e.initiatorRootKeyCipher,r=e.initiatorOneTimePbkCipher,i=e.responderContactCard,a=e.initiatorContactCard;return M(this,void 0,void 0,(function(){var e,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I,w,K,P,k,R,E,D,A,M,T,j,N,F,_,$,L,U,x,q;return O(this,(function(O){switch(O.label){case 0:return e=this.keyService.currentRootKey,s=this.keyService.currentMasterKey,[4,this.encryptionService.decrypt(e.jwk,n)];case 1:return o=O.sent(),u=this.decryptResponseCipher,[4,ge.asKey(o.otKey)];case 2:return p=[O.sent()],[4,ge.asKey(o.oneTimePrk)];case 3:return[4,u.apply(this,p.concat([O.sent(),r]))];case 4:if(c=O.sent(),o.nonce!==c.nonce)throw new Y("The nonce returned by responder does not match with the one created by the initiator.");return d=this.keyService.currentSigPxk,[4,ge.asKey(c.responder.sigPbk)];case 5:return l=O.sent(),[4,ge.asKey(c.responder.pbk)];case 6:return h=O.sent(),[4,this.encryptionService.sign(d.jwk,h.toJSON())];case 7:return y=O.sent(),[4,this.encryptionService.sign(d.jwk,l.toJSON())];case 8:return f=O.sent(),[4,ge.asKey(c.sharedKey)];case 9:return v=O.sent(),[4,this.encryptionService.encrypt(e.jwk,v.toJSON(!0))];case 10:return m=O.sent(),[4,ge.asKey(c.mkSharedKey)];case 11:return g=O.sent(),[4,this.encryptionService.encrypt(s.jwk,g.toJSON(!0))];case 12:return S=O.sent(),i?[4,this.keyFactory.createKey()]:[3,16];case 13:return b=O.sent(),I={},K=(w=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,b.toJSON(!0))];case 14:return I.receiverWrappedKey=K.apply(w,[O.sent()]),I.receiverWrappingKeyId=e.id,k=(P=JSON).stringify,[4,this.encryptionService.encrypt(b,i.receiverCipherDataClearJson)];case 15:I.receiverCipherData=k.apply(P,[O.sent()]),C=I,O.label=16;case 16:return o.initiatorContactCard?(D=o.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,25];case 17:return A=O.sent(),[4,ge.asKey(c.responder.contactCard.sharedCipherKey)];case 18:return M=O.sent(),N=(j=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,A.toJSON(!0))];case 19:return T=N.apply(j,[O.sent()]),(F=(null==a?void 0:a.ownerCipherDataClearJson)||D.ownerCipherDataClearJson)?[4,this.keyGraph.encryptToString(A,F)]:[3,21];case 20:return $=O.sent(),[3,22];case 21:$="",O.label=22;case 22:return _=$,R={ownerWrappedKey:T,ownerWrappingKeyId:e.id,ownerCipherData:_},E={sigPxkId:d.id},[4,this.encryptionService.encrypt(M,D.sharedCipherDataClearJson)];case 23:return L=O.sent(),U=E,q=(x=JSON).stringify,[4,this.encryptionService.sign(d.jwk,L)];case 24:U.sharedCipherDataSig=q.apply(x,[O.sent()]),O.label=25;case 25:return[2,new ze({mutation:on,variables:{input:{keyExchangeId:t,rootKeyId:e.id,masterKeyId:s.id,initiatorSigPxkId:d.id,signedResponderPbk:JSON.stringify(y),signedResponderSigPbk:JSON.stringify(f),rkWrappedSharedKey:JSON.stringify(m),mkWrappedMkSharedKey:JSON.stringify(S),responderContactCardCipher:C,initiatorContactCardCipher:R,initiatorContactCardSharedCipher:E}}})]}}))}))},t}(Kt),e.KeyExchangeService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.KeyExchangeService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ge),t.ɵɵinject(Ke),t.ɵɵinject(ve),t.ɵɵinject(Pe))},token:e.KeyExchangeService,providedIn:"root"}),e.KeyExchangeService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.KeyExchangeService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ge},{type:Ke},{type:ve},{type:Pe}]},e.KeyExchangeService=A([qe({ngZoneName:"ngZone"})],e.KeyExchangeService);var Li="LBOP";(e.KcLbopErrorCode||(e.KcLbopErrorCode={})).INVALID_PASSPHRASE="INVALID_PASSPHRASE";var Ui,xi,qi,Ji,Gi,Qi=K.default(Ui||(Ui=F(["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"],["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"]))),Wi=K.default(xi||(xi=F(["\n mutation DeleteLbop($input: DeleteLbopInput!) {\n deleteLbop(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteLbop($input: DeleteLbopInput!) {\n deleteLbop(input: $input) {\n id\n }\n }\n"]))),Vi=K.default(qi||(qi=F(["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"],["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"]))),Bi=K.default(Ji||(Ji=F(["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"],["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"]))),Zi=K.default(Gi||(Gi=F(["\n query Lbops {\n lbops {\n edges {\n node {\n id\n cipherMeta\n }\n }\n }\n }\n"],["\n query Lbops {\n lbops {\n edges {\n node {\n id\n cipherMeta\n }\n }\n }\n }\n"]))),Hi=function(){function t(e,t,n,r,i,a,s,o){this.config=e,this.http=t,this.lrApollo=n,this.auth=r,this.keyFactory=i,this.keyService=a,this.encryptionService=s,this.passwordService=o,this.CLIENT_NONCE_LENGTH=32,this.LBOP_WORDS=25}return t.prototype.getPartial=function(e){return e.split(" ")[0]},t.prototype.remove=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Wi,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteLbop.id]}}))}))},t.prototype.update=function(e){var t=e.id,n=e.name;return M(this,void 0,void 0,(function(){var e,r,i;return O(this,(function(a){switch(a.label){case 0:return[4,this.get(t)];case 1:return(e=a.sent()).name=n,r=this.keyService.currentMasterKey,[4,this.encryptionService.encrypt(r.jwk,e)];case 2:return i=a.sent(),[4,this.lrApollo.mutate({mutation:Vi,variables:{input:{id:t,cipherMeta:JSON.stringify(i)}}})];case 3:return[2,a.sent().updateLbop]}}))}))},t.prototype.get=function(e){return M(this,void 0,void 0,(function(){var t,n,r;return O(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:Bi,variables:{id:e}})];case 1:return t=i.sent(),n=this.keyService.currentMasterKey,[4,this.encryptionService.decrypt(n.jwk,JSON.parse(t.lbop.cipherMeta))];case 2:return r=i.sent(),[2,Object.assign({id:t.id},r)]}}))}))},t.prototype.list=function(){return M(this,void 0,void 0,(function(){var e,t,n=this;return O(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Zi})];case 1:return e=r.sent(),[4,this.keyService.currentMasterKey];case 2:return t=r.sent(),[2,Promise.all(e.lbops.edges.map((function(e){return M(n,void 0,void 0,(function(){var n;return O(this,(function(r){switch(r.label){case 0:return[4,this.encryptionService.decrypt(t.jwk,JSON.parse(e.node.cipherMeta))];case 1:return n=r.sent(),[2,Object.assign({id:e.node.id},n)]}}))}))})))]}}))}))},t.prototype.create=function(e){var t=e.name;return M(this,void 0,void 0,(function(){var e,n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,S;return O(this,(function(C){switch(C.label){case 0:if(1024!==g.Slip39Helper.WORD_LIST.length)throw new W("Slip39Helper.WORD_LIST.length != 1024");return[4,this.list()];case 1:for(e=C.sent(),r=function(){n=i.keyFactory.randomChoices(g.Slip39Helper.WORD_LIST,i.LBOP_WORDS).join(" ");var t=i.getPartial(n);if(!e.some((function(e){return e.partial===t})))return"break"},i=this;"break"!==r(););return[4,this.keyFactory.createLbopKeyParams()];case 2:return a=C.sent(),c=(o=this.keyFactory).deriveLbopKey,p=(u=Object).assign,d={},[4,this.keyFactory.importPassword(n)];case 3:return[4,c.apply(o,[p.apply(u,[(d.password=C.sent(),d),a])])];case 4:return s=C.sent().jwk,[4,this.keyFactory.createSignKey()];case 5:return l=C.sent(),[4,this.encryptionService.encrypt(s,l.toJSON(!0))];case 6:return h=C.sent(),y=this.keyService.currentMasterKey,[4,this.encryptionService.encrypt(s,y.jwk.toJSON(!0))];case 7:return f=C.sent(),v=Object.assign(Object.assign({},t&&{name:t}),{partial:this.getPartial(n)}),[4,this.encryptionService.encrypt(y.jwk,v)];case 8:return m=C.sent(),[4,this.lrApollo.mutate({mutation:Qi,variables:{input:{cipherMeta:JSON.stringify(m),lbopKeyParams:JSON.stringify(a),lbopKeyVerifier:JSON.stringify(l.toJSON(!0)),wrappedLbopKeyVerifier:JSON.stringify(h),masterKeyId:y.id,wrappedMasterKey:JSON.stringify(f)}}})];case 9:return S=C.sent(),[2,Object.assign(Object.assign({},S.createLbop.lbop),{lbopString:n})]}}))}))},t.prototype.verifyLbops=function(t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g;return O(this,(function(S){switch(S.label){case 0:r=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),S.label=1;case 1:S.trys.push([1,11,12,13]),i=T(t.lbops),a=i.next(),S.label=2;case 2:return a.done?[3,10]:(s=a.value,u=(c=this.keyFactory).deriveLbopKey,d=(p=Object).assign,l={},[4,this.keyFactory.importPassword(n)]);case 3:return[4,u.apply(c,[d.apply(p,[(l.password=S.sent(),l),s.lbopKeyParams])])];case 4:o=S.sent().jwk,S.label=5;case 5:return S.trys.push([5,8,,9]),[4,this.encryptionService.decrypt(o,s.wrappedLbopKeyVerifier)];case 6:return h=S.sent(),y=t.challenge.serverNonce,[4,this.encryptionService.sign(h,{serverNonce:y,clientNonce:r})];case 7:return f=S.sent(),[2,{lbop:s,signedChallenge:f,lbopKey:o}];case 8:return S.sent(),[3,9];case 9:return a=i.next(),[3,2];case 10:return[3,13];case 11:return v=S.sent(),m={error:v},[3,13];case 12:try{a&&!a.done&&(g=i.return)&&g.call(i)}finally{if(m)throw m.error}return[7];case 13:throw new J(new q({source:Li,code:e.KcLbopErrorCode.INVALID_PASSPHRASE,message:"Invalid passphrase."}))}}))}))},t.prototype.verifyContact=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.http.post(this.config.authUrl+"users/lbop-reset/verify-contact/",e).toPromise()]}))}))},t.prototype.confirmContact=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e.claimId,v_code:e.vCode}).toPromise()]}))}))},t.prototype.verify=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return O(this,(function(p){switch(p.label){case 0:return[4,this.http.post(this.config.authUrl+"users/lbop-reset/get-challenge/",{claimId:e.claimId,claimToken:e.claimToken}).toPromise()];case 1:return t=p.sent(),[4,this.verifyLbops(t,e.lbop)];case 2:return n=p.sent(),r=n.signedChallenge,i=n.lbop,a=n.lbopKey,[4,this.http.post(this.config.authUrl+"users/lbop-reset/verify-challenge/",{lbopId:i.lbopId,signedChallenge:r}).toPromise()];case 3:return s=p.sent(),o={lbopId:i.lbopId,verifiedToken:s.verifiedToken,masterKeyId:s.masterKeyId},u=(c=ge).asKey,[4,this.encryptionService.decrypt(a,s.wrappedMasterKey)];case 4:return[4,u.apply(c,[p.sent()])];case 5:return[2,(o.masterKey=p.sent(),o)]}}))}))},t.prototype.setPassword=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i;return O(this,(function(a){switch(a.label){case 0:return[4,this.passwordService.createPassKeyBundle(e.newPassword)];case 1:return t=a.sent(),[4,this.encryptionService.encrypt(t.passKey,e.masterKey.toJSON(!0))];case 2:return n=a.sent(),[4,this.http.post(this.config.authUrl+"users/lbop-reset/set-password/",{lbopId:e.lbopId,verifiedToken:e.verifiedToken,masterKeyId:e.masterKeyId,newWrappedMasterKey:n,newPassKey:{passKeyParams:t.passKeyParams,passIdpParams:t.passIdpParams,passIdpVerifierPbk:t.passIdpVerifier.toJSON(),wrappedPassIdpVerifierPrk:t.wrappedPassIdpVerifierPrk}}).toPromise()];case 3:return r=a.sent(),[4,this.auth.signIn(r.username,r.idpPassword,{noProxy:"true"})];case 4:if("NEW_PASSWORD_REQUIRED"!==(i=a.sent()).challengeName)throw new ee("Expecting Cognito to have done a password reset.");return[4,this.auth.completeNewPassword(i,this.passwordService.getPassIdpString(t.passIdp),{})];case 5:return i=a.sent(),[4,this.auth.signOut()];case 6:return a.sent(),[4,this.http.post(this.config.authUrl+"users/lbop-reset/complete/",{lbopId:e.lbopId,setPasswordToken:r.setPasswordToken}).toPromise()];case 7:return[2,a.sent()]}}))}))},t}();Hi.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Hi(t.ɵɵinject(Se),t.ɵɵinject(y.HttpClient),t.ɵɵinject(ke),t.ɵɵinject(s.AuthClass),t.ɵɵinject(ge),t.ɵɵinject(Ke),t.ɵɵinject(ve),t.ɵɵinject(Bn))},token:Hi,providedIn:"root"}),Hi.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Hi.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:y.HttpClient},{type:ke},{type:s.AuthClass},{type:ge},{type:Ke},{type:ve},{type:Bn}]};var Yi=function(){function e(){}return e.forRoot=function(r){return{ngModule:e,providers:[{provide:Se,useValue:r},{provide:s.AuthClass,useValue:k.default},{provide:t.APP_INITIALIZER,useFactory:Et,deps:[Se,s.AuthClass],multi:!0},{provide:n.APOLLO_OPTIONS,useFactory:Ie,deps:[Se,s.AuthClass]}]}},e}();Yi.decorators=[{type:t.NgModule,args:[{imports:[y.HttpClientModule,m.NgIdleKeepaliveModule.forRoot()]}]}];var Xi,zi,ea,ta,na,ra=Te(Xi||(Xi=F(["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"],["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"]))),ia=Te(zi||(zi=F(["\nmutation UpdateAllNotificationsReadStateMutation($input: UpdateAllNotificationsReadStateInput!) {\n updateAllNotificationsReadState(input: $input) {\n count\n }\n}\n"],["\nmutation UpdateAllNotificationsReadStateMutation($input: UpdateAllNotificationsReadStateInput!) {\n updateAllNotificationsReadState(input: $input) {\n count\n }\n}\n"]))),aa=Te(ea||(ea=F(["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"],["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"]))),sa=Te(ta||(ta=F(["\nmutation DebugDeleteAllNotificationsMutation($input: DebugDeleteAllNotificationsInput!) {\n debugDeleteAllNotifications(input: $input) {\n count\n }\n}\n"],["\nmutation DebugDeleteAllNotificationsMutation($input: DebugDeleteAllNotificationsInput!) {\n debugDeleteAllNotifications(input: $input) {\n count\n }\n}\n"]))),oa=Te(na||(na=F(["\nmutation UpdateNotificationFeatureStateMutation($input: UpdateNotificationFeatureStateInput!) {\n updateNotificationFeatureState(input: $input) {\n featureState {\n notificationsLastViewed\n\t\t}\n }\n}\n"],["\nmutation UpdateNotificationFeatureStateMutation($input: UpdateNotificationFeatureStateInput!) {\n updateNotificationFeatureState(input: $input) {\n featureState {\n notificationsLastViewed\n\t\t}\n }\n}\n"])));e.NotificationService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return E(t,e),t.prototype.updateNotification=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.updateNotificationMutation(e))]}))}))},t.prototype.updateNotificationMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:ra,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.updateAllNotificationsReadState=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.updateAllNotificationsReadStateMutation(e))]}))}))},t.prototype.updateAllNotificationsReadStateMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:ia,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.debugCreateNotification=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.debugCreateNotificationMutation(e))]}))}))},t.prototype.debugCreateNotificationMutation=function(e){var t;return M(this,void 0,void 0,(function(){return O(this,(function(n){return[2,new ze({mutation:aa,variables:{input:{receiverId:e.receiverId,hasBeenRead:e.hasBeenRead,timeRead:null===(t=e.timeRead)||void 0===t?void 0:t.toISOString(),plainData:JSON.stringify(e.plainData),plainMeta:JSON.stringify(e.plainMeta)}}})]}))}))},t.prototype.debugDeleteAllNotifications=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.debugDeleteAllNotificationsMutation(e))]}))}))},t.prototype.debugDeleteAllNotificationsMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:sa,variables:{input:{receiverId:e.receiverId}}})]}))}))},t.prototype.updateNotificationFeatureState=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.updateNotificationFeatureStateMutation(e))]}))}))},t.prototype.updateNotificationFeatureStateMutation=function(e){var t;return M(this,void 0,void 0,(function(){return O(this,(function(n){return[2,new ze({mutation:oa,variables:{input:{lastViewed:null===(t=e.lastViewed)||void 0===t?void 0:t.toISOString(),clearLastViewed:null==e.lastViewed||void 0}}})]}))}))},t}(Kt),e.NotificationService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.NotificationService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.NotificationService,providedIn:"root"}),e.NotificationService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.NotificationService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.NotificationService=A([qe({ngZoneName:"ngZone"})],e.NotificationService);var ca,ua,pa,da,la,ha,ya,fa,va,ma,ga=Te(ca||(ca=F(["\nmutation InitiateStripePaymentMethodCaptureMutation {\n initiateStripePaymentMethodCapture(input: {}) {\n paymentCapture {\n stripeIntentId\n stripeClientSecret\n }\n }\n}\n"],["\nmutation InitiateStripePaymentMethodCaptureMutation {\n initiateStripePaymentMethodCapture(input: {}) {\n paymentCapture {\n stripeIntentId\n stripeClientSecret\n }\n }\n}\n"]))),Sa=Te(ua||(ua=F(["\nmutation CompleteStripePaymentMethodCaptureMutation($input: CompleteStripePaymentMethodCaptureInput!) {\n completeStripePaymentMethodCapture(input: $input) {\n paymentMethod {\n id\n created\n modified\n card {\n brand\n lastFourDigits\n expiryYear\n expiryMonth\n }\n isDefault \n }\n }\n}\n"],["\nmutation CompleteStripePaymentMethodCaptureMutation($input: CompleteStripePaymentMethodCaptureInput!) {\n completeStripePaymentMethodCapture(input: $input) {\n paymentMethod {\n id\n created\n modified\n card {\n brand\n lastFourDigits\n expiryYear\n expiryMonth\n }\n isDefault \n }\n }\n}\n"]))),Ca=Te(pa||(pa=F(["\nmutation RemovePaymentMethodMutation($input: RemovePaymentMethodInput!) {\n removePaymentMethod(input: $input) {\n id\n }\n}\n"],["\nmutation RemovePaymentMethodMutation($input: RemovePaymentMethodInput!) {\n removePaymentMethod(input: $input) {\n id\n }\n}\n"]))),ba=Te(da||(da=F(["\nmutation SetDefaultPaymentMethodMutation($input: SetDefaultPaymentMethodInput!) {\n setDefaultPaymentMethod(input: $input) {\n paymentMethod {\n id\n } \n }\n}\n"],["\nmutation SetDefaultPaymentMethodMutation($input: SetDefaultPaymentMethodInput!) {\n setDefaultPaymentMethod(input: $input) {\n paymentMethod {\n id\n } \n }\n}\n"]))),Ia=Te(la||(la=F(["\nmutation RemoveDefaultPaymentMethodMutation {\n removeDefaultPaymentMethod(input: {}) {\n paymentMethod {\n id\n } \n }\n}\n"],["\nmutation RemoveDefaultPaymentMethodMutation {\n removeDefaultPaymentMethod(input: {}) {\n paymentMethod {\n id\n } \n }\n}\n"]))),wa=Te(ha||(ha=F(["\nmutation IssuePlanMutation($input: IssuePlanInput!) {\n issuePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"],["\nmutation IssuePlanMutation($input: IssuePlanInput!) {\n issuePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"]))),Ka=Te(ya||(ya=F(["\nmutation CancelPlanMutation($input: CancelPlanInput!) {\n cancelPlan(input: $input) {\n plan {\n id\n } \n }\n}\n"],["\nmutation CancelPlanMutation($input: CancelPlanInput!) {\n cancelPlan(input: $input) {\n plan {\n id\n } \n }\n}\n"]))),Pa=Te(fa||(fa=F(["\nmutation ChangePriceOptionMutation($input: ChangePriceOptionInput!) {\n changePriceOption(input: $input) {\n plan {\n id\n }\n }\n}\n"],["\nmutation ChangePriceOptionMutation($input: ChangePriceOptionInput!) {\n changePriceOption(input: $input) {\n plan {\n id\n }\n }\n}\n"]))),ka=Te(va||(va=F(["\nmutation ReactivatePlanMutation($input: ReactivatePlanInput!) {\n reactivatePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"],["\nmutation ReactivatePlanMutation($input: ReactivatePlanInput!) {\n reactivatePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"])));e.PlanService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return E(t,e),t.prototype.initiateStripePaymentMethodCapture=function(){return this.mutate(this.initiateStripePaymentMethodCaptureMutation())},t.prototype.initiateStripePaymentMethodCaptureMutation=function(){return new ze({mutation:ga,variables:{input:{}}})},t.prototype.completeStripePaymentMethodCapture=function(e){return this.mutate(this.completeStripePaymentMethodCaptureMutation(e))},t.prototype.completeStripePaymentMethodCaptureMutation=function(e){return new ze({mutation:Sa,variables:{input:{stripeIntentId:e}}})},t.prototype.setDefaultPaymentMethod=function(e){return this.mutate(this.setDefaultPaymentMethodMutation(e))},t.prototype.setDefaultPaymentMethodMutation=function(e){return new ze({mutation:ba,variables:{input:{paymentMethodId:e}}})},t.prototype.removeDefaultPaymentMethod=function(){return this.mutate(this.removeDefaultPaymentMethodMutation())},t.prototype.removeDefaultPaymentMethodMutation=function(){return new ze({mutation:Ia,variables:{input:{}}})},t.prototype.issuePlan=function(e){return this.mutate(this.issuePlanMutation(e))},t.prototype.issuePlanMutation=function(e){return new ze({mutation:wa,variables:{input:e}})},t.prototype.removePaymentMethod=function(e){return this.mutate(this.removePaymentMethodMutation(e))},t.prototype.removePaymentMethodMutation=function(e){return new ze({mutation:Ca,variables:{input:{paymentMethodId:e}}})},t.prototype.cancelPlan=function(e){return this.mutate(this.cancelPlanMutation(e))},t.prototype.cancelPlanMutation=function(e){return new ze({mutation:Ka,variables:{input:e}})},t.prototype.changePriceOption=function(e){return this.mutate(this.changePriceOptionMutation(e))},t.prototype.changePriceOptionMutation=function(e){return new ze({mutation:Pa,variables:{input:e}})},t.prototype.reactivatePlan=function(e){return this.mutate(this.reactivatePlanMutation(e))},t.prototype.reactivatePlanMutation=function(e){return new ze({mutation:ka,variables:{input:{planId:e}}})},t}(Kt),e.PlanService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.PlanService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.PlanService,providedIn:"root"}),e.PlanService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.PlanService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.PlanService=A([qe({ngZoneName:"ngZone"})],e.PlanService),function(e){e.Name="name",e.Email="email",e.Image="image",e.Phone="phone",e.Address="address"}(ma||(ma={}));var Ra=[ma.Name,ma.Email,ma.Image,ma.Phone,ma.Address],Ea=function(){function t(e,t,n){this.sharedContactCardService=e,this.profileService=t,this.api=n}return t.prototype.updateDetails=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return console.log("updateDetails()"),[4,this.fetchMainContactCard()];case 1:return t=r.sent(),[4,this.profileService.updateDetails(null==t?void 0:t.id,null==t?void 0:t.keyId,e)];case 2:return n=r.sent(),[4,this.synchronizeContactCards(e,null==t?void 0:t.fields)];case 3:return r.sent(),[2,n]}}))}))},t.prototype.updateTrustedPartyDetails=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i;return O(this,(function(a){switch(a.label){case 0:return t=e.id,n=e.ownedKeyId,r=e.sharedKeyId,i=D(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(t,n,r,i)];case 1:return a.sent(),[4,this.synchronizeSharedDetails(e)];case 2:return a.sent(),[2]}}))}))},t.prototype.synchronizeSharedDetails=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,h;return O(this,(function(y){switch(y.label){case 0:return t=!1,[4,this.fetchMainContactCard()];case 1:if(n=y.sent(),e.name&&(u=this.checkField(e.name,n.fields.name))&&(n.fields.name=u,t=!0),e.email&&(u=this.checkField(e.email,n.fields.email))&&(n.fields.email=u,t=!0),e.image&&(u=this.checkField(e.image,n.fields.image))&&(n.fields.image=u,t=!0),e.phones&&e.phones.length)try{for(r=T(e.phones),i=r.next();!i.done;i=r.next())a=i.value,(u=this.checkField(a.value,n.fields.phone,a.label))&&(n.fields.phone=u,t=!0)}catch(e){p={error:e}}finally{try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(p)throw p.error}}if(e.addresses&&e.addresses.length)try{for(s=T(e.addresses),o=s.next();!o.done;o=s.next())c=o.value,(u=this.checkField(c.value,n.fields.address,c.label))&&(n.fields.address=u,t=!0)}catch(e){l={error:e}}finally{try{o&&!o.done&&(h=s.return)&&h.call(s)}finally{if(l)throw l.error}}return t?[4,this.profileService.updateDetails(n.id,n.keyId,n.fields)]:[3,3];case 2:y.sent(),y.label=3;case 3:return[2]}}))}))},t.prototype.fetchMainContactCard=function(){var e;return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.api.query({query:$n})];case 1:return[2,(t=null===(e=n.sent().contactCards.edges[0])||void 0===e?void 0:e.node)?{id:t.id,keyId:t.key.id,fields:t.cipherDataClearJson}:null]}}))}))},t.prototype.getTrustedParties=function(){return M(this,void 0,void 0,(function(){var e=this;return O(this,(function(t){switch(t.label){case 0:return[4,this.api.query({query:_n})];case 1:return[2,Pt(t.sent().tps).map((function(t){return e.mapTrustedParty(t)}))]}}))}))},t.prototype.mapTrustedParty=function(t){var n,r,i=t.sharedContactCard.sharedCipherDataClearJson,a=Object.assign(Object.assign({},t.myContactCard.sharedCipherDataClearJson),{id:t.myContactCard.id,ownedKeyId:t.myContactCard.ownerKey.id,sharedKeyId:t.myContactCard.sharedKey.id});return{id:t.id,type:e.TrustedPartyType.User,hasScenarios:!!t.sharedScenarios.edges.length,hasSharedVault:!!t.theirItems.directories.edges.length,name:null===(n=null==i?void 0:i.name)||void 0===n?void 0:n.name,details:i,mySharedDetails:a,userSharedKey:t.currentUserSharedKey.userSharedKey,username:t.other.username,features:{sharedVault:{hasAccess:"access"===((null===(r=t.other.features)||void 0===r?void 0:r.shareVault)||["noaccess"])[0]}}}},t.prototype.synchronizeContactCards=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return O(this,(function(p){switch(p.label){case 0:return t?0===(n=this.getChanges(e,t)).length?[2]:[4,this.getTrustedParties()]:[2];case 1:if(0===(r=p.sent()).length)return[2];p.label=2;case 2:p.trys.push([2,7,8,9]),i=T(r.map((function(e){return e.mySharedDetails}))),a=i.next(),p.label=3;case 3:return a.done?[3,6]:(s=a.value,[4,this.synchronizeSharedContactCard(s,n)]);case 4:p.sent(),p.label=5;case 5:return a=i.next(),[3,3];case 6:return[3,9];case 7:return o=p.sent(),c={error:o},[3,9];case 8:try{a&&!a.done&&(u=i.return)&&u.call(i)}finally{if(c)throw c.error}return[7];case 9:return[2]}}))}))},t.prototype.getChanges=function(e,t){var n,r,i,a,s,o=[];try{for(var c=T(Ra),u=c.next();!u.done;u=c.next()){var p=u.value,d=t[p];if(d&&d.values){var l=function(t){var n=null===(s=e[p].values)||void 0===s?void 0:s.find((function(e){return e.id===t.id}));n?w.default.isEqual(n.value,t.value)||o.push({field:p,id:t.id,label:t.label,oldValue:t.value,newValue:n.value}):o.push({field:p,id:t.id,label:t.label,oldValue:t.value})};try{for(var h=(i=void 0,T(d.values)),y=h.next();!y.done;y=h.next()){l(y.value)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return o},t.prototype.synchronizeSharedContactCard=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l;return O(this,(function(h){switch(h.label){case 0:n=!1,r=function(t){switch(t.field){case ma.Phone:(r=e.phones&&e.phones.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;case ma.Address:(r=e.addresses&&e.addresses.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;default:var r=e[t.field];w.default.isEqual(r,t.oldValue)&&(n=!0,e[t.field]=t.newValue)}};try{for(i=T(t),a=i.next();!a.done;a=i.next())s=a.value,r(s)}catch(e){d={error:e}}finally{try{a&&!a.done&&(l=i.return)&&l.call(i)}finally{if(d)throw d.error}}return n?(o=e.id,c=e.ownedKeyId,u=e.sharedKeyId,p=D(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(o,c,u,p)]):[3,2];case 1:h.sent(),h.label=2;case 2:return[2]}}))}))},t.prototype.checkField=function(e,t,n){return void 0===n&&(n=null),(t=t||{value:e,hasMultiple:!1}).values=t.values||[],0===t.values.length||t.values.every((function(t){return!w.default.isEqual(e,t.value)}))?(t.values.push({id:n+"-"+(new Date).getTime(),label:n,value:e}),t.hasMultiple=t.values.length>1,t.value=t.value||e,t):null},t}();Ea.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ea(t.ɵɵinject(Rn),t.ɵɵinject(Ln),t.ɵɵinject(e.ɵg))},token:Ea,providedIn:"root"}),Ea.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ea.ctorParameters=function(){return[{type:Rn},{type:Ln},{type:e.ɵg}]};var Da=function(){function e(e,t,n,r,i,a){this.config=e,this.auth=t,this.http=n,this.keyFactory=r,this.encryptionService=i,this.passwordService=a}return e.prototype.verifyEmail=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/claim/email/",{address:e,context:"signup"}).toPromise()];case 1:return[2,t.sent().claim_id]}}))}))},e.prototype.verifyPhone=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/claim/sms/",{address:e,context:"signup"}).toPromise()];case 1:return[2,t.sent().claim_id]}}))}))},e.prototype.confirmVerificationCode=function(e,t){return M(this,void 0,void 0,(function(){return O(this,(function(n){switch(n.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e,v_code:t}).toPromise()];case 1:return[2,n.sent().token]}}))}))},e.prototype.register=function(e,t,n,r,i){return void 0===i&&(i="email"),M(this,void 0,void 0,(function(){var a,s,o,c,u,p,d,l,h,y,f,v,m;return O(this,(function(g){switch(g.label){case 0:return[4,this.passwordService.createPassKeyBundle(t)];case 1:return a=g.sent(),[4,this.keyFactory.createKey()];case 2:return s=g.sent(),[4,this.encryptionService.encrypt(a.passKey,s.toJSON(!0))];case 3:return o=g.sent(),[4,this.keyFactory.createKey()];case 4:return c=g.sent(),[4,this.encryptionService.encrypt(s,c.toJSON(!0))];case 5:return u=g.sent(),[4,this.keyFactory.createPkcKey()];case 6:return p=g.sent(),[4,this.encryptionService.encrypt(c,p.toJSON(!0))];case 7:return d=g.sent(),[4,this.keyFactory.createPkcSignKey()];case 8:return l=g.sent(),[4,this.encryptionService.encrypt(c,l.toJSON(!0))];case 9:return h=g.sent(),[4,this.http.post(this.config.authUrl+"users/",{claims:[{type:i,token:r,claim_id:n}],pass_idp_params:a.passIdpParams,pass_idp_verifier_pbk:a.passIdpVerifier.toJSON(),wrapped_pass_idp_verifier_prk:a.wrappedPassIdpVerifierPrk,pass_key_params:a.passKeyParams,wrapped_master_key:o,wrapped_root_key:u,pbk:p.toJSON(),wrapped_prk:d,sig_pbk:l.toJSON(),wrapped_sig_prk:h}).toPromise()];case 10:return y=g.sent(),f={},y.claims.forEach((function(e){f[e.type]=e.value})),v=this.keyFactory.randomDigitsNoZeros(4),[4,this.auth.signUp({username:e.split("@")[0]+"."+v,password:this.passwordService.getPassIdpString(a.passIdp),attributes:f,clientMetadata:{user_id:String(y.id),user_pre_sign_up_token:String(y.pre_sign_up_token)}})];case 11:return[2,{username:(m=g.sent()).user.getUsername(),userId:y.id,preSignUpToken:y.pre_sign_up_token,userSub:m.userSub}]}}))}))},e.prototype.hibpBreachedAccounts=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.http.get(this.config.authUrl+"users/hibp/breachedaccount/"+e+"/?truncateResponse=false").toPromise()];case 1:return[2,n.sent()];case 2:if(404===(t=n.sent()).status)return[2,null];throw t;case 3:return[2]}}))}))},e}();Da.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Da(t.ɵɵinject(Se),t.ɵɵinject(s.AuthClass),t.ɵɵinject(y.HttpClient),t.ɵɵinject(ge),t.ɵɵinject(ve),t.ɵɵinject(Bn))},token:Da,providedIn:"root"}),Da.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Da.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:s.AuthClass},{type:y.HttpClient},{type:ge},{type:ve},{type:Bn}]};var Aa,Ma,Oa,Ta=function(){},ja=Te(Aa||(Aa=F(["\nmutation CreateReminderMutation($input: CreateReminderInput!) {\n createReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"],["\nmutation CreateReminderMutation($input: CreateReminderInput!) {\n createReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"]))),Na=Te(Ma||(Ma=F(["\nmutation UpdateReminderMutation($input: UpdateReminderInput!) {\n updateReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"],["\nmutation UpdateReminderMutation($input: UpdateReminderInput!) {\n updateReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"]))),Fa=Te(Oa||(Oa=F(["\nmutation DeleteReminderMutation($input: DeleteReminderInput!) {\n deleteReminder(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteReminderMutation($input: DeleteReminderInput!) {\n deleteReminder(input: $input) {\n id\n }\n}\n"])));e.ReminderService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return E(t,e),t.prototype.createReminder=function(e){return this.mutate(this.createReminderMutation(e))},t.prototype.createReminderMutation=function(e){var t;return M(this,void 0,void 0,(function(){return O(this,(function(n){return[2,new ze({mutation:ja,variables:{input:{directoryId:e.directoryId,firstEvent:e.firstEvent.toISOString(),plain:JSON.stringify(e.plainJson),notifyAheadSeconds:null!==(t=e.notifyAheadSeconds)&&void 0!==t?t:0}}})]}))}))},t.prototype.updateReminder=function(e){return this.mutate(this.updateReminderMutation(e))},t.prototype.updateReminderMutation=function(e){var t,n;return M(this,void 0,void 0,(function(){return O(this,(function(r){return[2,new ze({mutation:Na,variables:{input:{id:e.id,firstEvent:null===(t=e.firstEvent)||void 0===t?void 0:t.toISOString(),plain:JSON.stringify(null!==(n=e.plainJson)&&void 0!==n?n:void 0),notifyAheadSeconds:e.notifyAheadSeconds}}})]}))}))},t.prototype.deleteReminder=function(e){return this.mutate(this.deleteReminderMutation(e))},t.prototype.deleteReminderMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:Fa,variables:{input:{id:e}}})]}))}))},t}(Kt),e.ReminderService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ReminderService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ReminderService,providedIn:"root"}),e.ReminderService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ReminderService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ReminderService=A([qe({ngZoneName:"ngZone"})],e.ReminderService);var _a,$a,La,Ua,xa,qa,Ja,Ga,Qa,Wa,Va=Te(_a||(_a=F(["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"],["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"]))),Ba=Te($a||($a=F(["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"],["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"]))),Za=Te(La||(La=F(["\nmutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n}\n"]))),Ha=Te(Ua||(Ua=F(["\nmutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),Ya=Te(xa||(xa=F(["\nmutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),Xa=Te(qa||(qa=F(["\nmutation RejectScenarioClaimMutation($input: RejectScenarioClaimInput!) {\n rejectScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"],["\nmutation RejectScenarioClaimMutation($input: RejectScenarioClaimInput!) {\n rejectScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"]))),za=Te(Ja||(Ja=F(["\nmutation ApproveScenarioClaimMutation($input: ApproveScenarioClaimInput!) {\n approveScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"],["\nmutation ApproveScenarioClaimMutation($input: ApproveScenarioClaimInput!) {\n approveScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"]))),es=Te(Ga||(Ga=F(["\nmutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),ts=Te(Qa||(Qa=F(["\nmutation DebugExpireScenarioClaimMutation($input: DebugExpireScenarioClaimInput!) {\n debugExpireScenarioClaim(input: $input) {\n scenarioClaim {\n id\n }\n }\n}\n"],["\nmutation DebugExpireScenarioClaimMutation($input: DebugExpireScenarioClaimInput!) {\n debugExpireScenarioClaim(input: $input) {\n scenarioClaim {\n id\n }\n }\n}\n"]))),ns=Te(Wa||(Wa=F(["\nmutation DebugExpireTpPasswordResetRequestMutation($input: DebugExpireTpPasswordResetRequestInput!) {\n debugExpireTpPasswordResetRequest(input: $input) {\n passwordResetRequest {\n id\n }\n }\n}\n"],["\nmutation DebugExpireTpPasswordResetRequestMutation($input: DebugExpireTpPasswordResetRequestInput!) {\n debugExpireTpPasswordResetRequest(input: $input) {\n passwordResetRequest {\n id\n }\n }\n}\n"])));e.ɵm=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r.slip39Passphrase="lifeready",r}return E(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.sharedKey.id},t}(nr),e.ɵm.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵm(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵm,providedIn:"root"}),e.ɵm.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵm.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵm=A([qe({ngZoneName:"ngZone"})],e.ɵm);var rs,is,as=Te(rs||(rs=F(["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n\n # The itemKey is the same as directory.keyId. It's here so we can detect\n # when the directory key has been rotated.\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n\n # The itemKey is the same as file.keyId. It's here so we can detect\n # when the file key has been rotated.\n itemKey {\n id\n }\n file {\n id\n keyId\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n\n # The itemKey is the same as directory.keyId. It's here so we can detect\n # when the directory key has been rotated.\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n\n # The itemKey is the same as file.keyId. It's here so we can detect\n # when the file key has been rotated.\n itemKey {\n id\n }\n file {\n id\n keyId\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),ss=Te(is||(is=F(["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n assemblyKeyId\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"],["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n assemblyKeyId\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));function os(){throw new Q("claimId does not match with the current claimId of the scenario")}function cs(){throw new Z("Scenario claim has not been approved")}e.ScenarioService=function(t){function n(e,n,r,i,a,s){var o=t.call(this,n)||this;return o.ngZone=e,o.injector=n,o.keyGraph=r,o.itemService=i,o.assemblyController=a,o.encryptionService=s,o.prepareAddReceiverDirectory=o.prepareReceiverDirectory,o.prepareUpdateReceiverDirectory=o.prepareReceiverDirectory,o.prepareAddReceiverFile=o.prepareReceiverFile,o.prepareUpdateReceiverFile=o.prepareReceiverFile,o}return E(n,t),n.prototype.createScenario=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.createScenarioMutation(e))]}))}))},n.prototype.createScenarioMutation=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.prepareCreateScenarioMutation(e)];case 1:return t=n.sent(),[2,new ze({mutation:Va,variables:{input:t}})]}}))}))},n.prototype.updateScenario=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.updateScenarioMutation(e))]}))}))},n.prototype.updateScenarioMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return[4,this.getScenario(e.scenarioId)];case 1:return t=r.sent().scenario,[4,this.prepareUpdateScenario(e,t)];case 2:return n=r.sent(),[2,new ze({mutation:Ba,variables:{input:n}})]}}))}))},n.prototype.resetScenario=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.resetScenarioMutation(e))]}))}))},n.prototype.resetScenarioMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i;return O(this,(function(a){switch(a.label){case 0:return[4,this.getScenario(e.scenarioId)];case 1:return t=a.sent().scenario,n=t.assembly,r=Pt(n.subAssemblies).map((function(e){var t=Pt(e.approvers).map((function(e){return{tpId:e.tp.id}}));return{id:e.id,quorum:e.quorum,singleReject:e.singleReject,subjectCipherDataClearJson:e.subjectCipherDataClearJson,approverTps:t}})),[4,this.prepareUpdateScenario({scenarioId:e.scenarioId,enabled:e.enabled,updateAssembly:{quorum:n.quorum,singleReject:n.singleReject,updateSubAssemblies:r}},t)];case 2:return i=a.sent(),[2,new ze({mutation:Ba,variables:{input:i}})]}}))}))},n.prototype.deleteScenario=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.lrGraphQL.lrMutate(this.deleteScenarioMutation(e))]}))}))},n.prototype.deleteScenarioMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:Za,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.createClaim=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.createClaimMutation(e))]}))}))},n.prototype.createClaimMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:Ha,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.cancelClaim=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.cancelClaimMutation(e))]}))}))},n.prototype.cancelClaimMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:Ya,variables:{input:{claimId:e}}})]}))}))},n.prototype.rejectClaim=function(e,t){return M(this,void 0,void 0,(function(){return O(this,(function(n){return[2,this.mutate(this.rejectClaimMutation(e,t))]}))}))},n.prototype.rejectClaimMutation=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return O(this,(function(a){switch(a.label){case 0:return[4,this.prepareRejectClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=tt).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.approveClaim=function(e,t){return M(this,void 0,void 0,(function(){return O(this,(function(n){return[2,this.mutate(this.approveClaimMutation(e,t))]}))}))},n.prototype.approveClaimMutation=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return O(this,(function(a){switch(a.label){case 0:return[4,this.prepareApproveClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=tt).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.receiveClaim=function(e,t){return M(this,void 0,void 0,(function(){return O(this,(function(n){return[2,this.mutate(this.receiveClaim2Mutation(e,t))]}))}))},n.prototype.receiveClaim2Mutation=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i;return O(this,(function(a){switch(a.label){case 0:return n=ze.bind,r={mutation:es},i={},[4,this.prepareReceiveClaim2(e,t)];case 1:return[2,new(n.apply(ze,[void 0,(r.variables=(i.input=a.sent(),i),r)]))]}}))}))},n.prototype.debugExpireClaim=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.debugExpireClaimMutation(e))]}))}))},n.prototype.debugExpireClaimMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:ts,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.getScenario=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.query({query:as,variables:{scenarioId:e}})]}))}))},n.prototype.getSharedScenario=function(e,t){return M(this,void 0,void 0,(function(){var n;return O(this,(function(r){switch(r.label){case 0:return[4,this.query({query:ss,variables:{scenarioId:e}})];case 1:return n=r.sent(),t&&n.sharedScenario.sharedClaim.id!==t&&os(),[2,n]}}))}))},n.prototype.getParticipantTpsKeys=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return t=e.map((function(e){return e.tpId})),n=Pt,[4,this.lrGraphQL.query({query:tr,variables:{ids:t}})];case 1:return[2,n.apply(void 0,[r.sent().tps])]}}))}))},n.prototype.fillTpSharedKeyId=function(e,t){e.forEach((function(e){if(!e.tpSharedKeyId){var n=t.find((function(t){return t.id===e.tpId}));e.tpSharedKeyId=n.currentUserSharedKey.userSharedKey.sharedKey.id}}))},n.prototype.prepareCreateScenarioMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p=this;return O(this,(function(d){switch(d.label){case 0:return[4,this.assemblyController.prepareCreate(e.createAssembly)];case 1:return t=d.sent(),n=t.assemblyKey,r=t.mutationInput,i=e.createReceivers||[],a=e.createClaimants||[],s=i.concat(a),[4,this.getParticipantTpsKeys(s)];case 2:return o=d.sent(),this.fillTpSharedKeyId(s,o),[4,Promise.all(i.map((function(e){return p.prepareCreateReceiver(e,n)})))];case 3:return c=d.sent(),[4,Promise.all(a.map((function(e){return p.prepareCreateClaimant(e)})))];case 4:return u=d.sent(),[2,{enabled:e.enabled,createAssembly:r,createReceivers:c,createClaimants:u}]}}))}))},n.prototype.prepareUpdateScenario=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I=this;return O(this,(function(w){switch(w.label){case 0:return[4,this.keyGraph.getJwkKey(t.assembly.assemblyKey.id)];case 1:return n=w.sent(),e.updateAssembly?[4,M(I,void 0,void 0,(function(){var r;return O(this,(function(i){switch(i.label){case 0:return[4,this.assemblyController.prepareUpdate(e.updateAssembly,t.assembly)];case 1:return r=i.sent(),n=r.assemblyKey,[2,r.mutationInput]}}))}))]:[3,3];case 2:return i=w.sent(),[3,4];case 3:i=void 0,w.label=4;case 4:return r=i,a=e.createReceivers||[],s=e.createClaimants||[],o=a.concat(s),[4,this.getParticipantTpsKeys(o)];case 5:return c=w.sent(),this.fillTpSharedKeyId(o,c),(p=e.createReceivers)?[4,Promise.all(e.createReceivers.map((function(e){return I.prepareCreateReceiver(e,n)})))]:[3,7];case 6:p=w.sent(),w.label=7;case 7:return u=p,d=Pt(t.receivers),e.updateReceivers?[4,Promise.all(e.updateReceivers.map((function(e){var t=d.find((function(t){return t.tp.id===e.tpId}));return I.prepareUpdateReceiver(e,n,t)})))]:[3,9];case 8:return h=w.sent(),[3,10];case 9:h=[],w.label=10;case 10:return l=h,e.updateAssembly?(y=d.filter((function(t){return!(e.deleteReceivers||[]).includes(t.tp.id)&&!l.some((function(e){return e.tpId===t.tp.id}))})),v=(f=l).concat,[4,this.prepareExistingReceivers(y,n)]):[3,12];case 11:l=v.apply(f,[w.sent()]),w.label=12;case 12:return(g=e.createClaimants)?[4,Promise.all(e.createClaimants.map((function(e){return I.prepareCreateClaimant(e)})))]:[3,14];case 13:g=w.sent(),w.label=14;case 14:return m=g,S=Pt(t.claimants),(b=e.updateClaimants)?[4,Promise.all(e.updateClaimants.map((function(e){var t=S.find((function(t){return t.tp.id===e.tpId}));return I.prepareUpdateClaimant(e,t.sharedKey.id)})))]:[3,16];case 15:b=w.sent(),w.label=16;case 16:return C=b,[2,{scenarioId:e.scenarioId,enabled:e.enabled,updateAssembly:r,createReceivers:u,updateReceivers:l,deleteReceivers:e.deleteReceivers,createClaimants:m,updateClaimants:C,deleteClaimants:e.deleteClaimants}]}}))}))},n.prototype.prepareReceiverItem=function(t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d;return O(this,(function(l){switch(l.label){case 0:return n=t.receiverItemOptions,r=t.receiverSharedKey,i=t.assemblyKey,a=t.directory,s=t.file,function(e){var t=Object.keys(e);if(2!=t.length)throw new W("You must provide exactly 2 fields in the argument.");if(null!=e[t[0]]&&null!=e[t[1]])throw new W("You can not specify both "+t[0]+" and "+t[1]);if(null==e[t[0]]&&null==e[t[1]])throw new W("You must specify either "+t[0]+" and "+t[1])}({directory:a,file:s}),(o=n.accessRole)!=e.AccessRoleChoice.DENY?[3,1]:(d={accessRole:o,wrappedItemKey:null,sharedCipherData:null},a?[2,Object.assign(Object.assign({},d),{directoryId:a.id})]:[2,Object.assign(Object.assign({},d),{fileId:s.id})]);case 1:return c=void 0,a?[4,this.itemService.getDirectoryKey(a.id,a.keyId)]:[3,3];case 2:return c=l.sent(),[3,5];case 3:return[4,this.itemService.getFileKey(s.id,s.keyId)];case 4:c=l.sent(),l.label=5;case 5:return[4,this.keyGraph.encryptToString(r,c.jwk.toJSON(!0))];case 6:return u=l.sent(),[4,this.keyGraph.encryptToString(r,n.sharedCipherDataClearJson||"")];case 7:return p=l.sent(),[4,this.keyGraph.encryptToString(i,u)];case 8:return u=l.sent(),d={accessRole:o,wrappedItemKey:u,sharedCipherData:p},a?[2,Object.assign(Object.assign({},d),{directoryId:a.id})]:[2,Object.assign(Object.assign({},d),{fileId:s.id})];case 9:return[2]}}))}))},n.prototype.prepareReceiverDirectory=function(e,t,n){return M(this,void 0,void 0,(function(){return O(this,(function(r){return[2,this.prepareReceiverItem({receiverItemOptions:e,receiverSharedKey:t,assemblyKey:n,directory:{id:e.directoryId,keyId:e.directoryKeyId}})]}))}))},n.prototype.prepareReceiverFile=function(e,t,n){return M(this,void 0,void 0,(function(){return O(this,(function(r){return[2,this.prepareReceiverItem({receiverItemOptions:e,receiverSharedKey:t,assemblyKey:n,file:{id:e.fileId,keyId:e.fileKeyId}})]}))}))},n.prototype.prepareCreateReceiver=function(e,t){return M(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u=this;return O(this,(function(p){switch(p.label){case 0:return[4,this.prepareCreateParticipant(e)];case 1:return n=p.sent(),r=n.sharedKey,i=n.mutationInput,(s=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return u.prepareAddReceiverDirectory(e,r.key,t)})))]:[3,3];case 2:s=p.sent(),p.label=3;case 3:return a=s,(c=e.addFiles)?[4,Promise.all(e.addFiles.map((function(e){return u.prepareAddReceiverFile(e,r.key,t)})))]:[3,5];case 4:c=p.sent(),p.label=5;case 5:return o=c,[2,Object.assign(Object.assign({},i),{addDirectories:a,addFiles:o})]}}))}))},n.prototype.prepareUpdateReceiver=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h,y,f,v,m=this;return O(this,(function(g){switch(g.label){case 0:return r=n.sharedKey.id,i=e.deleteDirectories||[],a=e.updateDirectories||[],s=e.deleteFiles||[],o=e.updateFiles||[],Pt(n.receiverItems.receiverDirectories).forEach((function(e){i.includes(e.directory.id)||a.find((function(t){return t.directoryId===e.directory.id}))||a.push({accessRole:e.accessRole,directoryId:e.directory.id,directoryKeyId:e.directory.keyId,sharedCipherDataClearJson:e.sharedCipherDataClearJson})})),Pt(n.receiverItems.receiverFiles).forEach((function(e){s.includes(e.file.id)||o.find((function(t){return t.fileId===e.file.id}))||o.push({accessRole:e.accessRole,fileId:e.file.id,fileKeyId:e.file.keyId,sharedCipherDataClearJson:e.sharedCipherDataClearJson})})),[4,this.prepareUpdateParticipant(e,r)];case 1:return c=g.sent(),u=c.sharedKey,p=c.mutationInput,(l=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return m.prepareAddReceiverDirectory(e,u,t)})))]:[3,3];case 2:l=g.sent(),g.label=3;case 3:return d=l,(y=e.addFiles)?[4,Promise.all(e.addFiles.map((function(e){return m.prepareAddReceiverFile(e,u,t)})))]:[3,5];case 4:y=g.sent(),g.label=5;case 5:return h=y,[4,Promise.all(a.map((function(e){return m.prepareUpdateReceiverDirectory(e,u,t)})))];case 6:return f=g.sent(),[4,Promise.all(o.map((function(e){return m.prepareUpdateReceiverFile(e,u,t)})))];case 7:return v=g.sent(),[2,Object.assign(Object.assign({},p),{addDirectories:d,addFiles:h,updateDirectories:f,updateFiles:v,deleteDirectories:e.deleteDirectories,deleteFiles:e.deleteFiles})]}}))}))},n.prototype.prepareExistingReceiver=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return O(this,(function(i){return n=Pt(e.receiverItems.receiverDirectories).map((function(e){var t=e.accessRole,n=e.sharedCipherDataClearJson,r=e.directory;return{accessRole:t,sharedCipherDataClearJson:n,directoryId:r.id,directoryKeyId:r.keyId}})),r=Pt(e.receiverItems.receiverFiles).map((function(e){var t=e.accessRole,n=e.sharedCipherDataClearJson,r=e.file;return{accessRole:t,sharedCipherDataClearJson:n,fileId:r.id,fileKeyId:r.keyId}})),[2,this.prepareUpdateReceiver({tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,updateDirectories:n,updateFiles:r},t,e)]}))}))},n.prototype.prepareExistingReceivers=function(e,t){return M(this,void 0,void 0,(function(){var n=this;return O(this,(function(r){return[2,Promise.all(e.map((function(e){return n.prepareExistingReceiver(e,t)})))]}))}))},n.prototype.prepareCreateParticipant=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.keyGraph.encryptWithNewKey(e.tpSharedKeyId,e.sharedCipherDataClearJson||"")];case 1:return[2,{sharedKey:t=n.sent(),mutationInput:{tpId:e.tpId,tpSharedKeyId:e.tpSharedKeyId,tpSharedKeyWrappedSharedKey:t.wrappedKey,sharedCipherData:t.cipher}}]}}))}))},n.prototype.prepareUpdateParticipant=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return O(this,(function(i){switch(i.label){case 0:return[4,this.keyGraph.getJwkKey(t)];case 1:return n=i.sent(),[4,this.keyGraph.encryptToString(n,e.sharedCipherDataClearJson||"")];case 2:return r=i.sent(),[2,{sharedKey:n,mutationInput:{tpId:e.tpId,sharedKeyId:t,sharedCipherData:r}}]}}))}))},n.prototype.prepareCreateClaimant=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.prepareCreateParticipant(e)];case 1:return[2,t.sent().mutationInput]}}))}))},n.prototype.prepareUpdateClaimant=function(e,t){return M(this,void 0,void 0,(function(){return O(this,(function(n){switch(n.label){case 0:return[4,this.prepareUpdateParticipant(e,t)];case 1:return[2,n.sent().mutationInput]}}))}))},n.prototype.prepareReceiveClaim2=function(t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o;return O(this,(function(c){switch(c.label){case 0:return[4,this.getSharedScenario(t,n)];case 1:return(r=c.sent().sharedScenario).state!==e.ScenarioState.APPROVED&&cs(),i=Pt(r.sharedClaim.asClaimReceiver.approvals),[4,this.recoverAssemblyKey(i)];case 2:return a=c.sent(),[4,this.keyGraph.getKey(r.asReceiver.sharedKey.id)];case 3:return s=c.sent(),[4,this.keyGraph.encryptToString(s,a.toJSON(!0))];case 4:return o=c.sent(),[2,{scenarioClaimId:n,sharedKeyWrappedAssemblyKey:o,sharedKeyId:s.id,assemblyKeyId:r.sharedClaim.asClaimReceiver.assemblyKeyId}]}}))}))},n.prototype.prepareReceiveClaim=function(t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o=this;return O(this,(function(c){switch(c.label){case 0:return[4,this.getSharedScenario(t,n)];case 1:return(r=c.sent().sharedScenario).state!==e.ScenarioState.APPROVED&&cs(),i=Pt(r.sharedClaim.asClaimReceiver.approvals),[4,this.recoverAssemblyKey(i)];case 2:return a=c.sent(),[4,Promise.all(r.asReceiver.receiverItems.receiverDirectories.edges.map((function(e){return e.node})).map((function(e){return M(o,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.encryptionService.decrypt(a,e.wrappedItemKey)];case 1:return t=n.sent(),[2,{receiverDirectoryId:e.id,receiverSharedKeyWrappedItemKey:t}]}}))}))})))];case 3:return s=c.sent(),[2,{scenarioClaimId:n,receiverDirectories:s}]}}))}))},n.prototype.recoverAssemblyKey=function(e){return M(this,void 0,void 0,(function(){var t,n=this;return O(this,(function(r){switch(r.label){case 0:return[4,Promise.all(e.map((function(e){return n.keyGraph.decryptFromString(e.pxk.id,e.receiverCipherPartialAssemblyKey)})))];case 1:return t=r.sent(),[2,this.assemblyController.recoverAssemblyKey(t)]}}))}))},n.prototype.asClaimApprovers=function(e,t,n){return M(this,void 0,void 0,(function(){return O(this,(function(r){switch(r.label){case 0:return[4,this.getSharedScenario(e,t)];case 1:return[2,Pt(r.sent().sharedScenario.sharedClaim.claim.asClaimApprovers).filter((function(e){return e.state===n}))]}}))}))},n.prototype.prepareApproveClaimMutations=function(t,n){return M(this,void 0,void 0,(function(){var r=this;return O(this,(function(i){switch(i.label){case 0:return[4,this.asClaimApprovers(t,n,e.TpClaimApproverState.CLAIMED)];case 1:return[2,i.sent().map((function(e){return M(r,void 0,void 0,(function(){var t,n,r;return O(this,(function(i){switch(i.label){case 0:return t=ze.bind,n={mutation:za},r={},[4,this.prepareApproveClaim(e)];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))}))]}}))}))},n.prototype.prepareApproveClaim=function(e){return M(this,void 0,void 0,(function(){var t,n=this;return O(this,(function(r){switch(r.label){case 0:return[4,Promise.all(Pt(e.receiverApprovals).map((function(t){return n.prepareReceiverApproval({receiverApprovalId:t.id,receiverApprovalPxkId:t.pxk.id,sharedCipherPartialAssemblyKeyClearJson:e.sharedCipherPartialAssemblyKeyClearJson})})))];case 1:return t=r.sent(),[2,{claimApproverId:e.id,receiverApprovals:t}]}}))}))},n.prototype.prepareReceiverApproval=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return t={receiverApprovalId:e.receiverApprovalId,receiverCipher:""},[4,this.keyGraph.encryptToString(e.receiverApprovalPxkId,e.sharedCipherPartialAssemblyKeyClearJson)];case 1:return[2,(t.receiverCipherPartialAssemblyKey=n.sent(),t)]}}))}))},n.prototype.prepareRejectClaimMutations=function(t,n){return M(this,void 0,void 0,(function(){var r=this;return O(this,(function(i){switch(i.label){case 0:return[4,this.asClaimApprovers(t,n,e.TpClaimApproverState.CLAIMED)];case 1:return[2,i.sent().map((function(e){return M(r,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:Xa,variables:{input:{claimApproverId:e.id}}})]}))}))}))]}}))}))},n}(Kt),e.ScenarioService.SLIP39_PASSPHRASE="lifeready",e.ScenarioService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ScenarioService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(Pe),t.ɵɵinject(e.ItemService),t.ɵɵinject(e.ɵm),t.ɵɵinject(ve))},token:e.ScenarioService,providedIn:"root"}),e.ScenarioService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ScenarioService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:Pe},{type:e.ItemService},{type:e.ɵm},{type:ve}]},e.ScenarioService=A([qe({ngZoneName:"ngZone"})],e.ScenarioService);var us,ps=Te(us||(us=F(["\nquery ServerConfigQuery {\n serverConfig {\n relayConnectionMaxLimit\n }\n}\n"],["\nquery ServerConfigQuery {\n serverConfig {\n relayConnectionMaxLimit\n }\n}\n"])));e.ServerConfigService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return E(t,e),t.prototype.getConfig=function(){return M(this,void 0,void 0,(function(){var e;return O(this,(function(t){switch(t.label){case 0:return null!=this.serverConfig?[3,2]:(e=this,[4,this.query({query:ps,includeKeyGraph:!1})]);case 1:e.serverConfig=t.sent().serverConfig,t.label=2;case 2:return[2,this.serverConfig]}}))}))},t}(Kt),e.ServerConfigService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ServerConfigService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ServerConfigService,providedIn:"root"}),e.ServerConfigService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ServerConfigService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ServerConfigService=A([qe({ngZoneName:"ngZone"})],e.ServerConfigService);var ds,ls,hs,ys,fs=Te(ds||(ds=F(["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"],["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"]))),vs=Te(ls||(ls=F(["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"],["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"]))),ms=Te(hs||(hs=F(["\nquery GetOwnedContactCardKeyIdsQuery($id: LrRelayIdInput!) {\n ownedContactCard(id: $id) {\n sharedKey {\n id\n }\n ownerKey {\n id\n }\n }\n}"],["\nquery GetOwnedContactCardKeyIdsQuery($id: LrRelayIdInput!) {\n ownedContactCard(id: $id) {\n sharedKey {\n id\n }\n ownerKey {\n id\n }\n }\n}"]))),gs=Te(ys||(ys=F(["\nquery GetReceivedContactCardKeyIdQuery($id: LrRelayIdInput!) {\n receivedContactCard(id: $id) {\n receiverKey {\n id\n }\n }\n}"],["\nquery GetReceivedContactCardKeyIdQuery($id: LrRelayIdInput!) {\n receivedContactCard(id: $id) {\n receiverKey {\n id\n }\n }\n}"])));e.SharedContactCard2Service=function(){function e(e,t,n,r,i){this.ngZone=e,this.keyService=t,this.keyGraph=n,this.encryptionService=r,this.lrGraphQL=i}return e.prototype.getOwnedContactCardKeyIds=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:ms,variables:{id:e}})];case 1:return[2,{sharedKeyId:(t=n.sent().ownedContactCard).sharedKey.id,ownerKeyId:t.ownerKey.id}]}}))}))},e.prototype.getReceivedContactCardKeyId=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:gs,variables:{id:e}})];case 1:return[2,t.sent().receivedContactCard.receiverKey.id]}}))}))},e.prototype.updateOwnedContactCard=function(e){var t=e.id,n=e.ownerKeyId,r=e.sharedKeyId,i=e.ownerPlainDataJson,a=e.ownerCipherDataClearJson,s=e.sharedCipherDataClearJson;return M(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,h,y,f,v,m;return O(this,(function(g){switch(g.label){case 0:return g.trys.push([0,3,,7]),[4,this.keyGraph.getKey(n)];case 1:return e=g.sent(),[4,this.keyGraph.getKey(r)];case 2:return o=g.sent(),[3,7];case 3:return g.sent(),[4,this.getOwnedContactCardKeyIds(t)];case 4:return c=g.sent(),[4,this.keyGraph.getKey(c.ownerKeyId)];case 5:return e=g.sent(),[4,this.keyGraph.getKey(c.sharedKeyId)];case 6:return o=g.sent(),[3,7];case 7:return u=this.keyService.currentSigPxk,[4,this.encryptionService.encrypt(o.jwk,s)];case 8:return p=g.sent(),h=(l=JSON).stringify,[4,this.encryptionService.sign(u.jwk,p)];case 9:return d=h.apply(l,[g.sent()]),v=(f=JSON).stringify,[4,this.encryptionService.sign(u.jwk,i)];case 10:return y=v.apply(f,[g.sent()]),[4,this.encryptionService.encryptToString(e.jwk,a)];case 11:return m=g.sent(),[2,new ze({mutation:fs,variables:{input:{id:t,ownerCipherData:m,ownerKeyId:e.id,sharedCipherDataSig:d,sharedKeyId:o.id,sigPxkId:u.id,ownerPlainDataSig:y}}})]}}))}))},e.prototype.updateReceivedContactCard=function(e){var t=e.id,n=e.receiverKeyId,r=e.receiverCipherDataClearJson;return M(this,void 0,void 0,(function(){var e,i,a=this;return O(this,(function(s){switch(s.label){case 0:return[4,this.keyGraph.getKey(n,(function(){return a.getReceivedContactCardKeyId(t)}))];case 1:return e=s.sent(),[4,this.encryptionService.encryptToString(e.jwk,r)];case 2:return i=s.sent(),[2,new ze({mutation:vs,variables:{input:{id:t,receiverCipherData:i,receiverKeyId:e.id}}})]}}))}))},e}(),e.SharedContactCard2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.SharedContactCard2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(Ke),t.ɵɵinject(Pe),t.ɵɵinject(ve),t.ɵɵinject(e.ɵg))},token:e.SharedContactCard2Service,providedIn:"root"}),e.SharedContactCard2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.SharedContactCard2Service.ctorParameters=function(){return[{type:t.NgZone},{type:Ke},{type:Pe},{type:ve},{type:e.ɵg}]},e.SharedContactCard2Service=A([qe({ngZoneName:"ngZone"})],e.SharedContactCard2Service);var Ss,Cs,bs,Is,ws,Ks=Te(Ss||(Ss=F(["\nfragment SharedTpPasswordResetFragment on SharedTpPasswordResetNode {\n id\n tp {\n id\n other {\n username\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedRequest {\n id\n pxk {\n id\n pbk\n }\n claim {\n id\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nfragment SharedTpPasswordResetFragment on SharedTpPasswordResetNode {\n id\n tp {\n id\n other {\n username\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedRequest {\n id\n pxk {\n id\n pbk\n }\n claim {\n id\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),Ps=Te(Cs||(Cs=F(["\nquery SharedTpPasswordResetsQuery {\n sharedTpPasswordResets {\n edges {\n node {\n ...SharedTpPasswordResetFragment\n }\n }\n }\n}\n","\n"],["\nquery SharedTpPasswordResetsQuery {\n sharedTpPasswordResets {\n edges {\n node {\n ...SharedTpPasswordResetFragment\n }\n }\n }\n}\n","\n"])),Ks),ks=Te(bs||(bs=F(["\nquery SharedTpPasswordResetQuery($id: LrRelayIdInput!) {\n sharedTpPasswordReset(id: $id) {\n ...SharedTpPasswordResetFragment\n }\n}\n","\n"],["\nquery SharedTpPasswordResetQuery($id: LrRelayIdInput!) {\n sharedTpPasswordReset(id: $id) {\n ...SharedTpPasswordResetFragment\n }\n}\n","\n"])),Ks),Rs=(Te(Is||(Is=F(["\nquery TpPasswordResetUserQuery {\n tpPasswordResetUser {\n username\n resetUsername\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n sessionEncryptionKey\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n requestAgainAfter\n }\n}"],["\nquery TpPasswordResetUserQuery {\n tpPasswordResetUser {\n username\n resetUsername\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n sessionEncryptionKey\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n requestAgainAfter\n }\n}"]))),Te(ws||(ws=F(["\nquery TpPasswordResetQuery {\n tpPasswordReset {\n id\n applied\n assembly {\n singleReject\n quorum\n canMeetQuorum\n subjectCipherData\n subjectKey {\n id\n }\n assemblyKey {\n id\n }\n assemblyCipherData\n subAssemblies {\n edges {\n node {\n id\n singleReject\n quorum\n subjectCipherData\n subjectKey {\n id\n }\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nquery TpPasswordResetQuery {\n tpPasswordReset {\n id\n applied\n assembly {\n singleReject\n quorum\n canMeetQuorum\n subjectCipherData\n subjectKey {\n id\n }\n assemblyKey {\n id\n }\n assemblyCipherData\n subAssemblies {\n edges {\n node {\n id\n singleReject\n quorum\n subjectCipherData\n subjectKey {\n id\n }\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))));e.ɵn=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return E(t,e),t.prototype.getReset=function(){return M(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.query({query:Rs})];case 1:return[2,e.sent().tpPasswordReset]}}))}))},t.prototype.getSharedResets=function(){return M(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.query({query:Ps})];case 1:return[2,e.sent().sharedTpPasswordResets]}}))}))},t.prototype.getSharedReset=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.query({query:ks,variables:{id:e}})];case 1:return[2,t.sent().sharedTpPasswordReset]}}))}))},t}(Kt),e.ɵn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵn(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵn,providedIn:"root"}),e.ɵn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵn.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵn=A([qe({ngZoneName:"ngZone"})],e.ɵn),e.TpPasswordResetRequestService=function(t){function n(e,n,r,i){var a=t.call(this,n)||this;return a.ngZone=e,a.injector=n,a.encryptionService=r,a.privateService=i,a}return E(n,t),n.prototype.activeRequestOrRaise=function(t){var n=t.sharedRequest.claim.state;if(n!==e.TpAssemblyState.CLAIMED)throw new Z("Claim is already in "+n+" state.")},n.prototype.rejectRequest=function(e){return this.mutate(this.rejectRequestMutation(e))},n.prototype.rejectRequestMutation=function(t){return M(this,void 0,void 0,(function(){var n;return O(this,(function(r){switch(r.label){case 0:return[4,this.privateService.getSharedReset(t)];case 1:return n=r.sent(),this.activeRequestOrRaise(n),[2,tt.create(n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})).map((function(e){return new ze({mutation:Kr,variables:{input:{claimApproverId:e.node.id}}})})))]}}))}))},n.prototype.approveRequest=function(e,t){return M(this,void 0,void 0,(function(){var n,r;return O(this,(function(i){switch(i.label){case 0:return r=(n=this.lrGraphQL).lrMutate,[4,this.approveRequestMutation(e,t)];case 1:return[2,r.apply(n,[i.sent()])]}}))}))},n.prototype.approveRequestMutation=function(t,n){return M(this,void 0,void 0,(function(){var n,r,i,s,o,c=this;return O(this,(function(u){switch(u.label){case 0:return[4,this.privateService.getSharedReset(t)];case 1:return n=u.sent(),this.activeRequestOrRaise(n),[4,a.JWK.asKey(JSON.parse(n.sharedRequest.pxk.pbk))];case 2:return r=u.sent(),i=n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})),o=(s=tt).create,[4,Promise.all(i.map((function(e){return M(c,void 0,void 0,(function(){var t,n,i=this;return O(this,(function(a){switch(a.label){case 0:return t=e.node,n={claimApproverId:t.id},[4,Promise.all(t.receiverApprovals.edges.map((function(e){return M(i,void 0,void 0,(function(){var n,i;return O(this,(function(a){switch(a.label){case 0:return n=e.node,i={receiverApprovalId:n.id,receiverCipher:""},[4,this.encryptionService.encryptToString(r,t.sharedCipherPartialAssemblyKeyClearJson)];case 1:return[2,(i.receiverCipherPartialAssemblyKey=a.sent(),i)]}}))}))})))];case 1:return n.receiverApprovals=a.sent(),[2,new ze({mutation:wr,variables:{input:n}})]}}))}))})))];case 3:return[2,o.apply(s,[u.sent()])]}}))}))},n}(Kt),e.TpPasswordResetRequestService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetRequestService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ve),t.ɵɵinject(e.ɵn))},token:e.TpPasswordResetRequestService,providedIn:"root"}),e.TpPasswordResetRequestService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetRequestService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ve},{type:e.ɵn}]},e.TpPasswordResetRequestService=A([qe({ngZoneName:"ngZone"})],e.TpPasswordResetRequestService);function Es(){!function(e){if(!e)throw new Q("You must specify a non empty prefix.");Object.keys(localStorage).forEach((function(t){t.startsWith(e)&&localStorage.removeItem(t)}))}("CognitoIdentityServiceProvider")}e.TpPasswordResetUserService=function(e){function t(t,n,r,i,a,s,o,c){var u=e.call(this,n)||this;return u.ngZone=t,u.injector=n,u.config=r,u.keyFactory=i,u.encryptionService=a,u.passwordService=s,u.http=o,u.auth=c,u}return E(t,e),t.prototype.verifyEmailContact=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){return t={email:e},[2,this.http.post(this.config.authUrl+"tp/password-reset/verify-contact/",t).toPromise()]}))}))},t.prototype.verifyContactRespond=function(e,t){return M(this,void 0,void 0,(function(){return O(this,(function(n){switch(n.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e,v_code:t}).toPromise()];case 1:return[2,n.sent().token]}}))}))},t.prototype.requestReset=function(e,t,n){return M(this,void 0,void 0,(function(){var r,i,a,s,o,c,u;return O(this,(function(p){switch(p.label){case 0:return Es(),[4,this.passwordService.createPassKeyBundle(e)];case 1:return r=p.sent(),[4,this.keyFactory.createKey()];case 2:return i=p.sent(),[4,this.encryptionService.encrypt(r.passKey,i.toJSON(!0))];case 3:return a=p.sent(),[4,this.keyFactory.createPkcKey()];case 4:return s=p.sent(),[4,this.encryptionService.encrypt(i,s.toJSON(!0))];case 5:return o=p.sent(),[4,this.http.post(this.config.authUrl+"tp/password-reset/request/",{claimId:t,claimToken:n,pass_key_params:r.passKeyParams,pass_idp_params:r.passIdpParams,pass_idp_verifier_pbk:r.passIdpVerifier.toJSON(),wrapped_pass_idp_verifier_prk:r.wrappedPassIdpVerifierPrk,wrapped_master_key:a,pbk:s.toJSON(),master_key_wrapped_prk:o}).toPromise()];case 6:return c=p.sent(),console.log("Using new password"),[4,this.auth.signUp({username:c.reset_username,password:this.passwordService.getPassIdpString(r.passIdp),clientMetadata:{tp_password_reset_request:JSON.stringify({id:c.id,associate_reset_user_token:c.associate_reset_user_token})}})];case 7:return u=p.sent(),console.log("requestRest done"),[2,{requestResetResult:c,signUpResult:u}]}}))}))},t}(Kt),e.TpPasswordResetUserService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetUserService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(Se),t.ɵɵinject(ge),t.ɵɵinject(ve),t.ɵɵinject(Bn),t.ɵɵinject(y.HttpClient),t.ɵɵinject(s.AuthClass))},token:e.TpPasswordResetUserService,providedIn:"root"}),e.TpPasswordResetUserService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetUserService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:void 0,decorators:[{type:t.Inject,args:[Se]}]},{type:ge},{type:ve},{type:Bn},{type:y.HttpClient},{type:s.AuthClass}]},e.TpPasswordResetUserService=A([qe({ngZoneName:"ngZone"})],e.TpPasswordResetUserService),e.TpPasswordResetService=function(e){function t(t,n,r,i){var a=e.call(this,n)||this;return a.ngZone=t,a.injector=n,a.privateService=r,a.assemblyController=i,a.slip39Passphrase=Zn,a}return E(t,e),t.prototype.cancelResetRequest=function(){return this.mutate(this.cancelResetRequestMutation())},t.prototype.cancelResetRequestMutation=function(){return new ze({mutation:Sr})},t.prototype.deleteReset=function(){return this.mutate(this.deleteResetMutation())},t.prototype.deleteResetMutation=function(){return new ze({mutation:kr})},t.prototype.validateApprovers=function(e){return this.assemblyController.validateApprovers(e)},t.prototype.createReset=function(e){return this.mutate(this.createResetMutation(e))},t.prototype.createResetMutation=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.assemblyController.prepareCreate(e)];case 1:return t=n.sent().mutationInput,[2,new ze({mutation:Pr,variables:{input:{assembly:Object.assign({},t)}}})]}}))}))},t.prototype.updateReset=function(e){return this.mutate(this.updateResetMutation(e))},t.prototype.updateResetMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return[4,this.privateService.getReset()];case 1:return t=r.sent(),[4,this.assemblyController.prepareUpdate(e,t.assembly)];case 2:return n=r.sent().mutationInput,[2,new ze({mutation:Rr,variables:{input:{assembly:Object.assign({},n)}}})]}}))}))},t.prototype.debugExpireResetRequest=function(e){return this.mutate(this.debugExpireResetRequestMutation(e),{includeKeyGraph:!1})},t.prototype.debugExpireResetRequestMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:ns,variables:{input:{username:e}}})]}))}))},t}(Kt),e.TpPasswordResetService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(e.ɵn),t.ɵɵinject(e.ɵi))},token:e.TpPasswordResetService,providedIn:"root"}),e.TpPasswordResetService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:e.ɵn},{type:e.ɵi}]},e.TpPasswordResetService=A([qe({ngZoneName:"ngZone"})],e.TpPasswordResetService);var Ds,As,Ms,Os,Ts,js,Ns,Fs,_s,$s,Ls,Us,xs,qs=Te(Ds||(Ds=F(["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"]))),Js=Te(As||(As=F(["\nmutation CreateDirectoryShareMutation($input: CreateDirectoryShareInput!) {\n createDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"],["\nmutation CreateDirectoryShareMutation($input: CreateDirectoryShareInput!) {\n createDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"]))),Gs=Te(Ms||(Ms=F(["\nmutation CreateFileShareMutation($input: CreateFileShareInput!) {\n createFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"],["\nmutation CreateFileShareMutation($input: CreateFileShareInput!) {\n createFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"]))),Qs=Te(Os||(Os=F(["\nmutation UpdateDirectoryShareMutation($input: UpdateDirectoryShareInput!) {\n updateDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"],["\nmutation UpdateDirectoryShareMutation($input: UpdateDirectoryShareInput!) {\n updateDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"]))),Ws=Te(Ts||(Ts=F(["\nmutation UpdateFileShareMutation($input: UpdateFileShareInput!) {\n updateFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"],["\nmutation UpdateFileShareMutation($input: UpdateFileShareInput!) {\n updateFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"]))),Vs=Te(js||(js=F(["\nmutation DeleteDirectoryShareMutation($input: DeleteDirectoryShareInput!) {\n deleteDirectoryShare(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteDirectoryShareMutation($input: DeleteDirectoryShareInput!) {\n deleteDirectoryShare(input: $input) {\n id\n }\n}\n"]))),Bs=Te(Ns||(Ns=F(["\nmutation DeleteFileShareMutation($input: DeleteFileShareInput!) {\n deleteFileShare(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteFileShareMutation($input: DeleteFileShareInput!) {\n deleteFileShare(input: $input) {\n id\n }\n}\n"]))),Zs=Te(Fs||(Fs=F(["\nmutation CompleteDetachedDirectoryShareMutation($input: CompleteDetachedDirectoryShareInput!) {\n completeDetachedDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"],["\nmutation CompleteDetachedDirectoryShareMutation($input: CompleteDetachedDirectoryShareInput!) {\n completeDetachedDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"]))),Hs=Te(_s||(_s=F(["\nmutation CompleteDetachedFileShareMutation($input: CompleteDetachedFileShareInput!) {\n completeDetachedFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"],["\nmutation CompleteDetachedFileShareMutation($input: CompleteDetachedFileShareInput!) {\n completeDetachedFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"]))),Ys=Te($s||($s=F(["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"]))),Xs=Te(Ls||(Ls=F(["\n mutation RespondTpMkReshareMutation($input: RespondTpMkReshareInput!) {\n respondTpMkReshare(input: $input) {\n id\n }\n }\n"],["\n mutation RespondTpMkReshareMutation($input: RespondTpMkReshareInput!) {\n respondTpMkReshare(input: $input) {\n id\n }\n }\n"]))),zs=Te(Us||(Us=F(["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"]))),eo=Te(xs||(xs=F(["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"],["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"])));e.TrustedPartyService=function(e){function t(t,n,r,i,a,s,o){var c=e.call(this,n)||this;return c.ngZone=t,c.injector=n,c.keyGraph=r,c.itemService=i,c.keyService=a,c.keyFactory=s,c.encryptionService=o,c}return E(t,e),t.prototype.deleteTp=function(e){return this.mutate(this.deleteTpMutation(e))},t.prototype.deleteTpMutation=function(e){return new ze({mutation:qs,variables:{input:{id:e}}})},t.prototype.createDirectoryShare=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.createDirectoryShareMutation(e))]}))}))},t.prototype.createDirectoryShareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return t=ze.bind,n={mutation:Js},[4,this.prepareCreateItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=r.sent(),n)]))]}}))}))},t.prototype.createFileShare=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.createFileShareMutation(e))]}))}))},t.prototype.createFileShareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return t=ze.bind,n={mutation:Gs},[4,this.prepareCreateItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=r.sent(),n)]))]}}))}))},t.prototype.prepareCreateItemShareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d=this;return O(this,(function(l){switch(l.label){case 0:return t=e.itemId,n=e.itemKeyId,r=e.tpId,i=e.tpSharedKeyId,a=e.accessRole,s=e.isDirectory,o=e.shareType,[4,this.keyGraph.getKey(n,(function(){return s?d.itemService.getDirectoryKeyId(t):d.itemService.getFileKeyId(t)}))];case 1:return c=l.sent(),[4,this.keyGraph.getKey(i,(function(){return d.getTpCurrentUserSharedKey(r).then((function(e){return e.sharedKey.id}))}))];case 2:return u=l.sent(),[4,this.keyGraph.wrapKey(u,c.jwk)];case 3:return p=l.sent(),[2,{input:{id:t,tpId:r,accessRole:a,keyId:c.id,wrappingKeyId:u.id,wrappedKey:p,shareType:o}}]}}))}))},t.prototype.updateDirectoryShare=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.updateDirectoryShareMutation(e))]}))}))},t.prototype.updateDirectoryShareMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:Qs,variables:this.prepareUpdateItemShareMutation(e)})]}))}))},t.prototype.updateFileShare=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.updateFileShareMutation(e))]}))}))},t.prototype.updateFileShareMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:Ws,variables:this.prepareUpdateItemShareMutation(e)})]}))}))},t.prototype.prepareUpdateItemShareMutation=function(e){return{input:{id:e.itemShareId,accessRole:e.accessRole}}},t.prototype.deleteDirectoryShare=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.deleteDirectoryShareMutation(e))]}))}))},t.prototype.deleteDirectoryShareMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:Vs,variables:{input:{id:e}}})]}))}))},t.prototype.deleteFileShare=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.deleteFileShareMutation(e))]}))}))},t.prototype.deleteFileShareMutation=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,new ze({mutation:Bs,variables:{input:{id:e}}})]}))}))},t.prototype.completeDetachedDirectoryShare=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.completeDetachedDirectoryShareMutation(e))]}))}))},t.prototype.completeDetachedDirectoryShareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return t=ze.bind,n={mutation:Zs},[4,this.prepareCompleteDetachedItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=r.sent(),n)]))]}}))}))},t.prototype.completeDetachedFileShare=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.mutate(this.completeDetachedFileShareMutation(e))]}))}))},t.prototype.completeDetachedFileShareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return t=ze.bind,n={mutation:Hs},[4,this.prepareCompleteDetachedItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))];case 1:return[2,new(t.apply(ze,[void 0,(n.variables=r.sent(),n)]))]}}))}))},t.prototype.prepareCompleteDetachedItemShareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s,o=this;return O(this,(function(c){switch(c.label){case 0:return t=e.itemShareId,n=e.itemKeyId,r=e.isDirectory,[4,this.keyGraph.getKey(n,(function(){return r?o.itemService.getDirectoryKeyIdFromDirectoryShare(t):o.itemService.getFileKeyIdFromFileShare(t)}))];case 1:return i=c.sent(),a=this.keyService.currentRootKey,[4,this.keyGraph.wrapKey(a,i.jwk)];case 2:return s=c.sent(),[2,{input:{id:t,keyId:i.id,wrappingKeyId:a.id,wrappedKey:s}}]}}))}))},t.prototype.requestMkReshareMutation=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,a,s;return O(this,(function(o){switch(o.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if((t=o.sent()).mkSharedKey)throw new Z("TP already has mkSharedKey");return n=this.keyService.currentMasterKey,[4,this.keyFactory.createPkcKey()];case 2:return r=o.sent(),[4,this.encryptionService.encryptToString(n.jwk,r.toJSON(!0))];case 3:return i=o.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 4:return a=o.sent(),[4,this.encryptionService.encryptToString(a.jwk,{pbk:r.toJSON()})];case 5:return s=o.sent(),[4,new ze({mutation:Ys,variables:{input:{tpId:e,masterKeyId:n.id,mkPbk:JSON.stringify(r.toJSON()),mkWrappedMkPrk:i,sharedKeyId:a.id,mkReshareRequestCipher:s}}})];case 6:return[2,o.sent()]}}))}))},t.prototype.respondMkReshare=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u,p,d;return O(this,(function(l){switch(l.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if(!(t=l.sent()).mkSharedKey)throw new Z("No access to the mkSharedKey so cannot reshare it with TP");return[4,this.keyGraph.getKey(t.sharedKey.id)];case 2:return n=l.sent(),[4,this.encryptionService.decrypt(n,t.mkReshareRequestCipher)];case 3:return r=l.sent(),[4,a.JWK.asKey(r.pbk)];case 4:return i=l.sent(),[4,this.keyGraph.getKey(t.mkSharedKey.id)];case 5:return s=l.sent(),o={mkSharedKey:{id:s.id,jwk:s.jwk.toJSON(!0)}},p=(u=this.encryptionService).encryptToString,d=[i],[4,this.encryptionService.encryptToString(n.jwk,o)];case 6:return[4,p.apply(u,d.concat([l.sent()]))];case 7:return c=l.sent(),[2,new ze({mutation:Xs,variables:{input:{tpId:e,mkSharedKeyId:s.id,mkReshareResponseCipher:c}}})]}}))}))},t.prototype.completeMkReshare=function(e){return M(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u,p,d,l;return O(this,(function(h){switch(h.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:return t=h.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 2:return n=h.sent(),[4,this.keyGraph.getKey(t.mkPxk.id)];case 3:return r=h.sent(),o=(s=this.encryptionService).decrypt,c=[n],[4,this.encryptionService.decrypt(r,t.mkReshareResponseCipher)];case 4:return[4,o.apply(s,c.concat([h.sent()]))];case 5:return i=h.sent(),p={id:i.mkSharedKey.id},[4,a.JWK.asKey(i.mkSharedKey.jwk)];case 6:return p.jwk=h.sent(),u=p,d=this.keyService.currentMasterKey,[4,this.encryptionService.encryptToString(d.jwk,u.jwk.toJSON(!0))];case 7:return l=h.sent(),[2,new ze({mutation:zs,variables:{input:{tpId:e,masterKeyId:d.id,mkSharedKeyId:u.id,mkWrappedMkSharedKey:l}}})]}}))}))},t.prototype.getTpCurrentUserSharedKey=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:eo,variables:{id:e}})];case 1:return[2,t.sent().tp.currentUserSharedKey.userSharedKey]}}))}))},t}(Kt),e.TrustedPartyService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TrustedPartyService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(Pe),t.ɵɵinject(e.ItemService),t.ɵɵinject(Ke),t.ɵɵinject(ge),t.ɵɵinject(ve))},token:e.TrustedPartyService,providedIn:"root"}),e.TrustedPartyService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TrustedPartyService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:Pe},{type:e.ItemService},{type:Ke},{type:ge},{type:ve}]},e.TrustedPartyService=A([qe({ngZoneName:"ngZone"})],e.TrustedPartyService);var to=function(){function e(e){this.auth=e}return e.prototype.getPreferredMFA=function(){return M(this,void 0,void 0,(function(){var e;return O(this,(function(t){switch(t.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return e=t.sent(),[4,this.auth.getPreferredMFA(e)];case 2:return[2,t.sent()]}}))}))},e.prototype.setPreferredMFA=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t=n.sent(),[4,this.auth.setPreferredMFA(t,e)];case 2:return n.sent(),[2]}}))}))},e.prototype.setPhoneNumber=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t=n.sent(),[4,this.auth.updateUserAttributes(t,{phone_number:e})];case 2:return n.sent(),[2]}}))}))},e.prototype.getSMSCode=function(){return M(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.auth.verifyCurrentUserAttribute("phone_number")];case 1:return e.sent(),[2]}}))}))},e.prototype.verifySMSCode=function(e){return M(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.auth.verifyCurrentUserAttributeSubmit("phone_number",e)];case 1:return t.sent(),[2]}}))}))},e.prototype.getSoftwareToken=function(){return M(this,void 0,void 0,(function(){var e,t,n,r,i;return O(this,(function(a){switch(a.label){case 0:return[4,Promise.all([this.auth.currentAuthenticatedUser(),this.auth.currentUserInfo()])];case 1:return e=j.apply(void 0,[a.sent(),2]),t=e[0],n=e[1],[4,this.auth.setupTOTP(t)];case 2:if(r=a.sent(),!(i=n.attributes.email))throw new Q("No email associated with user.");return[2,{code:r,codeUri:"otpauth://totp/"+i+"?secret="+r+"&issuer=LifeReady"}]}}))}))},e.prototype.verifySoftwareToken=function(e){return M(this,void 0,void 0,(function(){var t;return O(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t=n.sent(),[4,this.auth.verifyTotpToken(t,e)];case 2:return n.sent(),[2]}}))}))},e}();to.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new to(t.ɵɵinject(s.AuthClass))},token:to,providedIn:"root"}),to.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],to.ctorParameters=function(){return[{type:s.AuthClass}]};var no,ro,io,ao=K.default(no||(no=F(["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"],["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"]))),so=K.default(ro||(ro=F(["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"],["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"]))),oo=K.default(io||(io=F(["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"],["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"]))),co=function(){function e(e){this.lrApollo=e}return e.prototype.requestUserDelete=function(){return M(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:ao,variables:{input:{}}})];case 1:return[2,e.sent().requestUserDelete.userDelete]}}))}))},e.prototype.cancelUserDelete=function(){return M(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:so,variables:{input:{}}})];case 1:return[2,e.sent().cancelUserDelete.id]}}))}))},e.prototype.loginHistory=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=null),M(this,void 0,void 0,(function(){return O(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:oo,variables:{first:e,after:t}})];case 1:return[2,n.sent().loginHistory]}}))}))},e}();co.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new co(t.ɵɵinject(ke))},token:co,providedIn:"root"}),co.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],co.ctorParameters=function(){return[{type:ke}]},e.ApiContactCard=hn,e.ApiCurrentUser=ln,e.ApproveScenarioClaimMutation=za,e.ApproveTpPasswordResetRequestMutation=wr,e.ArchiveDirectoryMutation=yi,e.ArchiveFileMutation=fi,e.BeginDeleteChildItemLinksWindowMutation=Ci,e.CancelKeyExchangeMutation=nn,e.CancelScenarioClaimMutation=Ya,e.CancelTpPasswordResetRequestMutation=Sr,e.CancelUserDeleteMutation=so,e.ChangeDirectoryParentsMutation=gi,e.ChangeFileParentsMutation=Si,e.CompleteKeyExchangeOtkMutation=on,e.CompleteTpPasswordResetRequestMutation=Ir,e.ContactCardAddress=fn,e.ContactCardName=yn,e.ContactCardsQuery=$n,e.CreateContactCardMutation=Nn,e.CreateDirectoryMutation=oi,e.CreateFileMutation=pi,e.CreateLbopQuery=Qi,e.CreateScenarioClaimMutation=Ha,e.CreateScenarioMutation=Va,e.CreateTpAssemblyKeyChallengeMutation=Cr,e.CreateTpPasswordResetMutation=Pr,e.CurrentUserKey=dn,e.CurrentUserQuery=jn,e.CurrentUserSharedKeyQuery2=cn,e.DebugExpireScenarioClaimMutation=ts,e.DebugExpireTpPasswordResetRequestMutation=ns,e.DeclineKeyExchangeMutation=rn,e.DefaultProcessorOptions=Je,e.DeleteDirectoryMutation=ui,e.DeleteFileMutation=hi,e.DeleteLbopQuery=Wi,e.DeleteScenarioMutation=Za,e.DeleteTpPasswordResetMutation=kr,e.DirectoryQuery=Ue,e.ERROR_SOURCE=Li,e.Features=pn,e.FetchKeyGraphField=Le,e.FileUploadService=Lr,e.GetOwnedContactCardKeyIdsQuery=ms,e.GetReceivedContactCardKeyIdQuery=gs,e.IdleService=Dt,e.InitiateKeyExchangeOtkMutation=an,e.KC_CONFIG=Se,e.KcAuthException=G,e.KcBadArgumentException=Q,e.KcBadLogicException=W,e.KcBadRequestException=V,e.KcBadSignatureException=B,e.KcBadStateException=Z,e.KcBadTimeSyncException=H,e.KcCodeMismatchException=Y,e.KcConcurrentAccessException=X,e.KcEncryptionException=z,e.KcError=q,e.KcException=J,e.KcInternalErrorException=ee,e.KcLockedException=te,e.KcNotFoundException=ne,e.KcSuspiciousOperationException=re,e.KcUnsupportedException=ie,e.KeyExchangeFields=Yt,e.KeyExchangeQuery2=en,e.KeyExchangeTokenQuery2=tn,e.KeyExchangesQuery2=zt,e.KeyGraphField=$e,e.KeyGraphFragment=_e,e.LbopQuery=Bi,e.LbopService=Hi,e.LbopsQuery=Zi,e.LifeReadyModule=Yi,e.LoginHistoryQuery=oo,e.LrApolloService=ke,e.LrGraphQLService=e.ɵg,e.LrMergedMutation=tt,e.LrMutation=ze,e.LrMutationBase=Xe,e.LrService=Kt,e.MainContactCardFields=mn,e.MainContactCardPlainFields=gn,e.MainContactCardProperty=vn,e.OwnerPlainDataJson=$r,e.PasswordCheck=Vn,e.PasswordService=Bn,e.PersistService=we,e.PreCompleteTpPasswordResetRequestMutation=br,e.ProfileDetailsService=Ea,e.ProfileService=Ln,e.ReceiveScenarioClaimMutation=es,e.RegisterResult=Ta,e.RegisterService=Da,e.RejectScenarioClaimMutation=Xa,e.RejectTpPasswordResetRequestMutation=Kr,e.RequestUserDeleteMutation=ao,e.RespondKeyExchangeOtkMutation=sn,e.RevertFileMutation=li,e.ServerTimeQuery=le,e.SetDirectoryConfidentialMutation=wi,e.SetFileConfidentialMutation=Ii,e.SharedTrustedPartyDetails=Cn,e.SharedVaultFeature=In,e.TPFeatures=bn,e.TempDirectoryQuery=bi,e.TimeService=he,e.TrustedPartiesQuery=_n,e.TrustedParty=Kn,e.TrustedPartyDetails=Sn,e.TrustedPartyProperties=Tn,e.TwoFactorService=to,e.UnarchiveDirectoryMutation=vi,e.UnarchiveFileMutation=mi,e.UpdateContactCardMutation=Fn,e.UpdateDirectoryMutation=ci,e.UpdateFileMutation=di,e.UpdateLbopQuery=Vi,e.UpdateOwnedContactCardMutation=fs,e.UpdateReceivedContactCardMutation=vs,e.UpdateScenarioMutation=Ba,e.UpdateTpPasswordResetMutation=Rr,e.UserService=co,e.UserSharedKeyFields=Xt,e.WebCryptoService=me,e.awsFetch=Rt,e.configureAmplifyAuth=Et,e.configureApollo=Ie,e.fragmentSpreadAstSelection=Ye,e.gqlTyped=Te,e.handleApolloError=U,e.handleCognitoCallback=function(e){return new Promise((function(t,n){return e((function(e,r){return e?n(e):t(r)}))}))},e.httpOptions=be,e.mapEdges=Pt,e.processConnection=Ge,e.throwClaimIdMismatch=os,e.throwClaimNotApproved=cs,e.ɵa=Pe,e.ɵb=ve,e.ɵc=Ke,e.ɵd=ge,e.ɵe=Kt,e.ɵf=qe,e.ɵh=xt,e.ɵj=nr,e.ɵk=Pn,e.ɵl=Rn,Object.defineProperty(e,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=lifeready-core.umd.min.js.map