@lifeready/core 1.0.1 → 1.0.2

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.
Files changed (380) hide show
  1. package/README.md +62 -62
  2. package/bundles/lifeready-core.umd.js +15939 -0
  3. package/bundles/lifeready-core.umd.js.map +1 -0
  4. package/bundles/lifeready-core.umd.min.js +16 -0
  5. package/bundles/lifeready-core.umd.min.js.map +1 -0
  6. package/esm2015/lib/_common/ast.js +40 -0
  7. package/esm2015/lib/_common/deferred-promise.js +24 -0
  8. package/esm2015/lib/_common/exceptions.js +157 -0
  9. package/esm2015/lib/_common/queries.gql.js +190 -0
  10. package/esm2015/lib/_common/run-outside-angular.js +79 -0
  11. package/esm2015/lib/_common/types.js +1 -0
  12. package/esm2015/lib/_common/utils.js +44 -0
  13. package/esm2015/lib/api/contact-card.gql.js +79 -0
  14. package/esm2015/lib/api/contact-card.service.js +154 -0
  15. package/esm2015/lib/api/contact-card2.gql.js +60 -0
  16. package/esm2015/lib/api/contact-card2.service.js +103 -0
  17. package/esm2015/lib/api/file.service.js +74 -0
  18. package/esm2015/lib/api/item2.gql.js +110 -0
  19. package/esm2015/lib/api/item2.service.js +311 -0
  20. package/esm2015/lib/api/key-exchange.gql.js +188 -0
  21. package/esm2015/lib/api/key-exchange.service.js +442 -0
  22. package/esm2015/lib/api/key-exchange.types.js +18 -0
  23. package/esm2015/lib/api/key-exchange2.gql.js +171 -0
  24. package/esm2015/lib/api/key-exchange2.service.js +479 -0
  25. package/esm2015/lib/api/lock.gql.js +40 -0
  26. package/esm2015/lib/api/lock.service.js +64 -0
  27. package/esm2015/lib/api/lr-apollo.service.js +46 -0
  28. package/esm2015/lib/api/lr-graphql/index.js +6 -0
  29. package/esm2015/lib/api/lr-graphql/lr-graphql.service.js +155 -0
  30. package/esm2015/lib/api/lr-graphql/lr-merged-mutation.js +213 -0
  31. package/esm2015/lib/api/lr-graphql/lr-mutation-base.js +51 -0
  32. package/esm2015/lib/api/lr-graphql/lr-mutation.js +48 -0
  33. package/esm2015/lib/api/lr-graphql/lr.service.js +18 -0
  34. package/esm2015/lib/api/message.service.js +138 -0
  35. package/esm2015/lib/api/persist.service.js +181 -0
  36. package/esm2015/lib/api/query-processor/common-processors.service.js +93 -0
  37. package/esm2015/lib/api/query-processor/index.js +3 -0
  38. package/esm2015/lib/api/query-processor/query-processor.service.js +192 -0
  39. package/esm2015/lib/api/query-processor/tp-password-reset-processor.service.js +109 -0
  40. package/esm2015/lib/api/shared-contact-card.service.js +119 -0
  41. package/esm2015/lib/api/shared-contact-card2.gql.js +41 -0
  42. package/esm2015/lib/api/shared-contact-card2.service.js +117 -0
  43. package/esm2015/lib/api/time.service.js +146 -0
  44. package/esm2015/lib/api/types/graphql.types.js +7 -0
  45. package/esm2015/lib/api/types/index.js +3 -0
  46. package/esm2015/lib/api/types/lr-graphql.types.js +71 -0
  47. package/esm2015/lib/auth/auth.config.js +57 -0
  48. package/esm2015/lib/auth/auth.gql.js +48 -0
  49. package/esm2015/lib/auth/auth.types.js +27 -0
  50. package/esm2015/lib/auth/idle.service.js +168 -0
  51. package/esm2015/lib/auth/idle.types.js +7 -0
  52. package/esm2015/lib/auth/lbop.service.js +355 -0
  53. package/esm2015/lib/auth/life-ready-auth.service.js +500 -0
  54. package/esm2015/lib/auth/password.service.js +320 -0
  55. package/esm2015/lib/auth/register.service.js +172 -0
  56. package/esm2015/lib/auth/two-factor.service.js +74 -0
  57. package/esm2015/lib/category/category-meta.service.js +99 -0
  58. package/esm2015/lib/category/category.gql.js +406 -0
  59. package/esm2015/lib/category/category.service.js +390 -0
  60. package/esm2015/lib/category/category.types.js +29 -0
  61. package/esm2015/lib/cryptography/cryptography.types.js +11 -0
  62. package/esm2015/lib/cryptography/encryption.service.js +189 -0
  63. package/esm2015/lib/cryptography/key-factory.service.js +237 -0
  64. package/esm2015/lib/cryptography/key-graph.service.js +280 -0
  65. package/esm2015/lib/cryptography/key-meta.service.js +200 -0
  66. package/esm2015/lib/cryptography/key.service.js +124 -0
  67. package/esm2015/lib/cryptography/slip39.service.js +169 -0
  68. package/esm2015/lib/cryptography/web-crypto.service.js +29 -0
  69. package/esm2015/lib/life-ready.config.js +84 -0
  70. package/esm2015/lib/life-ready.module.js +74 -0
  71. package/esm2015/lib/plan/plan.gql.js +123 -0
  72. package/esm2015/lib/plan/plan.service.js +149 -0
  73. package/esm2015/lib/plan/plan.types.js +11 -0
  74. package/esm2015/lib/record/record-attachment.service.js +101 -0
  75. package/esm2015/lib/record/record.gql.js +179 -0
  76. package/esm2015/lib/record/record.service.js +206 -0
  77. package/esm2015/lib/record/record.types.js +15 -0
  78. package/esm2015/lib/record-type/record-type.service.js +75 -0
  79. package/esm2015/lib/record-type/record-type.types.js +28 -0
  80. package/esm2015/lib/scenario/approvals/scenario-approval.gql.js +105 -0
  81. package/esm2015/lib/scenario/approvals/scenario-approval.types.js +1 -0
  82. package/esm2015/lib/scenario/approvals/scenario-approver.service.js +300 -0
  83. package/esm2015/lib/scenario/claimants/scenario-claimant.gql.js +52 -0
  84. package/esm2015/lib/scenario/claimants/scenario-claimant.service.js +97 -0
  85. package/esm2015/lib/scenario/claimants/scenario-claimant.types.js +1 -0
  86. package/esm2015/lib/scenario/receivers/scenario-receiver.gql.js +150 -0
  87. package/esm2015/lib/scenario/receivers/scenario-receiver.service.js +229 -0
  88. package/esm2015/lib/scenario/receivers/scenario-receiver.types.js +1 -0
  89. package/esm2015/lib/scenario/scenario-setup.service.js +269 -0
  90. package/esm2015/lib/scenario/scenario.gql.js +368 -0
  91. package/esm2015/lib/scenario/scenario.service.js +611 -0
  92. package/esm2015/lib/scenario/scenario.types.js +64 -0
  93. package/esm2015/lib/search/search.gql.js +62 -0
  94. package/esm2015/lib/search/search.service.js +156 -0
  95. package/esm2015/lib/search/search.types.js +6 -0
  96. package/esm2015/lib/trusted-parties/tp-password-reset-request.service.js +112 -0
  97. package/esm2015/lib/trusted-parties/tp-password-reset-user.service.js +129 -0
  98. package/esm2015/lib/trusted-parties/tp-password-reset.constants.js +4 -0
  99. package/esm2015/lib/trusted-parties/tp-password-reset.gql.js +232 -0
  100. package/esm2015/lib/trusted-parties/tp-password-reset.service.js +299 -0
  101. package/esm2015/lib/trusted-parties/trusted-party.gql.js +148 -0
  102. package/esm2015/lib/trusted-parties/trusted-party.service.js +326 -0
  103. package/esm2015/lib/trusted-parties/trusted-party.types.js +41 -0
  104. package/esm2015/lib/trusted-parties/trusted-party2.gql.js +87 -0
  105. package/esm2015/lib/trusted-parties/trusted-party2.service.js +215 -0
  106. package/esm2015/lib/users/profile-details.service.js +214 -0
  107. package/esm2015/lib/users/profile.gql.js +97 -0
  108. package/esm2015/lib/users/profile.service.js +169 -0
  109. package/esm2015/lib/users/profile.types.js +34 -0
  110. package/esm2015/lib/users/user.gql.js +60 -0
  111. package/esm2015/lib/users/user.service.js +79 -0
  112. package/esm2015/lib/users/user.types.js +5 -0
  113. package/esm2015/lifeready-core.js +10 -0
  114. package/esm2015/public-api.js +81 -0
  115. package/fesm2015/lifeready-core.js +13314 -0
  116. package/fesm2015/lifeready-core.js.map +1 -0
  117. package/lib/_common/ast.d.ts +11 -0
  118. package/lib/_common/deferred-promise.d.ts +12 -0
  119. package/lib/_common/exceptions.d.ts +109 -0
  120. package/lib/_common/queries.gql.d.ts +10 -0
  121. package/lib/_common/run-outside-angular.d.ts +14 -0
  122. package/{src/lib/_common/types.ts → lib/_common/types.d.ts} +10 -13
  123. package/lib/_common/utils.d.ts +3 -0
  124. package/lib/api/contact-card.gql.d.ts +7 -0
  125. package/lib/api/contact-card.service.d.ts +52 -0
  126. package/lib/api/contact-card2.gql.d.ts +34 -0
  127. package/lib/api/contact-card2.service.d.ts +49 -0
  128. package/lib/api/file.service.d.ts +18 -0
  129. package/lib/api/item2.gql.d.ts +96 -0
  130. package/lib/api/item2.service.d.ts +177 -0
  131. package/lib/api/key-exchange.gql.d.ts +9 -0
  132. package/lib/api/key-exchange.service.d.ts +39 -0
  133. package/lib/api/key-exchange.types.d.ts +196 -0
  134. package/lib/api/key-exchange2.gql.d.ts +125 -0
  135. package/lib/api/key-exchange2.service.d.ts +187 -0
  136. package/lib/api/lock.gql.d.ts +27 -0
  137. package/lib/api/lock.service.d.ts +25 -0
  138. package/lib/api/lr-apollo.service.d.ts +15 -0
  139. package/{src/lib/api/lr-graphql/index.ts → lib/api/lr-graphql/index.d.ts} +5 -5
  140. package/lib/api/lr-graphql/lr-graphql.service.d.ts +60 -0
  141. package/lib/api/lr-graphql/lr-merged-mutation.d.ts +27 -0
  142. package/lib/api/lr-graphql/lr-mutation-base.d.ts +28 -0
  143. package/lib/api/lr-graphql/lr-mutation.d.ts +8 -0
  144. package/lib/api/lr-graphql/lr.service.d.ts +9 -0
  145. package/lib/api/message.service.d.ts +58 -0
  146. package/lib/api/persist.service.d.ts +31 -0
  147. package/lib/api/query-processor/common-processors.service.d.ts +36 -0
  148. package/{src/lib/api/query-processor/index.ts → lib/api/query-processor/index.d.ts} +2 -2
  149. package/lib/api/query-processor/query-processor.service.d.ts +18 -0
  150. package/lib/api/query-processor/tp-password-reset-processor.service.d.ts +15 -0
  151. package/lib/api/shared-contact-card.service.d.ts +33 -0
  152. package/lib/api/shared-contact-card2.gql.d.ts +36 -0
  153. package/lib/api/shared-contact-card2.service.d.ts +45 -0
  154. package/lib/api/time.service.d.ts +16 -0
  155. package/lib/api/types/graphql.types.d.ts +29 -0
  156. package/{src/lib/api/types/index.ts → lib/api/types/index.d.ts} +2 -2
  157. package/lib/api/types/lr-graphql.types.d.ts +385 -0
  158. package/lib/auth/auth.config.d.ts +5 -0
  159. package/lib/auth/auth.gql.d.ts +15 -0
  160. package/lib/auth/auth.types.d.ts +66 -0
  161. package/lib/auth/idle.service.d.ts +40 -0
  162. package/lib/auth/idle.types.d.ts +10 -0
  163. package/lib/auth/lbop.service.d.ts +91 -0
  164. package/lib/auth/life-ready-auth.service.d.ts +59 -0
  165. package/lib/auth/password.service.d.ts +78 -0
  166. package/lib/auth/register.service.d.ts +25 -0
  167. package/lib/auth/two-factor.service.d.ts +15 -0
  168. package/lib/category/category-meta.service.d.ts +23 -0
  169. package/lib/category/category.gql.d.ts +45 -0
  170. package/lib/category/category.service.d.ts +67 -0
  171. package/lib/category/category.types.d.ts +79 -0
  172. package/lib/cryptography/cryptography.types.d.ts +83 -0
  173. package/lib/cryptography/encryption.service.d.ts +41 -0
  174. package/lib/cryptography/key-factory.service.d.ts +38 -0
  175. package/lib/cryptography/key-graph.service.d.ts +33 -0
  176. package/lib/cryptography/key-meta.service.d.ts +44 -0
  177. package/lib/cryptography/key.service.d.ts +36 -0
  178. package/lib/cryptography/slip39.service.d.ts +43 -0
  179. package/lib/cryptography/web-crypto.service.d.ts +5 -0
  180. package/lib/life-ready.config.d.ts +14 -0
  181. package/lib/life-ready.module.d.ts +5 -0
  182. package/lib/plan/plan.gql.d.ts +11 -0
  183. package/lib/plan/plan.service.d.ts +33 -0
  184. package/lib/plan/plan.types.d.ts +31 -0
  185. package/lib/record/record-attachment.service.d.ts +16 -0
  186. package/lib/record/record.gql.d.ts +14 -0
  187. package/lib/record/record.service.d.ts +25 -0
  188. package/lib/record/record.types.d.ts +57 -0
  189. package/lib/record-type/record-type.service.d.ts +11 -0
  190. package/lib/record-type/record-type.types.d.ts +50 -0
  191. package/lib/scenario/approvals/scenario-approval.gql.d.ts +7 -0
  192. package/lib/scenario/approvals/scenario-approval.types.d.ts +63 -0
  193. package/lib/scenario/approvals/scenario-approver.service.d.ts +32 -0
  194. package/lib/scenario/claimants/scenario-claimant.gql.d.ts +5 -0
  195. package/lib/scenario/claimants/scenario-claimant.service.d.ts +17 -0
  196. package/lib/scenario/claimants/scenario-claimant.types.d.ts +18 -0
  197. package/lib/scenario/receivers/scenario-receiver.gql.d.ts +8 -0
  198. package/lib/scenario/receivers/scenario-receiver.service.d.ts +30 -0
  199. package/lib/scenario/receivers/scenario-receiver.types.d.ts +54 -0
  200. package/lib/scenario/scenario-setup.service.d.ts +22 -0
  201. package/lib/scenario/scenario.gql.d.ts +34 -0
  202. package/lib/scenario/scenario.service.d.ts +58 -0
  203. package/lib/scenario/scenario.types.d.ts +217 -0
  204. package/lib/search/search.gql.d.ts +1 -0
  205. package/lib/search/search.service.d.ts +25 -0
  206. package/lib/search/search.types.d.ts +20 -0
  207. package/lib/trusted-parties/tp-password-reset-request.service.d.ts +20 -0
  208. package/lib/trusted-parties/tp-password-reset-user.service.d.ts +35 -0
  209. package/lib/trusted-parties/tp-password-reset.constants.d.ts +3 -0
  210. package/lib/trusted-parties/tp-password-reset.gql.d.ts +218 -0
  211. package/lib/trusted-parties/tp-password-reset.service.d.ts +130 -0
  212. package/lib/trusted-parties/trusted-party.gql.d.ts +9 -0
  213. package/lib/trusted-parties/trusted-party.service.d.ts +44 -0
  214. package/lib/trusted-parties/trusted-party.types.d.ts +102 -0
  215. package/lib/trusted-parties/trusted-party2.gql.d.ts +79 -0
  216. package/lib/trusted-parties/trusted-party2.service.d.ts +114 -0
  217. package/lib/users/profile-details.service.d.ts +21 -0
  218. package/lib/users/profile.gql.d.ts +11 -0
  219. package/lib/users/profile.service.d.ts +35 -0
  220. package/lib/users/profile.types.d.ts +96 -0
  221. package/lib/users/user.gql.d.ts +9 -0
  222. package/lib/users/user.service.d.ts +12 -0
  223. package/lib/users/user.types.d.ts +23 -0
  224. package/lifeready-core.d.ts +9 -0
  225. package/lifeready-core.metadata.json +1 -0
  226. package/package.json +29 -21
  227. package/{src/public-api.ts → public-api.d.ts} +77 -96
  228. package/karma.conf.js +0 -32
  229. package/ng-package.json +0 -26
  230. package/src/lib/_common/ast.ts +0 -75
  231. package/src/lib/_common/deferred-promise.ts +0 -35
  232. package/src/lib/_common/exceptions.ts +0 -189
  233. package/src/lib/_common/queries.gql.ts +0 -200
  234. package/src/lib/_common/run-outside-angular.ts +0 -125
  235. package/src/lib/_common/tests.ts +0 -82
  236. package/src/lib/_common/utils.ts +0 -57
  237. package/src/lib/api/api-mutation.spec.ts +0 -547
  238. package/src/lib/api/api-query.spec.ts +0 -40
  239. package/src/lib/api/contact-card.gql.ts +0 -85
  240. package/src/lib/api/contact-card.service.spec.ts +0 -249
  241. package/src/lib/api/contact-card.service.ts +0 -228
  242. package/src/lib/api/contact-card2.gql.ts +0 -93
  243. package/src/lib/api/contact-card2.service.spec.ts +0 -297
  244. package/src/lib/api/contact-card2.service.ts +0 -139
  245. package/src/lib/api/file.service.spec.ts +0 -14
  246. package/src/lib/api/file.service.ts +0 -81
  247. package/src/lib/api/item2.gql.ts +0 -211
  248. package/src/lib/api/item2.service.spec.ts +0 -1043
  249. package/src/lib/api/item2.service.ts +0 -481
  250. package/src/lib/api/key-exchange.gql.ts +0 -196
  251. package/src/lib/api/key-exchange.service.spec.ts +0 -470
  252. package/src/lib/api/key-exchange.service.ts +0 -731
  253. package/src/lib/api/key-exchange.types.ts +0 -235
  254. package/src/lib/api/key-exchange2.gql.ts +0 -310
  255. package/src/lib/api/key-exchange2.service.spec.ts +0 -892
  256. package/src/lib/api/key-exchange2.service.ts +0 -875
  257. package/src/lib/api/lock.gql.ts +0 -67
  258. package/src/lib/api/lock.service.spec.ts +0 -549
  259. package/src/lib/api/lock.service.ts +0 -57
  260. package/src/lib/api/lr-apollo.service.spec.ts +0 -27
  261. package/src/lib/api/lr-apollo.service.ts +0 -43
  262. package/src/lib/api/lr-graphql/lr-graphql.service.ts +0 -313
  263. package/src/lib/api/lr-graphql/lr-merged-mutation.ts +0 -377
  264. package/src/lib/api/lr-graphql/lr-mutation-base.ts +0 -67
  265. package/src/lib/api/lr-graphql/lr-mutation.ts +0 -74
  266. package/src/lib/api/lr-graphql/lr.service.ts +0 -28
  267. package/src/lib/api/message.service.spec.ts +0 -20
  268. package/src/lib/api/message.service.ts +0 -210
  269. package/src/lib/api/persist.service.spec.ts +0 -209
  270. package/src/lib/api/persist.service.ts +0 -220
  271. package/src/lib/api/query-processor/common-processors.service.ts +0 -148
  272. package/src/lib/api/query-processor/query-processor.service.ts +0 -240
  273. package/src/lib/api/query-processor/tp-password-reset-processor.service.ts +0 -177
  274. package/src/lib/api/shared-contact-card.service.ts +0 -156
  275. package/src/lib/api/shared-contact-card2.gql.ts +0 -76
  276. package/src/lib/api/shared-contact-card2.service.ts +0 -154
  277. package/src/lib/api/time.service.spec.ts +0 -48
  278. package/src/lib/api/time.service.ts +0 -155
  279. package/src/lib/api/types/graphql.types.ts +0 -48
  280. package/src/lib/api/types/lr-graphql.types.ts +0 -467
  281. package/src/lib/auth/auth.config.ts +0 -83
  282. package/src/lib/auth/auth.gql.ts +0 -62
  283. package/src/lib/auth/auth.types.ts +0 -79
  284. package/src/lib/auth/idle.service.spec.ts +0 -119
  285. package/src/lib/auth/idle.service.ts +0 -208
  286. package/src/lib/auth/idle.types.ts +0 -11
  287. package/src/lib/auth/lbop.service.spec.ts +0 -56
  288. package/src/lib/auth/lbop.service.ts +0 -539
  289. package/src/lib/auth/life-ready-auth.service.spec.ts +0 -70
  290. package/src/lib/auth/life-ready-auth.service.ts +0 -454
  291. package/src/lib/auth/password.service.spec.ts +0 -51
  292. package/src/lib/auth/password.service.ts +0 -438
  293. package/src/lib/auth/register.service.spec.ts +0 -31
  294. package/src/lib/auth/register.service.ts +0 -181
  295. package/src/lib/auth/two-factor.service.spec.ts +0 -21
  296. package/src/lib/auth/two-factor.service.ts +0 -69
  297. package/src/lib/category/category-meta.service.spec.ts +0 -28
  298. package/src/lib/category/category-meta.service.ts +0 -125
  299. package/src/lib/category/category.gql.ts +0 -449
  300. package/src/lib/category/category.service.spec.ts +0 -26
  301. package/src/lib/category/category.service.ts +0 -498
  302. package/src/lib/category/category.types.ts +0 -89
  303. package/src/lib/cryptography/cryptography.types.ts +0 -108
  304. package/src/lib/cryptography/encryption.service.spec.ts +0 -125
  305. package/src/lib/cryptography/encryption.service.ts +0 -243
  306. package/src/lib/cryptography/key-factory.service.spec.ts +0 -15
  307. package/src/lib/cryptography/key-factory.service.ts +0 -303
  308. package/src/lib/cryptography/key-graph.service.spec.ts +0 -16
  309. package/src/lib/cryptography/key-graph.service.ts +0 -354
  310. package/src/lib/cryptography/key-meta.service.spec.ts +0 -40
  311. package/src/lib/cryptography/key-meta.service.ts +0 -254
  312. package/src/lib/cryptography/key.service.spec.ts +0 -16
  313. package/src/lib/cryptography/key.service.ts +0 -154
  314. package/src/lib/cryptography/slip39.service.spec.ts +0 -44
  315. package/src/lib/cryptography/slip39.service.ts +0 -204
  316. package/src/lib/cryptography/web-crypto.service.ts +0 -22
  317. package/src/lib/life-ready.config.ts +0 -127
  318. package/src/lib/life-ready.module.ts +0 -81
  319. package/src/lib/plan/plan.gql.ts +0 -133
  320. package/src/lib/plan/plan.service.spec.ts +0 -294
  321. package/src/lib/plan/plan.service.ts +0 -198
  322. package/src/lib/plan/plan.types.ts +0 -37
  323. package/src/lib/record/record-attachment.service.spec.ts +0 -31
  324. package/src/lib/record/record-attachment.service.ts +0 -101
  325. package/src/lib/record/record.gql.ts +0 -192
  326. package/src/lib/record/record.service.spec.ts +0 -598
  327. package/src/lib/record/record.service.ts +0 -236
  328. package/src/lib/record/record.types.ts +0 -86
  329. package/src/lib/record-type/record-type.service.spec.ts +0 -16
  330. package/src/lib/record-type/record-type.service.ts +0 -71
  331. package/src/lib/record-type/record-type.types.ts +0 -58
  332. package/src/lib/scenario/approvals/scenario-approval.gql.ts +0 -112
  333. package/src/lib/scenario/approvals/scenario-approval.types.ts +0 -85
  334. package/src/lib/scenario/approvals/scenario-approver.service.spec.ts +0 -16
  335. package/src/lib/scenario/approvals/scenario-approver.service.ts +0 -422
  336. package/src/lib/scenario/claimants/scenario-claimant.gql.ts +0 -56
  337. package/src/lib/scenario/claimants/scenario-claimant.service.spec.ts +0 -16
  338. package/src/lib/scenario/claimants/scenario-claimant.service.ts +0 -100
  339. package/src/lib/scenario/claimants/scenario-claimant.types.ts +0 -21
  340. package/src/lib/scenario/receivers/scenario-receiver.gql.ts +0 -157
  341. package/src/lib/scenario/receivers/scenario-receiver.service.spec.ts +0 -16
  342. package/src/lib/scenario/receivers/scenario-receiver.service.ts +0 -278
  343. package/src/lib/scenario/receivers/scenario-receiver.types.ts +0 -66
  344. package/src/lib/scenario/scenario-setup.service.spec.ts +0 -22
  345. package/src/lib/scenario/scenario-setup.service.ts +0 -369
  346. package/src/lib/scenario/scenario.gql.ts +0 -404
  347. package/src/lib/scenario/scenario.service.spec.ts +0 -1586
  348. package/src/lib/scenario/scenario.service.ts +0 -811
  349. package/src/lib/scenario/scenario.types.ts +0 -258
  350. package/src/lib/search/search.gql.ts +0 -62
  351. package/src/lib/search/search.service.spec.ts +0 -57
  352. package/src/lib/search/search.service.ts +0 -174
  353. package/src/lib/search/search.types.ts +0 -24
  354. package/src/lib/trusted-parties/tp-password-reset-request.service.ts +0 -140
  355. package/src/lib/trusted-parties/tp-password-reset-user.service.ts +0 -359
  356. package/src/lib/trusted-parties/tp-password-reset.gql.ts +0 -453
  357. package/src/lib/trusted-parties/tp-password-reset.service.spec.ts +0 -602
  358. package/src/lib/trusted-parties/tp-password-reset.service.ts +0 -482
  359. package/src/lib/trusted-parties/trusted-party.gql.ts +0 -159
  360. package/src/lib/trusted-parties/trusted-party.service.spec.ts +0 -1008
  361. package/src/lib/trusted-parties/trusted-party.service.ts +0 -394
  362. package/src/lib/trusted-parties/trusted-party.types.ts +0 -119
  363. package/src/lib/trusted-parties/trusted-party2.gql.ts +0 -165
  364. package/src/lib/trusted-parties/trusted-party2.service.spec.ts +0 -1782
  365. package/src/lib/trusted-parties/trusted-party2.service.ts +0 -272
  366. package/src/lib/users/profile-details.service.spec.ts +0 -45
  367. package/src/lib/users/profile-details.service.ts +0 -278
  368. package/src/lib/users/profile.gql.ts +0 -108
  369. package/src/lib/users/profile.service.spec.ts +0 -97
  370. package/src/lib/users/profile.service.ts +0 -224
  371. package/src/lib/users/profile.types.ts +0 -101
  372. package/src/lib/users/user.gql.ts +0 -69
  373. package/src/lib/users/user.service.spec.ts +0 -161
  374. package/src/lib/users/user.service.ts +0 -72
  375. package/src/lib/users/user.types.ts +0 -27
  376. package/src/test.ts +0 -21
  377. package/tsconfig.lib.json +0 -21
  378. package/tsconfig.lib.prod.json +0 -6
  379. package/tsconfig.spec.json +0 -10
  380. package/tslint.json +0 -17
