@lifeready/core 0.6.0-beta.1
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.
- package/README.md +62 -0
- package/bundles/lifeready-core.umd.js +15939 -0
- package/bundles/lifeready-core.umd.js.map +1 -0
- package/bundles/lifeready-core.umd.min.js +2 -0
- package/bundles/lifeready-core.umd.min.js.map +1 -0
- package/esm2015/lib/_common/ast.js +40 -0
- package/esm2015/lib/_common/deferred-promise.js +24 -0
- package/esm2015/lib/_common/exceptions.js +157 -0
- package/esm2015/lib/_common/queries.gql.js +190 -0
- package/esm2015/lib/_common/run-outside-angular.js +79 -0
- package/esm2015/lib/_common/types.js +1 -0
- package/esm2015/lib/_common/utils.js +44 -0
- package/esm2015/lib/api/contact-card.gql.js +79 -0
- package/esm2015/lib/api/contact-card.service.js +154 -0
- package/esm2015/lib/api/contact-card2.gql.js +60 -0
- package/esm2015/lib/api/contact-card2.service.js +103 -0
- package/esm2015/lib/api/file.service.js +74 -0
- package/esm2015/lib/api/item2.gql.js +110 -0
- package/esm2015/lib/api/item2.service.js +311 -0
- package/esm2015/lib/api/key-exchange.gql.js +188 -0
- package/esm2015/lib/api/key-exchange.service.js +442 -0
- package/esm2015/lib/api/key-exchange.types.js +18 -0
- package/esm2015/lib/api/key-exchange2.gql.js +171 -0
- package/esm2015/lib/api/key-exchange2.service.js +479 -0
- package/esm2015/lib/api/lock.gql.js +40 -0
- package/esm2015/lib/api/lock.service.js +64 -0
- package/esm2015/lib/api/lr-apollo.service.js +46 -0
- package/esm2015/lib/api/lr-graphql/index.js +6 -0
- package/esm2015/lib/api/lr-graphql/lr-graphql.service.js +155 -0
- package/esm2015/lib/api/lr-graphql/lr-merged-mutation.js +213 -0
- package/esm2015/lib/api/lr-graphql/lr-mutation-base.js +51 -0
- package/esm2015/lib/api/lr-graphql/lr-mutation.js +48 -0
- package/esm2015/lib/api/lr-graphql/lr.service.js +18 -0
- package/esm2015/lib/api/message.service.js +138 -0
- package/esm2015/lib/api/persist.service.js +181 -0
- package/esm2015/lib/api/query-processor/common-processors.service.js +93 -0
- package/esm2015/lib/api/query-processor/index.js +3 -0
- package/esm2015/lib/api/query-processor/query-processor.service.js +192 -0
- package/esm2015/lib/api/query-processor/tp-password-reset-processor.service.js +109 -0
- package/esm2015/lib/api/shared-contact-card.service.js +119 -0
- package/esm2015/lib/api/shared-contact-card2.gql.js +41 -0
- package/esm2015/lib/api/shared-contact-card2.service.js +117 -0
- package/esm2015/lib/api/time.service.js +146 -0
- package/esm2015/lib/api/types/graphql.types.js +7 -0
- package/esm2015/lib/api/types/index.js +3 -0
- package/esm2015/lib/api/types/lr-graphql.types.js +71 -0
- package/esm2015/lib/auth/auth.config.js +57 -0
- package/esm2015/lib/auth/auth.gql.js +48 -0
- package/esm2015/lib/auth/auth.types.js +27 -0
- package/esm2015/lib/auth/idle.service.js +168 -0
- package/esm2015/lib/auth/idle.types.js +7 -0
- package/esm2015/lib/auth/lbop.service.js +355 -0
- package/esm2015/lib/auth/life-ready-auth.service.js +333 -0
- package/esm2015/lib/auth/password.service.js +320 -0
- package/esm2015/lib/auth/register.service.js +172 -0
- package/esm2015/lib/auth/two-factor.service.js +74 -0
- package/esm2015/lib/category/category-meta.service.js +99 -0
- package/esm2015/lib/category/category.gql.js +406 -0
- package/esm2015/lib/category/category.service.js +390 -0
- package/esm2015/lib/category/category.types.js +29 -0
- package/esm2015/lib/cryptography/cryptography.types.js +11 -0
- package/esm2015/lib/cryptography/encryption.service.js +189 -0
- package/esm2015/lib/cryptography/key-factory.service.js +237 -0
- package/esm2015/lib/cryptography/key-graph.service.js +280 -0
- package/esm2015/lib/cryptography/key-meta.service.js +200 -0
- package/esm2015/lib/cryptography/key.service.js +124 -0
- package/esm2015/lib/cryptography/slip39.service.js +169 -0
- package/esm2015/lib/cryptography/web-crypto.service.js +29 -0
- package/esm2015/lib/life-ready.config.js +84 -0
- package/esm2015/lib/life-ready.module.js +74 -0
- package/esm2015/lib/plan/plan.gql.js +123 -0
- package/esm2015/lib/plan/plan.service.js +149 -0
- package/esm2015/lib/plan/plan.types.js +11 -0
- package/esm2015/lib/record/record-attachment.service.js +101 -0
- package/esm2015/lib/record/record.gql.js +179 -0
- package/esm2015/lib/record/record.service.js +206 -0
- package/esm2015/lib/record/record.types.js +15 -0
- package/esm2015/lib/record-type/record-type.service.js +75 -0
- package/esm2015/lib/record-type/record-type.types.js +28 -0
- package/esm2015/lib/scenario/approvals/scenario-approval.gql.js +105 -0
- package/esm2015/lib/scenario/approvals/scenario-approval.types.js +1 -0
- package/esm2015/lib/scenario/approvals/scenario-approver.service.js +300 -0
- package/esm2015/lib/scenario/claimants/scenario-claimant.gql.js +52 -0
- package/esm2015/lib/scenario/claimants/scenario-claimant.service.js +97 -0
- package/esm2015/lib/scenario/claimants/scenario-claimant.types.js +1 -0
- package/esm2015/lib/scenario/receivers/scenario-receiver.gql.js +150 -0
- package/esm2015/lib/scenario/receivers/scenario-receiver.service.js +229 -0
- package/esm2015/lib/scenario/receivers/scenario-receiver.types.js +1 -0
- package/esm2015/lib/scenario/scenario-setup.service.js +269 -0
- package/esm2015/lib/scenario/scenario.gql.js +368 -0
- package/esm2015/lib/scenario/scenario.service.js +611 -0
- package/esm2015/lib/scenario/scenario.types.js +64 -0
- package/esm2015/lib/search/search.gql.js +62 -0
- package/esm2015/lib/search/search.service.js +156 -0
- package/esm2015/lib/search/search.types.js +6 -0
- package/esm2015/lib/trusted-parties/tp-password-reset-request.service.js +112 -0
- package/esm2015/lib/trusted-parties/tp-password-reset-user.service.js +266 -0
- package/esm2015/lib/trusted-parties/tp-password-reset.gql.js +232 -0
- package/esm2015/lib/trusted-parties/tp-password-reset.service.js +300 -0
- package/esm2015/lib/trusted-parties/trusted-party.gql.js +148 -0
- package/esm2015/lib/trusted-parties/trusted-party.service.js +326 -0
- package/esm2015/lib/trusted-parties/trusted-party.types.js +41 -0
- package/esm2015/lib/trusted-parties/trusted-party2.gql.js +87 -0
- package/esm2015/lib/trusted-parties/trusted-party2.service.js +215 -0
- package/esm2015/lib/users/profile-details.service.js +214 -0
- package/esm2015/lib/users/profile.gql.js +97 -0
- package/esm2015/lib/users/profile.service.js +169 -0
- package/esm2015/lib/users/profile.types.js +34 -0
- package/esm2015/lib/users/user.gql.js +60 -0
- package/esm2015/lib/users/user.service.js +79 -0
- package/esm2015/lib/users/user.types.js +5 -0
- package/esm2015/lifeready-core.js +10 -0
- package/esm2015/public-api.js +81 -0
- package/fesm2015/lifeready-core.js +13290 -0
- package/fesm2015/lifeready-core.js.map +1 -0
- package/lib/_common/ast.d.ts +11 -0
- package/lib/_common/deferred-promise.d.ts +12 -0
- package/lib/_common/exceptions.d.ts +109 -0
- package/lib/_common/queries.gql.d.ts +10 -0
- package/lib/_common/run-outside-angular.d.ts +14 -0
- package/lib/_common/types.d.ts +10 -0
- package/lib/_common/utils.d.ts +3 -0
- package/lib/api/contact-card.gql.d.ts +7 -0
- package/lib/api/contact-card.service.d.ts +52 -0
- package/lib/api/contact-card2.gql.d.ts +34 -0
- package/lib/api/contact-card2.service.d.ts +49 -0
- package/lib/api/file.service.d.ts +18 -0
- package/lib/api/item2.gql.d.ts +96 -0
- package/lib/api/item2.service.d.ts +177 -0
- package/lib/api/key-exchange.gql.d.ts +9 -0
- package/lib/api/key-exchange.service.d.ts +39 -0
- package/lib/api/key-exchange.types.d.ts +196 -0
- package/lib/api/key-exchange2.gql.d.ts +125 -0
- package/lib/api/key-exchange2.service.d.ts +187 -0
- package/lib/api/lock.gql.d.ts +27 -0
- package/lib/api/lock.service.d.ts +25 -0
- package/lib/api/lr-apollo.service.d.ts +15 -0
- package/lib/api/lr-graphql/index.d.ts +5 -0
- package/lib/api/lr-graphql/lr-graphql.service.d.ts +60 -0
- package/lib/api/lr-graphql/lr-merged-mutation.d.ts +27 -0
- package/lib/api/lr-graphql/lr-mutation-base.d.ts +28 -0
- package/lib/api/lr-graphql/lr-mutation.d.ts +8 -0
- package/lib/api/lr-graphql/lr.service.d.ts +9 -0
- package/lib/api/message.service.d.ts +58 -0
- package/lib/api/persist.service.d.ts +31 -0
- package/lib/api/query-processor/common-processors.service.d.ts +36 -0
- package/lib/api/query-processor/index.d.ts +2 -0
- package/lib/api/query-processor/query-processor.service.d.ts +18 -0
- package/lib/api/query-processor/tp-password-reset-processor.service.d.ts +15 -0
- package/lib/api/shared-contact-card.service.d.ts +33 -0
- package/lib/api/shared-contact-card2.gql.d.ts +36 -0
- package/lib/api/shared-contact-card2.service.d.ts +45 -0
- package/lib/api/time.service.d.ts +16 -0
- package/lib/api/types/graphql.types.d.ts +29 -0
- package/lib/api/types/index.d.ts +2 -0
- package/lib/api/types/lr-graphql.types.d.ts +385 -0
- package/lib/auth/auth.config.d.ts +5 -0
- package/lib/auth/auth.gql.d.ts +15 -0
- package/lib/auth/auth.types.d.ts +66 -0
- package/lib/auth/idle.service.d.ts +40 -0
- package/lib/auth/idle.types.d.ts +10 -0
- package/lib/auth/lbop.service.d.ts +91 -0
- package/lib/auth/life-ready-auth.service.d.ts +46 -0
- package/lib/auth/password.service.d.ts +78 -0
- package/lib/auth/register.service.d.ts +25 -0
- package/lib/auth/two-factor.service.d.ts +15 -0
- package/lib/category/category-meta.service.d.ts +23 -0
- package/lib/category/category.gql.d.ts +45 -0
- package/lib/category/category.service.d.ts +67 -0
- package/lib/category/category.types.d.ts +79 -0
- package/lib/cryptography/cryptography.types.d.ts +83 -0
- package/lib/cryptography/encryption.service.d.ts +41 -0
- package/lib/cryptography/key-factory.service.d.ts +38 -0
- package/lib/cryptography/key-graph.service.d.ts +33 -0
- package/lib/cryptography/key-meta.service.d.ts +44 -0
- package/lib/cryptography/key.service.d.ts +36 -0
- package/lib/cryptography/slip39.service.d.ts +43 -0
- package/lib/cryptography/web-crypto.service.d.ts +5 -0
- package/lib/life-ready.config.d.ts +14 -0
- package/lib/life-ready.module.d.ts +5 -0
- package/lib/plan/plan.gql.d.ts +11 -0
- package/lib/plan/plan.service.d.ts +33 -0
- package/lib/plan/plan.types.d.ts +31 -0
- package/lib/record/record-attachment.service.d.ts +16 -0
- package/lib/record/record.gql.d.ts +14 -0
- package/lib/record/record.service.d.ts +25 -0
- package/lib/record/record.types.d.ts +57 -0
- package/lib/record-type/record-type.service.d.ts +11 -0
- package/lib/record-type/record-type.types.d.ts +50 -0
- package/lib/scenario/approvals/scenario-approval.gql.d.ts +7 -0
- package/lib/scenario/approvals/scenario-approval.types.d.ts +63 -0
- package/lib/scenario/approvals/scenario-approver.service.d.ts +32 -0
- package/lib/scenario/claimants/scenario-claimant.gql.d.ts +5 -0
- package/lib/scenario/claimants/scenario-claimant.service.d.ts +17 -0
- package/lib/scenario/claimants/scenario-claimant.types.d.ts +18 -0
- package/lib/scenario/receivers/scenario-receiver.gql.d.ts +8 -0
- package/lib/scenario/receivers/scenario-receiver.service.d.ts +30 -0
- package/lib/scenario/receivers/scenario-receiver.types.d.ts +54 -0
- package/lib/scenario/scenario-setup.service.d.ts +22 -0
- package/lib/scenario/scenario.gql.d.ts +34 -0
- package/lib/scenario/scenario.service.d.ts +58 -0
- package/lib/scenario/scenario.types.d.ts +217 -0
- package/lib/search/search.gql.d.ts +1 -0
- package/lib/search/search.service.d.ts +25 -0
- package/lib/search/search.types.d.ts +20 -0
- package/lib/trusted-parties/tp-password-reset-request.service.d.ts +20 -0
- package/lib/trusted-parties/tp-password-reset-user.service.d.ts +41 -0
- package/lib/trusted-parties/tp-password-reset.gql.d.ts +218 -0
- package/lib/trusted-parties/tp-password-reset.service.d.ts +131 -0
- package/lib/trusted-parties/trusted-party.gql.d.ts +9 -0
- package/lib/trusted-parties/trusted-party.service.d.ts +44 -0
- package/lib/trusted-parties/trusted-party.types.d.ts +102 -0
- package/lib/trusted-parties/trusted-party2.gql.d.ts +79 -0
- package/lib/trusted-parties/trusted-party2.service.d.ts +114 -0
- package/lib/users/profile-details.service.d.ts +21 -0
- package/lib/users/profile.gql.d.ts +11 -0
- package/lib/users/profile.service.d.ts +35 -0
- package/lib/users/profile.types.d.ts +96 -0
- package/lib/users/user.gql.d.ts +9 -0
- package/lib/users/user.service.d.ts +12 -0
- package/lib/users/user.types.d.ts +23 -0
- package/lifeready-core.d.ts +9 -0
- package/lifeready-core.metadata.json +1 -0
- package/package.json +29 -0
- package/public-api.d.ts +77 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common/http"),require("@angular/core"),require("@apollo/client/core"),require("@apollo/client/link/context"),require("@apollo/client/link/retry"),require("@aws-amplify/core"),require("rxjs"),require("@dagrejs/graphlib"),require("lodash"),require("node-jose"),require("@aws-amplify/auth/lib-esm/Auth"),require("apollo-angular"),require("graphql-tag"),require("moment"),require("ngx-cookie-service"),require("@aws-amplify/auth"),require("@ng-idle/core"),require("@ng-idle/keepalive"),require("graphql/language/printer"),require("slip39")):"function"==typeof define&&define.amd?define("@lifeready/core",["exports","@angular/common/http","@angular/core","@apollo/client/core","@apollo/client/link/context","@apollo/client/link/retry","@aws-amplify/core","rxjs","@dagrejs/graphlib","lodash","node-jose","@aws-amplify/auth/lib-esm/Auth","apollo-angular","graphql-tag","moment","ngx-cookie-service","@aws-amplify/auth","@ng-idle/core","@ng-idle/keepalive","graphql/language/printer","slip39"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).lifeready=e.lifeready||{},e.lifeready.core={}),e.ng.common.http,e.ng.core,e["@apollo/client/core"],e["@apollo/client/link/context"],e["@apollo/client/link/retry"],e["@aws-amplify/core"],e.rxjs,e["@dagrejs/graphlib"],e.lodash,e["node-jose"],e["@aws-amplify/auth/lib-esm/Auth"],e["apollo-angular"],e["graphql-tag"],e.moment,e["ngx-cookie-service"],e["@aws-amplify/auth"],e["@ng-idle/core"],e["@ng-idle/keepalive"],e["graphql/language/printer"],e.slip39)}(this,(function(e,t,n,r,i,a,s,o,c,u,d,p,l,y,h,v,f,m,g,S,I){"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 k=b(t),w=b(n),K=C(c),P=C(u),R=b(u),D=b(p),A=b(l),E=C(y),$=b(h),O=b(v),j=C(f),T=b(m),M=b(g),F=b(S),N=function(e,t){return(N=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 L(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}N(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function x(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 U(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 q(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 J(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 _(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 G(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 B(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(G(arguments[t]));return e}function Q(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}Object.create;function V(e){if(e&&e.length){var t=e.map((function(e){return{code:e.extensions&&e.extensions.code,source:e.extensions&&e.extensions.source,message:e.message,debug:{locations:e.locations,path:e.path}}}));throw new(Y.bind.apply(Y,B([void 0],t)))}}var W,H,Z=function(){},Y=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.errors=e}return e.prototype.toString=function(){return this.errors.map((function(e){return JSON.stringify(e,null,2)}))},e}();e.LrApiErrorCode=void 0,(W=e.LrApiErrorCode||(e.LrApiErrorCode={})).ARCHIVED_RESOURCE="ARCHIVED_RESOURCE",W.BAD_ARGUMENT="BAD_ARGUMENT",W.BAD_SIGNATURE="BAD_SIGNATURE",W.BAD_STATE="BAD_STATE",W.CHANGED_PERMISSIONS="CHANGED_PERMISSIONS",W.CONCURRENT_ACCESS="CONCURRENT_ACCESS",W.CONFIG_ERROR="CONFIG_ERROR",W.CYCLE_DETECTED="CYCLE_DETECTED",W.EXPIRED="EXPIRED",W.INVALID_TOKEN="INVALID_TOKEN",W.INTERNAL_ERROR="INTERNAL_ERROR",W.JSON_DECODE_ERROR="JSON_DECODE_ERROR",W.KEY_MISMATCH="KEY_MISMATCH",W.LIMIT_REACHED="LIMIT_REACHED",W.LOCKED="LOCKED",W.LOGIC_ERROR="LOGIC_ERROR",W.LR_DEBUG_ONLY="LR_DEBUG_ONLY",W.MIN_DELAY="MIN_DELAY",W.MISSING_FIELD="MISSING_FIELD",W.MISSING_FIELD_VALUE="MISSING_FIELD_VALUE",W.MISSING_QUERY_PARAM="MISSING_QUERY_PARAM",W.NOT_IMPLEMENTED="NOT_IMPLEMENTED",W.OBJECT_DOES_NOT_EXIST="OBJECT_DOES_NOT_EXIST",W.OBJECT_EXISTS="OBJECT_EXISTS",W.RANGE_ERROR="RANGE_ERROR",W.TRUSTED_PARTY_NOT_FOUND="TRUSTED_PARTY_NOT_FOUND",W.UNAUTHENTICATED_USER="UNAUTHENTICATED_USER",W.USER_NOT_FOUND="USER_NOT_FOUND",W.VERSION_MISMATCH="VERSION_MISMATCH",W.WRONG_PERMISSIONS="WRONG_PERMISSIONS",e.LrErrorCode=void 0,(H=e.LrErrorCode||(e.LrErrorCode={})).BadTimeSync="LrBadTimeSync",H.ReceiveClaimMismatch="LrReceiveClaimMismatch",H.BadState="LrBadState",H.BadSignature="LrBadSignature",H.Auth="LrAuth",H.BadArgument="LrBadArgument",H.SuspiciousException="LrSuspiciousException",H.NotFound="LrNotFound",H.BadLogic="LrBadLogicException",H.CodeMismatch="LrCodeMismatchException",H.ConcurrentAccess="LrConcurrentAccessException",H.BadRequest="LrBadRequestException",H.Encryption="LrEncryptionGoBad",H.Locked="LrLockedException";var z,X,ee=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadArgument,message:n})||this}return L(n,t),n}(Y),te=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadArgument,message:n})||this}return L(n,t),n}(Y),ne=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.NotFound,message:n})||this}return L(n,t),n}(Y),re=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadLogic,message:n})||this}return L(n,t),n}(Y),ie=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.CodeMismatch,message:n})||this}return L(n,t),n}(Y),ae=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.ConcurrentAccess,message:n})||this}return L(n,t),n}(Y),se=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.Locked,message:n})||this}return L(n,t),n}(Y),oe=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadRequest,message:n})||this}return L(n,t),n}(Y),ce=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.Auth,message:n})||this}return L(n,t),n}(Y),ue=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.Encryption,message:n})||this}return L(n,t),n}(Y),de=function(e){function t(t){return e.call(this,{code:"LrUnsupportedException",message:t})||this}return L(t,e),t}(Y),pe=function(e){function t(t){return e.call(this,{code:"LrExpiredCodeException",message:t})||this}return L(t,e),t}(Y),le=function(e){function t(t){return e.call(this,{code:"LrExpiredException",message:t})||this}return L(t,e),t}(Y),ye=function(e){function t(t){return e.call(this,{code:"LrBadStateException",message:t})||this}return L(t,e),t}(Y),he=new n.InjectionToken("LR.AUTH"),ve=[e.LrApiErrorCode.CONCURRENT_ACCESS],fe=function(e,t){var n=i.setContext((function(e,n){var r=n.headers;return q(void 0,void 0,void 0,(function(){var e;return J(this,(function(n){switch(n.label){case 0:e=null,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.currentSession()];case 2:return e=n.sent().getAccessToken(),[3,4];case 3:return n.sent(),console.log("User not signed in"),[3,4];case 4:return[2,{headers:Object.assign(Object.assign({},r),{authorization:e?"Bearer "+e.jwtToken:""})}]}}))}))})),s=new a.RetryLink({delay:{initial:300,max:1/0,jitter:!0},attempts:{max:3,retryIf:function(e,t){return!!(e instanceof o&&e.errors.some((function(e){var t;return ve.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})))}}}),o=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 L(t,e),t}(Error),c=new r.ApolloLink((function(e,t){return t(e).map((function(e){if(e&&e.errors&&e.errors.filter((function(e){var t;return ve.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})).length>0)throw new o(e.errors);return e}))})),u=r.createHttpLink({uri:e.apolloUrl,credentials:"include"});return Object.assign({link:r.from([s,c,n,u]),cache:new r.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"all"},query:{fetchPolicy:"no-cache",errorPolicy:"all"},mutate:{errorPolicy:"all"}}},e.apolloConfig)};e.NodeType=void 0,(z=e.NodeType||(e.NodeType={})).Key="key",z.PassKey="passKey",e.EdgeType=void 0,(X=e.EdgeType||(e.EdgeType={})).KeyLink="keyLink",X.PassKeyLink="passKeyLink";var me,ge,Se=$,Ie=E.default(me||(me=Q(["\n query {\n serverTime {\n timestamp\n }\n }\n"],["\n query {\n serverTime {\n timestamp\n }\n }\n"]))),Ce=function(){function t(e,t){this.auth=e,this.apollo=t,this.VERIFY_ENABLED=!0,this.MAX_DIFF_MSEC=Se.duration({seconds:30}).asMilliseconds(),this.offsetMs=null,this.verified=!1}return t.prototype.getAccessToken=function(){return q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.auth.currentAuthenticatedUser()];case 1:return[2,e.sent().getSignInUserSession().getAccessToken().getJwtToken()];case 2:return e.sent(),[2,""];case 3:return[2]}}))}))},t.prototype.verifyCognito=function(){return q(this,void 0,void 0,(function(){var t,n,r,i,a;return J(this,(function(s){switch(s.label){case 0:return[4,this.getAccessToken()];case 1:return(t=s.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:t})})]:[2];case 2:if(n=s.sent(),r=Date.now(),i=Se(n.headers.get("Date")).valueOf(),a=r+this.offsetMs,Math.abs(a-i)>this.MAX_DIFF_MSEC)throw new Y({code:e.LrErrorCode.BadTimeSync,message:"Server time does not match independent source. ServerTime: "+a+", Cognito time: "+i});return this.verified=!0,[2]}}))}))},t.prototype.refresh=function(){return q(this,void 0,void 0,(function(){var e,t,n,r,i;return J(this,(function(a){switch(a.label){case 0:return e=Date.now(),[4,this.apollo.query({query:Ie}).toPromise()];case 1:return t=a.sent(),n=Date.now(),V(t.errors),r=parseInt(t.data.serverTime.timestamp,10),i=n-e,this.offsetMs=r-(e+i/2),this.VERIFY_ENABLED?[4,this.verifyCognito()]:[3,3];case 2:a.sent(),a.label=3;case 3:return[2]}}))}))},t.prototype.serverNow=function(){return q(this,void 0,void 0,(function(){var e,t;return J(this,(function(n){switch(n.label){case 0:return e=!1,null===this.offsetMs&&(e=!0),this.VERIFY_ENABLED?(t=!this.verified)?[4,this.getAccessToken()]:[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]}}))}))},t}();Ce.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Ce(w.ɵɵinject(D.AuthClass),w.ɵɵinject(A.Apollo))},token:Ce,providedIn:"root"}),Ce.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ce.ctorParameters=function(){return[{type:p.AuthClass},{type:l.Apollo}]},e.JoseSerialization=void 0,(ge=e.JoseSerialization||(e.JoseSerialization={})).JSON="JSON",ge.COMPACT="COMPACT";var be={payloadType:"json",returnOnlyPayload:!0},ke={payloadType:"json",returnOnlyPayload:!0,serializations:[e.JoseSerialization.JSON]};function we(e){return"oct"===e.kty}function Ke(e){return e.id&&e.jwk?e.jwk:e.keystore&&e.length&&e.kty&&e.kid&&e.alg?e:null}var Pe=function(){function t(e){this.timeService=e}return t.prototype.decrypt=function(t,n,r){return q(this,void 0,void 0,(function(){var i,a;return J(this,(function(s){switch(s.label){case 0:if(i={algorithms:["dir","A*GCM","RSA-OAEP-*"]},r=Object.assign(Object.assign({},ke),r),t.jwk&&(t=t.jwk),"string"==typeof n&&r.serializations.includes(e.JoseSerialization.JSON))try{n=JSON.parse(n)}catch(t){if(!r.serializations.includes(e.JoseSerialization.COMPACT))throw t;console.log("Not a JSON-formatted JWE, it maybe compact serialisation format.")}return[4,d.JWE.createDecrypt(t,i).decrypt(n)];case 1:return(a=s.sent()).payload=this.decodePayload(r.payloadType,a.payload),r.returnOnlyPayload?[2,a.payload]:[2,a]}}))}))},t.prototype.encryptToString=function(e,t){return q(this,void 0,void 0,(function(){var n,r;return J(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()])]}}))}))},t.prototype.encrypt=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a;return J(this,(function(s){switch(s.label){case 0:if(!t)throw new Error("Encrypting empty content.");return t instanceof ArrayBuffer||(t=(new TextEncoder).encode(JSON.stringify(t))),r=(n=d.JWE).createEncrypt,i={contentAlg:"A256GCM"},a={},[4,this.timeService.serverNow()];case 1:return[2,r.apply(n,[(i.fields=(a.timestamp=s.sent(),a),i),e]).update(t).final()]}}))}))},t.prototype.sign=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s;return J(this,(function(o){switch(o.label){case 0:return i=(r=d.JWS).createSign,a={},s={},[4,this.timeService.serverNow()];case 1:return n=i.apply(r,[(a.fields=(s.timestamp=o.sent(),s),a),e]),t instanceof Buffer?n.update(t):n.update(JSON.stringify(t),"utf8"),[2,n.final()]}}))}))},t.prototype.signToString=function(e,t){return q(this,void 0,void 0,(function(){var n,r;return J(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()])]}}))}))},t.prototype.verify=function(t,n,r){return q(this,void 0,void 0,(function(){var i,a,s;return J(this,(function(o){switch(o.label){case 0:i={algorithms:["RS*"]},r=Object.assign(Object.assign({},be),r),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,d.JWS.createVerify(t,i).verify(n)];case 2:return(a=o.sent()).payload=this.decodePayload(r.payloadType,a.payload),r.returnOnlyPayload?[2,a.payload]:[2,a];case 3:throw s=o.sent(),new Y({code:e.LrErrorCode.BadSignature,message:"Bad signature: "+s});case 4:return[2]}}))}))},t.prototype.encryptThenSign=function(e,t){var n=e.key,r=e.sigPrk;return q(this,void 0,void 0,(function(){var e,i,a,s;return J(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)}]}}))}))},t.prototype.decodePayload=function(e,t){switch(e){case"json":return JSON.parse((new TextDecoder).decode(t));case"ArrayBuffer":return t;default:throw new ee("Unknown payloadType: "+e)}},t}();Pe.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Pe(w.ɵɵinject(Ce))},token:Pe,providedIn:"root"}),Pe.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Pe.ctorParameters=function(){return[{type:Ce}]};var Re=function(){function e(){this.crypto=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 q(this,void 0,void 0,(function(){var n,r,i;return J(this,(function(a){switch(a.label){case 0:return n=new TextEncoder,r=n.encode(t),[4,this.crypto.subtle.digest(e,r)];case 1:return i=a.sent(),[2,this.toHex(i)]}}))}))},e}();Re.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Re},token:Re,providedIn:"root"}),Re.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}];var De=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.crypto=this.webCryptoService.crypto}return e.asKey=function(e,t,n){return d.JWK.asKey(e,t,n)},e.prototype.randomString=function(e){if(e<=0)throw new ee("digits <= 0");var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint32Array(e);return this.crypto.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 ee("array.length <= 0");if(t<=0)throw new ee("chooseN <= 0");var n=new Uint32Array(t);this.crypto.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 q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return[4,this.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 1:return t=r.sent(),[4,this.crypto.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 q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return[4,this.crypto.subtle.generateKey({name:"HMAC",hash:{name:"SHA-512"}},!0,["sign","verify"])];case 1:return t=r.sent(),[4,this.crypto.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 q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return[4,this.crypto.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.crypto.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 q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return[4,this.crypto.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.crypto.subtle.exportKey("jwk",t.privateKey)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.deriveKey=function(t){var n=t.password,r=t.salt,i=t.iterations,a=t.kid;return q(this,void 0,void 0,(function(){var t,s,o,c;return J(this,(function(u){switch(u.label){case 0:return t=new TextEncoder,[4,this.crypto.subtle.importKey("raw",t.encode(n),"PBKDF2",!1,["deriveBits","deriveKey"])];case 1:return s=u.sent(),[4,crypto.subtle.deriveKey({name:"PBKDF2",salt:(new TextEncoder).encode(r),iterations:i,hash:"SHA-256"},s,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 2:return o=u.sent(),[4,crypto.subtle.exportKey("jwk",o)];case 3:return c=u.sent(),a&&(c.kid=a),[4,e.asKey(c)];case 4:return[2,{jwk:u.sent()}]}}))}))},e.prototype.derivePassIdp=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){if(e.iterations<this.MIN_PASS_IDP_PBKDF_ITER)throw new te("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 q(this,void 0,void 0,(function(){return J(this,(function(t){if(e.iterations<this.MIN_PASS_KEY_PBKDF_ITER)throw new te("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 q(this,void 0,void 0,(function(){return J(this,(function(t){if(e.iterations<this.MIN_LBOP_KEY_PBKDF_ITER)throw new te("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 q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return[4,this.createKey()];case 1:return[2,e.sent().kid]}}))}))},e.prototype.createPassIdpParams=function(){return q(this,void 0,void 0,(function(){return J(this,(function(e){return[2,{salt:this.createSalt(),iterations:this.DEFAULT_PASS_IDP_PBKDF_ITER}]}))}))},e.prototype.createPassKeyParams=function(){return q(this,void 0,void 0,(function(){var e;return J(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 q(this,void 0,void 0,(function(){var e;return J(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}();De.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new De(w.ɵɵinject(Re))},token:De,providedIn:"root"}),De.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],De.ctorParameters=function(){return[{type:Re}]};var Ae=function(){function e(e,t,r,i){this.keyFactory=e,this.cookieService=t,this.encryptionService=r,this.injector=i,this.KEY_PREFIX="lrSession-",this.cookieSecure=!0,this.serverSessionEncryptionKey=null,n.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(!n.isDevMode())throw new ee("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 q(this,void 0,void 0,(function(){var e,a,s,o,c,u,d;return J(this,(function(p){switch(p.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=p.sent(),a=s,[3,3];case 2:a={data:n},p.label=3;case 3:return i?[4,this.keyFactory.createKey()]:[3,6];case 4:return o=p.sent(),a.expiry=i.toISOString(),c=a,[4,this.encryptionService.encryptToString(o,a.data)];case 5:c.data=p.sent(),u={key:o.toJSON(!0)},d=this.getCookieParams(),this.cookieService.set(e,JSON.stringify(u),i,d.path,d.domain,d.secure,d.sameSite),p.label=6;case 6:return localStorage.setItem(e,JSON.stringify(a)),[2]}}))}))},e.prototype.get=function(e){return q(this,void 0,void 0,(function(){var t,n,r;return J(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 q(this,void 0,void 0,(function(){var t,n,r,i,a,s;return J(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,De.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}();Ae.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Ae(w.ɵɵinject(De),w.ɵɵinject(O.CookieService),w.ɵɵinject(Pe),w.ɵɵinject(w.INJECTOR))},token:Ae,providedIn:"root"}),Ae.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ae.ctorParameters=function(){return[{type:De},{type:v.CookieService},{type:Pe},{type:n.Injector}]};var Ee=function(){},$e=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.populateKeys=function(e){this.keys=e},e.prototype.getCurrentPassKey=function(){return this.keys.passKey},e.prototype.getCurrentMasterKey=function(){return this.keys.masterKey},e.prototype.getCurrentRootKey=function(){return this.keys.rootKey},e.prototype.getCurrentPxk=function(){return this.keys.pxk},e.prototype.getCurrentSigPxk=function(){return this.keys.sigPxk},e.prototype.expiresAfter=function(e){return new Date(Date.now()+1e3*e)},e.prototype.persistMasterKey=function(e,t){return q(this,void 0,void 0,(function(){var n;return J(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 q(this,void 0,void 0,(function(){var t;return J(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 q(this,void 0,void 0,(function(){var t,n;return J(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,De.asKey(t.jwk)];case 2:n.jwk=r.sent(),this.masterKey=t,r.label=3;case 3:return[2,this.masterKey]}}))}))},e}();$e.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new $e(w.ɵɵinject(he),w.ɵɵinject(Ae))},token:$e,providedIn:"root"}),$e.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],$e.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[he]}]},{type:Ae}]};var Oe=function(){function t(e,t){this.encryptionService=e,this.keyService=t,this.purgeKeys()}return t.prototype.purgeKeys=function(){this.graph=new c.Graph},t.prototype.populateKeys=function(e){return q(this,void 0,void 0,(function(){var t,n,r;return J(this,(function(i){switch(i.label){case 0:return n=(t=this.keyService).populateKeys,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]}}))}))},t.prototype.hasKey=function(e){return!!this.graph.node(e)},t.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 Y({message:"Key with id "+e+" is not of type "+t});return n.data},t.prototype.key=function(t){return this.getNode(t,e.NodeType.Key)},t.prototype.passKey=function(t){return this.getNode(t,e.NodeType.PassKey)},t.prototype.addKeys=function(t){var n,r,i,a,s,o;if(t.keys)try{for(var c=_(t.keys),u=c.next();!u.done;u=c.next()){var d=u.value;if(!this.graph.hasNode(d.id)){var p={type:e.NodeType.Key,data:P.default.cloneDeep(d)};this.graph.setNode(d.id,p)}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}if(t.keyLinks)try{for(var l=_(t.keyLinks),y=l.next();!y.done;y=l.next()){var h=y.value;if(!this.graph.hasEdge(h.wrappingKeyId,h.keyId)){var v={type:e.EdgeType.KeyLink,data:P.default.cloneDeep(h)};this.graph.setEdge(h.wrappingKeyId,h.keyId,v)}}}catch(e){i={error:e}}finally{try{y&&!y.done&&(a=l.return)&&a.call(l)}finally{if(i)throw i.error}}if(t.passKeyLinks)try{for(var f=_(t.passKeyLinks),m=f.next();!m.done;m=f.next()){var g=m.value;if(!this.graph.hasEdge(g.passKeyId,g.keyId)){v={type:e.EdgeType.PassKeyLink,data:P.default.cloneDeep(g)};this.graph.setEdge(g.passKeyId,g.keyId,v)}}}catch(e){s={error:e}}finally{try{m&&!m.done&&(o=f.return)&&o.call(f)}finally{if(s)throw s.error}}},t.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},t.prototype.getPath=function(e,t){if(!e||"string"!=typeof e)throw new ue("Param knownKeyId wrong format: "+e);if(!t||"string"!=typeof t)throw new ue("Param keyId wrong format: "+t);var n=K.default.alg.dijkstra(this.graph,e);return this.tracePath(n,t)},t.prototype.getJwkKey=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){switch(n.label){case 0:return[4,this.getKey(e,t)];case 1:return[2,n.sent().jwk]}}))}))},t.prototype.getKey=function(e,t){return q(this,void 0,void 0,(function(){var n,r;return J(this,(function(i){switch(i.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:n=i.sent(),i.label=2;case 2:return(r=this.key(n)).jwk?[2,r]:[2,this.unwrapKey(this.keyService.getCurrentMasterKey().id,n)]}}))}))},t.prototype._unwrapLink=function(e,t,n){return q(this,void 0,void 0,(function(){var r,i,a;return J(this,(function(s){switch(s.label){case 0:return(r=JSON.parse(t.data.wrappedKey)).signatures?[4,this.encryptionService.verify(e,r)]:[3,2];case 1:return i=s.sent(),[3,4];case 2:return[4,this.encryptionService.decrypt(e,r)];case 3:i=s.sent(),s.label=4;case 4:return a=n,[4,De.asKey(i)];case 5:return a.jwk=s.sent(),n.task=null,[2]}}))}))},t.prototype._unwrap=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o,c;return J(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),n=_(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]}}))}))},t.prototype.unwrapWithPassKey=function(e,t,n){return q(this,void 0,void 0,(function(){var r,i;return J(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)]}}))}))},t.prototype.unwrapKey=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i;return J(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)]}}))}))},t.prototype.decryptFromString=function(e,t,n){return q(this,void 0,void 0,(function(){var r;return J(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]}}))}))},t.prototype.decryptFile=function(e,t){return q(this,void 0,void 0,(function(){var n;return J(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:"ArrayBuffer"})];case 2:return[2,r.sent()]}}))}))},t.prototype.encryptToString=function(e,t){return q(this,void 0,void 0,(function(){var n,r;return J(this,(function(i){switch(i.label){case 0:return null==t?[2,null]:(r=Ke(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)]}}))}))},t.prototype.wrapKey=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){if(!we(t))throw new ee("Only allowing wrapping of symmetric keys.");return[2,this.encryptToString(e,t.toJSON(!0))]}))}))},t}();Oe.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Oe(w.ɵɵinject(Pe),w.ɵɵinject($e))},token:Oe,providedIn:"root"}),Oe.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Oe.ctorParameters=function(){return[{type:Pe},{type:$e}]};var je=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 q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query(e).toPromise()];case 1:return V((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e.prototype.mutate=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.apollo.mutate(e).toPromise()];case 1:return V((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e}();je.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new je(w.ɵɵinject(A.Apollo),w.ɵɵinject(Oe))},token:je,providedIn:"root"}),je.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],je.ctorParameters=function(){return[{type:l.Apollo},{type:Oe}]};var Te,Me,Fe,Ne,Le,xe,Ue,qe,Je,_e,Ge,Be,Qe="\n{\n keys {\n id\n }\n keyLinks {\n keyId\n wrappingKeyId\n wrappedKey\n }\n passKeys {\n id\n }\n passKeyLinks {\n keyId\n passKeyId\n wrappedKey\n }\n __typename\n}\n",Ve=E.default(Te||(Te=Q(["\nfragment KeyGraphFragment on KeyGraphType ","\n"],["\nfragment KeyGraphFragment on KeyGraphType ","\n"])),Qe),We="keyGraph "+Qe,He="keyGraph: fetchKeyGraph "+Qe,Ze=E.default(Me||(Me=Q(["\n query File($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n file(id: $id) {\n id\n keyId\n currentVersion {\n id\n operation\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n id\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n }\n }\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n id\n plainMeta\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query File($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n file(id: $id) {\n id\n keyId\n currentVersion {\n id\n operation\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n id\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n }\n }\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n id\n plainMeta\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),Ve),Ye=E.default(Fe||(Fe=Q(["\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"])),Ve),ze=E.default(Ne||(Ne=Q(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),Xe=E.default(Le||(Le=Q(["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"],["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"]))),et=E.default(xe||(xe=Q(["\n mutation RevertFile($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"],["\n mutation RevertFile($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"]))),tt=E.default(Ue||(Ue=Q(["\n mutation MoveFile(\n $fileId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput!\n $toParentDirectoryId: LrRelayIdInput!\n $wrappingKeyId: LrRelayIdInput!\n $wrappedKey: String!\n ) {\n moveFile(\n input: {\n fileId: $fileId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappingKeyId: $wrappingKeyId\n wrappedKey: $wrappedKey\n }\n ) {\n file {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"],["\n mutation MoveFile(\n $fileId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput!\n $toParentDirectoryId: LrRelayIdInput!\n $wrappingKeyId: LrRelayIdInput!\n $wrappedKey: String!\n ) {\n moveFile(\n input: {\n fileId: $fileId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappingKeyId: $wrappingKeyId\n wrappedKey: $wrappedKey\n }\n ) {\n file {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"]))),nt=E.default(qe||(qe=Q(["\n mutation MoveDirectory(\n $directoryId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput\n $toParentDirectoryId: LrRelayIdInput!\n $wrappedKey: String!\n $wrappingKeyId: LrRelayIdInput!\n ) {\n moveDirectory(\n input: {\n directoryId: $directoryId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappedKey: $wrappedKey\n wrappingKeyId: $wrappingKeyId\n }\n ) {\n directory {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"],["\n mutation MoveDirectory(\n $directoryId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput\n $toParentDirectoryId: LrRelayIdInput!\n $wrappedKey: String!\n $wrappingKeyId: LrRelayIdInput!\n ) {\n moveDirectory(\n input: {\n directoryId: $directoryId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappedKey: $wrappedKey\n wrappingKeyId: $wrappingKeyId\n }\n ) {\n directory {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"]))),rt=E.default(Je||(Je=Q(['\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 }\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 }\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"])),Ve),it=E.default(_e||(_e=Q(["\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"]))),at=E.default(Ge||(Ge=Q(["\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"]))),st=function(){},ot=function(){},ct=function(){},ut=function(e){this.name=e.name,this.title=e.title,this.firstName=e.firstName,this.lastName=e.lastName},dt=function(){},pt=function(){},lt=function(){},yt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return L(t,e),t}(lt),ht=function(){};e.PasswordChangeStatus=void 0,(Be=e.PasswordChangeStatus||(e.PasswordChangeStatus={})).InProgress="IN_PROGRESS",Be.Recovery="RECOVERY";var vt,ft=function(){},mt=function(){};e.DirectoryType=void 0,(vt=e.DirectoryType||(e.DirectoryType={})).Vault="vault",vt.Category="category",vt.Record="record";var gt,St,It,Ct,bt,kt,wt,Kt,Pt,Rt,Dt,At,Et,$t=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Vault,default:!0}}]}),Ot=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Category}}]}),jt=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Record}}]}),Tt="\naccessRoles {\n role\n method\n inheritedFrom {\n id\n }\n trustedParty {\n id\n }\n isIssuer\n}",Mt="\ndescendantDirectories(depth: 5, plainMeta: $categoryFilter, archived: false) {\n recordsCount: directoriesCount(plainMeta: $recordFilter, archived: false)\n}\n",Ft="\n id\n keyId\n archived\n plainMeta\n cipherMeta\n "+Tt+"\n "+Mt+"\n",Nt="\n id\n keyId\n plainMeta\n cipherMeta\n",Lt=E.default(gt||(gt=Q(["\n query GetRootDirectoryIdsQuery($archived: Boolean) {\n rootDirectories(archived: $archived) {\n edges {\n node {\n id\n }\n }\n }\n }\n"],["\n query GetRootDirectoryIdsQuery($archived: Boolean) {\n rootDirectories(archived: $archived) {\n edges {\n node {\n id\n }\n }\n }\n }\n"]))),xt=E.default(St||(St=Q(['\nquery GetCategories($vaultFilter: LrJSONFilter!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $archived: Boolean, $cachedKeyIds: [LrRelayIdInput!])\n{\n vaults: rootDirectories(plainMeta: $vaultFilter) {\n edges {\n node {\n childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created", archived: $archived) {\n edges {\n node {\n childDirectory {\n ',"\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetCategories($vaultFilter: LrJSONFilter!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $archived: Boolean, $cachedKeyIds: [LrRelayIdInput!])\n{\n vaults: rootDirectories(plainMeta: $vaultFilter) {\n edges {\n node {\n childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created", archived: $archived) {\n edges {\n node {\n childDirectory {\n ',"\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),Ft,Ve),Ut=E.default(It||(It=Q(['\nquery GetVaults($plainMetaFilter: LrJSONFilter!, $cachedKeyIds: [LrRelayIdInput!])\n{\n list: rootDirectories(plainMeta: $plainMetaFilter, orderBy: "created") {\n edges {\n node {\n ',"\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetVaults($plainMetaFilter: LrJSONFilter!, $cachedKeyIds: [LrRelayIdInput!])\n{\n list: rootDirectories(plainMeta: $plainMetaFilter, orderBy: "created") {\n edges {\n node {\n ',"\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),Nt,Ve),qt=E.default(Ct||(Ct=Q(['\nquery GetTrustedPartyCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n sharedItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetTrustedPartyCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n sharedItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),Ft,Tt,Ve),Jt=E.default(bt||(bt=Q(['\nquery GetMySharedCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n myItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetMySharedCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n myItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),Ft,Tt,Ve),_t=function(e){return void 0===e&&(e=5),e?"\nparentCategories: parentDirectoryLinks(plainMeta: $categoryFilter) {\n edges {\n node {\n parentDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n "+_t(e-1)+"\n "+Tt+"\n }\n }\n }\n}\n":""},Gt=function(e){return void 0===e&&(e=5),E.default(kt||(kt=Q(["\nquery GetCategory(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter,\n $cachedKeyIds: [LrRelayIdInput!]) {\n category: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n ","\n ","\n ",'\n subCategories: childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n ','\n }\n }\n }\n }\n records: childDirectoryLinks(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n"," "],["\nquery GetCategory(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter,\n $cachedKeyIds: [LrRelayIdInput!]) {\n category: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n ","\n ","\n ",'\n subCategories: childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n ','\n }\n }\n }\n }\n records: childDirectoryLinks(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n"," "])),Tt,Mt,_t(e),Ft,Tt,Ve)},Bt=E.default(wt||(wt=Q(["\n query GetCategoryKeyIdQuery(\n $id: LrRelayIdInput!\n $cachedKeyIds: [LrRelayIdInput!]\n ) {\n category: directory(id: $id) {\n keyId\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query GetCategoryKeyIdQuery(\n $id: LrRelayIdInput!\n $cachedKeyIds: [LrRelayIdInput!]\n ) {\n category: directory(id: $id) {\n keyId\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),Ve),Qt=E.default(Kt||(Kt=Q(["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"]))),Vt=E.default(Pt||(Pt=Q(["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n vault: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n vault: directory {\n id\n keyId\n }\n }\n }\n"]))),Wt=E.default(Rt||(Rt=Q(["\n mutation UpdateCategory($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UpdateCategory($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Ht=E.default(Dt||(Dt=Q(["\n mutation DeleteCategory($categoryId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $categoryId }) {\n id\n }\n }\n"],["\n mutation DeleteCategory($categoryId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $categoryId }) {\n id\n }\n }\n"]))),Zt=E.default(At||(At=Q(["\n mutation ArchiveDirectory($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation ArchiveDirectory($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Yt=E.default(Et||(Et=Q(["\n mutation UnarchiveDirectory($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UnarchiveDirectory($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),zt=function(){},Xt=function(){},en=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 q(this,void 0,void 0,(function(){var t;return J(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 q(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,d,p;return J(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?(p=(d=JSON).stringify,[4,this.encryptionService.encrypt(r,n)]):[3,7];case 6:return u=p.apply(d,[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 q(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return J(this,(function(d){switch(d.label){case 0:return[4,this.keyGraph.getJwkKey(e)];case 1:return n=d.sent(),[4,this.keyFactory.createKey()];case 2:return r=d.sent(),i={},s=(a=JSON).stringify,[4,this.encryptionService.encrypt(n,r.toJSON(!0))];case 3:return i.doubleWrappedKey=s.apply(a,[d.sent()]),t?(u=(c=JSON).stringify,[4,this.encryptionService.encrypt(r,t)]):[3,5];case 4:return o=u.apply(c,[d.sent()]),[3,6];case 5:o=null,d.label=6;case 6:return[2,(i.cipherMeta=o,i)]}}))}))},e.prototype.wrapContent=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,d,p,l,y=this;return J(this,(function(h){switch(h.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=h.sent(),t&&t.length?[4,Promise.all(t.map((function(e){return q(y,void 0,void 0,(function(){var t,r,i,a;return J(this,(function(s){switch(s.label){case 0:return[4,this.getCategoryKeyId(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=h.sent(),[3,5];case 3:return a=this.keyService.getCurrentRootKey(),c=(o=JSON).stringify,[4,this.encryptionService.encrypt(a.jwk,n.toJSON(!0))];case 4:s=c.apply(o,[h.sent()]),i={wrappingKeyId:a.id,wrappedKey:s},h.label=5;case 5:return u={key:n,rootKey:i,wrappedKeys:r},e?(l=(p=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,7];case 6:return d=l.apply(p,[h.sent()]),[3,8];case 7:d=null,h.label=8;case 8:return[2,(u.cipherMeta=d,u)]}}))}))},e.prototype.wrapContentWithKey=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o;return J(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.getCategoryKeyId=function(e){return q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Bt,variables:{id:e}})];case 1:return t=r.sent().category,n={keyId:t.keyId},[4,this.keyGraph.getJwkKey(t.keyId)];case 2:return[2,(n.key=r.sent(),n)]}}))}))},e}();en.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new en(w.ɵɵinject(Pe),w.ɵɵinject(Oe),w.ɵɵinject(je),w.ɵɵinject($e),w.ɵɵinject(De))},token:en,providedIn:"root"}),en.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],en.ctorParameters=function(){return[{type:Pe},{type:Oe},{type:je},{type:$e},{type:De}]};var tn,nn,rn,an,sn,on,cn,un,dn,pn,ln,yn,hn,vn,fn,mn,gn="\nid\npublicData\npublicSearchable\ncipherData\nkey {\n id\n}\n",Sn=(E.default(tn||(tn=Q(["\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}"])),gn,We),E.default(nn||(nn=Q(['\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}"])),gn,We),E.default(rn||(rn=Q(['\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}"])),gn,We)),In=(E.default(an||(an=Q(["\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}"])),gn),E.default(sn||(sn=Q(["\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}"])),gn),E.default(on||(on=Q(["\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"])))),Cn=E.default(cn||(cn=Q(["\n mutation CreateStripeCheckoutSession(\n $priceId: String!\n $successUrl: String!\n $cancelUrl: String!\n ) {\n createStripeCheckoutSession(\n input: {\n priceId: $priceId\n successUrl: $successUrl\n cancelUrl: $cancelUrl\n }\n ) {\n sessionId\n }\n }\n"],["\n mutation CreateStripeCheckoutSession(\n $priceId: String!\n $successUrl: String!\n $cancelUrl: String!\n ) {\n createStripeCheckoutSession(\n input: {\n priceId: $priceId\n successUrl: $successUrl\n cancelUrl: $cancelUrl\n }\n ) {\n sessionId\n }\n }\n"]))),bn=E.default(un||(un=Q(["\n mutation CreateStripeBillingPortalSession($returnUrl: String!) {\n createStripeBillingPortalSession(input: { returnUrl: $returnUrl }) {\n sessionUrl\n }\n }\n"],["\n mutation CreateStripeBillingPortalSession($returnUrl: String!) {\n createStripeBillingPortalSession(input: { returnUrl: $returnUrl }) {\n sessionUrl\n }\n }\n"]))),kn="\n name\n data\n state\n",wn=E.default(dn||(dn=Q(["\nmutation CreateUserIssuedPlan($input: CreateUserIssuedPlanInput!){\n createUserIssuedPlan(input: $input) {\n userIssuedPlan {\n id\n plan {\n ","\n }\n token\n tokenExpiryTime\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n }\n}"],["\nmutation CreateUserIssuedPlan($input: CreateUserIssuedPlanInput!){\n createUserIssuedPlan(input: $input) {\n userIssuedPlan {\n id\n plan {\n ","\n }\n token\n tokenExpiryTime\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n }\n}"])),kn),Kn=E.default(pn||(pn=Q(["\n mutation DeleteUserIssuedPlan($input: DeleteUserIssuedPlanInput!) {\n deleteUserIssuedPlan(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteUserIssuedPlan($input: DeleteUserIssuedPlanInput!) {\n deleteUserIssuedPlan(input: $input) {\n id\n }\n }\n"]))),Pn=E.default(ln||(ln=Q(["\nquery UserIssuablePlans {\n userIssuablePlans {\n plan {\n ","\n }\n }\n}\n"],["\nquery UserIssuablePlans {\n userIssuablePlans {\n plan {\n ","\n }\n }\n}\n"])),kn),Rn=E.default(yn||(yn=Q(["\n query UserIssuedPlans {\n userIssuedPlans {\n edges {\n node {\n id\n }\n }\n }\n }\n"],["\n query UserIssuedPlans {\n userIssuedPlans {\n edges {\n node {\n id\n }\n }\n }\n }\n"]))),Dn=E.default(hn||(hn=Q(["\nquery UserIssuedPlan(\n $id: LrRelayIdInput!\n $token: String\n) {\n userIssuedPlan(\n id: $id\n token: $token\n ) {\n id\n plan {\n ","\n }\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n}\n"],["\nquery UserIssuedPlan(\n $id: LrRelayIdInput!\n $token: String\n) {\n userIssuedPlan(\n id: $id\n token: $token\n ) {\n id\n plan {\n ","\n }\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n}\n"])),kn),An=E.default(vn||(vn=Q(["\nmutation AssociateUserIssuedPlan($input: AssociateUserIssuedPlanInput!){\n associateUserIssuedPlan(input: $input) {\n userPlan {\n id\n plan {\n ","\n }\n periodEnd\n }\n }\n}"],["\nmutation AssociateUserIssuedPlan($input: AssociateUserIssuedPlanInput!){\n associateUserIssuedPlan(input: $input) {\n userPlan {\n id\n plan {\n ","\n }\n periodEnd\n }\n }\n}"])),kn),En=E.default(fn||(fn=Q(["\nquery UserPlans {\n userPlans {\n id\n periodEnd\n plan {\n ","\n }\n }\n}\n"],["\nquery UserPlans {\n userPlans {\n id\n periodEnd\n plan {\n ","\n }\n }\n}\n"])),kn),$n=E.default(mn||(mn=Q(["\n query Stripe {\n stripe {\n id\n customer\n }\n }\n"],["\n query Stripe {\n stripe {\n id\n customer\n }\n }\n"])));function On(e){return e.map((function(e){var t;return Object.assign(Object.assign({},e),{periodEnd:e.periodEnd&&new Date(e.periodEnd),subscription:{id:null===(t=e.stripe)||void 0===t?void 0:t.subscriptionId}})}))}var jn=function(){function e(e){this.lrApollo=e}return e.prototype.createStripeCheckoutSession=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Cn,variables:Object.assign({},e)})];case 1:return[2,{id:t.sent().createStripeCheckoutSession.sessionId}]}}))}))},e.prototype.createStripeBillingPortalSession=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:bn,variables:{returnUrl:e}})];case 1:return[2,{url:t.sent().createStripeBillingPortalSession.sessionUrl}]}}))}))},e.prototype.getUserIssuablePlans=function(){return q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:Pn})];case 1:return[2,e.sent().userIssuablePlans]}}))}))},e.prototype.createUserIssuedPlan=function(e){var t=e.planName,n=e.tokenExpiryTime,r=e.planPeriodEnd,i=e.planPeriodEndAfterSeconds;return q(this,void 0,void 0,(function(){var e,a;return J(this,(function(s){switch(s.label){case 0:if(null==r&&null==i)throw new ee('Must specify either "planPeriodEnd" or "planPeriodEndAfterSeconds"');return[4,this.lrApollo.mutate({mutation:wn,variables:{input:{planName:t,tokenExpiryTime:n.toISOString(),planPeriodEnd:r&&r.toISOString(),planPeriodEndAfterSeconds:i}}})];case 1:return e=s.sent().createUserIssuedPlan,a=e.userIssuedPlan,[2,Object.assign(Object.assign({},a),{tokenExpiryTime:new Date(a.tokenExpiryTime),planPeriodEnd:new Date(a.planPeriodEnd)})]}}))}))},e.prototype.deleteUserIssuedPlan=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Kn,variables:{input:{id:e}}})];case 1:return[2,t.sent()]}}))}))},e.prototype.getUserIssuedPlans=function(){return q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:Rn})];case 1:return[2,e.sent().userIssuedPlans.edges.map((function(e){return e.node}))]}}))}))},e.prototype.getUserIssuedPlan=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Dn,variables:{id:e,token:t}})];case 1:return[2,n.sent().userIssuedPlan]}}))}))},e.prototype.associateUserIssuedPlan=function(e){var t=e.id,n=e.token;return q(this,void 0,void 0,(function(){var e,r;return J(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:An,variables:{input:{id:t,token:n}}})];case 1:return e=i.sent().associateUserIssuedPlan,r=e.userPlan,[2,Object.assign(Object.assign({},r),{periodEnd:new Date(r.periodEnd)})]}}))}))},e.prototype.getUserPlans=function(){return q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:En})];case 1:return[2,On(e.sent().userPlans)]}}))}))},e.prototype.getPlanType=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.getStripe()];case 1:return[2,t.sent().customer.subscriptions.data.filter((function(t){return t.id===e}))[0].items.data[0].plan.interval]}}))}))},e.prototype.getStripe=function(){return q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:$n})];case 1:return[2,e.sent().stripe]}}))}))},e}();jn.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new jn(w.ɵɵinject(je))},token:jn,providedIn:"root"}),jn.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],jn.ctorParameters=function(){return[{type:je}]};var Tn=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.getPassIdpParams=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.http.get(this.config.authUrl+"users/pass-idp-params/?login_name="+encodeURIComponent(e)).toPromise()];case 1:return[2,t.sent()]}}))}))},e.prototype.getCurrentUser=function(){return q(this,void 0,void 0,(function(){var e,t,n,r,i;return J(this,(function(a){switch(a.label){case 0:return[4,this.lrApollo.query({query:rt})];case 1:return e=a.sent(),t=e.currentUser,n=e.contactCards,r=e.userPlans,i=n.edges.map((function(e){return e.node}))[0],[2,{currentUser:t,contactCard:i,userPlans:On(r)}]}}))}))},e.prototype.decryptContactCard=function(e){return q(this,void 0,void 0,(function(){var t;return J(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 q(this,void 0,void 0,(function(){return J(this,(function(r){switch(r.label){case 0:return[4,e?this.updateContactCard(e,t,n):this.createContactCard(n)];case 1:return r.sent(),[2]}}))}))},e.prototype.prepareContactCardInput=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d,p;return J(this,(function(l){switch(l.label){case 0:return[4,this.keyService.getCurrentSigPxk()];case 1:return t=l.sent(),i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 2:return n=i.apply(r,[l.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 3:return a=o.apply(s,[l.sent()]),c={name:new ut(e.name.value)},p=(d=JSON).stringify,[4,this.encryptionService.sign(t.jwk,c)];case 4:return u=p.apply(d,[l.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:u}]}}))}))},e.prototype.createContactCard=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i;return J(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:it,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 q(this,void 0,void 0,(function(){var r,i;return J(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:at,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 q(this,void 0,void 0,(function(){var t=this;return J(this,(function(n){return[2,Promise.all(e.map((function(e){return q(t,void 0,void 0,(function(){var t;return J(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 q(this,void 0,void 0,(function(){var e;return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Sn})];case 1:return e=t.sent(),[4,this.decryptContactCardEdges(e.contactCards.edges)];case 2:return[2,t.sent()]}}))}))},e.prototype.deleteContactCard=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:In,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteContactCard.id]}}))}))},e.prototype.signOut=function(){return q(this,void 0,void 0,(function(){return J(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}();Tn.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Tn(w.ɵɵinject(he),w.ɵɵinject(k.HttpClient),w.ɵɵinject(je),w.ɵɵinject($e),w.ɵɵinject(en),w.ɵɵinject(Oe),w.ɵɵinject(Pe))},token:Tn,providedIn:"root"}),Tn.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Tn.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[he]}]},{type:t.HttpClient},{type:je},{type:$e},{type:en},{type:Oe},{type:Pe}]};var Mn=function(e){function t(){var t=e.apply(this,B(arguments))||this;return t.isTpPasswordResetUser=!1,t}return L(t,e),t}(f.CognitoUser);e.FeatureAction=void 0,(e.FeatureAction||(e.FeatureAction={})).ACCESS="access";var Fn,Nn=function(){},Ln=function(){},xn=function(){},Un=function(){};function qn(e,t){var n=e.definitions.filter((function(e){return"OperationDefinition"===e.kind}));if(n.length>1)throw new re("There can be only one '"+t+"' operation, instead there are "+n.length);return n[0]}function Jn(e){return qn(e,"query")}function _n(e){return qn(e,"mutation")}function Gn(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function Bn(e){return{kind:"Name",value:e}}function Qn(e){var t;return(null===(t=e.alias)||void 0===t?void 0:t.value)||e.name.value}function Vn(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return E.default.apply(void 0,B([e],t))}e.RecoveryStatus=void 0,(Fn=e.RecoveryStatus||(e.RecoveryStatus={})).NONE="none",Fn.NEW_PASSWORD="new-password",Fn.OLD_PASSWORD="old-password";var Wn,Hn,Zn,Yn,zn,Xn,er=E.default(Wn||(Wn=Q(["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n passKeys {\n id\n passIdpParams\n wrappedPassIdpVerifierPrk\n }\n }\n }\n"],["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n passKeys {\n id\n passIdpParams\n wrappedPassIdpVerifierPrk\n }\n }\n }\n"]))),tr=E.default(Hn||(Hn=Q(["\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"]))),nr=E.default(Zn||(Zn=Q(["\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"]))),rr=Vn(Yn||(Yn=Q(["\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"])));Vn(zn||(zn=Q(["\nmutation ClearSessionEncryptionKeyMutation {\n clearSessionEncryptionKey(input: {}) {\n sessionEncryptionKey\n }\n}\n"],["\nmutation ClearSessionEncryptionKeyMutation {\n clearSessionEncryptionKey(input: {}) {\n sessionEncryptionKey\n }\n}\n"])));e.Config=void 0,(Xn=e.Config||(e.Config={}))[Xn.TIMEOUT=.01]="TIMEOUT",Xn[Xn.IDLE=1200]="IDLE",Xn[Xn.KEEP_ALIVE_INTERVAL=60]="KEEP_ALIVE_INTERVAL";var ir=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 ye("Call IdleService.init() first.")},t.prototype.init=function(t){return q(this,void 0,void 0,(function(){var n,r=this;return J(this,(function(i){switch(i.label){case 0:if(this.initCalled)throw new ye("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 ee("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(m.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 q(r,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return console.log("Idle timed out"),this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout())];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())]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.keepalivePost=function(){return q(this,void 0,void 0,(function(){var e;return J(this,(function(t){switch(t.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return e=t.sent(),[4,this.http.post(this.config.authUrl+"auth/keepalive/",null,{withCredentials:!0,headers:{Authorization:"Bearer "+e.getSignInUserSession().getAccessToken().getJwtToken()}}).toPromise()];case 2:return[2,{keepaliveResult:t.sent(),expiresAfterSeconds:this.idle.getIdle()+this.idle.getTimeout()+this.keepalive.interval()}]}}))}))},t.prototype.persistMasterKey=function(e){return q(this,void 0,void 0,(function(){var t;return J(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(),console.log("setMasterKey() done"),[2]}}))}))},t.prototype.onPing=function(){return q(this,void 0,void 0,(function(){var e;return J(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 q(this,void 0,void 0,(function(){return J(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}();ir.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new ir(w.ɵɵinject(he),w.ɵɵinject(k.HttpClient),w.ɵɵinject(T.Idle),w.ɵɵinject(M.Keepalive),w.ɵɵinject($e),w.ɵɵinject(D.AuthClass))},token:ir,providedIn:"root"}),ir.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ir.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[he]}]},{type:t.HttpClient},{type:m.Idle},{type:g.Keepalive},{type:$e},{type:p.AuthClass}]};var ar=$,sr=function(){},or=function(){function e(e,t,n,r,i,a,s,o,c,u){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.idleService=u,this.CLIENT_NONCE_LENGTH=32}return e.prototype.checkPassword=function(e){return q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return t=this.passwordStrength(e).years,n={length:e.length,timeToCrack:ar.duration({years:t})},[4,this.getExposureCount(e)];case 1:return[2,(n.passwordExposed=r.sent(),n)]}}))}))},e.prototype.getExposureCount=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i;return J(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 q(this,void 0,void 0,(function(){var t,n,r,i,a,s;return J(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 q(this,void 0,void 0,(function(){var e,t,n,r;return J(this,(function(i){switch(i.label){case 0:return[4,this.getChangePasswordConfig()];case 1:return e=i.sent(),t=ar(e.authTime),n=ar(e.serverTime),r=ar.duration(n.diff(t)),r.asSeconds()>e.maxAuthAgeSeconds?[2,!0]:[2,!1]}}))}))},e.prototype.changePassword=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,d,p;return J(this,(function(l){switch(l.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:if(n=l.sent(),e===t)throw new ee("New password is the same as the current one.");return[4,this.profileService.getCurrentUser()];case 2:return r=l.sent().currentUser,[4,this.verifyPassword(e,r)];case 3:return i=l.sent(),a=i.passIdp,s=i.signedChallenge,[4,this.createPassKeyBundle(t)];case 4:return o=l.sent(),[4,this.keyGraph.getKey(r.currentUserKey.masterKey.id)];case 5:return c=l.sent(),[4,this.encryptionService.encrypt(o.passKey,c.jwk.toJSON(!0))];case 6:return u=l.sent(),[4,this.changePasswordMutation(s,r.currentUserKey.masterKey.id,u,o)];case 7:return d=l.sent(),p=d.token,d.newPassKeyId,[4,this.auth.changePassword(n,this.getPassIdpString(a),this.getPassIdpString(o.passIdp))];case 8:return l.sent(),[4,this.changePasswordComplete(n.getSignInUserSession().getAccessToken().getJwtToken(),!0,p)];case 9:return l.sent(),[2]}}))}))},e.prototype.changePasswordComplete=function(e,t,n){return void 0===n&&(n=null),q(this,void 0,void 0,(function(){return J(this,(function(r){return[2,this.http.post(this.config.authUrl+"users/password-change-complete/",Object.assign({use_new_password:t},n&&{token:n}),{headers:{Authorization:"Bearer "+e}}).toPromise()]}))}))},e.prototype.getVerifierPrK=function(e,t){return q(this,void 0,void 0,(function(){var n;return J(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,De.asKey(n)];case 2:throw r.sent(),new ce("Wrong current password");case 3:return[2]}}))}))},e.prototype.verifyPassword=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s;return J(this,(function(o){switch(o.label){case 0:return[4,this.apollo.mutate({mutation:er,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 q(this,void 0,void 0,(function(){var i;return J(this,(function(a){switch(a.label){case 0:return[4,this.apollo.mutate({mutation:tr,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 q(this,void 0,void 0,(function(){var e,t;return J(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query({query:nr})];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}();or.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new or(w.ɵɵinject(he),w.ɵɵinject(k.HttpClient),w.ɵɵinject(je),w.ɵɵinject(D.AuthClass),w.ɵɵinject(Tn),w.ɵɵinject(De),w.ɵɵinject(Pe),w.ɵɵinject(Oe),w.ɵɵinject(Re),w.ɵɵinject(ir))},token:or,providedIn:"root"}),or.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],or.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[he]}]},{type:t.HttpClient},{type:je},{type:p.AuthClass},{type:Tn},{type:De},{type:Pe},{type:Oe},{type:Re},{type:ir}]};var cr,ur,dr,pr,lr,yr,hr,vr,fr,mr,gr,Sr,Ir,Cr,br=Vn(cr||(cr=Q(["\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}"]))),kr=Vn(ur||(ur=Q(["\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"])),br),wr=Vn(dr||(dr=Q(["\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"])),br),Kr=Vn(pr||(pr=Q(["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"],["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"]))),Pr=Vn(lr||(lr=Q(["\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}"]))),Rr=Vn(yr||(yr=Q(["\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}"]))),Dr=Vn(hr||(hr=Q(["\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}"]))),Ar=Vn(vr||(vr=Q(["\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}"]))),Er=Vn(fr||(fr=Q(["\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}"]))),$r=Vn(mr||(mr=Q(["\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 }\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 }\n}"]))),Or=Vn(gr||(gr=Q(["\nquery TpPasswordResetQuery {\n tpPasswordReset {\n id\n applied\n assembly {\n singleReject\n quorum\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 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 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 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}"]))),jr=Vn(Sr||(Sr=Q(["\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}"]))),Tr=Vn(Ir||(Ir=Q(["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"],["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"]))),Mr=Vn(Cr||(Cr=Q(["\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}"])));function Fr(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 Nr(e,t){var n,r,i={};try{for(var a=_(Object.keys(e).entries()),s=a.next();!s.done;s=a.next()){var o=G(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 Lr(e,t){var n=Fr(Object.entries(e).map((function(n){var r=G(n,2),i=r[0],a=r[1];return t(a,i,e)})));return n.then?n.then((function(t){return Nr(e,t)})):Nr(e,n)}var xr=["constructor","ngOnChanges","ngOnInit","ngDoCheck","ngAfterContentInit","ngAfterContentChecked","ngAfterViewInit","ngAfterViewChecked","ngOnDestroy"];function Ur(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 re("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=B(a,xr),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 qr={hasKeys:!0};function Jr(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s=this;return J(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 q(s,void 0,void 0,(function(){var n,r,i,a;return J(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)]))]}}))}))}function _r(e,t){return Object.assign(Object.assign({},e),{path:B(e.path,[t])})}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 q(t,void 0,void 0,(function(){var t,n,s,o,c;return J(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),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 q(t,void 0,void 0,(function(){var t,n,i,a,s,u;return J(this,(function(d){switch(d.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=d.sent(),[3,3];case 2:u=n.keyId||(null===(t=n.key)||void 0===t?void 0:t.id),d.label=3;case 3:if(!(s=u))throw new re("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=w.ɵɵdefineInjectable({factory:function(){return new e.CommonProcessorsService(w.ɵɵinject(w.NgZone),w.ɵɵinject(Oe))},token:e.CommonProcessorsService,providedIn:"root"}),e.CommonProcessorsService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.CommonProcessorsService.ctorParameters=function(){return[{type:n.NgZone},{type:Oe}]},e.CommonProcessorsService=U([Ur({ngZoneName:"ngZone"})],e.CommonProcessorsService),e.ɵc=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.processTpPasswordResetUserNode=function(e){var t;return q(this,void 0,void 0,(function(){var n,r,i,a,s=this;return J(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 q(this,void 0,void 0,(function(){var n;return J(this,(function(r){return n=Object.assign({},e),e.receiverCipher&&(n.receiverCipherClearJson=this.keyGraph.decryptFromString(t,e.receiverCipher)),e.receiverCipherPartialAssemblyKey&&(n.receiverCipherPartialAssemblyKeyClearJson=this.keyGraph.decryptFromString(t,e.receiverCipherPartialAssemblyKey)),[2,n]}))}))},e.prototype.makeTpPasswordResetNodeProcessor=function(){var e=this;return function(t){var n=t.field;return q(e,void 0,void 0,(function(){var e,t;return J(this,(function(r){switch(r.label){case 0:if(e=Object.assign({},n),!n.assembly)return[3,2];if(null==n.applied)throw new oe('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 q(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,d,p,l=this;return J(this,(function(y){switch(y.label){case 0:return n=e.subjectKey,r=e.assemblyKey,i=e.assemblyCipherData,a=e.subAssemblies,c=(o=Object).assign,u=[Object.assign({},e)],d={},[4,Jr(a,(function(e){return l.processTpSubAssemblyNode(e,n.id,t)}))];case 1:return s=c.apply(o,u.concat([(d.subAssemblies=y.sent(),d)])),t?[3,3]:i?(p=s,[4,this.keyGraph.decryptFromString(r.id,i)]):[3,3];case 2:p.assemblyCipherDataClearJson=y.sent(),y.label=3;case 3:return[2,s]}}))}))},e.prototype.processTpSubAssemblyNode=function(e,t,n){return q(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,d,p=this;return J(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,Jr(i,(function(e){return p.processTpAssemblyApproverNode(e,n)}))];case 1:return a=o.apply(s,c.concat([(u.approvers=l.sent(),u)])),n?[3,3]:r?(d=a,[4,this.keyGraph.decryptFromString(t,r)]):[3,3];case 2:d.subjectCipherDataClearJson=l.sent(),l.label=3;case 3:return[2,a]}}))}))},e.prototype.processTpAssemblyApproverNode=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,e]}))}))},e}(),e.ɵc.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new e.ɵc(w.ɵɵinject(w.NgZone),w.ɵɵinject(Oe))},token:e.ɵc,providedIn:"root"}),e.ɵc.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ɵc.ctorParameters=function(){return[{type:n.NgZone},{type:Oe}]},e.ɵc=U([Ur({ngZoneName:"ngZone"})],e.ɵc),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}})]))}return e.prototype.processQuery=function(e,t){return q(this,void 0,void 0,(function(){var n=this;return J(this,(function(r){return t=Object.assign(Object.assign({},qr),t),[2,Lr(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 q(this,void 0,void 0,(function(){var e,i,a,s=this;return J(this,(function(o){if(null==t?void 0:t.then)throw new re("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?Lr(e,(function(e,t){return s.processField({field:e,context:_r(n,t),options:r})})):e},t=t.then?t.then((function(e){return a(e)})):a(t)):n.processChildren&&Array.isArray(t)&&(t=Fr(t.map((function(e,t){return s.processField({field:e,context:_r(n,t.toString()),options:r})})))),[2,t])}))}))},e.prototype.registerProcessor=function(e,t){if(this.processors[e])throw new re("Processor for field "+e+" already exists.");this.processors[e]=t},e}(),e.QueryProcessorService.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new e.QueryProcessorService(w.ɵɵinject(w.NgZone),w.ɵɵinject($e),w.ɵɵinject(e.CommonProcessorsService),w.ɵɵinject(e.ɵc))},token:e.QueryProcessorService,providedIn:"root"}),e.QueryProcessorService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.QueryProcessorService.ctorParameters=function(){return[{type:n.NgZone},{type:$e},{type:e.CommonProcessorsService},{type:e.ɵc}]},e.QueryProcessorService=U([Ur({ngZoneName:"ngZone"})],e.QueryProcessorService);var Gr,Br,Qr,Vr=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}(),Wr=Jn(E.default(Gr||(Gr=Q(["\n query {\n ...FragmentName\n }\n"],["\n query {\n ...FragmentName\n }\n"])))).selectionSet.selections[0],Hr=function(){function e(){this._executed=!1,this.deferredPromise=new Vr}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 ye("Already executed");this._executed=!0},e}(),Zr=function(e){function t(t){var n=e.call(this)||this;return n.mutation=t.mutation,n.variables=t.variables,n}return L(t,e),t.prototype.select=function(e){var n=R.cloneDeep(this.mutation),r=_n(n),i={};Gn(e).forEach((function(e){i[e.name.value]=e}));return r.selectionSet.selections.forEach((function(e){"Field"===e.kind&&function(e){var t=e,n=Qn(t);i[n]&&(t.selectionSet.selections=[Object.assign(Object.assign({},Wr),{name:Bn(n)})])}(e)})),new t({mutation:Object.assign(Object.assign({},n),{definitions:B(n.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})),e.definitions)}),variables:this.variables})},t}(Hr),Yr={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"lrMergedMutation"},variableDefinitions:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[]}}]},zr=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 L(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 re("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 Zr)n(e);else{if(!(e instanceof t))throw new de("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:Bn(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:Bn(t+e.value.name.value)})})},t.prototype.renameField=function(e,t){var n=this;if("Field"!==e.kind)return e;var r=t+Qn(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:Bn(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":var r=n.renameField(e,t);return n.processSelection(r,t);default:return e}}))},t.prototype.renameFragmentDefinition=function(e,t){var n=Object.assign(Object.assign({},e),{name:Bn(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={},i=[],a=[];this.lrMutations.forEach((function(s,o){var c,u,d=s.lrMutationData,p=d.mutation,l=d.variables,y=_n(p),h="item"+o+"_";y.name&&(h+=y.name.value+"_"),a.push(h),t=B(t,e.renameVariableDefinitions(y.variableDefinitions,h)),n=B(n,e.renameSelections(y.selectionSet.selections,h));try{for(var v=_(Object.keys(l)),f=v.next();!f.done;f=v.next()){var m=f.value;r[h+m]=l[m]}}catch(e){c={error:e}}finally{try{f&&!f.done&&(u=v.return)&&u.call(v)}finally{if(c)throw c.error}}var g=Gn(p);i=B(i,e.renameFragmentDefinitions(g,h))}));var s=R.cloneDeep(Yr),o=_n(s);return o.selectionSet.selections=n,o.variableDefinitions=t,s.definitions=B(s.definitions,i),{mutation:s,variables:r,prefixes:a}},t}(Hr),Xr=Jn(E.default(Br||(Br=Q(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),We)).selectionSet.selections[0],ei=Jn(E.default(Qr||(Qr=Q(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),He)).selectionSet.selections[0];e.ɵb=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 q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return e=R.cloneDeep(e),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=Jn(e.query)).selectionSet.selections=B(t.selectionSet.selections,[Xr])),[4,this.apollo.query(e).toPromise()];case 1:return n=r.sent(),this.stats.queryCount++,V(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 q(this,void 0,void 0,(function(){return J(this,(function(n){if(null==t?void 0:t.variables)throw new de('Unsupported field: "options.variables"');if(e.executed)throw new ye("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 q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return e=Object.assign(Object.assign({},e),{mutation:R.cloneDeep(e.mutation)}),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=_n(e.mutation)).selectionSet.selections=B(t.selectionSet.selections,[ei])),e.mutation=E.default(F.print(e.mutation)),[4,this.apollo.mutate(e).toPromise()];case 1:return n=r.sent(),this.stats.mutationCount++,V(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.statsSnapshot=function(){return R.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 q(this,void 0,void 0,(function(){var n,r,i,a;return J(this,(function(s){switch(s.label){case 0:return e instanceof Array?(i=(r=zr).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.ɵb.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new e.ɵb(w.ɵɵinject(w.NgZone),w.ɵɵinject(A.Apollo),w.ɵɵinject(Oe),w.ɵɵinject(e.QueryProcessorService))},token:e.ɵb,providedIn:"root"}),e.ɵb.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ɵb.ctorParameters=function(){return[{type:n.NgZone},{type:l.Apollo},{type:Oe},{type:e.QueryProcessorService}]},e.ɵb=U([Ur({ngZoneName:"ngZone"})],e.ɵb);var ti=function(){function t(t){this.lrGraphQL=t.get(e.ɵb)}return t.prototype.mutate=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){return[2,this.lrGraphQL.lrMutate(e,t)]}))}))},t.prototype.query=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.lrGraphQL.query(e)]}))}))},t}(),ni=function(e){return function(){return e.initialise()}},ri=function(){function t(e,t,n,r,i,a,s,c,u,d,p){this.config=e,this.auth=t,this.keyFactory=n,this.keyService=r,this.profileService=i,this.keyGraphService=a,this.passwordService=s,this.idleService=c,this.lrGraphQL=u,this.tpPasswordResetProcessorService=d,this.persistService=p,this.hubSubject=new o.ReplaySubject(1)}return t.prototype.initialise=function(){return q(this,void 0,void 0,(function(){var e=this;return J(this,(function(t){return s.Hub.listen("auth",(function(t){return e.hubSubject.next(t.payload)})),[2]}))}))},t.prototype.loginIdpImpl=function(e,t,n,r){return q(this,void 0,void 0,(function(){var i,a;return J(this,(function(s){switch(s.label){case 0:return[4,this.keyFactory.derivePassIdp(Object.assign({password:t},n))];case 1:return i=s.sent(),[4,this.auth.signIn(e,this.passwordService.getPassIdpString(i.jwk))];case 2:return(a=s.sent()).recoveryStatus=r,[2,a]}}))}))},t.prototype.loginIdp=function(t,n){return q(this,void 0,void 0,(function(){var r,i,a,s,o,c;return J(this,(function(u){switch(u.label){case 0:return[4,this.profileService.getPassIdpParams(t)];case 1:if((r=u.sent()).passwordChangeStatus===e.PasswordChangeStatus.InProgress)throw new ae("A password change is in progress");if(r.passwordChangeStatus!==e.PasswordChangeStatus.Recovery)return[3,8];console.log("In recovery mode."),u.label=2;case 2:return u.trys.push([2,4,,5]),[4,this.loginIdpImpl(t,n,r.newPassIdpParams,e.RecoveryStatus.NEW_PASSWORD)];case 3:return a=u.sent(),console.log("New password works!"),[2,a];case 4:if("NotAuthorizedException"!==(i=u.sent()).code)throw i;return[3,5];case 5:return u.trys.push([5,7,,8]),[4,this.loginIdpImpl(t,n,r.currentPassIdpParams,e.RecoveryStatus.OLD_PASSWORD)];case 6:return a=u.sent(),console.log("Old password works!"),[2,a];case 7:throw"NotAuthorizedException"===(s=u.sent()).code?new oe("The password change request was interrupted, please try to login with both your new and old password"):s;case 8:if(!r.tpPasswordReset)return[3,12];u.label=9;case 9:return u.trys.push([9,11,,12]),o=r.tpPasswordReset,[4,this.loginIdpImpl(o.resetUsername,n,o.passIdpParams,e.RecoveryStatus.NONE)];case 10:return(c=u.sent()).isTpPasswordResetUser=!0,[2,c];case 11:return u.sent(),[3,12];case 12:return[4,this.loginIdpImpl(t,n,r.currentPassIdpParams,e.RecoveryStatus.NONE)];case 13:return[2,u.sent()]}}))}))},t.prototype.handleSessionEncryptionKey=function(){return q(this,void 0,void 0,(function(){var e,t;return J(this,(function(r){switch(r.label){case 0:if(!this.config.disableSessionEncryptionKey)return[3,1];if(!n.isDevMode())throw e="You should not set disableSessionEncryptionKey=True in mode prod. It defaults to false.",console.error(e),new Error(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.keyFactory.createKey()];case 2:return t=r.sent(),[4,this.lrGraphQL.lrMutate(new Zr({mutation:rr,variables:{input:{sessionEncryptionKey:JSON.stringify(t.toJSON(!0))}}}),{includeKeyGraph:!1})];case 3:r.sent(),this.persistService.setServerSessionEncryptionKey(t),r.label=4;case 4:return[2]}}))}))},t.prototype.handlePostAuth=function(e){return q(this,void 0,void 0,(function(){return J(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]}}))}))},t.prototype.login=function(e,t){return q(this,void 0,void 0,(function(){var n,r;return J(this,(function(i){switch(i.label){case 0:return[4,this.loginIdp(e,t)];case 1:return n=i.sent(),["SMS_MFA","SOFTWARE_TOKEN_MFA"].includes(n.challengeName)?[2,{hasChallenge:!0,challenge:n}]:[4,this.handlePostAuth(n)];case 2:return i.sent(),n.isTpPasswordResetUser?[4,this.loadResetUser(t)]:[3,4];case 3:return[2,{hasChallenge:!1,resetUser:i.sent()}];case 4:return[4,this.loadUser(n,t)];case 5:return r=i.sent(),[4,this.idleService.start()];case 6:return i.sent(),[2,{hasChallenge:!1,user:r}]}}))}))},t.prototype.verifyLogin=function(e,t,n,r){return q(this,void 0,void 0,(function(){var i,a;return J(this,(function(s){switch(s.label){case 0:return[4,this.auth.confirmSignIn(e,r,e.challengeName)];case 1:return s.sent(),[4,this.auth.currentAuthenticatedUser()];case 2:return i=s.sent(),[4,this.handlePostAuth(e)];case 3:return s.sent(),[4,this.loadUser(i,t)];case 4:return a=s.sent(),n&&i.setDeviceStatusRemembered({onSuccess:function(){},onFailure:function(e){return console.error(e)}}),[2,a]}}))}))},t.prototype.handlePasswordRecovery=function(t){return q(this,void 0,void 0,(function(){var n;return J(this,(function(r){switch(r.label){case 0:return t.recoveryStatus===e.RecoveryStatus.NONE?[3,2]:(n=t.getSignInUserSession().getAccessToken().getJwtToken(),[4,this.passwordService.changePasswordComplete(n,t.recoveryStatus===e.RecoveryStatus.NEW_PASSWORD)]);case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},t.prototype.getUser=function(e){return void 0===e&&(e=!1),q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return!e&&this.currentUser?[2,this.currentUser]:(t=this,n=this.loadUser,[4,this.auth.currentAuthenticatedUser()]);case 1:return[4,n.apply(this,[r.sent()])];case 2:return t.currentUser=r.sent(),console.log("Starting idle service."),[4,this.idleService.start()];case 3:return r.sent(),[2,this.currentUser]}}))}))},t.prototype.mapTPVaultAccess=function(e){var t=null==e?void 0:e.tpVault;return(null==t?void 0:t.length)>0&&t.some((function(e){return"ACCESS"===e.toUpperCase()}))},t.prototype.loadUser=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,l,y,h,v,f;return J(this,(function(m){switch(m.label){case 0:return[4,this.profileService.getCurrentUser()];case 1:return n=m.sent(),r=n.currentUser,i=n.contactCard,a=n.userPlans,r.sessionEncryptionKey?(o=(s=this.persistService).setServerSessionEncryptionKey,[4,d.JWK.asKey(r.sessionEncryptionKey)]):[3,3];case 2:o.apply(s,[m.sent()]),m.label=3;case 3:return[4,this.auth.userAttributes(e)];case 4:return c=m.sent(),t?[4,this.keyFactory.derivePassKey(Object.assign({password:t},r.currentUserKey.passKey.passKeyParams))]:[3,8];case 5:return u=m.sent().jwk,l=(p=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(r.currentUserKey.passKey.id,u,r.currentUserKey.masterKey.id)];case 6:return[4,l.apply(p,[m.sent()])];case 7:m.sent(),m.label=8;case 8:return[4,this.keyGraphService.populateKeys(r.currentUserKey)];case 9:return m.sent(),y={id:r.id,sub:this.getUserAttribute("sub",c),username:r.username,currentUserKey:r.currentUserKey,getAccessJwtToken:function(){return e.getSignInUserSession().getAccessToken().getJwtToken()},email:this.getUserAttribute("email",c),emailVerified:"true"===this.getUserAttribute("email_verified",c),phone:this.getUserAttribute("phone_number",c),phoneVerified:"true"===this.getUserAttribute("phone_number_verified",c)},v=(h=Object).assign,f=[{}],[4,this.profileService.decryptContactCard(i)];case 10:return[2,(y.contactCard=v.apply(h,f.concat([m.sent()])),y.userDelete=r.userDelete,y.userPlans=a,y.hasTPVaultAccess=this.mapTPVaultAccess(r.features),y.features=r.features,y.sessionEncryptionKey=r.sessionEncryptionKey,y)]}}))}))},t.prototype.watchAuth=function(){return this.hubSubject},t.prototype.logout=function(){return q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return this.currentUser=null,this.keyService.purgeKeys(),this.keyGraphService.purgeKeys(),[4,Promise.all([this.auth.signOut(),this.profileService.signOut()])];case 1:return e.sent(),[2]}}))}))},t.prototype.getUserAttribute=function(e,t){var n=t.find((function(t){return t.getName()===e}));return n?n.getValue():null},t.prototype.loadResetUser=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,l,y,h,v,f;return J(this,(function(m){switch(m.label){case 0:return[4,this.lrGraphQL.query({query:$r})];case 1:return(t=m.sent().tpPasswordResetUser).sessionEncryptionKey?(r=(n=this.persistService).setServerSessionEncryptionKey,[4,d.JWK.asKey(t.sessionEncryptionKey)]):[3,3];case 2:r.apply(n,[m.sent()]),m.label=3;case 3:return e?[4,this.keyFactory.derivePassKey(Object.assign({password:e},t.passKey.passKeyParams))]:[3,7];case 4:return i=m.sent().jwk,s=(a=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(t.passKey.id,i,t.masterKey.id)];case 5:return[4,s.apply(a,[m.sent()])];case 6:m.sent(),m.label=7;case 7:return this.keyService.populateKeys({passKey:{id:t.passKey.id},masterKey:{id:t.masterKey.id}}),u=(c=this.auth).userAttributes,[4,this.auth.currentAuthenticatedUser()];case 8:return[4,u.apply(c,[m.sent()])];case 9:return o=m.sent(),p=this.getUserAttribute("sub",o),y=(l=Object).assign,v=(h=Object).assign,f=[{}],[4,this.tpPasswordResetProcessorService.processTpPasswordResetUserNode(t)];case 10:return[2,y.apply(l,[v.apply(h,f.concat([m.sent()])),{sub:p}])]}}))}))},t.prototype.refreshAccessToken=function(){return q(this,void 0,void 0,(function(){var e,t;return J(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return e=n.sent(),t=e.getSignInUserSession().getRefreshToken(),[2,new Promise((function(n,r){e.refreshSession(t,(function(e,t){e?(console.error("Error refreshing token: ",e),r(e)):(console.log("Token refresh complete: ",t),n(0))}))}))]}}))}))},t}();ri.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new ri(w.ɵɵinject(he),w.ɵɵinject(D.AuthClass),w.ɵɵinject(De),w.ɵɵinject($e),w.ɵɵinject(Tn),w.ɵɵinject(Oe),w.ɵɵinject(or),w.ɵɵinject(ir),w.ɵɵinject(e.ɵb),w.ɵɵinject(e.ɵc),w.ɵɵinject(Ae))},token:ri,providedIn:"root"}),ri.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ri.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[he]}]},{type:p.AuthClass},{type:De},{type:$e},{type:Tn},{type:Oe},{type:or},{type:ir},{type:e.ɵb},{type:e.ɵc},{type:Ae}]};var ii=function(){function e(e,t,n){this.config=e,this.http=t,this.lrAuth=n}return e.prototype.downloadEncryptedFile=function(e){return q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return n=(t=JSON).parse,[4,this.downloadEncryptedFile2(e)];case 1:return[2,n.apply(t,[r.sent()])]}}))}))},e.prototype.downloadEncryptedFile2=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o;return J(this,(function(c){switch(c.label){case 0:return t=this.config.apiUrl+"files/download/?file_state_node_id="+e,r=(n=this.http).get,i=[t],a={responseType:"text"},s={},o="Bearer ",[4,this.lrAuth.getUser()];case 1:return[4,r.apply(n,i.concat([(a.headers=(s.Authorization=o+c.sent().getAccessJwtToken(),s),a)])).toPromise()];case 2:return[2,c.sent()]}}))}))},e.prototype.loadFile=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.readAsArrayBuffer(e)}))]}))}))},e.prototype.uploadEncryptedFile=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return J(this,(function(d){switch(d.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],o={},c={},u="Bearer ",[4,this.lrAuth.getUser()];case 1:return[4,a.apply(i,s.concat([(o.headers=(c.Authorization=u+d.sent().getAccessJwtToken(),c),o)])).toPromise()];case 2:return[2,d.sent().content_resource]}}))}))},e}();ii.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new ii(w.ɵɵinject(he),w.ɵɵinject(k.HttpClient),w.ɵɵinject(ri))},token:ii,providedIn:"root"}),ii.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ii.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[he]}]},{type:t.HttpClient},{type:ri}]};var ai,si,oi,ci,ui=E.default(ai||(ai=Q(["\n query UserQuery($email: LrEmail, $username: String) {\n user(email: $email, username: $username) {\n id\n username\n haveTp\n isCurrentUser\n contactCards {\n edges {\n node {\n publicData\n publicSearchable\n }\n }\n }\n currentUserKey {\n sigPxk {\n id\n pbk\n }\n pxk {\n id\n pbk\n }\n }\n }\n }\n"],["\n query UserQuery($email: LrEmail, $username: String) {\n user(email: $email, username: $username) {\n id\n username\n haveTp\n isCurrentUser\n contactCards {\n edges {\n node {\n publicData\n publicSearchable\n }\n }\n }\n currentUserKey {\n sigPxk {\n id\n pbk\n }\n pxk {\n id\n pbk\n }\n }\n }\n }\n"]))),di=E.default(si||(si=Q(["\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"]))),pi=E.default(oi||(oi=Q(["\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"]))),li=E.default(ci||(ci=Q(["\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"]))),yi=function(){function e(e){this.lrApollo=e}return e.prototype.getUserByEmail=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.getUser({email:e})]}))}))},e.prototype.getUserByUsername=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.getUser({username:e})]}))}))},e.prototype.getUser=function(e){var t=e.email,n=e.username;return q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:ui,variables:{email:t,username:n}})];case 1:return[2,e.sent().user]}}))}))},e.prototype.requestUserDelete=function(){return q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:di,variables:{input:{}}})];case 1:return[2,e.sent().requestUserDelete.userDelete]}}))}))},e.prototype.cancelUserDelete=function(){return q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:pi,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),q(this,void 0,void 0,(function(){return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:li,variables:{first:e,after:t}})];case 1:return[2,n.sent().loginHistory]}}))}))},e}();yi.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new yi(w.ɵɵinject(je))},token:yi,providedIn:"root"}),yi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],yi.ctorParameters=function(){return[{type:je}]};var hi,vi,fi,mi,gi,Si,Ii,Ci,bi="\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\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}",ki="\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",wi=E.default(hi||(hi=Q(["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n",""],["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n",""])),ki,Ve),Ki=E.default(vi||(vi=Q(["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ","\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n","\n"],["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ","\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n","\n"])),bi,Ve),Pi=E.default(fi||(fi=Q(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ","\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ","\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"])),bi,Ve),Ri=E.default(mi||(mi=Q(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ","\n }\n}"],["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ","\n }\n}"])),bi),Di=E.default(gi||(gi=Q(["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n}\n","\n}"],["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n}\n","\n}"])),bi,He),Ai=E.default(Si||(Si=Q(["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"],["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"])),bi,ki),Ei=E.default(Ii||(Ii=Q(["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"],["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"])),bi,ki);e.OtkState=void 0,(Ci=e.OtkState||(e.OtkState={})).OTK_INITIATED="OTK_INITIATED",Ci.OTK_ACCEPTED="OTK_ACCEPTED",Ci.OTK_COMPLETED="OTK_COMPLETED",e.KeyExchangeState=void 0,function(e){e.IN_PROGRESS="IN_PROGRESS",e.COMPLETED="COMPLETED",e.DECLINED="DECLINED",e.CANCELLED="CANCELLED"}(e.KeyExchangeState||(e.KeyExchangeState={})),e.KeyExchangeMode=void 0,function(e){e.OTK="OTK"}(e.KeyExchangeMode||(e.KeyExchangeMode={}));var $i=function(){function t(e,t,n,r,i,a){this.keyFactory=e,this.keyService=t,this.lrApollo=n,this.encryptionService=r,this.authService=i,this.userService=a,this.CLIENT_NONCE_LENGTH=32}return t.prototype.getKeyExchangeList=function(e){return void 0===e&&(e={}),q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Ki,variables:Object.assign({},e)})];case 1:return[2,t.sent().keyExchanges]}}))}))},t.prototype.getKeyExchange=function(e,t){var n=void 0===t?{}:t,r=n.otKeyK,i=n.token;return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:i?Ri:Pi,variables:{id:e,token:i}})];case 1:return t=n.sent().keyExchange,[4,this.decryptKeyExchange(t,r)];case 2:return[2,n.sent()]}}))}))},t.prototype.decryptResponseCipher=function(e,t,n){return q(this,void 0,void 0,(function(){var r;return J(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.decryptKeyExchange=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,d;return J(this,(function(p){switch(p.label){case 0:return e.isInitiator?[4,this.keyService.getCurrentRootKey()]:[3,8];case 1:return n=p.sent(),[4,this.encryptionService.decrypt(n.jwk,e.initiatorRootKeyCipher)];case 2:return r=p.sent(),e.otk.initiatorOneTimePbkCipher?(s=this.decryptResponseCipher,[4,De.asKey(r.otKey)]):[3,6];case 3:return o=[p.sent()],[4,De.asKey(r.oneTimePrk)];case 4:return[4,s.apply(this,o.concat([p.sent(),e.otk.initiatorOneTimePbkCipher]))];case 5:return a=p.sent(),[3,7];case 6:a=null,p.label=7;case 7:return c=(i=a)&&i.responder,d=r&&r.initiator,[2,Object.assign(Object.assign({},e),{message:c?c.message:null,contactCard:c&&c.contactCard?c.contactCard.plainSharedCipherDataJson:null,myContactCard:d&&d.contactCard?d.contactCard.plainSharedCipherDataJson:null,myMessage:d&&d.message})];case 8:return[4,this.decryptOtk(e,t)];case 9:return u=p.sent(),d=u&&u.plainOtKeyCipher.initiator,[2,Object.assign(Object.assign({},e),{decryptedOtk:u,message:d&&d.message,contactCard:d&&d.contactCard&&d.contactCard.plainSharedCipherDataJson})]}}))}))},t.prototype.decryptOtk=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i;return J(this,(function(a){switch(a.label){case 0:return[4,this.getOtKey(e,t)];case 1:return(n=a.sent())&&e.otk.otKeyCipher?(i={},[4,this.encryptionService.decrypt(n,e.otk.otKeyCipher)]):[3,3];case 2:return i.plainOtKeyCipher=a.sent(),i.otKey=n,r=i,[3,4];case 3:r=null,a.label=4;case 4:return[2,r]}}))}))},t.prototype.getOtKey=function(t,n){return q(this,void 0,void 0,(function(){var r,i;return J(this,(function(a){switch(a.label){case 0:return n?[4,De.asKey(Object.assign(Object.assign({},JSON.parse(t.otk.otKeyParams)),{k:n}))]:[3,2];case 1:return[2,a.sent()];case 2:return t.otk.state!==e.OtkState.OTK_INITIATED||t.isInitiator||!t.otk.responderPbkCipher?[3,6]:[4,this.keyService.getCurrentPxk()];case 3:return r=a.sent(),[4,this.encryptionService.decrypt(r.jwk,JSON.parse(t.otk.responderPbkCipher),{serializations:[e.JoseSerialization.COMPACT]})];case 4:return(i=a.sent()).otKey?[4,De.asKey(i.otKey)]:[3,6];case 5:return[2,a.sent()];case 6:return[2,null]}}))}))},t.prototype.initiateOtk=function(e){var t=e.message,n=e.email,r=e.contactCard,i=e.upgrade;return q(this,void 0,void 0,(function(){var e,a,s,o,c,u,d,p,l,y,h,v,f,m,g,S;return J(this,(function(I){switch(I.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=I.sent(),a=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.authService.getUser()];case 2:return s=I.sent(),[4,this.keyFactory.createPkcKey()];case 3:return o=I.sent(),[4,this.keyService.getCurrentPxk()];case 4:return c=I.sent(),[4,this.keyService.getCurrentSigPxk()];case 5:return u=I.sent(),d=null,r&&r.ownerPlainData?(l=(p=JSON).stringify,[4,this.encryptionService.sign(u.jwk,r.ownerPlainData)]):[3,7];case 6:d=l.apply(p,[I.sent()]),I.label=7;case 7:return y={message:t,contactCard:r?{plainSharedCipherDataJson:r.plainSharedCipherDataJson}:null},h={nonce:a,initiator:Object.assign(Object.assign({},y),{oneTimePbk:o.toJSON(),pbk:c.jwk.toJSON(),sigPbk:u.jwk.toJSON(),profile:{username:s.username}})},[4,this.encryptionService.encrypt(e,h)];case 8:return v=I.sent(),f={nonce:a,oneTimePrk:o.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:r,initiator:y},[4,this.keyService.getCurrentRootKey()];case 9:return m=I.sent(),[4,this.encryptionService.encrypt(m.jwk,f)];case 10:return g=I.sent(),S=e.toJSON(!0).k,[4,this.lrApollo.mutate({mutation:Di,variables:{input:{initiatorRootKeyCipher:JSON.stringify(g),initiatorPxkId:c.id,initiatorSigPxkId:u.id,otKeyParams:JSON.stringify(e.toJSON()),otKeyCipher:JSON.stringify(v),sendEmail:n?{email:n,rawOtKey:S}:null,createTp:!0,initiatorPlainDataSig:d,upgrade:i}}})];case 11:return[2,{keyExchange:I.sent().initiateKeyExchangeOtk.keyExchange,otKeyK:S}]}}))}))},t.prototype.respondOtk=function(e){var t=e.id,n=e.token,r=e.decryptedOtk,i=e.message,a=e.initiatorContactCard,s=e.responderContactCard;return q(this,void 0,void 0,(function(){var e,o,c,u,d,p,l,y,h,v,f,m,g,S,I,C,b,k,w,K,P,R,D,A,E,$,O,j,T,M,F,N,L,x,U,q,_,G,B,Q,V,W,H,Z,Y,z,X,ee,te,ne,re;return J(this,(function(J){switch(J.label){case 0:return[4,this.authService.getUser()];case 1:return e=J.sent(),[4,this.keyService.getCurrentRootKey()];case 2:return o=J.sent(),c=this.keyService.getCurrentMasterKey().id,[4,this.keyService.getCurrentMasterKey()];case 3:return u=J.sent(),[4,this.keyFactory.createKey()];case 4:return d=J.sent(),[4,this.keyFactory.createKey()];case 5:return p=J.sent(),[4,this.encryptionService.encrypt(o.jwk,d.toJSON(!0))];case 6:return l=J.sent(),[4,this.encryptionService.encrypt(u.jwk,p.toJSON(!0))];case 7:return y=J.sent(),[4,De.asKey(r.plainOtKeyCipher.initiator.oneTimePbk)];case 8:return h=J.sent(),[4,De.asKey(r.plainOtKeyCipher.initiator.pbk)];case 9:return v=J.sent(),[4,De.asKey(r.plainOtKeyCipher.initiator.sigPbk)];case 10:return f=J.sent(),[4,this.keyService.getCurrentPxk()];case 11:return m=J.sent(),[4,this.keyService.getCurrentSigPxk()];case 12:return g=J.sent(),[4,this.encryptionService.sign(g.jwk,v.toJSON())];case 13:return S=J.sent(),[4,this.encryptionService.sign(g.jwk,f.toJSON())];case 14:return I=J.sent(),C={nonce:r.plainOtKeyCipher.nonce,sharedKey:d.toJSON(!0),mkSharedKey:p.toJSON(!0),responder:{pbk:m.jwk.toJSON(),sigPbk:g.jwk.toJSON(),profile:{username:e.username},message:i}},r.plainOtKeyCipher.initiator.contactCard?(k=r.plainOtKeyCipher.initiator.contactCard.plainSharedCipherDataJson,[4,this.keyFactory.createKey()]):[3,25];case 15:return w=J.sent(),[4,this.keyFactory.createKey()];case 16:return L=J.sent(),[4,this.keyService.getCurrentSigPxk()];case 17:return x=J.sent(),K={},R=(P=JSON).stringify,[4,this.encryptionService.encrypt(o.jwk,w.toJSON(!0))];case 18:return K.receiverWrappedKey=R.apply(P,[J.sent()]),K.receiverWrappingKeyId=o.id,a?(E=(A=JSON).stringify,[4,this.encryptionService.encrypt(w,a.plainReceiverCipherDataJson)]):[3,20];case 19:return D=E.apply(A,[J.sent()]),[3,21];case 20:D="",J.label=21;case 21:return K.receiverCipherData=D,O=($=JSON).stringify,[4,this.encryptionService.encrypt(d,L.toJSON(!0))];case 22:return K.sharedWrappedKey=O.apply($,[J.sent()]),b=K,[4,this.encryptionService.encrypt(L,k)];case 23:return H=J.sent(),j=b,M=(T=JSON).stringify,[4,this.encryptionService.sign(x.jwk,H)];case 24:j.sharedCipherDataSig=M.apply(T,[J.sent()]),b.sigPxkId=x.id,C.responder.contactCard=Object.assign(Object.assign({},C.responder.contactCard),{sharedCipherKey:L.toJSON(!0)}),J.label=25;case 25:return s?[4,this.keyFactory.createKey()]:[3,38];case 26:return N=J.sent(),[4,this.keyFactory.createKey()];case 27:return L=J.sent(),[4,this.keyService.getCurrentSigPxk()];case 28:return x=J.sent(),U={},_=(q=JSON).stringify,[4,this.encryptionService.encrypt(o.jwk,N.toJSON(!0))];case 29:return U.ownerWrappedKey=_.apply(q,[J.sent()]),U.ownerWrappingKeyId=o.id,s.plainOwnerCipherDataJson?(Q=(B=JSON).stringify,[4,this.encryptionService.encrypt(N,s.plainOwnerCipherDataJson)]):[3,31];case 30:return G=Q.apply(B,[J.sent()]),[3,32];case 31:G="",J.label=32;case 32:return U.ownerCipherData=G,W=(V=JSON).stringify,[4,this.encryptionService.encrypt(d,L.toJSON(!0))];case 33:return U.sharedWrappedKey=W.apply(V,[J.sent()]),F=U,[4,this.encryptionService.encrypt(L,s.plainSharedCipherDataJson)];case 34:return H=J.sent(),Z=F,z=(Y=JSON).stringify,[4,this.encryptionService.sign(x.jwk,H)];case 35:return Z.sharedCipherDataSig=z.apply(Y,[J.sent()]),F.sigPxkId=x.id,s.ownerPlainData?(X=F,te=(ee=JSON).stringify,[4,this.encryptionService.sign(g.jwk,s.ownerPlainData)]):[3,37];case 36:X.ownerPlainDataSig=te.apply(ee,[J.sent()]),J.label=37;case 37:C.responder.contactCard=Object.assign(Object.assign({},C.responder.contactCard),{plainSharedCipherDataJson:s.plainSharedCipherDataJson}),J.label=38;case 38:return[4,this.encryptionService.encrypt(h,C)];case 39:return ne=J.sent(),[4,this.encryptionService.encrypt(r.otKey,ne)];case 40:return ne=J.sent(),[4,this.lrApollo.mutate({mutation:Ai,variables:{input:{keyExchangeId:t,keyExchangeToken:n,rootKeyId:o.id,masterKeyId:c,responderPxkId:m.id,responderSigPxkId:g.id,signedInitiatorPbk:JSON.stringify(S),signedInitiatorSigPbk:JSON.stringify(I),rkWrappedSharedKey:JSON.stringify(l),mkWrappedMkSharedKey:JSON.stringify(y),initiatorOneTimePbkCipher:JSON.stringify(ne),initiatorContactCard:b,responderContactCard:F}}})];case 41:return[2,{keyExchange:(re=J.sent().respondKeyExchangeOtk).keyExchange,userSharedKey:re.userSharedKey,tp:re.tp}]}}))}))},t.prototype.completeOtk=function(e,t,n,r){return q(this,void 0,void 0,(function(){var i,a,s,o,c,u,d,p,l,y,h,v,f,m,g,S,I,C,b,k,w,K,P,R,D,A,E,$,O,j,T,M,F,N,L,x,U,q;return J(this,(function(J){switch(J.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return i=J.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return a=J.sent(),[4,this.encryptionService.decrypt(i.jwk,t)];case 3:return s=J.sent(),c=this.decryptResponseCipher,[4,De.asKey(s.otKey)];case 4:return u=[J.sent()],[4,De.asKey(s.oneTimePrk)];case 5:return[4,c.apply(this,u.concat([J.sent(),n]))];case 6:if(o=J.sent(),s.nonce!==o.nonce)throw new ie("The nonce returned by responder does not match with the one created by the initiator.");return[4,this.keyService.getCurrentSigPxk()];case 7:return d=J.sent(),[4,De.asKey(o.responder.sigPbk)];case 8:return p=J.sent(),[4,De.asKey(o.responder.pbk)];case 9:return l=J.sent(),[4,this.encryptionService.sign(d.jwk,l.toJSON())];case 10:return y=J.sent(),[4,this.encryptionService.sign(d.jwk,p.toJSON())];case 11:return h=J.sent(),[4,De.asKey(o.sharedKey)];case 12:return v=J.sent(),[4,this.encryptionService.encrypt(i.jwk,v.toJSON(!0))];case 13:return f=J.sent(),[4,De.asKey(o.mkSharedKey)];case 14:return m=J.sent(),[4,this.encryptionService.encrypt(a.jwk,m.toJSON(!0))];case 15:return g=J.sent(),r?[4,this.keyFactory.createKey()]:[3,19];case 16:return I=J.sent(),C={},k=(b=JSON).stringify,[4,this.encryptionService.encrypt(i.jwk,I.toJSON(!0))];case 17:return C.receiverWrappedKey=k.apply(b,[J.sent()]),C.receiverWrappingKeyId=i.id,K=(w=JSON).stringify,[4,this.encryptionService.encrypt(I,r)];case 18:C.receiverCipherData=K.apply(w,[J.sent()]),S=C,J.label=19;case 19:return s.initiatorContactCard?(D=s.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,28];case 20:return A=J.sent(),[4,De.asKey(o.responder.contactCard.sharedCipherKey)];case 21:return E=J.sent(),j=(O=JSON).stringify,[4,this.encryptionService.encrypt(i.jwk,A.toJSON(!0))];case 22:return $=j.apply(O,[J.sent()]),D.plainOwnerCipherDataJson?(N=(F=JSON).stringify,[4,this.encryptionService.encrypt(A,D.plainOwnerCipherDataJson)]):[3,24];case 23:return M=N.apply(F,[J.sent()]),[3,25];case 24:M="",J.label=25;case 25:return T=M,P={ownerWrappedKey:$,ownerWrappingKeyId:i.id,ownerCipherData:T},R={sigPxkId:d.id},[4,this.encryptionService.encrypt(E,D.plainSharedCipherDataJson)];case 26:return L=J.sent(),x=R,q=(U=JSON).stringify,[4,this.encryptionService.sign(d.jwk,L)];case 27:x.sharedCipherDataSig=q.apply(U,[J.sent()]),J.label=28;case 28:return[4,this.lrApollo.mutate({mutation:Ei,variables:{input:{keyExchangeId:e,rootKeyId:i.id,masterKeyId:a.id,initiatorSigPxkId:d.id,signedResponderPbk:JSON.stringify(y),signedResponderSigPbk:JSON.stringify(h),rkWrappedSharedKey:JSON.stringify(f),mkWrappedMkSharedKey:JSON.stringify(g),responderContactCardCipher:S,initiatorContactCardCipher:P,initiatorContactCardSharedCipher:R}}})];case 29:return[2,J.sent().completeKeyExchangeOtk]}}))}))},t.prototype.currentUserSharedKey=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:wi,variables:{username:e.username,userId:e.userId}})];case 1:return[2,t.sent().currentUserSharedKey.userSharedKey]}}))}))},t}();$i.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new $i(w.ɵɵinject(De),w.ɵɵinject($e),w.ɵɵinject(je),w.ɵɵinject(Pe),w.ɵɵinject(ri),w.ɵɵinject(yi))},token:$i,providedIn:"root"}),$i.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],$i.ctorParameters=function(){return[{type:De},{type:$e},{type:je},{type:Pe},{type:ri},{type:yi}]};var Oi,ji,Ti=E.default(Oi||(Oi=Q(["\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n }\n"],["\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n }\n"]))),Mi=E.default(ji||(ji=Q(["\n query Message($id: LrRelayIdInput!) {\n message(id: $id) {\n id\n sender {\n username\n }\n receiver {\n username\n }\n plainMessage\n signedCipherMessage\n sharedKey {\n id\n }\n senderSigPbk {\n id\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query Message($id: LrRelayIdInput!) {\n message(id: $id) {\n id\n sender {\n username\n }\n receiver {\n username\n }\n plainMessage\n signedCipherMessage\n sharedKey {\n id\n }\n senderSigPbk {\n id\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ","\n"])),Ve),Fi=function(){function e(e,t,n,r){this.lrApollo=e,this.keyGraph=t,this.encryptionService=n,this.keyExchangeService=r,this.encrypt=this.encryptionService.encrypt.bind(this.encryptionService),this.decrypt=this.encryptionService.decrypt.bind(this.encryptionService),this.sign=this.encryptionService.sign.bind(this.encryptionService),this.verify=this.encryptionService.verify.bind(this.encryptionService)}return e.prototype.sendMessage=function(e){var t=e.username,n=e.userId,r=e.plainMessageJson,i=e.plainCipherMessageJson;return q(this,void 0,void 0,(function(){var e,a,s,o,c,u;return J(this,(function(d){switch(d.label){case 0:return[4,this.keyExchangeService.currentUserSharedKey({username:t,userId:n})];case 1:return e=d.sent(),a={receiverUsername:t,receiverId:n,sharedKeyId:e.sharedKey.id,senderSigPbkId:e.userSigPrk.id},i?[4,this.keyGraph.getJwkKey(e.sharedKey.id)]:[3,6];case 2:return s=d.sent(),[4,this.encrypt(s,i)];case 3:return o=d.sent(),[4,this.keyGraph.getJwkKey(e.userSigPrk.id)];case 4:return c=d.sent(),[4,this.sign(c,o)];case 5:u=d.sent(),a.signedCipherMessage=JSON.stringify(u),d.label=6;case 6:return r&&(a.plainMessage=JSON.stringify(r)),[4,this.lrApollo.query({query:Ti,variables:{input:a}})];case 7:return[2,d.sent().sendMessage]}}))}))},e.prototype.decryptMessage=function(e,t){var n=t.sharedKey,r=t.senderSigPbk;return q(this,void 0,void 0,(function(){var t,i;return J(this,(function(a){switch(a.label){case 0:return[4,this.verify(r,JSON.parse(e.signedCipherMessage))];case 1:return t=a.sent(),i=e,[4,this.decrypt(n,t)];case 2:return i.plainSignedCipherMessageJson=a.sent(),[2]}}))}))},e.prototype.getMessage=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i;return J(this,(function(a){switch(a.label){case 0:return[4,this.lrApollo.query({query:Mi,variables:{id:e}})];case 1:return t=a.sent(),this.keyGraph.addKeys(t.keyGraph),n=t.message,[4,this.keyGraph.getJwkKey(n.sharedKey.id)];case 2:return r=a.sent(),[4,this.keyGraph.getJwkKey(n.senderSigPbk.id)];case 3:return i=a.sent(),[4,this.decryptMessage(n,{sharedKey:r,senderSigPbk:i})];case 4:return a.sent(),n.plainMessage&&(n.plainMessageJson=JSON.parse(n.plainMessage)),[2,t.message]}}))}))},e}();Fi.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Fi(w.ɵɵinject(je),w.ɵɵinject(Oe),w.ɵɵinject(Pe),w.ɵɵinject($i))},token:Fi,providedIn:"root"}),Fi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Fi.ctorParameters=function(){return[{type:je},{type:Oe},{type:Pe},{type:$i}]};var Ni,Li,xi,Ui,qi,Ji=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()}},_i=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=Ji(n),t.configure({region:e[0],userPoolId:r,userPoolWebClientId:i,mandatorySignIn:!1})}},Gi=E.default(Ni||(Ni=Q(["\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"]))),Bi=E.default(Li||(Li=Q(["\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"]))),Qi=E.default(xi||(xi=Q(["\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"]))),Vi=E.default(Ui||(Ui=Q(["\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"]))),Wi=E.default(qi||(qi=Q(["\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 e(e,t,n,r,i,a,s,o,c,u){this.config=e,this.http=t,this.lrApollo=n,this.auth=r,this.authService=i,this.keyFactory=a,this.keyService=s,this.encryptionService=o,this.keyGraph=c,this.passwordService=u,this.CLIENT_NONCE_LENGTH=32,this.LBOP_WORDS=25}return e.prototype.getPartial=function(e){return e.split(" ")[0]},e.prototype.remove=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Bi,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteLbop.id]}}))}))},e.prototype.update=function(e){var t=e.id,n=e.name;return q(this,void 0,void 0,(function(){var e,r,i;return J(this,(function(a){switch(a.label){case 0:return[4,this.get(t)];case 1:return(e=a.sent()).name=n,[4,this.keyService.getCurrentMasterKey()];case 2:return r=a.sent(),[4,this.encryptionService.encrypt(r.jwk,e)];case 3:return i=a.sent(),[4,this.lrApollo.mutate({mutation:Qi,variables:{input:{id:t,cipherMeta:JSON.stringify(i)}}})];case 4:return[2,a.sent().updateLbop]}}))}))},e.prototype.get=function(e){return q(this,void 0,void 0,(function(){var t,n,r;return J(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:Vi,variables:{id:e}})];case 1:return t=i.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return n=i.sent(),[4,this.encryptionService.decrypt(n.jwk,JSON.parse(t.lbop.cipherMeta))];case 3:return r=i.sent(),[2,Object.assign({id:t.id},r)]}}))}))},e.prototype.list=function(){return q(this,void 0,void 0,(function(){var e,t,n=this;return J(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Wi})];case 1:return e=r.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return t=r.sent(),[2,Promise.all(e.lbops.edges.map((function(e){return q(n,void 0,void 0,(function(){var n;return J(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)]}}))}))})))]}}))}))},e.prototype.create=function(e){var t=e.name;return q(this,void 0,void 0,(function(){var e,n,r,i,a,s,o,c,u,d,p,l,y,h;return J(this,(function(v){switch(v.label){case 0:if(1024!==I.Slip39Helper.WORD_LIST.length)throw new re("Slip39Helper.WORD_LIST.length != 1024");return[4,this.list()];case 1:for(e=v.sent(),r=function(){n=i.keyFactory.randomChoices(I.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=v.sent(),[4,this.keyFactory.deriveLbopKey(Object.assign({password:n},a))];case 3:return s=v.sent().jwk,[4,this.keyFactory.createSignKey()];case 4:return o=v.sent(),[4,this.encryptionService.encrypt(s,o.toJSON(!0))];case 5:return c=v.sent(),[4,this.authService.getUser()];case 6:return u=v.sent(),[4,this.keyGraph.getKey(u.currentUserKey.masterKey.id)];case 7:return d=v.sent(),[4,this.encryptionService.encrypt(s,d.jwk.toJSON(!0))];case 8:return p=v.sent(),l=Object.assign(Object.assign({},t&&{name:t}),{partial:this.getPartial(n)}),[4,this.encryptionService.encrypt(d.jwk,l)];case 9:return y=v.sent(),[4,this.lrApollo.mutate({mutation:Gi,variables:{input:{cipherMeta:JSON.stringify(y),lbopKeyParams:JSON.stringify(a),lbopKeyVerifier:JSON.stringify(o.toJSON(!0)),wrappedLbopKeyVerifier:JSON.stringify(c),masterKeyId:u.currentUserKey.masterKey.id,wrappedMasterKey:JSON.stringify(p)}}})];case 10:return h=v.sent(),[2,Object.assign(Object.assign({},h.createLbop.lbop),{lbopString:n})]}}))}))},e.prototype.verifyLbops=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,d,p,l;return J(this,(function(y){switch(y.label){case 0:n=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),y.label=1;case 1:y.trys.push([1,10,11,12]),r=_(e.lbops),i=r.next(),y.label=2;case 2:return i.done?[3,9]:(a=i.value,[4,this.keyFactory.deriveLbopKey(Object.assign({password:t},a.lbopKeyParams))]);case 3:s=y.sent().jwk,y.label=4;case 4:return y.trys.push([4,7,,8]),[4,this.encryptionService.decrypt(s,a.wrappedLbopKeyVerifier)];case 5:return o=y.sent(),c=e.challenge.serverNonce,[4,this.encryptionService.sign(o,{serverNonce:c,clientNonce:n})];case 6:return u=y.sent(),[2,{lbop:a,signedChallenge:u,lbopKey:s}];case 7:return y.sent(),[3,8];case 8:return i=r.next(),[3,2];case 9:return[3,12];case 10:return d=y.sent(),p={error:d},[3,12];case 11:try{i&&!i.done&&(l=r.return)&&l.call(r)}finally{if(p)throw p.error}return[7];case 12:throw new Y({source:"LBOP",code:"INVALID_PASSPHRASE",message:"Invalid passphrase."})}}))}))},e.prototype.verifyContact=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.http.post(this.config.authUrl+"users/lbop-reset/verify-contact/",e).toPromise()]}))}))},e.prototype.confirmContact=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e.claimId,v_code:e.vCode}).toPromise()]}))}))},e.prototype.verify=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return J(this,(function(d){switch(d.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=d.sent(),[4,this.verifyLbops(t,e.lbop)];case 2:return n=d.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=d.sent(),o={lbopId:i.lbopId,verifiedToken:s.verifiedToken,masterKeyId:s.masterKeyId},u=(c=De).asKey,[4,this.encryptionService.decrypt(a,s.wrappedMasterKey)];case 4:return[4,u.apply(c,[d.sent()])];case 5:return[2,(o.masterKey=d.sent(),o)]}}))}))},e.prototype.setPassword=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i;return J(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 Y({message:"Internal error. 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()]}}))}))},e}();Hi.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Hi(w.ɵɵinject(he),w.ɵɵinject(k.HttpClient),w.ɵɵinject(je),w.ɵɵinject(D.AuthClass),w.ɵɵinject(ri),w.ɵɵinject(De),w.ɵɵinject($e),w.ɵɵinject(Pe),w.ɵɵinject(Oe),w.ɵɵinject(or))},token:Hi,providedIn:"root"}),Hi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Hi.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[he]}]},{type:t.HttpClient},{type:je},{type:p.AuthClass},{type:ri},{type:De},{type:$e},{type:Pe},{type:Oe},{type:or}]};var Zi=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 q(this,void 0,void 0,(function(){return J(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 q(this,void 0,void 0,(function(){return J(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 q(this,void 0,void 0,(function(){return J(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"),q(this,void 0,void 0,(function(){var a,s,o,c,u,d,p,l,y,h,v,f,m;return J(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 d=g.sent(),[4,this.encryptionService.encrypt(c,d.toJSON(!0))];case 7:return p=g.sent(),[4,this.keyFactory.createPkcSignKey()];case 8:return l=g.sent(),[4,this.encryptionService.encrypt(c,l.toJSON(!0))];case 9:return y=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:d.toJSON(),wrapped_prk:p,sig_pbk:l.toJSON(),wrapped_sig_prk:y}).toPromise()];case 10:return h=g.sent(),v={},h.claims.forEach((function(e){v[e.type]=e.value})),f=this.keyFactory.randomDigitsNoZeros(4),[4,this.auth.signUp({username:e.split("@")[0]+"."+f,password:this.passwordService.getPassIdpString(a.passIdp),attributes:v,clientMetadata:{user_id:String(h.id),user_pre_sign_up_token:String(h.pre_sign_up_token)}})];case 11:return[2,{username:(m=g.sent()).user.getUsername(),userId:h.id,preSignUpToken:h.pre_sign_up_token,userSub:m.userSub}]}}))}))},e.prototype.hibpBreachedAccounts=function(e){return q(this,void 0,void 0,(function(){var t;return J(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}();Zi.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Zi(w.ɵɵinject(he),w.ɵɵinject(D.AuthClass),w.ɵɵinject(k.HttpClient),w.ɵɵinject(De),w.ɵɵinject(Pe),w.ɵɵinject(or))},token:Zi,providedIn:"root"}),Zi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Zi.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[he]}]},{type:p.AuthClass},{type:t.HttpClient},{type:De},{type:Pe},{type:or}]};var Yi=function(){function e(e){this.auth=e}return e.prototype.getPreferredMFA=function(){return q(this,void 0,void 0,(function(){var e;return J(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 q(this,void 0,void 0,(function(){var t;return J(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 q(this,void 0,void 0,(function(){var t;return J(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 q(this,void 0,void 0,(function(){return J(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 q(this,void 0,void 0,(function(){return J(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 q(this,void 0,void 0,(function(){var e,t,n,r,i;return J(this,(function(a){switch(a.label){case 0:return[4,Promise.all([this.auth.currentAuthenticatedUser(),this.auth.currentUserInfo()])];case 1:return e=G.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 ee("No email associated with user.");return[2,{code:r,codeUri:"otpauth://totp/"+i+"?secret="+r+"&issuer=LifeReady"}]}}))}))},e.prototype.verifySoftwareToken=function(e){return q(this,void 0,void 0,(function(){var t;return J(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}();Yi.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Yi(w.ɵɵinject(D.AuthClass))},token:Yi,providedIn:"root"}),Yi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Yi.ctorParameters=function(){return[{type:p.AuthClass}]};var zi,Xi=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},ea=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=Array()},e.prototype.addShare=function(e){this.shares.push(e)},e}(),ta=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=new Array},e.prototype.addSubAssembly=function(e){this.subAssemblies.push(e)},e}(),na=function(){function e(e){this.subAssemblyIndex=e,this.clearShares()}return e.prototype.clearShares=function(){this.shares=new Array},e.prototype.addShare=function(e){this.shares.push(e)},e}(),ra=function(){function e(){this.clearSubQuora()}return e.prototype.clearSubQuora=function(){this.subQuora=new Array},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},e}(),ia=function(){function e(){}return e.prototype.generateShares=function(e,t,n){return q(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,d;return J(this,(function(p){switch(p.label){case 0:r=btoa(e),r=I.Slip39Helper.slip39EncodeHex(r),i=[];try{for(a=_(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&&(d=a.return)&&d.call(a)}finally{if(u)throw u.error}}return[4,I.Slip39.fromArray(r,{passphrase:t,threshold:n.threshold,groups:i,title:""})];case 1:return c=p.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 Xi(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=_(e),c=o.next();!c.done;c=o.next()){var u=c.value,d=I.Slip39Helper.decodeMnemonic(u);if(a&&a!==d.groupThreshold)throw new Error("groupThreshold is different in mnemonics");a=d.groupThreshold,null==(v=s.get(d.groupIndex))&&(v={memberThreshold:d.memberThreshold,members:[]},s.set(d.groupIndex,v)),v.members.push({mnemonic:u,decoded:d})}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}var p=[],l=0;try{for(var y=_(s.values()),h=y.next();!h.done;h=y.next()){var v;if(!((v=h.value).members.length<v.memberThreshold)&&(v.members.slice(0,v.memberThreshold).forEach((function(e){p.push(e.mnemonic)})),++l>=a))break}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=y.return)&&i.call(y)}finally{if(r)throw r.error}}return p},e.prototype.recoverSecret=function(e,t){return q(this,void 0,void 0,(function(){var n,r;return J(this,(function(i){switch(i.label){case 0:return e=this.minimalSet(e),[4,I.Slip39.recoverSecret(e,t)];case 1:return n=i.sent(),r=I.Slip39Helper.slip39DecodeHex(n),[2,atob(r)]}}))}))},e}();ia.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new ia},token:ia,providedIn:"root"}),ia.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ia.ctorParameters=function(){return[]},e.FileType=void 0,(zi=e.FileType||(e.FileType={})).RecordContent="record-content",zi.RecordAttachment="record-attachment";var aa,sa,oa,ca,ua,da,pa,la,ya,ha=JSON.stringify({filter:[{contains:{fileType:e.FileType.RecordContent}}]}),va=JSON.stringify({filter:[{contains:{fileType:e.FileType.RecordAttachment}}]}),fa=function(e){return void 0===e&&(e=5),E.default(aa||(aa=Q(["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ","\n ","\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ","\n ","\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),Tt,_t(e),Ve)},ma=E.default(sa||(sa=Q(["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"]))),ga=E.default(oa||(oa=Q(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),Sa=E.default(ca||(ca=Q(["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Ia=E.default(ua||(ua=Q(["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),Ca=E.default(da||(da=Q(["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"],["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"]))),ba=E.default(pa||(pa=Q(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),ka=E.default(la||(la=Q(["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"],["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"])));e.AccessLevel=void 0,(ya=e.AccessLevel||(e.AccessLevel={})).Owner="OWNER",ya.Admin="ADMIN",ya.Writer="WRITER",ya.Reader="READER",ya.Deny="DENY";var wa=function(){},Ka=function(){},Pa=function(){},Ra=function(){},Da=function(){},Aa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return L(t,e),t}(Da),Ea=function(){},$a=function(){},Oa=function(){},ja=function(){},Ta=function(){function t(e,t,n){this.lrApollo=e,this.keyMetaService=t,this.keyGraph=n}return t.prototype.getRootDirectoryIds=function(e){return void 0===e&&(e=null),q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Lt,variables:{archived:e&&e.archived}})];case 1:return[2,t.sent().rootDirectories.edges.map((function(e){return e.node.id}))]}}))}))},t.prototype.getDefaultVault=function(){return q(this,void 0,void 0,(function(){var e,t;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Ut,variables:{plainMetaFilter:$t}})];case 1:return e=n.sent().list,[4,this.mapVaults(e)];case 2:if((t=n.sent()).length>1)throw new ye("There are more than one default vaults");return[2,t[0]||null]}}))}))},t.prototype.getCategories=function(e){return void 0===e&&(e=null),q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:xt,variables:{vaultFilter:$t,categoryFilter:Ot,recordFilter:jt,archived:e&&e.archived}})];case 1:if(!((t=n.sent()).vaults.edges.length>1))return[3,2];throw new ye("There is more than one default vault");case 2:return t.vaults.edges.length<1?(console.error("There is no default vault."),[2,[]]):[3,3];case 3:return[4,this.mapCategories(t.vaults.edges[0].node.childDirectoryLinks)];case 4:return[2,n.sent()]}}))}))},t.prototype.getTrustedPartyCategories=function(e){return q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:qt,variables:{trustedPartyId:e,categoryFilter:Ot,recordFilter:jt,contentFilter:ha}})];case 1:return t=r.sent().tp,n={},[4,this.mapCategories(t.sharedItems.list)];case 2:return n.categories=r.sent(),[4,this.mapRecords(t.sharedItems.records)];case 3:return[2,(n.records=r.sent(),n)]}}))}))},t.prototype.getMySharedCategories=function(e){return q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Jt,variables:{trustedPartyId:e,categoryFilter:Ot,recordFilter:jt,contentFilter:ha}})];case 1:return t=r.sent().tp,n={},[4,this.mapCategories(t.myItems.list)];case 2:return n.categories=r.sent(),[4,this.mapRecords(t.myItems.records)];case 3:return[2,(n.records=r.sent(),n)]}}))}))},t.prototype.getCategory=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return J(this,(function(d){switch(d.label){case 0:return[4,this.lrApollo.query({query:Gt(),variables:{id:e,categoryFilter:Ot,recordFilter:jt,contentFilter:ha}})];case 1:return t=d.sent().category,n={},i=(r=Object).assign,s=(a=Object).assign,o=[{}],[4,this.mapCategory(t)];case 2:return c=[s.apply(a,o.concat([d.sent()]))],u={},[4,this.mapParentCategories(t)];case 3:return n.category=i.apply(r,c.concat([(u.parents=d.sent(),u)])),[4,this.mapCategories(t.subCategories)];case 4:return n.subCategories=d.sent(),[4,this.mapRecords(t.records)];case 5:return[2,(n.records=d.sent(),n)]}}))}))},t.prototype.mapVaults=function(e){return q(this,void 0,void 0,(function(){var t=this;return J(this,(function(n){return[2,Promise.all(e.edges.map((function(e){return t.mapVault(e.node)})))]}))}))},t.prototype.mapCategories=function(e){return q(this,void 0,void 0,(function(){var t=this;return J(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.edges.map((function(e){return e.node})).map((function(e){return e.childDirectory||e})).map((function(e){return t.mapCategory(e)})))];case 1:return[2,n.sent().filter((function(e){return e})).sort((function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}))]}}))}))},t.prototype.mapRecords=function(e){return q(this,void 0,void 0,(function(){var t=this;return J(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.edges.map((function(e){return e.node})).map((function(e){return e.childDirectory||e})).map((function(e){return t.mapRecord(e)})))];case 1:return[2,n.sent().filter((function(e){return e})).sort((function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}))]}}))}))},t.prototype.createDefaultVault=function(){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return"",[4,this.keyMetaService.wrapContent("")];case 1:return t=n.sent(),[4,this.lrApollo.mutate({mutation:Vt,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Vault,default:!0}),cipherMeta:t.cipherMeta,parentRootDirectory:t.rootKey}})];case 2:return[2,n.sent().new.vault.id]}}))}))},t.prototype.createCategory=function(t){return q(this,void 0,void 0,(function(){var n,r;return J(this,(function(i){switch(i.label){case 0:return n={name:t.name,code:t.code,isCustom:t.isCustom,allowRecords:t.allowRecords,allowCustomCategories:t.allowCustomCategories},[4,this.keyMetaService.wrapContent(n,t.categoryIds)];case 1:return r=i.sent(),[4,this.lrApollo.mutate({mutation:Qt,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Category,isHidden:!1}),cipherMeta:r.cipherMeta,parentDirectories:r.wrappedKeys,parentRootDirectory:r.rootKey}})];case 2:return[2,i.sent().new.category.id]}}))}))},t.prototype.updateCategory=function(e,t,n){return q(this,void 0,void 0,(function(){var r,i;return J(this,(function(a){switch(a.label){case 0:return r={name:n.name,code:n.code,isCustom:n.isCustom,allowRecords:n.allowRecords,allowCustomCategories:n.allowCustomCategories},[4,this.keyGraph.encryptToString(t,r)];case 1:return i=a.sent(),[4,this.lrApollo.mutate({mutation:Wt,variables:{input:{directoryId:e,cipherMeta:i}}})];case 2:return a.sent(),[2]}}))}))},t.prototype.setCategoryVisibility=function(t,n){return q(this,void 0,void 0,(function(){return J(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.mutate({mutation:Wt,variables:{input:{directoryId:t,plainMeta:JSON.stringify({directoryType:e.DirectoryType.Category,isHidden:n})}}})];case 1:return r.sent(),[2]}}))}))},t.prototype.deleteCategory=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ht,variables:{categoryId:e}})];case 1:return t.sent(),[2]}}))}))},t.prototype.archiveCategory=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){return[2,this.archiveDirectory(e,t)]}))}))},t.prototype.unarchiveCategory=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){return[2,this.unarchiveDirectory(e,t)]}))}))},t.prototype.archiveDirectory=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:Zt,variables:{input:{directoryId:e,recursive:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.unarchiveDirectory=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:Yt,variables:{input:{directoryId:e,recursive:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.mapVault=function(e){return q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.keyMetaService.decryptMeta(e)];case 1:return t=(r.sent()||{}).name,[2,{id:e.id,keyId:e.keyId,name:t}];case 2:return n=r.sent(),console.error("Failed to decrypt Vault.",n,e),[2,null];case 3:return[2]}}))}))},t.prototype.mapParentCategories=function(e){return q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return e.parentCategories&&e.parentCategories.edges&&e.parentCategories.edges.length?(t=e.parentCategories.edges[0].node.parentDirectory,[4,this.mapParentCategories(t)]):[2,[]];case 1:return n=[r.sent()],[4,this.mapCategory(t)];case 2:return[2,B.apply(void 0,n.concat([[r.sent()]]))]}}))}))},t.prototype.mapCategory=function(t){var n;return q(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,d,p;return J(this,(function(l){switch(l.label){case 0:return l.trys.push([0,2,,3]),[4,this.keyMetaService.decryptMeta(t)];case 1:return r=l.sent()||{},i=r.name,a=r.isCustom,s=r.allowRecords,o=r.allowCustomCategories,c=r.code,u=(t.plainMeta&&JSON.parse(t.plainMeta)||{}).isHidden,d=t.accessRoles&&t.accessRoles.some((function(t){return t.role===e.AccessLevel.Owner})),[2,{id:t.id,keyId:t.keyId,code:c,name:i,isHidden:!!u,isCustom:!!a,isArchived:!!t.archived,allowRecords:!!s,allowCustomCategories:!!o,isEmpty:t.descendantDirectories?0===t.descendantDirectories.recordsCount:null,allRecordsCount:null===(n=t.descendantDirectories)||void 0===n?void 0:n.recordsCount,myAccessLevel:d?e.AccessLevel.Owner:t.accessRoles[0].role,sharedAccess:d?t.accessRoles.filter((function(t){return t.role!==e.AccessLevel.Owner})).map((function(e){return{trustedPartyId:e.trustedParty&&e.trustedParty.id,accessLevel:e.role,isInherited:"inherited"===e.method,inheritedFrom:e.inheritedFrom&&e.inheritedFrom.id}})):[]}];case 2:return p=l.sent(),console.error("Failed to decrypt Category.",p,t),[2,null];case 3:return[2]}}))}))},t.prototype.mapRecord=function(t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o;return J(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),n=t.content.edges[0].node.childFile,[4,this.keyMetaService.decryptMeta(n.currentVersion.state)];case 1:return r=c.sent()||{},i=r.name,a=r.recordType,s=t.accessRoles&&t.accessRoles.some((function(t){return t.role===e.AccessLevel.Owner})),[2,{id:t.id,keyId:t.keyId,name:i,recordType:a,isArchived:!!t.archived,createdOn:t.created,lastModified:new Date(t.modified)>new Date(n.currentVersion.state.modified)?t.modified:n.currentVersion.state.modified,myAccessLevel:s?e.AccessLevel.Owner:t.accessRoles[0].role,sharedAccess:s?t.accessRoles.filter((function(t){return t.role!==e.AccessLevel.Owner})).map((function(e){return{trustedPartyId:e.trustedParty&&e.trustedParty.id,accessLevel:e.role,isInherited:"inherited"===e.method,inheritedFrom:e.inheritedFrom&&e.inheritedFrom.id}})):[]}];case 2:return o=c.sent(),console.error("Failed to decrypt Record.",o),[2,null];case 3:return[2]}}))}))},t}();Ta.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Ta(w.ɵɵinject(je),w.ɵɵinject(en),w.ɵɵinject(Oe))},token:Ta,providedIn:"root"}),Ta.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ta.ctorParameters=function(){return[{type:je},{type:en},{type:Oe}]};var Ma=function(){},Fa=function(){function e(e,t){this.http=e,this.categoryService=t}return e.prototype.getCoreCategories=function(){return q(this,void 0,void 0,(function(){var e;return J(this,(function(t){switch(t.label){case 0:return this.categories?[3,2]:(e=this,[4,this.http.get("/assets/meta/categories.json").toPromise()]);case 1:e.categories=t.sent(),t.label=2;case 2:return[2,Promise.resolve(this.categories)]}}))}))},e.prototype.loadCategories=function(e,t,n){return q(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,d=this;return J(this,(function(p){switch(p.label){case 0:return n?[4,this.categoryService.getTrustedPartyCategories(n)]:[3,2];case 1:return i=p.sent().categories,[3,4];case 2:return[4,this.categoryService.getCategories()];case 3:i=p.sent(),p.label=4;case 4:return r=i,t?[4,this.categoryService.getCategory(t)]:[3,6];case 5:return s=p.sent(),[3,7];case 6:s=null,p.label=7;case 7:return a=s,o=e.map((function(e){return q(d,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return t={categoryTree:e},[4,this.loadCategory(B(e),r,a)];case 1:return[2,(t.category=n.sent(),t)]}}))}))})),[4,Promise.all(o)];case 8:return c=p.sent(),u={categories:[],missingCategories:[]},c.forEach((function(e){return e.category?u.categories.push(e.category):u.missingCategories.push(e.categoryTree)})),[2,u]}}))}))},e.prototype.loadCategoriesForRole=function(e){return q(this,void 0,void 0,(function(){var t,n=this;return J(this,(function(r){switch(r.label){case 0:return[4,this.categoryService.getCategories()];case 1:return t=r.sent(),[4,Promise.all(e.map((function(e){return q(n,void 0,void 0,(function(){var n;return J(this,(function(r){switch(r.label){case 0:return n={},[4,this.loadCategory(B(e.category),t)];case 1:return[2,(n.category=r.sent(),n.accessLevel=e.accessLevel,n)]}}))}))})))];case 2:return[2,r.sent()]}}))}))},e.prototype.loadCategory=function(e,t,n){return q(this,void 0,void 0,(function(){var r,i,a,s;return J(this,(function(o){switch(o.label){case 0:return r=e.shift(),(i=t.find((function(e){return e.code===r&&!e.isCustom})))?e.length?[4,this.categoryService.getCategory(i.id)]:[3,2]:[3,5];case 1:return a=o.sent().subCategories,[2,this.loadCategory(e,a,n)];case 2:return[4,this.categoryService.getCategory(i.id)];case 3:return s=o.sent().category,n&&n.category.parents.some((function(e){return e.id===s.id}))?[2,n.category]:[2,s];case 4:return[3,6];case 5:return e.length?[2,this.loadCategory(e,t,n)]:[2,null];case 6:return[2]}}))}))},e}();Fa.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Fa(w.ɵɵinject(k.HttpClient),w.ɵɵinject(Ta))},token:Fa,providedIn:"root"}),Fa.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Fa.ctorParameters=function(){return[{type:t.HttpClient},{type:Ta}]};var Na=function(){function t(e,t,n,r){this.fileService=e,this.lrApollo=t,this.keyMetaService=n,this.keyGraph=r}return t.prototype.downloadAttachment=function(e,t){return q(this,void 0,void 0,(function(){var n;return J(this,(function(r){switch(r.label){case 0:return[4,this.fileService.downloadEncryptedFile(e)];case 1:return n=r.sent(),[4,this.keyGraph.decryptFile(t,n)];case 2:return[2,r.sent()]}}))}))},t.prototype.uploadAttachments=function(e,t){return q(this,void 0,void 0,(function(){var n=this;return J(this,(function(r){switch(r.label){case 0:return[4,Promise.all((t||[]).map((function(t){return q(n,void 0,void 0,(function(){return J(this,(function(n){switch(n.label){case 0:return t.fileId?t.isDeleted?[4,this.deleteAttachment(t.fileId)]:[3,2]:[3,4];case 1:return n.sent(),[2,null];case 2:return[2,t.fileId];case 3:return[3,6];case 4:return[4,this.addAttachment(e,t)];case 5:return[2,n.sent()];case 6:return[2]}}))}))})))];case 1:return[2,r.sent().filter((function(e){return e}))]}}))}))},t.prototype.addAttachment=function(t,n){return q(this,void 0,void 0,(function(){var r,i,a,s;return J(this,(function(o){switch(o.label){case 0:return r={name:n.name,fieldId:n.fieldId,fileType:n.file.type,fileSize:n.file.size,lastModified:n.file.lastModified},[4,this.fileService.loadFile(n.file)];case 1:return i=o.sent(),[4,this.keyMetaService.doubleWrapContent(r,[t],i)];case 2:return a=o.sent(),[4,this.fileService.uploadEncryptedFile({encryptedContent:a.cipherFileContent,fileName:n.name})];case 3:return s=o.sent(),[4,this.lrApollo.mutate({mutation:ba,variables:{input:{plainMeta:JSON.stringify({fileType:e.FileType.RecordAttachment}),wrappedStateKey:a.doubleWrappedKey,cipherMeta:a.cipherMeta,parentDirectories:a.wrappedKeys.map((function(e){return{directoryId:e.directoryId,wrappingKeyId:e.wrappingKeyId,wrappedFileKey:e.wrappedKey}})),contentResource:s}}})];case 4:return[2,o.sent().createFile.file.id]}}))}))},t.prototype.deleteAttachment=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:ka,variables:{fileId:e}})];case 1:return t.sent(),[2]}}))}))},t}();Na.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Na(w.ɵɵinject(ii),w.ɵɵinject(je),w.ɵɵinject(en),w.ɵɵinject(Oe))},token:Na,providedIn:"root"}),Na.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Na.ctorParameters=function(){return[{type:ii},{type:je},{type:en},{type:Oe}]};var La,xa=function(){},Ua=function(){},qa=function(){},Ja=function(){},_a=function(){},Ga=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return L(t,e),t}(Ja),Ba=function(){},Qa=function(){function t(e,t,n,r){this.lrApollo=e,this.keyMetaService=t,this.categoryService=n,this.recordAttachmentService=r}return t.prototype.getRecord=function(t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,d,p=this;return J(this,(function(l){switch(l.label){case 0:return[4,this.lrApollo.query({query:fa(),variables:{id:t,categoryFilter:Ot,contentFilter:ha,attachmentsFilter:va}})];case 1:return n=l.sent().record,r=n.content.edges[0].node.childFile,[4,this.keyMetaService.decryptMeta(r.currentVersion.state)];case 2:return i=l.sent()||{},a=i.name,s=i.recordType,o=i.fields,[4,Promise.all(n.parentCategories.edges.map((function(e){return q(p,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.categoryService.mapParentCategories(e.node.parentDirectory)];case 1:return t=[n.sent()],[4,this.categoryService.mapCategory(e.node.parentDirectory)];case 2:return[2,B.apply(void 0,t.concat([[n.sent()]]))]}}))}))})))];case 3:return c=l.sent(),[4,this.mapAttachments(n.attachments.edges)];case 4:return u=l.sent(),d=n.accessRoles&&n.accessRoles.some((function(t){return t.role===e.AccessLevel.Owner})),[2,{id:n.id,keyId:n.keyId,updateKeyId:r.keyId,updateId:r.id,name:a,recordType:s,fields:o,categories:c,attachments:u,myAccessLevel:d?e.AccessLevel.Owner:n.accessRoles[0].role,sharedAccess:d?n.accessRoles.filter((function(t){return t.role!==e.AccessLevel.Owner})).map((function(e){return{trustedPartyId:e.trustedParty&&e.trustedParty.id,accessLevel:e.role,isInherited:"inherited"===e.method,inheritedFrom:e.inheritedFrom&&e.inheritedFrom.id}})):[],isArchived:!!n.archived,createdOn:n.created,lastModified:new Date(n.modified)>new Date(r.currentVersion.state.modified)?n.modified:r.currentVersion.state.modified}]}}))}))},t.prototype.mapAttachments=function(e){return q(this,void 0,void 0,(function(){var t=this;return J(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return e.node.childFile})).map((function(e){return q(t,void 0,void 0,(function(){var t,n,r,i,a,s;return J(this,(function(o){switch(o.label){case 0:return[4,this.keyMetaService.decryptMeta(e.currentVersion.state)];case 1:return t=o.sent()||{},n=t.name,r=t.fieldId,i=t.fileType,a=t.fileSize,s=t.lastModified,[2,{fileId:e.id,keyId:e.currentVersion.state.keyId,contentId:e.currentVersion.state.id,fieldId:r,name:n,fileType:i,fileSize:a,lastModified:s}]}}))}))})))];case 1:return[2,n.sent()]}}))}))},t.prototype.createRecord=function(t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o;return J(this,(function(c){switch(c.label){case 0:return[4,this.keyMetaService.wrapContent(null,t.categoryIds)];case 1:return n=c.sent(),[4,this.lrApollo.mutate({mutation:ma,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Record,isHidden:!1}),parentDirectories:n.wrappedKeys,parentRootDirectory:n.rootKey}})];case 2:return r=c.sent(),i=r.new.category.id,a={name:t.name,recordType:t.recordType,fields:t.fields},[4,this.keyMetaService.doubleWrapContent(a,[i])];case 3:return s=c.sent(),[4,this.lrApollo.mutate({mutation:ga,variables:{input:{plainMeta:JSON.stringify({fileType:e.FileType.RecordContent}),wrappedStateKey:s.doubleWrappedKey,cipherMeta:s.cipherMeta,parentDirectories:s.wrappedKeys.map((function(e){return{directoryId:e.directoryId,wrappingKeyId:e.wrappingKeyId,wrappedFileKey:e.wrappedKey}}))}}})];case 4:c.sent(),c.label=5;case 5:return c.trys.push([5,7,,8]),[4,this.recordAttachmentService.uploadAttachments(i,t.attachments)];case 6:return c.sent(),[3,8];case 7:return o=c.sent(),console.error(o),[2,{recordId:i,attachmentError:o}];case 8:return[2,{recordId:i}]}}))}))},t.prototype.updateRecord=function(t,n,r,i){return q(this,void 0,void 0,(function(){var a,s,o;return J(this,(function(c){switch(c.label){case 0:return a={name:i.name,recordType:i.recordType,fields:i.fields},[4,this.keyMetaService.reWrapContent(r,a)];case 1:return s=c.sent(),[4,this.lrApollo.mutate({mutation:Ia,variables:{input:{fileId:n,plainMeta:JSON.stringify({fileType:e.FileType.RecordContent}),wrappedStateKey:s.doubleWrappedKey,cipherMeta:s.cipherMeta}}})];case 2:c.sent(),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,this.recordAttachmentService.uploadAttachments(t,i.attachments)];case 4:return c.sent(),[3,6];case 5:return o=c.sent(),console.error(o),[2,{recordId:t,attachmentError:o}];case 6:return[2,{recordId:t}]}}))}))},t.prototype.archiveRecord=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.categoryService.archiveDirectory(e,!0)]}))}))},t.prototype.unarchiveRecord=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.categoryService.unarchiveDirectory(e,!0)]}))}))},t.prototype.deleteRecord=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ca,variables:{recordId:e}})];case 1:return t.sent(),[2]}}))}))},t}();Qa.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Qa(w.ɵɵinject(je),w.ɵɵinject(en),w.ɵɵinject(Ta),w.ɵɵinject(Na))},token:Qa,providedIn:"root"}),Qa.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Qa.ctorParameters=function(){return[{type:je},{type:en},{type:Ta},{type:Na}]},e.RecordFieldType=void 0,(La=e.RecordFieldType||(e.RecordFieldType={})).Text="text",La.Email="email",La.Url="url",La.Phone="phone",La.Date="date",La.Password="password",La.TextArea="textArea",La.Select="select",La.SingleChoice="singleChoice",La.MultiChoice="multiChoice",La.File="file",La.MultiFile="multiFile",La.Record="record",La.MultiRecord="multiRecord",La.Group="group",La.Custom="custom";var Va=function(){},Wa=function(){},Ha=function(){},Za=function(){},Ya=function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0},za=Ya,Xa=function(){function e(e){this.http=e}return e.prototype.getRecordTypes=function(){return q(this,void 0,void 0,(function(){var e,t,n,r,i=this;return J(this,(function(a){switch(a.label){case 0:return this.recordTypes?[3,2]:(e=this,[4,this.http.get("/assets/meta/record-types.json").toPromise()]);case 1:e.recordTypes=a.sent(),a.label=2;case 2:return this.categories?[3,4]:(t=this,[4,this.http.get("/assets/meta/categories.json").toPromise()]);case 3:t.categories=a.sent(),a.label=4;case 4:return n=this.categories.map((function(e){return e.subCategories})).reduce((function(e,t){return B(e,t)}),[]),r=this.recordTypes.map((function(e){return Object.assign(Object.assign({},e),{categoryNames:e.categories.map((function(e){return e.map((function(e){var t=n.find((function(t){return t.code===e}));return t?t.name:i.categories.find((function(t){return t.code===e})).name}))}))})})),[2,Promise.resolve(r)]}}))}))},e.prototype.getRecordType=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.getRecordTypes()];case 1:return[2,t.sent().find((function(t){return t.id===e}))]}}))}))},e.prototype.getRecordTypesForCategory=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.getRecordTypes()];case 1:return[2,t.sent().filter((function(t){return t.categories.some((function(t){return Ya(t,e)}))}))]}}))}))},e}();Xa.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Xa(w.ɵɵinject(k.HttpClient))},token:Xa,providedIn:"root"}),Xa.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Xa.ctorParameters=function(){return[{type:t.HttpClient}]};var es,ts,ns,rs=function(){};e.TrustedPartyRoleType=void 0,(es=e.TrustedPartyRoleType||(e.TrustedPartyRoleType={})).General="general",es.Scenario="scenario",e.TrustedPartyType=void 0,(ts=e.TrustedPartyType||(e.TrustedPartyType={})).User="user",ts.Organisation="organisation",e.TrustedPartyInviteStatus=void 0,(ns=e.TrustedPartyInviteStatus||(e.TrustedPartyInviteStatus={})).Invited="IN_PROGRESS",ns.Cancelled="CANCELLED",ns.Declined="DECLINED",ns.Completed="COMPLETED";var is,as=function(){},ss=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return L(t,e),t}(mt),os=function(){},cs=function(){},us=function(){},ds=function(){},ps=function(){},ls=function(){},ys=function(){},hs=function(){},vs="\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",fs=E.default(is||(is=Q(["\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}"])),vs),ms=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 q(this,void 0,void 0,(function(){var t;return J(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 q(this,void 0,void 0,(function(){var t,n,r;return J(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 q(this,void 0,void 0,(function(){var i,a,s,o,c,u,d,p,l,y,h;return J(this,(function(v){switch(v.label){case 0:return[4,this.keyGraph.getKey(t)];case 1:return i=v.sent(),[4,this.keyGraph.getKey(n)];case 2:return a=v.sent(),[4,this.keyService.getCurrentSigPxk()];case 3:return s=v.sent(),[4,this.encryptionService.encrypt(a.jwk,r)];case 4:return o=v.sent(),d=(u=JSON).stringify,[4,this.encryptionService.sign(s.jwk,o)];case 5:return c=d.apply(u,[v.sent()]),p={name:new ut(r.name)},h=(y=JSON).stringify,[4,this.encryptionService.sign(s.jwk,p)];case 6:return l=h.apply(y,[v.sent()]),[4,this.lrApollo.mutate({mutation:fs,variables:{input:{id:e,ownerCipherData:"",ownerKeyId:i.id,sharedCipherDataSig:c,sharedKeyId:a.id,sigPxkId:s.id,ownerPlainDataSig:l}}})];case 7:return v.sent(),[2]}}))}))},e}();ms.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new ms(w.ɵɵinject($e),w.ɵɵinject(je),w.ɵɵinject(Oe),w.ɵɵinject(Pe))},token:ms,providedIn:"root"}),ms.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ms.ctorParameters=function(){return[{type:$e},{type:je},{type:Oe},{type:Pe}]};var gs,Ss,Is,Cs,bs,ks,ws,Ks,Ps,Rs,Ds,As="\n id\n user {\n id\n username\n }\n other{\n id\n username,\n features {\n shareVault\n }\n }\n sharedContactCard {\n "+vs+"\n }\n myContactCard {\n "+vs+"\n }\n sharedScenarios {\n edges {\n node {\n id\n }\n }\n }\n sharedItems {\n directories {\n edges {\n node {\n id\n }\n }\n }\n }\n currentUserSharedKey {\n userSharedKey {\n keyExchange {\n "+bi+"\n }\n "+ki+"\n }\n }",Es=E.default(gs||(gs=Q(["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n ","\n}"],["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n ","\n}"])),As,We),$s=E.default(Ss||(Ss=Q(["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ",'\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ','\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"],["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ",'\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ','\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"])),As,bi,bi,We),Os=E.default(Is||(Is=Q(["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ","\n }\n ","\n}"],["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ","\n }\n ","\n}"])),As,We),js=E.default(Cs||(Cs=Q(["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"],["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"]))),Ts=E.default(bs||(bs=Q(["\n mutation CancelKeyExchange($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"],["\n mutation CancelKeyExchange($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"]))),Ms=E.default(ks||(ks=Q(["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"]))),Fs=E.default(ws||(ws=Q(["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"],["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"]))),Ns=E.default(Ks||(Ks=Q(["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"],["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"]))),Ls=function(){function t(e,t,n,r,i,a,s,o,c,u){this.http=e,this.lrApollo=t,this.sharedContactCardService=n,this.userService=r,this.authService=i,this.keyExchangeService=a,this.keyGraphService=s,this.keyService=o,this.keyFactory=c,this.encryptionService=u}return t.prototype.getTrustedParties=function(){return q(this,void 0,void 0,(function(){var e,t=this;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Es})];case 1:return e=n.sent().tps,[4,Promise.all(e.edges.map((function(e){return t.mapTrustedParty(e.node)})))];case 2:return[2,n.sent()]}}))}))},t.prototype.getAllTrustedParties=function(){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o=this;return J(this,(function(c){switch(c.label){case 0:return[4,this.authService.getUser()];case 1:return t=c.sent(),[4,this.lrApollo.query({query:$s,variables:{userId:t.id,isExpired:!1}})];case 2:return n=c.sent(),r=n.tps,i=n.invites,a=n.sentInvites,s={},[4,Promise.all(r.edges.map((function(e){return o.mapTrustedParty(e.node)})))];case 3:return s.parties=c.sent().filter((function(e){return e})),[4,Promise.all(i.edges.map((function(e){return q(o,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return t=this.mapInvite,[4,this.keyExchangeService.decryptKeyExchange(e.node)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))})))];case 4:return s.invites=c.sent().filter((function(t){return t.status!==e.TrustedPartyInviteStatus.Completed})).filter((function(t){return t.status!==e.TrustedPartyInviteStatus.Invited||t.actionRequired})),[4,Promise.all(a.edges.map((function(e){return q(o,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return t=this.mapInvite,[4,this.keyExchangeService.decryptKeyExchange(e.node)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))})))];case 5:return[2,(s.sentInvites=c.sent().filter((function(t){return t.status!==e.TrustedPartyInviteStatus.Completed})),s)]}}))}))},t.prototype.getTrustedParty=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Os,variables:{partyId:e}})];case 1:return t=n.sent().tp,[4,this.mapTrustedParty(t)];case 2:return[2,n.sent()]}}))}))},t.prototype.getTrustedPartyRoles=function(t){return void 0===t&&(t=e.TrustedPartyRoleType.General),q(this,void 0,void 0,(function(){var e;return J(this,(function(n){switch(n.label){case 0:return this.trustedPartyRoles?[3,2]:(e=this,[4,this.http.get("/assets/meta/trusted-party-roles.json").toPromise()]);case 1:e.trustedPartyRoles=n.sent(),n.label=2;case 2:return[2,Promise.resolve(this.trustedPartyRoles.filter((function(e){return e.roleType===t})))]}}))}))},t.prototype.findByEmail=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.userService.getUserByEmail(e)];case 1:return[2,(t=n.sent())?{id:t.id,email:e,username:t.username,isTrustedParty:t.haveTp,isMe:t.isCurrentUser}:null];case 2:return n.sent(),[2,null];case 3:return[2]}}))}))},t.prototype.inviteTrustedParty=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return t={responderUsername:e.party.username,email:e.party.email,message:{name:e.party.name,email:e.party.email,message:e.party.message,permissions:e.permissions},contactCard:{plainOwnerCipherDataJson:null,plainSharedCipherDataJson:e.mySharedDetails,ownerPlainData:{name:new ut(e.mySharedDetails.name)}}},[4,this.keyExchangeService.initiateOtk(t)];case 1:return n.sent(),[2]}}))}))},t.prototype.cancelInvitation=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ts,variables:{input:{id:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.getInvitation=function(e,t,n){return q(this,void 0,void 0,(function(){var r;return J(this,(function(i){switch(i.label){case 0:return[4,this.keyExchangeService.getKeyExchange(e,{token:t,otKeyK:n})];case 1:return r=i.sent(),[2,this.mapInvite(r)]}}))}))},t.prototype.acceptInvitation=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return t={id:e.inviteId,token:e.inviteToken,decryptedOtk:e.decryptedOtk,initiatorContactCard:null,responderContactCard:{plainOwnerCipherDataJson:null,plainSharedCipherDataJson:e.mySharedDetails,ownerPlainData:{name:new ut(e.mySharedDetails.name)}}},[4,this.keyExchangeService.respondOtk(t)];case 1:return[2,n.sent().tp.id]}}))}))},t.prototype.declineInvitation=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:js,variables:{input:{id:e,token:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.confirmInvitation=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.keyExchangeService.completeOtk(e.inviteId,e.initiatorRootKeyCipher,e.initiatorOneTimePbkCipher,null)];case 1:return[2,t.sent().tp.id]}}))}))},t.prototype.removeTrustedParty=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ms,variables:{input:{id:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.setCategoryAccessLevel=function(e,t,n,r){return r?this.shareDirectory(e,t,n,r):this.unshareDirectory(e,n.id)},t.prototype.setRecordAccessLevel=function(e,t,n,r){return r?this.shareDirectory(e,t,n,r):this.unshareDirectory(e,n.id)},t.prototype.shareDirectory=function(e,t,n,r){return q(this,void 0,void 0,(function(){var i,a,s;return J(this,(function(o){switch(o.label){case 0:return[4,this.keyGraphService.getKey(t)];case 1:return i=o.sent(),[4,this.keyGraphService.getKey(n.userSharedKey.sharedKey.id)];case 2:return a=o.sent(),[4,this.encryptionService.encrypt(a.jwk,i.jwk.toJSON(!0))];case 3:return s=o.sent(),[4,this.lrApollo.mutate({mutation:Fs,variables:{input:{id:e,tpId:n.id,accessRole:r,keyId:i.id,wrappingKeyId:a.id,wrappedKey:JSON.stringify(s)}}})];case 4:return o.sent(),[2]}}))}))},t.prototype.unshareDirectory=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:Ns,variables:{input:{id:e,tpId:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.mapTrustedParty=function(t){var n;return q(this,void 0,void 0,(function(){var r,i,a,s,o;return J(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),(i=t.sharedContactCard)?[4,this.sharedContactCardService.decryptTrustedPartyDetails(t.sharedContactCard)]:[3,2];case 1:i=c.sent(),c.label=2;case 2:return r=i,(s=t.myContactCard)?[4,this.sharedContactCardService.decryptSharedTrustedPartyDetails(t.myContactCard)]:[3,4];case 3:s=c.sent(),c.label=4;case 4:return a=s,[2,{id:t.id,type:e.TrustedPartyType.User,hasScenarios:!!t.sharedScenarios.edges.length,hasSharedVault:!!t.sharedItems.directories.edges.length,name:r&&r.name&&r.name.name,details:r,mySharedDetails:a,userSharedKey:t.currentUserSharedKey.userSharedKey,username:t.other.username,features:{sharedVault:{hasAccess:"access"===((null===(n=t.other.features)||void 0===n?void 0:n.shareVault)||["noaccess"])[0]}}}];case 5:return o=c.sent(),console.error("Failed to decrypt Trusted Party.",o,t),[2,null];case 6:return[2]}}))}))},t.prototype.mapInvite=function(t){var n,r;return q(this,void 0,void 0,(function(){var i,a,s;return J(this,(function(o){return i=t.contactCard,a=t.isInitiator?null===(n=t.myMessage)||void 0===n?void 0:n.name:i&&i.name&&i.name.name,s=t.isInitiator?null===(r=t.myMessage)||void 0===r?void 0:r.email:i&&i.email||t.responderEmailAddress,[2,{id:t.id,type:e.TrustedPartyType.User,status:t.state,token:t.token,tokenExpiry:t.tokenExpiryTime,decryptedOtk:t.decryptedOtk,name:a,email:s,isSender:t.isInitiator,actionRequired:t.isInitiator?t.initiatorActionRequired:t.responderActionRequired,rootKeyCipher:t.initiatorRootKeyCipher,pbkCipher:t.otk.initiatorOneTimePbkCipher,isExpired:t.isExpired,details:i,message:t.message,mySharedDetails:t.myContactCard,mySharedMessage:t.myMessage}]}))}))},t}();Ls.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Ls(w.ɵɵinject(k.HttpClient),w.ɵɵinject(je),w.ɵɵinject(ms),w.ɵɵinject(yi),w.ɵɵinject(ri),w.ɵɵinject($i),w.ɵɵinject(Oe),w.ɵɵinject($e),w.ɵɵinject(De),w.ɵɵinject(Pe))},token:Ls,providedIn:"root"}),Ls.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ls.ctorParameters=function(){return[{type:t.HttpClient},{type:je},{type:ms},{type:yi},{type:ri},{type:$i},{type:Oe},{type:$e},{type:De},{type:Pe}]},e.ScenarioState=void 0,(Ps=e.ScenarioState||(e.ScenarioState={})).DISABLED="DISABLED",Ps.ENABLED="ENABLED",Ps.CLAIMED="CLAIMED",Ps.APPROVED="APPROVED",Ps.REJECTED="REJECTED",e.ScenarioClaimState=void 0,(Rs=e.ScenarioClaimState||(e.ScenarioClaimState={})).Claimed="CLAIMED",Rs.Approved="APPROVED",Rs.Expired="EXPIRED",Rs.Rejected="REJECTED",Rs.Cancelled="CANCELLED",Rs.Reset="RESET",e.ApproverClaimState=void 0,(Ds=e.ApproverClaimState||(e.ApproverClaimState={})).Claimed="CLAIMED",Ds.Approved="APPROVED",Ds.Rejected="REJECTED";var xs,Us,qs,Js,_s,Gs,Bs,Qs,Vs,Ws,Hs,Zs,Ys,zs,Xs,eo,to,no,ro,io,ao,so,oo,co,uo,po,lo,yo,ho,vo,fo,mo,go,So,Io,Co,bo=function(){},ko=function(){},wo=function(){},Ko=function(){},Po=function(){},Ro=function(){},Do=function(){},Ao=function(){},Eo=function(){},$o=function(){},Oo=function(){},jo=function(){},To=function(){},Mo=function(){},Fo="\nid\ntp {\n "+As+"\n}\nsharedKey {\n id\n}\nsharedCipherData\n",No=E.default(xs||(xs=Q(["\nquery GetScenarioClaimantQuery(\n $id: LrRelayIdInput!\n) {\n scenarioClaimant(id: $id) {\n ","\n }\n ","\n}"],["\nquery GetScenarioClaimantQuery(\n $id: LrRelayIdInput!\n) {\n scenarioClaimant(id: $id) {\n ","\n }\n ","\n}"])),Fo,We),Lo=E.default(Us||(Us=Q(["\n mutation AddScenarioClaimantMutation($input: AddScenarioClaimantInput!) {\n addScenarioClaimant(input: $input) {\n claimant {\n id\n }\n }\n }\n"],["\n mutation AddScenarioClaimantMutation($input: AddScenarioClaimantInput!) {\n addScenarioClaimant(input: $input) {\n claimant {\n id\n }\n }\n }\n"]))),xo=E.default(qs||(qs=Q(["\n mutation UpdateScenarioClaimantMutation(\n $input: UpdateScenarioClaimantInput!\n ) {\n updateScenarioClaimant(input: $input) {\n claimant {\n id\n }\n }\n }\n"],["\n mutation UpdateScenarioClaimantMutation(\n $input: UpdateScenarioClaimantInput!\n ) {\n updateScenarioClaimant(input: $input) {\n claimant {\n id\n }\n }\n }\n"]))),Uo=E.default(Js||(Js=Q(["\n mutation DeleteScenarioClaimantMutation(\n $input: DeleteScenarioClaimantInput!\n ) {\n deleteScenarioClaimant(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteScenarioClaimantMutation(\n $input: DeleteScenarioClaimantInput!\n ) {\n deleteScenarioClaimant(input: $input) {\n id\n }\n }\n"]))),qo="\n id\n tp {\n "+As+'\n }\n pbk {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n categories: receiverDirectories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n accessRole\n wrappedItemKey\n directory {\n '+Ft+'\n }\n }\n }\n }\n records: receiverDirectories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n accessRole\n wrappedItemKey\n directory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n '+Tt+"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n",Jo=E.default(_s||(_s=Q(["\nquery GetScenarioReceiverQuery(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter\n) {\n scenarioReceiver(id: $id) {\n ","\n }\n ","\n} "],["\nquery GetScenarioReceiverQuery(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter\n) {\n scenarioReceiver(id: $id) {\n ","\n }\n ","\n} "])),qo,We),_o=E.default(Gs||(Gs=Q(["\n mutation CreateScenarioReceiverMutation(\n $input: CreateScenarioReceiverInput!\n ) {\n createScenarioReceiver(input: $input) {\n receiver {\n id\n }\n }\n }\n"],["\n mutation CreateScenarioReceiverMutation(\n $input: CreateScenarioReceiverInput!\n ) {\n createScenarioReceiver(input: $input) {\n receiver {\n id\n }\n }\n }\n"]))),Go=E.default(Bs||(Bs=Q(["\n mutation UpdateScenarioReceiverMutation(\n $input: UpdateScenarioReceiverInput!\n ) {\n updateScenarioReceiver(input: $input) {\n receiver {\n id\n }\n }\n }\n"],["\n mutation UpdateScenarioReceiverMutation(\n $input: UpdateScenarioReceiverInput!\n ) {\n updateScenarioReceiver(input: $input) {\n receiver {\n id\n }\n }\n }\n"]))),Bo=E.default(Qs||(Qs=Q(["\n mutation DeleteScenarioReceiverMutation(\n $input: DeleteScenarioReceiverInput!\n ) {\n deleteScenarioReceiver(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteScenarioReceiverMutation(\n $input: DeleteScenarioReceiverInput!\n ) {\n deleteScenarioReceiver(input: $input) {\n id\n }\n }\n"]))),Qo=E.default(Vs||(Vs=Q(["\n mutation AddScenarioReceiverDirectoryMutation(\n $input: AddScenarioReceiverDirectoryInput!\n ) {\n addScenarioReceiverDirectory(input: $input) {\n receiverDirectory {\n id\n }\n }\n }\n"],["\n mutation AddScenarioReceiverDirectoryMutation(\n $input: AddScenarioReceiverDirectoryInput!\n ) {\n addScenarioReceiverDirectory(input: $input) {\n receiverDirectory {\n id\n }\n }\n }\n"]))),Vo=E.default(Ws||(Ws=Q(["\n mutation UpdateScenarioReceiverDirectoryMutation(\n $input: UpdateScenarioReceiverDirectoryInput!\n ) {\n updateScenarioReceiverDirectory(input: $input) {\n receiverDirectory {\n id\n }\n }\n }\n"],["\n mutation UpdateScenarioReceiverDirectoryMutation(\n $input: UpdateScenarioReceiverDirectoryInput!\n ) {\n updateScenarioReceiverDirectory(input: $input) {\n receiverDirectory {\n id\n }\n }\n }\n"]))),Wo=E.default(Hs||(Hs=Q(["\n mutation DeleteScenarioReceiverDirectoryMutation(\n $input: DeleteScenarioReceiverDirectoryInput!\n ) {\n deleteScenarioReceiverDirectory(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteScenarioReceiverDirectoryMutation(\n $input: DeleteScenarioReceiverDirectoryInput!\n ) {\n deleteScenarioReceiverDirectory(input: $input) {\n id\n }\n }\n"]))),Ho="\nid\ntp {\n "+As+"\n}\nsharedKey {\n id\n}\nsharedCipherData\nsharedCipherApprovalData\nsharedCipherPartialAssemblyKey\n",Zo="\nid\nsingleReject\nquorum\nassemblyKey {\n id\n}\nsubAssemblyCipherData\napproverCount\napprovers {\n edges {\n node {\n "+Ho+"\n }\n }\n}\n",Yo=E.default(Zs||(Zs=Q(["\nmutation CreateScenarioApproverAssemblyMutation(\n $input: CreateScenarioApproverAssemblyInput!\n) {\n createScenarioApproverAssembly(input: $input) {\n scenario {\n approverAssembly {\n assemblyKey {\n id\n }\n }\n }\n }\n ","\n}"],["\nmutation CreateScenarioApproverAssemblyMutation(\n $input: CreateScenarioApproverAssemblyInput!\n) {\n createScenarioApproverAssembly(input: $input) {\n scenario {\n approverAssembly {\n assemblyKey {\n id\n }\n }\n }\n }\n ","\n}"])),He),zo=E.default(Ys||(Ys=Q(["\n mutation UpdateScenarioApproverAssemblyMutation(\n $input: UpdateScenarioApproverAssemblyInput!\n ) {\n updateScenarioApproverAssembly(input: $input) {\n scenario {\n id\n }\n createdSubAssemblies {\n id\n }\n createdApprovers {\n id\n }\n }\n }\n"],["\n mutation UpdateScenarioApproverAssemblyMutation(\n $input: UpdateScenarioApproverAssemblyInput!\n ) {\n updateScenarioApproverAssembly(input: $input) {\n scenario {\n id\n }\n createdSubAssemblies {\n id\n }\n createdApprovers {\n id\n }\n }\n }\n"]))),Xo=E.default(zs||(zs=Q(["\n mutation DeleteScenarioApproverAssemblyMutation(\n $input: DeleteScenarioApproverAssemblyInput!\n ) {\n deleteScenarioApproverAssembly(input: $input) {\n scenario {\n id\n }\n }\n }\n"],["\n mutation DeleteScenarioApproverAssemblyMutation(\n $input: DeleteScenarioApproverAssemblyInput!\n ) {\n deleteScenarioApproverAssembly(input: $input) {\n scenario {\n id\n }\n }\n }\n"]))),ec=E.default(Xs||(Xs=Q(["\nquery GetScenarioApproverQuery(\n $id: LrRelayIdInput!\n) {\n scenarioApprover(id: $id) {\n ","\n }\n ","\n} "],["\nquery GetScenarioApproverQuery(\n $id: LrRelayIdInput!\n) {\n scenarioApprover(id: $id) {\n ","\n }\n ","\n} "])),Ho,We),tc=E.default(eo||(eo=Q(["\n mutation AddScenarioApproverMutation($input: AddScenarioApproverInput!) {\n addScenarioApprover(input: $input) {\n approver {\n id\n }\n }\n }\n"],["\n mutation AddScenarioApproverMutation($input: AddScenarioApproverInput!) {\n addScenarioApprover(input: $input) {\n approver {\n id\n }\n }\n }\n"]))),nc=E.default(to||(to=Q(["\n mutation UpdateScenarioApproverMutation(\n $input: UpdateScenarioApproverInput!\n ) {\n updateScenarioApprover(input: $input) {\n approver {\n id\n }\n }\n }\n"],["\n mutation UpdateScenarioApproverMutation(\n $input: UpdateScenarioApproverInput!\n ) {\n updateScenarioApprover(input: $input) {\n approver {\n id\n }\n }\n }\n"]))),rc="\n id\n sharedKey {\n id\n }\n sharedCipherData\n sharedCipherPartialAssemblyKey\n",ic="\nid\nstate\ntp {\n "+As+"\n}\nasClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n}\nasReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n}\nasApprovers {\n edges {\n node {\n "+rc+"\n }\n }\n}\nsharedClaim {\n \nid\nstate\nisClaimant\nasClaimApprovers {\n edges {\n node {\n state\n approver {\n \n id\n sharedKey {\n id\n }\n sharedCipherData\n sharedCipherPartialAssemblyKey\n\n }\n receivers {\n edges {\n node {\n id\n pbk {\n id\n }\n }\n }\n }\n }\n }\n}\nasClaimReceiver {\n received\n approvals {\n edges {\n node {\n receiverPbkCipher\n }\n }\n }\n}\n\n}\n",ac=E.default(no||(no=Q(["\nquery GetSharedScenarioQuery(\n $id: LrRelayIdInput!\n) {\n sharedScenario(id: $id) {\n ","\n }\n ","\n} "],["\nquery GetSharedScenarioQuery(\n $id: LrRelayIdInput!\n) {\n sharedScenario(id: $id) {\n ","\n }\n ","\n} "])),ic,We),sc=E.default(ro||(ro=Q(['\nquery GetAllSharedScenariosQuery {\n sharedScenarios(orderBy: "-created") {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n} "],['\nquery GetAllSharedScenariosQuery {\n sharedScenarios(orderBy: "-created") {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n} "])),ic,We),oc=E.default(io||(io=Q(['\nquery GetTrustedPartyScenariosQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n myScenarios(orderBy: "-created") {\n edges {\n node {\n id\n state\n subjectKey {\n id\n }\n subjectCipherData\n created\n modified\n }\n }\n }\n sharedScenarios(orderBy: "-created") {\n edges {\n node {\n ',"\n }\n }\n }\n }\n ","\n} "],['\nquery GetTrustedPartyScenariosQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n myScenarios(orderBy: "-created") {\n edges {\n node {\n id\n state\n subjectKey {\n id\n }\n subjectCipherData\n created\n modified\n }\n }\n }\n sharedScenarios(orderBy: "-created") {\n edges {\n node {\n ',"\n }\n }\n }\n }\n ","\n} "])),ic,We),cc=E.default(ao||(ao=Q(["\n query GetAllScenarioIdsQuery {\n scenarios {\n edges {\n node {\n id\n }\n }\n }\n }\n"],["\n query GetAllScenarioIdsQuery {\n scenarios {\n edges {\n node {\n id\n }\n }\n }\n }\n"]))),uc=E.default(so||(so=Q(['\nquery GetAllScenariosQuery {\n scenarios(orderBy: "-created") {\n edges {\n node {\n id\n state\n subjectKey {\n id\n }\n subjectCipherData\n created\n modified\n claim {\n id\n state\n }\n }\n }\n }\n ',"\n} "],['\nquery GetAllScenariosQuery {\n scenarios(orderBy: "-created") {\n edges {\n node {\n id\n state\n subjectKey {\n id\n }\n subjectCipherData\n created\n modified\n claim {\n id\n state\n }\n }\n }\n }\n ',"\n} "])),We),dc=E.default(oo||(oo=Q(["\nquery GetScenarioQuery(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter\n) {\n scenario(id: $id) {\n id\n state\n subjectKey {\n id\n }\n subjectCipherData\n claimants {\n edges {\n node {\n ","\n }\n }\n }\n approverAssembly {\n id\n quorum\n assemblyKey {\n id\n }\n subAssemblies {\n edges {\n node {\n ","\n }\n }\n }\n }\n receivers {\n edges {\n node {\n ","\n }\n }\n }\n claim {\n id\n state\n claimant {\n id\n }\n }\n }\n ","\n} "],["\nquery GetScenarioQuery(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter\n) {\n scenario(id: $id) {\n id\n state\n subjectKey {\n id\n }\n subjectCipherData\n claimants {\n edges {\n node {\n ","\n }\n }\n }\n approverAssembly {\n id\n quorum\n assemblyKey {\n id\n }\n subAssemblies {\n edges {\n node {\n ","\n }\n }\n }\n }\n receivers {\n edges {\n node {\n ","\n }\n }\n }\n claim {\n id\n state\n claimant {\n id\n }\n }\n }\n ","\n} "])),Fo,Zo,qo,We),pc=E.default(co||(co=Q(["\nquery GetAllScenariosQuery {\n scenarios {\n edges {\n node {\n id\n state\n subjectKey {\n id\n }\n subjectCipherData\n created\n modified\n claim {\n id\n state\n }\n claims {\n edges {\n node {\n id\n state\n created\n modified\n claimant {\n tp {\n ","\n }\n }\n }\n }\n }\n }\n }\n }\n ","\n} "],["\nquery GetAllScenariosQuery {\n scenarios {\n edges {\n node {\n id\n state\n subjectKey {\n id\n }\n subjectCipherData\n created\n modified\n claim {\n id\n state\n }\n claims {\n edges {\n node {\n id\n state\n created\n modified\n claimant {\n tp {\n ","\n }\n }\n }\n }\n }\n }\n }\n }\n ","\n} "])),As,We),lc=E.default(uo||(uo=Q(["\n mutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n }\n"],["\n mutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n }\n"]))),yc=E.default(po||(po=Q(["\n mutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n }\n"],["\n mutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n }\n"]))),hc=E.default(lo||(lo=Q(["\n mutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n }\n"]))),vc=E.default(yo||(yo=Q(["\n mutation EnableScenarioMutation($input: EnableScenarioInput!) {\n enableScenario(input: $input) {\n scenario {\n id\n }\n }\n }\n"],["\n mutation EnableScenarioMutation($input: EnableScenarioInput!) {\n enableScenario(input: $input) {\n scenario {\n id\n }\n }\n }\n"]))),fc=E.default(ho||(ho=Q(["\n mutation DisableScenarioMutation($input: DisableScenarioInput!) {\n disableScenario(input: $input) {\n scenario {\n id\n }\n }\n }\n"],["\n mutation DisableScenarioMutation($input: DisableScenarioInput!) {\n disableScenario(input: $input) {\n scenario {\n id\n }\n }\n }\n"]))),mc=E.default(vo||(vo=Q(["\n mutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n }\n"],["\n mutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n }\n"]))),gc=E.default(fo||(fo=Q(["\n mutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n }\n"],["\n mutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n }\n"]))),Sc=Vn(mo||(mo=Q(["\nmutation ApproveScenarioClaimMutation($input: ApproveScenarioClaimInput!) {\n approveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation ApproveScenarioClaimMutation($input: ApproveScenarioClaimInput!) {\n approveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),Ic=Vn(go||(go=Q(["\nmutation RejectScenarioClaimMutation($input: RejectScenarioClaimInput!) {\n rejectScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation RejectScenarioClaimMutation($input: RejectScenarioClaimInput!) {\n rejectScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),Cc=E.default(So||(So=Q(["\n mutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n }\n"],["\n mutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n }\n"]))),bc=E.default(Io||(Io=Q(["\n mutation ResetScenarioMutation($input: ResetScenarioInput!) {\n resetScenario(input: $input) {\n scenario {\n id\n }\n }\n }\n"],["\n mutation ResetScenarioMutation($input: ResetScenarioInput!) {\n resetScenario(input: $input) {\n scenario {\n id\n }\n }\n }\n"]))),kc=E.default(Co||(Co=Q(["\n mutation UpdateScenarioApproverSubAssemblyMutation(\n $input: UpdateScenarioApproverSubAssemblyInput!\n ) {\n updateScenarioApproverSubAssembly(input: $input) {\n subAssembly {\n id\n }\n }\n }\n"],["\n mutation UpdateScenarioApproverSubAssemblyMutation(\n $input: UpdateScenarioApproverSubAssemblyInput!\n ) {\n updateScenarioApproverSubAssembly(input: $input) {\n subAssembly {\n id\n }\n }\n }\n"]))),wc=function(){function e(e,t,n,r,i,a,s){this.lrApollo=e,this.keyFactory=t,this.keyMetaService=n,this.keyGraph=r,this.slip39Service=i,this.encryptionService=a,this.trustedPartyService=s}return e.prototype.getApprover=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:ec,variables:{id:e}})];case 1:return t=n.sent().scenarioApprover,[2,this.mapApprover(t)]}}))}))},e.prototype.mapApproverGroup=function(e){return q(this,void 0,void 0,(function(){var t,n,r=this;return J(this,(function(i){switch(i.label){case 0:return[4,this.keyGraph.decryptFromString(e.assemblyKey.id,e.subAssemblyCipherData)];case 1:return t=i.sent().name,n={id:e.id,keyId:e.assemblyKey.id,name:t,quorum:e.quorum,singleReject:e.singleReject},[4,Promise.all(e.approvers.edges.map((function(e){return r.mapApprover(e.node)})))];case 2:return[2,(n.approvers=i.sent(),n)]}}))}))},e.prototype.mapApprover=function(e){return q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return[4,this.keyGraph.decryptFromString(e.sharedKey.id,e.sharedCipherData)];case 1:return t=r.sent().message,n={id:e.id,keyId:e.sharedKey.id},[4,this.trustedPartyService.mapTrustedParty(e.tp)];case 2:return[2,(n.trustedParty=r.sent(),n.message=t,n)]}}))}))},e.prototype.updateApprover=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.keyGraph.encryptToString(e.keyId,e.plainSharedCipherData)];case 1:return t=n.sent(),[4,this.lrApollo.mutate({mutation:nc,variables:{input:{approverId:e.approverId,sharedKeyId:e.keyId,sharedCipherData:t,sharedCipherApprovalData:""}}})];case 2:return n.sent(),[2]}}))}))},e.prototype.createScenarioApproverAssembly=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return J(this,(function(d){switch(d.label){case 0:return[4,this.keyFactory.createKey()];case 1:return t=d.sent(),[4,this.keyGraph.encryptToString(e.keyId,t.toJSON(!0))];case 2:return n=d.sent(),e.plainAssemblyCipherData?[4,this.keyGraph.encryptToString(t,e.plainAssemblyCipherData)]:[3,4];case 3:return i=d.sent(),[3,5];case 4:i="",d.label=5;case 5:return r=i,s=(a=this.lrApollo).mutate,o={mutation:Yo},c={},u={scenarioId:e.scenarioId,singleReject:e.singleReject,quorum:e.quorum,subjectKeyId:e.keyId,subjectKeyWrappedAssemblyKey:n,assemblyCipherData:r},[4,this.mapApprovalGroups(e.approvalGroups,e.quorum,t)];case 6:return u.createSubAssemblies=d.sent().map((function(e){e.updateApprovers,e.deleteApprovers;return x(e,["updateApprovers","deleteApprovers"])})),[4,this.rewrapReceivers(t,e.event,e.receivers)];case 7:return[4,s.apply(a,[(o.variables=(c.input=(u.updateReceivers=d.sent(),u),c),o)])];case 8:return[2,d.sent().createScenarioApproverAssembly.scenario.approverAssembly.assemblyKey.id]}}))}))},e.prototype.updateScenarioApproverAssembly=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i;return J(this,(function(a){switch(a.label){case 0:return[4,this.keyGraph.getKey(e.assemblyKeyId)];case 1:return t=a.sent(),e.plainAssemblyCipherData?[4,this.keyGraph.encryptToString(t.jwk,e.plainAssemblyCipherData)]:[3,3];case 2:return r=a.sent(),[3,4];case 3:r="",a.label=4;case 4:return n=r,[4,this.mapApprovalGroups(e.approvalGroups,e.quorum,t.jwk)];case 5:return i=a.sent(),[4,this.lrApollo.mutate({mutation:zo,variables:{input:{scenarioId:e.scenarioId,singleReject:e.singleReject,quorum:e.quorum,assemblyKeyId:t.id,assemblyCipherData:n,createSubAssemblies:i.filter((function(e){return!e.subAssemblyId})).map((function(e){e.updateApprovers,e.deleteApprovers;return x(e,["updateApprovers","deleteApprovers"])})),updateSubAssemblies:i.filter((function(e){return e.subAssemblyId})),deleteSubAssemblies:e.deletedGroupIds}}})];case 6:return a.sent(),[2]}}))}))},e.prototype.deleteScenarioApproverAssembly=function(e,t,n){return q(this,void 0,void 0,(function(){var r,i,a,s,o;return J(this,(function(c){switch(c.label){case 0:return i=(r=this.lrApollo).mutate,a={mutation:Xo},s={},o={scenarioId:e},[4,this.rewrapReceivers(null,t,n)];case 1:return[4,i.apply(r,[(a.variables=(s.input=(o.updateReceivers=c.sent(),o),s),a)])];case 2:return c.sent(),[2]}}))}))},e.prototype.rewrapReceivers=function(e,t,n){return q(this,void 0,void 0,(function(){var r=this;return J(this,(function(i){switch(i.label){case 0:return n&&n.length?[4,Promise.all(n.map((function(n){return q(r,void 0,void 0,(function(){var r,i,a,s,o=this;return J(this,(function(c){switch(c.label){case 0:return[4,this.keyGraph.getKey(n.keyId)];case 1:return r=c.sent(),i=function(t,n){return q(o,void 0,void 0,(function(){var i,a;return J(this,(function(s){switch(s.label){case 0:return[4,this.keyGraph.getKey(n)];case 1:return i=s.sent(),[4,this.keyGraph.encryptToString(r.jwk,i.jwk.toJSON(!0))];case 2:return a=s.sent(),e?[4,this.keyGraph.encryptToString(e,a)]:[3,4];case 3:a=s.sent(),s.label=4;case 4:return[2,{accessRole:t.accessLevel,sharedKeyId:r.id,sharedCipherData:"",wrappedItemKey:a}]}}))}))},[4,Promise.all(B(n.categories.map((function(e){return q(o,void 0,void 0,(function(){var t,n,r,a,s;return J(this,(function(o){switch(o.label){case 0:return n=(t=Object).assign,a=(r=Object).assign,s=[{}],[4,i(e,e.category.keyId)];case 1:return[2,n.apply(t,[a.apply(r,s.concat([o.sent()])),{receiverDirectoryId:e.id}])]}}))}))})),n.records.map((function(e){return q(o,void 0,void 0,(function(){var t,n,r,a,s;return J(this,(function(o){switch(o.label){case 0:return n=(t=Object).assign,a=(r=Object).assign,s=[{}],[4,i(e,e.record.keyId)];case 1:return[2,n.apply(t,[a.apply(r,s.concat([o.sent()])),{receiverDirectoryId:e.id}])]}}))}))}))))];case 2:return a=c.sent(),s={receiverId:n.id,sharedKeyId:n.keyId,receiverDirectories:a,receiverFiles:[]},[4,this.keyGraph.encryptToString(r.jwk,{event:t,message:n.message})];case 3:return[2,(s.sharedCipherData=c.sent(),s)]}}))}))})))]:[2,[]];case 1:return[2,i.sent()]}}))}))},e.prototype.mapApprovalGroups=function(e,t,n){return q(this,void 0,void 0,(function(){var r,i=this;return J(this,(function(a){switch(a.label){case 0:return[4,this.createSlipAssembly(t,e,n.toJSON(!0).k)];case 1:return r=a.sent(),[4,Promise.all(e.map((function(e,t){return i.mapApprovalGroup(e,r.subAssemblies[t],n)})))];case 2:return[2,a.sent()]}}))}))},e.prototype.mapApprovalGroup=function(e,t,n){return q(this,void 0,void 0,(function(){var r,i;return J(this,(function(a){switch(a.label){case 0:return[4,this.mapApprovers(e.approvers,e.quorum,t,n)];case 1:return r=a.sent(),i={subAssemblyId:e.subAssemblyId,singleReject:e.singleReject,quorum:e.quorum},[4,this.keyGraph.encryptToString(n,e.plainSubAssemblyCipherData)];case 2:return[2,(i.subAssemblyCipherData=a.sent(),i.createApprovers=r.filter((function(e){return!e.approverId})),i.updateApprovers=r.filter((function(e){return e.approverId})),i.deleteApprovers=e.deletedApproverIds||[],i)]}}))}))},e.prototype.mapApprovers=function(e,t,n,r){return q(this,void 0,void 0,(function(){var i,a,s,o,c=this;return J(this,(function(u){switch(u.label){case 0:return i=r.toJSON(!0),i.k,a=x(i,["k"]),s=0,o=function(r){return q(c,void 0,void 0,(function(){var i,o;return J(this,(function(c){return i=n.shares[s],1!==t&&++s,o={slip39:{share:i,subAssembly:{quorum:t,size:e.length}},assemblyKeyParams:a},[2,this.keyGraph.encryptToString(r,o)]}))}))},[4,Promise.all(e.map((function(e){return q(c,void 0,void 0,(function(){var t,n,r,i,a,s;return J(this,(function(c){switch(c.label){case 0:return e.approverId?[4,this.keyGraph.getKey(e.keyId)]:[3,5];case 1:return t=c.sent(),[4,this.keyGraph.encryptToString(e.keyId,e.plainSharedCipherData)];case 2:return n=c.sent(),[4,this.keyGraph.encryptToString(e.keyId,e.approvalData)];case 3:return r=c.sent(),i={approverId:e.approverId,sharedKeyId:e.keyId,sharedCipherData:n||"",sharedCipherApprovalData:r||""},[4,o(t.jwk)];case 4:return[2,(i.sharedCipherPartialAssemblyKey=c.sent(),i)];case 5:return[4,this.keyMetaService.wrapContentWithKey(e.plainSharedCipherData,e.trustedPartySharedKeyId)];case 6:return a=c.sent(),s={tpId:e.trustedPartyId,tpSharedKeyId:e.trustedPartySharedKeyId,tpSharedKeyWrappedSharedKey:a.rootKey.wrappedKey,sharedCipherData:a.cipherMeta,sharedCipherApprovalData:""},[4,o(a.key)];case 7:return[2,(s.sharedCipherPartialAssemblyKey=c.sent(),s)]}}))}))})))];case 1:return[2,u.sent()]}}))}))},e.prototype.createSlipAssembly=function(t,n,r){return q(this,void 0,void 0,(function(){var i;return J(this,(function(a){switch(a.label){case 0:return i=new ta(t),n.forEach((function(e,t){var n=e.approvers.length;1===e.quorum&&(n=1),i.addSubAssembly(new ea(t,e.quorum,n))})),i.subAssemblies.length<t?[2,null]:[4,this.slip39Service.generateShares(r,e.SLIP39_PASSPHRASE,i)];case 1:return a.sent(),[2,i]}}))}))},e}();wc.SLIP39_PASSPHRASE="lifeready",wc.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new wc(w.ɵɵinject(je),w.ɵɵinject(De),w.ɵɵinject(en),w.ɵɵinject(Oe),w.ɵɵinject(ia),w.ɵɵinject(Pe),w.ɵɵinject(Ls))},token:wc,providedIn:"root"}),wc.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],wc.ctorParameters=function(){return[{type:je},{type:De},{type:en},{type:Oe},{type:ia},{type:Pe},{type:Ls}]};var Kc=function(){function e(e,t,n,r){this.lrApollo=e,this.keyMetaService=t,this.keyGraph=n,this.tpService=r}return e.prototype.getClaimant=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:No,variables:{id:e}})];case 1:return t=n.sent().scenarioClaimant,[2,this.mapClaimant(t)]}}))}))},e.prototype.mapClaimant=function(e){return q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return[4,this.keyGraph.decryptFromString(e.sharedKey.id,e.sharedCipherData)];case 1:return t=r.sent().message,n={id:e.id,keyId:e.sharedKey.id},[4,this.tpService.mapTrustedParty(e.tp)];case 2:return[2,(n.trustedParty=r.sent(),n.message=t,n)]}}))}))},e.prototype.addClaimant=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.keyMetaService.wrapContentWithKey(e.plainSharedCipherData,e.trustedPartySharedKeyId)];case 1:return t=n.sent(),[4,this.lrApollo.mutate({mutation:Lo,variables:{input:{scenarioId:e.scenarioId,tpId:e.trustedPartyId,tpSharedKeyId:e.trustedPartySharedKeyId,tpSharedKeyWrappedSharedKey:t.rootKey.wrappedKey,sharedCipherData:t.cipherMeta}}})];case 2:return[2,n.sent().addScenarioClaimant.claimant.id]}}))}))},e.prototype.updateClaimant=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.keyGraph.encryptToString(e.keyId,e.plainSharedCipherData)];case 1:return t=n.sent(),[4,this.lrApollo.mutate({mutation:xo,variables:{input:{claimantId:e.id,sharedKeyId:e.keyId,sharedCipherData:t}}})];case 2:return[2,n.sent().updateScenarioClaimant.claimant.id]}}))}))},e.prototype.deleteClaimant=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Uo,variables:{input:{claimantId:e}}})];case 1:return t.sent(),[2]}}))}))},e}();Kc.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Kc(w.ɵɵinject(je),w.ɵɵinject(en),w.ɵɵinject(Oe),w.ɵɵinject(Ls))},token:Kc,providedIn:"root"}),Kc.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Kc.ctorParameters=function(){return[{type:je},{type:en},{type:Oe},{type:Ls}]};var Pc=function(){function e(e,t,n,r,i,a){this.lrApollo=e,this.keyGraph=t,this.keyMetaService=n,this.tpService=r,this.categoryService=i,this.recordService=a}return e.prototype.getReceiver=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Jo,variables:{id:e,categoryFilter:Ot,recordFilter:jt,contentFilter:ha}})];case 1:return t=n.sent().scenarioReceiver,[2,this.mapReceiver(t)]}}))}))},e.prototype.mapReceiver=function(e){return q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return[4,this.keyGraph.decryptFromString(e.sharedKey.id,e.sharedCipherData)];case 1:return t=r.sent().message,n={id:e.id,keyId:e.sharedKey.id},[4,this.tpService.mapTrustedParty(e.tp)];case 2:return n.trustedParty=r.sent(),n.message=t,[4,this.mapCategories(e.categories)];case 3:return n.categories=r.sent(),[4,this.mapRecords(e.records)];case 4:return[2,(n.records=r.sent(),n)]}}))}))},e.prototype.mapCategories=function(e){return q(this,void 0,void 0,(function(){var t=this;return J(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.edges.map((function(e){return e.node})).map((function(e){return e.childDirectory||e})).map((function(e){return t.mapReceiverCategory(e)})))];case 1:return[2,n.sent().filter((function(e){return e})).sort((function(e,t){return e.category.name===t.category.name?0:e.category.name>t.category.name?1:-1}))]}}))}))},e.prototype.mapRecords=function(e){return q(this,void 0,void 0,(function(){var t=this;return J(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.edges.map((function(e){return e.node})).map((function(e){return e.childDirectory||e})).map((function(e){return t.mapReceiverRecord(e)})))];case 1:return[2,n.sent().filter((function(e){return e})).sort((function(e,t){return e.record.name===t.record.name?0:e.record.name>t.record.name?1:-1}))]}}))}))},e.prototype.mapReceiverCategory=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return t={id:e.id,keyId:e.sharedKey.id,accessLevel:e.accessRole},[4,this.categoryService.mapCategory(e.directory)];case 1:return[2,(t.category=n.sent(),t)]}}))}))},e.prototype.mapReceiverRecord=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return t={id:e.id,keyId:e.sharedKey.id,accessLevel:e.accessRole},[4,this.categoryService.mapRecord(e.directory)];case 1:return[2,(t.record=n.sent(),t)]}}))}))},e.prototype.addReceiver=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.keyMetaService.wrapContentWithKey(e.plainSharedCipherData,e.trustedPartySharedKeyId)];case 1:return t=n.sent(),[4,this.lrApollo.mutate({mutation:_o,variables:{input:{scenarioId:e.scenarioId,tpId:e.trustedPartyId,tpSharedKeyId:e.trustedPartySharedKeyId,tpSharedKeyWrappedSharedKey:t.rootKey.wrappedKey,sharedCipherData:t.cipherMeta}}})];case 2:return[2,n.sent().createScenarioReceiver.receiver.id]}}))}))},e.prototype.updateReceiver=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.keyGraph.encryptToString(e.keyId,e.plainSharedCipherData)];case 1:return t=n.sent(),[4,this.lrApollo.mutate({mutation:Go,variables:{input:{receiverId:e.id,sharedKeyId:e.keyId,sharedCipherData:t}}})];case 2:return n.sent(),[2]}}))}))},e.prototype.deleteReceiver=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Bo,variables:{input:{receiverId:e}}})];case 1:return t.sent(),[2]}}))}))},e.prototype.addReceiverCategory=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d;return J(this,(function(p){switch(p.label){case 0:return[4,this.categoryService.getCategory(e.categoryId)];case 1:return t=p.sent(),r=(n=this.lrApollo).mutate,i={mutation:Qo},a={},o=(s=Object).assign,u=(c=Object).assign,d=[{}],[4,this.addReceiverItem(e,t.category.keyId)];case 2:return[4,r.apply(n,[(i.variables=(a.input=o.apply(s,[u.apply(c,d.concat([p.sent()])),{directoryId:t.category.id}]),a),i)])];case 3:return[2,p.sent().addScenarioReceiverDirectory.receiverDirectory.id]}}))}))},e.prototype.addReceiverRecord=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d;return J(this,(function(p){switch(p.label){case 0:return[4,this.recordService.getRecord(e.recordId)];case 1:return t=p.sent(),r=(n=this.lrApollo).mutate,i={mutation:Qo},a={},o=(s=Object).assign,u=(c=Object).assign,d=[{}],[4,this.addReceiverItem(e,t.keyId)];case 2:return[4,r.apply(n,[(i.variables=(a.input=o.apply(s,[u.apply(c,d.concat([p.sent()])),{directoryId:t.id}]),a),i)])];case 3:return[2,p.sent().addScenarioReceiverDirectory.receiverDirectory.id]}}))}))},e.prototype.addReceiverItem=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a;return J(this,(function(s){switch(s.label){case 0:return e.plainSharedCipherData?[4,this.keyGraph.encryptToString(e.receiverKeyId,e.plainSharedCipherData)]:[3,2];case 1:return r=s.sent(),[3,3];case 2:r="",s.label=3;case 3:return n=r,[4,this.keyGraph.getKey(t)];case 4:return i=s.sent(),[4,this.keyGraph.encryptToString(e.receiverKeyId,i.jwk.toJSON(!0))];case 5:return a=s.sent(),e.assemblyKeyId?[4,this.keyGraph.encryptToString(e.assemblyKeyId,a)]:[3,7];case 6:a=s.sent(),s.label=7;case 7:return[2,{receiverId:e.receiverId,sharedKeyId:e.receiverKeyId,assemblyKeyId:e.assemblyKeyId,wrappedItemKey:a,accessRole:e.accessRole,sharedCipherData:n}]}}))}))},e.prototype.updateReceiverItem=function(e){return q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return e.plainSharedCipherData?[4,this.keyGraph.encryptToString(e.keyId,e.plainSharedCipherData)]:[3,2];case 1:return n=r.sent(),[3,3];case 2:n="",r.label=3;case 3:return t=n,[4,this.lrApollo.mutate({mutation:Vo,variables:{input:{receiverDirectoryId:e.id,sharedKeyId:e.keyId,accessRole:e.accessRole,sharedCipherData:t}}})];case 4:return r.sent(),[2]}}))}))},e.prototype.deleteReceiverItem=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Wo,variables:{input:{receiverDirectoryId:e}}})];case 1:return t.sent(),[2]}}))}))},e}();Pc.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Pc(w.ɵɵinject(je),w.ɵɵinject(Oe),w.ɵɵinject(en),w.ɵɵinject(Ls),w.ɵɵinject(Ta),w.ɵɵinject(Qa))},token:Pc,providedIn:"root"}),Pc.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Pc.ctorParameters=function(){return[{type:je},{type:Oe},{type:en},{type:Ls},{type:Ta},{type:Qa}]};var Rc=$,Dc=function(){function t(e,t,n,r,i,a,s,o,c,u,d,p){this.lrApollo=e,this.keyMetaService=t,this.keyFactory=n,this.keyService=r,this.encryptionService=i,this.keyGraph=a,this.tpService=s,this.slip39Service=o,this.scenarioClaimantService=c,this.scenarioApproverService=u,this.scenarioReceiverService=d,this.lrGraphQL=p}return t.prototype.getMyScenarios=function(){return q(this,void 0,void 0,(function(){var e,t=this;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:uc})];case 1:return e=n.sent().scenarios,[4,Promise.all(e.edges.map((function(e){return t.mapScenarioSummary(e.node)})))];case 2:return[2,n.sent()]}}))}))},t.prototype.mapScenarioSummary=function(e){return q(this,void 0,void 0,(function(){var t,n,r;return J(this,(function(i){switch(i.label){case 0:return[4,this.keyGraph.decryptFromString(e.subjectKey.id,e.subjectCipherData)];case 1:return t=i.sent(),n=t.event,r=t.name,[2,{id:e.id,name:r,event:n,status:e.state,claimId:e.claim&&e.claim.id,claimStatus:e.claim&&e.claim.state,createdOn:e.created,lastModified:e.modified}]}}))}))},t.prototype.getSharedScenarios=function(){return q(this,void 0,void 0,(function(){var e,t=this;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:sc})];case 1:return e=n.sent().sharedScenarios,[4,Promise.all(e.edges.map((function(e){return t.mapSharedScenario(e.node)})))];case 2:return[2,n.sent().filter((function(e){return e}))]}}))}))},t.prototype.mapSharedScenarioSummary=function(e){return q(this,void 0,void 0,(function(){var t,n,r;return J(this,(function(i){switch(i.label){case 0:return[4,this.keyGraph.decryptFromString(e.subjectKey.id,e.subjectCipherData)];case 1:return t=i.sent(),n=t.event,r=t.name,[2,{id:e.id,name:r,event:n,status:e.state,claimId:e.claim&&e.claim.id,claimStatus:e.claim&&e.claim.state,createdOn:e.created,lastModified:e.modified}]}}))}))},t.prototype.getSharedScenario=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:ac,variables:{id:e}})];case 1:return t=n.sent().sharedScenario,[4,this.mapSharedScenario(t)];case 2:return[2,n.sent()]}}))}))},t.prototype.mapSharedScenario=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c=this;return J(this,(function(u){switch(u.label){case 0:return u.trys.push([0,8,,9]),[4,this.getCipherData(e.asClaimant)];case 1:return t=u.sent(),[4,this.getCipherData(e.asReceiver)];case 2:return n=u.sent(),[4,Promise.all(e.asApprovers.edges.map((function(e){return c.getCipherData(e.node.approver)})))];case 3:return r=u.sent(),i={id:e.id,event:t.event||n.event||r.map((function(e){return e.event}))[0],status:e.state},[4,this.tpService.mapTrustedParty(e.tp)];case 4:return i.trustedParty=u.sent(),i.isClaimant=!!e.asClaimant,i.claimantMessage=t.message,i.isApprover=e.asApprovers.edges.length>0,i.approverMessages=r.map((function(e){return e.message})),i.isReceiver=!!e.asReceiver,i.receiverMessage=n.message,i.receiverKeyId=e.asReceiver&&e.asReceiver.sharedKey.id,i.receiverPbkId=e.asReceiver&&e.asReceiver.pbk.id,i.receiverDirectories=e.asReceiver&&e.asReceiver.receiverDirectories.edges.map((function(e){return e.node})),e.sharedClaim?(s={id:e.sharedClaim.id,isClaimant:e.sharedClaim.isClaimant,status:e.sharedClaim.state},[4,Promise.all(e.sharedClaim.asClaimApprovers.edges.map((function(e){return e.node})).map((function(e){return q(c,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return t={approverId:e.approver.id},[4,this.getApproverKey(e.approver)];case 1:return[2,(t.approverKey=n.sent(),t.status=e.state,t.receivers=e.receivers.edges.map((function(e){return{id:e.node.id,pbkId:e.node.pbk.id}})),t)]}}))}))})))]):[3,6];case 5:return s.asApprovers=u.sent(),s.asReceiver=e.sharedClaim.asClaimReceiver?{received:e.sharedClaim.asClaimReceiver.received,ciphers:e.sharedClaim.asClaimReceiver.approvals.edges.map((function(e){return e.node.receiverPbkCipher}))}:null,a=s,[3,7];case 6:a=null,u.label=7;case 7:return[2,(i.claim=a,i)];case 8:return o=u.sent(),console.error("Failed to decrypt shared scenario.",o,e),[2,null];case 9:return[2]}}))}))},t.prototype.getTrustedPartyScenarios=function(e){return q(this,void 0,void 0,(function(){var t,n,r=this;return J(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:oc,variables:{partyId:e}})];case 1:return t=i.sent().tp,n={},[4,Promise.all(t.myScenarios.edges.map((function(e){return r.mapScenarioSummary(e.node)})))];case 2:return n.myScenarios=i.sent(),[4,Promise.all(t.sharedScenarios.edges.map((function(e){return r.mapSharedScenario(e.node)})))];case 3:return[2,(n.sharedScenarios=i.sent(),n)]}}))}))},t.prototype.getScenarioClaims=function(){return q(this,void 0,void 0,(function(){var e,t=this;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:pc})];case 1:return e=n.sent().scenarios,[4,Promise.all(e.edges.map((function(e){return q(t,void 0,void 0,(function(){var t,n=this;return J(this,(function(r){switch(r.label){case 0:return[4,this.mapScenarioSummary(e.node)];case 1:return t=r.sent(),[4,Promise.all(e.node.claims.edges.map((function(e){return q(n,void 0,void 0,(function(){var n;return J(this,(function(r){switch(r.label){case 0:return n={id:e.node.id,state:e.node.state},[4,this.tpService.mapTrustedParty(e.node.claimant.tp)];case 1:return[2,(n.triggeredBy=r.sent(),n.triggeredOn=e.node.created,n.lastModified=e.node.modified,n.scenario=t,n)]}}))}))})))];case 2:return[2,r.sent()]}}))}))})))];case 2:return[2,n.sent().reduce((function(e,t){return B(e,t)}),[]).sort((function(e,t){return-1*Rc(new Date(e.lastModified)).diff(Rc(new Date(t.lastModified)))}))]}}))}))},t.prototype.getCipherData=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return e?[4,this.keyGraph.decryptFromString(e.sharedKey.id,e.sharedCipherData)]:[2,{}];case 1:return[2,t.sent()]}}))}))},t.prototype.getApproverKey=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return e?[4,this.keyGraph.decryptFromString(e.sharedKey.id,e.sharedCipherPartialAssemblyKey)]:[2,null];case 1:return[2,t.sent()]}}))}))},t.prototype.getScenario=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:dc,variables:{id:e,categoryFilter:Ot,recordFilter:jt,contentFilter:ha}})];case 1:return t=n.sent().scenario,[4,this.mapScenario(t)];case 2:return[2,n.sent()]}}))}))},t.prototype.mapScenario=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o=this;return J(this,(function(c){switch(c.label){case 0:return[4,this.keyGraph.decryptFromString(e.subjectKey.id,e.subjectCipherData)];case 1:return t=c.sent(),n=t.name,r=t.event,[4,Promise.all(e.claimants.edges.map((function(e){return o.scenarioClaimantService.mapClaimant(e.node)})))];case 2:return i=c.sent(),a={id:e.id,keyId:e.subjectKey.id,assemblyKeyId:e.approverAssembly&&e.approverAssembly.assemblyKey.id,assemblyQuorum:e.approverAssembly&&e.approverAssembly.quorum,name:n,event:r,status:e.state,claimants:i},e.approverAssembly?[4,Promise.all(e.approverAssembly.subAssemblies.edges.map((function(e){return o.scenarioApproverService.mapApproverGroup(e.node)})))]:[3,4];case 3:return s=c.sent(),[3,5];case 4:s=[],c.label=5;case 5:return a.approverGroups=s,[4,Promise.all(e.receivers.edges.map((function(e){return o.scenarioReceiverService.mapReceiver(e.node)})))];case 6:return[2,(a.receivers=c.sent(),a.claim=e.claim?{id:e.claim.id,status:e.claim.state,claimant:i.find((function(t){return t.id===e.claim.claimant.id}))}:null,a)]}}))}))},t.prototype.createScenario=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i;return J(this,(function(a){switch(a.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return t=a.sent(),[4,this.keyFactory.createKey()];case 2:return n=a.sent(),[4,this.keyGraph.encryptToString(t.jwk,n.toJSON(!0))];case 3:return r=a.sent(),[4,this.keyGraph.encryptToString(n,e.plainSubjectCipherData)];case 4:return i=a.sent(),[4,this.lrApollo.mutate({mutation:lc,variables:{input:{rootKeyId:t.id,rootKeyWrappedSubjectKey:r,subjectCipherData:i}}})];case 5:return[2,a.sent().createScenario.scenario.id]}}))}))},t.prototype.updateScenario=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a;return J(this,(function(s){switch(s.label){case 0:return n=(t=this.lrApollo).mutate,r={mutation:yc},i={},a={scenarioId:e.scenarioId,subjectKeyId:e.keyId},[4,this.keyGraph.encryptToString(e.keyId,e.plainSubjectCipherData)];case 1:return[4,n.apply(t,[(r.variables=(i.input=(a.subjectCipherData=s.sent(),a),i),r)])];case 2:return s.sent(),[2]}}))}))},t.prototype.enableScenario=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:vc,variables:{input:{scenarioId:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.disableScenario=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:fc,variables:{input:{scenarioId:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.deleteScenario=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:hc,variables:{input:{scenarioId:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.createClaim=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:mc,variables:{input:{scenarioId:e}}})];case 1:return[2,t.sent().createScenarioClaim.sharedClaim.id]}}))}))},t.prototype.cancelClaim=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:gc,variables:{input:{claimId:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.approveClaim=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){return[2,this.lrGraphQL.lrMutate(this.approveClaimMutation(e,t))]}))}))},t.prototype.approveClaimMutation=function(t,n){return q(this,void 0,void 0,(function(){var r,i,a,s,o,c=this;return J(this,(function(u){switch(u.label){case 0:return[4,this.getSharedScenario(t)];case 1:if((r=u.sent()).claim.id!==n)throw new Y({code:e.LrErrorCode.ReceiveClaimMismatch,message:"claimId does not match with the current claimId of the scenario"});return i=function(e){return q(c,void 0,void 0,(function(){var t,r,i,a,s=this;return J(this,(function(o){switch(o.label){case 0:return t=Zr.bind,r={mutation:Sc},i={},a={claimId:n,approverId:e.approverId},[4,Promise.all(e.receivers.map((function(t){return q(s,void 0,void 0,(function(){var n;return J(this,(function(r){switch(r.label){case 0:return n={receiverId:t.id},[4,this.keyGraph.encryptToString(t.pbkId,{partialAssemblyKey:e.approverKey})];case 1:return[2,(n.receiverPbkCipher=r.sent(),n)]}}))}))})))];case 1:return[2,new(t.apply(Zr,[void 0,(r.variables=(i.input=(a.receivers=o.sent(),a),i),r)]))]}}))}))},a=r.claim.asApprovers.filter((function(t){return t.status===e.ApproverClaimState.Claimed})).map((function(e){return i(e)})),o=(s=zr).create,[4,Promise.all(a)];case 2:return[2,o.apply(s,[u.sent()])]}}))}))},t.prototype.rejectClaim=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){return[2,this.lrGraphQL.lrMutate(this.rejectClaimMutation(e,t))]}))}))},t.prototype.rejectClaimMutation=function(t,n){return q(this,void 0,void 0,(function(){var r,i,a,s,o,c=this;return J(this,(function(u){switch(u.label){case 0:return[4,this.getSharedScenario(t)];case 1:if((r=u.sent()).claim.id!==n)throw new Y({code:e.LrErrorCode.ReceiveClaimMismatch,message:"ClaimId does not match with the current claimId of the scenario"});return i=function(e){return q(c,void 0,void 0,(function(){return J(this,(function(t){return[2,new Zr({mutation:Ic,variables:{input:{claimId:n,approverId:e.approverId}}})]}))}))},a=r.claim.asApprovers.filter((function(t){return t.status===e.ApproverClaimState.Claimed})).map((function(e){return i(e)})),o=(s=zr).create,[4,Promise.all(a)];case 2:return[2,o.apply(s,[u.sent()])]}}))}))},t.prototype.receiveClaim=function(t,n){return q(this,void 0,void 0,(function(){var r,i,a,s=this;return J(this,(function(o){switch(o.label){case 0:return[4,this.getSharedScenario(t)];case 1:if((r=o.sent()).claim.id!==n)throw new Y({code:e.LrErrorCode.ReceiveClaimMismatch,message:"ClaimId does not match with the current claimId of the scenario"});if(r.status!==e.ScenarioState.APPROVED)throw new Y({code:e.LrErrorCode.BadState,message:"Scenario claim has not been approved"});return[4,this.getClaimAssemblyKey(r.receiverPbkId,r.claim.asReceiver.ciphers)];case 2:return i=o.sent(),[4,Promise.all(r.receiverDirectories.map((function(e){return q(s,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return i?[4,this.encryptionService.decrypt(i,e.wrappedItemKey)]:[3,2];case 1:return n=r.sent(),[3,3];case 2:n=e.wrappedItemKey,r.label=3;case 3:return t=n,[2,{receiverDirectoryId:e.id,receiverSharedKeyWrappedItemKey:t}]}}))}))})))];case 3:return a=o.sent(),[4,this.lrApollo.mutate({mutation:Cc,variables:{input:{claimId:n,receiverDirectories:a}}})];case 4:return o.sent(),[2]}}))}))},t.prototype.getClaimAssemblyKey=function(t,n){return q(this,void 0,void 0,(function(){var r,i,a,s=this;return J(this,(function(o){switch(o.label){case 0:return n&&n.length?[4,Promise.all(n.map((function(n){return q(s,void 0,void 0,(function(){var i;return J(this,(function(a){switch(a.label){case 0:return[4,this.keyGraph.decryptFromString(t,n)];case 1:if(i=a.sent().partialAssemblyKey,r){if(JSON.stringify(r)!==JSON.stringify(i.assemblyKeyParams))throw new Y({code:e.LrErrorCode.BadState,message:"The assembly key parameters are different between the approvals."})}else r=i.assemblyKeyParams;return[2,i.slip39.share.mnemonics]}}))}))})))]:[2,null];case 1:return i=o.sent(),[4,this.slip39Service.recoverSecret(i,wc.SLIP39_PASSPHRASE)];case 2:return a=o.sent(),[4,De.asKey(Object.assign(Object.assign({},r),{k:a}))];case 3:return[2,o.sent()]}}))}))},t.prototype.resetScenario=function(t,n){return void 0===n&&(n=!1),q(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,d,p,l,y,h,v,f,m,g,S,I=this;return J(this,(function(C){switch(C.label){case 0:return r=function(e,t,n){return q(I,void 0,void 0,(function(){var r,i,a;return J(this,(function(s){switch(s.label){case 0:return[4,this.keyGraph.getKey(t)];case 1:return r=s.sent(),[4,this.keyGraph.getKey(e)];case 2:return i=s.sent(),[4,this.keyGraph.encryptToString(r.jwk,i.jwk.toJSON(!0))];case 3:return a=s.sent(),n?[4,this.keyGraph.encryptToString(n,a)]:[3,5];case 4:a=s.sent(),s.label=5;case 5:return[2,a]}}))}))},i=function(e,t){return q(I,void 0,void 0,(function(){var n=this;return J(this,(function(i){return[2,Promise.all(B(e.categories.map((function(i){return q(n,void 0,void 0,(function(){var n;return J(this,(function(a){switch(a.label){case 0:return n={receiverDirectoryId:i.id},[4,r(i.category.keyId,e.keyId,t)];case 1:return[2,(n.wrappedItemKey=a.sent(),n)]}}))}))})),e.records.map((function(i){return q(n,void 0,void 0,(function(){var n;return J(this,(function(a){switch(a.label){case 0:return n={receiverDirectoryId:i.id},[4,r(i.record.keyId,e.keyId,t)];case 1:return[2,(n.wrappedItemKey=a.sent(),n)]}}))}))}))))]}))}))},a=function(e,t){return q(I,void 0,void 0,(function(){var n=this;return J(this,(function(r){return[2,Promise.all(e.map((function(e){return q(n,void 0,void 0,(function(){var n;return J(this,(function(r){switch(r.label){case 0:return n={receiverId:e.id},[4,i(e,t)];case 1:return[2,(n.receiverDirectories=r.sent(),n.receiverFiles=[],n)]}}))}))})))]}))}))},s=function(e){return q(I,void 0,void 0,(function(){var t=this;return J(this,(function(n){return[2,Promise.all(e.map((function(e){return q(t,void 0,void 0,(function(){return J(this,(function(t){return[2,{approverId:e.id,sharedKeyId:e.keyId}]}))}))})))]}))}))},o=function(e,t){return q(I,void 0,void 0,(function(){var n=this;return J(this,(function(r){return[2,Promise.all(e.map((function(e){return q(n,void 0,void 0,(function(){var n;return J(this,(function(r){switch(r.label){case 0:return n={subAssemblyId:e.id},[4,this.keyGraph.encryptToString(t,{name:e.name})];case 1:return n.subAssemblyCipherData=r.sent(),[4,s(e.approvers)];case 2:return[2,(n.approvers=r.sent(),n)]}}))}))})))]}))}))},[4,this.getScenario(t)];case 1:if((c=C.sent()).status!==e.ScenarioState.APPROVED)throw new Y({code:e.LrErrorCode.BadState,message:"Scenario must be in "+e.ScenarioState.APPROVED+" state"});return[4,this.keyGraph.getKey(c.keyId)];case 2:return u=C.sent(),[4,this.keyFactory.createKey()];case 3:return d=C.sent(),l={scenarioId:c.id,disable:n},[4,a(c.receivers,d)];case 4:return l.receivers=C.sent(),p=l,[4,this.keyGraph.encryptToString(u.jwk,d.toJSON(!0))];case 5:return y=C.sent(),h=p,v={subjectKeyId:u.id,subjectKeyWrappedAssemblyKey:y,assemblyCipherData:""},[4,o(c.approverGroups,d)];case 6:return h.approverAssembly=(v.subAssemblies=C.sent(),v),c.approverGroups.length?(f=d.toJSON(!0),m=f.k,g=x(f,["k"]),S=new ta(c.assemblyQuorum),c.approverGroups.forEach((function(e,t){var n=e.approvers.length;1===e.quorum&&(n=1),S.addSubAssembly(new ea(t,e.quorum,n))})),[4,this.slip39Service.generateShares(m,wc.SLIP39_PASSPHRASE,S)]):[3,9];case 7:return C.sent(),[4,Promise.all(c.approverGroups.map((function(e,t){return q(I,void 0,void 0,(function(){var n,r,i=this;return J(this,(function(a){switch(a.label){case 0:return n=S.subAssemblies[t],r=p.approverAssembly.subAssemblies[t],[4,Promise.all(e.approvers.map((function(t,a){return q(i,void 0,void 0,(function(){var i,s,o,c;return J(this,(function(u){switch(u.label){case 0:return[4,this.keyGraph.getKey(t.keyId)];case 1:return i=u.sent(),s=1===e.quorum?n.shares[0]:n.shares[a],o={slip39:{share:s,subAssembly:{quorum:e.quorum,size:e.approvers.length}},assemblyKeyParams:g},c=r.approvers[a],[4,this.keyGraph.encryptToString(i.jwk,o)];case 2:return c.sharedCipherPartialAssemblyKey=u.sent(),[2]}}))}))})))];case 1:return a.sent(),[2]}}))}))})))];case 8:C.sent(),C.label=9;case 9:return[4,this.lrApollo.mutate({mutation:bc,variables:{input:p}})];case 10:return C.sent(),[2]}}))}))},t.prototype.getAllScenarioIds=function(){return q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:cc})];case 1:return[2,e.sent().scenarios.edges.map((function(e){return e.node.id}))]}}))}))},t}();Dc.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Dc(w.ɵɵinject(je),w.ɵɵinject(en),w.ɵɵinject(De),w.ɵɵinject($e),w.ɵɵinject(Pe),w.ɵɵinject(Oe),w.ɵɵinject(Ls),w.ɵɵinject(ia),w.ɵɵinject(Kc),w.ɵɵinject(wc),w.ɵɵinject(Pc),w.ɵɵinject(e.ɵb))},token:Dc,providedIn:"root"}),Dc.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Dc.ctorParameters=function(){return[{type:je},{type:en},{type:De},{type:$e},{type:Pe},{type:Oe},{type:Ls},{type:ia},{type:Kc},{type:wc},{type:Pc},{type:e.ɵb}]};var Ac,Ec=function(){function e(e,t,n,r){this.scenarioService=e,this.scenarioClaimantService=t,this.scenarioApproverService=n,this.scenarioReceiverService=r}return e.prototype.setupScenario=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s=this;return J(this,(function(o){switch(o.label){case 0:return[4,this.scenarioService.createScenario({plainSubjectCipherData:{event:e.event,name:e.name}})];case 1:t=o.sent(),o.label=2;case 2:return o.trys.push([2,8,,9]),[4,Promise.all(e.claimants.map((function(n){return s.updateClaimant(t,e.event,n)})))];case 3:return o.sent(),[4,this.scenarioService.getScenario(t)];case 4:return n=o.sent(),e.approvalGroups.length?(r={scenarioId:t,keyId:n.keyId,event:n.event,singleReject:!1,quorum:1,plainAssemblyCipherData:null,approvalGroups:e.approvalGroups.map((function(t){return{quorum:t.quorum,singleReject:t.singleReject,plainSubAssemblyCipherData:{name:t.name},approvers:t.approvers.map((function(t){return{trustedPartyId:t.trustedPartyId,trustedPartySharedKeyId:t.trustedPartySharedKeyId,plainSharedCipherData:{message:t.message,event:e.event}}}))}}))},i=n,[4,this.scenarioApproverService.createScenarioApproverAssembly(r)]):[3,6];case 5:i.assemblyKeyId=o.sent(),o.label=6;case 6:return[4,Promise.all(e.receivers.map((function(r){return s.updateReceiver(t,n.assemblyKeyId,e.event,r)})))];case 7:return o.sent(),[3,9];case 8:return a=o.sent(),[2,{scenarioId:t,error:a}];case 9:return[2,{scenarioId:t}]}}))}))},e.prototype.updateScenario=function(e){return q(this,void 0,void 0,(function(){var t,n,r=this;return J(this,(function(i){switch(i.label){case 0:return t={scenarioId:e.scenarioId,keyId:e.keyId,plainSubjectCipherData:{event:e.event,name:e.name}},[4,this.scenarioService.updateScenario(t)];case 1:return i.sent(),[4,Promise.all(e.claimants.map((function(t){return r.updateClaimant(e.scenarioId,e.event,t)})))];case 2:return i.sent(),[4,Promise.all(e.deletedClaimantIds.map((function(e){return r.scenarioClaimantService.deleteClaimant(e)})))];case 3:return i.sent(),[4,this.updateApprovalGroups(e)];case 4:return n=i.sent(),[4,Promise.all(e.receivers.map((function(t){return r.updateReceiver(e.scenarioId,n,e.event,t)})))];case 5:return i.sent(),[4,Promise.all(e.deletedReceiverIds.map((function(e){return r.scenarioReceiverService.deleteReceiver(e)})))];case 6:return i.sent(),[2]}}))}))},e.prototype.updateClaimant=function(e,t,n){return q(this,void 0,void 0,(function(){return J(this,(function(r){switch(r.label){case 0:return n.claimantId?[4,this.scenarioClaimantService.updateClaimant({id:n.claimantId,keyId:n.keyId,plainSharedCipherData:{message:n.message,event:t}})]:[3,2];case 1:return r.sent(),[3,4];case 2:return[4,this.scenarioClaimantService.addClaimant({scenarioId:e,trustedPartyId:n.trustedPartyId,trustedPartySharedKeyId:n.trustedPartySharedKeyId,plainSharedCipherData:{message:n.message,event:t}})];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))},e.prototype.updateApprovalGroups=function(e){return q(this,void 0,void 0,(function(){var t,n;return J(this,(function(r){switch(r.label){case 0:return e.assemblyKeyId?e.approvalGroups.length?(n={scenarioId:e.scenarioId,assemblyKeyId:e.assemblyKeyId,singleReject:!1,quorum:1,approvalGroups:e.approvalGroups.map((function(t){return{subAssemblyId:t.subAssemblyId,quorum:t.quorum,singleReject:t.singleReject,plainSubAssemblyCipherData:{name:t.name},approvers:t.approvers.map((function(t){return{approverId:t.approverId,keyId:t.keyId,trustedPartyId:t.trustedPartyId,trustedPartySharedKeyId:t.trustedPartySharedKeyId,plainSharedCipherData:{message:t.message,event:e.event}}})),deletedApproverIds:t.deletedApproverIds}})),deletedGroupIds:e.deletedGroupIds},[4,this.scenarioApproverService.updateScenarioApproverAssembly(n)]):[3,2]:[3,6];case 1:return r.sent(),[2,e.assemblyKeyId];case 2:return[4,this.scenarioService.getScenario(e.scenarioId)];case 3:return t=r.sent().receivers,[4,this.scenarioApproverService.deleteScenarioApproverAssembly(e.scenarioId,e.event,t)];case 4:return r.sent(),[2,null];case 5:return[3,9];case 6:return e.approvalGroups.length?[4,this.scenarioService.getScenario(e.scenarioId)]:[3,9];case 7:return t=r.sent().receivers,n={scenarioId:e.scenarioId,keyId:e.keyId,event:e.event,singleReject:!1,quorum:1,approvalGroups:e.approvalGroups.map((function(t){return{quorum:t.quorum,singleReject:t.singleReject,plainSubAssemblyCipherData:{name:t.name},approvers:t.approvers.map((function(t){return{trustedPartyId:t.trustedPartyId,trustedPartySharedKeyId:t.trustedPartySharedKeyId,plainSharedCipherData:{message:t.message,event:e.event}}}))}})),receivers:t},[4,this.scenarioApproverService.createScenarioApproverAssembly(n)];case 8:return[2,r.sent()];case 9:return[2,null]}}))}))},e.prototype.updateReceiver=function(e,t,n,r){return q(this,void 0,void 0,(function(){var i,a,s;return J(this,(function(o){switch(o.label){case 0:return(i=r.receiverId)?[4,this.scenarioReceiverService.updateReceiver({id:r.receiverId,keyId:r.keyId,plainSharedCipherData:{message:r.message,event:n}})]:[3,2];case 1:return o.sent(),[3,4];case 2:return a={scenarioId:e,trustedPartyId:r.trustedPartyId,trustedPartySharedKeyId:r.trustedPartySharedKeyId,plainSharedCipherData:{message:r.message,event:n}},[4,this.scenarioReceiverService.addReceiver(a)];case 3:i=o.sent(),o.label=4;case 4:return[4,this.scenarioReceiverService.getReceiver(i)];case 5:return s=o.sent(),[4,this.updateReceiverItems(e,t,s,r.permissions)];case 6:return o.sent(),[2]}}))}))},e.prototype.updateReceiverItems=function(e,t,n,r){return q(this,void 0,void 0,(function(){var i=this;return J(this,(function(a){switch(a.label){case 0:return(r=r||{}).categories=r.categories||[],r.records=r.records||[],[4,Promise.all(r.categories.filter((function(e){return!n.categories.some((function(t){return t.category.id===e.categoryId}))})).map((function(r){return q(i,void 0,void 0,(function(){var i;return J(this,(function(a){switch(a.label){case 0:return i={scenarioId:e,assemblyKeyId:t,receiverId:n.id,receiverKeyId:n.keyId,accessRole:r.accessLevel,categoryId:r.categoryId},[4,this.scenarioReceiverService.addReceiverCategory(i)];case 1:return a.sent(),[2]}}))}))})))];case 1:return a.sent(),[4,Promise.all(r.records.filter((function(e){return!n.records.some((function(t){return t.record.id===e.recordId}))})).map((function(r){return q(i,void 0,void 0,(function(){var i;return J(this,(function(a){switch(a.label){case 0:return i={scenarioId:e,assemblyKeyId:t,receiverId:n.id,receiverKeyId:n.keyId,accessRole:r.accessLevel,recordId:r.recordId},[4,this.scenarioReceiverService.addReceiverRecord(i)];case 1:return a.sent(),[2]}}))}))})))];case 2:return a.sent(),[4,Promise.all(r.categories.map((function(e){return{accessLevel:e.accessLevel,category:n.categories.find((function(t){return t.category.id===e.categoryId}))}})).filter((function(e){return e.category})).map((function(e){return q(i,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return t={id:e.category.id,keyId:e.category.keyId,accessRole:e.accessLevel},[4,this.scenarioReceiverService.updateReceiverItem(t)];case 1:return n.sent(),[2]}}))}))})))];case 3:return a.sent(),[4,Promise.all(r.records.map((function(e){return{accessLevel:e.accessLevel,record:n.records.find((function(t){return t.record.id===e.recordId}))}})).filter((function(e){return e.record})).map((function(e){return q(i,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return t={id:e.record.id,keyId:e.record.keyId,accessRole:e.accessLevel},[4,this.scenarioReceiverService.updateReceiverItem(t)];case 1:return n.sent(),[2]}}))}))})))];case 4:return a.sent(),[4,Promise.all(n.categories.filter((function(e){return!r.categories.some((function(t){return t.categoryId===e.category.id}))})).map((function(e){return i.scenarioReceiverService.deleteReceiverItem(e.id)})))];case 5:return a.sent(),[4,Promise.all(n.records.filter((function(e){return!r.records.some((function(t){return t.recordId===e.record.id}))})).map((function(e){return i.scenarioReceiverService.deleteReceiverItem(e.id)})))];case 6:return a.sent(),[2]}}))}))},e}();Ec.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Ec(w.ɵɵinject(Dc),w.ɵɵinject(Kc),w.ɵɵinject(wc),w.ɵɵinject(Pc))},token:Ec,providedIn:"root"}),Ec.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ec.ctorParameters=function(){return[{type:Dc},{type:Kc},{type:wc},{type:Pc}]},function(e){e.Name="name",e.Email="email",e.Image="image",e.Phone="phone",e.Address="address"}(Ac||(Ac={}));var $c=[Ac.Name,Ac.Email,Ac.Image,Ac.Phone,Ac.Address],Oc=function(){function e(e,t,n,r){this.sharedContactCardService=e,this.trustedPartyService=t,this.profileService=n,this.authService=r}return e.prototype.updateDetails=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.authService.getUser()];case 1:return t=n.sent(),[4,this.profileService.updateDetails(t.contactCard.id,t.contactCard.keyId,e)];case 2:return n.sent(),[4,this.synchronizeContactCards(e,t.contactCard)];case 3:return n.sent(),[4,this.authService.getUser(!0)];case 4:return[2,n.sent()]}}))}))},e.prototype.synchronizeContactCards=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return J(this,(function(d){switch(d.label){case 0:return t?0===(n=this.getChanges(e,t)).length?[2]:[4,this.trustedPartyService.getTrustedParties()]:[2];case 1:if(0===(r=d.sent()).length)return[2];d.label=2;case 2:d.trys.push([2,7,8,9]),i=_(r.map((function(e){return e.mySharedDetails}))),a=i.next(),d.label=3;case 3:return a.done?[3,6]:(s=a.value,[4,this.synchronizeSharedContactCard(s,n)]);case 4:d.sent(),d.label=5;case 5:return a=i.next(),[3,3];case 6:return[3,9];case 7:return o=d.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]}}))}))},e.prototype.getChanges=function(e,t){var n,r,i,a,s=[];try{for(var o=_($c),c=o.next();!c.done;c=o.next()){var u=c.value,d=t[u];if(d&&d.values){var p=function(t){var n=e[u].values.find((function(e){return e.id===t.id}));n?P.default.isEqual(n.value,t.value)||s.push({field:u,id:t.id,label:t.label,oldValue:t.value,newValue:n.value}):s.push({field:u,id:t.id,label:t.label,oldValue:t.value})};try{for(var l=(i=void 0,_(d.values)),y=l.next();!y.done;y=l.next()){p(y.value)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(a=l.return)&&a.call(l)}finally{if(i)throw i.error}}}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s},e.prototype.synchronizeSharedContactCard=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,d,p,l;return J(this,(function(y){switch(y.label){case 0:n=!1,r=function(t){switch(t.field){case Ac.Phone:(r=e.phones&&e.phones.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;case Ac.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];P.default.isEqual(r,t.oldValue)&&(n=!0,e[t.field]=t.newValue)}};try{for(i=_(t),a=i.next();!a.done;a=i.next())s=a.value,r(s)}catch(e){p={error:e}}finally{try{a&&!a.done&&(l=i.return)&&l.call(i)}finally{if(p)throw p.error}}return n?(o=e.id,c=e.ownedKeyId,u=e.sharedKeyId,d=x(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(o,c,u,d)]):[3,2];case 1:y.sent(),y.label=2;case 2:return[2]}}))}))},e.prototype.updateTrustedPartyDetails=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i;return J(this,(function(a){switch(a.label){case 0:return t=e.id,n=e.ownedKeyId,r=e.sharedKeyId,i=x(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]}}))}))},e.prototype.synchronizeSharedDetails=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d,p,l,y;return J(this,(function(h){switch(h.label){case 0:return[4,this.authService.getUser()];case 1:if(t=h.sent().contactCard,n=!1,t=Object.assign({},t),e.name&&(u=this.checkField(e.name,t.name))&&(t.name=u,n=!0),e.email&&(u=this.checkField(e.email,t.email))&&(t.email=u,n=!0),e.image&&(u=this.checkField(e.image,t.image))&&(t.image=u,n=!0),e.phones&&e.phones.length)try{for(r=_(e.phones),i=r.next();!i.done;i=r.next())a=i.value,(u=this.checkField(a.value,t.phone,a.label))&&(t.phone=u,n=!0)}catch(e){d={error:e}}finally{try{i&&!i.done&&(p=r.return)&&p.call(r)}finally{if(d)throw d.error}}if(e.addresses&&e.addresses.length)try{for(s=_(e.addresses),o=s.next();!o.done;o=s.next())c=o.value,(u=this.checkField(c.value,t.address,c.label))&&(t.address=u,n=!0)}catch(e){l={error:e}}finally{try{o&&!o.done&&(y=s.return)&&y.call(s)}finally{if(l)throw l.error}}return n?[4,this.profileService.updateDetails(t.id,t.keyId,t)]:[3,3];case 2:h.sent(),h.label=3;case 3:return[2]}}))}))},e.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!P.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},e}();Oc.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new Oc(w.ɵɵinject(ms),w.ɵɵinject(Ls),w.ɵɵinject(Tn),w.ɵɵinject(ri))},token:Oc,providedIn:"root"}),Oc.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Oc.ctorParameters=function(){return[{type:ms},{type:Ls},{type:Tn},{type:ri}]},e.UserDeleteState=void 0,(e.UserDeleteState||(e.UserDeleteState={})).REQUESTED="REQUESTED";var jc=function(){function e(){}return e.forRoot=function(t){return{ngModule:e,providers:[{provide:he,useValue:t},{provide:p.AuthClass,useValue:j.default},{provide:n.APP_INITIALIZER,useFactory:_i,deps:[he,p.AuthClass],multi:!0},{provide:n.APP_INITIALIZER,useFactory:ni,deps:[ri],multi:!0},{provide:l.APOLLO_OPTIONS,useFactory:fe,deps:[he,p.AuthClass]}]}},e}();jc.decorators=[{type:n.NgModule,args:[{imports:[t.HttpClientModule,g.NgIdleKeepaliveModule.forRoot()],providers:[v.CookieService,Ce,ii,Tn,Zi,ri,or,Re,Pe,Oe,$e,De]}]}];var Tc,Mc=function(){},Fc=function(){},Nc=function(){},Lc=function(){},xc=function(){};e.SearchItemType=void 0,(Tc=e.SearchItemType||(e.SearchItemType={})).RECORD="RECORD",Tc.CATEGORY="CATEGORY";var Uc,qc=E.default(Uc||(Uc=Q(['\n query GetRecordContents(\n $id: LrRelayIdInput!\n $depth: Int\n $first: Int\n $after: String\n $recordContentFilter: LrJSONFilter!\n ) {\n category: directory(id: $id) {\n descendantDirectories(depth: $depth) {\n recordContents: files(\n first: $first\n after: $after\n plainMeta: $recordContentFilter\n orderBy: "-created"\n ) {\n edges {\n node {\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n nParentDirectoryLinks(n: 1) {\n list {\n parentDirectory {\n id\n keyId\n created\n modified\n archived\n plainMeta\n cipherMeta\n nParentDirectoryLinks(n: 3) {\n list {\n parentDirectory {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ',"\n"],['\n query GetRecordContents(\n $id: LrRelayIdInput!\n $depth: Int\n $first: Int\n $after: String\n $recordContentFilter: LrJSONFilter!\n ) {\n category: directory(id: $id) {\n descendantDirectories(depth: $depth) {\n recordContents: files(\n first: $first\n after: $after\n plainMeta: $recordContentFilter\n orderBy: "-created"\n ) {\n edges {\n node {\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n nParentDirectoryLinks(n: 1) {\n list {\n parentDirectory {\n id\n keyId\n created\n modified\n archived\n plainMeta\n cipherMeta\n nParentDirectoryLinks(n: 3) {\n list {\n parentDirectory {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ',"\n"])),Ve);function Jc(t,n,r,i,a){return q(this,void 0,void 0,(function(){var s,o,c,u;return J(this,(function(d){switch(d.label){case 0:return[],[4,t.getCategory(i)];case 1:s=d.sent(),c=s.records.length,d.label=2;case 2:return c<a?(o=s.category.name+"+"+r.randomString(16),console.log("Creating record: ",o),[4,n.createRecord({categoryIds:[s.category.id],name:o,recordType:{id:"1",version:1,name:"Vehicle Details"},fields:[{id:"1-vin",type:e.RecordFieldType.Text,label:"VIN Number",value:"1234567890"},{id:"1-location",type:e.RecordFieldType.Text,label:"Location",value:"10".repeat(1e3)}]})]):[3,5];case 3:d.sent(),d.label=4;case 4:return++c,[3,2];case 5:c=s.records.length,d.label=6;case 6:return c>a?(u=s.records[c-1].id,console.log("Deleting record: ",u),[4,n.deleteRecord(u)]):[3,9];case 7:d.sent(),d.label=8;case 8:return--c,[3,6];case 9:return[2]}}))}))}e.SearchService=function(){function t(e,t,n,r){this.ngZone=e,this.lrApollo=t,this.categoryService=n,this.keyGraph=r,this.vaultItems={}}return t.prototype.mapRecordContent=function(t){return q(this,void 0,void 0,(function(){var n,r,i,a;return J(this,(function(s){switch(s.label){case 0:return n=t.nParentDirectoryLinks.list[0].parentDirectory,r=t.currentVersion.state,(a=r.cipherMeta)?[4,this.keyGraph.decryptFromString(r.keyId,r.cipherMeta)]:[3,2];case 1:a=s.sent(),s.label=2;case 2:return i=a,[2,{type:e.SearchItemType.RECORD,id:n.id,created:new Date(n.created),modified:new Date(n.modified),archived:n.archived,plainMeta:r.plainMeta&&JSON.parse(t.currentVersion.state.plainMeta),plainCipherMeta:i,parentCategoryId:n.nParentDirectoryLinks.list[0].parentDirectory.id}]}}))}))},t.prototype.mapRecordContents=function(e){return q(this,void 0,void 0,(function(){var t=this;return J(this,(function(n){return[2,Promise.all(e.map((function(e){return t.mapRecordContent(e.node)})))]}))}))},t.prototype.load=function(){return q(this,void 0,void 0,(function(){var e,t,n,r,i,a,s,o,c,u;return J(this,(function(d){switch(d.label){case 0:return[4,this.categoryService.getDefaultVault()];case 1:return e=d.sent(),t=Date.now(),r=this,[4,this.lrApollo.query({query:qc,variables:{id:e.id,depth:5,first:null,after:null,recordContentFilter:ha}})];case 2:return r.recordContentsResult=d.sent(),n=Date.now(),console.log("Search API time (s): ",(n-t)/1e3),t=Date.now(),[4,this.mapRecordContents(this.recordContentsResult.category.descendantDirectories.recordContents.edges)];case 3:i=d.sent();try{for(a=_(i),s=a.next();!s.done;s=a.next())o=s.value,this.vaultItems[o.id]=o}catch(e){c={error:e}}finally{try{s&&!s.done&&(u=a.return)&&u.call(a)}finally{if(c)throw c.error}}return n=Date.now(),console.log("Search mapCategory time (s): ",(n-t)/1e3),[2]}}))}))},t.prototype.refresh=function(){return q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return[4,this.load()];case 1:return e.sent(),console.log(Object.values(this.vaultItems)),[2,this.vaultItems]}}))}))},t}(),e.SearchService.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new e.SearchService(w.ɵɵinject(w.NgZone),w.ɵɵinject(je),w.ɵɵinject(Ta),w.ɵɵinject(Oe))},token:e.SearchService,providedIn:"root"}),e.SearchService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.SearchService.ctorParameters=function(){return[{type:n.NgZone},{type:je},{type:Ta},{type:Oe}]},e.SearchService=U([Ur({ngZoneName:"ngZone"})],e.SearchService);var _c,Gc,Bc,Qc,Vc,Wc,Hc=Vn(_c||(_c=Q(["\n fragment ContactCardFragment on ContactCardNode {\n id\n publicData\n publicSearchable\n cipherData\n key {\n id\n }\n }\n"],["\n fragment ContactCardFragment on ContactCardNode {\n id\n publicData\n publicSearchable\n cipherData\n key {\n id\n }\n }\n"]))),Zc=Vn(Gc||(Gc=Q(["\n mutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n ) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"],["\n mutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n ) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"]))),Yc=Vn(Bc||(Bc=Q(["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"],["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"]))),zc=Vn(Qc||(Qc=Q(["\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"]))),Xc=(Vn(Vc||(Vc=Q(['\n query ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n ...ContactCardFragment\n }\n }\n }\n }\n ',"\n"],['\n query ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n ...ContactCardFragment\n }\n }\n }\n }\n ',"\n"])),Hc),Vn(Wc||(Wc=Q(["\n query ContactCardQuery($id: LrRelayIdInput!) {\n contactCard(id: $id) {\n ...ContactCardFragment\n }\n }\n ","\n"],["\n query ContactCardQuery($id: LrRelayIdInput!) {\n contactCard(id: $id) {\n ...ContactCardFragment\n }\n }\n ","\n"])),Hc),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 q(this,void 0,void 0,(function(){var t,n,r,i,a;return J(this,(function(s){switch(s.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return t=s.sent(),[4,this.keyFactory.createKey()];case 2:return n=s.sent(),[4,this.keyGraph.encryptToString(t.jwk,n.toJSON(!0))];case 3:return r=s.sent(),[4,this.keyGraph.encryptToString(n,e.plainCipherDataJson)];case 4:return i=s.sent(),[4,this.prepareContactCardInput(e)];case 5:return a=s.sent(),[2,new Zr({mutation:Zc,variables:{input:Object.assign(Object.assign({},a),{wrappingKeyId:t.id,wrappedKey:r,cipherData:i})}})]}}))}))},e.prototype.updateContactCard=function(e){return q(this,void 0,void 0,(function(){var t,n;return J(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 Zr({mutation:Yc,variables:{input:Object.assign(Object.assign({},n),{id:e.id,cipherData:t})}})]}}))}))},e.prototype.deleteContactCard=function(e){return new Zr({mutation:zc,variables:{input:{id:e}}})},e.prototype.prepareContactCardInput=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d;return J(this,(function(p){switch(p.label){case 0:return[4,this.keyService.getCurrentSigPxk()];case 1:return t=p.sent(),i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicDataJson)];case 2:return n=i.apply(r,[p.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicSearchableJson)];case 3:return a=o.apply(s,[p.sent()]),d=(u=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.plainDataJson)];case 4:return c=d.apply(u,[p.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:c}]}}))}))},e}(),e.ContactCard2Service.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new e.ContactCard2Service(w.ɵɵinject(De),w.ɵɵinject($e),w.ɵɵinject(Pe),w.ɵɵinject(Oe),w.ɵɵinject(en),w.ɵɵinject(w.NgZone))},token:e.ContactCard2Service,providedIn:"root"}),e.ContactCard2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ContactCard2Service.ctorParameters=function(){return[{type:De},{type:$e},{type:Pe},{type:Oe},{type:en},{type:n.NgZone}]},e.ContactCard2Service=U([Ur({ngZoneName:"ngZone"})],e.ContactCard2Service);var eu,tu,nu,ru,iu,au,su,ou,cu,uu,du,pu,lu,yu=Vn(eu||(eu=Q(["\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"]))),hu=Vn(tu||(tu=Q(["\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"]))),vu=Vn(nu||(nu=Q(["\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"]))),fu=Vn(ru||(ru=Q(["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),mu=Vn(iu||(iu=Q(["\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"]))),gu=Vn(au||(au=Q(["\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"]))),Su=Vn(su||(su=Q(["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),Iu=Vn(ou||(ou=Q(["\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"]))),Cu=Vn(cu||(cu=Q(["\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"]))),bu=Vn(uu||(uu=Q(["\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"]))),ku=Vn(du||(du=Q(["\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"]))),wu=Vn(pu||(pu=Q(["\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"]))),Ku=Vn(lu||(lu=Q(["\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"])));e.DirectoryLinkType=void 0,(e.DirectoryLinkType||(e.DirectoryLinkType={})).HARD="HARD",e.Item2Service=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.fileService=r,c.keyService=i,c.keyMeta=a,c.keyFactory=s,c.keyGraph=o,c}return L(t,e),t.prototype.downloadFileContent=function(e){return q(this,void 0,void 0,(function(){var t,n,r=this;return J(this,(function(i){switch(i.label){case 0:return[4,this.fileService.downloadEncryptedFile2(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:"ArrayBuffer"})]}}))}))},t.prototype.createDirectory=function(e){var t,n;return q(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,d,p,l,y,h=this;return J(this,(function(v){switch(v.label){case 0:return[4,this.keyFactory.createKey()];case 1:if(r=v.sent(),e.parentDirectories=e.parentDirectories||[],!e.asRootDirectory&&!(null===(t=e.parentDirectories)||void 0===t?void 0:t.length))throw new ee("A new directory must be either a root directory or a sub-directory. So you must provide either parentDirectories and/or asRootDirectory parameter.");return[4,Promise.all(null===(n=e.parentDirectories)||void 0===n?void 0:n.map((function(e){return h.getParentDirectoryInput(e,r)})))];case 2:return i=v.sent(),e.asRootDirectory?(s=this.keyService.getCurrentRootKey(),o={wrappingKeyId:s.id},[4,this.keyGraph.wrapKey(s,r)]):[3,4];case 3:o.wrappedKey=v.sent(),a=o,v.label=4;case 4:return d=(u=Object).assign,l=(p=Object).assign,y=[{}],[4,this.getInput(r,e)];case 5:return c=d.apply(u,[l.apply(p,y.concat([v.sent()])),{parentDirectories:i,parentRootDirectory:a}]),[2,new Zr({mutation:fu,variables:{input:c}})]}}))}))},t.prototype.updateDirectoryExec=function(e){return this.mutate(this.updateDirectoryMutation(e))},t.prototype.updateDirectory=function(e){return this.updateDirectoryMutation(e)},t.prototype.updateDirectoryMutation=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return J(this,(function(d){switch(d.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=d.sent(),n=Zr.bind,r={mutation:mu},i={},s=(a=Object).assign,c=(o=Object).assign,u=[{}],[4,this.getInput(t.jwk,e)];case 2:return[2,new(n.apply(Zr,[void 0,(r.variables=(i.input=s.apply(a,[c.apply(o,u.concat([d.sent()])),{directoryId:e.directoryId}]),i),r)]))]}}))}))},t.prototype.deleteDirectory=function(e){return new Zr({mutation:gu,variables:{input:{directoryId:e}}})},t.prototype.createFile=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d,p=this;return J(this,(function(l){switch(l.label){case 0:return[4,this.keyFactory.createKey()];case 1:return t=l.sent(),[4,Promise.all(e.parentDirectories.map((function(e){return q(p,void 0,void 0,(function(){var n,r,i,a;return J(this,(function(s){switch(s.label){case 0:return[4,this.getParentDirectoryInput(e,t)];case 1:return n=s.sent(),r=n.directoryId,i=n.wrappingKeyId,a=n.wrappedKey,[2,{directoryId:r,wrappingKeyId:i,wrappedFileKey:a}]}}))}))})))];case 2:return n=l.sent(),r=Zr.bind,i={mutation:Su},a={},o=(s=Object).assign,u=(c=Object).assign,d=[{}],[4,this.createFileState(t,e)];case 3:return[2,new(r.apply(Zr,[void 0,(i.variables=(a.input=o.apply(s,[u.apply(c,d.concat([l.sent()])),{parentDirectories:n}]),a),i)]))]}}))}))},t.prototype.updateFile=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return J(this,(function(d){switch(d.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=d.sent(),n=Zr.bind,r={mutation:Iu},i={},s=(a=Object).assign,c=(o=Object).assign,u=[{}],[4,this.createFileState(t.jwk,e)];case 2:return[2,new(n.apply(Zr,[void 0,(r.variables=(i.input=s.apply(a,[c.apply(o,u.concat([d.sent()])),{fileId:e.fileId}]),i),r)]))]}}))}))},t.prototype.deleteFile=function(e){return new Zr({mutation:Cu,variables:{input:{fileId:e}}})},t.prototype.getParentDirectoryInput=function(e,t){return q(this,void 0,void 0,(function(){var n,r;return J(this,(function(i){switch(i.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.wrappingKeyId)];case 1:return n=i.sent(),r={directoryId:e.directoryId,wrappingKeyId:n.id},[4,this.keyGraph.wrapKey(n,t)];case 2:return[2,(r.wrappedKey=i.sent(),r)]}}))}))},t.prototype.getFileStateKeyId=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.query({query:vu,variables:{id:e}})];case 1:return[2,t.sent().fileState.keyId]}}))}))},t.prototype.getDirectoryKeyId=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.query({query:yu,variables:{id:e}})];case 1:return[2,t.sent().directory.keyId]}}))}))},t.prototype.getFileKeyId=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.query({query:hu,variables:{id:e}})];case 1:return[2,t.sent().file.keyId]}}))}))},t.prototype.getDirectoryKey=function(e,t){return q(this,void 0,void 0,(function(){var n=this;return J(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getDirectoryKeyId(e)}))]}))}))},t.prototype.getFileKey=function(e,t){return q(this,void 0,void 0,(function(){var n=this;return J(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getFileKeyId(e)}))]}))}))},t.prototype.getInput=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a;return J(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)]}}))}))},t.prototype.createFileState=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,d,p,l,y;return J(this,(function(h){switch(h.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=h.sent(),(i=t.file)?[4,this.fileService.loadFile(t.file)]:[3,3];case 2:i=h.sent(),h.label=3;case 3:return(r=i)?[4,this.keyGraph.encryptToString(n,r)]:[3,9];case 4:return s=h.sent(),t.upload?[4,t.upload(s)]:[3,6];case 5:return a=h.sent(),[3,8];case 6:return[4,this.fileService.uploadEncryptedFile({encryptedContent:s})];case 7:a=h.sent(),h.label=8;case 8:console.log("contentResource",a),h.label=9;case 9:return c=(o=Object).assign,d=(u=Object).assign,p=[{}],[4,this.getInput(n,t)];case 10:return l=[d.apply(u,p.concat([h.sent()]))],y={},[4,this.keyGraph.wrapKey(e,n)];case 11:return[2,c.apply(o,l.concat([(y.wrappedStateKey=h.sent(),y.contentResource=a,y)]))]}}))}))},t.prototype.archiveDirectory=function(e,t){return new Zr({mutation:bu,variables:{input:{directoryId:e,recursive:t}}})},t.prototype.unarchiveDirectory=function(e,t){return new Zr({mutation:ku,variables:{input:{directoryId:e,recursive:t}}})},t.prototype.getChangeItemParentsInput=function(e,t){return q(this,void 0,void 0,(function(){var n,r=this;return J(this,(function(i){switch(i.label){case 0:return[4,Promise.all(e.parentsToAdd.map((function(e){return r.getParentDirectoryInput(e,t)})))];case 1:return n=i.sent(),[2,{directoriesToRemove:e.parentsToRemove,directoriesToAdd:n}]}}))}))},t.prototype.changeDirectoryParents=function(e){return this.mutate(this.changeDirectoryParentsMutation(e))},t.prototype.changeDirectoryParentsMutation=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return J(this,(function(d){switch(d.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=d.sent(),n=Zr.bind,r={mutation:wu},i={},s=(a=Object).assign,c=(o=Object).assign,u=[{}],[4,this.getChangeItemParentsInput(e,t.jwk)];case 2:return[2,new(n.apply(Zr,[void 0,(r.variables=(i.input=s.apply(a,[c.apply(o,u.concat([d.sent()])),{directoryId:e.directoryId}]),i),r)]))]}}))}))},t.prototype.changeFileParents=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.mutate(this.changeFileParentsMutation(e))]}))}))},t.prototype.changeFileParentsMutation=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return J(this,(function(d){switch(d.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=d.sent(),n=Zr.bind,r={mutation:Ku},i={},s=(a=Object).assign,c=(o=Object).assign,u=[{}],[4,this.getChangeItemParentsInput(e,t.jwk)];case 2:return[2,new(n.apply(Zr,[void 0,(r.variables=(i.input=s.apply(a,[c.apply(o,u.concat([d.sent()])),{fileId:e.fileId}]),i),r)]))]}}))}))},t}(ti),e.Item2Service.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new e.Item2Service(w.ɵɵinject(w.NgZone),w.ɵɵinject(w.INJECTOR),w.ɵɵinject(ii),w.ɵɵinject($e),w.ɵɵinject(en),w.ɵɵinject(De),w.ɵɵinject(Oe))},token:e.Item2Service,providedIn:"root"}),e.Item2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.Item2Service.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:ii},{type:$e},{type:en},{type:De},{type:Oe}]},e.Item2Service=U([Ur({ngZoneName:"ngZone"})],e.Item2Service);var Pu,Ru,Du,Au,Eu,$u,Ou,ju,Tu,Mu,Fu,Nu=Vn(Pu||(Pu=Q(["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\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}\n"],["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\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}\n"]))),Lu=Vn(Ru||(Ru=Q(["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"],["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"]))),xu=Vn(Du||(Du=Q(["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n","\n"],["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n","\n"])),Nu),Uu=Vn(Au||(Au=Q(["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n","\n"],["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n","\n"])),Nu),qu=Vn(Eu||(Eu=Q(["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ...KeyExchangeFragment\n }\n}\n","\n"],["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ...KeyExchangeFragment\n }\n}\n","\n"])),Nu),Ju=Vn($u||($u=Q(["\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"]))),_u=Vn(Ou||(Ou=Q(["\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"]))),Gu=Vn(ju||(ju=Q(["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n }\n}\n","\n"],["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n }\n}\n","\n"])),Nu),Bu=Vn(Tu||(Tu=Q(["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"],["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"])),Nu,Lu),Qu=Vn(Mu||(Mu=Q(["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"],["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"])),Nu,Lu),Vu=Vn(Fu||(Fu=Q(["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ...UserSharedKeyFragment\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 ...UserSharedKeyFragment\n }\n }\n}\n","\n"])),Lu);e.KeyExchange2Service=function(){function t(e,t,n,r,i,a,s){this.ngZone=e,this.keyFactory=t,this.keyService=n,this.encryptionService=r,this.userService=i,this.keyGraph=a,this.lrGraphQL=s,this.CLIENT_NONCE_LENGTH=32}return t.prototype.getOtKey=function(t,n){return q(this,void 0,void 0,(function(){var r,i;return J(this,(function(a){switch(a.label){case 0:return n?[4,De.asKey(Object.assign(Object.assign({},JSON.parse(t.otk.otKeyParams)),{k:n}))]:[3,2];case 1:return[2,a.sent()];case 2:return"OTK_INITIATED"!==t.otk.state||t.isInitiator||!t.otk.responderPbkCipher?[3,6]:[4,this.keyService.getCurrentPxk()];case 3:return r=a.sent(),[4,this.encryptionService.decrypt(r.jwk,JSON.parse(t.otk.responderPbkCipher),{serializations:[e.JoseSerialization.COMPACT]})];case 4:return(i=a.sent()).otKey?[4,De.asKey(i.otKey)]:[3,6];case 5:return[2,a.sent()];case 6:return[2,null]}}))}))},t.prototype.decryptOtk=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o;return J(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 q(this,void 0,void 0,(function(){var r;return J(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 q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d,p;return J(this,(function(l){switch(l.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return t=l.sent(),[4,this.encryptionService.decrypt(t.jwk,e.initiatorRootKeyCipher)];case 2:return n=l.sent(),[4,De.asKey(n.otKey)];case 3: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,d=[r],[4,De.asKey(n.oneTimePrk)]):[3,6];case 4:return[4,u.apply(this,d.concat([l.sent(),i.initiatorOneTimePbkCipher]))];case 5:i=s.apply(a,o.concat([(c.initiatorOneTimePbkCipherClearJson=l.sent(),c)])),l.label=6;case 6:return i.otKeyCipher?(p=i,[4,this.encryptionService.decrypt(r,i.otKeyCipher)]):[3,8];case 7:p.otKeyCipherClearJson=l.sent(),l.label=8;case 8:return[2,Object.assign(Object.assign({},e),{otk:i})]}}))}))},t.prototype.decryptKeyExchangeAsResponder=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){return[2,this.decryptOtk(e,t)]}))}))},t.prototype.decryptKeyExchange=function(e,t){return q(this,void 0,void 0,(function(){return J(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 q(this,void 0,void 0,(function(){var e,n=this;return J(this,(function(r){switch(r.label){case 0:return[4,this.lrGraphQL.query({query:xu,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 q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:i?qu:Uu,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 q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.lrGraphQL.query({query:Vu,variables:{username:e.username,userId:e.userId}})]}))}))},t.prototype.cancelKeyExchange=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.cancelKeyExchangeMutation(e)]}))}))},t.prototype.cancelKeyExchangeMutation=function(e){return new Zr({mutation:Ju,variables:{input:{id:e}}})},t.prototype.declineKeyExchange=function(e,t){return q(this,void 0,void 0,(function(){return J(this,(function(n){return[2,this.declineKeyExchangeMutation(e,t)]}))}))},t.prototype.declineKeyExchangeMutation=function(e,t){return new Zr({mutation:_u,variables:{input:{id:e,token:t}}})},t.prototype.initiateOtk=function(e){var t=void 0===e?{}:e,n=t.message,r=t.email,i=t.contactCard,a=t.upgrade;return q(this,void 0,void 0,(function(){var e,t,s,o,c,u,d,p,l,y,h,v,f;return J(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(),[4,this.keyService.getCurrentPxk()];case 3:return o=m.sent(),[4,this.keyService.getCurrentSigPxk()];case 4:return c=m.sent(),u=null,i&&i.ownerPlainDataJson?[4,this.encryptionService.signToString(c.jwk,i.ownerPlainDataJson)]:[3,6];case 5:u=m.sent(),m.label=6;case 6:return d={message:n,contactCard:i&&{sharedCipherDataClearJson:i.sharedCipherDataClearJson}},p={nonce:t,initiator:Object.assign(Object.assign({},d),{oneTimePbk:s.toJSON(),pbk:o.jwk.toJSON(),sigPbk:c.jwk.toJSON()})},[4,this.keyGraph.encryptToString(e,p)];case 7:return l=m.sent(),y={nonce:t,oneTimePrk:s.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:i,initiator:d},[4,this.keyService.getCurrentRootKey()];case 8:return h=m.sent(),[4,this.keyGraph.encryptToString(h.jwk,y)];case 9:return v=m.sent(),f=e.toJSON(!0).k,[2,{lrMutation:new Zr({mutation:Gu,variables:{input:{initiatorRootKeyCipher:v,initiatorPxkId:o.id,initiatorSigPxkId:c.id,otKeyParams:JSON.stringify(e.toJSON()),otKeyCipher:l,sendEmail:r&&{email:r,rawOtKey:f},createTp:!0,initiatorPlainDataSig:u,upgrade:a}}}),otKeyK:f}]}}))}))},t.prototype.respondOtk=function(e){var t=e.keyExchangeId,n=e.token,r=e.decryptedOtk,i=e.message,a=e.initiatorContactCard,s=e.responderContactCard;return q(this,void 0,void 0,(function(){var e,o,c,u,d,p,l,y,h,v,f,m,g,S,I,C,b,k,w,K,P,R,D,A,E,$,O,j,T,M,F,N,L,x,U,q,_,G,B,Q,V,W,H,Z,Y,z,X,ee,te;return J(this,(function(J){switch(J.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return e=J.sent(),o=this.keyService.getCurrentMasterKey().id,[4,this.keyService.getCurrentMasterKey()];case 2:return c=J.sent(),[4,this.keyFactory.createKey()];case 3:return u=J.sent(),[4,this.keyFactory.createKey()];case 4:return d=J.sent(),[4,this.encryptionService.encrypt(e.jwk,u.toJSON(!0))];case 5:return p=J.sent(),[4,this.encryptionService.encrypt(c.jwk,d.toJSON(!0))];case 6:return l=J.sent(),[4,De.asKey(r.otKeyCipherClearJson.initiator.oneTimePbk)];case 7:return y=J.sent(),[4,De.asKey(r.otKeyCipherClearJson.initiator.pbk)];case 8:return h=J.sent(),[4,De.asKey(r.otKeyCipherClearJson.initiator.sigPbk)];case 9:return v=J.sent(),[4,this.keyService.getCurrentPxk()];case 10:return f=J.sent(),[4,this.keyService.getCurrentSigPxk()];case 11:return m=J.sent(),[4,this.encryptionService.sign(m.jwk,h.toJSON())];case 12:return g=J.sent(),[4,this.encryptionService.sign(m.jwk,v.toJSON())];case 13:return S=J.sent(),I={nonce:r.otKeyCipherClearJson.nonce,sharedKey:u.toJSON(!0),mkSharedKey:d.toJSON(!0),responder:{pbk:f.jwk.toJSON(),sigPbk:m.jwk.toJSON(),message:i}},r.otKeyCipherClearJson.initiator.contactCard?(b=r.otKeyCipherClearJson.initiator.contactCard.sharedCipherDataClearJson,[4,this.keyFactory.createKey()]):[3,24];case 14:return k=J.sent(),[4,this.keyFactory.createKey()];case 15:return N=J.sent(),[4,this.keyService.getCurrentSigPxk()];case 16:return L=J.sent(),w={},P=(K=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,k.toJSON(!0))];case 17:return w.receiverWrappedKey=P.apply(K,[J.sent()]),w.receiverWrappingKeyId=e.id,a?(A=(D=JSON).stringify,[4,this.encryptionService.encrypt(k,a.receiverCipherDataClearJson)]):[3,19];case 18:return R=A.apply(D,[J.sent()]),[3,20];case 19:R="",J.label=20;case 20:return w.receiverCipherData=R,$=(E=JSON).stringify,[4,this.encryptionService.encrypt(u,N.toJSON(!0))];case 21:return w.sharedWrappedKey=$.apply(E,[J.sent()]),C=w,[4,this.encryptionService.encrypt(N,b)];case 22:return W=J.sent(),O=C,T=(j=JSON).stringify,[4,this.encryptionService.sign(L.jwk,W)];case 23:O.sharedCipherDataSig=T.apply(j,[J.sent()]),C.sigPxkId=L.id,I.responder.contactCard=Object.assign(Object.assign({},I.responder.contactCard),{sharedCipherKey:N.toJSON(!0)}),J.label=24;case 24:return s?[4,this.keyFactory.createKey()]:[3,37];case 25:return F=J.sent(),[4,this.keyFactory.createKey()];case 26:return N=J.sent(),[4,this.keyService.getCurrentSigPxk()];case 27:return L=J.sent(),x={},q=(U=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,F.toJSON(!0))];case 28:return x.ownerWrappedKey=q.apply(U,[J.sent()]),x.ownerWrappingKeyId=e.id,s.ownerCipherDataClearJson?(B=(G=JSON).stringify,[4,this.encryptionService.encrypt(F,s.ownerCipherDataClearJson)]):[3,30];case 29:return _=B.apply(G,[J.sent()]),[3,31];case 30:_="",J.label=31;case 31:return x.ownerCipherData=_,V=(Q=JSON).stringify,[4,this.encryptionService.encrypt(u,N.toJSON(!0))];case 32:return x.sharedWrappedKey=V.apply(Q,[J.sent()]),M=x,[4,this.encryptionService.encrypt(N,s.sharedCipherDataClearJson)];case 33:return W=J.sent(),H=M,Y=(Z=JSON).stringify,[4,this.encryptionService.sign(L.jwk,W)];case 34:return H.sharedCipherDataSig=Y.apply(Z,[J.sent()]),M.sigPxkId=L.id,s.ownerPlainDataJson?(z=M,ee=(X=JSON).stringify,[4,this.encryptionService.sign(m.jwk,s.ownerPlainDataJson)]):[3,36];case 35:z.ownerPlainDataSig=ee.apply(X,[J.sent()]),J.label=36;case 36:I.responder.contactCard=Object.assign(Object.assign({},I.responder.contactCard),{sharedCipherDataClearJson:s.sharedCipherDataClearJson}),J.label=37;case 37:return[4,this.encryptionService.encrypt(y,I)];case 38:return te=J.sent(),[4,this.encryptionService.encrypt(r.otKey,te)];case 39:return te=J.sent(),[2,new Zr({mutation:Bu,variables:{input:{keyExchangeId:t,keyExchangeToken:n,rootKeyId:e.id,masterKeyId:o,responderPxkId:f.id,responderSigPxkId:m.id,signedInitiatorPbk:JSON.stringify(g),signedInitiatorSigPbk:JSON.stringify(S),rkWrappedSharedKey:JSON.stringify(p),mkWrappedMkSharedKey:JSON.stringify(l),initiatorOneTimePbkCipher:JSON.stringify(te),initiatorContactCard:C,responderContactCard:M}}})]}}))}))},t.prototype.completeOtk=function(e){var t=e.keyExchangeId,n=e.initiatorRootKeyCipher,r=e.initiatorOneTimePbkCipher,i=e.responderContactCard,a=e.initiatorContactCard;return q(this,void 0,void 0,(function(){var e,s,o,c,u,d,p,l,y,h,v,f,m,g,S,I,C,b,k,w,K,P,R,D,A,E,$,O,j,T,M,F,N,L,x,U,q;return J(this,(function(J){switch(J.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return e=J.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return s=J.sent(),[4,this.encryptionService.decrypt(e.jwk,n)];case 3:return o=J.sent(),u=this.decryptResponseCipher,[4,De.asKey(o.otKey)];case 4:return d=[J.sent()],[4,De.asKey(o.oneTimePrk)];case 5:return[4,u.apply(this,d.concat([J.sent(),r]))];case 6:if(c=J.sent(),o.nonce!==c.nonce)throw new ie("The nonce returned by responder does not match with the one created by the initiator.");return[4,this.keyService.getCurrentSigPxk()];case 7:return p=J.sent(),[4,De.asKey(c.responder.sigPbk)];case 8:return l=J.sent(),[4,De.asKey(c.responder.pbk)];case 9:return y=J.sent(),[4,this.encryptionService.sign(p.jwk,y.toJSON())];case 10:return h=J.sent(),[4,this.encryptionService.sign(p.jwk,l.toJSON())];case 11:return v=J.sent(),[4,De.asKey(c.sharedKey)];case 12:return f=J.sent(),[4,this.encryptionService.encrypt(e.jwk,f.toJSON(!0))];case 13:return m=J.sent(),[4,De.asKey(c.mkSharedKey)];case 14:return g=J.sent(),[4,this.encryptionService.encrypt(s.jwk,g.toJSON(!0))];case 15:return S=J.sent(),i?[4,this.keyFactory.createKey()]:[3,19];case 16:return C=J.sent(),b={},w=(k=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,C.toJSON(!0))];case 17:return b.receiverWrappedKey=w.apply(k,[J.sent()]),b.receiverWrappingKeyId=e.id,P=(K=JSON).stringify,[4,this.encryptionService.encrypt(C,i.receiverCipherDataClearJson)];case 18:b.receiverCipherData=P.apply(K,[J.sent()]),I=b,J.label=19;case 19:return o.initiatorContactCard?(A=o.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,28];case 20:return E=J.sent(),[4,De.asKey(c.responder.contactCard.sharedCipherKey)];case 21:return $=J.sent(),T=(j=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,E.toJSON(!0))];case 22:return O=T.apply(j,[J.sent()]),(M=(null==a?void 0:a.ownerCipherDataClearJson)||A.ownerCipherDataClearJson)?[4,this.keyGraph.encryptToString(E,M)]:[3,24];case 23:return N=J.sent(),[3,25];case 24:N="",J.label=25;case 25:return F=N,R={ownerWrappedKey:O,ownerWrappingKeyId:e.id,ownerCipherData:F},D={sigPxkId:p.id},[4,this.encryptionService.encrypt($,A.sharedCipherDataClearJson)];case 26:return L=J.sent(),x=D,q=(U=JSON).stringify,[4,this.encryptionService.sign(p.jwk,L)];case 27:x.sharedCipherDataSig=q.apply(U,[J.sent()]),J.label=28;case 28:return[2,new Zr({mutation:Qu,variables:{input:{keyExchangeId:t,rootKeyId:e.id,masterKeyId:s.id,initiatorSigPxkId:p.id,signedResponderPbk:JSON.stringify(h),signedResponderSigPbk:JSON.stringify(v),rkWrappedSharedKey:JSON.stringify(m),mkWrappedMkSharedKey:JSON.stringify(S),responderContactCardCipher:I,initiatorContactCardCipher:R,initiatorContactCardSharedCipher:D}}})]}}))}))},t}(),e.KeyExchange2Service.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new e.KeyExchange2Service(w.ɵɵinject(w.NgZone),w.ɵɵinject(De),w.ɵɵinject($e),w.ɵɵinject(Pe),w.ɵɵinject(yi),w.ɵɵinject(Oe),w.ɵɵinject(e.ɵb))},token:e.KeyExchange2Service,providedIn:"root"}),e.KeyExchange2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.KeyExchange2Service.ctorParameters=function(){return[{type:n.NgZone},{type:De},{type:$e},{type:Pe},{type:yi},{type:Oe},{type:e.ɵb}]},e.KeyExchange2Service=U([Ur({ngZoneName:"ngZone"})],e.KeyExchange2Service);var Wu,Hu,Zu,Yu,zu=Vn(Wu||(Wu=Q(["\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}"]))),Xu=Vn(Hu||(Hu=Q(["\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}"]))),ed=Vn(Zu||(Zu=Q(["\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}"]))),td=Vn(Yu||(Yu=Q(["\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 q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:ed,variables:{id:e}})];case 1:return[2,{sharedKeyId:(t=n.sent().ownedContactCard).sharedKey.id,ownerKeyId:t.ownerKey.id}]}}))}))},e.prototype.getReceivedContactCardKeyId=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:td,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 q(this,void 0,void 0,(function(){var e,o,c,u,d,p,l,y,h,v,f,m;return J(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[4,this.keyService.getCurrentSigPxk()];case 8:return u=g.sent(),[4,this.encryptionService.encrypt(o.jwk,s)];case 9:return d=g.sent(),y=(l=JSON).stringify,[4,this.encryptionService.sign(u.jwk,d)];case 10:return p=y.apply(l,[g.sent()]),f=(v=JSON).stringify,[4,this.encryptionService.sign(u.jwk,i)];case 11:return h=f.apply(v,[g.sent()]),[4,this.encryptionService.encryptToString(e.jwk,a)];case 12:return m=g.sent(),[2,new Zr({mutation:zu,variables:{input:{id:t,ownerCipherData:m,ownerKeyId:e.id,sharedCipherDataSig:p,sharedKeyId:o.id,sigPxkId:u.id,ownerPlainDataSig:h}}})]}}))}))},e.prototype.updateReceivedContactCard=function(e){var t=e.id,n=e.receiverKeyId,r=e.receiverCipherDataClearJson;return q(this,void 0,void 0,(function(){var e,i,a=this;return J(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 Zr({mutation:Xu,variables:{input:{id:t,receiverCipherData:i,receiverKeyId:e.id}}})]}}))}))},e}(),e.SharedContactCard2Service.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new e.SharedContactCard2Service(w.ɵɵinject(w.NgZone),w.ɵɵinject($e),w.ɵɵinject(Oe),w.ɵɵinject(Pe),w.ɵɵinject(e.ɵb))},token:e.SharedContactCard2Service,providedIn:"root"}),e.SharedContactCard2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.SharedContactCard2Service.ctorParameters=function(){return[{type:n.NgZone},{type:$e},{type:Oe},{type:Pe},{type:e.ɵb}]},e.SharedContactCard2Service=U([Ur({ngZoneName:"ngZone"})],e.SharedContactCard2Service);var nd,rd,id,ad,sd=Vn(nd||(nd=Q(["\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}"]))),od=Vn(rd||(rd=Q(["\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"])),sd),cd=Vn(id||(id=Q(["\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"])),sd),ud=Vn(ad||(ad=Q(["\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"])),sd);e.LockService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return L(t,e),t.prototype.updateLockMutation=function(e,t){return new Zr({mutation:od,variables:{input:{resourceId:e,version:t}}})},t.prototype.acquireLockMutation=function(e,t){return new Zr({mutation:cd,variables:{input:{resourceId:e,timeoutMs:t}}})},t.prototype.releaseLockMutation=function(e,t){return new Zr({mutation:ud,variables:{input:{resourceId:e,version:t}}})},t}(ti),e.LockService.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new e.LockService(w.ɵɵinject(w.NgZone),w.ɵɵinject(w.INJECTOR))},token:e.LockService,providedIn:"root"}),e.LockService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.LockService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector}]},e.LockService=U([Ur({ngZoneName:"ngZone"})],e.LockService);var dd,pd,ld,yd,hd,vd,fd,md,gd,Sd,Id=Vn(dd||(dd=Q(["\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"]))),Cd=Vn(pd||(pd=Q(["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"],["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"]))),bd=Vn(ld||(ld=Q(["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"],["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"]))),kd=Vn(yd||(yd=Q(["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"],["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"]))),wd=Vn(hd||(hd=Q(["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"],["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"]))),Kd=Vn(vd||(vd=Q(["\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"]))),Pd=Vn(fd||(fd=Q(["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"]))),Rd=Vn(md||(md=Q(["\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"]))),Dd=Vn(gd||(gd=Q(["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"])));e.TrustedParty2Service=function(){function e(e,t,n,r,i,a,s){this.ngZone=e,this.keyGraph=t,this.lrGraphQL=n,this.item2Service=r,this.keyService=i,this.keyFactory=a,this.encryptionService=s}return e.prototype.deleteTp=function(e){return this.deleteTpMutation(e)},e.prototype.deleteTpMutation=function(e){return new Zr({mutation:Id,variables:{input:{id:e}}})},e.prototype.getTpCurrentUserSharedKey=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:Kd,variables:{id:e}})];case 1:return[2,t.sent().tp.currentUserSharedKey.userSharedKey]}}))}))},e.prototype.shareDirectory=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.shareItem(Object.assign(Object.assign({},e),{isDirectory:!0}))]}))}))},e.prototype.shareFile=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.shareItem(Object.assign(Object.assign({},e),{isDirectory:!1}))]}))}))},e.prototype.shareItem=function(e){var t=e.itemId,n=e.itemKeyId,r=e.tpId,i=e.tpSharedKeyId,a=e.accessRole,s=e.isDirectory;return q(this,void 0,void 0,(function(){var e,o,c,u=this;return J(this,(function(d){switch(d.label){case 0:return[4,this.keyGraph.getKey(n,(function(){return s?u.item2Service.getDirectoryKeyId(t):u.item2Service.getFileKeyId(t)}))];case 1:return e=d.sent(),[4,this.keyGraph.getKey(i,(function(){return u.getTpCurrentUserSharedKey(r).then((function(e){return e.sharedKey.id}))}))];case 2:return o=d.sent(),[4,this.keyGraph.wrapKey(o,e.jwk)];case 3:return c=d.sent(),[2,new Zr({mutation:s?Cd:kd,variables:{input:{id:t,tpId:r,accessRole:a,keyId:e.id,wrappingKeyId:o.id,wrappedKey:c}}})]}}))}))},e.prototype.unshareDirectory=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.unshareItem(Object.assign(Object.assign({},e),{isDirectory:!0}))]}))}))},e.prototype.unshareFile=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){return[2,this.unshareItem(Object.assign(Object.assign({},e),{isDirectory:!1}))]}))}))},e.prototype.unshareItem=function(e){var t=e.itemId,n=e.tpId,r=e.isDirectory;return q(this,void 0,void 0,(function(){return J(this,(function(e){return[2,new Zr({mutation:r?bd:wd,variables:{input:{id:t,tpId:n}}})]}))}))},e.prototype.requestMkReshare=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s;return J(this,(function(o){switch(o.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if((t=o.sent()).mkSharedKey)throw new ye("TP already has mkSharedKey");return[4,this.keyService.getCurrentMasterKey()];case 2:return n=o.sent(),[4,this.keyFactory.createPkcKey()];case 3:return r=o.sent(),[4,this.encryptionService.encryptToString(n.jwk,r.toJSON(!0))];case 4:return i=o.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 5:return a=o.sent(),[4,this.encryptionService.encryptToString(a.jwk,{pbk:r.toJSON()})];case 6:return s=o.sent(),[4,new Zr({mutation:Pd,variables:{input:{tpId:e,masterKeyId:n.id,mkPbk:JSON.stringify(r.toJSON()),mkWrappedMkPrk:i,sharedKeyId:a.id,mkReshareRequestCipher:s}}})];case 7:return[2,o.sent()]}}))}))},e.prototype.respondMkReshare=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return J(this,(function(l){switch(l.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if(!(t=l.sent()).mkSharedKey)throw new ye("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,d.JWK.asKey(r.pbk)];case 4:return i=l.sent(),[4,this.keyGraph.getKey(t.mkSharedKey.id)];case 5:return a=l.sent(),s={mkSharedKey:{id:a.id,jwk:a.jwk.toJSON(!0)}},u=(c=this.encryptionService).encryptToString,p=[i],[4,this.encryptionService.encryptToString(n.jwk,s)];case 6:return[4,u.apply(c,p.concat([l.sent()]))];case 7:return o=l.sent(),[2,new Zr({mutation:Rd,variables:{input:{tpId:e,mkSharedKeyId:a.id,mkReshareResponseCipher:o}}})]}}))}))},e.prototype.completeMkReshare=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,l;return J(this,(function(y){switch(y.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:return t=y.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 2:return n=y.sent(),[4,this.keyGraph.getKey(t.mkPxk.id)];case 3:return r=y.sent(),s=(a=this.encryptionService).decrypt,o=[n],[4,this.encryptionService.decrypt(r,t.mkReshareResponseCipher)];case 4:return[4,s.apply(a,o.concat([y.sent()]))];case 5:return i=y.sent(),u={id:i.mkSharedKey.id},[4,d.JWK.asKey(i.mkSharedKey.jwk)];case 6:return u.jwk=y.sent(),c=u,[4,this.keyService.getCurrentMasterKey()];case 7:return p=y.sent(),[4,this.encryptionService.encryptToString(p.jwk,c.jwk.toJSON(!0))];case 8:return l=y.sent(),[2,new Zr({mutation:Dd,variables:{input:{tpId:e,masterKeyId:p.id,mkSharedKeyId:c.id,mkWrappedMkSharedKey:l}}})]}}))}))},e}(),e.TrustedParty2Service.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new e.TrustedParty2Service(w.ɵɵinject(w.NgZone),w.ɵɵinject(Oe),w.ɵɵinject(e.ɵb),w.ɵɵinject(e.Item2Service),w.ɵɵinject($e),w.ɵɵinject(De),w.ɵɵinject(Pe))},token:e.TrustedParty2Service,providedIn:"root"}),e.TrustedParty2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.TrustedParty2Service.ctorParameters=function(){return[{type:n.NgZone},{type:Oe},{type:e.ɵb},{type:e.Item2Service},{type:$e},{type:De},{type:Pe}]},e.TrustedParty2Service=U([Ur({ngZoneName:"ngZone"})],e.TrustedParty2Service);var Ad,Ed,$d,Od,jd,Td,Md,Fd,Nd,Ld,xd=function(){},Ud=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return L(t,e),t}(xd),qd=function(){},Jd=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return L(t,e),t}(qd);e.TpPasswordResetService=Sd=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.keyService=r,c.keyFactory=i,c.encryptionService=a,c.keyGraph=s,c.slip39Service=o,c}return L(t,e),t.prototype.getReset=function(){return q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return[4,this.query({query:Or})];case 1:return[2,e.sent().tpPasswordReset]}}))}))},t.prototype.createReset=function(e){return this.mutate(this.createResetMutation(e))},t.prototype.createResetMutation=function(e){return q(this,void 0,void 0,(function(){var t,n=this;return J(this,(function(r){switch(r.label){case 0:return[4,this._createReset(e,(function(t){return q(n,void 0,void 0,(function(){return J(this,(function(n){return[2,this.prepareSlip39(e.createSubAssemblies,e.quorum,t)]}))}))}))];case 1:return t=r.sent().mutationInput,[2,new Zr({mutation:jr,variables:{input:t}})]}}))}))},t.prototype.deleteReset=function(){return this.mutate(this.deleteResetMutation())},t.prototype.deleteResetMutation=function(){return new Zr({mutation:Tr})},t.prototype.updateReset=function(e){return this.mutate(this.updateResetMutation(e))},t.prototype.updateResetMutation=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c=this;return J(this,(function(u){switch(u.label){case 0:return[4,this.getReset()];case 1:return t=u.sent(),[4,this._createReset(e,(function(t){return q(c,void 0,void 0,(function(){return J(this,(function(n){return[2,this.prepareSlip39(e.createSubAssemblies.concat(e.updateSubAssemblies),e.quorum,t)]}))}))}))];case 2:return n=u.sent(),r=n.mutationInput,i=n.subjectKey,a=n.slipAssembly,s=n.assemblyKeyParams,[4,Promise.all(e.updateSubAssemblies.map((function(n,r){return q(c,void 0,void 0,(function(){var o,c,u,d,p,l=this;return J(this,(function(y){switch(y.label){case 0:return[4,this.encryptionService.encryptToString(i,{name:n.name})];case 1:return o=y.sent(),c=t.assembly.subAssemblies.edges.find((function(e){return e.node.id===n.id})).node,u=[],d=[],n.approverTps.forEach((function(e){var t,n=null===(t=c.approvers.edges.find((function(t){return t.node.tp.id===e.id})))||void 0===t?void 0:t.node;n?d.push({tp:e,approverId:n.id}):u.push({tp:e})})),p={subAssemblyId:n.id,singleReject:n.singleReject,quorum:n.quorum,subjectCipherData:o},[4,Promise.all(u.map((function(t,n){var o=t.tp;return q(l,void 0,void 0,(function(){return J(this,(function(t){return[2,this.prepareApprover({tp:o,approverIndex:n,saIndex:r+e.createSubAssemblies.length,slipAssembly:a,assemblyKeyParams:s,subjectKey:i})]}))}))})))];case 2:return p.createApprovers=y.sent(),[4,Promise.all(d.map((function(t,n){var o=t.tp,c=t.approverId;return q(l,void 0,void 0,(function(){return J(this,(function(t){return[2,this.prepareApprover({approverId:c,tp:o,approverIndex:n+u.length,saIndex:r+e.createSubAssemblies.length,slipAssembly:a,assemblyKeyParams:s,subjectKey:i})]}))}))})))];case 3:return[2,(p.updateApprovers=y.sent(),p)]}}))}))})))];case 3:return o=u.sent(),[2,new Zr({mutation:Mr,variables:{input:Object.assign(Object.assign({},r),{assembly:Object.assign(Object.assign({},r.assembly),{updateSubAssemblies:o})})}})]}}))}))},t.prototype.cancelResetRequest=function(){return this.mutate(this.cancelResetRequestMutation())},t.prototype.cancelResetRequestMutation=function(){return new Zr({mutation:Kr})},t.prototype.validateApprovers=function(e){var t,n;try{for(var r=_(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 ee(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.prepareApprover=function(e){var t=e.approverId,n=e.tp,r=e.approverIndex,i=e.saIndex,a=e.slipAssembly,s=e.assemblyKeyParams,o=e.subjectKey;return q(this,void 0,void 0,(function(){var e,c,u,d,p,l,y,h;return J(this,(function(v){switch(v.label){case 0:if(!n.currentUserSharedKey.userSharedKey.mkSharedKey)throw new ee("Tp "+n.other.username+" does not have mkSharedKey. Need to reshared it first.");return[4,this.keyFactory.createKey()];case 1:return e=v.sent(),[4,this.keyGraph.getKey(n.currentUserSharedKey.userSharedKey.mkSharedKey.id)];case 2:return c=v.sent(),[4,this.encryptionService.encryptToString(c.jwk,e.toJSON(!0))];case 3:return u=v.sent(),[4,this.encryptionService.encryptToString(o,e.toJSON(!0))];case 4:if(d=v.sent(),(p=a.subAssemblies[i]).index!==i)throw new re("slip sub assembly index should match with array index");return l=1===p.threshold?p.shares[0]:p.shares[r],y={slip39:{share:l,subAssembly:{quorum:p.threshold,size:p.size}},assemblyKeyParams:s},console.log("partialAssemblyKey",y),h={tpMkSharedKeyId:c.id,tpMkSharedKeyWrappedSharedKey:u,subjectKeyWrappedSharedKey:d},[4,this.encryptionService.encryptToString(e,{a:"123"})];case 5:return h.sharedCipherData=v.sent(),h.sharedCipherApprovalData="",[4,this.encryptionService.encryptToString(e,y)];case 6:return[2,(h.sharedCipherPartialAssemblyKey=v.sent(),h.approverId=t||void 0,h.tpId=t?void 0:n.id,h)]}}))}))},t.prototype.prepareSlip39=function(e,t,n){return q(this,void 0,void 0,(function(){var r;return J(this,(function(i){switch(i.label){case 0:if(e.length<t)throw new ee("Not enough sub assemblies to meet quorum");return r=new ta(t),e.forEach((function(e,t){var n=e.approverTps.length;1===e.quorum&&(n=1),r.addSubAssembly(new ea(t,e.quorum,n))})),[4,this.slip39Service.generateShares(n,Sd.SLIP39_PASSPHRASE,r)];case 1:return i.sent(),[2,r]}}))}))},t.prototype._createReset=function(e,t){return q(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,d,p,l,y,h,v,f=this;return J(this,(function(m){switch(m.label){case 0:return[4,this.keyService.getCurrentMasterKey()];case 1:return n=m.sent(),[4,this.keyFactory.createKey()];case 2:return r=m.sent(),[4,this.keyFactory.createKey()];case 3:return i=m.sent(),a=i.toJSON(!0),s=a.k,o=x(a,["k"]),[4,this.keyFactory.createPkcSignKey()];case 4:return c=m.sent(),[4,this.encryptionService.encryptToString(i,c.toJSON(!0))];case 5:return u=m.sent(),[4,this.encryptionService.encryptToString(n.jwk,r.toJSON(!0))];case 6:return d=m.sent(),[4,this.encryptionService.encryptToString(r,i.toJSON(!0))];case 7:return p=m.sent(),[4,this.keyService.getCurrentRootKey()];case 8:return l=m.sent(),[4,this.encryptionService.encryptToString(i,{rootKey:l.jwk.toJSON(!0)})];case 9:return y=m.sent(),[4,t(s)];case 10:return h=m.sent(),[4,Promise.all(e.createSubAssemblies.map((function(e,t){return q(f,void 0,void 0,(function(){var n,i,a=this;return J(this,(function(s){switch(s.label){case 0:return[4,this.encryptionService.encryptToString(r,{name:e.name})];case 1:return n=s.sent(),i={singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:n},[4,Promise.all(e.approverTps.map((function(e,n){return q(a,void 0,void 0,(function(){return J(this,(function(i){return[2,this.prepareApprover({tp:e,approverIndex:n,saIndex:t,slipAssembly:h,assemblyKeyParams:o,subjectKey:r})]}))}))})))];case 2:return[2,(i.createApprovers=s.sent(),i)]}}))}))})))];case 11:return v=m.sent(),[2,{subjectKey:r,slipAssembly:h,assemblyKeyParams:o,mutationInput:{assembly:{singleReject:e.singleReject,quorum:e.quorum,masterKeyId:n.id,masterKeyWrappedSubjectKey:d,subjectKeyWrappedAssemblyKey:p,subjectCipherData:"",assemblyCipherData:y,createSubAssemblies:v,assemblyKeyVerifierPbk:JSON.stringify(c.toJSON()),wrappedAssemblyKeyVerifierPrk:u}}}]}}))}))},t}(ti),e.TpPasswordResetService.SLIP39_PASSPHRASE="lifeready",e.TpPasswordResetService.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetService(w.ɵɵinject(w.NgZone),w.ɵɵinject(w.INJECTOR),w.ɵɵinject($e),w.ɵɵinject(De),w.ɵɵinject(Pe),w.ɵɵinject(Oe),w.ɵɵinject(ia))},token:e.TpPasswordResetService,providedIn:"root"}),e.TpPasswordResetService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:$e},{type:De},{type:Pe},{type:Oe},{type:ia}]},e.TpPasswordResetService=Sd=U([Ur({ngZoneName:"ngZone"})],e.TpPasswordResetService),function(e){e.READER="READER",e.WRITER="WRITER",e.ADMIN="ADMIN",e.DENY="DENY",e.OWNER="OWNER"}(Ad||(Ad={})),function(e){e.inherited="inherited",e.direct="direct"}(Ed||(Ed={})),function(e){e.CREATE="CREATE",e.READ="READ",e.UPDATE="UPDATE",e.REVERT="REVERT",e.DELETE="DELETE"}($d||($d={})),function(e){e.OTK_INITIATED="OTK_INITIATED",e.OTK_ACCEPTED="OTK_ACCEPTED",e.OTK_COMPLETED="OTK_COMPLETED"}(Od||(Od={})),function(e){e.IN_PROGRESS="IN_PROGRESS",e.COMPLETED="COMPLETED",e.DECLINED="DECLINED",e.CANCELLED="CANCELLED",e.DELETED="DELETED"}(jd||(jd={})),function(e){e.OTK="OTK"}(Td||(Td={})),function(e){e.DISABLED="DISABLED",e.ENABLED="ENABLED",e.CLAIMED="CLAIMED",e.APPROVED="APPROVED",e.REJECTED="REJECTED",e.EXPIRED="EXPIRED",e.CANCELLED="CANCELLED",e.RESET="RESET"}(Md||(Md={})),function(e){e.CLAIMED="CLAIMED",e.APPROVED="APPROVED",e.REJECTED="REJECTED",e.EXPIRED="EXPIRED",e.CANCELLED="CANCELLED",e.RESET="RESET"}(Fd||(Fd={})),function(e){e.CLAIMED="CLAIMED",e.APPROVED="APPROVED",e.REJECTED="REJECTED"}(Nd||(Nd={})),function(e){e.UNLOCKED="UNLOCKED",e.MUTEX_LOCKED="MUTEX_LOCKED"}(Ld||(Ld={})),e.TpPasswordResetUserService=function(t){function n(e,n,r,i,a,s,o,c,u,d,p){var l=t.call(this,n)||this;return l.ngZone=e,l.injector=n,l.config=r,l.keyFactory=i,l.encryptionService=a,l.keyGraphService=s,l.slip39Service=o,l.passwordService=c,l.http=u,l.auth=d,l.lrAuth=p,l.CLIENT_NONCE_LENGTH=32,l}return L(n,t),n.prototype.verifyEmailContact=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){return t={email:e},[2,this.http.post(this.config.authUrl+"tp/password-reset/verify-contact/",t).toPromise()]}))}))},n.prototype.verifyContactRespond=function(e,t){return q(this,void 0,void 0,(function(){return J(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]}}))}))},n.prototype.requestReset=function(e,t,n){return q(this,void 0,void 0,(function(){var r,i,a,s,o,c,u;return J(this,(function(d){switch(d.label){case 0:return[4,this.passwordService.createPassKeyBundle(e)];case 1:return r=d.sent(),[4,this.keyFactory.createKey()];case 2:return i=d.sent(),[4,this.encryptionService.encrypt(r.passKey,i.toJSON(!0))];case 3:return a=d.sent(),[4,this.keyFactory.createPkcKey()];case 4:return s=d.sent(),[4,this.encryptionService.encrypt(i,s.toJSON(!0))];case 5:return o=d.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=d.sent(),console.log(c),console.log("Using new password: ",this.passwordService.getPassIdpString(r.passIdp)),[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=d.sent(),console.log("requestRest done: ",u),[2,{requestResetResult:c,signUpResult:u}]}}))}))},n.prototype.getResetUser=function(e){return void 0===e&&(e=!1),q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return!e&&this.resetUser?[2,this.resetUser]:(t=this,[4,this.lrAuth.loadResetUser()]);case 1:return t.resetUser=n.sent(),[2,this.resetUser]}}))}))},n.prototype.recoverAssemblyKey=function(t){return q(this,void 0,void 0,(function(){var n,r,i,a,s=this;return J(this,(function(o){switch(o.label){case 0:return[4,this.keyGraphService.getKey(t.pxk.id)];case 1:return r=o.sent(),[4,Promise.all(t.approvals.map((function(e){return q(s,void 0,void 0,(function(){var t;return J(this,(function(i){switch(i.label){case 0:return[4,this.encryptionService.decrypt(r,e.receiverCipherPartialAssemblyKey)];case 1:if(t=i.sent(),n){if(JSON.stringify(n)!==JSON.stringify(t.assemblyKeyParams))throw new ye("The assembly key parameters are different between the approvals.")}else n=t.assemblyKeyParams;return[2,t.slip39.share.mnemonics]}}))}))})))];case 2:return i=o.sent(),console.log("recoverAssemblyKey()",i),[4,this.slip39Service.recoverSecret(i,e.TpPasswordResetService.SLIP39_PASSPHRASE)];case 3:return a=o.sent(),[2,d.JWK.asKey(Object.assign(Object.assign({},n),{k:a}))]}}))}))},n.prototype.completeRequest=function(e){return q(this,void 0,void 0,(function(){var t,n,r,i,a,o,c,u,p,l,y,h,v,f,m=this;return J(this,(function(g){switch(g.label){case 0:return[4,this.getResetUser(!0)];case 1:if((t=g.sent()).state!==Fd.APPROVED)throw new ye("Password reset request has not been approved.");return[4,this.recoverAssemblyKey(t)];case 2:return n=g.sent(),[4,this.encryptionService.decrypt(n,t.assemblyCipherData)];case 3:return r=g.sent().rootKey,console.log(r),[4,d.JWK.asKey(r)];case 4:return i=g.sent(),[4,this.keyGraphService.getKey(t.masterKey.id)];case 5:return a=g.sent(),[4,this.encryptionService.encryptToString(a.jwk,i.toJSON(!0))];case 6:return o=g.sent(),[4,this.keyFactory.derivePassIdp(Object.assign({password:e},t.passKey.passIdpParams))];case 7:return c=g.sent(),u=this.passwordService.getPassIdpString(c.jwk),[4,this.mutate(new Zr({mutation:Pr,variables:{input:{}}}),{includeKeyGraph:!1})];case 8:return p=g.sent().createTpAssemblyKeyChallenge.challenge,console.log(p),p.clientNonce=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),console.log(p),[4,this.encryptionService.decrypt(n,t.wrappedAssemblyKeyVerifierPrk)];case 9:return l=g.sent(),[4,this.encryptionService.sign(l,p)];case 10:return y=g.sent(),[4,this.mutate(new Zr({mutation:Rr,variables:{input:{signedChallenge:JSON.stringify(y)}}}),{includeKeyGraph:!1})];case 11:return h=g.sent().preCompleteTpPasswordResetRequest.idpPassword,v=new Promise((function(e){var n=function(r){return q(m,void 0,void 0,(function(){return J(this,(function(i){switch(i.label){case 0:return"signIn"!==r.payload.event?[2]:(s.Hub.remove("auth",n),console.log(r.payload),[4,this.auth.signIn(t.username,u)]);case 1:return i.sent(),[4,this.mutate(new Zr({mutation:Dr,variables:{input:{masterKeyWrappedRootKey:o,masterKeyId:a.id}}}))];case 2:return i.sent(),e(),[2]}}))}))};s.Hub.listen("auth",n)})),[4,this.auth.signIn(t.username,h,{noProxy:"true"})];case 12:if("NEW_PASSWORD_REQUIRED"!==(f=g.sent()).challengeName)throw new Y({message:"Internal error. Expecting Cognito to have done a password reset after call to PreCompleteTpPasswordResetRequestMutation."});return[4,this.auth.completeNewPassword(f,u,{})];case 13:return f=g.sent(),[2,v]}}))}))},n}(ti),e.TpPasswordResetUserService.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetUserService(w.ɵɵinject(w.NgZone),w.ɵɵinject(w.INJECTOR),w.ɵɵinject(he),w.ɵɵinject(De),w.ɵɵinject(Pe),w.ɵɵinject(Oe),w.ɵɵinject(ia),w.ɵɵinject(or),w.ɵɵinject(k.HttpClient),w.ɵɵinject(D.AuthClass),w.ɵɵinject(ri))},token:e.TpPasswordResetUserService,providedIn:"root"}),e.TpPasswordResetUserService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetUserService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:void 0,decorators:[{type:n.Inject,args:[he]}]},{type:De},{type:Pe},{type:Oe},{type:ia},{type:or},{type:t.HttpClient},{type:p.AuthClass},{type:ri}]},e.TpPasswordResetUserService=U([Ur({ngZoneName:"ngZone"})],e.TpPasswordResetUserService),e.TpPasswordResetRequestService=function(e){function t(t,n,r){var i=e.call(this,n)||this;return i.ngZone=t,i.injector=n,i.encryptionService=r,i}return L(t,e),t.prototype.getSharedResets=function(){return q(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return[4,this.query({query:kr})];case 1:return[2,e.sent().sharedTpPasswordResets]}}))}))},t.prototype.getSharedReset=function(e){return q(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,this.query({query:wr,variables:{id:e}})];case 1:return[2,t.sent().sharedTpPasswordReset]}}))}))},t.prototype.activeRequestOrRaise=function(e){var t=e.sharedRequest.claim.state;if(t!==Md.CLAIMED)throw new ye("Claim is already in "+t+" state.")},t.prototype.rejectRequest=function(e){return this.mutate(this.rejectRequestMutation(e))},t.prototype.rejectRequestMutation=function(e){return q(this,void 0,void 0,(function(){var t;return J(this,(function(n){switch(n.label){case 0:return[4,this.getSharedReset(e)];case 1:return t=n.sent(),this.activeRequestOrRaise(t),[2,zr.create(t.sharedRequest.claim.asClaimApprovers.edges.filter((function(e){return e.node.state===Nd.CLAIMED})).map((function(e){return new Zr({mutation:Er,variables:{input:{claimApproverId:e.node.id}}})})))]}}))}))},t.prototype.approveRequest=function(e,t){return this.mutate(this.approveRequestMutation(e,t))},t.prototype.approveRequestMutation=function(e,t){return q(this,void 0,void 0,(function(){var t,n,r,i,a,s=this;return J(this,(function(o){switch(o.label){case 0:return[4,this.getSharedReset(e)];case 1:return t=o.sent(),this.activeRequestOrRaise(t),[4,d.JWK.asKey(JSON.parse(t.sharedRequest.pxk.pbk))];case 2:return n=o.sent(),console.log(n.toJSON()),r=t.sharedRequest.claim.asClaimApprovers.edges.filter((function(e){return e.node.state===Nd.CLAIMED})),a=(i=zr).create,[4,Promise.all(r.map((function(e){return q(s,void 0,void 0,(function(){var t,r,i,a=this;return J(this,(function(s){switch(s.label){case 0:return t=e.node,i={claimApproverId:t.id},[4,Promise.all(t.receiverApprovals.edges.map((function(e){return q(a,void 0,void 0,(function(){var r,i;return J(this,(function(a){switch(a.label){case 0:return r=e.node,i={receiverApprovalId:r.id,receiverCipher:""},[4,this.encryptionService.encryptToString(n,t.sharedCipherPartialAssemblyKeyClearJson)];case 1:return[2,(i.receiverCipherPartialAssemblyKey=a.sent(),i)]}}))}))})))];case 1:return i.receiverApprovals=s.sent(),r=i,console.log(r),[2,new Zr({mutation:Ar,variables:{input:r}})]}}))}))})))];case 3:return[2,a.apply(i,[o.sent()])]}}))}))},t}(ti),e.TpPasswordResetRequestService.ɵprov=w.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetRequestService(w.ɵɵinject(w.NgZone),w.ɵɵinject(w.INJECTOR),w.ɵɵinject(Pe))},token:e.TpPasswordResetRequestService,providedIn:"root"}),e.TpPasswordResetRequestService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetRequestService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:Pe}]},e.TpPasswordResetRequestService=U([Ur({ngZoneName:"ngZone"})],e.TpPasswordResetRequestService),e.AcceptTrustedPartyInvite=ys,e.AccessFields=Tt,e.AddScenarioApproverMutation=tc,e.AddScenarioClaimantMutation=Lo,e.AddScenarioReceiverDirectoryMutation=Qo,e.ApiContactCard=ct,e.ApiCurrentUser=ot,e.ApproveScenarioClaimMutation=Sc,e.ArchiveDirectoryMutation=Zt,e.Assembly=ta,e.CancelScenarioClaimMutation=gc,e.CancelTrustedPartyInvitationMutation=Ts,e.CancelUserDeleteMutation=pi,e.Category=Da,e.CategoryFields=Ft,e.CategoryFilter=Ot,e.CategoryMetaService=Fa,e.CategoryService=Ta,e.ClaimantFields=Fo,e.CognitoChallengeUser=Mn,e.CompleteOtkMutation=Ei,e.ConfirmTrustedPartyInvite=hs,e.ContactCardAddress=dt,e.ContactCardName=ut,e.CreateCategoryMutation=Qt,e.CreateContactCardMutation=it,e.CreateFileMutation=ba,e.CreateFileQuery=ze,e.CreateLbopQuery=Gi,e.CreateRecordContainerMutation=ma,e.CreateRecordMutation=ga,e.CreateScenarioApproverAssemblyMutation=Yo,e.CreateScenarioClaimMutation=mc,e.CreateScenarioMutation=lc,e.CreateScenarioReceiverMutation=_o,e.CreateSubAssembliesInput=xd,e.CreateTpPasswordResetInput=qd,e.CreateVaultMutation=Vt,e.CurrentCategory=Aa,e.CurrentUser=Ln,e.CurrentUserKey=st,e.CurrentUserQuery=rt,e.CurrentUserSharedKeyQuery=wi,e.DECRYPT_OPTIONS_DEFAULT=ke,e.DEFAULT_BREADCRUMB_DEPTH=5,e.DEFAULT_DESCENDANTS_DEPTH=5,e.DeclineTrustedPartyInvitationMutation=js,e.DefaultCategory=Ka,e.DefaultProcessorOptions=qr,e.DefaultVaultFilter=$t,e.DeleteCategoryMutation=Ht,e.DeleteFileMutation=ka,e.DeleteLbopQuery=Bi,e.DeleteRecordMutation=Ca,e.DeleteScenarioApproverAssemblyMutation=Xo,e.DeleteScenarioClaimantMutation=Uo,e.DeleteScenarioMutation=hc,e.DeleteScenarioReceiverDirectoryMutation=Wo,e.DeleteScenarioReceiverMutation=Bo,e.DeleteTrustedPartyMutation=Ms,e.DirectoryQuery=Ye,e.DisableScenarioMutation=fc,e.EnableScenarioMutation=vc,e.EncryptionService=Pe,e.Features=Nn,e.FetchKeyGraphField=He,e.FileQuery=Ze,e.FileService=ii,e.FoundTrustedParty=ps,e.GetAllScenarioClaimsQuery=pc,e.GetAllScenarioIdsQuery=cc,e.GetAllScenariosQuery=uc,e.GetAllSharedScenariosQuery=sc,e.GetAllTrustedPartiesQuery=$s,e.GetCategoriesQuery=xt,e.GetCategoryKeyIdQuery=Bt,e.GetCategoryQuery=Gt,e.GetMySharedCategoriesQuery=Jt,e.GetRecordQuery=fa,e.GetRootDirectoryIdsQuery=Lt,e.GetScenarioApproverQuery=ec,e.GetScenarioClaimantQuery=No,e.GetScenarioQuery=dc,e.GetScenarioReceiverQuery=Jo,e.GetSharedScenarioQuery=ac,e.GetTrustedPartiesQuery=Es,e.GetTrustedPartyCategoriesQuery=qt,e.GetTrustedPartyQuery=Os,e.GetTrustedPartyScenariosQuery=oc,e.GetVaultsQuery=Ut,e.IdleService=ir,e.InitiateOtkMutation=Di,e.InviteTrustedParty=ls,e.KeyExchangeFields=bi,e.KeyExchangeQuery=Pi,e.KeyExchangeService=$i,e.KeyExchangeTokenQuery=Ri,e.KeyExchangesQuery=Ki,e.KeyFactoryService=De,e.KeyGraphField=We,e.KeyGraphFragment=Ve,e.KeyGraphService=Oe,e.KeyMetaService=en,e.KeyService=$e,e.LR_CONFIG=he,e.LbopQuery=Vi,e.LbopService=Hi,e.LbopsQuery=Wi,e.LifeReadyAuthService=ri,e.LifeReadyModule=jc,e.LoadedCategoryTree=Ma,e.LoginHistoryQuery=li,e.LoginResult=xn,e.LrApolloService=je,e.LrAuthException=ce,e.LrBadArgumentException=ee,e.LrBadLogicException=re,e.LrBadRequestException=oe,e.LrBadStateException=ye,e.LrCodeMismatchException=ie,e.LrConcurrentAccessException=ae,e.LrEncryptionException=ue,e.LrError=Z,e.LrException=Y,e.LrExpiredCodeException=pe,e.LrExpiredException=le,e.LrGraphQLService=e.ɵb,e.LrLockedException=se,e.LrMergedMutation=zr,e.LrMutation=Zr,e.LrMutationBase=Hr,e.LrNotFoundException=ne,e.LrRecord=qa,e.LrService=ti,e.LrSuspiciousException=te,e.LrUnsupportedException=de,e.MainContactCard=yt,e.MainContactCardFields=lt,e.MainContactCardPlainFields=ht,e.MainContactCardProperty=pt,e.MessageQuery=Mi,e.MessageService=Fi,e.MoveDirectoryQuery=nt,e.MoveFileQuery=tt,e.NewAttachment=Ja,e.NewCategory=$a,e.NewOrUpdatedAttachment=Ga,e.NewRecord=_a,e.NewScenario=bo,e.NewScenarioApprovalGroup=wo,e.NewScenarioApprover=Ko,e.NewScenarioClaimant=ko,e.NewScenarioReceiver=Po,e.OwnerPlainDataJson=Xc,e.PassIdpApiResult=ft,e.PasswordCheck=sr,e.PasswordService=or,e.PersistService=Ae,e.Plan=Mc,e.PlanService=jn,e.ProfileDetailsService=Oc,e.ProfileService=Tn,e.Quorum=ra,e.ReceiveScenarioClaimMutation=Cc,e.ReceiverFields=qo,e.RecordAttachment=Ua,e.RecordAttachmentFilter=va,e.RecordAttachmentService=Na,e.RecordContentFilter=ha,e.RecordField=xa,e.RecordFilter=jt,e.RecordService=Qa,e.RecordType=Va,e.RecordTypeField=Ha,e.RecordTypeFieldOption=Wa,e.RecordTypeService=Xa,e.RecordTypeSummary=Za,e.RegisterResult=Un,e.RegisterService=Zi,e.RejectScenarioClaimMutation=Ic,e.RequestUserDeleteMutation=di,e.ResetScenarioMutation=bc,e.RespondOtkMutation=Ai,e.RevertFileQuery=et,e.ScenarioApproverService=wc,e.ScenarioClaim=jo,e.ScenarioClaimantService=Kc,e.ScenarioReceiverService=Pc,e.ScenarioService=Dc,e.ScenarioSetupService=Ec,e.ScenarioSummary=Oo,e.SecretShare=Xi,e.SendMessageMutation=Ti,e.ShareCategoryMutation=Fs,e.SharedAccess=wa,e.SharedScenario=Mo,e.SharedScenarioSummary=To,e.SharedTrustedPartyDetails=ss,e.SharedVaultFeature=us,e.Slip39Service=ia,e.StripeBillingPortalSession=xc,e.StripeCheckoutSession=Lc,e.SubAssembly=ea,e.SubAssemblyFields=Zo,e.SubQuorum=na,e.Subscription=Fc,e.TPFeatures=cs,e.TrustedParties=as,e.TrustedParty=ds,e.TrustedPartyDetails=mt,e.TrustedPartyInvite=os,e.TrustedPartyProperties=As,e.TrustedPartyRole=rs,e.TrustedPartyService=Ls,e.TwoFactorService=Yi,e.UnarchiveDirectoryMutation=Yt,e.UnshareCategoryMutation=Ns,e.UpdateCategoryMutation=Wt,e.UpdateContactCardMutation=at,e.UpdateFileQuery=Xe,e.UpdateLbopQuery=Qi,e.UpdateRecordContainerMutation=Sa,e.UpdateRecordMutation=Ia,e.UpdateScenario=Ro,e.UpdateScenarioApproverAssemblyMutation=zo,e.UpdateScenarioApproverMutation=nc,e.UpdateScenarioApproverSubAssemblyMutation=kc,e.UpdateScenarioClaimantMutation=xo,e.UpdateScenarioMutation=yc,e.UpdateScenarioReceiverDirectoryMutation=Vo,e.UpdateScenarioReceiverMutation=Go,e.UpdateSubAssembliesInput=Ud,e.UpdateTpPasswordResetInput=Jd,e.UpdatedCategory=Oa,e.UpdatedRecord=Ba,e.UpdatedScenarioApprovalGroup=Ao,e.UpdatedScenarioApprover=Eo,e.UpdatedScenarioClaimant=Do,e.UpdatedScenarioReceiver=$o,e.UserKeys=Ee,e.UserPlan=Nc,e.UserQuery=ui,e.UserService=yi,e.UserSharedKeyFields=ki,e.VERIFY_OPTIONS_DEFAULT=be,e.Vault=ja,e.VaultCategory=Ea,e.VaultFields=Nt,e.VaultRecord=Ra,e.VaultRecordType=Pa,e.WebCryptoService=Re,e.WrappedContent=zt,e.WrappingKey=Xt,e.asJwk=Ke,e.awsFetch=Ji,e.configureAmplifyAuth=_i,e.configureApollo=fe,e.debugPopulateRecords=function(e,t,n,r){return q(this,void 0,void 0,(function(){var i,a,s,o,c,u,d,p,l,y,h,v,f,m;return J(this,(function(g){switch(g.label){case 0:return[4,e.getCategories()];case 1:i=g.sent(),g.label=2;case 2:g.trys.push([2,14,15,16]),a=_(i),s=a.next(),g.label=3;case 3:return s.done?[3,13]:(o=s.value,[4,e.getCategory(o.id)]);case 4:c=g.sent(),g.label=5;case 5:g.trys.push([5,10,11,12]),f=void 0,u=_(c.subCategories),d=u.next(),g.label=6;case 6:return d.done?[3,9]:(p=d.value).allowRecords?[4,Jc(e,t,n,p.id,r)]:[3,8];case 7:g.sent(),g.label=8;case 8:return d=u.next(),[3,6];case 9:return[3,12];case 10:return l=g.sent(),f={error:l},[3,12];case 11:try{d&&!d.done&&(m=u.return)&&m.call(u)}finally{if(f)throw f.error}return[7];case 12:return s=a.next(),[3,3];case 13:return[3,16];case 14:return y=g.sent(),h={error:y},[3,16];case 15:try{s&&!s.done&&(v=a.return)&&v.call(a)}finally{if(h)throw h.error}return[7];case 16:return[2]}}))}))},e.fragmentSpreadAstSelection=Wr,e.gqlTyped=Vn,e.handleApolloError=V,e.handleCognitoCallback=function(e){return new Promise((function(t,n){return e((function(e,r){return e?n(e):t(r)}))}))},e.initialiseAuth=ni,e.isSymmetricKey=we,e.mapUserPlans=On,e.parentCategoriesField=_t,e.processConnection=Jr,e.sha256=function(e){return q(this,void 0,void 0,(function(){var t,n,r;return J(this,(function(i){switch(i.label){case 0:return t=(new TextEncoder).encode(e),[4,crypto.subtle.digest("SHA-256",t)];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)),[2,r.map((function(e){return("00"+e.toString(16)).slice(-2)})).join("")]}}))}))},e.ɵ0=za,e.ɵa=Ce,e.ɵd=Ur,e.ɵe=vs,e.ɵf=ms,e.ɵg=ti,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
|
+
//# sourceMappingURL=lifeready-core.umd.min.js.map
|