@@ -0,0 +1,16 @@
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=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,p,d,l,y,h,v,f,m,g,S,I){"use strict";var b="default"in c?c.default:c,C="default"in u?u.default:u;y=y&&Object.prototype.hasOwnProperty.call(y,"default")?y.default:y;var k="default"in f?f.default:f,w=function(e,t){return(w=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)};
2
+ /*! *****************************************************************************
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
+ PERFORMANCE OF THIS SOFTWARE.
15
+ ***************************************************************************** */function K(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}w(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function P(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 R(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 D(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 A(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(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 $(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 O(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat($(arguments[t]));return e}function j(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}Object.create;function T(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(L.bind.apply(L,O([void 0],t)))}}var M,F,N=function(){},L=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}();(M=e.LrApiErrorCode||(e.LrApiErrorCode={})).ARCHIVED_RESOURCE="ARCHIVED_RESOURCE",M.BAD_ARGUMENT="BAD_ARGUMENT",M.BAD_SIGNATURE="BAD_SIGNATURE",M.BAD_STATE="BAD_STATE",M.CHANGED_PERMISSIONS="CHANGED_PERMISSIONS",M.CONCURRENT_ACCESS="CONCURRENT_ACCESS",M.CONFIG_ERROR="CONFIG_ERROR",M.CYCLE_DETECTED="CYCLE_DETECTED",M.EXPIRED="EXPIRED",M.INVALID_TOKEN="INVALID_TOKEN",M.INTERNAL_ERROR="INTERNAL_ERROR",M.JSON_DECODE_ERROR="JSON_DECODE_ERROR",M.KEY_MISMATCH="KEY_MISMATCH",M.LIMIT_REACHED="LIMIT_REACHED",M.LOCKED="LOCKED",M.LOGIC_ERROR="LOGIC_ERROR",M.LR_DEBUG_ONLY="LR_DEBUG_ONLY",M.MIN_DELAY="MIN_DELAY",M.MISSING_FIELD="MISSING_FIELD",M.MISSING_FIELD_VALUE="MISSING_FIELD_VALUE",M.MISSING_QUERY_PARAM="MISSING_QUERY_PARAM",M.NOT_IMPLEMENTED="NOT_IMPLEMENTED",M.OBJECT_DOES_NOT_EXIST="OBJECT_DOES_NOT_EXIST",M.OBJECT_EXISTS="OBJECT_EXISTS",M.RANGE_ERROR="RANGE_ERROR",M.TRUSTED_PARTY_NOT_FOUND="TRUSTED_PARTY_NOT_FOUND",M.UNAUTHENTICATED_USER="UNAUTHENTICATED_USER",M.USER_NOT_FOUND="USER_NOT_FOUND",M.VERSION_MISMATCH="VERSION_MISMATCH",M.WRONG_PERMISSIONS="WRONG_PERMISSIONS",(F=e.LrErrorCode||(e.LrErrorCode={})).BadTimeSync="LrBadTimeSync",F.ReceiveClaimMismatch="LrReceiveClaimMismatch",F.BadState="LrBadState",F.BadSignature="LrBadSignature",F.Auth="LrAuth",F.BadArgument="LrBadArgument",F.SuspiciousException="LrSuspiciousException",F.NotFound="LrNotFound",F.BadLogic="LrBadLogicException",F.CodeMismatch="LrCodeMismatchException",F.ConcurrentAccess="LrConcurrentAccessException",F.BadRequest="LrBadRequestException",F.Encryption="LrEncryptionGoBad",F.Locked="LrLockedException";var x,U,q=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadArgument,message:n})||this}return K(n,t),n}(L),J=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadArgument,message:n})||this}return K(n,t),n}(L),_=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.NotFound,message:n})||this}return K(n,t),n}(L),G=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadLogic,message:n})||this}return K(n,t),n}(L),B=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.CodeMismatch,message:n})||this}return K(n,t),n}(L),Q=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.ConcurrentAccess,message:n})||this}return K(n,t),n}(L),V=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.Locked,message:n})||this}return K(n,t),n}(L),W=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadRequest,message:n})||this}return K(n,t),n}(L),H=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.Auth,message:n})||this}return K(n,t),n}(L),Z=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.Encryption,message:n})||this}return K(n,t),n}(L),Y=function(e){function t(t){return e.call(this,{code:"LrUnsupportedException",message:t})||this}return K(t,e),t}(L),z=function(e){function t(t){return e.call(this,{code:"LrExpiredCodeException",message:t})||this}return K(t,e),t}(L),X=function(e){function t(t){return e.call(this,{code:"LrExpiredException",message:t})||this}return K(t,e),t}(L),ee=function(e){function t(t){return e.call(this,{code:"LrBadStateException",message:t})||this}return K(t,e),t}(L),te=new n.InjectionToken("LR.AUTH"),ne=[e.LrApiErrorCode.CONCURRENT_ACCESS],re=function(e,t){var n=i.setContext((function(e,n){var r=n.headers;return D(void 0,void 0,void 0,(function(){var e;return A(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 ne.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 K(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 ne.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)};(x=e.NodeType||(e.NodeType={})).Key="key",x.PassKey="passKey",(U=e.EdgeType||(e.EdgeType={})).KeyLink="keyLink",U.PassKeyLink="passKeyLink";var ie,ae,se=h,oe=y(ie||(ie=j(["\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 D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var t,n,r,i,a;return A(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 L({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 D(this,void 0,void 0,(function(){var e,t,n,r,i;return A(this,(function(a){switch(a.label){case 0:return e=Date.now(),[4,this.apollo.query({query:oe}).toPromise()];case 1:return t=a.sent(),n=Date.now(),T(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 D(this,void 0,void 0,(function(){var e,t;return A(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=n.ɵɵdefineInjectable({factory:function(){return new ce(n.ɵɵinject(d.AuthClass),n.ɵɵinject(l.Apollo))},token:ce,providedIn:"root"}),ce.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ce.ctorParameters=function(){return[{type:d.AuthClass},{type:l.Apollo}]},(ae=e.JoseSerialization||(e.JoseSerialization={})).JSON="JSON",ae.COMPACT="COMPACT";var ue={payloadType:"json",returnOnlyPayload:!0},pe={payloadType:"json",returnOnlyPayload:!0,serializations:[e.JoseSerialization.JSON]};function de(e){return"oct"===e.kty}function le(e){return e.id&&e.jwk?e.jwk:e.keystore&&e.length&&e.kty&&e.kid&&e.alg?e:null}var ye=function(){function t(e){this.timeService=e}return t.prototype.decrypt=function(t,n,r){return D(this,void 0,void 0,(function(){var i,a;return A(this,(function(s){switch(s.label){case 0:if(i={algorithms:["dir","A*GCM","RSA-OAEP-*"]},r=Object.assign(Object.assign({},pe),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,p.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 D(this,void 0,void 0,(function(){var n,r;return A(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 D(this,void 0,void 0,(function(){var n,r,i,a;return A(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=p.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 D(this,void 0,void 0,(function(){var n,r,i,a,s;return A(this,(function(o){switch(o.label){case 0:return i=(r=p.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 D(this,void 0,void 0,(function(){var n,r;return A(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 D(this,void 0,void 0,(function(){var i,a,s;return A(this,(function(o){switch(o.label){case 0:i={algorithms:["RS*"]},r=Object.assign(Object.assign({},ue),r),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,p.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 L({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 D(this,void 0,void 0,(function(){var e,i,a,s;return A(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 q("Unknown payloadType: "+e)}},t}();ye.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ye(n.ɵɵinject(ce))},token:ye,providedIn:"root"}),ye.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ye.ctorParameters=function(){return[{type:ce}]};var he=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 D(this,void 0,void 0,(function(){var n,r,i;return A(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}();he.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new he},token:he,providedIn:"root"}),he.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}];var ve=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 p.JWK.asKey(e,t,n)},e.prototype.randomString=function(e){if(e<=0)throw new q("digits <= 0");var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint32Array(e);return this.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 q("array.length <= 0");if(t<=0)throw new q("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 D(this,void 0,void 0,(function(){var t,n;return A(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 D(this,void 0,void 0,(function(){var t,n;return A(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 D(this,void 0,void 0,(function(){var t,n;return A(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 D(this,void 0,void 0,(function(){var t,n;return A(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 D(this,void 0,void 0,(function(){var t,s,o,c;return A(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 D(this,void 0,void 0,(function(){return A(this,(function(t){if(e.iterations<this.MIN_PASS_IDP_PBKDF_ITER)throw new J("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 D(this,void 0,void 0,(function(){return A(this,(function(t){if(e.iterations<this.MIN_PASS_KEY_PBKDF_ITER)throw new J("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 D(this,void 0,void 0,(function(){return A(this,(function(t){if(e.iterations<this.MIN_LBOP_KEY_PBKDF_ITER)throw new J("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 D(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return[4,this.createKey()];case 1:return[2,e.sent().kid]}}))}))},e.prototype.createPassIdpParams=function(){return D(this,void 0,void 0,(function(){return A(this,(function(e){return[2,{salt:this.createSalt(),iterations:this.DEFAULT_PASS_IDP_PBKDF_ITER}]}))}))},e.prototype.createPassKeyParams=function(){return D(this,void 0,void 0,(function(){var e;return A(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 D(this,void 0,void 0,(function(){var e;return A(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}();ve.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ve(n.ɵɵinject(he))},token:ve,providedIn:"root"}),ve.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ve.ctorParameters=function(){return[{type:he}]};var fe=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 q("Can not set PersistService cookie secure flag to false in production mode.");console.warn("The cookie secure flag in persistService has been set to false, set it to true in production mode")}},e.prototype.prefixName=function(e){return this.KEY_PREFIX+e},e.prototype.delete=function(e){this.deletePrefixedName(this.prefixName(e))},e.prototype.deletePrefixedName=function(e){var t=this.getCookieParams();this.cookieService.delete(e,t.path,t.domain,t.secure,t.sameSite),localStorage.removeItem(e)},e.prototype.set=function(e){var t=e.name,n=e.value,r=e.serverSession,i=e.expiry;return D(this,void 0,void 0,(function(){var e,a,s,o,c,u,p;return A(this,(function(d){switch(d.label){case 0:return e=this.prefixName(t),r?(s={serverSession:!0},[4,this.encryptionService.encryptToString(this.serverSessionEncryptionKey,n)]):[3,2];case 1:return s.data=d.sent(),a=s,[3,3];case 2:a={data:n},d.label=3;case 3:return i?[4,this.keyFactory.createKey()]:[3,6];case 4:return o=d.sent(),a.expiry=i.toISOString(),c=a,[4,this.encryptionService.encryptToString(o,a.data)];case 5:c.data=d.sent(),u={key:o.toJSON(!0)},p=this.getCookieParams(),this.cookieService.set(e,JSON.stringify(u),i,p.path,p.domain,p.secure,p.sameSite),d.label=6;case 6:return localStorage.setItem(e,JSON.stringify(a)),[2]}}))}))},e.prototype.get=function(e){return D(this,void 0,void 0,(function(){var t,n,r;return A(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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s;return A(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,ve.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}();fe.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new fe(n.ɵɵinject(ve),n.ɵɵinject(v.CookieService),n.ɵɵinject(ye),n.ɵɵinject(n.INJECTOR))},token:fe,providedIn:"root"}),fe.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],fe.ctorParameters=function(){return[{type:ve},{type:v.CookieService},{type:ye},{type:n.Injector}]};var me=function(){},ge=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 D(this,void 0,void 0,(function(){var n;return A(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 D(this,void 0,void 0,(function(){var t;return A(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 _("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 D(this,void 0,void 0,(function(){var t,n;return A(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 _("Could not find masterKey in persisted storage");if(t.id!==e)throw new _("masterKeyId "+t.id+" in persisted storage does not match the one requested "+e);return n=t,[4,ve.asKey(t.jwk)];case 2:n.jwk=r.sent(),this.masterKey=t,r.label=3;case 3:return[2,this.masterKey]}}))}))},e}();ge.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ge(n.ɵɵinject(te),n.ɵɵinject(fe))},token:ge,providedIn:"root"}),ge.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ge.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:fe}]};var Se=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 D(this,void 0,void 0,(function(){var t,n,r;return A(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 _("Key graphs does not contain key id: "+e);if(n.type!==t)throw new L({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=E(t.keys),u=c.next();!u.done;u=c.next()){var p=u.value;if(!this.graph.hasNode(p.id)){var d={type:e.NodeType.Key,data:C.cloneDeep(p)};this.graph.setNode(p.id,d)}}}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=E(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:C.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=E(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:C.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 Z("Param knownKeyId wrong format: "+e);if(!t||"string"!=typeof t)throw new Z("Param keyId wrong format: "+t);var n=b.alg.dijkstra(this.graph,e);return this.tracePath(n,t)},t.prototype.getJwkKey=function(e,t){return D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var n,r;return A(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 D(this,void 0,void 0,(function(){var r,i,a;return A(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,ve.asKey(i)];case 5:return a.jwk=s.sent(),n.task=null,[2]}}))}))},t.prototype._unwrap=function(e,t){return D(this,void 0,void 0,(function(){var n,r,i,a,s,o,c;return A(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),n=E(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 D(this,void 0,void 0,(function(){var r,i;return A(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 D(this,void 0,void 0,(function(){var n,r,i;return A(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 D(this,void 0,void 0,(function(){var r;return A(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 D(this,void 0,void 0,(function(){var n;return A(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 D(this,void 0,void 0,(function(){var n,r;return A(this,(function(i){switch(i.label){case 0:return null==t?[2,null]:(r=le(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 D(this,void 0,void 0,(function(){return A(this,(function(n){if(!de(t))throw new q("Only allowing wrapping of symmetric keys.");return[2,this.encryptToString(e,t.toJSON(!0))]}))}))},t}();Se.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Se(n.ɵɵinject(ye),n.ɵɵinject(ge))},token:Se,providedIn:"root"}),Se.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Se.ctorParameters=function(){return[{type:ye},{type:ge}]};var Ie=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 D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query(e).toPromise()];case 1:return T((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e.prototype.mutate=function(e){return D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return[4,this.apollo.mutate(e).toPromise()];case 1:return T((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e}();Ie.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Ie(n.ɵɵinject(l.Apollo),n.ɵɵinject(Se))},token:Ie,providedIn:"root"}),Ie.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ie.ctorParameters=function(){return[{type:l.Apollo},{type:Se}]};var be,Ce,ke,we,Ke,Pe,Re,De,Ae,Ee,$e,Oe,je="\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",Te=y(be||(be=j(["\nfragment KeyGraphFragment on KeyGraphType ","\n"],["\nfragment KeyGraphFragment on KeyGraphType ","\n"])),je),Me="keyGraph "+je,Fe="keyGraph: fetchKeyGraph "+je,Ne=y(Ce||(Ce=j(["\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"])),Te),Le=y(ke||(ke=j(["\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"])),Te),xe=y(we||(we=j(["\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"]))),Ue=y(Ke||(Ke=j(["\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"]))),qe=y(Pe||(Pe=j(["\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"]))),Je=y(Re||(Re=j(["\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"]))),_e=y(De||(De=j(["\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"]))),Ge=y(Ae||(Ae=j(['\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"])),Te),Be=y(Ee||(Ee=j(["\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"]))),Qe=y($e||($e=j(["\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"]))),Ve=function(){},We=function(){},He=function(){},Ze=function(e){this.name=e.name,this.title=e.title,this.firstName=e.firstName,this.lastName=e.lastName},Ye=function(){},ze=function(){},Xe=function(){},et=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return K(t,e),t}(Xe),tt=function(){};(Oe=e.PasswordChangeStatus||(e.PasswordChangeStatus={})).InProgress="IN_PROGRESS",Oe.Recovery="RECOVERY";var nt,rt=function(){},it=function(){};(nt=e.DirectoryType||(e.DirectoryType={})).Vault="vault",nt.Category="category",nt.Record="record";var at,st,ot,ct,ut,pt,dt,lt,yt,ht,vt,ft,mt,gt=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Vault,default:!0}}]}),St=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Category}}]}),It=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Record}}]}),bt="\naccessRoles {\n role\n method\n inheritedFrom {\n id\n }\n trustedParty {\n id\n }\n isIssuer\n}",Ct="\ndescendantDirectories(depth: 5, plainMeta: $categoryFilter, archived: false) {\n recordsCount: directoriesCount(plainMeta: $recordFilter, archived: false)\n}\n",kt="\n id\n keyId\n archived\n plainMeta\n cipherMeta\n "+bt+"\n "+Ct+"\n",wt="\n id\n keyId\n plainMeta\n cipherMeta\n",Kt=y(at||(at=j(["\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"]))),Pt=y(st||(st=j(['\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"])),kt,Te),Rt=y(ot||(ot=j(['\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"])),wt,Te),Dt=y(ct||(ct=j(['\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"])),kt,bt,Te),At=y(ut||(ut=j(['\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"])),kt,bt,Te),Et=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 "+Et(e-1)+"\n "+bt+"\n }\n }\n }\n}\n":""},$t=function(e){return void 0===e&&(e=5),y(pt||(pt=j(["\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"," "])),bt,Ct,Et(e),kt,bt,Te)},Ot=y(dt||(dt=j(["\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"])),Te),jt=y(lt||(lt=j(["\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"]))),Tt=y(yt||(yt=j(["\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"]))),Mt=y(ht||(ht=j(["\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"]))),Ft=y(vt||(vt=j(["\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"]))),Nt=y(ft||(ft=j(["\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"]))),Lt=y(mt||(mt=j(["\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"]))),xt=function(){},Ut=function(){},qt=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 D(this,void 0,void 0,(function(){var t;return A(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 D(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d;return A(this,(function(l){switch(l.label){case 0:return[4,this.keyFactory.createKey()];case 1:return r=l.sent(),[4,this.wrapContent(r.toJSON(!0),t)];case 2:return i=l.sent(),a={rootKey:i.rootKey,wrappedKeys:i.wrappedKeys,doubleWrappedKey:i.cipherMeta},e?(c=(o=JSON).stringify,[4,this.encryptionService.encrypt(r,e)]):[3,4];case 3:return s=c.apply(o,[l.sent()]),[3,5];case 4:s=null,l.label=5;case 5:return a.cipherMeta=s,n?(d=(p=JSON).stringify,[4,this.encryptionService.encrypt(r,n)]):[3,7];case 6:return u=d.apply(p,[l.sent()]),[3,8];case 7:u=null,l.label=8;case 8:return[2,(a.cipherFileContent=u,a)]}}))}))},e.prototype.reWrapContent=function(e,t){return D(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return A(this,(function(p){switch(p.label){case 0:return[4,this.keyGraph.getJwkKey(e)];case 1:return n=p.sent(),[4,this.keyFactory.createKey()];case 2:return r=p.sent(),i={},s=(a=JSON).stringify,[4,this.encryptionService.encrypt(n,r.toJSON(!0))];case 3:return i.doubleWrappedKey=s.apply(a,[p.sent()]),t?(u=(c=JSON).stringify,[4,this.encryptionService.encrypt(r,t)]):[3,5];case 4:return o=u.apply(c,[p.sent()]),[3,6];case 5:o=null,p.label=6;case 6:return[2,(i.cipherMeta=o,i)]}}))}))},e.prototype.wrapContent=function(e,t){return D(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y=this;return A(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 D(y,void 0,void 0,(function(){var t,r,i,a;return A(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=(d=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,7];case 6:return p=l.apply(d,[h.sent()]),[3,8];case 7:p=null,h.label=8;case 8:return[2,(u.cipherMeta=p,u)]}}))}))},e.prototype.wrapContentWithKey=function(e,t){return D(this,void 0,void 0,(function(){var n,r,i,a,s,o;return A(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 D(this,void 0,void 0,(function(){var t,n;return A(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Ot,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}();qt.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new qt(n.ɵɵinject(ye),n.ɵɵinject(Se),n.ɵɵinject(Ie),n.ɵɵinject(ge),n.ɵɵinject(ve))},token:qt,providedIn:"root"}),qt.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],qt.ctorParameters=function(){return[{type:ye},{type:Se},{type:Ie},{type:ge},{type:ve}]};var Jt,_t,Gt,Bt,Qt,Vt,Wt,Ht,Zt,Yt,zt,Xt,en,tn,nn,rn,an="\nid\npublicData\npublicSearchable\ncipherData\nkey {\n id\n}\n",sn=(y(Jt||(Jt=j(["\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}"])),an,Me),y(_t||(_t=j(['\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}"])),an,Me),y(Gt||(Gt=j(['\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}"])),an,Me)),on=(y(Bt||(Bt=j(["\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}"])),an),y(Qt||(Qt=j(["\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}"])),an),y(Vt||(Vt=j(["\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=y(Wt||(Wt=j(["\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"]))),un=y(Ht||(Ht=j(["\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"]))),pn="\n name\n data\n state\n",dn=y(Zt||(Zt=j(["\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}"])),pn),ln=y(Yt||(Yt=j(["\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"]))),yn=y(zt||(zt=j(["\nquery UserIssuablePlans {\n userIssuablePlans {\n plan {\n ","\n }\n }\n}\n"],["\nquery UserIssuablePlans {\n userIssuablePlans {\n plan {\n ","\n }\n }\n}\n"])),pn),hn=y(Xt||(Xt=j(["\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"]))),vn=y(en||(en=j(["\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"])),pn),fn=y(tn||(tn=j(["\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}"])),pn),mn=y(nn||(nn=j(["\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"])),pn),gn=y(rn||(rn=j(["\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 Sn(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 In=function(){function e(e){this.lrApollo=e}return e.prototype.createStripeCheckoutSession=function(e){return D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:un,variables:{returnUrl:e}})];case 1:return[2,{url:t.sent().createStripeBillingPortalSession.sessionUrl}]}}))}))},e.prototype.getUserIssuablePlans=function(){return D(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:yn})];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 D(this,void 0,void 0,(function(){var e,a;return A(this,(function(s){switch(s.label){case 0:if(null==r&&null==i)throw new q('Must specify either "planPeriodEnd" or "planPeriodEndAfterSeconds"');return[4,this.lrApollo.mutate({mutation:dn,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 D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:ln,variables:{input:{id:e}}})];case 1:return[2,t.sent()]}}))}))},e.prototype.getUserIssuedPlans=function(){return D(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:hn})];case 1:return[2,e.sent().userIssuedPlans.edges.map((function(e){return e.node}))]}}))}))},e.prototype.getUserIssuedPlan=function(e,t){return D(this,void 0,void 0,(function(){return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:vn,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 D(this,void 0,void 0,(function(){var e,r;return A(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:fn,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 D(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:mn})];case 1:return[2,Sn(e.sent().userPlans)]}}))}))},e.prototype.getPlanType=function(e){return D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:gn})];case 1:return[2,e.sent().stripe]}}))}))},e}();In.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new In(n.ɵɵinject(Ie))},token:In,providedIn:"root"}),In.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],In.ctorParameters=function(){return[{type:Ie}]};var bn=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 D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var e,t,n,r,i;return A(this,(function(a){switch(a.label){case 0:return[4,this.lrApollo.query({query:Ge})];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:Sn(r)}]}}))}))},e.prototype.decryptContactCard=function(e){return D(this,void 0,void 0,(function(){var t;return A(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 D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return A(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 Ze(e.name.value)},d=(p=JSON).stringify,[4,this.encryptionService.sign(t.jwk,c)];case 4:return u=d.apply(p,[l.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:u}]}}))}))},e.prototype.createContactCard=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i;return A(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:Be,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 D(this,void 0,void 0,(function(){var r,i;return A(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:Qe,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 D(this,void 0,void 0,(function(){var t=this;return A(this,(function(n){return[2,Promise.all(e.map((function(e){return D(t,void 0,void 0,(function(){var t;return A(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 D(this,void 0,void 0,(function(){var e;return A(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 D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:on,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteContactCard.id]}}))}))},e.prototype.signOut=function(){return D(this,void 0,void 0,(function(){return A(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}();bn.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new bn(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(Ie),n.ɵɵinject(ge),n.ɵɵinject(qt),n.ɵɵinject(Se),n.ɵɵinject(ye))},token:bn,providedIn:"root"}),bn.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],bn.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:Ie},{type:ge},{type:qt},{type:Se},{type:ye}]};var Cn=function(e){function t(){var t=e.apply(this,O(arguments))||this;return t.isTpPasswordResetUser=!1,t}return K(t,e),t}(f.CognitoUser);(e.FeatureAction||(e.FeatureAction={})).ACCESS="access";var kn,wn=function(){},Kn=function(){},Pn=function(){},Rn=function(){};function Dn(e,t){var n=e.definitions.filter((function(e){return"OperationDefinition"===e.kind}));if(n.length>1)throw new G("There can be only one '"+t+"' operation, instead there are "+n.length);return n[0]}function An(e){return Dn(e,"query")}function En(e){return Dn(e,"mutation")}function $n(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function On(e){return{kind:"Name",value:e}}function jn(e){var t;return(null===(t=e.alias)||void 0===t?void 0:t.value)||e.name.value}function Tn(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return y.apply(void 0,O([e],t))}(kn=e.RecoveryStatus||(e.RecoveryStatus={})).NONE="none",kn.NEW_PASSWORD="new-password",kn.OLD_PASSWORD="old-password";var Mn,Fn,Nn,Ln,xn,Un,qn=y(Mn||(Mn=j(["\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"]))),Jn=y(Fn||(Fn=j(["\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"]))),_n=y(Nn||(Nn=j(["\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"]))),Gn=Tn(Ln||(Ln=j(["\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"])));Tn(xn||(xn=j(["\nmutation ClearSessionEncryptionKeyMutation {\n clearSessionEncryptionKey(input: {}) {\n sessionEncryptionKey\n }\n}\n"],["\nmutation ClearSessionEncryptionKeyMutation {\n clearSessionEncryptionKey(input: {}) {\n sessionEncryptionKey\n }\n}\n"])));(Un=e.Config||(e.Config={}))[Un.TIMEOUT=.01]="TIMEOUT",Un[Un.IDLE=1200]="IDLE",Un[Un.KEEP_ALIVE_INTERVAL=60]="KEEP_ALIVE_INTERVAL";var Bn=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 ee("Call IdleService.init() first.")},t.prototype.init=function(t){return D(this,void 0,void 0,(function(){var n,r=this;return A(this,(function(i){switch(i.label){case 0:if(this.initCalled)throw new ee("IdleService.init() can only be called once. IdleService.start() calls init() with default values if init() has not been called yet.");if(this.initCalled=!0,(t=Object.assign({onTimeout:null,onKeepalive:null,idleSec:e.Config.IDLE,timeoutSec:e.Config.TIMEOUT,keepAliveIntervalSec:e.Config.KEEP_ALIVE_INTERVAL},t)).timeoutSec<.01)throw new q("Minimum value for IdleService.init({ timeoutSec }) is 0.01");return this.onTimeout=t.onTimeout,this.onKeepalive=t.onKeepalive,this.idle.setIdle(t.idleSec),this.idle.setTimeout(t.timeoutSec),this.idle.setInterrupts(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 D(r,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var e;return A(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 D(this,void 0,void 0,(function(){var t;return A(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 D(this,void 0,void 0,(function(){var e;return A(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 D(this,void 0,void 0,(function(){return A(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}();Bn.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Bn(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(m.Idle),n.ɵɵinject(g.Keepalive),n.ɵɵinject(ge),n.ɵɵinject(d.AuthClass))},token:Bn,providedIn:"root"}),Bn.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Bn.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:m.Idle},{type:g.Keepalive},{type:ge},{type:d.AuthClass}]};var Qn=h,Vn=function(){},Wn=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 D(this,void 0,void 0,(function(){var t,n;return A(this,(function(r){switch(r.label){case 0:return t=this.passwordStrength(e).years,n={length:e.length,timeToCrack:Qn.duration({years:t})},[4,this.getExposureCount(e)];case 1:return[2,(n.passwordExposed=r.sent(),n)]}}))}))},e.prototype.getExposureCount=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i;return A(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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s;return A(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 D(this,void 0,void 0,(function(){var e,t,n,r;return A(this,(function(i){switch(i.label){case 0:return[4,this.getChangePasswordConfig()];case 1:return e=i.sent(),t=Qn(e.authTime),n=Qn(e.serverTime),r=Qn.duration(n.diff(t)),r.asSeconds()>e.maxAuthAgeSeconds?[2,!0]:[2,!1]}}))}))},e.prototype.changePassword=function(e,t){return D(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d;return A(this,(function(l){switch(l.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:if(n=l.sent(),e===t)throw new q("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 p=l.sent(),d=p.token,p.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,d)];case 9:return l.sent(),[2]}}))}))},e.prototype.changePasswordComplete=function(e,t,n){return void 0===n&&(n=null),D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var n;return A(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,ve.asKey(n)];case 2:throw r.sent(),new H("Wrong current password");case 3:return[2]}}))}))},e.prototype.verifyPassword=function(e,t){return D(this,void 0,void 0,(function(){var n,r,i,a,s;return A(this,(function(o){switch(o.label){case 0:return[4,this.apollo.mutate({mutation:qn,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 D(this,void 0,void 0,(function(){var i;return A(this,(function(a){switch(a.label){case 0:return[4,this.apollo.mutate({mutation:Jn,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 D(this,void 0,void 0,(function(){var e,t;return A(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query({query:_n})];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}();Wn.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Wn(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(Ie),n.ɵɵinject(d.AuthClass),n.ɵɵinject(bn),n.ɵɵinject(ve),n.ɵɵinject(ye),n.ɵɵinject(Se),n.ɵɵinject(he),n.ɵɵinject(Bn))},token:Wn,providedIn:"root"}),Wn.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Wn.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:Ie},{type:d.AuthClass},{type:bn},{type:ve},{type:ye},{type:Se},{type:he},{type:Bn}]};var Hn,Zn,Yn,zn,Xn,er,tr,nr,rr,ir,ar,sr,or,cr,ur=Tn(Hn||(Hn=j(["\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}"]))),pr=Tn(Zn||(Zn=j(["\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"])),ur),dr=Tn(Yn||(Yn=j(["\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"])),ur),lr=Tn(zn||(zn=j(["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"],["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"]))),yr=Tn(Xn||(Xn=j(["\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}"]))),hr=Tn(er||(er=j(["\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}"]))),vr=Tn(tr||(tr=j(["\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}"]))),fr=Tn(nr||(nr=j(["\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}"]))),mr=Tn(rr||(rr=j(["\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}"]))),gr=Tn(ir||(ir=j(["\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}"]))),Sr=Tn(ar||(ar=j(["\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}"]))),Ir=Tn(sr||(sr=j(["\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}"]))),br=Tn(or||(or=j(["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"],["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"]))),Cr=Tn(cr||(cr=j(["\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 kr(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 wr(e,t){var n,r,i={};try{for(var a=E(Object.keys(e).entries()),s=a.next();!s.done;s=a.next()){var o=$(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 Kr(e,t){var n=kr(Object.entries(e).map((function(n){var r=$(n,2),i=r[0],a=r[1];return t(a,i,e)})));return n.then?n.then((function(t){return wr(e,t)})):wr(e,n)}var Pr=["constructor","ngOnChanges","ngOnInit","ngDoCheck","ngAfterContentInit","ngAfterContentChecked","ngAfterViewInit","ngAfterViewChecked","ngOnDestroy"];function Rr(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 G("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=O(a,Pr),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 Dr={hasKeys:!0};function Ar(e,t){return D(this,void 0,void 0,(function(){var n,r,i,a,s=this;return A(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 D(s,void 0,void 0,(function(){var n,r,i,a;return A(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 Er(e,t){return Object.assign(Object.assign({},e),{path:O(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 D(t,void 0,void 0,(function(){var t,n,s,o,c;return A(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),t=E(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 D(t,void 0,void 0,(function(){var t,n,i,a,s,u;return A(this,(function(p){switch(p.label){case 0:return n=e.field,i=e.context,e.options.hasKeys?!(a=n[r])||c in n?[2,n]:o?[4,o(e)]:[3,2]:[2,n];case 1:return u=p.sent(),[3,3];case 2:u=n.keyId||(null===(t=n.key)||void 0===t?void 0:t.id),p.label=3;case 3:if(!(s=u))throw new G("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=n.ɵɵdefineInjectable({factory:function(){return new e.CommonProcessorsService(n.ɵɵinject(n.NgZone),n.ɵɵinject(Se))},token:e.CommonProcessorsService,providedIn:"root"}),e.CommonProcessorsService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.CommonProcessorsService.ctorParameters=function(){return[{type:n.NgZone},{type:Se}]},e.CommonProcessorsService=R([Rr({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 D(this,void 0,void 0,(function(){var n,r,i,a,s=this;return A(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 D(this,void 0,void 0,(function(){var n,r;return A(this,(function(i){switch(i.label){case 0:return n=Object.assign({},e),e.receiverCipher&&(n.receiverCipherClearJson=this.keyGraph.decryptFromString(t,e.receiverCipher)),e.receiverCipherPartialAssemblyKey?(r=n,[4,this.keyGraph.decryptFromString(t,e.receiverCipherPartialAssemblyKey)]):[3,2];case 1:r.receiverCipherPartialAssemblyKeyClearJson=i.sent(),i.label=2;case 2:return[2,n]}}))}))},e.prototype.makeTpPasswordResetNodeProcessor=function(){var e=this;return function(t){var n=t.field;return D(e,void 0,void 0,(function(){var e,t;return A(this,(function(r){switch(r.label){case 0:if(e=Object.assign({},n),!n.assembly)return[3,2];if(null==n.applied)throw new W("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 D(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l=this;return A(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)],p={},[4,Ar(a,(function(e){return l.processTpSubAssemblyNode(e,n.id,t)}))];case 1:return s=c.apply(o,u.concat([(p.subAssemblies=y.sent(),p)])),t?[3,3]:i?(d=s,[4,this.keyGraph.decryptFromString(r.id,i)]):[3,3];case 2:d.assemblyCipherDataClearJson=y.sent(),y.label=3;case 3:return[2,s]}}))}))},e.prototype.processTpSubAssemblyNode=function(e,t,n){return D(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d=this;return A(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,Ar(i,(function(e){return d.processTpAssemblyApproverNode(e,n)}))];case 1:return a=o.apply(s,c.concat([(u.approvers=l.sent(),u)])),n?[3,3]:r?(p=a,[4,this.keyGraph.decryptFromString(t,r)]):[3,3];case 2:p.subjectCipherDataClearJson=l.sent(),l.label=3;case 3:return[2,a]}}))}))},e.prototype.processTpAssemblyApproverNode=function(e,t){return D(this,void 0,void 0,(function(){return A(this,(function(t){return[2,e]}))}))},e}(),e.ɵc.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ɵc(n.ɵɵinject(n.NgZone),n.ɵɵinject(Se))},token:e.ɵc,providedIn:"root"}),e.ɵc.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ɵc.ctorParameters=function(){return[{type:n.NgZone},{type:Se}]},e.ɵc=R([Rr({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 D(this,void 0,void 0,(function(){var n=this;return A(this,(function(r){return t=Object.assign(Object.assign({},Dr),t),[2,Kr(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 D(this,void 0,void 0,(function(){var e,i,a,s=this;return A(this,(function(o){if(null==t?void 0:t.then)throw new G("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?Kr(e,(function(e,t){return s.processField({field:e,context:Er(n,t),options:r})})):e},t=t.then?t.then((function(e){return a(e)})):a(t)):n.processChildren&&Array.isArray(t)&&(t=kr(t.map((function(e,t){return s.processField({field:e,context:Er(n,t.toString()),options:r})})))),[2,t])}))}))},e.prototype.registerProcessor=function(e,t){if(this.processors[e])throw new G("Processor for field "+e+" already exists.");this.processors[e]=t},e}(),e.QueryProcessorService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.QueryProcessorService(n.ɵɵinject(n.NgZone),n.ɵɵinject(ge),n.ɵɵinject(e.CommonProcessorsService),n.ɵɵ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:ge},{type:e.CommonProcessorsService},{type:e.ɵc}]},e.QueryProcessorService=R([Rr({ngZoneName:"ngZone"})],e.QueryProcessorService);var $r,Or,jr,Tr=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}(),Mr=An(y($r||($r=j(["\n query {\n ...FragmentName\n }\n"],["\n query {\n ...FragmentName\n }\n"])))).selectionSet.selections[0],Fr=function(){function e(){this._executed=!1,this.deferredPromise=new Tr}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 ee("Already executed");this._executed=!0},e}(),Nr=function(e){function t(t){var n=e.call(this)||this;return n.mutation=t.mutation,n.variables=t.variables,n}return K(t,e),t.prototype.select=function(e){var n=u.cloneDeep(this.mutation),r=En(n),i={};$n(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=jn(t);i[n]&&(t.selectionSet.selections=[Object.assign(Object.assign({},Mr),{name:On(n)})])}(e)})),new t({mutation:Object.assign(Object.assign({},n),{definitions:O(n.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})),e.definitions)}),variables:this.variables})},t}(Fr),Lr={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"lrMergedMutation"},variableDefinitions:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[]}}]},xr=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 K(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 G("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 Nr)n(e);else{if(!(e instanceof t))throw new Y("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:On(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:On(t+e.value.name.value)})})},t.prototype.renameField=function(e,t){var n=this;if("Field"!==e.kind)return e;var r=t+jn(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:On(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:On(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,p=s.lrMutationData,d=p.mutation,l=p.variables,y=En(d),h="item"+o+"_";y.name&&(h+=y.name.value+"_"),a.push(h),t=O(t,e.renameVariableDefinitions(y.variableDefinitions,h)),n=O(n,e.renameSelections(y.selectionSet.selections,h));try{for(var v=E(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=$n(d);i=O(i,e.renameFragmentDefinitions(g,h))}));var s=u.cloneDeep(Lr),o=En(s);return o.selectionSet.selections=n,o.variableDefinitions=t,s.definitions=O(s.definitions,i),{mutation:s,variables:r,prefixes:a}},t}(Fr),Ur=An(y(Or||(Or=j(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Me)).selectionSet.selections[0],qr=An(y(jr||(jr=j(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Fe)).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 D(this,void 0,void 0,(function(){var t,n;return A(this,(function(r){switch(r.label){case 0:return e=u.cloneDeep(e),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=An(e.query)).selectionSet.selections=O(t.selectionSet.selections,[Ur])),[4,this.apollo.query(e).toPromise()];case 1:return n=r.sent(),this.stats.queryCount++,T(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 D(this,void 0,void 0,(function(){return A(this,(function(n){if(null==t?void 0:t.variables)throw new Y('Unsupported field: "options.variables"');if(e.executed)throw new ee("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 D(this,void 0,void 0,(function(){var t,n;return A(this,(function(r){switch(r.label){case 0:return e=Object.assign(Object.assign({},e),{mutation:u.cloneDeep(e.mutation)}),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=En(e.mutation)).selectionSet.selections=O(t.selectionSet.selections,[qr])),e.mutation=y(S.print(e.mutation)),[4,this.apollo.mutate(e).toPromise()];case 1:return n=r.sent(),this.stats.mutationCount++,T(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.statsSnapshot=function(){return u.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 D(this,void 0,void 0,(function(){var n,r,i,a;return A(this,(function(s){switch(s.label){case 0:return e instanceof Array?(i=(r=xr).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=n.ɵɵdefineInjectable({factory:function(){return new e.ɵb(n.ɵɵinject(n.NgZone),n.ɵɵinject(l.Apollo),n.ɵɵinject(Se),n.ɵɵ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:Se},{type:e.QueryProcessorService}]},e.ɵb=R([Rr({ngZoneName:"ngZone"})],e.ɵb);var Jr,_r,Gr,Br,Qr,Vr,Wr,Hr,Zr,Yr,zr=function(){function t(t){this.lrGraphQL=t.get(e.ɵb)}return t.prototype.mutate=function(e,t){return D(this,void 0,void 0,(function(){return A(this,(function(n){return[2,this.lrGraphQL.lrMutate(e,t)]}))}))},t.prototype.query=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){return[2,this.lrGraphQL.query(e)]}))}))},t}();!function(e){e.READER="READER",e.WRITER="WRITER",e.ADMIN="ADMIN",e.DENY="DENY",e.OWNER="OWNER"}(Jr||(Jr={})),function(e){e.inherited="inherited",e.direct="direct"}(_r||(_r={})),function(e){e.CREATE="CREATE",e.READ="READ",e.UPDATE="UPDATE",e.REVERT="REVERT",e.DELETE="DELETE"}(Gr||(Gr={})),function(e){e.OTK_INITIATED="OTK_INITIATED",e.OTK_ACCEPTED="OTK_ACCEPTED",e.OTK_COMPLETED="OTK_COMPLETED"}(Br||(Br={})),function(e){e.IN_PROGRESS="IN_PROGRESS",e.COMPLETED="COMPLETED",e.DECLINED="DECLINED",e.CANCELLED="CANCELLED",e.DELETED="DELETED"}(Qr||(Qr={})),function(e){e.OTK="OTK"}(Vr||(Vr={})),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"}(Wr||(Wr={})),function(e){e.CLAIMED="CLAIMED",e.APPROVED="APPROVED",e.REJECTED="REJECTED",e.EXPIRED="EXPIRED",e.CANCELLED="CANCELLED",e.RESET="RESET"}(Hr||(Hr={})),function(e){e.CLAIMED="CLAIMED",e.APPROVED="APPROVED",e.REJECTED="REJECTED"}(Zr||(Zr={})),function(e){e.UNLOCKED="UNLOCKED",e.MUTEX_LOCKED="MUTEX_LOCKED"}(Yr||(Yr={}));var Xr=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},ei=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}(),ti=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}(),ni=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}(),ri=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}(),ii=function(){function e(){}return e.prototype.generateShares=function(e,t,n){return D(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p;return A(this,(function(d){switch(d.label){case 0:r=btoa(e),r=I.Slip39Helper.slip39EncodeHex(r),i=[];try{for(a=E(n.subAssemblies),s=a.next();!s.done;s=a.next())o=s.value,i.push([o.threshold,o.size])}catch(e){u={error:e}}finally{try{s&&!s.done&&(p=a.return)&&p.call(a)}finally{if(u)throw u.error}}return[4,I.Slip39.fromArray(r,{passphrase:t,threshold:n.threshold,groups:i,title:""})];case 1:return c=d.sent(),n.subAssemblies.forEach((function(e,t){e.clearShares();for(var n=0;n<e.size;n++){var r="r/"+t.toString().padStart(2,"0")+"/"+n.toString().padStart(2,"0"),i=c.fromPath(r).mnemonics[0],a=new Xr(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(e),c=o.next();!c.done;c=o.next()){var u=c.value,p=I.Slip39Helper.decodeMnemonic(u);if(a&&a!==p.groupThreshold)throw new Error("groupThreshold is different in mnemonics");a=p.groupThreshold,null==(v=s.get(p.groupIndex))&&(v={memberThreshold:p.memberThreshold,members:[]},s.set(p.groupIndex,v)),v.members.push({mnemonic:u,decoded:p})}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}var d=[],l=0;try{for(var y=E(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){d.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 d},e.prototype.recoverSecret=function(e,t){return D(this,void 0,void 0,(function(){var n,r;return A(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}();ii.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ii},token:ii,providedIn:"root"}),ii.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ii.ctorParameters=function(){return[]};var ai="lifeready",si=function(e){return function(){return e.initialise()}},oi=function(){function t(e,t,n,r,i,a,s,c,u,p,d,l,y){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=p,this.persistService=d,this.encryptionService=l,this.slip39Service=y,this.hubSubject=new o.ReplaySubject(1)}return t.prototype.initialise=function(){return D(this,void 0,void 0,(function(){var e=this;return A(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 D(this,void 0,void 0,(function(){var i,a;return A(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 D(this,void 0,void 0,(function(){var r,i,a,s,o,c;return A(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 Q("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 W("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 D(this,void 0,void 0,(function(){var e,t;return A(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 Nr({mutation:Gn,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 D(this,void 0,void 0,(function(){return A(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,n){var r,i=(void 0===n?{}:n).tpPasswordResetAutoComplete,a=void 0===i||i;return D(this,void 0,void 0,(function(){var n;return A(this,(function(i){switch(i.label){case 0:return[4,this.loginImpl(e,t)];case 1:return n=i.sent(),a&&(null===(r=n.resetUser)||void 0===r?void 0:r.state)===Hr.APPROVED?[4,this.completeRequest(t)]:[3,4];case 2:return i.sent(),[4,this.loginImpl(e,t)];case 3:n=i.sent(),i.label=4;case 4:return[2,n]}}))}))},t.prototype.loginImpl=function(e,t){return D(this,void 0,void 0,(function(){var n,r;return A(this,(function(i){switch(i.label){case 0:return[4,this.logout()];case 1:return i.sent(),[4,this.loginIdp(e,t)];case 2:return n=i.sent(),["SMS_MFA","SOFTWARE_TOKEN_MFA"].includes(n.challengeName)?[2,{hasChallenge:!0,challenge:n}]:[4,this.handlePostAuth(n)];case 3:return i.sent(),n.isTpPasswordResetUser?[4,this.loadResetUser(t)]:[3,5];case 4:return[2,{hasChallenge:!1,resetUser:i.sent()}];case 5:return[4,this.loadUser(n,t)];case 6:return r=i.sent(),[4,this.idleService.start()];case 7:return i.sent(),[2,{hasChallenge:!1,user:r}]}}))}))},t.prototype.verifyLogin=function(e,t,n,r){return D(this,void 0,void 0,(function(){var i,a;return A(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 D(this,void 0,void 0,(function(){var n;return A(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.getUserOrResetUser=function(e){return void 0===e&&(e=!1),D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t.sent().getUsername().endsWith(".tp_password_reset")?[2,this.getResetUser(e)]:[2,this.getUser(e)]}}))}))},t.prototype.getResetUser=function(e){return void 0===e&&(e=!1),D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return!e&&this.currentResetUser?[2,this.currentResetUser]:(t=this,[4,this.loadResetUser()]);case 1:return t.currentResetUser=n.sent(),[4,this.idleService.start()];case 2:return n.sent(),[2,this.currentResetUser]}}))}))},t.prototype.getUser=function(e){return void 0===e&&(e=!1),D(this,void 0,void 0,(function(){var t,n;return A(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 D(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,d,l,y,h,v,f;return A(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,p.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=(d=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(r.currentUserKey.passKey.id,u,r.currentUserKey.masterKey.id)];case 6:return[4,l.apply(d,[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 D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d,l,y,h,v,f;return A(this,(function(m){switch(m.label){case 0:return[4,this.lrGraphQL.query({query:gr})];case 1:return(t=m.sent().tpPasswordResetUser).sessionEncryptionKey?(r=(n=this.persistService).setServerSessionEncryptionKey,[4,p.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(),d=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:d}])]}}))}))},t.prototype.refreshAccessToken=function(){return D(this,void 0,void 0,(function(){var e,t;return A(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.prototype.completeRequest=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a,o,c,u,d,l,y,h,v,f,m=this;return A(this,(function(g){switch(g.label){case 0:return[4,this.getResetUser(!0)];case 1:if((t=g.sent()).state!==Hr.APPROVED)throw new ee("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,p.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.lrGraphQL.lrMutate(new Nr({mutation:yr,variables:{input:{}}}),{includeKeyGraph:!1})];case 8:return d=g.sent().createTpAssemblyKeyChallenge.challenge,console.log(d),d.clientNonce=this.keyFactory.randomString(32),console.log(d),[4,this.encryptionService.decrypt(n,t.wrappedAssemblyKeyVerifierPrk)];case 9:return l=g.sent(),[4,this.encryptionService.sign(l,d)];case 10:return y=g.sent(),[4,this.lrGraphQL.lrMutate(new Nr({mutation:hr,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 D(m,void 0,void 0,(function(){return A(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.lrGraphQL.lrMutate(new Nr({mutation:vr,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 L({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]}}))}))},t.prototype.recoverAssemblyKey=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a=this;return A(this,(function(s){switch(s.label){case 0:return[4,this.keyGraphService.getKey(e.pxk.id)];case 1:return n=s.sent(),[4,Promise.all(e.approvals.filter((function(e){return!!e.receiverCipherPartialAssemblyKey})).map((function(e){return D(a,void 0,void 0,(function(){var r;return A(this,(function(i){switch(i.label){case 0:return[4,this.encryptionService.decrypt(n,e.receiverCipherPartialAssemblyKey)];case 1:if(r=i.sent(),t){if(JSON.stringify(t)!==JSON.stringify(r.assemblyKeyParams))throw new ee("The assembly key parameters are different between the approvals.")}else t=r.assemblyKeyParams;return[2,r.slip39.share.mnemonics]}}))}))})))];case 2:return r=s.sent(),console.log("recoverAssemblyKey()",r),[4,this.slip39Service.recoverSecret(r,ai)];case 3:return i=s.sent(),[2,p.JWK.asKey(Object.assign(Object.assign({},t),{k:i}))]}}))}))},t}();oi.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new oi(n.ɵɵinject(te),n.ɵɵinject(d.AuthClass),n.ɵɵinject(ve),n.ɵɵinject(ge),n.ɵɵinject(bn),n.ɵɵinject(Se),n.ɵɵinject(Wn),n.ɵɵinject(Bn),n.ɵɵinject(e.ɵb),n.ɵɵinject(e.ɵc),n.ɵɵinject(fe),n.ɵɵinject(ye),n.ɵɵinject(ii))},token:oi,providedIn:"root"}),oi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],oi.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:d.AuthClass},{type:ve},{type:ge},{type:bn},{type:Se},{type:Wn},{type:Bn},{type:e.ɵb},{type:e.ɵc},{type:fe},{type:ye},{type:ii}]};var ci=function(){function e(e,t,n){this.config=e,this.http=t,this.lrAuth=n}return e.prototype.downloadEncryptedFile=function(e){return D(this,void 0,void 0,(function(){var t,n;return A(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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o;return A(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 D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return A(this,(function(p){switch(p.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+p.sent().getAccessJwtToken(),c),o)])).toPromise()];case 2:return[2,p.sent().content_resource]}}))}))},e}();ci.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ci(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(oi))},token:ci,providedIn:"root"}),ci.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ci.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:oi}]};var ui,pi,di,li,yi=y(ui||(ui=j(["\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"]))),hi=y(pi||(pi=j(["\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"]))),vi=y(di||(di=j(["\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"]))),fi=y(li||(li=j(["\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"]))),mi=function(){function e(e){this.lrApollo=e}return e.prototype.getUserByEmail=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){return[2,this.getUser({email:e})]}))}))},e.prototype.getUserByUsername=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){return[2,this.getUser({username:e})]}))}))},e.prototype.getUser=function(e){var t=e.email,n=e.username;return D(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:yi,variables:{email:t,username:n}})];case 1:return[2,e.sent().user]}}))}))},e.prototype.requestUserDelete=function(){return D(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:hi,variables:{input:{}}})];case 1:return[2,e.sent().requestUserDelete.userDelete]}}))}))},e.prototype.cancelUserDelete=function(){return D(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:vi,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),D(this,void 0,void 0,(function(){return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:fi,variables:{first:e,after:t}})];case 1:return[2,n.sent().loginHistory]}}))}))},e}();mi.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new mi(n.ɵɵinject(Ie))},token:mi,providedIn:"root"}),mi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],mi.ctorParameters=function(){return[{type:Ie}]};var gi,Si,Ii,bi,Ci,ki,wi,Ki,Pi="\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}",Ri="\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",Di=y(gi||(gi=j(["\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",""])),Ri,Te),Ai=y(Si||(Si=j(["\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"])),Pi,Te),Ei=y(Ii||(Ii=j(["\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"])),Pi,Te),$i=y(bi||(bi=j(["\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}"])),Pi),Oi=y(Ci||(Ci=j(["\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}"])),Pi,Fe),ji=y(ki||(ki=j(["\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}"])),Pi,Ri),Ti=y(wi||(wi=j(["\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}"])),Pi,Ri);(Ki=e.OtkState||(e.OtkState={})).OTK_INITIATED="OTK_INITIATED",Ki.OTK_ACCEPTED="OTK_ACCEPTED",Ki.OTK_COMPLETED="OTK_COMPLETED",function(e){e.IN_PROGRESS="IN_PROGRESS",e.COMPLETED="COMPLETED",e.DECLINED="DECLINED",e.CANCELLED="CANCELLED"}(e.KeyExchangeState||(e.KeyExchangeState={})),function(e){e.OTK="OTK"}(e.KeyExchangeMode||(e.KeyExchangeMode={}));var Mi=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={}),D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Ai,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 D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:i?$i:Ei,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 D(this,void 0,void 0,(function(){var r;return A(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 D(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p;return A(this,(function(d){switch(d.label){case 0:return e.isInitiator?[4,this.keyService.getCurrentRootKey()]:[3,8];case 1:return n=d.sent(),[4,this.encryptionService.decrypt(n.jwk,e.initiatorRootKeyCipher)];case 2:return r=d.sent(),e.otk.initiatorOneTimePbkCipher?(s=this.decryptResponseCipher,[4,ve.asKey(r.otKey)]):[3,6];case 3:return o=[d.sent()],[4,ve.asKey(r.oneTimePrk)];case 4:return[4,s.apply(this,o.concat([d.sent(),e.otk.initiatorOneTimePbkCipher]))];case 5:return a=d.sent(),[3,7];case 6:a=null,d.label=7;case 7:return c=(i=a)&&i.responder,p=r&&r.initiator,[2,Object.assign(Object.assign({},e),{message:c?c.message:null,contactCard:c&&c.contactCard?c.contactCard.plainSharedCipherDataJson:null,myContactCard:p&&p.contactCard?p.contactCard.plainSharedCipherDataJson:null,myMessage:p&&p.message})];case 8:return[4,this.decryptOtk(e,t)];case 9:return u=d.sent(),p=u&&u.plainOtKeyCipher.initiator,[2,Object.assign(Object.assign({},e),{decryptedOtk:u,message:p&&p.message,contactCard:p&&p.contactCard&&p.contactCard.plainSharedCipherDataJson})]}}))}))},t.prototype.decryptOtk=function(e,t){return D(this,void 0,void 0,(function(){var n,r,i;return A(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 D(this,void 0,void 0,(function(){var r,i;return A(this,(function(a){switch(a.label){case 0:return n?[4,ve.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,ve.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 D(this,void 0,void 0,(function(){var e,a,s,o,c,u,p,d,l,y,h,v,f,m,g,S;return A(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(),p=null,r&&r.ownerPlainData?(l=(d=JSON).stringify,[4,this.encryptionService.sign(u.jwk,r.ownerPlainData)]):[3,7];case 6:p=l.apply(d,[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:Oi,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:p,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 D(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,v,f,m,g,S,I,b,C,k,w,K,P,R,D,E,$,O,j,T,M,F,N,L,x,U,q,J,_,G,B,Q,V,W,H,Z,Y,z,X,ee,te,ne,re;return A(this,(function(A){switch(A.label){case 0:return[4,this.authService.getUser()];case 1:return e=A.sent(),[4,this.keyService.getCurrentRootKey()];case 2:return o=A.sent(),c=this.keyService.getCurrentMasterKey().id,[4,this.keyService.getCurrentMasterKey()];case 3:return u=A.sent(),[4,this.keyFactory.createKey()];case 4:return p=A.sent(),[4,this.keyFactory.createKey()];case 5:return d=A.sent(),[4,this.encryptionService.encrypt(o.jwk,p.toJSON(!0))];case 6:return l=A.sent(),[4,this.encryptionService.encrypt(u.jwk,d.toJSON(!0))];case 7:return y=A.sent(),[4,ve.asKey(r.plainOtKeyCipher.initiator.oneTimePbk)];case 8:return h=A.sent(),[4,ve.asKey(r.plainOtKeyCipher.initiator.pbk)];case 9:return v=A.sent(),[4,ve.asKey(r.plainOtKeyCipher.initiator.sigPbk)];case 10:return f=A.sent(),[4,this.keyService.getCurrentPxk()];case 11:return m=A.sent(),[4,this.keyService.getCurrentSigPxk()];case 12:return g=A.sent(),[4,this.encryptionService.sign(g.jwk,v.toJSON())];case 13:return S=A.sent(),[4,this.encryptionService.sign(g.jwk,f.toJSON())];case 14:return I=A.sent(),b={nonce:r.plainOtKeyCipher.nonce,sharedKey:p.toJSON(!0),mkSharedKey:d.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=A.sent(),[4,this.keyFactory.createKey()];case 16:return x=A.sent(),[4,this.keyService.getCurrentSigPxk()];case 17:return U=A.sent(),K={},R=(P=JSON).stringify,[4,this.encryptionService.encrypt(o.jwk,w.toJSON(!0))];case 18:return K.receiverWrappedKey=R.apply(P,[A.sent()]),K.receiverWrappingKeyId=o.id,a?($=(E=JSON).stringify,[4,this.encryptionService.encrypt(w,a.plainReceiverCipherDataJson)]):[3,20];case 19:return D=$.apply(E,[A.sent()]),[3,21];case 20:D="",A.label=21;case 21:return K.receiverCipherData=D,j=(O=JSON).stringify,[4,this.encryptionService.encrypt(p,x.toJSON(!0))];case 22:return K.sharedWrappedKey=j.apply(O,[A.sent()]),C=K,[4,this.encryptionService.encrypt(x,k)];case 23:return H=A.sent(),T=C,F=(M=JSON).stringify,[4,this.encryptionService.sign(U.jwk,H)];case 24:T.sharedCipherDataSig=F.apply(M,[A.sent()]),C.sigPxkId=U.id,b.responder.contactCard=Object.assign(Object.assign({},b.responder.contactCard),{sharedCipherKey:x.toJSON(!0)}),A.label=25;case 25:return s?[4,this.keyFactory.createKey()]:[3,38];case 26:return L=A.sent(),[4,this.keyFactory.createKey()];case 27:return x=A.sent(),[4,this.keyService.getCurrentSigPxk()];case 28:return U=A.sent(),q={},_=(J=JSON).stringify,[4,this.encryptionService.encrypt(o.jwk,L.toJSON(!0))];case 29:return q.ownerWrappedKey=_.apply(J,[A.sent()]),q.ownerWrappingKeyId=o.id,s.plainOwnerCipherDataJson?(Q=(B=JSON).stringify,[4,this.encryptionService.encrypt(L,s.plainOwnerCipherDataJson)]):[3,31];case 30:return G=Q.apply(B,[A.sent()]),[3,32];case 31:G="",A.label=32;case 32:return q.ownerCipherData=G,W=(V=JSON).stringify,[4,this.encryptionService.encrypt(p,x.toJSON(!0))];case 33:return q.sharedWrappedKey=W.apply(V,[A.sent()]),N=q,[4,this.encryptionService.encrypt(x,s.plainSharedCipherDataJson)];case 34:return H=A.sent(),Z=N,z=(Y=JSON).stringify,[4,this.encryptionService.sign(U.jwk,H)];case 35:return Z.sharedCipherDataSig=z.apply(Y,[A.sent()]),N.sigPxkId=U.id,s.ownerPlainData?(X=N,te=(ee=JSON).stringify,[4,this.encryptionService.sign(g.jwk,s.ownerPlainData)]):[3,37];case 36:X.ownerPlainDataSig=te.apply(ee,[A.sent()]),A.label=37;case 37:b.responder.contactCard=Object.assign(Object.assign({},b.responder.contactCard),{plainSharedCipherDataJson:s.plainSharedCipherDataJson}),A.label=38;case 38:return[4,this.encryptionService.encrypt(h,b)];case 39:return ne=A.sent(),[4,this.encryptionService.encrypt(r.otKey,ne)];case 40:return ne=A.sent(),[4,this.lrApollo.mutate({mutation:ji,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:C,responderContactCard:N}}})];case 41:return[2,{keyExchange:(re=A.sent().respondKeyExchangeOtk).keyExchange,userSharedKey:re.userSharedKey,tp:re.tp}]}}))}))},t.prototype.completeOtk=function(e,t,n,r){return D(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,y,h,v,f,m,g,S,I,b,C,k,w,K,P,R,D,E,$,O,j,T,M,F,N,L,x,U,q,J;return A(this,(function(A){switch(A.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return i=A.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return a=A.sent(),[4,this.encryptionService.decrypt(i.jwk,t)];case 3:return s=A.sent(),c=this.decryptResponseCipher,[4,ve.asKey(s.otKey)];case 4:return u=[A.sent()],[4,ve.asKey(s.oneTimePrk)];case 5:return[4,c.apply(this,u.concat([A.sent(),n]))];case 6:if(o=A.sent(),s.nonce!==o.nonce)throw new B("The nonce returned by responder does not match with the one created by the initiator.");return[4,this.keyService.getCurrentSigPxk()];case 7:return p=A.sent(),[4,ve.asKey(o.responder.sigPbk)];case 8:return d=A.sent(),[4,ve.asKey(o.responder.pbk)];case 9:return l=A.sent(),[4,this.encryptionService.sign(p.jwk,l.toJSON())];case 10:return y=A.sent(),[4,this.encryptionService.sign(p.jwk,d.toJSON())];case 11:return h=A.sent(),[4,ve.asKey(o.sharedKey)];case 12:return v=A.sent(),[4,this.encryptionService.encrypt(i.jwk,v.toJSON(!0))];case 13:return f=A.sent(),[4,ve.asKey(o.mkSharedKey)];case 14:return m=A.sent(),[4,this.encryptionService.encrypt(a.jwk,m.toJSON(!0))];case 15:return g=A.sent(),r?[4,this.keyFactory.createKey()]:[3,19];case 16:return I=A.sent(),b={},k=(C=JSON).stringify,[4,this.encryptionService.encrypt(i.jwk,I.toJSON(!0))];case 17:return b.receiverWrappedKey=k.apply(C,[A.sent()]),b.receiverWrappingKeyId=i.id,K=(w=JSON).stringify,[4,this.encryptionService.encrypt(I,r)];case 18:b.receiverCipherData=K.apply(w,[A.sent()]),S=b,A.label=19;case 19:return s.initiatorContactCard?(D=s.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,28];case 20:return E=A.sent(),[4,ve.asKey(o.responder.contactCard.sharedCipherKey)];case 21:return $=A.sent(),T=(j=JSON).stringify,[4,this.encryptionService.encrypt(i.jwk,E.toJSON(!0))];case 22:return O=T.apply(j,[A.sent()]),D.plainOwnerCipherDataJson?(L=(N=JSON).stringify,[4,this.encryptionService.encrypt(E,D.plainOwnerCipherDataJson)]):[3,24];case 23:return F=L.apply(N,[A.sent()]),[3,25];case 24:F="",A.label=25;case 25:return M=F,P={ownerWrappedKey:O,ownerWrappingKeyId:i.id,ownerCipherData:M},R={sigPxkId:p.id},[4,this.encryptionService.encrypt($,D.plainSharedCipherDataJson)];case 26:return x=A.sent(),U=R,J=(q=JSON).stringify,[4,this.encryptionService.sign(p.jwk,x)];case 27:U.sharedCipherDataSig=J.apply(q,[A.sent()]),A.label=28;case 28:return[4,this.lrApollo.mutate({mutation:Ti,variables:{input:{keyExchangeId:e,rootKeyId:i.id,masterKeyId:a.id,initiatorSigPxkId:p.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,A.sent().completeKeyExchangeOtk]}}))}))},t.prototype.currentUserSharedKey=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Di,variables:{username:e.username,userId:e.userId}})];case 1:return[2,t.sent().currentUserSharedKey.userSharedKey]}}))}))},t}();Mi.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Mi(n.ɵɵinject(ve),n.ɵɵinject(ge),n.ɵɵinject(Ie),n.ɵɵinject(ye),n.ɵɵinject(oi),n.ɵɵinject(mi))},token:Mi,providedIn:"root"}),Mi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Mi.ctorParameters=function(){return[{type:ve},{type:ge},{type:Ie},{type:ye},{type:oi},{type:mi}]};var Fi,Ni,Li=y(Fi||(Fi=j(["\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"]))),xi=y(Ni||(Ni=j(["\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"])),Te),Ui=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 D(this,void 0,void 0,(function(){var e,a,s,o,c,u;return A(this,(function(p){switch(p.label){case 0:return[4,this.keyExchangeService.currentUserSharedKey({username:t,userId:n})];case 1:return e=p.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=p.sent(),[4,this.encrypt(s,i)];case 3:return o=p.sent(),[4,this.keyGraph.getJwkKey(e.userSigPrk.id)];case 4:return c=p.sent(),[4,this.sign(c,o)];case 5:u=p.sent(),a.signedCipherMessage=JSON.stringify(u),p.label=6;case 6:return r&&(a.plainMessage=JSON.stringify(r)),[4,this.lrApollo.query({query:Li,variables:{input:a}})];case 7:return[2,p.sent().sendMessage]}}))}))},e.prototype.decryptMessage=function(e,t){var n=t.sharedKey,r=t.senderSigPbk;return D(this,void 0,void 0,(function(){var t,i;return A(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 D(this,void 0,void 0,(function(){var t,n,r,i;return A(this,(function(a){switch(a.label){case 0:return[4,this.lrApollo.query({query:xi,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}();Ui.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Ui(n.ɵɵinject(Ie),n.ɵɵinject(Se),n.ɵɵinject(ye),n.ɵɵinject(Mi))},token:Ui,providedIn:"root"}),Ui.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ui.ctorParameters=function(){return[{type:Ie},{type:Se},{type:ye},{type:Mi}]};var qi,Ji,_i,Gi,Bi,Qi=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()}},Vi=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=Qi(n),t.configure({region:e[0],userPoolId:r,userPoolWebClientId:i,mandatorySignIn:!1})}},Wi=y(qi||(qi=j(["\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"]))),Hi=y(Ji||(Ji=j(["\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"]))),Zi=y(_i||(_i=j(["\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"]))),Yi=y(Gi||(Gi=j(["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"],["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"]))),zi=y(Bi||(Bi=j(["\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"]))),Xi=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 D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Hi,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 D(this,void 0,void 0,(function(){var e,r,i;return A(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:Zi,variables:{input:{id:t,cipherMeta:JSON.stringify(i)}}})];case 4:return[2,a.sent().updateLbop]}}))}))},e.prototype.get=function(e){return D(this,void 0,void 0,(function(){var t,n,r;return A(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:Yi,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 D(this,void 0,void 0,(function(){var e,t,n=this;return A(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:zi})];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 D(n,void 0,void 0,(function(){var n;return A(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 D(this,void 0,void 0,(function(){var e,n,r,i,a,s,o,c,u,p,d,l,y,h;return A(this,(function(v){switch(v.label){case 0:if(1024!==I.Slip39Helper.WORD_LIST.length)throw new G("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 p=v.sent(),[4,this.encryptionService.encrypt(s,p.jwk.toJSON(!0))];case 8:return d=v.sent(),l=Object.assign(Object.assign({},t&&{name:t}),{partial:this.getPartial(n)}),[4,this.encryptionService.encrypt(p.jwk,l)];case 9:return y=v.sent(),[4,this.lrApollo.mutate({mutation:Wi,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(d)}}})];case 10:return h=v.sent(),[2,Object.assign(Object.assign({},h.createLbop.lbop),{lbopString:n})]}}))}))},e.prototype.verifyLbops=function(e,t){return D(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l;return A(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(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 p=y.sent(),d={error:p},[3,12];case 11:try{i&&!i.done&&(l=r.return)&&l.call(r)}finally{if(d)throw d.error}return[7];case 12:throw new L({source:"LBOP",code:"INVALID_PASSPHRASE",message:"Invalid passphrase."})}}))}))},e.prototype.verifyContact=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){return[2,this.http.post(this.config.authUrl+"users/lbop-reset/verify-contact/",e).toPromise()]}))}))},e.prototype.confirmContact=function(e){return D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return A(this,(function(p){switch(p.label){case 0:return[4,this.http.post(this.config.authUrl+"users/lbop-reset/get-challenge/",{claimId:e.claimId,claimToken:e.claimToken}).toPromise()];case 1:return t=p.sent(),[4,this.verifyLbops(t,e.lbop)];case 2:return n=p.sent(),r=n.signedChallenge,i=n.lbop,a=n.lbopKey,[4,this.http.post(this.config.authUrl+"users/lbop-reset/verify-challenge/",{lbopId:i.lbopId,signedChallenge:r}).toPromise()];case 3:return s=p.sent(),o={lbopId:i.lbopId,verifiedToken:s.verifiedToken,masterKeyId:s.masterKeyId},u=(c=ve).asKey,[4,this.encryptionService.decrypt(a,s.wrappedMasterKey)];case 4:return[4,u.apply(c,[p.sent()])];case 5:return[2,(o.masterKey=p.sent(),o)]}}))}))},e.prototype.setPassword=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i;return A(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 L({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}();Xi.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Xi(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(Ie),n.ɵɵinject(d.AuthClass),n.ɵɵinject(oi),n.ɵɵinject(ve),n.ɵɵinject(ge),n.ɵɵinject(ye),n.ɵɵinject(Se),n.ɵɵinject(Wn))},token:Xi,providedIn:"root"}),Xi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Xi.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:Ie},{type:d.AuthClass},{type:oi},{type:ve},{type:ge},{type:ye},{type:Se},{type:Wn}]};var ea=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 D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){return A(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"),D(this,void 0,void 0,(function(){var a,s,o,c,u,p,d,l,y,h,v,f,m;return A(this,(function(g){switch(g.label){case 0:return[4,this.passwordService.createPassKeyBundle(t)];case 1:return a=g.sent(),[4,this.keyFactory.createKey()];case 2:return s=g.sent(),[4,this.encryptionService.encrypt(a.passKey,s.toJSON(!0))];case 3:return o=g.sent(),[4,this.keyFactory.createKey()];case 4:return c=g.sent(),[4,this.encryptionService.encrypt(s,c.toJSON(!0))];case 5:return u=g.sent(),[4,this.keyFactory.createPkcKey()];case 6:return p=g.sent(),[4,this.encryptionService.encrypt(c,p.toJSON(!0))];case 7:return d=g.sent(),[4,this.keyFactory.createPkcSignKey()];case 8:return l=g.sent(),[4,this.encryptionService.encrypt(c,l.toJSON(!0))];case 9:return 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:p.toJSON(),wrapped_prk:d,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 D(this,void 0,void 0,(function(){var t;return A(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}();ea.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ea(n.ɵɵinject(te),n.ɵɵinject(d.AuthClass),n.ɵɵinject(t.HttpClient),n.ɵɵinject(ve),n.ɵɵinject(ye),n.ɵɵinject(Wn))},token:ea,providedIn:"root"}),ea.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ea.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:d.AuthClass},{type:t.HttpClient},{type:ve},{type:ye},{type:Wn}]};var ta,na=function(){function e(e){this.auth=e}return e.prototype.getPreferredMFA=function(){return D(this,void 0,void 0,(function(){var e;return A(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 D(this,void 0,void 0,(function(){var t;return A(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 D(this,void 0,void 0,(function(){var t;return A(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 D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var e,t,n,r,i;return A(this,(function(a){switch(a.label){case 0:return[4,Promise.all([this.auth.currentAuthenticatedUser(),this.auth.currentUserInfo()])];case 1:return e=$.apply(void 0,[a.sent(),2]),t=e[0],n=e[1],[4,this.auth.setupTOTP(t)];case 2:if(r=a.sent(),!(i=n.attributes.email))throw new q("No email associated with user.");return[2,{code:r,codeUri:"otpauth://totp/"+i+"?secret="+r+"&issuer=LifeReady"}]}}))}))},e.prototype.verifySoftwareToken=function(e){return D(this,void 0,void 0,(function(){var t;return A(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}();na.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new na(n.ɵɵinject(d.AuthClass))},token:na,providedIn:"root"}),na.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],na.ctorParameters=function(){return[{type:d.AuthClass}]},(ta=e.FileType||(e.FileType={})).RecordContent="record-content",ta.RecordAttachment="record-attachment";var ra,ia,aa,sa,oa,ca,ua,pa,da,la=JSON.stringify({filter:[{contains:{fileType:e.FileType.RecordContent}}]}),ya=JSON.stringify({filter:[{contains:{fileType:e.FileType.RecordAttachment}}]}),ha=function(e){return void 0===e&&(e=5),y(ra||(ra=j(["\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"])),bt,Et(e),Te)},va=y(ia||(ia=j(["\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"]))),fa=y(aa||(aa=j(["\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"]))),ma=y(sa||(sa=j(["\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"]))),ga=y(oa||(oa=j(["\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"]))),Sa=y(ca||(ca=j(["\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"]))),Ia=y(ua||(ua=j(["\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"]))),ba=y(pa||(pa=j(["\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"])));(da=e.AccessLevel||(e.AccessLevel={})).Owner="OWNER",da.Admin="ADMIN",da.Writer="WRITER",da.Reader="READER",da.Deny="DENY";var Ca=function(){},ka=function(){},wa=function(){},Ka=function(){},Pa=function(){},Ra=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return K(t,e),t}(Pa),Da=function(){},Aa=function(){},Ea=function(){},$a=function(){},Oa=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),D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Kt,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 D(this,void 0,void 0,(function(){var e,t;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Rt,variables:{plainMetaFilter:gt}})];case 1:return e=n.sent().list,[4,this.mapVaults(e)];case 2:if((t=n.sent()).length>1)throw new ee("There are more than one default vaults");return[2,t[0]||null]}}))}))},t.prototype.getCategories=function(e){return void 0===e&&(e=null),D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Pt,variables:{vaultFilter:gt,categoryFilter:St,recordFilter:It,archived:e&&e.archived}})];case 1:if(!((t=n.sent()).vaults.edges.length>1))return[3,2];throw new ee("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 D(this,void 0,void 0,(function(){var t,n;return A(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Dt,variables:{trustedPartyId:e,categoryFilter:St,recordFilter:It,contentFilter:la}})];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 D(this,void 0,void 0,(function(){var t,n;return A(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:At,variables:{trustedPartyId:e,categoryFilter:St,recordFilter:It,contentFilter:la}})];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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return A(this,(function(p){switch(p.label){case 0:return[4,this.lrApollo.query({query:$t(),variables:{id:e,categoryFilter:St,recordFilter:It,contentFilter:la}})];case 1:return t=p.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([p.sent()]))],u={},[4,this.mapParentCategories(t)];case 3:return n.category=i.apply(r,c.concat([(u.parents=p.sent(),u)])),[4,this.mapCategories(t.subCategories)];case 4:return n.subCategories=p.sent(),[4,this.mapRecords(t.records)];case 5:return[2,(n.records=p.sent(),n)]}}))}))},t.prototype.mapVaults=function(e){return D(this,void 0,void 0,(function(){var t=this;return A(this,(function(n){return[2,Promise.all(e.edges.map((function(e){return t.mapVault(e.node)})))]}))}))},t.prototype.mapCategories=function(e){return D(this,void 0,void 0,(function(){var t=this;return A(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 D(this,void 0,void 0,(function(){var t=this;return A(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 D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return"",[4,this.keyMetaService.wrapContent("")];case 1:return t=n.sent(),[4,this.lrApollo.mutate({mutation:Tt,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 D(this,void 0,void 0,(function(){var n,r;return A(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:jt,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 D(this,void 0,void 0,(function(){var r,i;return A(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:Mt,variables:{input:{directoryId:e,cipherMeta:i}}})];case 2:return a.sent(),[2]}}))}))},t.prototype.setCategoryVisibility=function(t,n){return D(this,void 0,void 0,(function(){return A(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.mutate({mutation:Mt,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 D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ft,variables:{categoryId:e}})];case 1:return t.sent(),[2]}}))}))},t.prototype.archiveCategory=function(e,t){return D(this,void 0,void 0,(function(){return A(this,(function(n){return[2,this.archiveDirectory(e,t)]}))}))},t.prototype.unarchiveCategory=function(e,t){return D(this,void 0,void 0,(function(){return A(this,(function(n){return[2,this.unarchiveDirectory(e,t)]}))}))},t.prototype.archiveDirectory=function(e,t){return D(this,void 0,void 0,(function(){return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:Nt,variables:{input:{directoryId:e,recursive:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.unarchiveDirectory=function(e,t){return D(this,void 0,void 0,(function(){return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:Lt,variables:{input:{directoryId:e,recursive:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.mapVault=function(e){return D(this,void 0,void 0,(function(){var t,n;return A(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 D(this,void 0,void 0,(function(){var t,n;return A(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,O.apply(void 0,n.concat([[r.sent()]]))]}}))}))},t.prototype.mapCategory=function(t){var n;return D(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d;return A(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,p=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:p?e.AccessLevel.Owner:t.accessRoles[0].role,sharedAccess:p?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 d=l.sent(),console.error("Failed to decrypt Category.",d,t),[2,null];case 3:return[2]}}))}))},t.prototype.mapRecord=function(t){return D(this,void 0,void 0,(function(){var n,r,i,a,s,o;return A(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}();Oa.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Oa(n.ɵɵinject(Ie),n.ɵɵinject(qt),n.ɵɵinject(Se))},token:Oa,providedIn:"root"}),Oa.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Oa.ctorParameters=function(){return[{type:Ie},{type:qt},{type:Se}]};var ja=function(){},Ta=function(){function e(e,t){this.http=e,this.categoryService=t}return e.prototype.getCoreCategories=function(){return D(this,void 0,void 0,(function(){var e;return A(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 D(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p=this;return A(this,(function(d){switch(d.label){case 0:return n?[4,this.categoryService.getTrustedPartyCategories(n)]:[3,2];case 1:return i=d.sent().categories,[3,4];case 2:return[4,this.categoryService.getCategories()];case 3:i=d.sent(),d.label=4;case 4:return r=i,t?[4,this.categoryService.getCategory(t)]:[3,6];case 5:return s=d.sent(),[3,7];case 6:s=null,d.label=7;case 7:return a=s,o=e.map((function(e){return D(p,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return t={categoryTree:e},[4,this.loadCategory(O(e),r,a)];case 1:return[2,(t.category=n.sent(),t)]}}))}))})),[4,Promise.all(o)];case 8:return c=d.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 D(this,void 0,void 0,(function(){var t,n=this;return A(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 D(n,void 0,void 0,(function(){var n;return A(this,(function(r){switch(r.label){case 0:return n={},[4,this.loadCategory(O(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 D(this,void 0,void 0,(function(){var r,i,a,s;return A(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}();Ta.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Ta(n.ɵɵinject(t.HttpClient),n.ɵɵinject(Oa))},token:Ta,providedIn:"root"}),Ta.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ta.ctorParameters=function(){return[{type:t.HttpClient},{type:Oa}]};var Ma=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 D(this,void 0,void 0,(function(){var n;return A(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 D(this,void 0,void 0,(function(){var n=this;return A(this,(function(r){switch(r.label){case 0:return[4,Promise.all((t||[]).map((function(t){return D(n,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var r,i,a,s;return A(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:Ia,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 D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:ba,variables:{fileId:e}})];case 1:return t.sent(),[2]}}))}))},t}();Ma.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Ma(n.ɵɵinject(ci),n.ɵɵinject(Ie),n.ɵɵinject(qt),n.ɵɵinject(Se))},token:Ma,providedIn:"root"}),Ma.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ma.ctorParameters=function(){return[{type:ci},{type:Ie},{type:qt},{type:Se}]};var Fa,Na=function(){},La=function(){},xa=function(){},Ua=function(){},qa=function(){},Ja=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return K(t,e),t}(Ua),_a=function(){},Ga=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 D(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d=this;return A(this,(function(l){switch(l.label){case 0:return[4,this.lrApollo.query({query:ha(),variables:{id:t,categoryFilter:St,contentFilter:la,attachmentsFilter:ya}})];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 D(d,void 0,void 0,(function(){var t;return A(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,O.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(),p=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:p?e.AccessLevel.Owner:n.accessRoles[0].role,sharedAccess:p?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 D(this,void 0,void 0,(function(){var t=this;return A(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return e.node.childFile})).map((function(e){return D(t,void 0,void 0,(function(){var t,n,r,i,a,s;return A(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 D(this,void 0,void 0,(function(){var n,r,i,a,s,o;return A(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:va,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:fa,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 D(this,void 0,void 0,(function(){var a,s,o;return A(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:ga,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 D(this,void 0,void 0,(function(){return A(this,(function(t){return[2,this.categoryService.archiveDirectory(e,!0)]}))}))},t.prototype.unarchiveRecord=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){return[2,this.categoryService.unarchiveDirectory(e,!0)]}))}))},t.prototype.deleteRecord=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Sa,variables:{recordId:e}})];case 1:return t.sent(),[2]}}))}))},t}();Ga.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Ga(n.ɵɵinject(Ie),n.ɵɵinject(qt),n.ɵɵinject(Oa),n.ɵɵinject(Ma))},token:Ga,providedIn:"root"}),Ga.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ga.ctorParameters=function(){return[{type:Ie},{type:qt},{type:Oa},{type:Ma}]},(Fa=e.RecordFieldType||(e.RecordFieldType={})).Text="text",Fa.Email="email",Fa.Url="url",Fa.Phone="phone",Fa.Date="date",Fa.Password="password",Fa.TextArea="textArea",Fa.Select="select",Fa.SingleChoice="singleChoice",Fa.MultiChoice="multiChoice",Fa.File="file",Fa.MultiFile="multiFile",Fa.Record="record",Fa.MultiRecord="multiRecord",Fa.Group="group",Fa.Custom="custom";var Ba=function(){},Qa=function(){},Va=function(){},Wa=function(){},Ha=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=Ha,Ya=function(){function e(e){this.http=e}return e.prototype.getRecordTypes=function(){return D(this,void 0,void 0,(function(){var e,t,n,r,i=this;return A(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 O(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 D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){return A(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 Ha(t,e)}))}))]}}))}))},e}();Ya.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Ya(n.ɵɵinject(t.HttpClient))},token:Ya,providedIn:"root"}),Ya.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ya.ctorParameters=function(){return[{type:t.HttpClient}]};var za,Xa,es,ts=function(){};(za=e.TrustedPartyRoleType||(e.TrustedPartyRoleType={})).General="general",za.Scenario="scenario",(Xa=e.TrustedPartyType||(e.TrustedPartyType={})).User="user",Xa.Organisation="organisation",(es=e.TrustedPartyInviteStatus||(e.TrustedPartyInviteStatus={})).Invited="IN_PROGRESS",es.Cancelled="CANCELLED",es.Declined="DECLINED",es.Completed="COMPLETED";var ns,rs=function(){},is=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return K(t,e),t}(it),as=function(){},ss=function(){},os=function(){},cs=function(){},us=function(){},ps=function(){},ds=function(){},ls=function(){},ys="\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",hs=y(ns||(ns=j(["\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}"])),ys),vs=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 D(this,void 0,void 0,(function(){var t;return A(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 D(this,void 0,void 0,(function(){var t,n,r;return A(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 D(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,y,h;return A(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(),p=(u=JSON).stringify,[4,this.encryptionService.sign(s.jwk,o)];case 5:return c=p.apply(u,[v.sent()]),d={name:new Ze(r.name)},h=(y=JSON).stringify,[4,this.encryptionService.sign(s.jwk,d)];case 6:return l=h.apply(y,[v.sent()]),[4,this.lrApollo.mutate({mutation:hs,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}();vs.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new vs(n.ɵɵinject(ge),n.ɵɵinject(Ie),n.ɵɵinject(Se),n.ɵɵinject(ye))},token:vs,providedIn:"root"}),vs.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],vs.ctorParameters=function(){return[{type:ge},{type:Ie},{type:Se},{type:ye}]};var fs,ms,gs,Ss,Is,bs,Cs,ks,ws,Ks,Ps,Rs="\n id\n user {\n id\n username\n }\n other{\n id\n username,\n features {\n shareVault\n }\n }\n sharedContactCard {\n "+ys+"\n }\n myContactCard {\n "+ys+"\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 "+Pi+"\n }\n "+Ri+"\n }\n }",Ds=y(fs||(fs=j(["\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}"])),Rs,Me),As=y(ms||(ms=j(["\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}"])),Rs,Pi,Pi,Me),Es=y(gs||(gs=j(["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ","\n }\n ","\n}"],["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ","\n }\n ","\n}"])),Rs,Me),$s=y(Ss||(Ss=j(["\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"]))),Os=y(Is||(Is=j(["\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"]))),js=y(bs||(bs=j(["\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"]))),Ts=y(Cs||(Cs=j(["\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"]))),Ms=y(ks||(ks=j(["\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"]))),Fs=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 D(this,void 0,void 0,(function(){var e,t=this;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Ds})];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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o=this;return A(this,(function(c){switch(c.label){case 0:return[4,this.authService.getUser()];case 1:return t=c.sent(),[4,this.lrApollo.query({query:As,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 D(o,void 0,void 0,(function(){var t;return A(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 D(o,void 0,void 0,(function(){var t;return A(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 D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Es,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),D(this,void 0,void 0,(function(){var e;return A(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 D(this,void 0,void 0,(function(){var t;return A(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 D(this,void 0,void 0,(function(){var t;return A(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 Ze(e.mySharedDetails.name)}}},[4,this.keyExchangeService.initiateOtk(t)];case 1:return n.sent(),[2]}}))}))},t.prototype.cancelInvitation=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Os,variables:{input:{id:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.getInvitation=function(e,t,n){return D(this,void 0,void 0,(function(){var r;return A(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 D(this,void 0,void 0,(function(){var t;return A(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 Ze(e.mySharedDetails.name)}}},[4,this.keyExchangeService.respondOtk(t)];case 1:return[2,n.sent().tp.id]}}))}))},t.prototype.declineInvitation=function(e,t){return D(this,void 0,void 0,(function(){return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:$s,variables:{input:{id:e,token:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.confirmInvitation=function(e){return D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:js,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 D(this,void 0,void 0,(function(){var i,a,s;return A(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:Ts,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 D(this,void 0,void 0,(function(){return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:Ms,variables:{input:{id:e,tpId:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.mapTrustedParty=function(t){var n;return D(this,void 0,void 0,(function(){var r,i,a,s,o;return A(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 D(this,void 0,void 0,(function(){var i,a,s;return A(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}();Fs.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Fs(n.ɵɵinject(t.HttpClient),n.ɵɵinject(Ie),n.ɵɵinject(vs),n.ɵɵinject(mi),n.ɵɵinject(oi),n.ɵɵinject(Mi),n.ɵɵinject(Se),n.ɵɵinject(ge),n.ɵɵinject(ve),n.ɵɵinject(ye))},token:Fs,providedIn:"root"}),Fs.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Fs.ctorParameters=function(){return[{type:t.HttpClient},{type:Ie},{type:vs},{type:mi},{type:oi},{type:Mi},{type:Se},{type:ge},{type:ve},{type:ye}]},(ws=e.ScenarioState||(e.ScenarioState={})).DISABLED="DISABLED",ws.ENABLED="ENABLED",ws.CLAIMED="CLAIMED",ws.APPROVED="APPROVED",ws.REJECTED="REJECTED",(Ks=e.ScenarioClaimState||(e.ScenarioClaimState={})).Claimed="CLAIMED",Ks.Approved="APPROVED",Ks.Expired="EXPIRED",Ks.Rejected="REJECTED",Ks.Cancelled="CANCELLED",Ks.Reset="RESET",(Ps=e.ApproverClaimState||(e.ApproverClaimState={})).Claimed="CLAIMED",Ps.Approved="APPROVED",Ps.Rejected="REJECTED";var Ns,Ls,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=function(){},bo=function(){},Co=function(){},ko=function(){},wo=function(){},Ko=function(){},Po=function(){},Ro=function(){},Do=function(){},Ao=function(){},Eo=function(){},$o=function(){},Oo=function(){},jo=function(){},To="\nid\ntp {\n "+Rs+"\n}\nsharedKey {\n id\n}\nsharedCipherData\n",Mo=y(Ns||(Ns=j(["\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}"])),To,Me),Fo=y(Ls||(Ls=j(["\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"]))),No=y(xs||(xs=j(["\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"]))),Lo=y(Us||(Us=j(["\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"]))),xo="\n id\n tp {\n "+Rs+'\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 '+kt+'\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 '+bt+"\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",Uo=y(qs||(qs=j(["\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} "])),xo,Me),qo=y(Js||(Js=j(["\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"]))),Jo=y(_s||(_s=j(["\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"]))),_o=y(Gs||(Gs=j(["\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"]))),Go=y(Bs||(Bs=j(["\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"]))),Bo=y(Qs||(Qs=j(["\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"]))),Qo=y(Vs||(Vs=j(["\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"]))),Vo="\nid\ntp {\n "+Rs+"\n}\nsharedKey {\n id\n}\nsharedCipherData\nsharedCipherApprovalData\nsharedCipherPartialAssemblyKey\n",Wo="\nid\nsingleReject\nquorum\nassemblyKey {\n id\n}\nsubAssemblyCipherData\napproverCount\napprovers {\n edges {\n node {\n "+Vo+"\n }\n }\n}\n",Ho=y(Ws||(Ws=j(["\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}"])),Fe),Zo=y(Hs||(Hs=j(["\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"]))),Yo=y(Zs||(Zs=j(["\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"]))),zo=y(Ys||(Ys=j(["\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} "])),Vo,Me),Xo=y(zs||(zs=j(["\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"]))),ec=y(Xs||(Xs=j(["\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"]))),tc="\n id\n sharedKey {\n id\n }\n sharedCipherData\n sharedCipherPartialAssemblyKey\n",nc="\nid\nstate\ntp {\n "+Rs+"\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 "+tc+"\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",rc=y(eo||(eo=j(["\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} "])),nc,Me),ic=y(to||(to=j(['\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} "])),nc,Me),ac=y(no||(no=j(['\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} "])),nc,Me),sc=y(ro||(ro=j(["\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"]))),oc=y(io||(io=j(['\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} "])),Me),cc=y(ao||(ao=j(["\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} "])),To,Wo,xo,Me),uc=y(so||(so=j(["\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} "])),Rs,Me),pc=y(oo||(oo=j(["\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"]))),dc=y(co||(co=j(["\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"]))),lc=y(uo||(uo=j(["\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"]))),yc=y(po||(po=j(["\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"]))),hc=y(lo||(lo=j(["\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"]))),vc=y(yo||(yo=j(["\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"]))),fc=y(ho||(ho=j(["\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"]))),mc=Tn(vo||(vo=j(["\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"]))),gc=Tn(fo||(fo=j(["\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"]))),Sc=y(mo||(mo=j(["\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"]))),Ic=y(go||(go=j(["\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"]))),bc=y(So||(So=j(["\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"]))),Cc=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 D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:zo,variables:{id:e}})];case 1:return t=n.sent().scenarioApprover,[2,this.mapApprover(t)]}}))}))},e.prototype.mapApproverGroup=function(e){return D(this,void 0,void 0,(function(){var t,n,r=this;return A(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 D(this,void 0,void 0,(function(){var t,n;return A(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 D(this,void 0,void 0,(function(){var t;return A(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:ec,variables:{input:{approverId:e.approverId,sharedKeyId:e.keyId,sharedCipherData:t,sharedCipherApprovalData:""}}})];case 2:return n.sent(),[2]}}))}))},e.prototype.createScenarioApproverAssembly=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return A(this,(function(p){switch(p.label){case 0:return[4,this.keyFactory.createKey()];case 1:return t=p.sent(),[4,this.keyGraph.encryptToString(e.keyId,t.toJSON(!0))];case 2:return n=p.sent(),e.plainAssemblyCipherData?[4,this.keyGraph.encryptToString(t,e.plainAssemblyCipherData)]:[3,4];case 3:return i=p.sent(),[3,5];case 4:i="",p.label=5;case 5:return r=i,s=(a=this.lrApollo).mutate,o={mutation:Ho},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=p.sent().map((function(e){e.updateApprovers,e.deleteApprovers;return P(e,["updateApprovers","deleteApprovers"])})),[4,this.rewrapReceivers(t,e.event,e.receivers)];case 7:return[4,s.apply(a,[(o.variables=(c.input=(u.updateReceivers=p.sent(),u),c),o)])];case 8:return[2,p.sent().createScenarioApproverAssembly.scenario.approverAssembly.assemblyKey.id]}}))}))},e.prototype.updateScenarioApproverAssembly=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i;return A(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 P(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 D(this,void 0,void 0,(function(){var r,i,a,s,o;return A(this,(function(c){switch(c.label){case 0:return i=(r=this.lrApollo).mutate,a={mutation:Yo},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 D(this,void 0,void 0,(function(){var r=this;return A(this,(function(i){switch(i.label){case 0:return n&&n.length?[4,Promise.all(n.map((function(n){return D(r,void 0,void 0,(function(){var r,i,a,s,o=this;return A(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 D(o,void 0,void 0,(function(){var i,a;return A(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(O(n.categories.map((function(e){return D(o,void 0,void 0,(function(){var t,n,r,a,s;return A(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 D(o,void 0,void 0,(function(){var t,n,r,a,s;return A(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 D(this,void 0,void 0,(function(){var r,i=this;return A(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 D(this,void 0,void 0,(function(){var r,i;return A(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 D(this,void 0,void 0,(function(){var i,a,s,o,c=this;return A(this,(function(u){switch(u.label){case 0:return i=r.toJSON(!0),i.k,a=P(i,["k"]),s=0,o=function(r){return D(c,void 0,void 0,(function(){var i,o;return A(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 D(c,void 0,void 0,(function(){var t,n,r,i,a,s;return A(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 D(this,void 0,void 0,(function(){var i;return A(this,(function(a){switch(a.label){case 0:return i=new ti(t),n.forEach((function(e,t){var n=e.approvers.length;1===e.quorum&&(n=1),i.addSubAssembly(new ei(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}();Cc.SLIP39_PASSPHRASE="lifeready",Cc.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Cc(n.ɵɵinject(Ie),n.ɵɵinject(ve),n.ɵɵinject(qt),n.ɵɵinject(Se),n.ɵɵinject(ii),n.ɵɵinject(ye),n.ɵɵinject(Fs))},token:Cc,providedIn:"root"}),Cc.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Cc.ctorParameters=function(){return[{type:Ie},{type:ve},{type:qt},{type:Se},{type:ii},{type:ye},{type:Fs}]};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 D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Mo,variables:{id:e}})];case 1:return t=n.sent().scenarioClaimant,[2,this.mapClaimant(t)]}}))}))},e.prototype.mapClaimant=function(e){return D(this,void 0,void 0,(function(){var t,n;return A(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 D(this,void 0,void 0,(function(){var t;return A(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:Fo,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 D(this,void 0,void 0,(function(){var t;return A(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:No,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 D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Lo,variables:{input:{claimantId:e}}})];case 1:return t.sent(),[2]}}))}))},e}();kc.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new kc(n.ɵɵinject(Ie),n.ɵɵinject(qt),n.ɵɵinject(Se),n.ɵɵinject(Fs))},token:kc,providedIn:"root"}),kc.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],kc.ctorParameters=function(){return[{type:Ie},{type:qt},{type:Se},{type:Fs}]};var wc=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 D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Uo,variables:{id:e,categoryFilter:St,recordFilter:It,contentFilter:la}})];case 1:return t=n.sent().scenarioReceiver,[2,this.mapReceiver(t)]}}))}))},e.prototype.mapReceiver=function(e){return D(this,void 0,void 0,(function(){var t,n;return A(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 D(this,void 0,void 0,(function(){var t=this;return A(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 D(this,void 0,void 0,(function(){var t=this;return A(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 D(this,void 0,void 0,(function(){var t;return A(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 D(this,void 0,void 0,(function(){var t;return A(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 D(this,void 0,void 0,(function(){var t;return A(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:qo,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 D(this,void 0,void 0,(function(){var t;return A(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:Jo,variables:{input:{receiverId:e.id,sharedKeyId:e.keyId,sharedCipherData:t}}})];case 2:return n.sent(),[2]}}))}))},e.prototype.deleteReceiver=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:_o,variables:{input:{receiverId:e}}})];case 1:return t.sent(),[2]}}))}))},e.prototype.addReceiverCategory=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return A(this,(function(d){switch(d.label){case 0:return[4,this.categoryService.getCategory(e.categoryId)];case 1:return t=d.sent(),r=(n=this.lrApollo).mutate,i={mutation:Go},a={},o=(s=Object).assign,u=(c=Object).assign,p=[{}],[4,this.addReceiverItem(e,t.category.keyId)];case 2:return[4,r.apply(n,[(i.variables=(a.input=o.apply(s,[u.apply(c,p.concat([d.sent()])),{directoryId:t.category.id}]),a),i)])];case 3:return[2,d.sent().addScenarioReceiverDirectory.receiverDirectory.id]}}))}))},e.prototype.addReceiverRecord=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return A(this,(function(d){switch(d.label){case 0:return[4,this.recordService.getRecord(e.recordId)];case 1:return t=d.sent(),r=(n=this.lrApollo).mutate,i={mutation:Go},a={},o=(s=Object).assign,u=(c=Object).assign,p=[{}],[4,this.addReceiverItem(e,t.keyId)];case 2:return[4,r.apply(n,[(i.variables=(a.input=o.apply(s,[u.apply(c,p.concat([d.sent()])),{directoryId:t.id}]),a),i)])];case 3:return[2,d.sent().addScenarioReceiverDirectory.receiverDirectory.id]}}))}))},e.prototype.addReceiverItem=function(e,t){return D(this,void 0,void 0,(function(){var n,r,i,a;return A(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 D(this,void 0,void 0,(function(){var t,n;return A(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:Bo,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 D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Qo,variables:{input:{receiverDirectoryId:e}}})];case 1:return t.sent(),[2]}}))}))},e}();wc.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new wc(n.ɵɵinject(Ie),n.ɵɵinject(Se),n.ɵɵinject(qt),n.ɵɵinject(Fs),n.ɵɵinject(Oa),n.ɵɵinject(Ga))},token:wc,providedIn:"root"}),wc.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],wc.ctorParameters=function(){return[{type:Ie},{type:Se},{type:qt},{type:Fs},{type:Oa},{type:Ga}]};var Kc=h,Pc=function(){function t(e,t,n,r,i,a,s,o,c,u,p,d){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=p,this.lrGraphQL=d}return t.prototype.getMyScenarios=function(){return D(this,void 0,void 0,(function(){var e,t=this;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:oc})];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 D(this,void 0,void 0,(function(){var t,n,r;return A(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 D(this,void 0,void 0,(function(){var e,t=this;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:ic})];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 D(this,void 0,void 0,(function(){var t,n,r;return A(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 D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:rc,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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c=this;return A(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 D(c,void 0,void 0,(function(){var t;return A(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 D(this,void 0,void 0,(function(){var t,n,r=this;return A(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:ac,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 D(this,void 0,void 0,(function(){var e,t=this;return A(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 D(t,void 0,void 0,(function(){var t,n=this;return A(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 D(n,void 0,void 0,(function(){var n;return A(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 O(e,t)}),[]).sort((function(e,t){return-1*Kc(new Date(e.lastModified)).diff(Kc(new Date(t.lastModified)))}))]}}))}))},t.prototype.getCipherData=function(e){return D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:cc,variables:{id:e,categoryFilter:St,recordFilter:It,contentFilter:la}})];case 1:return t=n.sent().scenario,[4,this.mapScenario(t)];case 2:return[2,n.sent()]}}))}))},t.prototype.mapScenario=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o=this;return A(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 D(this,void 0,void 0,(function(){var t,n,r,i;return A(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:pc,variables:{input:{rootKeyId:t.id,rootKeyWrappedSubjectKey:r,subjectCipherData:i}}})];case 5:return[2,a.sent().createScenario.scenario.id]}}))}))},t.prototype.updateScenario=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a;return A(this,(function(s){switch(s.label){case 0:return n=(t=this.lrApollo).mutate,r={mutation:dc},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 D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:yc,variables:{input:{scenarioId:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.disableScenario=function(e){return D(this,void 0,void 0,(function(){return A(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.deleteScenario=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:lc,variables:{input:{scenarioId:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.createClaim=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:vc,variables:{input:{scenarioId:e}}})];case 1:return[2,t.sent().createScenarioClaim.sharedClaim.id]}}))}))},t.prototype.cancelClaim=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:fc,variables:{input:{claimId:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.approveClaim=function(e,t){return D(this,void 0,void 0,(function(){return A(this,(function(n){return[2,this.lrGraphQL.lrMutate(this.approveClaimMutation(e,t))]}))}))},t.prototype.approveClaimMutation=function(t,n){return D(this,void 0,void 0,(function(){var r,i,a,s,o,c=this;return A(this,(function(u){switch(u.label){case 0:return[4,this.getSharedScenario(t)];case 1:if((r=u.sent()).claim.id!==n)throw new L({code:e.LrErrorCode.ReceiveClaimMismatch,message:"claimId does not match with the current claimId of the scenario"});return i=function(e){return D(c,void 0,void 0,(function(){var t,r,i,a,s=this;return A(this,(function(o){switch(o.label){case 0:return t=Nr.bind,r={mutation:mc},i={},a={claimId:n,approverId:e.approverId},[4,Promise.all(e.receivers.map((function(t){return D(s,void 0,void 0,(function(){var n;return A(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(Nr,[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=xr).create,[4,Promise.all(a)];case 2:return[2,o.apply(s,[u.sent()])]}}))}))},t.prototype.rejectClaim=function(e,t){return D(this,void 0,void 0,(function(){return A(this,(function(n){return[2,this.lrGraphQL.lrMutate(this.rejectClaimMutation(e,t))]}))}))},t.prototype.rejectClaimMutation=function(t,n){return D(this,void 0,void 0,(function(){var r,i,a,s,o,c=this;return A(this,(function(u){switch(u.label){case 0:return[4,this.getSharedScenario(t)];case 1:if((r=u.sent()).claim.id!==n)throw new L({code:e.LrErrorCode.ReceiveClaimMismatch,message:"ClaimId does not match with the current claimId of the scenario"});return i=function(e){return D(c,void 0,void 0,(function(){return A(this,(function(t){return[2,new Nr({mutation:gc,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=xr).create,[4,Promise.all(a)];case 2:return[2,o.apply(s,[u.sent()])]}}))}))},t.prototype.receiveClaim=function(t,n){return D(this,void 0,void 0,(function(){var r,i,a,s=this;return A(this,(function(o){switch(o.label){case 0:return[4,this.getSharedScenario(t)];case 1:if((r=o.sent()).claim.id!==n)throw new L({code:e.LrErrorCode.ReceiveClaimMismatch,message:"ClaimId does not match with the current claimId of the scenario"});if(r.status!==e.ScenarioState.APPROVED)throw new L({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 D(s,void 0,void 0,(function(){var t,n;return A(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:Sc,variables:{input:{claimId:n,receiverDirectories:a}}})];case 4:return o.sent(),[2]}}))}))},t.prototype.getClaimAssemblyKey=function(t,n){return D(this,void 0,void 0,(function(){var r,i,a,s=this;return A(this,(function(o){switch(o.label){case 0:return n&&n.length?[4,Promise.all(n.map((function(n){return D(s,void 0,void 0,(function(){var i;return A(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 L({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,Cc.SLIP39_PASSPHRASE)];case 2:return a=o.sent(),[4,ve.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),D(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,y,h,v,f,m,g,S,I=this;return A(this,(function(b){switch(b.label){case 0:return r=function(e,t,n){return D(I,void 0,void 0,(function(){var r,i,a;return A(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 D(I,void 0,void 0,(function(){var n=this;return A(this,(function(i){return[2,Promise.all(O(e.categories.map((function(i){return D(n,void 0,void 0,(function(){var n;return A(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 D(n,void 0,void 0,(function(){var n;return A(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 D(I,void 0,void 0,(function(){var n=this;return A(this,(function(r){return[2,Promise.all(e.map((function(e){return D(n,void 0,void 0,(function(){var n;return A(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 D(I,void 0,void 0,(function(){var t=this;return A(this,(function(n){return[2,Promise.all(e.map((function(e){return D(t,void 0,void 0,(function(){return A(this,(function(t){return[2,{approverId:e.id,sharedKeyId:e.keyId}]}))}))})))]}))}))},o=function(e,t){return D(I,void 0,void 0,(function(){var n=this;return A(this,(function(r){return[2,Promise.all(e.map((function(e){return D(n,void 0,void 0,(function(){var n;return A(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=b.sent()).status!==e.ScenarioState.APPROVED)throw new L({code:e.LrErrorCode.BadState,message:"Scenario must be in "+e.ScenarioState.APPROVED+" state"});return[4,this.keyGraph.getKey(c.keyId)];case 2:return u=b.sent(),[4,this.keyFactory.createKey()];case 3:return p=b.sent(),l={scenarioId:c.id,disable:n},[4,a(c.receivers,p)];case 4:return l.receivers=b.sent(),d=l,[4,this.keyGraph.encryptToString(u.jwk,p.toJSON(!0))];case 5:return y=b.sent(),h=d,v={subjectKeyId:u.id,subjectKeyWrappedAssemblyKey:y,assemblyCipherData:""},[4,o(c.approverGroups,p)];case 6:return h.approverAssembly=(v.subAssemblies=b.sent(),v),c.approverGroups.length?(f=p.toJSON(!0),m=f.k,g=P(f,["k"]),S=new ti(c.assemblyQuorum),c.approverGroups.forEach((function(e,t){var n=e.approvers.length;1===e.quorum&&(n=1),S.addSubAssembly(new ei(t,e.quorum,n))})),[4,this.slip39Service.generateShares(m,Cc.SLIP39_PASSPHRASE,S)]):[3,9];case 7:return b.sent(),[4,Promise.all(c.approverGroups.map((function(e,t){return D(I,void 0,void 0,(function(){var n,r,i=this;return A(this,(function(a){switch(a.label){case 0:return n=S.subAssemblies[t],r=d.approverAssembly.subAssemblies[t],[4,Promise.all(e.approvers.map((function(t,a){return D(i,void 0,void 0,(function(){var i,s,o,c;return A(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:b.sent(),b.label=9;case 9:return[4,this.lrApollo.mutate({mutation:Ic,variables:{input:d}})];case 10:return b.sent(),[2]}}))}))},t.prototype.getAllScenarioIds=function(){return D(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:sc})];case 1:return[2,e.sent().scenarios.edges.map((function(e){return e.node.id}))]}}))}))},t}();Pc.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Pc(n.ɵɵinject(Ie),n.ɵɵinject(qt),n.ɵɵinject(ve),n.ɵɵinject(ge),n.ɵɵinject(ye),n.ɵɵinject(Se),n.ɵɵinject(Fs),n.ɵɵinject(ii),n.ɵɵinject(kc),n.ɵɵinject(Cc),n.ɵɵinject(wc),n.ɵɵinject(e.ɵb))},token:Pc,providedIn:"root"}),Pc.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Pc.ctorParameters=function(){return[{type:Ie},{type:qt},{type:ve},{type:ge},{type:ye},{type:Se},{type:Fs},{type:ii},{type:kc},{type:Cc},{type:wc},{type:e.ɵb}]};var Rc,Dc=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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s=this;return A(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 D(this,void 0,void 0,(function(){var t,n,r=this;return A(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 D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var t,n;return A(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 D(this,void 0,void 0,(function(){var i,a,s;return A(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 D(this,void 0,void 0,(function(){var i=this;return A(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 D(i,void 0,void 0,(function(){var i;return A(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 D(i,void 0,void 0,(function(){var i;return A(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 D(i,void 0,void 0,(function(){var t;return A(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 D(i,void 0,void 0,(function(){var t;return A(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}();Dc.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Dc(n.ɵɵinject(Pc),n.ɵɵinject(kc),n.ɵɵinject(Cc),n.ɵɵinject(wc))},token:Dc,providedIn:"root"}),Dc.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Dc.ctorParameters=function(){return[{type:Pc},{type:kc},{type:Cc},{type:wc}]},function(e){e.Name="name",e.Email="email",e.Image="image",e.Phone="phone",e.Address="address"}(Rc||(Rc={}));var Ac=[Rc.Name,Rc.Email,Rc.Image,Rc.Phone,Rc.Address],Ec=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 D(this,void 0,void 0,(function(){var t;return A(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 D(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return A(this,(function(p){switch(p.label){case 0:return t?0===(n=this.getChanges(e,t)).length?[2]:[4,this.trustedPartyService.getTrustedParties()]:[2];case 1:if(0===(r=p.sent()).length)return[2];p.label=2;case 2:p.trys.push([2,7,8,9]),i=E(r.map((function(e){return e.mySharedDetails}))),a=i.next(),p.label=3;case 3:return a.done?[3,6]:(s=a.value,[4,this.synchronizeSharedContactCard(s,n)]);case 4:p.sent(),p.label=5;case 5:return a=i.next(),[3,3];case 6:return[3,9];case 7:return o=p.sent(),c={error:o},[3,9];case 8:try{a&&!a.done&&(u=i.return)&&u.call(i)}finally{if(c)throw c.error}return[7];case 9:return[2]}}))}))},e.prototype.getChanges=function(e,t){var n,r,i,a,s=[];try{for(var o=E(Ac),c=o.next();!c.done;c=o.next()){var u=c.value,p=t[u];if(p&&p.values){var d=function(t){var n=e[u].values.find((function(e){return e.id===t.id}));n?C.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,E(p.values)),y=l.next();!y.done;y=l.next()){d(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 D(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l;return A(this,(function(y){switch(y.label){case 0:n=!1,r=function(t){switch(t.field){case Rc.Phone:(r=e.phones&&e.phones.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;case Rc.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];C.isEqual(r,t.oldValue)&&(n=!0,e[t.field]=t.newValue)}};try{for(i=E(t),a=i.next();!a.done;a=i.next())s=a.value,r(s)}catch(e){d={error:e}}finally{try{a&&!a.done&&(l=i.return)&&l.call(i)}finally{if(d)throw d.error}}return n?(o=e.id,c=e.ownedKeyId,u=e.sharedKeyId,p=P(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(o,c,u,p)]):[3,2];case 1:y.sent(),y.label=2;case 2:return[2]}}))}))},e.prototype.updateTrustedPartyDetails=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i;return A(this,(function(a){switch(a.label){case 0:return t=e.id,n=e.ownedKeyId,r=e.sharedKeyId,i=P(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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,y;return A(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(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){p={error:e}}finally{try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(p)throw p.error}}if(e.addresses&&e.addresses.length)try{for(s=E(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!C.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}();Ec.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Ec(n.ɵɵinject(vs),n.ɵɵinject(Fs),n.ɵɵinject(bn),n.ɵɵinject(oi))},token:Ec,providedIn:"root"}),Ec.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ec.ctorParameters=function(){return[{type:vs},{type:Fs},{type:bn},{type:oi}]},(e.UserDeleteState||(e.UserDeleteState={})).REQUESTED="REQUESTED";var $c=function(){function e(){}return e.forRoot=function(t){return{ngModule:e,providers:[{provide:te,useValue:t},{provide:d.AuthClass,useValue:k},{provide:n.APP_INITIALIZER,useFactory:Vi,deps:[te,d.AuthClass],multi:!0},{provide:n.APP_INITIALIZER,useFactory:si,deps:[oi],multi:!0},{provide:l.APOLLO_OPTIONS,useFactory:re,deps:[te,d.AuthClass]}]}},e}();$c.decorators=[{type:n.NgModule,args:[{imports:[t.HttpClientModule,g.NgIdleKeepaliveModule.forRoot()],providers:[v.CookieService,ce,ci,bn,ea,oi,Wn,he,ye,Se,ge,ve]}]}];var Oc,jc=function(){},Tc=function(){},Mc=function(){},Fc=function(){},Nc=function(){};(Oc=e.SearchItemType||(e.SearchItemType={})).RECORD="RECORD",Oc.CATEGORY="CATEGORY";var Lc,xc=y(Lc||(Lc=j(['\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"])),Te);function Uc(t,n,r,i,a){return D(this,void 0,void 0,(function(){var s,o,c,u;return A(this,(function(p){switch(p.label){case 0:return[],[4,t.getCategory(i)];case 1:s=p.sent(),c=s.records.length,p.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:p.sent(),p.label=4;case 4:return++c,[3,2];case 5:c=s.records.length,p.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:p.sent(),p.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 D(this,void 0,void 0,(function(){var n,r,i,a;return A(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 D(this,void 0,void 0,(function(){var t=this;return A(this,(function(n){return[2,Promise.all(e.map((function(e){return t.mapRecordContent(e.node)})))]}))}))},t.prototype.load=function(){return D(this,void 0,void 0,(function(){var e,t,n,r,i,a,s,o,c,u;return A(this,(function(p){switch(p.label){case 0:return[4,this.categoryService.getDefaultVault()];case 1:return e=p.sent(),t=Date.now(),r=this,[4,this.lrApollo.query({query:xc,variables:{id:e.id,depth:5,first:null,after:null,recordContentFilter:la}})];case 2:return r.recordContentsResult=p.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=p.sent();try{for(a=E(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 D(this,void 0,void 0,(function(){return A(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=n.ɵɵdefineInjectable({factory:function(){return new e.SearchService(n.ɵɵinject(n.NgZone),n.ɵɵinject(Ie),n.ɵɵinject(Oa),n.ɵɵinject(Se))},token:e.SearchService,providedIn:"root"}),e.SearchService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.SearchService.ctorParameters=function(){return[{type:n.NgZone},{type:Ie},{type:Oa},{type:Se}]},e.SearchService=R([Rr({ngZoneName:"ngZone"})],e.SearchService);var qc,Jc,_c,Gc,Bc,Qc,Vc=Tn(qc||(qc=j(["\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"]))),Wc=Tn(Jc||(Jc=j(["\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"]))),Hc=Tn(_c||(_c=j(["\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=Tn(Gc||(Gc=j(["\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"]))),Yc=(Tn(Bc||(Bc=j(['\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"])),Vc),Tn(Qc||(Qc=j(["\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"])),Vc),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 D(this,void 0,void 0,(function(){var t,n,r,i,a;return A(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 Nr({mutation:Wc,variables:{input:Object.assign(Object.assign({},a),{wrappingKeyId:t.id,wrappedKey:r,cipherData:i})}})]}}))}))},e.prototype.updateContactCard=function(e){return D(this,void 0,void 0,(function(){var t,n;return A(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 Nr({mutation:Hc,variables:{input:Object.assign(Object.assign({},n),{id:e.id,cipherData:t})}})]}}))}))},e.prototype.deleteContactCard=function(e){return new Nr({mutation:Zc,variables:{input:{id:e}}})},e.prototype.prepareContactCardInput=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return A(this,(function(d){switch(d.label){case 0:return[4,this.keyService.getCurrentSigPxk()];case 1:return t=d.sent(),i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicDataJson)];case 2:return n=i.apply(r,[d.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicSearchableJson)];case 3:return a=o.apply(s,[d.sent()]),p=(u=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.plainDataJson)];case 4:return c=p.apply(u,[d.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:c}]}}))}))},e}(),e.ContactCard2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ContactCard2Service(n.ɵɵinject(ve),n.ɵɵinject(ge),n.ɵɵinject(ye),n.ɵɵinject(Se),n.ɵɵinject(qt),n.ɵɵinject(n.NgZone))},token:e.ContactCard2Service,providedIn:"root"}),e.ContactCard2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ContactCard2Service.ctorParameters=function(){return[{type:ve},{type:ge},{type:ye},{type:Se},{type:qt},{type:n.NgZone}]},e.ContactCard2Service=R([Rr({ngZoneName:"ngZone"})],e.ContactCard2Service);var zc,Xc,eu,tu,nu,ru,iu,au,su,ou,cu,uu,pu,du=Tn(zc||(zc=j(["\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"]))),lu=Tn(Xc||(Xc=j(["\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"]))),yu=Tn(eu||(eu=j(["\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"]))),hu=Tn(tu||(tu=j(["\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"]))),vu=Tn(nu||(nu=j(["\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"]))),fu=Tn(ru||(ru=j(["\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"]))),mu=Tn(iu||(iu=j(["\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"]))),gu=Tn(au||(au=j(["\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"]))),Su=Tn(su||(su=j(["\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"]))),Iu=Tn(ou||(ou=j(["\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"]))),bu=Tn(cu||(cu=j(["\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"]))),Cu=Tn(uu||(uu=j(["\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=Tn(pu||(pu=j(["\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||(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 K(t,e),t.prototype.downloadFileContent=function(e){return D(this,void 0,void 0,(function(){var t,n,r=this;return A(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 D(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,y,h=this;return A(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 q("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 p=(u=Object).assign,l=(d=Object).assign,y=[{}],[4,this.getInput(r,e)];case 5:return c=p.apply(u,[l.apply(d,y.concat([v.sent()])),{parentDirectories:i,parentRootDirectory:a}]),[2,new Nr({mutation:hu,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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return A(this,(function(p){switch(p.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=p.sent(),n=Nr.bind,r={mutation:vu},i={},s=(a=Object).assign,c=(o=Object).assign,u=[{}],[4,this.getInput(t.jwk,e)];case 2:return[2,new(n.apply(Nr,[void 0,(r.variables=(i.input=s.apply(a,[c.apply(o,u.concat([p.sent()])),{directoryId:e.directoryId}]),i),r)]))]}}))}))},t.prototype.deleteDirectory=function(e){return new Nr({mutation:fu,variables:{input:{directoryId:e}}})},t.prototype.createFile=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d=this;return A(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 D(d,void 0,void 0,(function(){var n,r,i,a;return A(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=Nr.bind,i={mutation:mu},a={},o=(s=Object).assign,u=(c=Object).assign,p=[{}],[4,this.createFileState(t,e)];case 3:return[2,new(r.apply(Nr,[void 0,(i.variables=(a.input=o.apply(s,[u.apply(c,p.concat([l.sent()])),{parentDirectories:n}]),a),i)]))]}}))}))},t.prototype.updateFile=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return A(this,(function(p){switch(p.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=p.sent(),n=Nr.bind,r={mutation:gu},i={},s=(a=Object).assign,c=(o=Object).assign,u=[{}],[4,this.createFileState(t.jwk,e)];case 2:return[2,new(n.apply(Nr,[void 0,(r.variables=(i.input=s.apply(a,[c.apply(o,u.concat([p.sent()])),{fileId:e.fileId}]),i),r)]))]}}))}))},t.prototype.deleteFile=function(e){return new Nr({mutation:Su,variables:{input:{fileId:e}}})},t.prototype.getParentDirectoryInput=function(e,t){return D(this,void 0,void 0,(function(){var n,r;return A(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 D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.query({query:yu,variables:{id:e}})];case 1:return[2,t.sent().fileState.keyId]}}))}))},t.prototype.getDirectoryKeyId=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.query({query:du,variables:{id:e}})];case 1:return[2,t.sent().directory.keyId]}}))}))},t.prototype.getFileKeyId=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.query({query:lu,variables:{id:e}})];case 1:return[2,t.sent().file.keyId]}}))}))},t.prototype.getDirectoryKey=function(e,t){return D(this,void 0,void 0,(function(){var n=this;return A(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getDirectoryKeyId(e)}))]}))}))},t.prototype.getFileKey=function(e,t){return D(this,void 0,void 0,(function(){var n=this;return A(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getFileKeyId(e)}))]}))}))},t.prototype.getInput=function(e,t){return D(this,void 0,void 0,(function(){var n,r,i,a;return A(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 D(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y;return A(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,p=(u=Object).assign,d=[{}],[4,this.getInput(n,t)];case 10:return l=[p.apply(u,d.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 Nr({mutation:Iu,variables:{input:{directoryId:e,recursive:t}}})},t.prototype.unarchiveDirectory=function(e,t){return new Nr({mutation:bu,variables:{input:{directoryId:e,recursive:t}}})},t.prototype.getChangeItemParentsInput=function(e,t){return D(this,void 0,void 0,(function(){var n,r=this;return A(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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return A(this,(function(p){switch(p.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=p.sent(),n=Nr.bind,r={mutation:Cu},i={},s=(a=Object).assign,c=(o=Object).assign,u=[{}],[4,this.getChangeItemParentsInput(e,t.jwk)];case 2:return[2,new(n.apply(Nr,[void 0,(r.variables=(i.input=s.apply(a,[c.apply(o,u.concat([p.sent()])),{directoryId:e.directoryId}]),i),r)]))]}}))}))},t.prototype.changeFileParents=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){return[2,this.mutate(this.changeFileParentsMutation(e))]}))}))},t.prototype.changeFileParentsMutation=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return A(this,(function(p){switch(p.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=p.sent(),n=Nr.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(Nr,[void 0,(r.variables=(i.input=s.apply(a,[c.apply(o,u.concat([p.sent()])),{fileId:e.fileId}]),i),r)]))]}}))}))},t}(zr),e.Item2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.Item2Service(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(ci),n.ɵɵinject(ge),n.ɵɵinject(qt),n.ɵɵinject(ve),n.ɵɵinject(Se))},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:ci},{type:ge},{type:qt},{type:ve},{type:Se}]},e.Item2Service=R([Rr({ngZoneName:"ngZone"})],e.Item2Service);var wu,Ku,Pu,Ru,Du,Au,Eu,$u,Ou,ju,Tu,Mu=Tn(wu||(wu=j(["\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"]))),Fu=Tn(Ku||(Ku=j(["\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}"]))),Nu=Tn(Pu||(Pu=j(["\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"])),Mu),Lu=Tn(Ru||(Ru=j(["\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"])),Mu),xu=Tn(Du||(Du=j(["\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"])),Mu),Uu=Tn(Au||(Au=j(["\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"]))),qu=Tn(Eu||(Eu=j(["\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"]))),Ju=Tn($u||($u=j(["\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"])),Mu),_u=Tn(Ou||(Ou=j(["\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"])),Mu,Fu),Gu=Tn(ju||(ju=j(["\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"])),Mu,Fu),Bu=Tn(Tu||(Tu=j(["\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"])),Fu);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 D(this,void 0,void 0,(function(){var r,i;return A(this,(function(a){switch(a.label){case 0:return n?[4,ve.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,ve.asKey(i.otKey)]:[3,6];case 5:return[2,a.sent()];case 6:return[2,null]}}))}))},t.prototype.decryptOtk=function(e,t){return D(this,void 0,void 0,(function(){var n,r,i,a,s,o;return A(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 D(this,void 0,void 0,(function(){var r;return A(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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return A(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,ve.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,p=[r],[4,ve.asKey(n.oneTimePrk)]):[3,6];case 4:return[4,u.apply(this,p.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?(d=i,[4,this.encryptionService.decrypt(r,i.otKeyCipher)]):[3,8];case 7:d.otKeyCipherClearJson=l.sent(),l.label=8;case 8:return[2,Object.assign(Object.assign({},e),{otk:i})]}}))}))},t.prototype.decryptKeyExchangeAsResponder=function(e,t){return D(this,void 0,void 0,(function(){return A(this,(function(n){return[2,this.decryptOtk(e,t)]}))}))},t.prototype.decryptKeyExchange=function(e,t){return D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var e,n=this;return A(this,(function(r){switch(r.label){case 0:return[4,this.lrGraphQL.query({query:Nu,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 D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:i?xu:Lu,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 D(this,void 0,void 0,(function(){return A(this,(function(t){return[2,this.lrGraphQL.query({query:Bu,variables:{username:e.username,userId:e.userId}})]}))}))},t.prototype.cancelKeyExchange=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){return[2,this.cancelKeyExchangeMutation(e)]}))}))},t.prototype.cancelKeyExchangeMutation=function(e){return new Nr({mutation:Uu,variables:{input:{id:e}}})},t.prototype.declineKeyExchange=function(e,t){return D(this,void 0,void 0,(function(){return A(this,(function(n){return[2,this.declineKeyExchangeMutation(e,t)]}))}))},t.prototype.declineKeyExchangeMutation=function(e,t){return new Nr({mutation:qu,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 D(this,void 0,void 0,(function(){var e,t,s,o,c,u,p,d,l,y,h,v,f;return A(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 p={message:n,contactCard:i&&{sharedCipherDataClearJson:i.sharedCipherDataClearJson}},d={nonce:t,initiator:Object.assign(Object.assign({},p),{oneTimePbk:s.toJSON(),pbk:o.jwk.toJSON(),sigPbk:c.jwk.toJSON()})},[4,this.keyGraph.encryptToString(e,d)];case 7:return l=m.sent(),y={nonce:t,oneTimePrk:s.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:i,initiator:p},[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 Nr({mutation:Ju,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 D(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,v,f,m,g,S,I,b,C,k,w,K,P,R,D,E,$,O,j,T,M,F,N,L,x,U,q,J,_,G,B,Q,V,W,H,Z,Y,z,X,ee,te;return A(this,(function(A){switch(A.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return e=A.sent(),o=this.keyService.getCurrentMasterKey().id,[4,this.keyService.getCurrentMasterKey()];case 2:return c=A.sent(),[4,this.keyFactory.createKey()];case 3:return u=A.sent(),[4,this.keyFactory.createKey()];case 4:return p=A.sent(),[4,this.encryptionService.encrypt(e.jwk,u.toJSON(!0))];case 5:return d=A.sent(),[4,this.encryptionService.encrypt(c.jwk,p.toJSON(!0))];case 6:return l=A.sent(),[4,ve.asKey(r.otKeyCipherClearJson.initiator.oneTimePbk)];case 7:return y=A.sent(),[4,ve.asKey(r.otKeyCipherClearJson.initiator.pbk)];case 8:return h=A.sent(),[4,ve.asKey(r.otKeyCipherClearJson.initiator.sigPbk)];case 9:return v=A.sent(),[4,this.keyService.getCurrentPxk()];case 10:return f=A.sent(),[4,this.keyService.getCurrentSigPxk()];case 11:return m=A.sent(),[4,this.encryptionService.sign(m.jwk,h.toJSON())];case 12:return g=A.sent(),[4,this.encryptionService.sign(m.jwk,v.toJSON())];case 13:return S=A.sent(),I={nonce:r.otKeyCipherClearJson.nonce,sharedKey:u.toJSON(!0),mkSharedKey:p.toJSON(!0),responder:{pbk:f.jwk.toJSON(),sigPbk:m.jwk.toJSON(),message:i}},r.otKeyCipherClearJson.initiator.contactCard?(C=r.otKeyCipherClearJson.initiator.contactCard.sharedCipherDataClearJson,[4,this.keyFactory.createKey()]):[3,24];case 14:return k=A.sent(),[4,this.keyFactory.createKey()];case 15:return L=A.sent(),[4,this.keyService.getCurrentSigPxk()];case 16:return x=A.sent(),w={},P=(K=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,k.toJSON(!0))];case 17:return w.receiverWrappedKey=P.apply(K,[A.sent()]),w.receiverWrappingKeyId=e.id,a?(E=(D=JSON).stringify,[4,this.encryptionService.encrypt(k,a.receiverCipherDataClearJson)]):[3,19];case 18:return R=E.apply(D,[A.sent()]),[3,20];case 19:R="",A.label=20;case 20:return w.receiverCipherData=R,O=($=JSON).stringify,[4,this.encryptionService.encrypt(u,L.toJSON(!0))];case 21:return w.sharedWrappedKey=O.apply($,[A.sent()]),b=w,[4,this.encryptionService.encrypt(L,C)];case 22:return W=A.sent(),j=b,M=(T=JSON).stringify,[4,this.encryptionService.sign(x.jwk,W)];case 23:j.sharedCipherDataSig=M.apply(T,[A.sent()]),b.sigPxkId=x.id,I.responder.contactCard=Object.assign(Object.assign({},I.responder.contactCard),{sharedCipherKey:L.toJSON(!0)}),A.label=24;case 24:return s?[4,this.keyFactory.createKey()]:[3,37];case 25:return N=A.sent(),[4,this.keyFactory.createKey()];case 26:return L=A.sent(),[4,this.keyService.getCurrentSigPxk()];case 27:return x=A.sent(),U={},J=(q=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,N.toJSON(!0))];case 28:return U.ownerWrappedKey=J.apply(q,[A.sent()]),U.ownerWrappingKeyId=e.id,s.ownerCipherDataClearJson?(B=(G=JSON).stringify,[4,this.encryptionService.encrypt(N,s.ownerCipherDataClearJson)]):[3,30];case 29:return _=B.apply(G,[A.sent()]),[3,31];case 30:_="",A.label=31;case 31:return U.ownerCipherData=_,V=(Q=JSON).stringify,[4,this.encryptionService.encrypt(u,L.toJSON(!0))];case 32:return U.sharedWrappedKey=V.apply(Q,[A.sent()]),F=U,[4,this.encryptionService.encrypt(L,s.sharedCipherDataClearJson)];case 33:return W=A.sent(),H=F,Y=(Z=JSON).stringify,[4,this.encryptionService.sign(x.jwk,W)];case 34:return H.sharedCipherDataSig=Y.apply(Z,[A.sent()]),F.sigPxkId=x.id,s.ownerPlainDataJson?(z=F,ee=(X=JSON).stringify,[4,this.encryptionService.sign(m.jwk,s.ownerPlainDataJson)]):[3,36];case 35:z.ownerPlainDataSig=ee.apply(X,[A.sent()]),A.label=36;case 36:I.responder.contactCard=Object.assign(Object.assign({},I.responder.contactCard),{sharedCipherDataClearJson:s.sharedCipherDataClearJson}),A.label=37;case 37:return[4,this.encryptionService.encrypt(y,I)];case 38:return te=A.sent(),[4,this.encryptionService.encrypt(r.otKey,te)];case 39:return te=A.sent(),[2,new Nr({mutation:_u,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(d),mkWrappedMkSharedKey:JSON.stringify(l),initiatorOneTimePbkCipher:JSON.stringify(te),initiatorContactCard:b,responderContactCard:F}}})]}}))}))},t.prototype.completeOtk=function(e){var t=e.keyExchangeId,n=e.initiatorRootKeyCipher,r=e.initiatorOneTimePbkCipher,i=e.responderContactCard,a=e.initiatorContactCard;return D(this,void 0,void 0,(function(){var e,s,o,c,u,p,d,l,y,h,v,f,m,g,S,I,b,C,k,w,K,P,R,D,E,$,O,j,T,M,F,N,L,x,U,q,J;return A(this,(function(A){switch(A.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return e=A.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return s=A.sent(),[4,this.encryptionService.decrypt(e.jwk,n)];case 3:return o=A.sent(),u=this.decryptResponseCipher,[4,ve.asKey(o.otKey)];case 4:return p=[A.sent()],[4,ve.asKey(o.oneTimePrk)];case 5:return[4,u.apply(this,p.concat([A.sent(),r]))];case 6:if(c=A.sent(),o.nonce!==c.nonce)throw new B("The nonce returned by responder does not match with the one created by the initiator.");return[4,this.keyService.getCurrentSigPxk()];case 7:return d=A.sent(),[4,ve.asKey(c.responder.sigPbk)];case 8:return l=A.sent(),[4,ve.asKey(c.responder.pbk)];case 9:return y=A.sent(),[4,this.encryptionService.sign(d.jwk,y.toJSON())];case 10:return h=A.sent(),[4,this.encryptionService.sign(d.jwk,l.toJSON())];case 11:return v=A.sent(),[4,ve.asKey(c.sharedKey)];case 12:return f=A.sent(),[4,this.encryptionService.encrypt(e.jwk,f.toJSON(!0))];case 13:return m=A.sent(),[4,ve.asKey(c.mkSharedKey)];case 14:return g=A.sent(),[4,this.encryptionService.encrypt(s.jwk,g.toJSON(!0))];case 15:return S=A.sent(),i?[4,this.keyFactory.createKey()]:[3,19];case 16:return b=A.sent(),C={},w=(k=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,b.toJSON(!0))];case 17:return C.receiverWrappedKey=w.apply(k,[A.sent()]),C.receiverWrappingKeyId=e.id,P=(K=JSON).stringify,[4,this.encryptionService.encrypt(b,i.receiverCipherDataClearJson)];case 18:C.receiverCipherData=P.apply(K,[A.sent()]),I=C,A.label=19;case 19:return o.initiatorContactCard?(E=o.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,28];case 20:return $=A.sent(),[4,ve.asKey(c.responder.contactCard.sharedCipherKey)];case 21:return O=A.sent(),M=(T=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,$.toJSON(!0))];case 22:return j=M.apply(T,[A.sent()]),(F=(null==a?void 0:a.ownerCipherDataClearJson)||E.ownerCipherDataClearJson)?[4,this.keyGraph.encryptToString($,F)]:[3,24];case 23:return L=A.sent(),[3,25];case 24:L="",A.label=25;case 25:return N=L,R={ownerWrappedKey:j,ownerWrappingKeyId:e.id,ownerCipherData:N},D={sigPxkId:d.id},[4,this.encryptionService.encrypt(O,E.sharedCipherDataClearJson)];case 26:return x=A.sent(),U=D,J=(q=JSON).stringify,[4,this.encryptionService.sign(d.jwk,x)];case 27:U.sharedCipherDataSig=J.apply(q,[A.sent()]),A.label=28;case 28:return[2,new Nr({mutation:Gu,variables:{input:{keyExchangeId:t,rootKeyId:e.id,masterKeyId:s.id,initiatorSigPxkId:d.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=n.ɵɵdefineInjectable({factory:function(){return new e.KeyExchange2Service(n.ɵɵinject(n.NgZone),n.ɵɵinject(ve),n.ɵɵinject(ge),n.ɵɵinject(ye),n.ɵɵinject(mi),n.ɵɵinject(Se),n.ɵɵ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:ve},{type:ge},{type:ye},{type:mi},{type:Se},{type:e.ɵb}]},e.KeyExchange2Service=R([Rr({ngZoneName:"ngZone"})],e.KeyExchange2Service);var Qu,Vu,Wu,Hu,Zu=Tn(Qu||(Qu=j(["\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}"]))),Yu=Tn(Vu||(Vu=j(["\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}"]))),zu=Tn(Wu||(Wu=j(["\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}"]))),Xu=Tn(Hu||(Hu=j(["\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 D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:zu,variables:{id:e}})];case 1:return[2,{sharedKeyId:(t=n.sent().ownedContactCard).sharedKey.id,ownerKeyId:t.ownerKey.id}]}}))}))},e.prototype.getReceivedContactCardKeyId=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:Xu,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 D(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,v,f,m;return A(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 p=g.sent(),y=(l=JSON).stringify,[4,this.encryptionService.sign(u.jwk,p)];case 10:return d=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 Nr({mutation:Zu,variables:{input:{id:t,ownerCipherData:m,ownerKeyId:e.id,sharedCipherDataSig:d,sharedKeyId:o.id,sigPxkId:u.id,ownerPlainDataSig:h}}})]}}))}))},e.prototype.updateReceivedContactCard=function(e){var t=e.id,n=e.receiverKeyId,r=e.receiverCipherDataClearJson;return D(this,void 0,void 0,(function(){var e,i,a=this;return A(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 Nr({mutation:Yu,variables:{input:{id:t,receiverCipherData:i,receiverKeyId:e.id}}})]}}))}))},e}(),e.SharedContactCard2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.SharedContactCard2Service(n.ɵɵinject(n.NgZone),n.ɵɵinject(ge),n.ɵɵinject(Se),n.ɵɵinject(ye),n.ɵɵ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:ge},{type:Se},{type:ye},{type:e.ɵb}]},e.SharedContactCard2Service=R([Rr({ngZoneName:"ngZone"})],e.SharedContactCard2Service);var ep,tp,np,rp,ip=Tn(ep||(ep=j(["\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}"]))),ap=Tn(tp||(tp=j(["\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"])),ip),sp=Tn(np||(np=j(["\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"])),ip),op=Tn(rp||(rp=j(["\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"])),ip);e.LockService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return K(t,e),t.prototype.updateLockMutation=function(e,t){return new Nr({mutation:ap,variables:{input:{resourceId:e,version:t}}})},t.prototype.acquireLockMutation=function(e,t){return new Nr({mutation:sp,variables:{input:{resourceId:e,timeoutMs:t}}})},t.prototype.releaseLockMutation=function(e,t){return new Nr({mutation:op,variables:{input:{resourceId:e,version:t}}})},t}(zr),e.LockService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.LockService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.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=R([Rr({ngZoneName:"ngZone"})],e.LockService);var cp,up,pp,dp,lp,yp,hp,vp,fp,mp=Tn(cp||(cp=j(["\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"]))),gp=Tn(up||(up=j(["\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"]))),Sp=Tn(pp||(pp=j(["\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"]))),Ip=Tn(dp||(dp=j(["\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"]))),bp=Tn(lp||(lp=j(["\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"]))),Cp=Tn(yp||(yp=j(["\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"]))),kp=Tn(hp||(hp=j(["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"]))),wp=Tn(vp||(vp=j(["\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"]))),Kp=Tn(fp||(fp=j(["\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 Nr({mutation:mp,variables:{input:{id:e}}})},e.prototype.getTpCurrentUserSharedKey=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:Cp,variables:{id:e}})];case 1:return[2,t.sent().tp.currentUserSharedKey.userSharedKey]}}))}))},e.prototype.shareDirectory=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){return[2,this.shareItem(Object.assign(Object.assign({},e),{isDirectory:!0}))]}))}))},e.prototype.shareFile=function(e){return D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){var e,o,c,u=this;return A(this,(function(p){switch(p.label){case 0:return[4,this.keyGraph.getKey(n,(function(){return s?u.item2Service.getDirectoryKeyId(t):u.item2Service.getFileKeyId(t)}))];case 1:return e=p.sent(),[4,this.keyGraph.getKey(i,(function(){return u.getTpCurrentUserSharedKey(r).then((function(e){return e.sharedKey.id}))}))];case 2:return o=p.sent(),[4,this.keyGraph.wrapKey(o,e.jwk)];case 3:return c=p.sent(),[2,new Nr({mutation:s?gp:Ip,variables:{input:{id:t,tpId:r,accessRole:a,keyId:e.id,wrappingKeyId:o.id,wrappedKey:c}}})]}}))}))},e.prototype.unshareDirectory=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){return[2,this.unshareItem(Object.assign(Object.assign({},e),{isDirectory:!0}))]}))}))},e.prototype.unshareFile=function(e){return D(this,void 0,void 0,(function(){return A(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 D(this,void 0,void 0,(function(){return A(this,(function(e){return[2,new Nr({mutation:r?Sp:bp,variables:{input:{id:t,tpId:n}}})]}))}))},e.prototype.requestMkReshare=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a,s;return A(this,(function(o){switch(o.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if((t=o.sent()).mkSharedKey)throw new ee("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 Nr({mutation:kp,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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d;return A(this,(function(l){switch(l.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if(!(t=l.sent()).mkSharedKey)throw new ee("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,p.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,d=[i],[4,this.encryptionService.encryptToString(n.jwk,s)];case 6:return[4,u.apply(c,d.concat([l.sent()]))];case 7:return o=l.sent(),[2,new Nr({mutation:wp,variables:{input:{tpId:e,mkSharedKeyId:a.id,mkReshareResponseCipher:o}}})]}}))}))},e.prototype.completeMkReshare=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d,l;return A(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,p.JWK.asKey(i.mkSharedKey.jwk)];case 6:return u.jwk=y.sent(),c=u,[4,this.keyService.getCurrentMasterKey()];case 7:return d=y.sent(),[4,this.encryptionService.encryptToString(d.jwk,c.jwk.toJSON(!0))];case 8:return l=y.sent(),[2,new Nr({mutation:Kp,variables:{input:{tpId:e,masterKeyId:d.id,mkSharedKeyId:c.id,mkWrappedMkSharedKey:l}}})]}}))}))},e}(),e.TrustedParty2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.TrustedParty2Service(n.ɵɵinject(n.NgZone),n.ɵɵinject(Se),n.ɵɵinject(e.ɵb),n.ɵɵinject(e.Item2Service),n.ɵɵinject(ge),n.ɵɵinject(ve),n.ɵɵinject(ye))},token:e.TrustedParty2Service,providedIn:"root"}),e.TrustedParty2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.TrustedParty2Service.ctorParameters=function(){return[{type:n.NgZone},{type:Se},{type:e.ɵb},{type:e.Item2Service},{type:ge},{type:ve},{type:ye}]},e.TrustedParty2Service=R([Rr({ngZoneName:"ngZone"})],e.TrustedParty2Service);var Pp=function(){},Rp=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return K(t,e),t}(Pp),Dp=function(){},Ap=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return K(t,e),t}(Dp);e.TpPasswordResetService=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 K(t,e),t.prototype.getReset=function(){return D(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return[4,this.query({query:Sr})];case 1:return[2,e.sent().tpPasswordReset]}}))}))},t.prototype.createReset=function(e){return this.mutate(this.createResetMutation(e))},t.prototype.createResetMutation=function(e){return D(this,void 0,void 0,(function(){var t,n=this;return A(this,(function(r){switch(r.label){case 0:return[4,this._createReset(e,(function(t){return D(n,void 0,void 0,(function(){return A(this,(function(n){return[2,this.prepareSlip39(e.createSubAssemblies,e.quorum,t)]}))}))}))];case 1:return t=r.sent().mutationInput,[2,new Nr({mutation:Ir,variables:{input:t}})]}}))}))},t.prototype.deleteReset=function(){return this.mutate(this.deleteResetMutation())},t.prototype.deleteResetMutation=function(){return new Nr({mutation:br})},t.prototype.updateReset=function(e){return this.mutate(this.updateResetMutation(e))},t.prototype.updateResetMutation=function(e){return D(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c=this;return A(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 D(c,void 0,void 0,(function(){return A(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 D(c,void 0,void 0,(function(){var o,c,u,p,d,l=this;return A(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=[],p=[],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?p.push({tp:e,approverId:n.id}):u.push({tp:e})})),d={subAssemblyId:n.id,singleReject:n.singleReject,quorum:n.quorum,subjectCipherData:o},[4,Promise.all(u.map((function(t,n){var o=t.tp;return D(l,void 0,void 0,(function(){return A(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 d.createApprovers=y.sent(),[4,Promise.all(p.map((function(t,n){var o=t.tp,c=t.approverId;return D(l,void 0,void 0,(function(){return A(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,(d.updateApprovers=y.sent(),d)]}}))}))})))];case 3:return o=u.sent(),[2,new Nr({mutation:Cr,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 Nr({mutation:lr})},t.prototype.validateApprovers=function(e){var t,n;try{for(var r=E(e),i=r.next();!i.done;i=r.next()){var a=i.value;if(!a.currentUserSharedKey.userSharedKey.mkSharedKey){var s="tp "+a.other.username+" does not have mkSharedKey";throw console.log(s),new q(s)}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},t.prototype.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 D(this,void 0,void 0,(function(){var e,c,u,p,d,l,y,h;return A(this,(function(v){switch(v.label){case 0:if(!n.currentUserSharedKey.userSharedKey.mkSharedKey)throw new q("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(p=v.sent(),(d=a.subAssemblies[i]).index!==i)throw new G("slip sub assembly index should match with array index");return l=1===d.threshold?d.shares[0]:d.shares[r],y={slip39:{share:l,subAssembly:{quorum:d.threshold,size:d.size}},assemblyKeyParams:s},console.log("partialAssemblyKey",y),h={tpMkSharedKeyId:c.id,tpMkSharedKeyWrappedSharedKey:u,subjectKeyWrappedSharedKey:p},[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 D(this,void 0,void 0,(function(){var r;return A(this,(function(i){switch(i.label){case 0:if(e.length<t)throw new q("Not enough sub assemblies to meet quorum");return r=new ti(t),e.forEach((function(e,t){var n=e.approverTps.length;1===e.quorum&&(n=1),r.addSubAssembly(new ei(t,e.quorum,n))})),[4,this.slip39Service.generateShares(n,ai,r)];case 1:return i.sent(),[2,r]}}))}))},t.prototype._createReset=function(e,t){return D(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y,h,v,f=this;return A(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=P(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 p=m.sent(),[4,this.encryptionService.encryptToString(r,i.toJSON(!0))];case 7:return d=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 D(f,void 0,void 0,(function(){var n,i,a=this;return A(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 D(a,void 0,void 0,(function(){return A(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:p,subjectKeyWrappedAssemblyKey:d,subjectCipherData:"",assemblyCipherData:y,createSubAssemblies:v,assemblyKeyVerifierPbk:JSON.stringify(c.toJSON()),wrappedAssemblyKeyVerifierPrk:u}}}]}}))}))},t}(zr),e.TpPasswordResetService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(ge),n.ɵɵinject(ve),n.ɵɵinject(ye),n.ɵɵinject(Se),n.ɵɵinject(ii))},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:ge},{type:ve},{type:ye},{type:Se},{type:ii}]},e.TpPasswordResetService=R([Rr({ngZoneName:"ngZone"})],e.TpPasswordResetService),e.TpPasswordResetUserService=function(e){function t(t,n,r,i,a,s,o,c,u,p,d){var l=e.call(this,n)||this;return l.ngZone=t,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=p,l.lrAuth=d,l}return K(t,e),t.prototype.verifyEmailContact=function(e){return D(this,void 0,void 0,(function(){var t;return A(this,(function(n){return t={email:e},[2,this.http.post(this.config.authUrl+"tp/password-reset/verify-contact/",t).toPromise()]}))}))},t.prototype.verifyContactRespond=function(e,t){return D(this,void 0,void 0,(function(){return A(this,(function(n){switch(n.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e,v_code:t}).toPromise()];case 1:return[2,n.sent().token]}}))}))},t.prototype.requestReset=function(e,t,n){return D(this,void 0,void 0,(function(){var r,i,a,s,o,c,u;return A(this,(function(p){switch(p.label){case 0:return[4,this.passwordService.createPassKeyBundle(e)];case 1:return r=p.sent(),[4,this.keyFactory.createKey()];case 2:return i=p.sent(),[4,this.encryptionService.encrypt(r.passKey,i.toJSON(!0))];case 3:return a=p.sent(),[4,this.keyFactory.createPkcKey()];case 4:return s=p.sent(),[4,this.encryptionService.encrypt(i,s.toJSON(!0))];case 5:return o=p.sent(),[4,this.http.post(this.config.authUrl+"tp/password-reset/request/",{claimId:t,claimToken:n,pass_key_params:r.passKeyParams,pass_idp_params:r.passIdpParams,pass_idp_verifier_pbk:r.passIdpVerifier.toJSON(),wrapped_pass_idp_verifier_prk:r.wrappedPassIdpVerifierPrk,wrapped_master_key:a,pbk:s.toJSON(),master_key_wrapped_prk:o}).toPromise()];case 6:return c=p.sent(),console.log(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=p.sent(),console.log("requestRest done: ",u),[2,{requestResetResult:c,signUpResult:u}]}}))}))},t}(zr),e.TpPasswordResetUserService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetUserService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(te),n.ɵɵinject(ve),n.ɵɵinject(ye),n.ɵɵinject(Se),n.ɵɵinject(ii),n.ɵɵinject(Wn),n.ɵɵinject(t.HttpClient),n.ɵɵinject(d.AuthClass),n.ɵɵinject(oi))},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:[te]}]},{type:ve},{type:ye},{type:Se},{type:ii},{type:Wn},{type:t.HttpClient},{type:d.AuthClass},{type:oi}]},e.TpPasswordResetUserService=R([Rr({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 K(t,e),t.prototype.getSharedResets=function(){return D(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return[4,this.query({query:pr})];case 1:return[2,e.sent().sharedTpPasswordResets]}}))}))},t.prototype.getSharedReset=function(e){return D(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return[4,this.query({query:dr,variables:{id:e}})];case 1:return[2,t.sent().sharedTpPasswordReset]}}))}))},t.prototype.activeRequestOrRaise=function(e){var t=e.sharedRequest.claim.state;if(t!==Wr.CLAIMED)throw new ee("Claim is already in "+t+" state.")},t.prototype.rejectRequest=function(e){return this.mutate(this.rejectRequestMutation(e))},t.prototype.rejectRequestMutation=function(e){return D(this,void 0,void 0,(function(){var t;return A(this,(function(n){switch(n.label){case 0:return[4,this.getSharedReset(e)];case 1:return t=n.sent(),this.activeRequestOrRaise(t),[2,xr.create(t.sharedRequest.claim.asClaimApprovers.edges.filter((function(e){return e.node.state===Zr.CLAIMED})).map((function(e){return new Nr({mutation:mr,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 D(this,void 0,void 0,(function(){var t,n,r,i,a,s=this;return A(this,(function(o){switch(o.label){case 0:return[4,this.getSharedReset(e)];case 1:return t=o.sent(),this.activeRequestOrRaise(t),[4,p.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===Zr.CLAIMED})),a=(i=xr).create,[4,Promise.all(r.map((function(e){return D(s,void 0,void 0,(function(){var t,r,i,a=this;return A(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 D(a,void 0,void 0,(function(){var r,i;return A(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 Nr({mutation:fr,variables:{input:r}})]}}))}))})))];case 3:return[2,a.apply(i,[o.sent()])]}}))}))},t}(zr),e.TpPasswordResetRequestService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetRequestService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(ye))},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:ye}]},e.TpPasswordResetRequestService=R([Rr({ngZoneName:"ngZone"})],e.TpPasswordResetRequestService),e.AcceptTrustedPartyInvite=ds,e.AccessFields=bt,e.AddScenarioApproverMutation=Xo,e.AddScenarioClaimantMutation=Fo,e.AddScenarioReceiverDirectoryMutation=Go,e.ApiContactCard=He,e.ApiCurrentUser=We,e.ApproveScenarioClaimMutation=mc,e.ArchiveDirectoryMutation=Nt,e.Assembly=ti,e.CancelScenarioClaimMutation=fc,e.CancelTrustedPartyInvitationMutation=Os,e.CancelUserDeleteMutation=vi,e.Category=Pa,e.CategoryFields=kt,e.CategoryFilter=St,e.CategoryMetaService=Ta,e.CategoryService=Oa,e.ClaimantFields=To,e.CognitoChallengeUser=Cn,e.CompleteOtkMutation=Ti,e.ConfirmTrustedPartyInvite=ls,e.ContactCardAddress=Ye,e.ContactCardName=Ze,e.CreateCategoryMutation=jt,e.CreateContactCardMutation=Be,e.CreateFileMutation=Ia,e.CreateFileQuery=xe,e.CreateLbopQuery=Wi,e.CreateRecordContainerMutation=va,e.CreateRecordMutation=fa,e.CreateScenarioApproverAssemblyMutation=Ho,e.CreateScenarioClaimMutation=vc,e.CreateScenarioMutation=pc,e.CreateScenarioReceiverMutation=qo,e.CreateSubAssembliesInput=Pp,e.CreateTpPasswordResetInput=Dp,e.CreateVaultMutation=Tt,e.CurrentCategory=Ra,e.CurrentUser=Kn,e.CurrentUserKey=Ve,e.CurrentUserQuery=Ge,e.CurrentUserSharedKeyQuery=Di,e.DECRYPT_OPTIONS_DEFAULT=pe,e.DEFAULT_BREADCRUMB_DEPTH=5,e.DEFAULT_DESCENDANTS_DEPTH=5,e.DeclineTrustedPartyInvitationMutation=$s,e.DefaultCategory=ka,e.DefaultProcessorOptions=Dr,e.DefaultVaultFilter=gt,e.DeleteCategoryMutation=Ft,e.DeleteFileMutation=ba,e.DeleteLbopQuery=Hi,e.DeleteRecordMutation=Sa,e.DeleteScenarioApproverAssemblyMutation=Yo,e.DeleteScenarioClaimantMutation=Lo,e.DeleteScenarioMutation=lc,e.DeleteScenarioReceiverDirectoryMutation=Qo,e.DeleteScenarioReceiverMutation=_o,e.DeleteTrustedPartyMutation=js,e.DirectoryQuery=Le,e.DisableScenarioMutation=hc,e.EnableScenarioMutation=yc,e.EncryptionService=ye,e.Features=wn,e.FetchKeyGraphField=Fe,e.FileQuery=Ne,e.FileService=ci,e.FoundTrustedParty=us,e.GetAllScenarioClaimsQuery=uc,e.GetAllScenarioIdsQuery=sc,e.GetAllScenariosQuery=oc,e.GetAllSharedScenariosQuery=ic,e.GetAllTrustedPartiesQuery=As,e.GetCategoriesQuery=Pt,e.GetCategoryKeyIdQuery=Ot,e.GetCategoryQuery=$t,e.GetMySharedCategoriesQuery=At,e.GetRecordQuery=ha,e.GetRootDirectoryIdsQuery=Kt,e.GetScenarioApproverQuery=zo,e.GetScenarioClaimantQuery=Mo,e.GetScenarioQuery=cc,e.GetScenarioReceiverQuery=Uo,e.GetSharedScenarioQuery=rc,e.GetTrustedPartiesQuery=Ds,e.GetTrustedPartyCategoriesQuery=Dt,e.GetTrustedPartyQuery=Es,e.GetTrustedPartyScenariosQuery=ac,e.GetVaultsQuery=Rt,e.IdleService=Bn,e.InitiateOtkMutation=Oi,e.InviteTrustedParty=ps,e.KeyExchangeFields=Pi,e.KeyExchangeQuery=Ei,e.KeyExchangeService=Mi,e.KeyExchangeTokenQuery=$i,e.KeyExchangesQuery=Ai,e.KeyFactoryService=ve,e.KeyGraphField=Me,e.KeyGraphFragment=Te,e.KeyGraphService=Se,e.KeyMetaService=qt,e.KeyService=ge,e.LR_CONFIG=te,e.LbopQuery=Yi,e.LbopService=Xi,e.LbopsQuery=zi,e.LifeReadyAuthService=oi,e.LifeReadyModule=$c,e.LoadedCategoryTree=ja,e.LoginHistoryQuery=fi,e.LoginResult=Pn,e.LrApolloService=Ie,e.LrAuthException=H,e.LrBadArgumentException=q,e.LrBadLogicException=G,e.LrBadRequestException=W,e.LrBadStateException=ee,e.LrCodeMismatchException=B,e.LrConcurrentAccessException=Q,e.LrEncryptionException=Z,e.LrError=N,e.LrException=L,e.LrExpiredCodeException=z,e.LrExpiredException=X,e.LrGraphQLService=e.ɵb,e.LrLockedException=V,e.LrMergedMutation=xr,e.LrMutation=Nr,e.LrMutationBase=Fr,e.LrNotFoundException=_,e.LrRecord=xa,e.LrService=zr,e.LrSuspiciousException=J,e.LrUnsupportedException=Y,e.MainContactCard=et,e.MainContactCardFields=Xe,e.MainContactCardPlainFields=tt,e.MainContactCardProperty=ze,e.MessageQuery=xi,e.MessageService=Ui,e.MoveDirectoryQuery=_e,e.MoveFileQuery=Je,e.NewAttachment=Ua,e.NewCategory=Aa,e.NewOrUpdatedAttachment=Ja,e.NewRecord=qa,e.NewScenario=Io,e.NewScenarioApprovalGroup=Co,e.NewScenarioApprover=ko,e.NewScenarioClaimant=bo,e.NewScenarioReceiver=wo,e.OwnerPlainDataJson=Yc,e.PassIdpApiResult=rt,e.PasswordCheck=Vn,e.PasswordService=Wn,e.PersistService=fe,e.Plan=jc,e.PlanService=In,e.ProfileDetailsService=Ec,e.ProfileService=bn,e.Quorum=ri,e.ReceiveScenarioClaimMutation=Sc,e.ReceiverFields=xo,e.RecordAttachment=La,e.RecordAttachmentFilter=ya,e.RecordAttachmentService=Ma,e.RecordContentFilter=la,e.RecordField=Na,e.RecordFilter=It,e.RecordService=Ga,e.RecordType=Ba,e.RecordTypeField=Va,e.RecordTypeFieldOption=Qa,e.RecordTypeService=Ya,e.RecordTypeSummary=Wa,e.RegisterResult=Rn,e.RegisterService=ea,e.RejectScenarioClaimMutation=gc,e.RequestUserDeleteMutation=hi,e.ResetScenarioMutation=Ic,e.RespondOtkMutation=ji,e.RevertFileQuery=qe,e.ScenarioApproverService=Cc,e.ScenarioClaim=$o,e.ScenarioClaimantService=kc,e.ScenarioReceiverService=wc,e.ScenarioService=Pc,e.ScenarioSetupService=Dc,e.ScenarioSummary=Eo,e.SecretShare=Xr,e.SendMessageMutation=Li,e.ShareCategoryMutation=Ts,e.SharedAccess=Ca,e.SharedScenario=jo,e.SharedScenarioSummary=Oo,e.SharedTrustedPartyDetails=is,e.SharedVaultFeature=os,e.Slip39Service=ii,e.StripeBillingPortalSession=Nc,e.StripeCheckoutSession=Fc,e.SubAssembly=ei,e.SubAssemblyFields=Wo,e.SubQuorum=ni,e.Subscription=Tc,e.TPFeatures=ss,e.TrustedParties=rs,e.TrustedParty=cs,e.TrustedPartyDetails=it,e.TrustedPartyInvite=as,e.TrustedPartyProperties=Rs,e.TrustedPartyRole=ts,e.TrustedPartyService=Fs,e.TwoFactorService=na,e.UnarchiveDirectoryMutation=Lt,e.UnshareCategoryMutation=Ms,e.UpdateCategoryMutation=Mt,e.UpdateContactCardMutation=Qe,e.UpdateFileQuery=Ue,e.UpdateLbopQuery=Zi,e.UpdateRecordContainerMutation=ma,e.UpdateRecordMutation=ga,e.UpdateScenario=Ko,e.UpdateScenarioApproverAssemblyMutation=Zo,e.UpdateScenarioApproverMutation=ec,e.UpdateScenarioApproverSubAssemblyMutation=bc,e.UpdateScenarioClaimantMutation=No,e.UpdateScenarioMutation=dc,e.UpdateScenarioReceiverDirectoryMutation=Bo,e.UpdateScenarioReceiverMutation=Jo,e.UpdateSubAssembliesInput=Rp,e.UpdateTpPasswordResetInput=Ap,e.UpdatedCategory=Ea,e.UpdatedRecord=_a,e.UpdatedScenarioApprovalGroup=Ro,e.UpdatedScenarioApprover=Do,e.UpdatedScenarioClaimant=Po,e.UpdatedScenarioReceiver=Ao,e.UserKeys=me,e.UserPlan=Mc,e.UserQuery=yi,e.UserService=mi,e.UserSharedKeyFields=Ri,e.VERIFY_OPTIONS_DEFAULT=ue,e.Vault=$a,e.VaultCategory=Da,e.VaultFields=wt,e.VaultRecord=Ka,e.VaultRecordType=wa,e.WebCryptoService=he,e.WrappedContent=xt,e.WrappingKey=Ut,e.asJwk=le,e.awsFetch=Qi,e.configureAmplifyAuth=Vi,e.configureApollo=re,e.debugPopulateRecords=function(e,t,n,r){return D(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,y,h,v,f,m;return A(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=E(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=E(c.subCategories),p=u.next(),g.label=6;case 6:return p.done?[3,9]:(d=p.value).allowRecords?[4,Uc(e,t,n,d.id,r)]:[3,8];case 7:g.sent(),g.label=8;case 8:return p=u.next(),[3,6];case 9:return[3,12];case 10:return l=g.sent(),f={error:l},[3,12];case 11:try{p&&!p.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=Mr,e.gqlTyped=Tn,e.handleApolloError=T,e.handleCognitoCallback=function(e){return new Promise((function(t,n){return e((function(e,r){return e?n(e):t(r)}))}))},e.initialiseAuth=si,e.isSymmetricKey=de,e.mapUserPlans=Sn,e.parentCategoriesField=Et,e.processConnection=Ar,e.sha256=function(e){return D(this,void 0,void 0,(function(){var t,n,r;return A(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=Rr,e.ɵe=ys,e.ɵf=vs,e.ɵg=zr,Object.defineProperty(e,"__esModule",{value:!0})}));
16
+ //# sourceMappingURL=lifeready-core.umd.min.js.map